From b6d7441e955c2e8567bbf59acc45f21bd4d62420 Mon Sep 17 00:00:00 2001 From: Bucur David Date: Fri, 15 Mar 2024 12:22:10 +0200 Subject: [PATCH] feat: initiateBond method --- src/abis/core-mx-life-bonding-sc.abi.json | 19 +++++++++++++++ src/bond.ts | 29 +++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/abis/core-mx-life-bonding-sc.abi.json b/src/abis/core-mx-life-bonding-sc.abi.json index e9e9770..3bf9d92 100644 --- a/src/abis/core-mx-life-bonding-sc.abi.json +++ b/src/abis/core-mx-life-bonding-sc.abi.json @@ -328,6 +328,25 @@ } ] }, + { + "name": "initiateBond", + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + } + ], + "outputs": [] + }, { "name": "setBlacklist", "mutability": "mutable", diff --git a/src/bond.ts b/src/bond.ts index 9495a19..5d3f477 100644 --- a/src/bond.ts +++ b/src/bond.ts @@ -806,6 +806,35 @@ export class BondContract extends Contract { return tx; } + /** + * Builds a `initiateBond` transaction to "whitelist" an address for being able to bond for a specific Data NFT + * @param senderAddress the address of the sender + * @param address the address to be whitelisted + * @param tokenIdentifier the token identifier + * @param nonce the token identifier nonce + */ + initiateBond( + senderAddress: IAddress, + address: IAddress, + tokenIdentifier: string, + nonce: number + ): Transaction { + const tx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction('initiateBond') + .addArg(new AddressValue(address)) + .addArg(new TokenIdentifierValue(tokenIdentifier)) + .addArg(new U64Value(nonce)) + .build(), + receiver: this.contract.getAddress(), + sender: senderAddress, + gasLimit: 20_000_000, + chainID: this.chainID + }); + return tx; + } + /** * Builds a `addPeriodsBonds` transaction to set the periods and bonds * @param senderAddress the address of the sender