Skip to content

Commit

Permalink
refactor: use api3/chains for chain names in airnode-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dcroote committed Dec 22, 2023
1 parent b87e0b3 commit 1e6cc9b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-wombats-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@api3/airnode-examples': patch
---

Use api3/chains instead of airnode-protocol for chain names
10 changes: 4 additions & 6 deletions packages/airnode-examples/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { join } from 'path';
import { parse as parseEnvFile } from 'dotenv';
import prompts, { PromptObject } from 'prompts';
import isWsl from 'is-wsl';
import references from '@api3/airnode-protocol/deployments/references.json';
import { AirnodeRrpV0 } from '@api3/airnode-protocol/deployments/references.json';
import { hardhatConfig } from '@api3/chains';

export const supportedNetworks = ['ethereum-sepolia-testnet', 'polygon-testnet', 'ethereum-goerli-testnet'] as const;

Expand Down Expand Up @@ -104,12 +105,9 @@ export const setMaxPromiseTimeout = <T>(promise: Promise<T>, timeoutMs: number):
* @returns The AirnodeRrpV0 contract address for the named network
*/
export const getExistingAirnodeRrpV0 = (networkName: string) => {
const { chainNames, AirnodeRrpV0 } = references;
const networks = hardhatConfig.networks();

// get network ID (key) for a given network name (value)
const networkId = (Object.keys(chainNames) as (keyof typeof chainNames)[]).find((name) => {
return chainNames[name] === networkName;
});
const networkId = networks[networkName].chainId.toString() as keyof typeof AirnodeRrpV0;

if (networkId) {
return AirnodeRrpV0[networkId];
Expand Down

0 comments on commit 1e6cc9b

Please sign in to comment.