Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"prepublishOnly": "yarn validate:chains",
"prettier": "prettier --write \"./**/*.{js,md,json}\"",
"providers:ping": "ts-node scripts/ping-providers.ts",
"providers:time": "ts-node scripts/calculate-average-block-times.ts",
"test": "node --test --loader ts-node/esm ./src/**/*.test.ts",
"validate": "yarn validate:chains",
"validate:chains": "ts-node scripts/validate-chains.ts"
Expand Down
5 changes: 4 additions & 1 deletion scripts/calculate-average-block-times.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import { CHAINS } from '../src';
const BLOCK_LOOKBACK = 400_000;

async function calculateAverageBlockTimes(): Promise<void> {
const specifiedChain = CHAINS.find(chain => chain.alias === process.env.CHAIN);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A command line arg would probably be better imo (i.e. yarn providers:time --chain-alias=xyz), but this works too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's not ideal but I'm in a rush

const chains = specifiedChain ? [specifiedChain] : CHAINS;

const results = await Promise.allSettled(
CHAINS.map(async (chain) => {
chains.map(async (chain) => {
const provider = new JsonRpcProvider(chain.providerUrl);
const chainId = (await provider.getNetwork()).chainId;
if (chainId.toString() !== chain.id) {
Expand Down
5 changes: 3 additions & 2 deletions scripts/ping-providers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { JsonRpcProvider } from 'ethers';
import { CHAINS, getChainByAlias } from '../src';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

import { CHAINS } from '../src';

const chains = process.env.CHAIN ? [getChainByAlias(process.env.CHAIN)] : CHAINS;
const specifiedChain = CHAINS.find(chain => chain.alias === process.env.CHAIN);
const chains = specifiedChain ? [specifiedChain] : CHAINS;

chains.forEach(async (chain) => {
const provider = new JsonRpcProvider(chain.providerUrl);
Expand Down