From 5c743b7458380b24226522aa7a1c3ecf194d2b7f Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 3 Dec 2024 20:21:50 +0700 Subject: [PATCH 1/4] feat: add command to remove trusted address on sui --- sui/its.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/sui/its.js b/sui/its.js index 06378b9e..79113394 100644 --- a/sui/its.js +++ b/sui/its.js @@ -31,6 +31,35 @@ async function setupTrustedAddress(keypair, client, contracts, args, options) { contracts.ITS.trustedAddresses[trustedChain].push(trustedAddress); } +async function removeTrustedAddress(keypair, client, contracts, args, options) { + const [trustedChain, trustedAddress] = args; + + const trustedAddressesObject = contracts.ITS.trustedAddresses; + + if (!trustedAddressesObject) throw new Error('No trusted addresses found'); + + const chainNames = trustedChain.split(','); + + if (chainNames.length === 0) throw new Error('No chain names provided'); + + const txBuilder = new TxBuilder(client); + + for (const chainName of chainNames) { + if (!trustedAddressesObject[chainName]) throw new Error(`No trusted addresses found for chain ${trustedChain}`); + } + + await txBuilder.moveCall({ + target: `${contracts.ITS.address}::its::remove_trusted_addresses`, + arguments: [contracts.ITS.objects.ITS, contracts.ITS.objects.OwnerCap, chainNames], + }); + + for (const chainName of chainNames) { + delete contracts.ITS.trustedAddresses[chainName]; + } + + await broadcastFromTxBuilder(txBuilder, keypair, 'Remove Trusted Address'); +} + async function processCommand(command, chain, args, options) { const [keypair, client] = getWallet(chain, options); @@ -60,7 +89,16 @@ if (require.main === module) { mainProcessor(setupTrustedAddress, options, [trustedChain, trustedAddress], processCommand); }); + const removeTrustedAddressProgram = new Command() + .name('remove-trusted-address') + .description('Remove trusted address') + .command('remove-trusted-address ') + .action((trustedChain, options) => { + mainProcessor(removeTrustedAddress, options, [trustedChain], processCommand); + }); + program.addCommand(setupTrustedAddressProgram); + program.addCommand(removeTrustedAddressProgram); addOptionsToCommands(program, addBaseOptions); From 5866d4de22521badd13e64e7b9ea79dc3baffbea Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 3 Dec 2024 20:24:03 +0700 Subject: [PATCH 2/4] fix: lint --- sui/its.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sui/its.js b/sui/its.js index 79113394..aba983d6 100644 --- a/sui/its.js +++ b/sui/its.js @@ -32,7 +32,7 @@ async function setupTrustedAddress(keypair, client, contracts, args, options) { } async function removeTrustedAddress(keypair, client, contracts, args, options) { - const [trustedChain, trustedAddress] = args; + const [trustedChain] = args; const trustedAddressesObject = contracts.ITS.trustedAddresses; From 7ada939edb071e410a2ddd54115d64cef30daab9 Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Fri, 6 Dec 2024 16:14:52 +0530 Subject: [PATCH 3/4] removed the old ITS address as trusted address --- axelar-chains-config/info/devnet-amplifier.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/axelar-chains-config/info/devnet-amplifier.json b/axelar-chains-config/info/devnet-amplifier.json index 6a4826f8..0236dc3f 100644 --- a/axelar-chains-config/info/devnet-amplifier.json +++ b/axelar-chains-config/info/devnet-amplifier.json @@ -739,10 +739,6 @@ "OwnerCap": "0x2dd1c932d894d5416d373474b58fe7f0d0bae2932220784657f3f7b2f95de4b3" }, "trustedAddresses": { - "axelar": [ - "axelar10jzzmv5m7da7dn2xsfac0yqe7zamy34uedx3e28laq0p6f3f8dzqp649fp", - "axelar157hl7gpuknjmhtac2qnphuazv2yerfagva7lsu9vuj2pgn32z22qa26dk4" - ], "eth-sepolia": [ "hub" ], @@ -763,6 +759,9 @@ ], "core-optimism": [ "hub" + ], + "axelar": [ + "axelar157hl7gpuknjmhtac2qnphuazv2yerfagva7lsu9vuj2pgn32z22qa26dk4" ] } }, From ea10041f3100dd3bc610cb190de22a722fad44e0 Mon Sep 17 00:00:00 2001 From: npty Date: Mon, 9 Dec 2024 17:44:28 +0700 Subject: [PATCH 4/4] chore: add doc --- sui/README.md | 20 ++++++++++++++++++++ sui/its.js | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/sui/README.md b/sui/README.md index 9d31c1ef..d5c30704 100644 --- a/sui/README.md +++ b/sui/README.md @@ -366,6 +366,26 @@ Note: - If coin type is not provided, it will split all the coins. - If transfer address is not provided, it will split the coins in the same wallet. Otherwise, it will transfer the splitted coins to the provided address. +## Setup Trusted Addresses + +Add trusted address + +```bash +node sui/its.js setup-trusted-address ,,... +``` + +or Add all evm chains that have ITS contract deployed + +```bash +node sui/its.js setup-trusted-address all-evm +``` + +Remove trusted address + +```bash +node sui/its.js remove-trusted-address ,,... +``` + ## Examples - [GMP Example Guide](docs/gmp.md) diff --git a/sui/its.js b/sui/its.js index f8d19785..8741b429 100644 --- a/sui/its.js +++ b/sui/its.js @@ -84,7 +84,7 @@ async function mainProcessor(command, options, args, processor) { if (require.main === module) { const program = new Command(); - program.name('ITS ').description('SUI ITS scripts'); + program.name('ITS').description('SUI ITS scripts'); // This command is used to setup the trusted address on the ITS contract. // The trusted address is used to verify the message from the source chain.