-
Notifications
You must be signed in to change notification settings - Fork 7
Feat/nft example #91
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
Open
elizabethengelman
wants to merge
31
commits into
loambuild:main
Choose a base branch
from
elizabethengelman:feat/nft-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/nft example #91
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
4849202
Update dev_dependencies -> dev-dependencies in examples
elizabethengelman 8e6d9c9
Add NFT example
elizabethengelman 9cf14ea
Fix build errors
elizabethengelman e1404c3
Change NFT ids to u32s
elizabethengelman 4f31132
Refactor so that the nft id is generated in mint
elizabethengelman e647a55
Formatting & clippy
elizabethengelman a1fb4ff
Fully qualify soroban_sdk types in subcontract traits
elizabethengelman aabcdfa
Panic on transfer if the NFT id does not exist
elizabethengelman 2c7fefd
Fix owner_id check
elizabethengelman 1bad366
Update examples/soroban/nft/src/nft.rs
elizabethengelman 432c914
Cargo fmt updates
elizabethengelman abe69e2
Make ft_init fn accept &self instead of &mut self
elizabethengelman 765fbf3
Update examples/soroban/nft/src/nft.rs
elizabethengelman 1aa5b11
Fix owners_to_nft_ids behavior 🙈
elizabethengelman b46b4c5
Move nft example to loam-cli dir
elizabethengelman b18d6d6
Use derive_contract for example nft
elizabethengelman 959952a
Refactor owners_to_nft_ids
elizabethengelman 6e41c99
build: 'loam build' changes Cargo.lock
chadoh 95d2161
fix: use doc comments for subcontracts
chadoh ba7af15
Remove extraneous comments in nft.rs
elizabethengelman ccaa9ae
Remove loam-soroban-sdk from Cargo.toml as it is re-exported from loa…
elizabethengelman d3acb1a
Require auth from the admin for minting
elizabethengelman cc22d8b
Bump total count limit
elizabethengelman 553f401
Remove admin attribute from MyNonFungibleToken
elizabethengelman ec7df81
WIP: add happy path tests for nft example
elizabethengelman 7e7cfbf
Apply suggestions from code review
elizabethengelman 5655fd8
Cleanup happy path test
elizabethengelman 3d83b38
Add tests for error cases
elizabethengelman 3a6507c
Ensure that panicks are happening for the right reasons
elizabethengelman 63ed1f4
Factor out some commonly use fns in nft test
elizabethengelman dc9ed7c
Add Metadata type for NFT example
elizabethengelman 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 hidden or 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
This file contains hidden or 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.
Hmm it seems annoying that the metadata is untyped. Would be nice for consumers of the contract to know what the shape of the metadata is. But if is the current standard it's fine, but it's something we should push on to get agreement.
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 assumed that this was an intentional part of the spec, to allow rapid ecosystem experimentation and de facto standards to arise.
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.
Still annoying. You need to know how to deserialize the bytes...
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.
Yeah, that's a great point. From what I can tell from SEP-0039 best practices are to include a few key fields in the metadata: name, description, URL, issue, and code.
What if we start with those fields in a Metadata struct, and then if/when a standard emerges we can update the type? Not sure how difficult it will be to upgrade subcontracts, though with the ability to redeploy, that seems doable.
alternatively we could have them all be optional fields? 🤔
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.
Personally I think the first three should be required. And Perhaps we use
String?. It's again annoying because the all seem like that is what they will be. So perhaps we just put this forward as our standard. Other contracts will convert from Bytes to string anyway so we are just skipping a step.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.
Could we implement it as two separate subcontracts,
IsSep39andIsSep39Extension, or something like that? ImplementingIsSep39Extensionwould override all instances of metadata fromBytesto this suggestedMetadatastruct.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.
Or
IsSep39WithTypedMetadata, orIsTypedMetadata, or... ¯\_(ツ)_/¯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.
Finally getting back to addressing this.
I like the idea of creating an
IsSep39Metadatasubcontract, but I'm unsure how to implement it.IsSep39Metdatasubcontract with aMetadataassociated type:The issue I ran into with this is that our
derive_contractdoesn't generate the associate type over to the generated traitTypedMetadata. It just adds theImplgenerated type. I'm not sure if this is something we actually want to add to the macro, or if there is a better way to do this, but I moved on and tried a different idea...IsTypedMetadatainclude adeserialize_metadatafn that transforms theBytesmetadata into the MyNonFungibleTokenMetadata type. But that is still annoying because the user needs to serialize the metadata into Bytes when minting, etc.I'll keep thinking on this, but I could probably use another set of eyes on this.
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.
Also, for now I've just added a Metadata type like the following, maybe we can move forward with that and then continue to improve the standard/make sure that the Metadata can be flexible going forward.
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.
With
#[contracttype]the name of the type exported, so perhaps we could just called itSep39Metadata?