Skip to content

Commit fe9b191

Browse files
committed
Create networkNames.md and assocated scripts that keep it up to date
1 parent 080384f commit fe9b191

4 files changed

Lines changed: 182 additions & 2 deletions

File tree

package.json

Lines changed: 3 additions & 2 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": {

packages/network/networkNames.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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+
| Chain ID | Name Slug |
10+
| --- | --- |
11+
| 1 | mainnet |
12+
| 3 | ropsten |
13+
| 4 | rinkeby |
14+
| 5 | goerli |
15+
| 10 | optimism |
16+
| 40 | telos |
17+
| 41 | telos-testnet |
18+
| 42 | kovan |
19+
| 56 | bsc |
20+
| 69 | optimism-kovan |
21+
| 97 | bsc-testnet |
22+
| 100 | gnosis |
23+
| 137 | polygon |
24+
| 273 | xr1 |
25+
| 420 | optimism-goerli |
26+
| 1101 | polygon-zkevm |
27+
| 1284 | moonbeam |
28+
| 1287 | moonbase-alpha |
29+
| 1868 | soneium |
30+
| 1946 | soneium-minato |
31+
| 1993 | b3-sepolia |
32+
| 2730 | xr-sepolia |
33+
| 6283 | laos |
34+
| 7668 | rootnet |
35+
| 7672 | rootnet-porcini |
36+
| 8333 | b3 |
37+
| 8453 | base |
38+
| 10143 | monad-testnet |
39+
| 13371 | immutable-zkevm |
40+
| 13473 | immutable-zkevm-testnet |
41+
| 19011 | homeverse |
42+
| 31337 | hardhat |
43+
| 31338 | hardhat2 |
44+
| 33111 | apechain-testnet |
45+
| 33139 | apechain |
46+
| 40875 | homeverse-testnet |
47+
| 42161 | arbitrum |
48+
| 42170 | arbitrum-nova |
49+
| 42793 | etherlink |
50+
| 43113 | avalanche-testnet |
51+
| 43114 | avalanche |
52+
| 50312 | somnia-testnet |
53+
| 62850 | laos-sigma-testnet |
54+
| 80001 | mumbai |
55+
| 80002 | amoy |
56+
| 81457 | blast |
57+
| 84531 | base-goerli |
58+
| 84532 | base-sepolia |
59+
| 94984 | borne-testnet |
60+
| 128123 | etherlink-testnet |
61+
| 421613 | arbitrum-goerli |
62+
| 421614 | arbitrum-sepolia |
63+
| 660279 | xai |
64+
| 11155111 | sepolia |
65+
| 11155420 | optimism-sepolia |
66+
| 21000000 | toy-testnet |
67+
| 37084624 | skale-nebula-testnet |
68+
| 168587773 | blast-sepolia |
69+
| 1482601649 | skale-nebula |
70+
| 37714555429 | xai-sepolia |
71+
72+
| Chain Name | Name Slug |
73+
| --- | --- |
74+
| APE Chain | apechain |
75+
| APE Chain Testnet | apechain-testnet |
76+
| Arbitrum Goerli | arbitrum-goerli |
77+
| Arbitrum Nova | arbitrum-nova |
78+
| Arbitrum One | arbitrum |
79+
| Arbitrum Sepolia | arbitrum-sepolia |
80+
| Avalanche | avalanche |
81+
| Avalanche Testnet | avalanche-testnet |
82+
| B3 | b3 |
83+
| B3 Sepolia | b3-sepolia |
84+
| Base (Coinbase) | base |
85+
| Base Goerli | base-goerli |
86+
| Base Sepolia | base-sepolia |
87+
| Blast | blast |
88+
| Blast Sepolia | blast-sepolia |
89+
| BNB Smart Chain | bsc |
90+
| BNB Smart Chain Testnet | bsc-testnet |
91+
| Borne Testnet | borne-testnet |
92+
| Ethereum | mainnet |
93+
| ETHERLINK | etherlink |
94+
| ETHERLINK Testnet | etherlink-testnet |
95+
| Gnosis Chain | gnosis |
96+
| Goerli | goerli |
97+
| Hardhat (local testnet) | hardhat |
98+
| Hardhat (local testnet) | hardhat2 |
99+
| Immutable zkEVM | immutable-zkevm |
100+
| Immutable zkEVM Testnet | immutable-zkevm-testnet |
101+
| Kovan | kovan |
102+
| LAOS | laos |
103+
| LAOS Sigma Testnet | laos-sigma-testnet |
104+
| MONAD Testnet | monad-testnet |
105+
| Moonbase Alpha | moonbase-alpha |
106+
| Moonbeam | moonbeam |
107+
| Oasys Homeverse | homeverse |
108+
| Oasys Homeverse Testnet | homeverse-testnet |
109+
| Optimism | optimism |
110+
| Optimism Goerli | optimism-goerli |
111+
| Optimism Kovan | optimism-kovan |
112+
| Optimism Sepolia | optimism-sepolia |
113+
| Polygon | polygon |
114+
| Polygon Amoy | amoy |
115+
| Polygon Mumbai | mumbai |
116+
| Polygon zkEVM | polygon-zkevm |
117+
| Rinkeby | rinkeby |
118+
| Ropsten | ropsten |
119+
| Sepolia | sepolia |
120+
| SKALE Nebula Gaming Hub | skale-nebula |
121+
| SKALE Nebula Gaming Hub Testnet | skale-nebula-testnet |
122+
| SOMNIA Testnet | somnia-testnet |
123+
| Soneium | soneium |
124+
| Soneium Minato (Testnet) | soneium-minato |
125+
| Telos | telos |
126+
| Telos Testnet | telos-testnet |
127+
| The Root Network | rootnet |
128+
| The Root Network Porcini Testnet | rootnet-porcini |
129+
| TOY (Testnet) | toy-testnet |
130+
| Xai | xai |
131+
| Xai Sepolia | xai-sepolia |
132+
| XR Sepolia | xr-sepolia |
133+
| XR1 | xr1 |
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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
chainId:number,
12+
name:string,
13+
title?:string
14+
}>;
15+
16+
networkObjs.sort((a, b) => a.chainId - b.chainId);
17+
const lines:string[] = [];
18+
lines.push(`| Chain ID | Name Slug |`);
19+
lines.push(`| --- | --- |`);
20+
for (const n of networkObjs) {
21+
lines.push(`| ${n.chainId} | ${n.name} |`);
22+
}
23+
24+
lines.push("");
25+
26+
networkObjs.sort((a, b) => a.title?.localeCompare(b.title || "") || 0);
27+
lines.push(`| Chain Name | Name Slug |`);
28+
lines.push(`| --- | --- |`);
29+
for (const n of networkObjs) {
30+
lines.push(`| ${n.title} | ${n.name} |`);
31+
}
32+
33+
const doc = template.replace("<!-- tables start here -->", lines.join("\n"));
34+
35+
fs.writeFileSync(outputPath, doc, 'utf8')
36+
37+
console.log(`Updated network/networkNames.md`)

0 commit comments

Comments
 (0)