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)); }