From 15b7b71af0fa1ebf14132332c28240b4740896f1 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Tue, 25 Jun 2024 12:54:02 +0200 Subject: [PATCH] add basetokenURI --- examples/gno.land/p/demo/grc/grc721/grc721.gno | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/gno.land/p/demo/grc/grc721/grc721.gno b/examples/gno.land/p/demo/grc/grc721/grc721.gno index e68aabdf46b..7dcbce7e7d6 100644 --- a/examples/gno.land/p/demo/grc/grc721/grc721.gno +++ b/examples/gno.land/p/demo/grc/grc721/grc721.gno @@ -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 { @@ -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 {