Skip to content

Commit

Permalink
add basetokenURI
Browse files Browse the repository at this point in the history
  • Loading branch information
leohhhn committed Jun 25, 2024
1 parent 1525fbb commit 15b7b71
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/gno.land/p/demo/grc/grc721/grc721.gno
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Collection struct {
balances *avl.Tree // std.Address > # of owned tokens
operatorApprovals *avl.Tree // "OwnerAddress:OperatorAddress" -> bool
tokenData *avl.Tree // tokenID > *tokenData
baseURI string // baseURI
}

type tokenData struct {
Expand Down Expand Up @@ -114,12 +115,14 @@ func (c *Collection) IsApprovedForAll(owner, operator std.Address) bool {
return true
}

// TokenURI returns the URI of a specific token, prepended with the baseURI for the collection
func (c Collection) TokenURI(tokenId string) string {
c.mustBeOwned(tokenId)
rawData, _ := c.tokenData.Get(tokenId)
return rawData.(*tokenData).uri
return c.baseURI + rawData.(*tokenData).uri
}

// SetTokenURI sets a URI for a specific token
func (c *Collection) SetTokenURI(tokenId string, tokenURI string) string {
rawData, exists := c.tokenData.Get(tokenId)
if !exists {
Expand Down

0 comments on commit 15b7b71

Please sign in to comment.