diff --git a/package.json b/package.json index 5415a9d..6b07534 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@itheum/sdk-mx-data-nft", - "version": "3.4.0", + "version": "3.5.0", "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 8d75524..16c94d1 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -179,6 +179,7 @@ export function parseDataNft(value: NftType): DataNft { : value.type === NftEnumType.NonFungibleESDT ? 1 : 0, + type: value.type, royalties: value.royalties !== null ? value.royalties / 100 : 0, nonce: value.nonce, collection: value.collection, diff --git a/src/datanft.ts b/src/datanft.ts index e628e9d..ffc94e4 100644 --- a/src/datanft.ts +++ b/src/datanft.ts @@ -27,7 +27,12 @@ import { ErrNetworkConfig, ErrTooManyItems } from './errors'; -import { DataNftType, NftType, ViewDataReturnType } from './interfaces'; +import { + DataNftType, + NftEnumType, + NftType, + ViewDataReturnType +} from './interfaces'; import BigNumber from 'bignumber.js'; export class DataNft implements DataNftType { @@ -46,11 +51,13 @@ export class DataNft implements DataNftType { readonly nonce: number = 0; readonly collection: string = ''; readonly balance: BigNumber.Value = 0; + readonly type: NftEnumType = NftEnumType.SemiFungibleESDT; readonly owner: string = ''; // works if tokenIdentifier is an NFT readonly overrideDataMarshal: string = ''; readonly overrideDataMarshalChainId: string = ''; readonly isDataNFTPH: boolean = false; readonly extraAssets: string[] = []; + readonly media: { url: string; originalUrl: string; @@ -375,15 +382,35 @@ export class DataNft implements DataNftType { } try { + let chainId; + + if (this.overrideDataMarshalChainId === '') { + chainId = + DataNft.networkConfiguration.chainID === 'D' + ? 'ED' + : DataNft.networkConfiguration.chainID == '1' + ? 'E1' + : ''; + } else if (this.overrideDataMarshalChainId === 'D') { + chainId = 'ED'; + } else if (this.overrideDataMarshalChainId === '1') { + chainId = 'E1'; + } else { + chainId = this.overrideDataMarshalChainId; + } + + let dataMarshal; + if (this.overrideDataMarshal === '') { + dataMarshal = this.dataMarshal; + } else { + dataMarshal = this.overrideDataMarshal; + } + let url = `${this.dataMarshal}/access?nonce=${p.signedMessage}&NFTId=${ this.collection }-${numberToPaddedHex(this.nonce)}&signature=${ signResult.signature - }&chainId=${ - DataNft.networkConfiguration.chainID == 'D' - ? 'ED' - : DataNft.networkConfiguration.chainID - }&accessRequesterAddr=${signResult.addrInHex}`; + }&chainId=${chainId}&accessRequesterAddr=${signResult.addrInHex}`; type FetchConfig = { [key: string]: any; @@ -522,9 +549,13 @@ export class DataNft implements DataNftType { chainId = DataNft.networkConfiguration.chainID === 'D' ? 'ED' - : DataNft.networkConfiguration.chainID; + : DataNft.networkConfiguration.chainID == '1' + ? 'E1' + : ''; } else if (this.overrideDataMarshalChainId === 'D') { chainId = 'ED'; + } else if (this.overrideDataMarshalChainId === '1') { + chainId = 'E1'; } else { chainId = this.overrideDataMarshalChainId; } diff --git a/src/interfaces.ts b/src/interfaces.ts index 68d5395..c9bfc67 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -53,6 +53,7 @@ export interface NftType { export interface DataNftType { readonly tokenIdentifier: string; readonly nftImgUrl: string; + readonly type: NftEnumType; readonly dataPreview: string; readonly dataStream: string; readonly dataMarshal: string; diff --git a/src/sft-minter.ts b/src/sft-minter.ts index c42a1bc..bf7e355 100644 --- a/src/sft-minter.ts +++ b/src/sft-minter.ts @@ -301,7 +301,7 @@ export class SftMinter extends Minter { nftStorageToken?: string; extraAssets?: string[]; } - ): Promise { + ): Promise<{ imageUrl: string; metadataUrl: string; tx: Transaction }> { const { imageUrl, traitsUrl, nftStorageToken, extraAssets } = options ?? {}; const tokenNameValidator = new StringValidator() @@ -434,6 +434,10 @@ export class SftMinter extends Minter { chainID: this.chainID }); - return mintTx; + return { + imageUrl: imageOnIpfsUrl, + metadataUrl: metadataOnIpfsUrl, + tx: mintTx + }; } }