-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathconfig.ts
More file actions
219 lines (196 loc) · 6.44 KB
/
config.ts
File metadata and controls
219 lines (196 loc) · 6.44 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
// We get this from the generated code to avoid circular imports
// eslint-disable-next-line no-restricted-imports
import { Layer } from './oasis-nexus/generated/api'
import { NativeToken, NativeTokenInfo } from './types/ticker'
import { SearchScope } from './types/searchScope'
import { Network } from './types/network'
export const NUMBER_OF_ITEMS_ON_DASHBOARD = 5
export const FILTERING_ON_DASHBOARD = true
export const NUMBER_OF_ITEMS_ON_SEPARATE_PAGE = 100
export const REFETCH_INTERVAL = 5000
export const API_MAX_TOTAL_COUNT = 1000
export const consensusDecimals = 9
/**
* The maximum processing delay above which we consider the data on this paratime to be out of date.
*
* Specified in milliseconds.
*/
export const outOfDateThreshold = 2 * 60 * 1000
type LayerNetwork = {
address: string | undefined
blockGasLimit: number | undefined
runtimeId: string | undefined
/**
* What are the tokens on this layer?
* Note: native token must be the first on the list. Others are just incorrectly named "Native"
* See terminology in https://github.com/oasisprotocol/oasis-sdk/blob/5bec25f/client-sdk/go/config/default.go#L109-L120
*/
tokens: [NativeTokenInfo, ...NativeTokenInfo[]]
/**
* What fiat currency should we use for displaying value?
*/
fiatCurrency?: string
}
type LayerConfig = {
mainnet: LayerNetwork
testnet: LayerNetwork
localnet?: LayerNetwork
decimals: number
type: RuntimeTypes
offerRoflTxTypes?: boolean
}
export enum RuntimeTypes {
Evm = 'evm',
Oasis = 'oasis',
}
// consensusConfig: max_block_size = 22020096, max_block_gas = unlimited right now
export const consensusConfig = {
mainnet: {
tokens: [NativeToken.ROSE],
},
testnet: {
tokens: [NativeToken.TEST],
},
localnet: {
tokens: [NativeToken.TEST],
},
decimals: consensusDecimals,
}
const emeraldConfig: LayerConfig = {
mainnet: {
address: 'oasis1qzvlg0grjxwgjj58tx2xvmv26era6t2csqn22pte',
// Match max_batch_gas https://github.com/oasisprotocol/emerald-paratime/blob/5a36a646b989e510fadc0029178fe96a24cad101/src/lib.rs#L112-L112
blockGasLimit: 10_000_000,
runtimeId: '000000000000000000000000000000000000000000000000e2eaa99fc008f87f',
tokens: [NativeToken.ROSE],
},
testnet: {
address: 'oasis1qr629x0tg9gm5fyhedgs9lw5eh3d8ycdnsxf0run',
blockGasLimit: 30_000_000,
runtimeId: '00000000000000000000000000000000000000000000000072c8215e60d5bca7',
tokens: [NativeToken.TEST],
},
localnet: {
address: '',
blockGasLimit: 30_000_000,
runtimeId: '',
tokens: [NativeToken.TEST],
},
decimals: 18,
type: RuntimeTypes.Evm,
}
const cipherConfig: LayerConfig = {
mainnet: {
address: 'oasis1qrnu9yhwzap7rqh6tdcdcpz0zf86hwhycchkhvt8',
blockGasLimit: undefined, // TODO: provide gas limit
runtimeId: '000000000000000000000000000000000000000000000000e199119c992377cb',
tokens: [NativeToken.ROSE],
},
testnet: {
address: 'oasis1qqdn25n5a2jtet2s5amc7gmchsqqgs4j0qcg5k0t',
blockGasLimit: undefined, // TODO: provide gas limit
runtimeId: '0000000000000000000000000000000000000000000000000000000000000000',
tokens: [NativeToken.TEST],
},
decimals: 9,
type: RuntimeTypes.Oasis,
}
const sapphireConfig: LayerConfig = {
mainnet: {
address: 'oasis1qrd3mnzhhgst26hsp96uf45yhq6zlax0cuzdgcfc',
// See max_batch_gas https://github.com/oasisprotocol/sapphire-paratime/blob/main/runtime/src/lib.rs#L166
blockGasLimit: 15_000_000,
runtimeId: '000000000000000000000000000000000000000000000000f80306c9858e7279',
tokens: [NativeToken.ROSE],
},
testnet: {
address: 'oasis1qqczuf3x6glkgjuf0xgtcpjjw95r3crf7y2323xd',
// See max_batch_gas https://github.com/oasisprotocol/sapphire-paratime/blob/main/runtime/src/lib.rs#L166
blockGasLimit: 15_000_000,
runtimeId: '000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c',
tokens: [NativeToken.TEST],
},
localnet: {
address: '',
blockGasLimit: 15_000_000,
runtimeId: '',
tokens: [NativeToken.TEST],
},
decimals: 18,
type: RuntimeTypes.Evm,
offerRoflTxTypes: true,
}
const pontusxDevConfig: LayerConfig = {
mainnet: {
address: undefined,
blockGasLimit: undefined,
runtimeId: undefined,
tokens: [NativeToken.EURAU],
},
testnet: {
address: 'oasis1qr02702pr8ecjuff2z3es254pw9xl6z2yg9qcc6c',
blockGasLimit: 15_000_000,
runtimeId: '0000000000000000000000000000000000000000000000004febe52eb412b421',
tokens: [NativeToken.EURAU, NativeToken.TEST],
fiatCurrency: 'eur',
},
decimals: 18,
type: RuntimeTypes.Evm,
}
const pontusxTestConfig: LayerConfig = {
mainnet: {
address: undefined,
blockGasLimit: undefined,
runtimeId: undefined,
tokens: [NativeToken.EURAU],
},
testnet: {
address: 'oasis1qrg6c89655pmdxeel08qkngs02jnrfll5v9c508v',
blockGasLimit: 15_000_000,
runtimeId: '00000000000000000000000000000000000000000000000004a6f9071c007069',
tokens: [NativeToken.EURAU, NativeToken.TEST],
fiatCurrency: 'eur',
},
decimals: 18,
type: RuntimeTypes.Evm,
}
type LayersConfig = {
[key in Layer]: LayerConfig | null
}
export const paraTimesConfig = {
cipher: cipherConfig,
emerald: emeraldConfig,
sapphire: sapphireConfig,
pontusxdev: pontusxDevConfig,
pontusxtest: pontusxTestConfig,
consensus: null,
} satisfies LayersConfig
const splitUrls = (input: string | undefined): string[] =>
input
? input
.split(',')
.filter(s => !!s)
.map(s => s.trim())
: []
export const deploys = {
production: splitUrls(import.meta.env.REACT_APP_PRODUCTION_URLS),
staging: splitUrls(import.meta.env.REACT_APP_STAGING_URLS),
localhost: 'http://localhost:1234',
}
export const getAppTitle = () => import.meta.env.REACT_APP_META_TITLE
export const getTokensForScope = (scope: SearchScope | undefined): NativeTokenInfo[] => {
if (!scope) return []
if (scope.layer === 'consensus') return consensusConfig[scope.network].tokens
return paraTimesConfig?.[scope.layer]?.[scope.network]?.tokens!
}
export const getFiatCurrencyForScope = (scope: SearchScope | undefined) =>
(scope ? paraTimesConfig[scope.layer]?.[scope.network]?.fiatCurrency : undefined) ?? 'usd'
export const showFiatValues = import.meta.env.REACT_APP_SHOW_FIAT_VALUES === 'true'
export const specialScopeNames: Partial<Record<Network, Partial<Record<Layer, string>>>> = {
mainnet: {},
testnet: {},
}
export const specialScopePaths: Partial<Record<Network, Partial<Record<Layer, [string, string]>>>> = {
mainnet: {},
testnet: {},
}