Skip to content

Commit

Permalink
Add etherscan verification script
Browse files Browse the repository at this point in the history
  • Loading branch information
elenadimitrova committed Nov 24, 2020
1 parent cf7e41f commit dee7bfc
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 35 deletions.
129 changes: 96 additions & 33 deletions package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@
"@uniswap/v2-core": "^1.0.1",
"ajv": "^6.10.0",
"aws-sdk": "^2.787.0",
"child_process": "^1.0.2",
"ethers": "^5.0.19",
"fs": "0.0.1-security",
"inquirer": "^7.0.0",
"node-fetch": "^2.6.1",
"openzeppelin-solidity": "2.3",
"semver": "^7.1.3"
"semver": "^7.1.3",
"util": "^0.12.3"
},
"devDependencies": {
"-": "0.0.1",
Expand All @@ -95,7 +97,7 @@
"truffle": "^5.1.48",
"truffle-assertions": "^0.9.2",
"truffle-flatten": "^1.0.8",
"truffle-plugin-verify": "^0.5.0",
"truffle-plugin-verify": "^0.5.2",
"web3": "^1.3.0",
"web3-eth-abi": "^1.3.0"
}
Expand Down
55 changes: 55 additions & 0 deletions scripts/verify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// ///////////////////////////////////////////////////////////////////
// Script to verify in EtherScan all contracts from the configuration file's
// "contracts" and "modules" sections.
// Can be executed (from the project root as we're loading .env file from root via `dotenv`) as:
// bash ./scripts/execute_script.sh --no-compile scripts/verify.js test
//
// where:
// - network = [test, staging, prod]
// ////////////////////////////////////////////////////////////////////
require("dotenv").config();

const util = require("util");
const exec = util.promisify(require("child_process").exec);

const ConfiguratorLoader = require("../utils/configurator-loader.js");
const Configurator = require("../utils/configurator.js");

async function execVerify(contractName, contractAddress, network) {
const res = await exec(`npx truffle run verify ${contractName}@${contractAddress} --network ${network}`).catch((e) => e);
console.log(res.stdout);
}

async function main() {
const idx = process.argv.indexOf("--network");
const network = process.argv[idx + 1];
const remotelyManagedNetworks = (process.env.S3_BUCKET_SUFFIXES || "").split(":");

// Ensure a supported network is requested
if (!remotelyManagedNetworks.includes(network)) {
console.error("Error: Invalid network selected");
return;
}

const bucket = `${process.env.S3_BUCKET_PREFIX}-${network}`;
const key = process.env.S3_CONFIG_KEY;
const configLoader = new ConfiguratorLoader.S3(bucket, key);

const configurator = new Configurator(configLoader);

// This will allow the config to be printed regardless of whether it's valid or not
await configurator.load(false);
const configuration = configurator.copyConfig();

for (const [contractName, contractAddress] of Object.entries(configuration.contracts)) {
await execVerify(contractName, contractAddress, network);
}

for (const [moduleName, moduleAddress] of Object.entries(configuration.modules)) {
await execVerify(moduleName, moduleAddress, network);
}
}

main().catch((err) => {
throw err;
});

0 comments on commit dee7bfc

Please sign in to comment.