Skip to content

Commit

Permalink
improve scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth committed Dec 7, 2023
1 parent 89040cd commit 0cfe8e1
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions evm/deploy-its.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const {
sleep,
getBytecodeHash,
getGasOptions,
isContract,
} = require('./utils');
const { addExtendedOptions } = require('./cli-utils');
const { Command, Option } = require('commander');
Expand All @@ -32,14 +33,20 @@ const { Command, Option } = require('commander');
* @param {*} verifyOptions
*/

async function deployImplementation(config, wallet, chain, options) {
async function deployAll(config, wallet, chain, options) {
const { env, artifactPath, salt, factorySalt, deployMethod, skipExisting, verify, yes } = options;
const verifyOptions = verify ? { env, chain: chain.name, only: verify === 'only' } : null;

const provider = getDefaultProvider(chain.rpc);
const InterchainTokenService = getContractJSON('InterchainTokenService', artifactPath);

const contractName = 'InterchainTokenService';
const contracts = chain.contracts;
// Reset config data if it's a fresh deployment
if (!skipExisting) {
contracts[contractName] = {};
}

const contractConfig = contracts[contractName] || {};

contractConfig.salt = salt;
Expand Down Expand Up @@ -231,23 +238,21 @@ async function deployImplementation(config, wallet, chain, options) {
if (skipExisting && contractConfig[key]) continue;

const deployment = deployments[key];
printInfo(`Deploying ${deployment.name}.`);
printInfo(`Deploying ${deployment.name}`);

const contract = await deployment.deploy();

if (contract.address === undefined) {
contractConfig[key] = contract;
printInfo(`Deployed ${deployment.name} at ${JSON.stringify(contract)}`);
} else {
contractConfig[key] = contract.address;
printInfo(`Deployed ${deployment.name} at ${contract.address}`);
}
contractConfig[key] = contract.address;
printInfo(`Deployed ${deployment.name} at ${contract.address}`);

saveConfig(config, options.env);

if (chain.chainId !== 31337) {
await sleep(2000);
}

if (!(await isContract(contract.address, provider))) {
throw new Error(`Contract ${deployment.name} at ${contract.address} was not deployed on ${chain.name}`);
}
}
}

Expand Down Expand Up @@ -276,7 +281,7 @@ async function deploy(config, chain, options) {
throw new Error(`Invalid operator address: ${operatorAddress}`);
}

await deployImplementation(config, wallet, chain, options);
await deployAll(config, wallet, chain, options);
}

async function upgrade(config, chain, options) {
Expand All @@ -298,7 +303,7 @@ async function upgrade(config, chain, options) {

contracts[contractName] = contractConfig;

await deployImplementation(config, wallet, chain, options);
await deployAll(config, wallet, chain, options);

printInfo(`Upgrading Interchain Token Service.`);

Expand Down

0 comments on commit 0cfe8e1

Please sign in to comment.