diff --git a/.changeset/wild-planets-crash.md b/.changeset/wild-planets-crash.md new file mode 100644 index 0000000000..35c98d1ed0 --- /dev/null +++ b/.changeset/wild-planets-crash.md @@ -0,0 +1,5 @@ +--- +'@api3/airnode-protocol': patch +--- + +Update airnode-protocol scripts with @api3/chains v3.0.0 changes diff --git a/packages/airnode-protocol/example.env b/packages/airnode-protocol/example.env index e1d2e327c1..ec3c77ab62 100644 --- a/packages/airnode-protocol/example.env +++ b/packages/airnode-protocol/example.env @@ -1,24 +1,24 @@ MNEMONIC="" -ETHERSCAN_API_KEY_arbitrum-goerli-testnet="" -ETHERSCAN_API_KEY_arbitrum-nova="" -ETHERSCAN_API_KEY_arbitrum="" -ETHERSCAN_API_KEY_avalanche-testnet="" -ETHERSCAN_API_KEY_avalanche="" -ETHERSCAN_API_KEY_boba-ethereum="" -ETHERSCAN_API_KEY_bsc-testnet="" -ETHERSCAN_API_KEY_bsc="" -ETHERSCAN_API_KEY_ethereum-goerli-testnet="" -ETHERSCAN_API_KEY_ethereum-sepolia-testnet="" -ETHERSCAN_API_KEY_ethereum="" -ETHERSCAN_API_KEY_fantom-testnet="" -ETHERSCAN_API_KEY_fantom="" -ETHERSCAN_API_KEY_gnosis="" -ETHERSCAN_API_KEY_moonbeam-testnet="" -ETHERSCAN_API_KEY_moonbeam="" -ETHERSCAN_API_KEY_moonriver="" -ETHERSCAN_API_KEY_optimism-goerli-testnet="" -ETHERSCAN_API_KEY_optimism="" -ETHERSCAN_API_KEY_polygon-testnet="" -ETHERSCAN_API_KEY_polygon-zkevm-goerli-testnet="" -ETHERSCAN_API_KEY_polygon-zkevm="" -ETHERSCAN_API_KEY_polygon="" +ETHERSCAN_API_KEY_ARBITRUM_GOERLI_TESTNET="" +ETHERSCAN_API_KEY_ARBITRUM_NOVA="" +ETHERSCAN_API_KEY_ARBITRUM="" +ETHERSCAN_API_KEY_AVALANCHE_TESTNET="" +ETHERSCAN_API_KEY_AVALANCHE="" +ETHERSCAN_API_KEY_BOBA_ETHEREUM="" +ETHERSCAN_API_KEY_BSC_TESTNET="" +ETHERSCAN_API_KEY_BSC="" +ETHERSCAN_API_KEY_ETHEREUM_GOERLI_TESTNET="" +ETHERSCAN_API_KEY_ETHEREUM_SEPOLIA_TESTNET="" +ETHERSCAN_API_KEY_ETHEREUM="" +ETHERSCAN_API_KEY_FANTOM_TESTNET="" +ETHERSCAN_API_KEY_FANTOM="" +ETHERSCAN_API_KEY_GNOSIS="" +ETHERSCAN_API_KEY_MOONBEAM_TESTNET="" +ETHERSCAN_API_KEY_MOONBEAM="" +ETHERSCAN_API_KEY_MOONRIVER="" +ETHERSCAN_API_KEY_OPTIMISM_GOERLI_TESTNET="" +ETHERSCAN_API_KEY_OPTIMISM="" +ETHERSCAN_API_KEY_POLYGON_TESTNET="" +ETHERSCAN_API_KEY_POLYGON_ZKEVM_GOERLI_TESTNET="" +ETHERSCAN_API_KEY_POLYGON_ZKEVM="" +ETHERSCAN_API_KEY_POLYGON="" diff --git a/packages/airnode-protocol/hardhat.config.js b/packages/airnode-protocol/hardhat.config.js index b8608ee989..0b89e0ba7e 100644 --- a/packages/airnode-protocol/hardhat.config.js +++ b/packages/airnode-protocol/hardhat.config.js @@ -6,31 +6,8 @@ require('hardhat-gas-reporter'); const api3Chains = require('@api3/chains'); require('dotenv').config(); -const { apiKey: etherscanApiKey, customChains: etherscanCustomChains } = api3Chains.hardhatEtherscan(); -const etherscan = { - apiKey: Object.entries(etherscanApiKey).reduce((populatedApiKey, etherscanApiKeyEntry) => { - const hardhatEtherscanChainAlias = etherscanApiKeyEntry[0]; - const chainAlias = etherscanApiKeyEntry[1]; - if (chainAlias !== 'DUMMY_VALUE') { - const envVariableName = `ETHERSCAN_API_KEY_${chainAlias}`; - populatedApiKey[hardhatEtherscanChainAlias] = process.env[envVariableName] ? process.env[envVariableName] : ''; - } else { - populatedApiKey[hardhatEtherscanChainAlias] = 'DUMMY_VALUE'; - } - return populatedApiKey; - }, {}), - customChains: etherscanCustomChains, -}; - -const networks = Object.entries(api3Chains.hardhatConfigNetworks()).reduce((networksWithMnemonic, networkEntry) => { - const chainAlias = networkEntry[0]; - const network = networkEntry[1]; - networksWithMnemonic[chainAlias] = { - ...network, - accounts: { mnemonic: process.env.MNEMONIC ? process.env.MNEMONIC : '' }, - }; - return networksWithMnemonic; -}, {}); +const etherscan = api3Chains.hardhatConfig.etherscan(); +const networks = api3Chains.hardhatConfig.networks(); module.exports = { etherscan, diff --git a/packages/airnode-protocol/package.json b/packages/airnode-protocol/package.json index 9aee39ed86..bcf0282816 100644 --- a/packages/airnode-protocol/package.json +++ b/packages/airnode-protocol/package.json @@ -29,7 +29,7 @@ "write-example-env-file": "hardhat run scripts/write-example-env-file.ts" }, "devDependencies": { - "@api3/chains": "^2.1.0", + "@api3/chains": "^3.1.0", "@nomiclabs/hardhat-ethers": "^2.2.3", "@nomiclabs/hardhat-etherscan": "^3.1.7", "@nomiclabs/hardhat-waffle": "^2.0.6", diff --git a/packages/airnode-protocol/scripts/write-example-env-file.ts b/packages/airnode-protocol/scripts/write-example-env-file.ts index 07102e71c9..f4f496cf67 100644 --- a/packages/airnode-protocol/scripts/write-example-env-file.ts +++ b/packages/airnode-protocol/scripts/write-example-env-file.ts @@ -1,9 +1,9 @@ import * as fs from 'fs'; -import * as api3Chains from '@api3/chains'; +import { hardhatConfig } from '@api3/chains'; fs.writeFileSync( 'example.env', - api3Chains.getEnvVariables().reduce((fileContents: string, envVariableName: string) => { + hardhatConfig.getEnvVariableNames().reduce((fileContents: string, envVariableName: string) => { return fileContents + `${envVariableName}=""\n`; }, '') ); diff --git a/yarn.lock b/yarn.lock index 3dadd954e4..ab872f1909 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,10 +22,10 @@ dependencies: "@openzeppelin/contracts" "4.8.2" -"@api3/chains@^2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@api3/chains/-/chains-2.1.0.tgz#67219e94e3301378a14ba81d50d4740e093d5678" - integrity sha512-u/YIE6aXsoHssSc1kir0Ws/12oYEIFPIMm5yDxC6TxL0upglasmYx0vrty40QVaksgsavva/CQNme+zwdJy4yA== +"@api3/chains@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@api3/chains/-/chains-3.1.0.tgz#37ae1a6c3d5419616d26a0340364587cbb81df86" + integrity sha512-lXEL6Of+Kcesb9j8LfTelttQwwVgYKU3Em5C7uiKofr3mSsxw3X0oaMRiAZBIRlCD7tuNWCXJx4wGmRcyFj+uA== dependencies: zod "^3.21.4"