Skip to content

Commit 918ff58

Browse files
committed
feat: Improve typings of chain explorer urls
1 parent 7ca0b92 commit 918ff58

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

src/chains.ts

+35-11
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ export interface SubstrateChain {
66
name: string
77
rpcUrls: [string, ...string[]]
88
ss58Prefix?: number
9-
explorerUrls?: string[]
9+
explorerUrls?: Partial<Record<SubstrateExplorer, string>>
1010
testnet?: boolean
1111
faucetUrls?: string[]
1212
}
1313

14+
export enum SubstrateExplorer {
15+
Subscan = 'subscan',
16+
PolkadotJs = 'polkadotjs',
17+
}
18+
1419
/**
1520
* Defined Substrate Chain Constants
1621
*/
@@ -21,9 +26,11 @@ export const development: SubstrateChain = {
2126
name: 'Local Development',
2227
ss58Prefix: 42,
2328
rpcUrls: ['ws://127.0.0.1:9944'],
24-
explorerUrls: [
25-
'https://polkadot.js.org/apps/#/explorer?rpc=ws://127.0.0.1:9944',
26-
],
29+
explorerUrls: {
30+
[SubstrateExplorer.PolkadotJs]: `https://polkadot.js.org/apps/?rpc=${encodeURIComponent(
31+
'ws://127.0.0.1:9944',
32+
)}/#/explorer`,
33+
},
2734
testnet: true,
2835
faucetUrls: [
2936
'https://polkadot.js.org/apps/#/accounts?rpc=ws://127.0.0.1:9944',
@@ -37,7 +44,11 @@ export const alephzeroTestnet: SubstrateChain = {
3744
name: 'Aleph Zero Testnet',
3845
ss58Prefix: 42,
3946
rpcUrls: ['wss://ws.test.azero.dev'],
40-
explorerUrls: ['https://azero.dev/?rpc=wss%3A%2F%2Fws.test.azero.dev'],
47+
explorerUrls: {
48+
[SubstrateExplorer.PolkadotJs]: `https://test.azero.dev/?rpc=${encodeURIComponent(
49+
'wss://ws.test.azero.dev',
50+
)}/#/explorer`,
51+
},
4152
testnet: true,
4253
faucetUrls: ['https://faucet.test.azero.dev'],
4354
}
@@ -46,19 +57,23 @@ export const rococo: SubstrateChain = {
4657
network: 'rococo',
4758
name: 'Rococo',
4859
rpcUrls: ['wss://rococo-rpc.polkadot.io'],
60+
explorerUrls: {
61+
[SubstrateExplorer.Subscan]: `https://rococo.subscan.io`,
62+
},
4963
testnet: true,
5064
faucetUrls: ['https://matrix.to/#/#rococo-faucet:matrix.org'],
51-
explorerUrls: ['https://rococo.subscan.io'],
5265
}
5366

5467
export const shibuya: SubstrateChain = {
5568
network: 'shibuya',
5669
name: 'Shibuya Testnet',
57-
testnet: true,
5870
ss58Prefix: 5,
5971
rpcUrls: ['wss://shibuya-rpc.dwellir.com'],
72+
explorerUrls: {
73+
[SubstrateExplorer.Subscan]: `https://shibuya.subscan.io`,
74+
},
75+
testnet: true,
6076
faucetUrls: ['https://portal.astar.network/#/shibuya-testnet/assets'],
61-
explorerUrls: ['https://shibuya.subscan.io'],
6277
}
6378

6479
/// Canary Networks (Kusama)
@@ -68,7 +83,9 @@ export const shiden: SubstrateChain = {
6883
name: 'Shiden',
6984
ss58Prefix: 5,
7085
rpcUrls: ['wss://shiden-rpc.dwellir.com'],
71-
explorerUrls: ['https://shiden.subscan.io'],
86+
explorerUrls: {
87+
[SubstrateExplorer.Subscan]: `https://shiden.subscan.io`,
88+
},
7289
}
7390

7491
/// Mainnets
@@ -78,16 +95,23 @@ export const alephzero: SubstrateChain = {
7895
name: 'Aleph Zero',
7996
ss58Prefix: 42,
8097
rpcUrls: ['wss://ws.azero.dev'],
81-
explorerUrls: ['https://azero.dev/?rpc=wss%3A%2F%2Fws.azero.dev'],
98+
explorerUrls: {
99+
[SubstrateExplorer.Subscan]: `https://alephzero.subscan.io`,
100+
[SubstrateExplorer.PolkadotJs]: `https://azero.dev/?rpc=${encodeURIComponent(
101+
'wss://ws.azero.dev',
102+
)}/#/explorer`,
103+
},
82104
}
83105

84106
export const astar: SubstrateChain = {
85107
network: 'astar',
86108
name: 'Astar',
87109
ss58Prefix: 5,
88110
rpcUrls: ['wss://astar-rpc.dwellir.com'],
111+
explorerUrls: {
112+
[SubstrateExplorer.Subscan]: `https://astar.subscan.io`,
113+
},
89114
faucetUrls: [],
90-
explorerUrls: ['https://astar.subscan.io'],
91115
}
92116

93117
/**

0 commit comments

Comments
 (0)