Skip to content

Commit 85ba8e7

Browse files
authored
Create networkNames.md and assocated scripts that keep it up to date (#700)
1 parent 080384f commit 85ba8e7

4 files changed

Lines changed: 105 additions & 3 deletions

File tree

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
"watch": "preconstruct watch",
88
"clean": "rimraf ./node_modules",
99
"changeset": "changeset",
10-
"changeset:version": "changeset version && pnpm update-version",
10+
"changeset:version": "changeset version && pnpm update-version && pnpm update-network-names-doc",
1111
"changeset:publish": "pnpm build && changeset publish",
1212
"changeset:snapshot": "changeset && changeset version --snapshot && pnpm i && pnpm build && changeset publish --tag snapshot && git tag | grep '0\\.0\\.0' | xargs git tag -d && echo && echo -n 'Published sequence.js snapshot ' && grep '^## ' packages/0xsequence/CHANGELOG.md | head -n 1 | cut -c 4-",
1313
"update-version": "node ./scripts/update-version",
14+
"update-network-names-doc": "ts-node ./scripts/update-network-names-doc.ts",
1415
"test": "pnpm -r --workspace-concurrency=1 test",
1516
"test:parallel": "pnpm -r test",
1617
"lint": "eslint -c .eslintrc.js 'packages/**/src/**/*.{ts,tsx}'",
@@ -28,7 +29,7 @@
2829
"husky": {
2930
"hooks": {
3031
"pre-commit": "pnpm lint",
31-
"pre-push": "pnpm lint && pnpm build && pnpm test:parallel"
32+
"pre-push": "pnpm lint && pnpm build && pnpm test:parallel && pnpm update-network-names-doc"
3233
}
3334
},
3435
"devDependencies": {
@@ -102,5 +103,6 @@
102103
"got@<11.8.5": ">=11.8.5",
103104
"glob-parent@<5.1.2": ">=5.1.2"
104105
}
105-
}
106+
},
107+
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0"
106108
}

packages/network/networkNames.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Network Names
2+
3+
Though networks have proper full names, we sometimes need to refer to a chain by a name slug.
4+
5+
A name slug is the name, sometimes simplified, and in kebab-case. This maximizes compatibility in the event that you want to use chain names as url paths, or filenames.
6+
7+
You can use this file as a reference to look up the correct network name slug a network's full name or its chain ID.
8+
9+
| Network Name | Chain ID | Name Slug |
10+
| --- | --- | --- |
11+
| Ethereum | 1 | mainnet |
12+
| Optimism | 10 | optimism |
13+
| Telos | 40 | telos |
14+
| Telos Testnet | 41 | telos-testnet |
15+
| BNB Smart Chain | 56 | bsc |
16+
| BNB Smart Chain Testnet | 97 | bsc-testnet |
17+
| Gnosis Chain | 100 | gnosis |
18+
| Polygon | 137 | polygon |
19+
| XR1 | 273 | xr1 |
20+
| Polygon zkEVM | 1101 | polygon-zkevm |
21+
| Moonbeam | 1284 | moonbeam |
22+
| Moonbase Alpha | 1287 | moonbase-alpha |
23+
| Soneium | 1868 | soneium |
24+
| Soneium Minato (Testnet) | 1946 | soneium-minato |
25+
| B3 Sepolia | 1993 | b3-sepolia |
26+
| XR Sepolia | 2730 | xr-sepolia |
27+
| LAOS | 6283 | laos |
28+
| The Root Network | 7668 | rootnet |
29+
| The Root Network Porcini Testnet | 7672 | rootnet-porcini |
30+
| B3 | 8333 | b3 |
31+
| Base (Coinbase) | 8453 | base |
32+
| MONAD Testnet | 10143 | monad-testnet |
33+
| Immutable zkEVM | 13371 | immutable-zkevm |
34+
| Immutable zkEVM Testnet | 13473 | immutable-zkevm-testnet |
35+
| Oasys Homeverse | 19011 | homeverse |
36+
| Hardhat (local testnet) | 31337 | hardhat |
37+
| Hardhat (local testnet) | 31338 | hardhat2 |
38+
| APE Chain Testnet | 33111 | apechain-testnet |
39+
| APE Chain | 33139 | apechain |
40+
| Oasys Homeverse Testnet | 40875 | homeverse-testnet |
41+
| Arbitrum One | 42161 | arbitrum |
42+
| Arbitrum Nova | 42170 | arbitrum-nova |
43+
| ETHERLINK | 42793 | etherlink |
44+
| Avalanche Testnet | 43113 | avalanche-testnet |
45+
| Avalanche | 43114 | avalanche |
46+
| SOMNIA Testnet | 50312 | somnia-testnet |
47+
| LAOS Sigma Testnet | 62850 | laos-sigma-testnet |
48+
| Polygon Amoy | 80002 | amoy |
49+
| Blast | 81457 | blast |
50+
| Base Sepolia | 84532 | base-sepolia |
51+
| Borne Testnet | 94984 | borne-testnet |
52+
| ETHERLINK Testnet | 128123 | etherlink-testnet |
53+
| Arbitrum Sepolia | 421614 | arbitrum-sepolia |
54+
| Xai | 660279 | xai |
55+
| Sepolia | 11155111 | sepolia |
56+
| Optimism Sepolia | 11155420 | optimism-sepolia |
57+
| TOY (Testnet) | 21000000 | toy-testnet |
58+
| SKALE Nebula Gaming Hub Testnet | 37084624 | skale-nebula-testnet |
59+
| Blast Sepolia | 168587773 | blast-sepolia |
60+
| SKALE Nebula Gaming Hub | 1482601649 | skale-nebula |
61+
| Xai Sepolia | 37714555429 | xai-sepolia |
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Network Names
2+
3+
Though networks have proper full names, we sometimes need to refer to a chain by a name slug.
4+
5+
A name slug is the name, sometimes simplified, and in kebab-case. This maximizes compatibility in the event that you want to use chain names as url paths, or filenames.
6+
7+
You can use this file as a reference to look up the correct network name slug a network's full name or its chain ID.
8+
9+
<!-- tables start here -->
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
const { networks } = require("@0xsequence/network/constants");
4+
5+
const networkPath = path.resolve(__dirname, '../packages/network')
6+
const templatePath = path.join(networkPath, 'networkNames.template.md')
7+
const outputPath = path.join(networkPath, 'networkNames.md')
8+
const template = fs.readFileSync(templatePath, 'utf8')
9+
10+
const networkObjs = Object.values(networks) as Array<{
11+
deprecated?: boolean,
12+
chainId: number,
13+
name: string,
14+
title?: string
15+
}>;
16+
17+
const activeNetworkObjs = networkObjs.filter(v => !v.deprecated).sort((a, b) => a.chainId - b.chainId)
18+
19+
const lines: string[] = [];
20+
lines.push(`| Network Name | Chain ID | Name Slug |`);
21+
lines.push(`| --- | --- | --- |`);
22+
for (const n of activeNetworkObjs) {
23+
lines.push(`| ${n.title} | ${n.chainId} | ${n.name} |`);
24+
}
25+
26+
const doc = template.replace("<!-- tables start here -->", lines.join("\n"));
27+
28+
fs.writeFileSync(outputPath, doc, 'utf8')
29+
30+
console.log(`Updated network/networkNames.md`)

0 commit comments

Comments
 (0)