Skip to content

Commit

Permalink
Minor fix of scripts (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
channing-magiceden authored Feb 15, 2024
1 parent 497a5dc commit 14f84ce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ export const deploy = async (
console.log('run the following command to verify the contract:');
const paramsStr = params.map((param) => {
if (hre.ethers.BigNumber.isBigNumber(param)) {
return param.toString();
return `"${param.toString()}"`;
}
return param;
return `"${param}"`;
}).join(' ');

console.log(`npx hardhat verify --network ${hre.network.name} ${contract.address} ${paramsStr}`);
Expand Down
18 changes: 16 additions & 2 deletions scripts/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,22 @@ export const estimateGas = async (hre: HardhatRuntimeEnvironment, tx: Deferrable
const estimatedGasPrice = await hre.ethers.provider.getGasPrice();
const estimatedGas = estimatedGasUnit.mul(estimatedGasPrice);
console.log('Estimated gas unit: ', estimatedGasUnit.toString());
console.log('Estimated gas price (WEI): ', estimatedGasPrice.toString());
console.log('Estimated gas (ETH): ', hre.ethers.utils.formatEther(estimatedGas));
console.log('Estimated gas price (GWei): ', estimatedGasPrice.div(1000000000).toString());
console.log(`Estimated gas (${getTokenName(hre)}): `, hre.ethers.utils.formatEther(estimatedGas));
return estimatedGas;
}

const getTokenName = (hre: HardhatRuntimeEnvironment) => {
switch(hre.network.name) {
case 'mainnet':
case 'sepolia':
case 'goerli':
return 'ETH';
case 'polygon':
case 'mumbai':
return 'MATIC';
default:
return 'ETH';
}
}

0 comments on commit 14f84ce

Please sign in to comment.