forked from threefoldtech/tfgrid-sdk-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-env.sh
116 lines (103 loc) · 3.44 KB
/
build-env.sh
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
#!/bin/bash
# Env vars with default values
MODE="${MODE:=dev}"
STELLAR_NETWORK="${STELLAR_NETWORK:=test}"
# Env vars must provide in `custom` mode
REQUIRED_ENV_VARS=(
GRAPHQL_URL
GRIDPROXY_URL
SUBSTRATE_URL
ACTIVATION_SERVICE_URL
RELAY_DOMAIN
BRIDGE_TFT_ADDRESS
)
STELLAR_ENV_Vars=(
STELLAR_HORIZON_URL
TFT_ASSET_ISSUER
)
case $MODE in
"dev")
GRAPHQL_URL='https://graphql.dev.grid.tf/graphql'
GRIDPROXY_URL='https://gridproxy.dev.grid.tf'
SUBSTRATE_URL='wss://tfchain.dev.grid.tf/ws'
ACTIVATION_SERVICE_URL='https://activation.dev.grid.tf'
RELAY_DOMAIN='relay.dev.grid.tf'
BRIDGE_TFT_ADDRESS=GDHJP6TF3UXYXTNEZ2P36J5FH7W4BJJQ4AYYAXC66I2Q2AH5B6O6BCFG
STELLAR_NETWORK=test
;;
"qa")
GRAPHQL_URL='https://graphql.qa.grid.tf/graphql'
GRIDPROXY_URL='https://gridproxy.qa.grid.tf'
SUBSTRATE_URL='wss://tfchain.qa.grid.tf/ws'
ACTIVATION_SERVICE_URL='https://activation.qa.grid.tf'
RELAY_DOMAIN='relay.qa.grid.tf'
BRIDGE_TFT_ADDRESS=GAQH7XXFBRWXT2SBK6AHPOLXDCLXVFAKFSOJIRMRNCDINWKHGI6UYVKM
STELLAR_NETWORK=test
;;
"test")
GRAPHQL_URL='https://graphql.test.grid.tf/graphql'
GRIDPROXY_URL='https://gridproxy.test.grid.tf'
SUBSTRATE_URL='wss://tfchain.test.grid.tf/ws'
ACTIVATION_SERVICE_URL='https://activation.test.grid.tf'
RELAY_DOMAIN='relay.test.grid.tf'
BRIDGE_TFT_ADDRESS=GA2CWNBUHX7NZ3B5GR4I23FMU7VY5RPA77IUJTIXTTTGKYSKDSV6LUA4
STELLAR_NETWORK=main
;;
"main")
GRAPHQL_URL='https://graphql.grid.tf/graphql'
GRIDPROXY_URL='https://gridproxy.grid.tf'
SUBSTRATE_URL='wss://tfchain.grid.tf/ws'
ACTIVATION_SERVICE_URL='https://activation.grid.tf'
RELAY_DOMAIN='relay.grid.tf'
BRIDGE_TFT_ADDRESS=GBNOTAYUMXVO5QDYWYO2SOCOYIJ3XFIP65GKOQN7H65ZZSO6BK4SLWSC
STELLAR_NETWORK=main
;;
"custom")
for i in "${REQUIRED_ENV_VARS[@]}"
do
if ! [[ -v $i ]]; then
echo -e "\n\e[1;50m \e[1;31m$i is required!\e[0m\n \e[1;3mPlease set it by executing the following command."
echo -e "\e[1;31m export\e[0m \e[1;32m$i\e[0m=\e[1;38m'Your Value Here'\n"
return
fi
done
echo -e "\e[1;33mEnvironment variables were exported before, if you want to change any of them maybe you have to re-export them or close the terminal window and start from scratch."
;;
*)
echo "Unknown 'MODE' selected!, Acceptable modes are [dev | qa | test | main | custom]\n"
return
;;
esac
case $STELLAR_NETWORK in
"test")
STELLAR_HORIZON_URL="https://horizon-testnet.stellar.org"
TFT_ASSET_ISSUER="GA47YZA3PKFUZMPLQ3B5F2E3CJIB57TGGU7SPCQT2WAEYKN766PWIMB3"
;;
"main")
STELLAR_HORIZON_URL="https://horizon.stellar.org"
TFT_ASSET_ISSUER="GBOVQKJYHXRR3DX6NOX2RRYFRCUMSADGDESTDNBDS6CDVLGVESRTAC47"
;;
*)
echo "Unknown 'STELLAR_NETWORK' selected!, Acceptable networks are [test | main]\n"
return
;;
esac
configs="
window.env = {
NETWORK: '$MODE',
GRAPHQL_URL: '$GRAPHQL_URL',
GRIDPROXY_URL: '$GRIDPROXY_URL',
SUBSTRATE_URL: '$SUBSTRATE_URL',
ACTIVATION_SERVICE_URL: '$ACTIVATION_SERVICE_URL',
RELAY_DOMAIN: '$RELAY_DOMAIN',
BRIDGE_TFT_ADDRESS: '$BRIDGE_TFT_ADDRESS',
STELLAR_NETWORK: '$STELLAR_NETWORK',
STELLAR_HORIZON_URL: '$STELLAR_HORIZON_URL',
TFT_ASSET_ISSUER: '$TFT_ASSET_ISSUER'
};
"
# decide the config file path
[ -d dist ] && file="dist/config.js" || file="config.js"
# override the content of the config file & echo the result
echo $configs > $file
echo -e "\e[1;32m$configs"