Skip to content

Commit

Permalink
Merge branch 'develop' into d-david
Browse files Browse the repository at this point in the history
  • Loading branch information
bucurdavid authored Apr 24, 2024
2 parents c4a95ea + 6f304ea commit 8391539
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@itheum/sdk-mx-data-nft",
"version": "3.2.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",
Expand Down
144 changes: 142 additions & 2 deletions src/abis/datanftmint.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -120,6 +120,15 @@
{
"name": "lock_period_sec",
"type": "u64"
},
{
"name": "donation_percentage",
"type": "u64"
},
{
"name": "extra_assets",
"type": "variadic<bytes>",
"multi_arg": true
}
],
"outputs": [
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -262,6 +293,7 @@
},
{
"name": "setBondContractAddress",
"onlyOwner": true,
"mutability": "mutable",
"inputs": [
{
Expand Down Expand Up @@ -322,6 +354,26 @@
}
]
},
{
"name": "getDonationTreasuryAddress",
"mutability": "readonly",
"inputs": [],
"outputs": [
{
"type": "Address"
}
]
},
{
"name": "getMaxDonationPercentage",
"mutability": "readonly",
"inputs": [],
"outputs": [
{
"type": "u64"
}
]
},
{
"name": "getWithdrawalAddress",
"mutability": "readonly",
Expand Down Expand Up @@ -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": [
Expand All @@ -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": [
Expand Down Expand Up @@ -926,6 +1040,11 @@
"name": "bond_amount",
"type": "BigUint",
"indexed": true
},
{
"name": "extra_assets",
"type": "List<bytes>",
"indexed": true
}
]
},
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -1060,6 +1196,10 @@
{
"name": "frozen_nonces",
"type": "List<u64>"
},
{
"name": "max_donation_percentage",
"type": "u64"
}
]
}
Expand Down
6 changes: 2 additions & 4 deletions src/bond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export interface SftMinterRequirements {
numberOfMintsForUser: number;
totalNumberOfMints: number;
contractWhitelistEnabled: boolean;
maxDonationPecentage: number;
}

export interface NftMinterRequirements {
Expand Down
53 changes: 52 additions & 1 deletion src/sft-minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -246,6 +294,7 @@ export class SftMinter extends Minter {
datasetDescription: string,
amountToSend: number,
lockPeriod?: number,
donationPercentage = 0,
options?: {
imageUrl?: string;
traitsUrl?: string;
Expand Down Expand Up @@ -371,6 +420,8 @@ export class SftMinter extends Minter {
data.addArg(new U64Value(lockPeriod));
}

data.addArg(new U64Value(donationPercentage));

for (const extraAsset of extraAssets ?? []) {
data.addArg(new StringValue(extraAsset));
}
Expand Down

0 comments on commit 8391539

Please sign in to comment.