Skip to content

Commit

Permalink
map hardhat network name to etherscan name to retrieve the etherscan …
Browse files Browse the repository at this point in the history
…api key
  • Loading branch information
yuetloo committed Apr 4, 2024
1 parent 7b70583 commit e7df7a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default {
'https://sepolia-rollup.arbitrum.io/rpc',
accounts,
},
optimisticEthereum: {
optimism: {
url: process.env.JSONRPC_HTTP_URL || 'https://mainnet.optimism.io',
accounts,
},
Expand Down
12 changes: 11 additions & 1 deletion contracts/tasks/runners/exportRound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ type RoundListEntry = {
isFinalized: boolean
}

// Map hardhat network name to the etherscan api network name in the hardhat.config
const ETHERSCAN_NETWORKS: Record<string, string> = {
optimism: 'optimisticEthereum',
}

const toUndefined = () => undefined
const toString = (val: bigint) => BigInt(val).toString()
const toZero = () => BigInt(0)
Expand All @@ -41,13 +46,18 @@ function roundListFileName(directory: string): string {
return path.join(directory, 'rounds.json')
}

function toEtherscanNetworkName(network: string): string {
return ETHERSCAN_NETWORKS[network] ?? network
}

function getEtherscanApiKey(config: any, network: string): string {
let etherscanApiKey = ''
if (config.etherscan?.apiKey) {
if (typeof config.etherscan.apiKey === 'string') {
etherscanApiKey = config.etherscan.apiKey
} else {
etherscanApiKey = config.etherscan.apiKey[network]
const etherscanNetwork = toEtherscanNetworkName(network)
etherscanApiKey = config.etherscan.apiKey[etherscanNetwork]
}
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/utils/providers/EtherscanProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const EtherscanApiUrl: Record<string, string> = {
arbitrum: 'https://api.arbiscan.io',
'arbitrum-goerli': 'https://api-goerli.arbiscan.io',
'arbitrum-sepolia': 'https://api-sepolia.arbiscan.io',
optimisticEthereum: 'https://api-optimistic.etherscan.io',
optimism: 'https://api-optimistic.etherscan.io',
'optimism-sepolia': 'https://api-sepolia-optimistic.etherscan.io',
}

Expand Down

0 comments on commit e7df7a8

Please sign in to comment.