-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgoz_relayer_helper.sh
136 lines (123 loc) · 7.21 KB
/
goz_relayer_helper.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
checklog ()
{
LOG=$(ls $PWD | grep goz_transferer.log)
if [ -z $LOG ]; then
touch ${PWD}/goz_transferer.log
echo "goz_transferer.log created" | tee -a ${PWD}/goz_transferer.log
fi
}
getfund ()
{
for FUND in $FUNDS
do
BAL=$(rly q bal $FUND | awk -F '[a-z][A-z]' '{print $1}')
if [ -z $BAL ]; then
echo "cant connect to $FUND" | tee -a ${PWD}/goz_transferer.log
elif [ $BAL -lt "200000" ]; then
echo "fund ends $BAL you need to get money from $FUND" #|ts| tee -a ${PWD}/goz_transferer.log
if [ "$FUND" == "flint" ]; then
rly tst req $FUND -u $FAUCET
else
rly tst req $FUND # | ts | tee -a ${PWD}/goz_transferer.log
fi
fi
done
}
client-update ()
{
for PTH in $PATHS
do
NAME=$(echo $PTH | awk -F ':' '{print $1}')
CHANELNAME=$(echo $PTH | awk -F ':' '{print $2}' | awk -F ';' '{print $1}')
ID1=$(rly pth show $CHANELNAME | grep -A 1 $GAMEOF | grep 'ClientID' | awk -F ':' '{print $2}'| sed 's/ //g')
ID2=$(rly pth show $CHANELNAME | grep -A 1 $NAME | grep 'ClientID' | awk -F ':' '{print $2}'| sed 's/ //g')
echo "execute rly tx raw update-client $NAME $GAMEOF $ID2" | ts |tee -a ${PWD}/goz_transferer.log
while true; do
STATE=$(rly tx raw update-client $NAME $GAMEOF $ID2 -d | jq .height 2>/dev/null | sed 's/"//g')
echo $STATE | ts | sed -e 's/$/ block/' |tee -a ${PWD}/goz_transferer.log
if [ -z $STATE ]; then
curl -s -X POST https://api.telegram.org/bot$BOTNUMBER1/sendMessage -d chat_id=$CHATID -d text="LAST $NAME CLIENT NOT UPDATED"
sleep 3;
continue;
elif [ "$STATE" -eq "0" ]; then
curl -s -X POST https://api.telegram.org/bot$BOTNUMBER1/sendMessage -d chat_id=$CHATID -d text="LAST $NAME CLIENT NOT UPDATED"
sleep 3;
continue;
else
break;
fi
done
echo "execute rly tx raw update-client $GAMEOF $NAME $ID1" | ts |tee -a ${PWD}/goz_transferer.log
while true; do
STATE1=$(rly tx raw update-client $GAMEOF $NAME $ID1 -d | jq .height 2>/dev/null | sed 's/"//g')
echo $STATE1 | ts | sed -e 's/$/ block/' |tee -a ${PWD}/goz_transferer.log
if [ -z $STATE1 ]; then
curl -s -X POST https://api.telegram.org/bot$BOTNUMBER1/sendMessage -d chat_id=$CHATID -d text="LAST $NAME CLIENT NOT UPDATED"
sleep 3;
continue;
elif [ "$STATE1" -eq "0" ]; then
curl -s -X POST https://api.telegram.org/bot$BOTNUMBER1/sendMessage -d chat_id=$CHATID -d text="LAST $GAMEOF CLIENT NOT UPDATED"
sleep 3;
continue;
else
break;
fi
done
rly q bal $GAMEOF | ts |tee -a ${PWD}/goz_transferer.log
done
}
transfer()
{
for PTH in $PATHS; do
NAME=$(echo $PTH | awk -F ':' '{print $1}')
CHANELNAME=$(echo $PTH | awk -F ':' '{print $2}' | awk -F ';' '{print $1}')
for (( ITER=1; ITER<=10; ITER++ )); do
TR=$(rly tx transfer $GAMEOF $NAME 10${DENOM} true $(rly ch addr $NAME))
if [ "$(echo $TR | awk -F "$GAMEOF" '{print $2}' | awk -F '-' '{print $1}' | sed 's/\]//g' |sed 's/\@//g'| sed 's/{//g'| sed 's/}//g')" -eq "0" ]; then
rly tx rly $CHANELNAME | tee -a ${PWD}/goz_transferer.log
sleep 3
continue;
else
break;
fi
done
echo $TR | tee -a ${PWD}/goz_transferer.log
rly q bal $GAMEOF | tee -a ${PWD}/goz_transferer.log
done
}
xref()
{
for PTH in $PATHS; do
NAME=$(echo $PTH | awk -F ':' '{print $1}')
CHANELNAME=$(echo $PTH | awk -F ':' '{print $2}' | awk -F ';' '{print $1}')
for (( ITER=1; ITER<=10; ITER++ )); do
XF=$(rly tx xfer $NAME $GAMEOF 1${DENOM} false $(rly ch addr $GAMEOF))
if [ "$(echo $XF | awk -F "$NAME" '{print $2}' | awk -F '-' '{print $1}' | sed 's/\]//g' |sed 's/\@//g'| sed 's/{//g'| sed 's/}//g')" -eq "0" ]; then
rly tx rly $CHANELNAME | tee -a ${PWD}/goz_transferer.log
sleep 3
continue;
else
break;
fi
done
echo $XF | tee -a ${PWD}/goz_transferer.log
rly q bal $NAME | tee -a ${PWD}/goz_transferer.log
done
}
DENOM=doubloons
GAMEOF=gameofzoneshub-1b
EVERSTAKE=everstakechain-1b
FUNDS="everstakechain-1b"
PATHS="everstakechain-1b:game3;cosmos1zt57587dk595090gdtsy"
CHATID=541111140
BOTNUMBER1=11111111:AAFoOdfgdfdgdgfdfWuEQ
FAUCET="http://faucet_ip:faucet:port"
while true; do
checklog
getfund
client-update
sleep 120
#transfer
#xref
done