Skip to content

Commit

Permalink
update so nft doesn't allow optional slug, but has to include tokenid
Browse files Browse the repository at this point in the history
  • Loading branch information
matijamarjanovic committed Jan 17, 2025
1 parent c0ca4a5 commit 87aac01
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions examples/gno.land/r/matijamarjanovic/tokenhub/tokenhub.gno
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,16 @@ func RegisterToken(tokenGetter grc20.TokenGetter, slugs ...string) {
grc20reg.Register(tokenGetter, slug)
}

func RegisterNFT(nftGetter grc721.NFTGetter, slugs ...string) error {
// TokenId is mandatory for NFTs
func RegisterNFT(nftGetter grc721.NFTGetter, tokenId string) error {
nft := nftGetter()
_, ok := nft.(grc721.IGRC721CollectionMetadata)
if !ok {
return errors.New("NFT must implement IGRC721CollectionMetadata")
}

rlmPath := std.PrevRealm().PkgPath()
slug := ""
if len(slugs) > 0 {
slug = slugs[0]
}
key := fqname.Construct(rlmPath, slug)
key := fqname.Construct(rlmPath, tokenId)

if registeredNFTs.Has(key) {
return ErrNFTAlreadyRegistered
Expand Down

0 comments on commit 87aac01

Please sign in to comment.