From 7fc250e376a0d77b9ccf8e043f33b321a0a627ef Mon Sep 17 00:00:00 2001 From: Bucur David Date: Thu, 29 Feb 2024 15:15:31 +0200 Subject: [PATCH] feat: bond blacklist update Refs: #99 --- src/abis/core-mx-life-bonding-sc.abi.json | 48 +++++++++++++++++++++++ src/bond.ts | 36 +++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/src/abis/core-mx-life-bonding-sc.abi.json b/src/abis/core-mx-life-bonding-sc.abi.json index bd64756..056fe21 100644 --- a/src/abis/core-mx-life-bonding-sc.abi.json +++ b/src/abis/core-mx-life-bonding-sc.abi.json @@ -185,6 +185,22 @@ } ] }, + { + "name": "getCompensationBlacklist", + "mutability": "readonly", + "inputs": [ + { + "name": "compensation_id", + "type": "u64" + } + ], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ] + }, { "name": "getBond", "mutability": "readonly", @@ -369,6 +385,38 @@ } ] }, + { + "name": "setBlacklist", + "mutability": "mutable", + "inputs": [ + { + "name": "compensation_id", + "type": "u64" + }, + { + "name": "addresses", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "removeBlacklist", + "mutability": "mutable", + "inputs": [ + { + "name": "compensation_id", + "type": "u64" + }, + { + "name": "addresses", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, { "name": "initiateRefund", "mutability": "mutable", diff --git a/src/bond.ts b/src/bond.ts index 4cf676b..7881de3 100644 --- a/src/bond.ts +++ b/src/bond.ts @@ -106,6 +106,34 @@ export class BondContract extends Contract { } } + /** + * Returns a list of addresses that are blacklisted from claiming compensations + * @param compensationId compensaton id to query + * @returns + */ + async viewCompensationBlacklist(compensationId: number): Promise { + const interaction = this.contract.methodsExplicit.getCompensationBlacklist([ + new U64Value(compensationId) + ]); + const query = interaction.buildQuery(); + const queryResponse = await this.networkProvider.queryContract(query); + const endpointDefinition = interaction.getEndpoint(); + const { firstValue, returnCode } = new ResultsParser().parseQueryResponse( + queryResponse, + endpointDefinition + ); + if (returnCode.isSuccess()) { + return firstValue + ?.valueOf() + .map((address: any) => new Address(address).bech32()); + } else { + throw new ErrContractQuery( + 'viewCompensationBlacklist', + returnCode.toString() + ); + } + } + /** * Returns the contract lock periods and bond amounts */ @@ -503,6 +531,14 @@ export class BondContract extends Contract { throw new Error('Not implemented'); } + setBlacklist(senderAddress: IAddress, addresses: IAddress[]) { + throw new Error('Not implemented'); + } + + removeBlacklist(senderAddress: IAddress, addresses: IAddress[]) { + throw new Error('Not implemented'); + } + removeAcceptedCallers(senderAddress: IAddress, addresses: IAddress[]) { throw new Error('Not implemented'); }