Skip to content

Commit

Permalink
improve verify script
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth committed Nov 15, 2023
1 parent 78064d2 commit d09ea35
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions evm/verify-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
getContractAt,
getContractFactoryFromArtifact,
utils: { defaultAbiCoder },
Contract,
} = ethers;
const { Command, Option } = require('commander');
const { verifyContract, getEVMAddresses, printInfo, printError, mainProcessor, getContractJSON } = require('./utils');
Expand Down Expand Up @@ -209,23 +210,29 @@ async function processCommand(config, chain, options) {
const interchainTokenService = interchainTokenServiceFactory.attach(
options.address || chain.contracts.InterchainTokenService.address,
);
const contractConfig = chain.contracts[contractName];

const implementation = await interchainTokenService.implementation();
const tokenManagerDeployer = await interchainTokenService.tokenManagerDeployer();
const interchainTokenDeployer = await interchainTokenService.interchainTokenDeployer();
const interchainToken = await interchainTokenDeployer.implementation();
const interchainTokenDeployerContract = new Contract(interchainTokenDeployer, getContractJSON('InterchainTokenDeployer').abi, wallet);
const interchainToken = await interchainTokenDeployerContract.implementationAddress();
const interchainTokenFactory = await interchainTokenService.interchainTokenFactory();
const interchainTokenFactoryContract = new Contract(interchainTokenFactory, getContractJSON('InterchainTokenFactory').abi, wallet);
const interchainTokenFactoryImplementation = await interchainTokenFactoryContract.implementation();

const tokenManagerMintBurn = await interchainTokenService.implementationMintBurn();
const tokenManagerMintBurnFrom = await interchainTokenService.implementationMintBurnFrom();
const tokenManagerLockUnlock = await interchainTokenService.implementationLockUnlock();
const tokenManagerLockUnlockFee = await interchainTokenService.implementationLockUnlockFee();
const tokenManagerMintBurn = await interchainTokenService.tokenManagerImplementation(0);
const tokenManagerMintBurnFrom = await interchainTokenService.tokenManagerImplementation(1);
const tokenManagerLockUnlock = await interchainTokenService.tokenManagerImplementation(2);
const tokenManagerLockUnlockFee = await interchainTokenService.tokenManagerImplementation(3);

const trustedChains = Object.values(config.chains).map((chain) => chain.id);
const trustedAddresses = trustedChains
.map(async (chainName) => await interchainTokenService.trustedAddress(chainName))
const trustedAddresses = (await Promise.all(trustedChains
.map(async (chainName) => await interchainTokenService.trustedAddress(chainName))))
.filter((address) => address !== '');

const setupParams = defaultAbiCoder.encode(['address', 'string', 'string[]', 'string[]'], [contractConfig.deployer, chain.id, trustedChains, trustedAddresses]);

await verifyContract(env, chain.name, tokenManagerDeployer, [], verifyOptions);
await verifyContract(env, chain.name, interchainToken, [], verifyOptions);
await verifyContract(env, chain.name, interchainTokenDeployer, [interchainToken], verifyOptions);
Expand All @@ -248,13 +255,26 @@ async function processCommand(config, chain, options) {
],
verifyOptions,
);
await verifyContract(env, chain.name, interchainTokenFactory, [interchainTokenService.address], verifyOptions);
await verifyContract(env, chain.name, interchainTokenFactoryImplementation, [interchainTokenService.address], verifyOptions);
await verifyContract(
env,
chain.name,
interchainTokenService.address,
[implementation, chain.contracts.InterchainTokenService.deployer, trustedChains, trustedAddresses],
verifyOptions,
[implementation, chain.contracts.InterchainTokenService.deployer, setupParams],
{
...verifyOptions,
contractPath: 'contracts/proxies/InterchainTokenServiceProxy.sol:InterchainTokenServiceProxy',
},
);
await verifyContract(
env,
chain.name,
interchainTokenFactory,
[interchainTokenFactoryImplementation, chain.contracts.InterchainTokenService.deployer],
{
...verifyOptions,
contractPath: 'contracts/proxies/InterchainTokenFactoryProxy.sol:InterchainTokenFactoryProxy',
},
);

break;
Expand Down

0 comments on commit d09ea35

Please sign in to comment.