-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathindex.ts
61 lines (55 loc) · 1.74 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import ethereumDev from './ethereum/development';
import ethereumProd from './ethereum/production';
import seiDev from './sei/development';
import seiProd from './sei/production';
import celoDev from './celo/development';
import celoProd from './celo/production';
import blastDev from './blast/development';
import blastProd from './blast/production';
import { handleConfigOverrides } from './utils';
const configs = {
ethereum: {
development: ethereumDev,
production: ethereumProd,
},
sei: {
development: seiDev,
production: seiProd,
},
celo: {
development: celoDev,
production: celoProd,
},
blast: {
development: blastDev,
production: blastProd,
},
};
type Network = keyof typeof configs;
type Mode = 'development' | 'production';
const network = (import.meta.env.VITE_NETWORK || 'ethereum') as Network;
const mode = import.meta.env.MODE as Mode;
if (!configs[network]) {
const networks = Object.keys(configs).join(' or ');
throw new Error(`VITE_NETWORK should be ${networks}, got "${network}"`);
}
if (!configs[network][mode]) {
const modes = Object.keys(configs[network]).join(' or ');
throw new Error(`NODE_ENV should be ${modes}, got "${mode}"`);
}
export { pairsToExchangeMapping } from './utils';
export const networks = Object.entries(configs)
.filter(([_id, config]) => config[mode].hidden !== true)
.map(([id, config]) => {
return {
id,
name: config[mode].network.name,
logoUrl: config[mode].network.logoUrl,
chainId: config[mode].network.chainId,
isCurrentNetwork: network === id,
appUrl: config[mode].appUrl,
};
});
export const defaultConfig = configs[network][mode];
const currentConfig = handleConfigOverrides(defaultConfig);
export default currentConfig;