diff --git a/.changeset/breezy-timers-wash.md b/.changeset/breezy-timers-wash.md new file mode 100644 index 0000000000..2a2fced47a --- /dev/null +++ b/.changeset/breezy-timers-wash.md @@ -0,0 +1,6 @@ +--- +'@api3/airnode-node': minor +'@api3/airnode-protocol': minor +--- + +BREAKING CHANGE: Remove chainNames and networks from references.json and instead use api3/chains diff --git a/packages/airnode-node/package.json b/packages/airnode-node/package.json index b02f867ced..8d63dc3e09 100644 --- a/packages/airnode-node/package.json +++ b/packages/airnode-node/package.json @@ -29,6 +29,7 @@ "@api3/airnode-protocol": "^0.13.0", "@api3/airnode-utilities": "^0.13.0", "@api3/airnode-validator": "^0.13.0", + "@api3/chains": "^4.1.1", "@api3/commons": "^0.5.0", "@api3/ois": "2.3.1", "@api3/promise-utils": "^0.4.0", diff --git a/packages/airnode-node/src/evm/evm-provider.ts b/packages/airnode-node/src/evm/evm-provider.ts index db484920d7..7640d9cc26 100644 --- a/packages/airnode-node/src/evm/evm-provider.ts +++ b/packages/airnode-node/src/evm/evm-provider.ts @@ -1,13 +1,15 @@ import { ethers } from 'ethers'; -import { networks } from '@api3/airnode-protocol'; +import { CHAINS } from '@api3/chains'; import { EVM_PROVIDER_TIMEOUT } from '../constants'; export function buildEVMProvider(url: string, chainId: string) { // Ethers makes a call to get the network in the background if it is // not provided/undefined when initializing the provider. We keep // a list of "known" networks to stop these extra calls if possible. - const network = networks[chainId] || null; + + const network = CHAINS.find((network) => network.id === chainId); + const ethersNetwork = network ? { name: network.alias, chainId: parseInt(network.id) } : undefined; // Ethers only let's us configure the timeout when creating a provider - return new ethers.providers.StaticJsonRpcProvider({ url, timeout: EVM_PROVIDER_TIMEOUT }, network); + return new ethers.providers.StaticJsonRpcProvider({ url, timeout: EVM_PROVIDER_TIMEOUT }, ethersNetwork); } diff --git a/packages/airnode-protocol/deployments/references.json b/packages/airnode-protocol/deployments/references.json index 34ad5fbae8..2c937c24a4 100644 --- a/packages/airnode-protocol/deployments/references.json +++ b/packages/airnode-protocol/deployments/references.json @@ -1,49 +1,4 @@ { - "chainNames": { - "1": "ethereum", - "5": "ethereum-goerli-testnet", - "10": "optimism", - "30": "rsk", - "31": "rsk-testnet", - "56": "bsc", - "97": "bsc-testnet", - "100": "gnosis", - "137": "polygon", - "250": "fantom", - "288": "boba-ethereum", - "416": "sx", - "420": "optimism-goerli-testnet", - "599": "metis-goerli-testnet", - "647": "sx-testnet", - "1088": "metis", - "1101": "polygon-zkevm", - "1284": "moonbeam", - "1285": "moonriver", - "1287": "moonbeam-testnet", - "1442": "polygon-zkevm-goerli-testnet", - "2001": "milkomeda-c1", - "4002": "fantom-testnet", - "5000": "mantle", - "5001": "mantle-goerli-testnet", - "8453": "base", - "10200": "gnosis-testnet", - "42161": "arbitrum", - "42170": "arbitrum-nova", - "43113": "avalanche-testnet", - "43114": "avalanche", - "56288": "boba-bnb", - "59140": "linea-goerli-testnet", - "59144": "linea", - "71401": "godwoken-testnet", - "71402": "godwoken", - "80001": "polygon-testnet", - "84531": "base-goerli-testnet", - "200101": "milkomeda-c1-testnet", - "421613": "arbitrum-goerli-testnet", - "11155111": "ethereum-sepolia-testnet", - "1313161554": "aurora", - "1313161555": "aurora-testnet" - }, "AccessControlRegistry": { "1": "0x92E5125adF385d86beDb950793526106143b6Df1", "5": "0x92E5125adF385d86beDb950793526106143b6Df1", @@ -223,179 +178,5 @@ "11155111": "0xFb10b1b0f68b3EaAcA1eCD12a47Cf7F55BeabB98", "1313161554": "0x04b833bD6339570B01aff994A72ea33cF92bD0EF", "1313161555": "0x2e768206bf5112e7D7efAf1d9df614C26475193f" - }, - "networks": { - "1": { - "chainId": 1, - "name": "ethereum" - }, - "5": { - "chainId": 5, - "name": "ethereum-goerli-testnet" - }, - "10": { - "chainId": 10, - "name": "optimism" - }, - "30": { - "chainId": 30, - "name": "rsk" - }, - "31": { - "chainId": 31, - "name": "rsk-testnet" - }, - "56": { - "chainId": 56, - "name": "bsc" - }, - "97": { - "chainId": 97, - "name": "bsc-testnet" - }, - "100": { - "chainId": 100, - "name": "gnosis" - }, - "137": { - "chainId": 137, - "name": "polygon" - }, - "250": { - "chainId": 250, - "name": "fantom" - }, - "288": { - "chainId": 288, - "name": "boba-ethereum" - }, - "416": { - "chainId": 416, - "name": "sx" - }, - "420": { - "chainId": 420, - "name": "optimism-goerli-testnet" - }, - "599": { - "chainId": 599, - "name": "metis-goerli-testnet" - }, - "647": { - "chainId": 647, - "name": "sx-testnet" - }, - "1088": { - "chainId": 1088, - "name": "metis" - }, - "1101": { - "chainId": 1101, - "name": "polygon-zkevm" - }, - "1284": { - "chainId": 1284, - "name": "moonbeam" - }, - "1285": { - "chainId": 1285, - "name": "moonriver" - }, - "1287": { - "chainId": 1287, - "name": "moonbeam-testnet" - }, - "1442": { - "chainId": 1442, - "name": "polygon-zkevm-goerli-testnet" - }, - "2001": { - "chainId": 2001, - "name": "milkomeda-c1" - }, - "4002": { - "chainId": 4002, - "name": "fantom-testnet" - }, - "5000": { - "chainId": 5000, - "name": "mantle" - }, - "5001": { - "chainId": 5001, - "name": "mantle-goerli-testnet" - }, - "8453": { - "chainId": 8453, - "name": "base" - }, - "10200": { - "chainId": 10200, - "name": "gnosis-testnet" - }, - "42161": { - "chainId": 42161, - "name": "arbitrum" - }, - "42170": { - "chainId": 42170, - "name": "arbitrum-nova" - }, - "43113": { - "chainId": 43113, - "name": "avalanche-testnet" - }, - "43114": { - "chainId": 43114, - "name": "avalanche" - }, - "56288": { - "chainId": 56288, - "name": "boba-bnb" - }, - "59140": { - "chainId": 59140, - "name": "linea-goerli-testnet" - }, - "59144": { - "chainId": 59144, - "name": "linea" - }, - "71401": { - "chainId": 71401, - "name": "godwoken-testnet" - }, - "71402": { - "chainId": 71402, - "name": "godwoken" - }, - "80001": { - "chainId": 80001, - "name": "polygon-testnet" - }, - "84531": { - "chainId": 84531, - "name": "base-goerli-testnet" - }, - "200101": { - "chainId": 200101, - "name": "milkomeda-c1-testnet" - }, - "421613": { - "chainId": 421613, - "name": "arbitrum-goerli-testnet" - }, - "11155111": { - "chainId": 11155111, - "name": "ethereum-sepolia-testnet" - }, - "1313161554": { - "chainId": 1313161554, - "name": "aurora" - }, - "1313161555": { - "chainId": 1313161555, - "name": "aurora-testnet" - } } } diff --git a/packages/airnode-protocol/scripts/generate-references.ts b/packages/airnode-protocol/scripts/generate-references.ts index d3dd4d0e67..7dba7db4b8 100644 --- a/packages/airnode-protocol/scripts/generate-references.ts +++ b/packages/airnode-protocol/scripts/generate-references.ts @@ -9,11 +9,6 @@ const networkNames = fs .map((item) => item.name); const references: any = {}; -references.chainNames = {}; - -for (const network of networkNames) { - references.chainNames[hre.config.networks[network].chainId] = network; -} for (const contractName of contractNames) { references[contractName] = {}; @@ -24,10 +19,4 @@ for (const contractName of contractNames) { } } -const networks = Object.entries(references.chainNames).reduce((acc, [chainId, name]) => { - if (name === 'mainnet') return { ...acc, [parseInt(chainId)]: { chainId: parseInt(chainId), name: 'homestead' } }; - return { ...acc, [parseInt(chainId)]: { chainId: parseInt(chainId), name } }; -}, {}); -references.networks = networks; - fs.writeFileSync(path.join('deployments', 'references.json'), JSON.stringify(references, null, 2) + '\n'); diff --git a/packages/airnode-protocol/src/index.ts b/packages/airnode-protocol/src/index.ts index 90795cd3f4..7128484b9a 100644 --- a/packages/airnode-protocol/src/index.ts +++ b/packages/airnode-protocol/src/index.ts @@ -10,7 +10,6 @@ * * The generated code "value exports" the factories, but "type exports" the contracts. */ -import { ethers } from 'ethers'; import { RequesterAuthorizerWithErc721__factory as RequesterAuthorizerWithErc721Factory, MockErc721__factory as MockErc721Factory, @@ -36,7 +35,6 @@ const AirnodeRrpDryRunAddresses: { [chainId: string]: string } = references.Airn const AccessControlRegistryAddresses: { [chainId: string]: string } = references.AccessControlRegistry; const RequesterAuthorizerWithAirnodeAddresses: { [chainId: string]: string } = references.RequesterAuthorizerWithAirnode; -const networks: { [chainId: string]: ethers.providers.Network } = references.networks; const PROTOCOL_IDS = { RRP: '1', @@ -72,7 +70,6 @@ export { RequesterAuthorizerWithErc721Factory, mocks, authorizers, - networks, references, PROTOCOL_IDS, erc721Mocks,