diff --git a/src/contractsTypes/tezos/NFT.types.ts b/src/contractsTypes/tezos/NFT.types.ts index 154bb24..1c423ef 100644 --- a/src/contractsTypes/tezos/NFT.types.ts +++ b/src/contractsTypes/tezos/NFT.types.ts @@ -22,6 +22,13 @@ export type Storage = { } > }; + token_metadata: BigMap< + nat, + { + token_id: nat; + token_info: MMap; + } + >; metadata: BigMap; admin: address; }; diff --git a/src/handler/tezos/utils/nftData.ts b/src/handler/tezos/utils/nftData.ts index 97a7517..17596b4 100644 --- a/src/handler/tezos/utils/nftData.ts +++ b/src/handler/tezos/utils/nftData.ts @@ -2,7 +2,12 @@ import type { TezosToolkit } from "@taquito/taquito"; import { Tzip16Module, bytesToString, tzip16 } from "@taquito/tzip16"; import type { NFTContractType } from "../../../contractsTypes/tezos/NFT.types"; -import { tas } from "../../../contractsTypes/tezos/type-aliases"; +import { + type MMap, + type bytes, + type nat, + tas, +} from "../../../contractsTypes/tezos/type-aliases"; import type { LogInstance } from "../../types"; export default async function nftData( @@ -14,9 +19,21 @@ export default async function nftData( const getNftTokenMetaData = async (contract: string, tokenId: bigint) => { const nftContract = await provider.contract.at(contract); - const tokenMetaData = await ( - await nftContract.storage() - ).tokens.token_metadata.get(tas.nat(tokenId.toString())); + let tokenMetaData: { + token_id: nat; + token_info: MMap; + }; + + try { + tokenMetaData = await ( + await nftContract.storage() + ).tokens.token_metadata.get(tas.nat(tokenId.toString())); + } catch (ex) { + tokenMetaData = await (await nftContract.storage()).token_metadata.get( + tas.nat(tokenId.toString()), + ); + } + const metaDataInHex = tokenMetaData.token_info.get(""); return bytesToString(metaDataInHex); };