From c1232981b32c922964ec97a4a75de8795a193910 Mon Sep 17 00:00:00 2001 From: Mark Paul Date: Fri, 16 Aug 2024 14:27:18 +1000 Subject: [PATCH] feature: updates to support nfme id vault launch and img selection --- package.json | 2 +- src/nft-minter.ts | 25 ++++++++++++++++++++++--- src/sft-minter.ts | 29 ++++++++++++++++++++++++++--- 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index e6059f6..71bcdd1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@itheum/sdk-mx-data-nft", - "version": "3.6.0-alpha.5", + "version": "3.6.0-alpha.6", "description": "SDK for Itheum's Data NFT Technology on MultiversX Blockchain", "main": "out/index.js", "types": "out/index.d.js", diff --git a/src/nft-minter.ts b/src/nft-minter.ts index cd761ec..792902e 100644 --- a/src/nft-minter.ts +++ b/src/nft-minter.ts @@ -160,6 +160,8 @@ export class NftMinter extends Minter { * - antiSpamTokenIdentifier: the anti spam token identifier to be used for the minting * - antiSpamTax: the anti spam tax to be set for the Data NFT-FT with decimals. Needs to be greater than 0 and should be obtained in real time via {@link viewMinterRequirements} prior to calling mint. * - extraAssets [optional] extra URIs to attached to the NFT. Can be media files, documents, etc. These URIs are public + * - imgGenBg: [optional] the custom series bg to influence the image generation service + * - imgGenSet: [optional] the custom series layer set to influence the image generation service */ async mint( senderAddress: IAddress, @@ -177,6 +179,8 @@ export class NftMinter extends Minter { antiSpamTokenIdentifier?: string; antiSpamTax?: BigNumber.Value; extraAssets?: string[]; + imgGenBg?: string; + imgGenSet?: string; } ): Promise { const { @@ -185,7 +189,9 @@ export class NftMinter extends Minter { nftStorageToken, antiSpamTokenIdentifier, antiSpamTax, - extraAssets + extraAssets, + imgGenBg, + imgGenSet } = options ?? {}; // deep validate all mandatory URLs @@ -213,8 +219,20 @@ export class NftMinter extends Minter { 'NFT Storage token is required when not using custom image and traits' ); } + + // create the img generative service API based on user options + let imgGenServiceApi = `${this.imageServiceUrl}/v1/generateNFTArt?hash=${dataNftHash}`; + + if (imgGenBg && imgGenBg.trim() !== '') { + imgGenServiceApi += `&bg=${imgGenBg.trim()}`; + } + + if (imgGenSet && imgGenSet.trim() !== '') { + imgGenServiceApi += `&set=${imgGenSet.trim()}`; + } + const { image, traits } = await createFileFromUrl( - `${this.imageServiceUrl}/v1/generateNFTArt?hash=${dataNftHash}`, + imgGenServiceApi, datasetTitle, datasetDescription, dataPreviewUrl, @@ -275,12 +293,13 @@ export class NftMinter extends Minter { for (const extraAsset of extraAssets ?? []) { data.addArg(new StringValue(extraAsset)); } + const mintTx = new Transaction({ value: antiSpamTokenIdentifier == 'EGLD' ? antiSpamTax : 0, data: data.build(), sender: senderAddress, receiver: this.contract.getAddress(), - gasLimit: 60000000, + gasLimit: 100_000_000, chainID: this.chainID }); diff --git a/src/sft-minter.ts b/src/sft-minter.ts index bf7e355..28d86b4 100644 --- a/src/sft-minter.ts +++ b/src/sft-minter.ts @@ -280,6 +280,8 @@ export class SftMinter extends Minter { * - nftStorageToken: the nft storage token to be used to upload the image and metadata to IPFS * - extraAssets: [optional] extra URIs to attached to the NFT. Can be media files, documents, etc. These URIs are public * - donationPercentage: [optional] the donation percentage to be set for the Data NFT-FT supply to be sent to the donation + * - imgGenBg: [optional] the custom series bg to influence the image generation service + * - imgGenSet: [optional] the custom series layer set to influence the image generation service * */ async mint( @@ -300,9 +302,18 @@ export class SftMinter extends Minter { traitsUrl?: string; nftStorageToken?: string; extraAssets?: string[]; + imgGenBg?: string; + imgGenSet?: string; } ): Promise<{ imageUrl: string; metadataUrl: string; tx: Transaction }> { - const { imageUrl, traitsUrl, nftStorageToken, extraAssets } = options ?? {}; + const { + imageUrl, + traitsUrl, + nftStorageToken, + extraAssets, + imgGenBg, + imgGenSet + } = options ?? {}; const tokenNameValidator = new StringValidator() .notEmpty() @@ -366,8 +377,20 @@ export class SftMinter extends Minter { 'NFT Storage token is required when not using custom image and traits' ); } + + // create the img generative service API based on user options + let imgGenServiceApi = `${this.imageServiceUrl}/v1/generateNFTArt?hash=${dataNftHash}`; + + if (imgGenBg && imgGenBg.trim() !== '') { + imgGenServiceApi += `&bg=${imgGenBg.trim()}`; + } + + if (imgGenSet && imgGenSet.trim() !== '') { + imgGenServiceApi += `&set=${imgGenSet.trim()}`; + } + const { image, traits } = await createFileFromUrl( - `${this.imageServiceUrl}/v1/generateNFTArt?hash=${dataNftHash}`, + imgGenServiceApi, datasetTitle, datasetDescription, dataPreviewUrl, @@ -430,7 +453,7 @@ export class SftMinter extends Minter { data: data.build(), sender: senderAddress, receiver: this.contract.getAddress(), - gasLimit: 80_000_000, + gasLimit: 100_000_000, chainID: this.chainID });