Skip to content

Commit

Permalink
feat: bond blacklist update
Browse files Browse the repository at this point in the history
Refs: #99
  • Loading branch information
bucurdavid committed Feb 29, 2024
1 parent 3f912cb commit 7fc250e
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/abis/core-mx-life-bonding-sc.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,22 @@
}
]
},
{
"name": "getCompensationBlacklist",
"mutability": "readonly",
"inputs": [
{
"name": "compensation_id",
"type": "u64"
}
],
"outputs": [
{
"type": "variadic<Address>",
"multi_result": true
}
]
},
{
"name": "getBond",
"mutability": "readonly",
Expand Down Expand Up @@ -369,6 +385,38 @@
}
]
},
{
"name": "setBlacklist",
"mutability": "mutable",
"inputs": [
{
"name": "compensation_id",
"type": "u64"
},
{
"name": "addresses",
"type": "variadic<Address>",
"multi_arg": true
}
],
"outputs": []
},
{
"name": "removeBlacklist",
"mutability": "mutable",
"inputs": [
{
"name": "compensation_id",
"type": "u64"
},
{
"name": "addresses",
"type": "variadic<Address>",
"multi_arg": true
}
],
"outputs": []
},
{
"name": "initiateRefund",
"mutability": "mutable",
Expand Down
36 changes: 36 additions & 0 deletions src/bond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string[]> {
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
*/
Expand Down Expand Up @@ -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');
}
Expand Down

0 comments on commit 7fc250e

Please sign in to comment.