networkSpecs.ts 7.92 KB
Newer Older
1
// Copyright 2015-2020 Parity Technologies (UK) Ltd.
Hanwen Cheng's avatar
Hanwen Cheng committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// This file is part of Parity.

// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity.  If not, see <http://www.gnu.org/licenses/>.

17
18
19
20
21
22
23
24
25
import colors from 'styles/colors';
import {
	EthereumNetworkParams,
	NetworkParams,
	NetworkProtocol,
	SubstrateNetworkParams,
	UnknownNetworkParams
} from 'types/networkSpecsTypes';

26
27
export const unknownNetworkPathId = '';

28
29
30
export const NetworkProtocols: {
	[key: string]: NetworkProtocol;
} = Object.freeze({
31
32
33
	ETHEREUM: 'ethereum',
	SUBSTRATE: 'substrate',
	UNKNOWN: 'unknown'
34
35
36
});

// accounts for which the network couldn't be found (failed migration, removed network)
37
38
39
export const UnknownNetworkKeys: {
	[key: string]: string;
} = Object.freeze({
40
	UNKNOWN: 'unknown'
41
});
Alexey's avatar
Alexey committed
42

43
// ethereumChainId is used as Network key for Ethereum networks
44
/* eslint-disable sort-keys */
45
46
47
export const EthereumNetworkKeys: {
	[key: string]: string;
} = Object.freeze({
48
49
50
51
52
53
	FRONTIER: '1',
	ROPSTEN: '3',
	RINKEBY: '4',
	GOERLI: '5',
	KOVAN: '42',
	CLASSIC: '61'
54
});
Hanwen Cheng's avatar
Hanwen Cheng committed
55

56
/* eslint-enable sort-keys */
Alexey's avatar
Alexey committed
57

58
// genesisHash is used as Network key for Substrate networks
59
60
61
export const SubstrateNetworkKeys: {
	[key: string]: string;
} = Object.freeze({
62
63
64
65
	CENTRIFUGE:
		'0x67dddf2673b69e5f875f6f25277495834398eafd67f492e09f3f3345e003d1b5', // https://portal.chain.centrifuge.io/#/explorer/query/0
	CENTRIFUGE_AMBER:
		'0x092af6e7d25178ebab1677d15f66e37b30392b44ef442f728a53dd1bf48ec110', // https://portal.chain.centrifuge.io/#/explorer/query/0
66
67
	EDGEWARE:
		'0x742a2ca70c2fda6cee4f8df98d64c4c670a052d9568058982dad9d5a7a135c5b', // https://polkascan.io/pre/edgeware/block/0
68
	KULUPU: '0xf7a99d3cb92853d00d5275c971c132c074636256583fee53b3bbe60d7b8769ba',
69
70
71
	KUSAMA: '0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe', // https://polkascan.io/pre/kusama-cc3/block/0
	KUSAMA_CC2:
		'0xe3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f636',
72
	KUSAMA_DEV:
73
		'0x5e9679182f658e148f33d3f760f11179977398bb3da8d1f0bf7b267fe6b3ebb0',
74
	POLKADOT:
75
		'0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3',
76
	SUBSTRATE_DEV:
77
		'0x0d667fd278ec412cd9fccdb066f09ed5b4cfd9c9afa9eb747213acb02b1e70bc', // substrate --dev commit ac6a2a783f0e1f4a814cf2add40275730cd41be1 hosted on wss://dev-node.substrate.dev .
78
	WESTEND: '0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e'
79
});
Alexey's avatar
Alexey committed
80

81
const unknownNetworkBase: { [key: string]: UnknownNetworkParams } = {
82
	[UnknownNetworkKeys.UNKNOWN]: {
83
		color: colors.signal.error,
84
85
		order: 99,
		pathId: unknownNetworkPathId,
86
		prefix: 2,
87
		protocol: NetworkProtocols.UNKNOWN,
88
		secondaryColor: colors.background.card,
89
		title: 'Unknown network'
90
91
	}
};
92

