From 7454af1dbf46455c0fdfd9fc613b01b3ead43780 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 6 Aug 2024 10:51:36 +0700 Subject: [PATCH] chore: fix remove cap error --- sui/operators.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sui/operators.js b/sui/operators.js index 0e330d51..a86aba0d 100644 --- a/sui/operators.js +++ b/sui/operators.js @@ -168,22 +168,24 @@ async function addOperator(keypair, client, config, operatorsConfig, args, optio printInfo('Operator Added', receipt.digest); } -// TODO: Fix `UnusedValueWithoutDrop` error async function removeCap(keypair, client, config, operatorsConfig, args, options) { const [capId] = args; const gasServiceAddress = config.sui.contracts.GasService.address; const operatorsObjectId = operatorsConfig.objects.Operators; const ownerCapObjectId = options.ownerCapId || operatorsConfig.objects.OwnerCap; + const capReceiver = options.receiver || keypair.toSuiAddress(); const tx = new Transaction(); - tx.moveCall({ + const cap = tx.moveCall({ target: `${operatorsConfig.address}::operators::remove_cap`, arguments: [tx.object(operatorsObjectId), tx.object(ownerCapObjectId), tx.object(capId)], typeArguments: [`${gasServiceAddress}::gas_service::GasCollectorCap`], }); + tx.transferObjects([cap], capReceiver); + try { const receipt = await broadcast(client, keypair, tx); @@ -258,6 +260,7 @@ if (require.main === module) { .command('removeCap ') .description('Remove a capability') .addOption(new Option('--ownerCap ', 'ID of the owner capability')) + .addOption(new Option('--receiver ', 'The removed cap receiver address')) .action((capId, options) => mainProcessor(removeCap, [capId], options)); const refundCmd = new Command('refund')