Skip to content

Commit

Permalink
Merge pull request #34 from api3dao/bdrhn9/issue10
Browse files Browse the repository at this point in the history
List supported chains instead of hardcoding in README
  • Loading branch information
bdrhn9 authored May 16, 2024
2 parents cc766c5 + 1f9cad6 commit 9608dbc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 45 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ continuous-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ jobs:
node-version: 20
- run: yarn
- run: yarn lint
- run: yarn list-supported-chains
- run: yarn test
54 changes: 9 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,67 +41,31 @@ FEED_NAME=ETH/USD yarn get-data-feed-id
See the command below, but use your own `NETWORK` and `DATA_FEED_ID` values.

```sh
NETWORK=polygon-testnet DATA_FEED_ID=0x4385954e058fbe6b6a744f32a4f89d67aad099f8fb8b23e7ea8dd366ae88151d yarn deploy-data-feed-proxy
NETWORK=bsc-testnet DATA_FEED_ID=0x4385954e058fbe6b6a744f32a4f89d67aad099f8fb8b23e7ea8dd366ae88151d yarn deploy-data-feed-proxy
```

- Deploy DataFeedReaderExample.
See the command below, but use your own `NETWORK` and `PROXY` values.
See the [supported networks section](#supported-networks) for valid `NETWORK` values.

```sh
NETWORK=polygon-testnet PROXY=0x93F7efd59A74A3Ccc7168C0De481461e5Bd9518c yarn deploy
NETWORK=bsc-testnet PROXY=0x93F7efd59A74A3Ccc7168C0De481461e5Bd9518c yarn deploy
```

- Have DataFeedReaderExample read from the proxy.
See the command below, but use your own `NETWORK` value.

```sh
NETWORK=polygon-testnet yarn read-data-feed
NETWORK=bsc-testnet yarn read-data-feed
```

## Supported networks

See https://github.com/api3dao/chains for details
```sh
yarn list-supported-chains
```

### Mainnets

- arbitrum
- avalanche
- base
- bsc
- ethereum
- fantom
- gnosis
- kava
- linea
- mantle
- moonbeam
- moonriver
- optimism
- polygon-zkevm
- polygon
- rsk

### Testnets

- arbitrum-goerli-testnet
- avalanche-testnet
- base-goerli-testnet
- bsc-testnet
- cronos-testnet
- ethereum-goerli-testnet
- ethereum-sepolia-testnet
- fantom-testnet
- gnosis-testnet
- kava-testnet
- linea-goerli-testnet
- mantle-goerli-testnet
- moonbeam-testnet
- optimism-goerli-testnet
- polygon-testnet
- polygon-zkevm-goerli-testnet
- rsk-testnet
- scroll-goerli-testnet
See https://github.com/api3dao/chains for details

## Local development and testing

Expand All @@ -123,7 +87,7 @@ You can update the proxy that your DataFeedReaderExample reads from.
- See the command below, but use your own `NETWORK` and `PROXY` values

```sh
NETWORK=polygon-testnet PROXY=0x08506208E776ecbdF4cE9DB69C08Aa90A06825C0 yarn update-proxy
NETWORK=bsc-testnet PROXY=0x08506208E776ecbdF4cE9DB69C08Aa90A06825C0 yarn update-proxy
```

### Deploy a DataFeedProxyWithOev
Expand All @@ -140,7 +104,7 @@ Users that want OEV-support should deploy a DataFeedProxyWithOev (instead of a D
See the command below, but use your own `NETWORK`, `DATA_FEED_ID` and `OEV_BENEFICIARY` values.

```sh
NETWORK=polygon-testnet DATA_FEED_ID=0x4385954e058fbe6b6a744f32a4f89d67aad099f8fb8b23e7ea8dd366ae88151d OEV_BENEFICIARY=0x07b589f06bD0A5324c4E2376d66d2F4F25921DE1 yarn deploy-data-feed-proxy-with-oev
NETWORK=bsc-testnet DATA_FEED_ID=0x4385954e058fbe6b6a744f32a4f89d67aad099f8fb8b23e7ea8dd366ae88151d OEV_BENEFICIARY=0x07b589f06bD0A5324c4E2376d66d2F4F25921DE1 yarn deploy-data-feed-proxy-with-oev
```

Note that DataFeedProxy and DataFeedProxyWithOev have identical interfaces, which is exported by `@api3/contracts` as IProxy.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"lint": "yarn run prettier:check && yarn run lint:eslint && yarn run lint:solhint",
"lint:solhint": "solhint ./contracts/**/*.sol",
"lint:eslint": "eslint . --ext .js,.ts",
"list-supported-chains": "node scripts/list-supported-chains.js",
"prettier:check": "prettier --check \"./**/*.{js,ts,md,json,sol}\"",
"prettier": "prettier --write \"./**/*.{js,ts,md,json,sol}\"",
"read-data-feed": "hardhat run scripts/read-data-feed.js --network $NETWORK",
Expand Down
28 changes: 28 additions & 0 deletions scripts/list-supported-chains.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { CHAINS } = require('@api3/chains');
const { nodaryChainIds } = require('@nodary/utilities');

async function main() {
const mainnets = [];
const testnets = [];

nodaryChainIds().forEach((chainId) => {
const chain = CHAINS.find(({ id }) => id === chainId);
if (!chain) {
throw new Error(`Chain ${chainId} does not exist in @api3/chains`);
}
const { alias: chainAlias } = chain;
chain.testnet ? testnets.push(chainAlias) : mainnets.push(chainAlias);
});

console.log('Mainnets:');
mainnets.sort().forEach((chainAlias) => console.log(` ${chainAlias}`));
console.log('Testnets:');
testnets.sort().forEach((chainAlias) => console.log(` ${chainAlias}`));
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

0 comments on commit 9608dbc

Please sign in to comment.