93
94
95
const substrateNetworkBase: {
	[key: string]: Partial<SubstrateNetworkParams>;
} = {
96
	[SubstrateNetworkKeys.CENTRIFUGE]: {
97
		color: '#FCC367',
98
99
		decimals: 18,
		genesisHash: SubstrateNetworkKeys.CENTRIFUGE,
100
		logo: require('res/img/logos/Centrifuge.png'),
101
102
103
104
105
106
107
		order: 6,
		pathId: 'centrifuge',
		prefix: 36,
		title: 'Centrifuge Mainnet',
		unit: 'RAD'
	},
	[SubstrateNetworkKeys.CENTRIFUGE_AMBER]: {
108
		color: '#7C6136',
109
110
		decimals: 18,
		genesisHash: SubstrateNetworkKeys.CENTRIFUGE_AMBER,
111
		logo: require('res/img/logos/Centrifuge.png'),
112
113
114
115
116
117
		order: 7,
		pathId: 'centrifuge_amber',
		prefix: 42,
		title: 'Centrifuge Testnet Amber',
		unit: 'ARAD'
	},
118
	[SubstrateNetworkKeys.EDGEWARE]: {
119
		color: '#0B95E0',
120
121
		decimals: 18,
		genesisHash: SubstrateNetworkKeys.EDGEWARE,
122
		logo: require('res/img/logos/Edgeware.png'),
123
124
125
126
127
128
129
		order: 4,
		pathId: 'edgeware',
		prefix: 7,
		title: 'Edgeware',
		unit: 'EDG'
	},
	[SubstrateNetworkKeys.KULUPU]: {
130
		color: '#003366',
131
132
133
134
135
136
137
138
		decimals: 18,
		genesisHash: SubstrateNetworkKeys.KULUPU,
		order: 5,
		pathId: 'kulupu',
		prefix: 16,
		title: 'Kulupu',
		unit: 'KULU'
	},
139
	[SubstrateNetworkKeys.KUSAMA]: {
140
		color: '#000',
141
142
		decimals: 12,
		genesisHash: SubstrateNetworkKeys.KUSAMA,
143
		logo: require('res/img/logos/Kusama.png'),
144
		order: 2,
Thibaut Sardan's avatar
Thibaut Sardan committed
145
		pathId: 'kusama',
146
		prefix: 2,
Thibaut Sardan's avatar
Thibaut Sardan committed
147
		title: 'Kusama',
148
		unit: 'KSM'
149
	},
150
	[SubstrateNetworkKeys.KUSAMA_CC2]: {
151
		color: '#000',
152
153
		decimals: 12,
		genesisHash: SubstrateNetworkKeys.KUSAMA,
154
		logo: require('res/img/logos/Kusama.png'),
155
		order: 2,
156
157
158
159
160
		pathId: 'kusama_CC2',
		prefix: 2,
		title: 'Kusama',
		unit: 'KSM'
	},
161
	[SubstrateNetworkKeys.KUSAMA_DEV]: {
162
		color: '#000',
163
164
		decimals: 12,
		genesisHash: SubstrateNetworkKeys.KUSAMA_DEV,
165
		order: 99,
Hanwen Cheng's avatar
Hanwen Cheng committed
166
		pathId: 'kusama_dev',
167
168
169
170
		prefix: 2,
		title: 'Kusama Development',
		unit: 'KSM'
	},
171
	[SubstrateNetworkKeys.POLKADOT]: {
172
		color: '#E6027A',
173
		decimals: 12,
174
175
		genesisHash: null,
		logo: require('res/img/logos/Polkadot.png'),
176
177
178
179
180
181
		order: 1,
		pathId: 'polkadot',
		prefix: 0,
		title: 'Polkadot',
		unit: 'DOT'
	},
182
	[SubstrateNetworkKeys.SUBSTRATE_DEV]: {
183
		color: '#18FFB2',
Hanwen Cheng's avatar
Hanwen Cheng committed
184
		decimals: 12,
185
		genesisHash: SubstrateNetworkKeys.SUBSTRATE_DEV,
186
		order: 100,
Hanwen Cheng's avatar
Hanwen Cheng committed
187
		pathId: 'substrate_dev',
188
189
190
		prefix: 42,
		title: 'Substrate Development',
		unit: 'UNIT'
191
192
	},
	[SubstrateNetworkKeys.WESTEND]: {
193
		color: '#660D35',
194
195
		decimals: 12,
		genesisHash: SubstrateNetworkKeys.WESTEND,
196
		logo: require('res/img/logos/Polkadot.png'),
197
		order: 3,
198
199
200
201
		pathId: 'westend',
		prefix: 42,
		title: 'Westend',
		unit: 'WND'
202
	}
Alexey's avatar
Alexey committed
203
204
};

