diff --git a/common/its.js b/common/its.js index 286cc794f..284cf4b5f 100644 --- a/common/its.js +++ b/common/its.js @@ -1,6 +1,7 @@ 'use strict'; const { Command } = require('commander'); +const { execSync } = require('child_process'); const { addBaseOptions, addOptionsToCommands, encodeITSDestination, loadConfig, printInfo } = require('../common'); async function encodeRecipient(config, args, _) { @@ -12,6 +13,49 @@ async function encodeRecipient(config, args, _) { printInfo('Encoded ITS destination address', itsDestinationAddress); } +async function setTrustedChainsAll(config, args, options) { + const chain = process.env.CHAIN; + if (!chain) { + throw new Error('CHAIN environment variable must be set'); + } + + const requiredKeys = [ + 'PRIVATE_KEY_EVM', + 'PRIVATE_KEY_SUI', + 'PRIVATE_KEY_STELLAR' + ]; + for (const key of requiredKeys) { + if (!process.env[key]) { + throw new Error(`${key} must be set in .env file`); + } + } + + const commands = [ + { + cmd: `ts-node evm/its.js set-trusted-chains ${chain} hub -n all`, + privateKeyEnv: 'PRIVATE_KEY_EVM' + }, + { + cmd: `ts-node sui/its.js add-trusted-chains ${chain}`, + privateKeyEnv: 'PRIVATE_KEY_SUI' + }, + { + cmd: `ts-node stellar/its.js add-trusted-chains ${chain}`, + privateKeyEnv: 'PRIVATE_KEY_STELLAR' + } + ]; + + for (const { cmd, privateKeyEnv } of commands) { + execSync(cmd, { + stdio: 'inherit', + env: { + ...process.env, + PRIVATE_KEY: process.env[privateKeyEnv] + } + }); + } +} + async function mainProcessor(processor, args, options) { const config = loadConfig(options.env); @@ -29,6 +73,13 @@ if (require.main === module) { .action((destinationChain, destinationAddress, options) => { mainProcessor(encodeRecipient, [destinationChain, destinationAddress], options); }); + + program + .command('set-trusted-chains-all') + .description('Set trusted chains for all chains') + .action((options) => { + mainProcessor(setTrustedChainsAll, [], options); + }); addOptionsToCommands(program, addBaseOptions, { ignoreChainNames: true }); diff --git a/releases/evm/EVM-ITS-Release-Template.md b/releases/evm/EVM-ITS-Release-Template.md index 3f0d8b169..89283db7b 100644 --- a/releases/evm/EVM-ITS-Release-Template.md +++ b/releases/evm/EVM-ITS-Release-Template.md @@ -58,25 +58,21 @@ ts-node evm/deploy-its.js -s "v2.1.0" -m create2 --proxySalt 'v1.0.0' Please follow this [instruction](https://github.com/axelarnetwork/axelar-contract-deployments/tree/main/evm#contract-verification) to verify ITS contracts on EVM chains. -## Set <ChainName> as trusted chain on remote ITS contracts +## Set as trusted chain on remote ITS contracts -#### Note: Ensure that <ChainName> is registered on ITS hub +- Ensure that `` is registered on ITS hub -Set `` as trusted chain on all EVM chains -```bash -ts-node evm/its.js set-trusted-chains $CHAIN hub -n all -``` - -Set `` as trusted chain on Sui +- Set the following addresses in `.env`. Refer to ITS release docs for owner addresses. -```bash -ts-node sui/its.js add-trusted-chains $CHAIN +```yaml +PRIVATE_KEY_EVM= +PRIVATE_KEY_SUI= +PRIVATE_KEY_STELLAR= ``` -Set `` as trusted chain on Stellar - +- Set chain as trusted chain on all ITS edge contracts: ```bash -ts-node stellar/its.js add-trusted-chains $CHAIN +ts-node common/its.js set-trusted-chains-all ``` ## Checklist