-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwaves-scripts
executable file
·123 lines (90 loc) · 2.34 KB
/
waves-scripts
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
#!/bin/bash
start_dev_env () {
set -e
start_nodes
local usdt_asset_id=$(mint_usdt)
start_bobtimus $usdt_asset_id
start_frontend
}
stop_dev_env () {
stop_bobtimus
stop_nodes
}
start_nodes () {
set -e
# start elementsd, esplora (et al)
nigiri start --liquid
}
mint_usdt () {
set -e
local -r amount=1000000
address=$(nigiri rpc --liquid getnewaddress)
# need to wait a couple of seconds so that we don't fail on the second request
sleep 2
response=$(nigiri mint $address $amount "Tether USD" "USDt")
asset_id=$(echo $response | sed -n -e 's/^.*\(asset: \)\(.*\)\( issuance_txin: .*$\)/\2/p')
echo "$asset_id"
}
start_bobtimus () {
if [ $# -ne 1 ]; then
echo "Incorrect number of arguments"
exit 1
fi
if [ -f ".bobtimus" ]; then
echo "Are you sure Bobtimus is not already up?"
exit 1
fi
set -e
__ensure_log_dir
__read_env_file
cargo build --bin fake_bobtimus
local -r elementsd_rpc_user="admin1"
local -r elementsd_rpc_password="123"
RUST_LOG=info cargo run --bin fake_bobtimus -- \
--elementsd http://$elementsd_rpc_user:[email protected]:$LIQUID_NODE_PORT \
--usdt $1 > $log_dir/bobtimus 2>&1 &
bobtimus_pid=$!
sleep 1
curl --fail http://127.0.0.1:3030
if [ $? -ne 0 ]; then
echo "Failed to start Bobtimus"
exit 1
fi
# save bobtimus pid to file for future teardown
echo $bobtimus_pid > .bobtimus
echo "Started bobtimus with pid $bobtimus_pid"
}
start_frontend () {
set -e
__read_env_file
local -r chopsticks_url="http://127.0.0.1:$LIQUID_CHOPSTICKS_PORT"
cd waves
yarn install
export NATIVE_ASSET_ID=$(nigiri rpc --liquid dumpassetlabels | jq -r '.bitcoin')
export CHAIN=ELEMENTS
export ESPLORA_API_URL=$chopsticks_url
yarn start
}
stop_nodes () {
nigiri stop --delete
}
stop_bobtimus () {
bobtimus_pid=$(cat .bobtimus)
if [ $? -ne 0 ]; then
echo "Are you sure Bobtimus is still running?"
exit 1
fi
kill -9 $bobtimus_pid
if [ $? -ne 0 ]; then
echo "Bobtimus is not running"
fi
rm .bobtimus
}
__read_env_file () {
export $(cat ~/.nigiri/.env | xargs)
}
__ensure_log_dir () {
readonly log_dir="./.log"
mkdir -p $log_dir
}
"$@"