From 396fe8a49257f0061898d0f371fcb20fd0d62975 Mon Sep 17 00:00:00 2001 From: Mark Paul Date: Thu, 18 Apr 2024 22:20:56 +1000 Subject: [PATCH 1/8] version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0f12109..b217660 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@itheum/sdk-mx-data-nft", - "version": "3.2.0", + "version": "3.2.1", "description": "SDK for Itheum's Data NFT Technology on MultiversX Blockchain", "main": "out/index.js", "types": "out/index.d.js", From aab01029e1418cd523ecf4ba6d0a565c7c5936ef Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 18 Apr 2024 12:21:25 +0000 Subject: [PATCH 2/8] chore: update package.json version to 3.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b217660..0f12109 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@itheum/sdk-mx-data-nft", - "version": "3.2.1", + "version": "3.2.0", "description": "SDK for Itheum's Data NFT Technology on MultiversX Blockchain", "main": "out/index.js", "types": "out/index.d.js", From cd253cbf1f0634e2fcf2470a63b76b30bbd71499 Mon Sep 17 00:00:00 2001 From: Mark Paul Date: Thu, 18 Apr 2024 22:29:16 +1000 Subject: [PATCH 3/8] version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0f12109..b217660 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@itheum/sdk-mx-data-nft", - "version": "3.2.0", + "version": "3.2.1", "description": "SDK for Itheum's Data NFT Technology on MultiversX Blockchain", "main": "out/index.js", "types": "out/index.d.js", From d5712d26aa20a4400447b594df3159d1bf8c8f1c Mon Sep 17 00:00:00 2001 From: Bucur David Date: Mon, 22 Apr 2024 14:58:50 +0300 Subject: [PATCH 4/8] feat: sft treasury donation implementation --- src/abis/datanftmint.abi.json | 144 +++++++++++++++++++++++++++++++++- src/interfaces.ts | 1 + src/sft-minter.ts | 63 ++++++++++++++- 3 files changed, 204 insertions(+), 4 deletions(-) diff --git a/src/abis/datanftmint.abi.json b/src/abis/datanftmint.abi.json index 9edc433..dafaf6b 100644 --- a/src/abis/datanftmint.abi.json +++ b/src/abis/datanftmint.abi.json @@ -9,11 +9,11 @@ }, "contractCrate": { "name": "datanftmint", - "version": "2.0.0" + "version": "3.0.0" }, "framework": { "name": "multiversx-sc", - "version": "0.47.4" + "version": "0.47.5" } }, "name": "DataNftMint", @@ -120,6 +120,15 @@ { "name": "lock_period_sec", "type": "u64" + }, + { + "name": "donation_percentage", + "type": "u64" + }, + { + "name": "extra_assets", + "type": "variadic", + "multi_arg": true } ], "outputs": [ @@ -149,6 +158,28 @@ ], "outputs": [] }, + { + "name": "setDonationTreasuryAddress", + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "setMaxDonationPercentage", + "mutability": "mutable", + "inputs": [ + { + "name": "percentage", + "type": "u64" + } + ], + "outputs": [] + }, { "name": "setIsPaused", "mutability": "mutable", @@ -262,6 +293,7 @@ }, { "name": "setBondContractAddress", + "onlyOwner": true, "mutability": "mutable", "inputs": [ { @@ -322,6 +354,26 @@ } ] }, + { + "name": "getDonationTreasuryAddress", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "Address" + } + ] + }, + { + "name": "getMaxDonationPercentage", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, { "name": "getWithdrawalAddress", "mutability": "readonly", @@ -631,6 +683,48 @@ } ], "outputs": [] + }, + { + "name": "get_bond_amount_for_lock_period", + "mutability": "mutable", + "inputs": [ + { + "name": "lock_period", + "type": "u64" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "send_bond", + "mutability": "mutable", + "inputs": [ + { + "name": "original_caller", + "type": "Address" + }, + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + }, + { + "name": "lock_period", + "type": "u64" + }, + { + "name": "payment", + "type": "EgldOrEsdtTokenPayment" + } + ], + "outputs": [] } ], "events": [ @@ -654,6 +748,26 @@ } ] }, + { + "identifier": "setDonationTreasuryAddress", + "inputs": [ + { + "name": "donation_treasury_address", + "type": "Address", + "indexed": true + } + ] + }, + { + "identifier": "setMaxDonationPercentage", + "inputs": [ + { + "name": "max_donation_percentage", + "type": "u64", + "indexed": true + } + ] + }, { "identifier": "whitelistEnableToggle", "inputs": [ @@ -926,6 +1040,11 @@ "name": "bond_amount", "type": "BigUint", "indexed": true + }, + { + "name": "extra_assets", + "type": "List", + "indexed": true } ] }, @@ -1006,6 +1125,23 @@ } ] }, + "EgldOrEsdtTokenPayment": { + "type": "struct", + "fields": [ + { + "name": "token_identifier", + "type": "EgldOrEsdtTokenIdentifier" + }, + { + "name": "token_nonce", + "type": "u64" + }, + { + "name": "amount", + "type": "BigUint" + } + ] + }, "UserDataOut": { "type": "struct", "fields": [ @@ -1060,6 +1196,10 @@ { "name": "frozen_nonces", "type": "List" + }, + { + "name": "max_donation_percentage", + "type": "u64" } ] } diff --git a/src/interfaces.ts b/src/interfaces.ts index 5b12341..75f5f53 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -102,6 +102,7 @@ export interface SftMinterRequirements { numberOfMintsForUser: number; totalNumberOfMints: number; contractWhitelistEnabled: boolean; + maxDonationPecentage: number; } export interface NftMinterRequirements { diff --git a/src/sft-minter.ts b/src/sft-minter.ts index 1836f68..d720314 100644 --- a/src/sft-minter.ts +++ b/src/sft-minter.ts @@ -83,7 +83,8 @@ export class SftMinter extends Minter { numberOfMintsForUser: returnValue.minted_per_user.toNumber(), totalNumberOfMints: returnValue.total_minted.toNumber(), addressFrozen: returnValue.frozen, - frozenNonces: returnValue.frozen_nonces.map((v: any) => v.toNumber()) + frozenNonces: returnValue.frozen_nonces.map((v: any) => v.toNumber()), + maxDonationPecentage: returnValue.max_donation_percentage.toNumber() }; return requirements; } else { @@ -184,6 +185,52 @@ export class SftMinter extends Minter { return setTreasuryAddressTx; } + /** + * Creates a `setDonationTreasuryAddress` transaction + * @param senderAddress The address of the sender, must be the admin of the contract + * @param donationTreasuryAddress The address of the donation treasury to collect the donation tax + */ + setDonationTreasuryAddress( + senderAddress: IAddress, + donationTreasuryAddress: IAddress + ): Transaction { + const setDonationTreasuryAddressTx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction(new ContractFunction('setDonationTreasuryAddress')) + .addArg(new AddressValue(donationTreasuryAddress)) + .build(), + receiver: this.contract.getAddress(), + gasLimit: 10000000, + sender: senderAddress, + chainID: this.chainID + }); + return setDonationTreasuryAddressTx; + } + + /** + * Creates a `setMaxDonationPercentage` transaction + * @param senderAddress The address of the sender, must be the admin of the contract + * @param maxDonationPercentage The maximum donation percentage that can be set + */ + setMaxDonationPercentage( + senderAddress: IAddress, + maxDonationPercentage: BigNumber.Value + ): Transaction { + const setMaxDonationPercentageTx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction(new ContractFunction('setMaxDonationPercentage')) + .addArg(new U64Value(maxDonationPercentage)) + .build(), + receiver: this.contract.getAddress(), + gasLimit: 10000000, + sender: senderAddress, + chainID: this.chainID + }); + return setMaxDonationPercentageTx; + } + /** * Creates a `setAntiSpamTax` transaction * @param senderAddress The address of the sender, must be the admin of the contract @@ -232,6 +279,7 @@ export class SftMinter extends Minter { * - traitsUrl: the URL of the traits for the Data NFT * - 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 * */ async mint( @@ -251,9 +299,16 @@ export class SftMinter extends Minter { traitsUrl?: string; nftStorageToken?: string; extraAssets?: string[]; + donationPercentage?: number; } ): Promise { - const { imageUrl, traitsUrl, nftStorageToken, extraAssets } = options ?? {}; + const { + imageUrl, + traitsUrl, + nftStorageToken, + extraAssets, + donationPercentage + } = options ?? {}; const tokenNameValidator = new StringValidator() .notEmpty() @@ -371,6 +426,10 @@ export class SftMinter extends Minter { data.addArg(new U64Value(lockPeriod)); } + if (donationPercentage) { + data.addArg(new U64Value(donationPercentage)); + } + for (const extraAsset of extraAssets ?? []) { data.addArg(new StringValue(extraAsset)); } From 7dce0f93cb47e61761d322d9008d222f346cb058 Mon Sep 17 00:00:00 2001 From: Bucur David Date: Tue, 23 Apr 2024 15:32:51 +0300 Subject: [PATCH 5/8] fix: donation percentage default 0 --- src/sft-minter.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/sft-minter.ts b/src/sft-minter.ts index d720314..c42a1bc 100644 --- a/src/sft-minter.ts +++ b/src/sft-minter.ts @@ -294,21 +294,15 @@ export class SftMinter extends Minter { datasetDescription: string, amountToSend: number, lockPeriod?: number, + donationPercentage = 0, options?: { imageUrl?: string; traitsUrl?: string; nftStorageToken?: string; extraAssets?: string[]; - donationPercentage?: number; } ): Promise { - const { - imageUrl, - traitsUrl, - nftStorageToken, - extraAssets, - donationPercentage - } = options ?? {}; + const { imageUrl, traitsUrl, nftStorageToken, extraAssets } = options ?? {}; const tokenNameValidator = new StringValidator() .notEmpty() @@ -426,9 +420,7 @@ export class SftMinter extends Minter { data.addArg(new U64Value(lockPeriod)); } - if (donationPercentage) { - data.addArg(new U64Value(donationPercentage)); - } + data.addArg(new U64Value(donationPercentage)); for (const extraAsset of extraAssets ?? []) { data.addArg(new StringValue(extraAsset)); From 6cd93e02c5cab0a4f96eb67fa97058686f0cafb9 Mon Sep 17 00:00:00 2001 From: Damian Date: Tue, 23 Apr 2024 15:53:36 +0300 Subject: [PATCH 6/8] chore: package v --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b217660..625b99e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@itheum/sdk-mx-data-nft", - "version": "3.2.1", + "version": "3.3.0-alpha.1", "description": "SDK for Itheum's Data NFT Technology on MultiversX Blockchain", "main": "out/index.js", "types": "out/index.d.js", From 2cfd9a6028c83e4457ca501c00b4529b2a772ab8 Mon Sep 17 00:00:00 2001 From: Bucur David Date: Tue, 23 Apr 2024 17:06:58 +0300 Subject: [PATCH 7/8] fix: blacklist payload builder --- src/bond.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/bond.ts b/src/bond.ts index 5d3f477..7059568 100644 --- a/src/bond.ts +++ b/src/bond.ts @@ -720,8 +720,7 @@ export class BondContract extends Contract { value: 0, data: new ContractCallPayloadBuilder() .setFunction('setBlacklist') - .addArg(new U64Value(compensationId)) - .setArgs(inputAddresses) + .setArgs([new U64Value(compensationId), ...inputAddresses]) .build(), receiver: this.contract.getAddress(), sender: senderAddress, @@ -749,8 +748,7 @@ export class BondContract extends Contract { value: 0, data: new ContractCallPayloadBuilder() .setFunction('removeBlacklist') - .addArg(new U64Value(compensationId)) - .setArgs(toBeRemovedAddresses) + .setArgs([new U64Value(compensationId), ...toBeRemovedAddresses]) .build(), receiver: this.contract.getAddress(), sender: senderAddress, From f222dc6c7e56bfa45052bf856e544ad80619c2cf Mon Sep 17 00:00:00 2001 From: Bucur David Date: Tue, 23 Apr 2024 17:07:44 +0300 Subject: [PATCH 8/8] chore: bump alpha version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 625b99e..972e9b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@itheum/sdk-mx-data-nft", - "version": "3.3.0-alpha.1", + "version": "3.3.0-alpha.2", "description": "SDK for Itheum's Data NFT Technology on MultiversX Blockchain", "main": "out/index.js", "types": "out/index.d.js",