Skip to content

Commit

Permalink
feat: multi-network verification config (Open-Attestation#87)
Browse files Browse the repository at this point in the history
* chore: update verify plugin

* feat: add multi network verification
  • Loading branch information
superical committed Apr 13, 2022
1 parent bb8f84d commit 5f21d8f
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 18 deletions.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ INFURA_APP_ID=

# API Keys
ETHERSCAN_API_KEY=
POLYGONSCAN_API_KEY=
COINMARKETCAP_API_KEY=

# Deployer Private Key
Expand Down
19 changes: 17 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import "./tasks";

dotenv.config();

const { INFURA_APP_ID, MNEMONIC, DEPLOYER_PK, COINMARKETCAP_API_KEY, ETHERSCAN_API_KEY } = process.env;
const { INFURA_APP_ID, MNEMONIC, DEPLOYER_PK, COINMARKETCAP_API_KEY, ETHERSCAN_API_KEY, POLYGONSCAN_API_KEY } =
process.env;
const IS_CI_ENV = process.env.NODE_ENV === "ci";

if (!IS_CI_ENV && !INFURA_APP_ID) {
Expand Down Expand Up @@ -63,7 +64,21 @@ const config: HardhatUserConfig = {
currency: "USD",
},
etherscan: {
apiKey: ETHERSCAN_API_KEY,
apiKey: {
/**
* Ethereum
*/
mainnet: ETHERSCAN_API_KEY,
ropsten: ETHERSCAN_API_KEY,
goerli: ETHERSCAN_API_KEY,
rinkeby: ETHERSCAN_API_KEY,
kovan: ETHERSCAN_API_KEY,
/**
* Polygon
*/
polygon: POLYGONSCAN_API_KEY,
polygonMumbai: POLYGONSCAN_API_KEY,
},
},
networks: {
/**
Expand Down
16 changes: 11 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@ls-age/commitlint-circle": "1.0.0",
"@maticnetwork/fx-portal": "^1.0.4",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-etherscan": "^2.1.7",
"@nomiclabs/hardhat-etherscan": "^3.0.3",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@openzeppelin/contracts": "^4.5.0",
"@typechain/ethers-v5": "^7.1.2",
Expand Down
10 changes: 6 additions & 4 deletions tasks/deploy-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { deployToken } from "./helpers/deploy-token";
import { verifyContract } from "./helpers/verify-contract";
import { TASK_DEPLOY_TOKEN } from "./task-names";

const wait = async (durationMs: number) => new Promise((resolve) => setTimeout(async () => resolve(true), durationMs));

task(TASK_DEPLOY_TOKEN)
.setDescription("Deploys the TradeTrustERC721 token and, optionally, Title Escrow factory if not provided.")
.addParam("name", "Name of the token")
Expand Down Expand Up @@ -43,8 +45,8 @@ task(TASK_DEPLOY_TOKEN)
});

if (verify) {
console.log("[Status] Waiting to verify (may take a while)...");
await token.deployTransaction.wait(5);
console.log("[Status] Waiting to verify (about a minute)...");
await wait(60000);
console.log("[Status] Start verification");

if (deployedNewFactory) {
Expand All @@ -64,8 +66,8 @@ task(TASK_DEPLOY_TOKEN)
}

console.log("[Status] Completed deploying token");
} catch (err) {
} catch (err: any) {
console.log("[Status] An error occurred while deploying token");
console.error(err);
console.error(err.message);
}
});
19 changes: 13 additions & 6 deletions tasks/helpers/verify-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ export const verifyContract = async ({ hre, address, constructorArgsParams, cont
return;
}
console.log(`[Status] Verifying contract ${address}...`);
await hre.run("verify", {
address,
constructorArgsParams,
contract,
});
console.log(`[Status] Verified contract at ${address}`);
try {
await hre.run("verify:verify", {
address,
constructorArguments: constructorArgsParams,
contract,
});
} catch (err: any) {
if ((err.message as string).indexOf("Reason: Already Verified") === -1) {
throw err;
}
} finally {
console.log(`[Status] Verified contract at ${address}`);
}
};

0 comments on commit 5f21d8f

Please sign in to comment.