forked from BirthdayResearch/defichain-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment.ts
77 lines (70 loc) · 1.79 KB
/
environment.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* Network supported in this environment
*/
export enum EnvironmentNetwork {
LocalPlayground = 'Local',
RemotePlayground = 'Playground',
MainNet = 'MainNet',
TestNet = 'TestNet'
}
export enum EnvironmentName {
Production = 'Production',
Preview = 'Preview',
Development = 'Development',
}
interface Environment {
name: EnvironmentName
debug: boolean
networks: EnvironmentNetwork[]
}
export const environments: Record<EnvironmentName, Environment> = {
Production: {
name: EnvironmentName.Production,
debug: false,
networks: [
EnvironmentNetwork.MainNet,
EnvironmentNetwork.TestNet,
EnvironmentNetwork.RemotePlayground
]
},
Preview: {
name: EnvironmentName.Preview,
debug: true,
networks: [
EnvironmentNetwork.RemotePlayground,
EnvironmentNetwork.TestNet,
EnvironmentNetwork.MainNet
]
},
Development: {
name: EnvironmentName.Development,
debug: true,
networks: [
EnvironmentNetwork.LocalPlayground,
EnvironmentNetwork.RemotePlayground,
EnvironmentNetwork.TestNet,
EnvironmentNetwork.MainNet
]
}
}
/**
* @return Environment of current Wallet, checked via expo release channels
*/
export function getEnvironment (channel: string): Environment {
if (channel === 'production') {
return environments[EnvironmentName.Production]
}
if (channel.startsWith('pr-preview-') || channel === 'prerelease') {
return environments[EnvironmentName.Preview]
}
return environments[EnvironmentName.Development]
}
/**
* @param {EnvironmentNetwork} network to check if it is a playground network
*/
export function isPlayground (network: EnvironmentNetwork): boolean {
return [
EnvironmentNetwork.LocalPlayground,
EnvironmentNetwork.RemotePlayground
].includes(network)
}