Skip to content

Commit

Permalink
add ovm etherscan key support (#1703)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeal-eth committed Feb 26, 2022
1 parent 7282e75 commit 2184636
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
1 change: 1 addition & 0 deletions .env.example
@@ -1,4 +1,5 @@
ETHERSCAN_KEY=SomeEtherscanKey
OVM_ETHERSCAN_KEY=SomeEtherscanKey
PROVIDER_URL=https://network.infura.io/v3/SomeInfuraKey (runtime replaces "network")
PROVIDER_URL_MAINNET=https://mainnet.infura.io/v3/SomeInfuraKey
DEPLOY_PRIVATE_KEY=SomeEthereumPrivateKey (including 0x prefix)
Expand Down
16 changes: 14 additions & 2 deletions examples/historical-state.js
Expand Up @@ -23,15 +23,27 @@ program
.option('-n, --network <value>', 'The network to run off.', x => x.toLowerCase(), 'mainnet')
.option('-i, --infura-project-id <value>', 'An infura project ID with access to archive state')
.option('-e, --etherscan-key <value>', 'Etherscan api key')
.option('--use-ovm', 'Use OVM')
.action(
async (
_,
{ network, contract, source, blockNumber, method, infuraProjectId, etherscanKey, args }
{
network,
contract,
source,
blockNumber,
method,
infuraProjectId,
etherscanKey,
args,
useOvm,
}
) => {
if (!infuraProjectId || !etherscanKey) {
require('dotenv').config();
infuraProjectId = infuraProjectId || process.env.INFURA_PROJECT_ID;
etherscanKey = etherscanKey || process.env.ETHERSCAN_KEY;
etherscanKey =
etherscanKey || (useOvm ? process.env.OVM_ETHERSCAN_KEY : process.env.ETHERSCAN_KEY);
if (!infuraProjectId) {
throw Error('Missing infura project ID');
}
Expand Down
12 changes: 9 additions & 3 deletions publish/src/commands/deploy-migration.js
Expand Up @@ -214,12 +214,18 @@ const deployMigration = async ({
});
}

await verifyMigrationContract({ deployedContract, releaseName, buildPath, etherscanUrl });
await verifyMigrationContract({ deployedContract, releaseName, buildPath, etherscanUrl, useOvm });

console.log(gray(`Done.`));
};

async function verifyMigrationContract({ deployedContract, releaseName, buildPath, etherscanUrl }) {
async function verifyMigrationContract({
deployedContract,
releaseName,
buildPath,
etherscanUrl,
useOvm,
}) {
const readFlattened = () => {
const flattenedFilename = path.join(
buildPath,
Expand Down Expand Up @@ -254,7 +260,7 @@ async function verifyMigrationContract({ deployedContract, releaseName, buildPat
compilerversion: solcVersion,
optimizationUsed: 1,
runs,
apikey: process.env.ETHERSCAN_KEY,
apikey: useOvm ? process.env.OVM_ETHERSCAN_KEY : process.env.ETHERSCAN_KEY,
}),
{
headers: {
Expand Down
10 changes: 8 additions & 2 deletions publish/src/commands/extract-staking-balances.js
Expand Up @@ -21,7 +21,12 @@ const DEFAULTS = {
network: 'kovan',
};

async function extractStakingBalances({ network = DEFAULTS.network, deploymentPath, synth }) {
async function extractStakingBalances({
network = DEFAULTS.network,
deploymentPath,
useOvm,
synth,
}) {
ensureNetwork(network);
deploymentPath = deploymentPath || getDeploymentPathForNetwork({ network });
ensureDeploymentPath(deploymentPath);
Expand Down Expand Up @@ -71,7 +76,7 @@ async function extractStakingBalances({ network = DEFAULTS.network, deploymentPa
module: 'account',
action: 'txlist',
address: stakingAddress,
apikey: process.env.ETHERSCAN_KEY,
apikey: useOvm ? process.env.OVM_ETHERSCAN_KEY : process.env.ETHERSCAN_KEY,
},
});

Expand Down Expand Up @@ -272,6 +277,7 @@ module.exports = {
'-d, --deployment-path <value>',
`Path to a folder that has your input configuration file ${CONFIG_FILENAME}, the synth list ${SYNTHS_FILENAME} and where your ${DEPLOYMENT_FILENAME} files will go`
)
.option('-z, --use-ovm', 'Target deployment for the OVM (Optimism).')
.option('-s, --synth <value>', 'The synth to extract from')
.description('Extracts staking reward balances')
.action(async (...args) => {
Expand Down
8 changes: 5 additions & 3 deletions publish/src/commands/verify.js
Expand Up @@ -56,6 +56,8 @@ const verify = async ({ buildPath, deploymentPath, network, useOvm }) => {

const tableData = [];

const etherscanKey = useOvm ? process.env.OVM_ETHERSCAN_KEY : process.env.ETHERSCAN_KEY;

for (const name of Object.keys(config)) {
const { address } = deployment.targets[name];
// Check if this contract already has been verified.
Expand All @@ -65,7 +67,7 @@ const verify = async ({ buildPath, deploymentPath, network, useOvm }) => {
module: 'contract',
action: 'getabi',
address,
apikey: process.env.ETHERSCAN_KEY,
apikey: etherscanKey,
},
});

Expand All @@ -82,7 +84,7 @@ const verify = async ({ buildPath, deploymentPath, network, useOvm }) => {
action: 'txlist',
address,
sort: 'asc',
apikey: process.env.ETHERSCAN_KEY,
apikey: etherscanKey,
},
});

Expand Down Expand Up @@ -186,7 +188,7 @@ const verify = async ({ buildPath, deploymentPath, network, useOvm }) => {
libraryname2: 'SystemSettingsLib',
libraryaddress1: deployment.targets['SafeDecimalMath'].address,
libraryaddress2: (deployment.targets['SystemSettingsLib'] || {}).address,
apikey: process.env.ETHERSCAN_KEY,
apikey: etherscanKey,
}),
{
headers: {
Expand Down

0 comments on commit 2184636

Please sign in to comment.