-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbuild-env.sh
More file actions
executable file
·136 lines (124 loc) · 6.45 KB
/
build-env.sh
File metadata and controls
executable file
·136 lines (124 loc) · 6.45 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
#!/bin/bash
# Env vars with default values
MODE="${MODE:=dev}"
STELLAR_NETWORK="${STELLAR_NETWORK:=test}"
TIMEOUT="${TIMEOUT:=10000}"
PAGE_SIZE="${PAGE_SIZE:=20}"
MINTING_URL="https://alpha.minting.tfchain.grid.tf"
ENABLE_TELEMETRY=false
STELLAR_ENV_Vars=(
STELLAR_HORIZON_URL
TFT_ASSET_ISSUER
)
WALLET_KEY="${WALLET_KEY:=wallet.v1}"
case $MODE in
"dev")
GRAPHQL_URL="${GRAPHQL_URL:-"https://graphql.dev.grid.tf/graphql,https://graphql.dev.threefold.me/graphql"}"
GRIDPROXY_URL="${GRIDPROXY_URL:-"https://gridproxy.dev.grid.tf,https://gridproxy.dev.threefold.me"}"
SUBSTRATE_URL="${SUBSTRATE_URL:-"wss://tfchain.dev.grid.tf/ws,wss://tfchain.dev.threefold.me/ws"}"
ACTIVATION_SERVICE_URL="${ACTIVATION_SERVICE_URL:-"https://activation.dev.grid.tf/activation/activate,https://activation.dev.threefold.me/activation/activate"}"
RELAY_DOMAIN="${RELAY_DOMAIN:-"wss://relay.dev.grid.tf,wss://relay.dev.threefold.me"}"
BRIDGE_TFT_ADDRESS="${BRIDGE_TFT_ADDRESS:-GDHJP6TF3UXYXTNEZ2P36J5FH7W4BJJQ4AYYAXC66I2Q2AH5B6O6BCFG}"
STATS_URL="${STATS_URL:-"https://stats.dev.grid.tf,https://stats.dev.threefold.me"}"
STELLAR_NETWORK="${STELLAR_NETWORK:-test}"
KYC_URL="${KYC_URL:-"https://kyc.dev.grid.tf,https://kyc.dev.threefold.me,https://kyc.dev.ninja.tf"}"
SENTRY_DSN="https://b9af6796f176d1f02837a06f0da3caee@dev.sentry.grid.tf/2"
MANUAL_URL="${MANUAL_URL:-https://manual.dev.grid.tf}"
;;
"qa")
GRAPHQL_URL="${GRAPHQL_URL:-"https://graphql.qa.grid.tf/graphql,https://graphql.qa.threefold.me/graphql"}"
GRIDPROXY_URL="${GRIDPROXY_URL:-"https://gridproxy.qa.grid.tf,https://gridproxy.qa.threefold.me"}"
SUBSTRATE_URL="${SUBSTRATE_URL:-"wss://tfchain.qa.grid.tf/ws,wss://tfchain.qa.threefold.me/ws"}"
ACTIVATION_SERVICE_URL="${ACTIVATION_SERVICE_URL:-"https://activation.qa.grid.tf/activation/activate,https://activation.qa.threefold.me/activation/activate"}"
RELAY_DOMAIN="${RELAY_DOMAIN:-"wss://relay.qa.grid.tf,wss://relay.qa.threefold.me"}"
BRIDGE_TFT_ADDRESS="${BRIDGE_TFT_ADDRESS:-GAQH7XXFBRWXT2SBK6AHPOLXDCLXVFAKFSOJIRMRNCDINWKHGI6UYVKM}"
STATS_URL="${STATS_URL:-"https://stats.qa.grid.tf,https://stats.qa.threefold.me"}"
STELLAR_NETWORK="${STELLAR_NETWORK:-test}"
KYC_URL="${KYC_URL:-"https://kyc.qa.grid.tf,https://kyc.qa.threefold.me,https://kyc.qa.ninja.tf"}"
SENTRY_DSN="https://b9af6796f176d1f02837a06f0da3caee@dev.sentry.grid.tf/2"
MANUAL_URL="${MANUAL_URL:-https://manual.grid.tf}"
;;
"test")
GRAPHQL_URL="${GRAPHQL_URL:-"https://graphql.test.grid.tf/graphql,https://graphql.test.threefold.me/graphql"}"
GRIDPROXY_URL="${GRIDPROXY_URL:-"https://gridproxy.test.grid.tf,https://gridproxy.test.threefold.me"}"
SUBSTRATE_URL="${SUBSTRATE_URL:-"wss://tfchain.test.grid.tf/ws,wss://tfchain.test.threefold.me/ws"}"
ACTIVATION_SERVICE_URL="${ACTIVATION_SERVICE_URL:-"https://activation.test.grid.tf/activation/activate,https://activation.test.threefold.me/activation/activate"}"
RELAY_DOMAIN="${RELAY_DOMAIN:-"wss://relay.test.grid.tf,wss://relay.test.threefold.me"}"
BRIDGE_TFT_ADDRESS="${BRIDGE_TFT_ADDRESS:-GA2CWNBUHX7NZ3B5GR4I23FMU7VY5RPA77IUJTIXTTTGKYSKDSV6LUA4}"
STATS_URL="${STATS_URL:-"https://stats.test.grid.tf,https://stats.test.threefold.me"}"
STELLAR_NETWORK="${STELLAR_NETWORK:-main}"
KYC_URL="${KYC_URL:-https://kyc.test.grid.tf}"
SENTRY_DSN="https://b9af6796f176d1f02837a06f0da3caee@dev.sentry.grid.tf/2"
MANUAL_URL="${MANUAL_URL:-https://manual.grid.tf}"
;;
"main")
GRAPHQL_URL="${GRAPHQL_URL:-"https://graphql.grid.tf/graphql,https://graphql.grid.threefold.me/graphql"}"
GRIDPROXY_URL="${GRIDPROXY_URL:-"https://gridproxy.grid.tf,https://gridproxy.grid.threefold.me"}"
SUBSTRATE_URL="${SUBSTRATE_URL:-"wss://tfchain.grid.tf/ws,wss://tfchain.grid.threefold.me/ws"}"
ACTIVATION_SERVICE_URL="${ACTIVATION_SERVICE_URL:-"https://activation.grid.tf/activation/activate,https://activation.grid.threefold.me/activation/activate"}"
RELAY_DOMAIN="${RELAY_DOMAIN:-"wss://relay.grid.tf,wss://relay.grid.threefold.me"}"
BRIDGE_TFT_ADDRESS="${BRIDGE_TFT_ADDRESS:-GBNOTAYUMXVO5QDYWYO2SOCOYIJ3XFIP65GKOQN7H65ZZSO6BK4SLWSC}"
STATS_URL="${STATS_URL:-"https://stats.grid.tf,https://stats.grid.threefold.me"}"
STELLAR_NETWORK="${STELLAR_NETWORK:-main}"
KYC_URL="${KYC_URL:-https://kyc.grid.tf}"
SENTRY_DSN="https://598bcc658bd99042ab429166035f8278@sentry.grid.tf/2"
MANUAL_URL="${MANUAL_URL:-https://manual.grid.tf}"
;;
*)
echo "Unknown 'MODE' selected! Acceptable modes are [dev | qa | test | main ]"
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
parss_array(){
local service_urls=$1
toString=($(echo "$service_urls" | tr ',' "\n"))
for item in "${toString[@]}"; do
quoted_string+="'$item' "
done
# add single quate to each elament
quoted_string=${quoted_string// /,}
# remove trailing comma
echo "${quoted_string%?}"
}
configs="
window.env = {
WALLET_KEY: '$WALLET_KEY',
NETWORK: '$MODE',
GRAPHQL_STACKS: "[$(parss_array "$GRAPHQL_URL")]",
GRIDPROXY_STACKS: "[$(parss_array "$GRIDPROXY_URL")]",
SUBSTRATE_STACKS: "[$(parss_array "$SUBSTRATE_URL")]",
ACTIVATION_SERVICE_STACKS: "[$(parss_array "$ACTIVATION_SERVICE_URL")]",
RELAY_STACKS: "[$(parss_array "$RELAY_DOMAIN")]",
BRIDGE_TFT_ADDRESS: '$BRIDGE_TFT_ADDRESS',
STELLAR_NETWORK: '$STELLAR_NETWORK',
STELLAR_HORIZON_URL: '$STELLAR_HORIZON_URL',
TFT_ASSET_ISSUER: '$TFT_ASSET_ISSUER',
MINTING_URL: '$MINTING_URL',
KYC_STACKS: "[$(parss_array "$KYC_URL")]",
STATS_STACKS: "[$(parss_array "$STATS_URL")]",
TIMEOUT: +'$TIMEOUT',
PAGE_SIZE: +'$PAGE_SIZE',
MANUAL_URL: '$MANUAL_URL',
SENTRY_DSN: '$SENTRY_DSN',
ENABLE_TELEMETRY: '$ENABLE_TELEMETRY'
};
"
# decide the config file path
[ -d public ] && file="public/config.js" || file="config.js"
# override the content of the config file & echo the result
echo $configs > $file
echo -e "\e[1;32m$configs"