Skip to content

Commit

Permalink
revert evm changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Foivos committed Jan 29, 2025
1 parent 2d1e7f6 commit 42255fd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 37 deletions.
54 changes: 26 additions & 28 deletions evm/deploy-its.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const { addEvmOptions } = require('./cli-utils');
const { Command, Option } = require('commander');

/**
* Function that handles the InterchainTokenService deployment.
* Function that handles the ITS deployment.
* @param {*} wallet
* @param {*} chain
* @param {*} deployOptions
Expand All @@ -53,22 +53,22 @@ async function deployAll(config, wallet, chain, options) {
const contractConfig = contracts[contractName] || {};
const itsFactoryContractConfig = contracts[itsFactoryContractName] || {};

const salt = options.salt ? `InterchainTokenService ${options.salt}` : 'InterchainTokenService';
const salt = options.salt ? `ITS ${options.salt}` : 'ITS';
let proxySalt, factorySalt;

// If reusing the proxy, then proxy salt is the existing value
if (options.reuseProxy) {
proxySalt = contractConfig.proxySalt;
factorySalt = itsFactoryContractConfig.salt;
} else if (options.proxySalt) {
proxySalt = `InterchainTokenService ${options.proxySalt}`;
factorySalt = `InterchainTokenService Factory ${options.proxySalt}`;
proxySalt = `ITS ${options.proxySalt}`;
factorySalt = `ITS Factory ${options.proxySalt}`;
} else if (options.salt) {
proxySalt = `InterchainTokenService ${options.salt}`;
factorySalt = `InterchainTokenService Factory ${options.salt}`;
proxySalt = `ITS ${options.salt}`;
factorySalt = `ITS Factory ${options.salt}`;
} else {
proxySalt = 'InterchainTokenService';
factorySalt = 'InterchainTokenService Factory';
proxySalt = 'ITS';
factorySalt = 'ITS Factory';
}

const implementationSalt = `${salt} Implementation`;
Expand Down Expand Up @@ -99,7 +99,7 @@ async function deployAll(config, wallet, chain, options) {
});

if (!isValidAddress(interchainTokenService)) {
throw new Error(`Invalid InterchainTokenService address: ${interchainTokenService}`);
throw new Error(`Invalid ITS address: ${interchainTokenService}`);
}

if (options.reuseProxy) {
Expand Down Expand Up @@ -130,8 +130,8 @@ async function deployAll(config, wallet, chain, options) {

const isCurrentChainConsensus = isConsensusChain(chain);

// Register all EVM chains that InterchainTokenService is or will be deployed on.
// Add a "skip": true under InterchainTokenService key in the config if the chain will not have InterchainTokenService.
// Register all EVM chains that ITS is or will be deployed on.
// Add a "skip": true under ITS key in the config if the chain will not have ITS.
const itsChains = Object.values(config.chains).filter(
(chain) => chain.chainType === 'evm' && chain.contracts?.InterchainTokenService?.skip !== true,
);
Expand All @@ -143,7 +143,7 @@ async function deployAll(config, wallet, chain, options) {
: 'hub',
);

// If InterchainTokenService Hub is deployed, register it as a trusted chain as well
// If ITS Hub is deployed, register it as a trusted chain as well
const itsHubAddress = config.axelar?.contracts?.InterchainTokenService?.address;

if (itsHubAddress) {
Expand Down Expand Up @@ -296,7 +296,7 @@ async function deployAll(config, wallet, chain, options) {
contractConfig.gatewayCaller,
];

printInfo('InterchainTokenService Implementation args', args);
printInfo('ITS Implementation args', args);

return await deployContract(
proxyDeployMethod,
Expand All @@ -323,7 +323,7 @@ async function deployAll(config, wallet, chain, options) {
contractConfig.predeployCodehash = predeployCodehash;

const args = [contractConfig.implementation, wallet.address, deploymentParams];
printInfo('InterchainTokenService Proxy args', args);
printInfo('ITS Proxy args', args);

return await deployContract(
proxyDeployMethod,
Expand Down Expand Up @@ -358,7 +358,7 @@ async function deployAll(config, wallet, chain, options) {
contractName: 'InterchainProxy',
async deploy() {
const args = [itsFactoryContractConfig.implementation, wallet.address, '0x'];
printInfo('InterchainTokenService Factory Proxy args', args);
printInfo('ITS Factory Proxy args', args);

return await deployContract(
proxyDeployMethod,
Expand Down Expand Up @@ -463,13 +463,13 @@ async function upgrade(_, chain, options) {
const contract = new Contract(contractConfig.address, InterchainTokenService.abi, wallet);
const codehash = await getBytecodeHash(contractConfig.implementation, chain.axelarId, provider);

printInfo(`InterchainTokenService Proxy`, contract.address);
printInfo(`ITS Proxy`, contract.address);

const currImplementation = await contract.implementation();
printInfo(`Current InterchainTokenService implementation`, currImplementation);
printInfo(`New InterchainTokenService implementation`, contractConfig.implementation);
printInfo(`Current ITS implementation`, currImplementation);
printInfo(`New ITS implementation`, contractConfig.implementation);

if (predictOnly || prompt(`Proceed with InterchainTokenService upgrade on ${chain.name}?`, options.yes)) {
if (predictOnly || prompt(`Proceed with ITS upgrade on ${chain.name}?`, options.yes)) {
return;
}

Expand All @@ -488,16 +488,16 @@ async function upgrade(_, chain, options) {
const itsFactory = new Contract(itsFactoryContractConfig.address, InterchainTokenFactory.abi, wallet);
const factoryCodehash = await getBytecodeHash(itsFactoryContractConfig.implementation, chain.axelarId, provider);

printInfo(`InterchainTokenService Factory Proxy`, itsFactory.address);
printInfo(`ITS Factory Proxy`, itsFactory.address);

const factoryImplementation = await itsFactory.implementation();
printInfo(`Current InterchainTokenService Factory implementation`, factoryImplementation);
printInfo(`New InterchainTokenService Factory implementation`, itsFactoryContractConfig.implementation);
printInfo(`Current ITS Factory implementation`, factoryImplementation);
printInfo(`New ITS Factory implementation`, itsFactoryContractConfig.implementation);

if (
options.predictOnly ||
prompt(
`Proceed with InterchainTokenService Factory upgrade to implementation ${itsFactoryContractConfig.implementation} on ${chain.name}?`,
`Proceed with ITS Factory upgrade to implementation ${itsFactoryContractConfig.implementation} on ${chain.name}?`,
options.yes,
)
) {
Expand Down Expand Up @@ -549,19 +549,17 @@ if (require.main === module) {

program.addOption(new Option('--reuseProxy', 'reuse existing proxy (useful for upgrade deployments'));
program.addOption(new Option('--contractName <contractName>', 'contract name').default('InterchainTokenService')); // added for consistency
program.addOption(new Option('-s, --salt <salt>', 'deployment salt to use for InterchainTokenService deployment').env('SALT'));
program.addOption(new Option('-s, --salt <salt>', 'deployment salt to use for ITS deployment').env('SALT'));
program.addOption(
new Option(
'--proxySalt <proxySalt>',
'deployment salt to use for InterchainTokenService proxies, this allows deploying latest releases to new chains while deriving the same proxy address',
'deployment salt to use for ITS proxies, this allows deploying latest releases to new chains while deriving the same proxy address',
)
.default('v1.0.0')
.env('PROXY_SALT'),
);
program.addOption(
new Option('-o, --operatorAddress <operatorAddress>', 'address of the InterchainTokenService operator/rate limiter').env(
'OPERATOR_ADDRESS',
),
new Option('-o, --operatorAddress <operatorAddress>', 'address of the ITS operator/rate limiter').env('OPERATOR_ADDRESS'),
);

program.action(async (options) => {
Expand Down
4 changes: 2 additions & 2 deletions evm/interchainTokenFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async function processCommand(config, chain, options) {
});

if ((await interchainTokenService.trustedAddress(destinationChain)) === '') {
throw new Error(`Destination chain ${destinationChain} is not trusted by InterchainTokenService`);
throw new Error(`Destination chain ${destinationChain} is not trusted by ITS`);
}

const tx = await interchainTokenFactory['deployRemoteInterchainToken(bytes32,string,uint256)'](
Expand Down Expand Up @@ -255,7 +255,7 @@ async function processCommand(config, chain, options) {
const deploymentSalt = getDeploymentSalt(options);

if ((await interchainTokenService.trustedAddress(destinationChain)) === '') {
throw new Error(`Destination chain ${destinationChain} is not trusted by InterchainTokenService`);
throw new Error(`Destination chain ${destinationChain} is not trusted by ITS`);
}

validateParameters({
Expand Down
12 changes: 6 additions & 6 deletions evm/its.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async function handleTx(tx, chain, contract, action, firstEvent, secondEvent) {
async function getTrustedChainsAndAddresses(config, interchainTokenService) {
const allChains = Object.values(config.chains).map((chain) => chain.axelarId);

// If InterchainTokenService Hub is deployed, register it as a trusted chain as well
// If ITS Hub is deployed, register it as a trusted chain as well
const itsHubAddress = config.axelar?.contracts?.InterchainTokenService?.address;

if (itsHubAddress) {
Expand Down Expand Up @@ -312,7 +312,7 @@ async function processCommand(config, chain, options) {
});

if ((await interchainTokenService.trustedAddress(destinationChain)) === '') {
throw new Error(`Destination chain ${destinationChain} is not trusted by InterchainTokenService`);
throw new Error(`Destination chain ${destinationChain} is not trusted by ITS`);
}

const tokenIdBytes32 = hexZeroPad(tokenId.startsWith('0x') ? tokenId : '0x' + tokenId, 32);
Expand Down Expand Up @@ -341,7 +341,7 @@ async function processCommand(config, chain, options) {
implementationType !== tokenManagerImplementations.MINT_BURN &&
implementationType !== tokenManagerImplementations.INTERCHAIN_TOKEN
) {
printInfo('Approving InterchainTokenService for a transfer for token with token manager type', implementationType);
printInfo('Approving ITS for a transfer for token with token manager type', implementationType);
await token.approve(interchainTokenService.address, amount, gasOptions).then((tx) => tx.wait());
}

Expand Down Expand Up @@ -561,7 +561,7 @@ async function processCommand(config, chain, options) {
printInfo('Trusted chains', trustedChains);
printInfo('Trusted addresses', trustedAddresses);

// check if all trusted addresses match InterchainTokenService address
// check if all trusted addresses match ITS address
for (const trustedAddress of trustedAddresses) {
if (trustedAddress !== interchainTokenServiceAddress) {
printError(
Expand Down Expand Up @@ -647,13 +647,13 @@ async function main(options) {
if (require.main === module) {
const program = new Command();

program.name('InterchainTokenService').description('Script to perform InterchainTokenService commands');
program.name('ITS').description('Script to perform ITS commands');

addEvmOptions(program, { address: true, salt: true });

program.addOption(new Option('-c, --contractName <contractName>', 'contract name').default('InterchainTokenService'));
program.addOption(
new Option('--action <action>', 'InterchainTokenService action')
new Option('--action <action>', 'ITS action')
.choices([
'contractId',
'tokenManagerAddress',
Expand Down
2 changes: 1 addition & 1 deletion evm/multisig.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ if (require.main === module) {
new Option('--nativeValue <nativeValue>', 'execute multisig proposal nativeValue').makeOptionMandatory(false).default(0),
);

// option for setFlowLimit in InterchainTokenService
// option for setFlowLimit in ITS
program.addOption(new Option('--tokenIds <tokenIds>', 'token ids'));

program.action((options) => {
Expand Down

0 comments on commit 42255fd

Please sign in to comment.