-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add native asset support to SEP-24 #1363
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
886f7c8
Mention XLM in the SEP-24 docs
philipliu d84df67
Fix changelog and date
philipliu 6d5084f
Fix withdrawal account
philipliu 944e8c5
Add note about XLM
philipliu bf219b8
Prettier
philipliu f5563ac
Apply suggestions from code review
philipliu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
native
is a valid asset code on the network, so I don't think SEP-24 should prevent an issued asset with the namenative
from being used.I think we would need to allow the case where
asset_code
is"native"
andasset_issuer
has a value, and in that case treat the asset as credit / issued. That would make this change truly backwards compatible.To make sure we're talking about all options, there are two ways we've preferred to represent assets as strings:
Three elements:
asset_type
with valid values beingnative
,credit_alphanum4
,credit_alphanum12
asset_code
asset_issuer
One string element, based on SEP-11, where:
"native"
"ABC:GJKJASD..."
I understand the latter format is unrealistic given the existing API.
The first form may be reasonable with some subset of values such as
native
andcredit
given the SEP-24 API already places code and issuer into separate fields.cc @JakeUrban
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a "native" asset, that is issued by someone, and it's configured by the anchor, we will have a undefined behavior for the request where only
asset_code
is specified. Anchor wouldn't know if it'sXLM
ornative:<issuer>
asset.This is really a corner-case, and I doubt it'll happen in real production environment, but worth considering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this edge case exists because the
asset_issuer
field is optional?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's because
asset_issuer
is optional.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see two ways of supporting an issued
native
token.asset_issuer
to be specified. I can't comment on if any wallets are leavingasset_issuer
as null today, but as far as breaking changes go, I don't think it's too difficult to migrate over.asset_code
andasset_issuer
with the goal of eventually deprecating theasset_code
andasset_issuer
pair.Of these two options, I prefer 2. It lets us move to using SEP-38/11 format everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both options assume that it is a good thing to make the issuer required in the API. I'm wondering what the context is on how it came to be optional. @JakeUrban do you have any context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the
asset_issuer
field was optional from the start (at least of my time at the SDF).The good news is that while there may be an asset with code
native
that exists on the network, the only time this becomes problematic is if an anchor wants to support both thenative
non-XLM asset and XLM itself. In this corner case, the anchor would have to require theasset_issuer
field in order to differentiate.I think this situation is acceptable in order to avoid adding something like
asset_type
to the list parameters.Longer-term, I think we do probably need to introduce an
asset
parameter that can be used as a unique identifier for all on-chain assets and deprecate the existing set of parameters (cc @philipliu), but I wouldn't want to make that parameter required in order to anchor XLM or other assets (such as AMM shares?), so we should find a backwards-compatible solution in the meantime.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JakeUrban For true native (rather than credit native) should the SEP require
asset_issuer: null
? This would be one way to do as you say, but make it deterministic.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I think thats appropriate, although I wouldn't be surprised if custom anchor implementations skip. Still good to include it in the specification though.