-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
62 lines (52 loc) · 1.18 KB
/
main.go
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
package main
import (
"encoding/json"
"fmt"
"github.com/spf13/cobra"
"io/ioutil"
"log"
"net/http"
"os"
)
var rootCmd = &cobra.Command{
Use: "filterdeposit",
Short: "filter missing inbound deposits",
}
func main() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
type deposit struct {
txId string
amount float64
}
func CheckForCCTX(list []deposit) {
zetaUrl := "http://46.4.15.110:1317/zeta-chain/crosschain/in_tx_hash_to_cctx_data/"
var missedList []deposit
fmt.Println("Going through list, num of transactions: ", len(list))
for _, entry := range list {
url := zetaUrl + entry.txId
res, getErr := http.Get(url)
if getErr != nil {
log.Fatal(getErr)
}
data, readErr := ioutil.ReadAll(res.Body)
if readErr != nil {
log.Fatal(readErr)
}
var cctx map[string]interface{}
err := json.Unmarshal(data, &cctx)
if err != nil {
fmt.Println("error unmarshalling: ", err.Error())
}
if _, ok := cctx["code"]; ok {
missedList = append(missedList, entry)
//fmt.Println("appending to missed list: ", entry)
}
}
for _, entry := range missedList {
fmt.Printf("%s, amount: %d\n", entry.txId, int64(entry.amount))
}
}