Skip to content

Commit

Permalink
fix: add checks for contracts incompatible with create3 (#36)
Browse files Browse the repository at this point in the history
Co-authored-by: Dean Amiel <dean@axelar.network>
  • Loading branch information
deanamiel and Dean Amiel authored Aug 29, 2023
1 parent 678777b commit 9ca3573
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
10 changes: 7 additions & 3 deletions evm/deploy-upgradable.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ async function deploy(options, chain) {
const { artifactPath, contractName, deployMethod, privateKey, upgrade, verifyEnv, yes } = options;
const verifyOptions = verifyEnv ? { env: verifyEnv, chain: chain.name } : null;

if (deployMethod === 'create3' && (contractName === 'AxelarGasService' || contractName === 'AxelarDepositService')) {
printError(`${deployMethod} not supported for ${contractName}`);
return;
}

const rpc = chain.rpc;
const provider = getDefaultProvider(rpc);
const wallet = new Wallet(privateKey, provider);
Expand Down Expand Up @@ -257,10 +262,9 @@ async function deploy(options, chain) {
printInfo(`${chain.name} | Proxy for ${contractName}`, contractConfig.address);

const owner = await contract.owner();

if (owner !== wallet.address) {
printError(
`${chain.name} | Signer ${wallet.address} does not match contract owner ${owner} for chain ${chain.name} in info.`,
);
printError(`${chain.name} | Signer ${wallet.address} does not match contract owner ${owner} for chain ${chain.name} in info.`);
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions evm/upgradable.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
'use strict';

const {
Contract,
ContractFactory,
utils: { keccak256 },
} = require('ethers');
const { Contract, ContractFactory } = require('ethers');
const { deployAndInitContractConstant, create3DeployAndInitContract } = require('@axelar-network/axelar-gmp-sdk-solidity');
const IUpgradable = require('@axelar-network/axelar-gmp-sdk-solidity/interfaces/IUpgradable.json');

Expand Down
14 changes: 3 additions & 11 deletions evm/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const {
ContractFactory,
Contract,
utils: { getContractAddress, keccak256, isAddress, getCreate2Address, Interface, defaultAbiCoder },
utils: { getContractAddress, keccak256, isAddress, getCreate2Address, defaultAbiCoder },
} = require('ethers');
const https = require('https');
const http = require('http');
Expand Down Expand Up @@ -404,11 +404,7 @@ const getDeployedAddress = async (deployer, deployMethod, options = {}) => {
const initCode = factory.getDeployTransaction(...constructorArgs).data;

if (!options.offline) {
const deployerInterface = new Contract(
deployerContract,
IDeployer.abi,
options.provider,
);
const deployerInterface = new Contract(deployerContract, IDeployer.abi, options.provider);

return await deployerInterface.deployedAddress(initCode, deployer, salt);
}
Expand All @@ -428,11 +424,7 @@ const getDeployedAddress = async (deployer, deployMethod, options = {}) => {
if (!options.offline) {
const salt = getSaltFromKey(options.salt);

const deployerInterface = new Contract(
deployerContract,
IDeployer.abi,
options.provider,
);
const deployerInterface = new Contract(deployerContract, IDeployer.abi, options.provider);

return await deployerInterface.deployedAddress('0x', deployer, salt);
}
Expand Down

0 comments on commit 9ca3573

Please sign in to comment.