Skip to content

Commit

Permalink
feature: updates to support nfme id vault launch and img selection
Browse files Browse the repository at this point in the history
  • Loading branch information
newbreedofgeek committed Aug 16, 2024
1 parent 45e32c0 commit c123298
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
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.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",
Expand Down
25 changes: 22 additions & 3 deletions src/nft-minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -177,6 +179,8 @@ export class NftMinter extends Minter {
antiSpamTokenIdentifier?: string;
antiSpamTax?: BigNumber.Value;
extraAssets?: string[];
imgGenBg?: string;
imgGenSet?: string;
}
): Promise<Transaction> {
const {
Expand All @@ -185,7 +189,9 @@ export class NftMinter extends Minter {
nftStorageToken,
antiSpamTokenIdentifier,
antiSpamTax,
extraAssets
extraAssets,
imgGenBg,
imgGenSet
} = options ?? {};

// deep validate all mandatory URLs
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
});

Expand Down
29 changes: 26 additions & 3 deletions src/sft-minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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()
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
});

Expand Down

0 comments on commit c123298

Please sign in to comment.