-
Notifications
You must be signed in to change notification settings - Fork 0
/
response.go
125 lines (105 loc) · 2.86 KB
/
response.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
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
package hackSDK
type NewTxResp struct {
Hash string `json:"data"`
Err string `json:"err"`
}
type QueryNonceResp struct {
Nonce uint64 `json:"data"`
Err string `json:"err"`
}
type QueryBalanceResp struct {
Data QueryBalanceRespData `json:"data"`
Err string `json:"err"`
}
type QueryBalanceRespData struct {
Address string `json:"address"`
Balance string `json:"balance"`
}
type QueryPoolTxsResp struct {
Data PoolTxs `json:"data"`
Err string `json:"err"`
}
type PoolTxs struct {
Seq SequencerResp `json:"sequencer"`
Txs []TransactionResp `json:"transactions"`
}
type QueryTxsResp struct {
Data []TransactionResp `json:"data"`
Err string `json:"err"`
}
type TxNumResp struct {
Data int `json:"data"`
Err string `json:"err"`
}
type QueryTransactionResp struct {
Data TransactionResp `json:"data"`
Err string `json:"err"`
}
type QueryTransactionsResp struct {
Data []TransactionResp `json:"data"`
Err string `json:"err"`
}
type TransactionResp struct {
Type int `json:"type"`
Hash string `json:"hash"`
Parents []string `json:"parents"`
From string `json:"from"`
To string `json:"to"`
Nonce uint64 `json:"nonce"`
Guarantee string `json:"guarantee"`
Value string `json:"value"`
}
func (t *TransactionResp) fromMap(m map[string]interface{}) {
t.Type = int(m["type"].(float64))
t.Hash = m["hash"].(string)
var parents []string
parentsInterface := m["parents"].([]interface{})
for _, p := range parentsInterface {
parents = append(parents, p.(string))
}
t.Parents = parents
t.From = m["from"].(string)
t.To = m["to"].(string)
t.Nonce = uint64(m["nonce"].(float64))
t.Guarantee = m["guarantee"].(string)
t.Value = m["value"].(string)
}
type QueryNextSeqResp struct {
Data QueryNextSeqRespData `json:"data"`
Err string `json:"err"`
}
type QueryNextSeqRespData struct {
Height uint64 `json:"height"`
TimeLeft uint64 `json:"time_left"`
}
type QuerySequencerResp struct {
Data SequencerResp `json:"data"`
Err string `json:"err"`
}
type SequencerResp struct {
Type int `json:"type"`
Hash string `json:"hash"`
Parents []string `json:"parents"`
From string `json:"from"`
Nonce uint64 `json:"nonce"`
Treasure string `json:"treasure"`
Height uint64 `json:"height"`
}
func (s *SequencerResp) fromMap(m map[string]interface{}) {
s.Type = int(m["type"].(float64))
s.Hash = m["hash"].(string)
var parents []string
parentsInterface := m["parents"].([]interface{})
for _, p := range parentsInterface {
parents = append(parents, p.(string))
}
s.Parents = parents
s.From = m["from"].(string)
s.Nonce = uint64(m["nonce"].(float64))
s.Treasure = m["treasure"].(string)
s.Height = uint64(m["height"].(float64))
}
type TxiResp struct {
Type int `json:"type"`
Data interface{} `json:"data"`
}