Are there any downsides to how I'm declaring the token_metadata in the @offchain_view
below? Loading the data from storage appears to work as expected when testing it on tzcomet and BCD, though I just want to confirm this approach looks good.
I want to build out the attributes
JSON array to be compliant with the tzip-21 interface, but doing the string manipulation for that is going to be a huge pain. Is there a utility I could import for this? Are there any code reference for a tzip-21 token_metadata offchain_view that have the attributes map? Thanks in advance.
@sp.offchain_view(pure = True)
def token_metadata(self, tok):
sp.set_type(tok, sp.TNat)
sp.result(sp.record(token_id=tok, token_info={
"name": self.data.token_metadata[tok].token_info["name"],
"symbol": self.data.token_metadata[tok].token_info["symbol"],
"decimals": self.data.token_metadata[tok].token_info["decimals"],
"description": Utils.Bytes.of_string("A unique TezosAsset NFT representing someone's purchased asset."),
"isBooleanAmount": Utils.Bytes.of_string("true"),
"artifactUri": Utils.Bytes.of_string(string_concat("http://abcd.xyz/asset/", string_of_nat(self.data.arr[tok].x))),
# TODO: encode x,y under JSON attributes array
"x": Utils.Bytes.of_string(self.string_of_nat(self.data.arr[tok].x)),
"y": Utils.Bytes.of_string(self.string_of_nat(self.data.arr[tok].y))
}))