205
const ethereumNetworkBase: { [key: string]: Partial<EthereumNetworkParams> } = {
206
	[EthereumNetworkKeys.FRONTIER]: {
207
		color: '#8B94B3',
208
		ethereumChainId: EthereumNetworkKeys.FRONTIER,
209
		order: 101,
210
		secondaryColor: colors.background.card,
211
212
213
		title: 'Ethereum'
	},
	[EthereumNetworkKeys.CLASSIC]: {
214
		color: '#1a4d33',
215
		ethereumChainId: EthereumNetworkKeys.CLASSIC,
216
		logo: require('res/img/logos/Ethereum_Classic.png'),
217
		order: 102,
218
		secondaryColor: colors.background.card,
219
220
221
222
		title: 'Ethereum Classic'
	},
	[EthereumNetworkKeys.ROPSTEN]: {
		ethereumChainId: EthereumNetworkKeys.ROPSTEN,
223
		order: 104,
224
225
226
227
		title: 'Ropsten Testnet'
	},
	[EthereumNetworkKeys.GOERLI]: {
		ethereumChainId: EthereumNetworkKeys.GOERLI,
228
		order: 105,
229
230
231
232
		title: 'Görli Testnet'
	},
	[EthereumNetworkKeys.KOVAN]: {
		ethereumChainId: EthereumNetworkKeys.KOVAN,
233
		order: 103,
234
235
		title: 'Kovan Testnet'
	}
Alexey's avatar
Alexey committed
236
237
};

238
const ethereumDefaultValues = {
239
240
	color: '#434875',
	logo: require('res/img/logos/Ethereum.png'),
241
	protocol: NetworkProtocols.ETHEREUM,
242
	secondaryColor: colors.background.card
243
};
244

245
const substrateDefaultValues = {
246
	color: '#4C4646',
247
	logo: require('res/img/logos/Substrate_Dev.png'),
248
	protocol: NetworkProtocols.SUBSTRATE,
249
	secondaryColor: colors.background.card
250
};
251

252
253
254
255
function setDefault(
	networkBase: any,
	defaultProps: object
): { [key: string]: any } {
256
257
258
259
260
261
262
263
264
	return Object.keys(networkBase).reduce((acc, networkKey) => {
		return {
			...acc,
			[networkKey]: {
				...defaultProps,
				...networkBase[networkKey]
			}
		};
	}, {});
265
}
266

267
268
269
270
271
272
273
274
275
276
export const ETHEREUM_NETWORK_LIST: {
	[key: string]: EthereumNetworkParams;
} = Object.freeze(setDefault(ethereumNetworkBase, ethereumDefaultValues));
export const SUBSTRATE_NETWORK_LIST: {
	[key: string]: SubstrateNetworkParams;
} = Object.freeze(setDefault(substrateNetworkBase, substrateDefaultValues));
export const UNKNOWN_NETWORK: {
	[key: string]: UnknownNetworkParams;
} = Object.freeze(unknownNetworkBase);

277
278
279
280
281
282
283
284
const substrateNetworkMetas = Object.values({
	...SUBSTRATE_NETWORK_LIST,
	...UNKNOWN_NETWORK
});
export const PATH_IDS_LIST = substrateNetworkMetas.map(
	(meta: UnknownNetworkParams | SubstrateNetworkParams) => meta.pathId
);

285
export const NETWORK_LIST: { [key: string]: NetworkParams } = Object.freeze(
286
287
288
289
290
291
	Object.assign(
		{},
		SUBSTRATE_NETWORK_LIST,
		ETHEREUM_NETWORK_LIST,
		UNKNOWN_NETWORK
	)
292
);
293
294

export const defaultNetworkKey = SubstrateNetworkKeys.KUSAMA;