diff --git a/package.json b/package.json index 0066bf8..e5a8092 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@itheum/sdk-mx-data-nft", - "version": "3.6.0-alpha.7", + "version": "3.6.0-alpha.8", "description": "SDK for Itheum's Data NFT Technology on MultiversX Blockchain", "main": "out/index.js", "types": "out/index.d.js", diff --git a/src/common/utils.ts b/src/common/utils.ts index f2cd450..e82a0b2 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -180,8 +180,17 @@ export function parseRefund(value: any): Refund { export function parseDataNft(value: NftType): DataNft { let attributes; + let metadataFile; + try { attributes = DataNft.decodeAttributes(value.attributes); // normal attributes + + // get the metadata file, assume for now its the 2nd item. (1 = img, 2 = json, 3.... extra assets) + metadataFile = value.uris?.[1]; + + if (metadataFile) { + metadataFile = Buffer.from(metadataFile, 'base64').toString('ascii'); + } } catch (error: any) { try { attributes = { @@ -198,6 +207,7 @@ export function parseDataNft(value: NftType): DataNft { throw new ErrParseNft(error.message); } } + const returnValue = { tokenIdentifier: value.identifier, nftImgUrl: value.url ?? '', @@ -218,8 +228,10 @@ export function parseDataNft(value: NftType): DataNft { ?.slice(2) .map((uri) => Buffer.from(uri, 'base64').toString('ascii')) ?? [], media: value.media, + metadataFile, ...attributes }; + return new DataNft(returnValue); }