Skip to content

Commit

Permalink
feature: include the metadata file in the parseDataNft method
Browse files Browse the repository at this point in the history
  • Loading branch information
newbreedofgeek committed Aug 22, 2024
1 parent ce454ac commit d759908
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 12 additions & 0 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -198,6 +207,7 @@ export function parseDataNft(value: NftType): DataNft {
throw new ErrParseNft(error.message);
}
}

const returnValue = {
tokenIdentifier: value.identifier,
nftImgUrl: value.url ?? '',
Expand All @@ -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);
}

Expand Down

0 comments on commit d759908

Please sign in to comment.