Skip to content

Commit 9e1b221

Browse files
TzKT API: operations entity
1 parent 7e049f4 commit 9e1b221

File tree

4 files changed

+110
-7
lines changed

4 files changed

+110
-7
lines changed

tools/encoding/base58.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,8 @@ func EncodeBase58(data, prefix []byte) (string, error) {
173173
if err != nil {
174174
return "", err
175175
}
176-
b := append(enc.DecodedPrefix, data...)
177176

178-
return base58Enc.CheckEncode(b), nil
177+
return base58Enc.CheckEncode(append(enc.DecodedPrefix, data...)), nil
179178
}
180179

181180
// EncodeBase58String -

tzkt/api/data.go

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package api
33
import (
44
stdJSON "encoding/json"
55
"time"
6+
7+
"github.com/shopspring/decimal"
68
)
79

810
const (
@@ -39,12 +41,112 @@ type Parameters struct {
3941
Value stdJSON.RawMessage `json:"value"`
4042
}
4143

44+
// Origination -
45+
type Origination struct {
46+
Type string `json:"type"`
47+
ID uint64 `json:"id"`
48+
Level uint64 `json:"level"`
49+
Timestamp time.Time `json:"timestamp"`
50+
Block string `json:"block"`
51+
Hash string `json:"hash"`
52+
Counter uint64 `json:"counter"`
53+
Sender Address `json:"sender"`
54+
Initiator Address `json:"initiator"`
55+
Nonce *uint64 `json:"nonce,omitempty"`
56+
GasLimit uint64 `json:"gasLimit"`
57+
GasUsed uint64 `json:"gasUsed"`
58+
StorageLimit uint64 `json:"storageLimit"`
59+
StorageUsed uint64 `json:"storageUsed"`
60+
BakerFee uint64 `json:"bakerFee"`
61+
StorageFee uint64 `json:"storageFee"`
62+
AllocationFee uint64 `json:"allocationFee"`
63+
ContractBalance uint64 `json:"contractBalance"`
64+
ContractManager Address `json:"contractManager"`
65+
ContractDelegate Address `json:"contractDelegate"`
66+
Status string `json:"status"`
67+
Originated Contract `json:"originatedContract"`
68+
Errors []Error `json:"errors,omitempty"`
69+
}
70+
71+
// Transaction -
72+
type Transaction struct {
73+
Type string `json:"type"`
74+
Sender Address `json:"sender"`
75+
Target Address `json:"target"`
76+
Initiator Address `json:"initiator"`
77+
Amount decimal.Decimal `json:"amount"`
78+
Parameter *Parameters `json:"parameter"`
79+
Timestamp time.Time `json:"timestamp"`
80+
ID uint64 `json:"id"`
81+
Level uint64 `json:"level"`
82+
Counter uint64 `json:"counter"`
83+
GasLimit uint64 `json:"gasLimit"`
84+
GasUsed uint64 `json:"gasUsed"`
85+
StorageLimit uint64 `json:"storageLimit"`
86+
StorageUsed uint64 `json:"storageUsed"`
87+
BakerFee uint64 `json:"bakerFee"`
88+
StorageFee uint64 `json:"storageFee"`
89+
AllocationFee uint64 `json:"allocationFee"`
90+
Status string `json:"status"`
91+
Parameters string `json:"parameters"`
92+
Block string `json:"block"`
93+
Hash string `json:"hash"`
94+
HasInternals bool `json:"hasInternals"`
95+
}
96+
97+
// Delegation -
98+
type Delegation struct {
99+
Block string `json:"block"`
100+
Hash string `json:"hash"`
101+
Type string `json:"type"`
102+
Status string `json:"status"`
103+
Sender Address `json:"sender"`
104+
NewDelegate Address `json:"newDelegate"`
105+
Timestamp time.Time `json:"timestamp"`
106+
Amount decimal.Decimal `json:"amount"`
107+
ID uint64 `json:"id"`
108+
Level uint64 `json:"level"`
109+
Counter uint64 `json:"counter"`
110+
GasLimit uint64 `json:"gasLimit"`
111+
GasUsed uint64 `json:"gasUsed"`
112+
BakerFee uint64 `json:"bakerFee"`
113+
}
114+
115+
// Reveal -
116+
type Reveal struct {
117+
Type string `json:"type"`
118+
Status string `json:"status"`
119+
Block string `json:"block"`
120+
Hash string `json:"hash"`
121+
Timestamp time.Time `json:"timestamp"`
122+
Sender Address `json:"sender"`
123+
ID uint64 `json:"id"`
124+
Level uint64 `json:"level"`
125+
Counter uint64 `json:"counter"`
126+
GasLimit uint64 `json:"gasLimit"`
127+
GasUsed uint64 `json:"gasUsed"`
128+
BakerFee uint64 `json:"bakerFee"`
129+
}
130+
131+
// Error -
132+
type Error struct {
133+
Type string `json:"type"`
134+
}
135+
42136
// Address -
43137
type Address struct {
44138
Alias string `json:"alias"`
45139
Address string `json:"address"`
46140
}
47141

142+
// Contract -
143+
type Contract struct {
144+
Kind string `json:"kind"`
145+
Address string `json:"address"`
146+
TypeHash int `json:"typeHash"`
147+
CodeHash int `json:"codeHash"`
148+
}
149+
48150
// Block -
49151
type Block struct {
50152
Level uint64 `json:"level"`

tzkt/api/operations.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,25 @@ func (tzkt *API) GetNonceRevelations(ctx context.Context, filters map[string]str
4545
}
4646

4747
// GetDelegations -
48-
func (tzkt *API) GetDelegations(ctx context.Context, filters map[string]string) (operations []Operation, err error) {
48+
func (tzkt *API) GetDelegations(ctx context.Context, filters map[string]string) (operations []Delegation, err error) {
4949
err = tzkt.json(ctx, "/v1/operations/delegations", filters, &operations)
5050
return
5151
}
5252

5353
// GetOriginations -
54-
func (tzkt *API) GetOriginations(ctx context.Context, filters map[string]string) (operations []Operation, err error) {
54+
func (tzkt *API) GetOriginations(ctx context.Context, filters map[string]string) (operations []Origination, err error) {
5555
err = tzkt.json(ctx, "/v1/operations/originations", filters, &operations)
5656
return
5757
}
5858

5959
// GetTransactions -
60-
func (tzkt *API) GetTransactions(ctx context.Context, filters map[string]string) (operations []Operation, err error) {
60+
func (tzkt *API) GetTransactions(ctx context.Context, filters map[string]string) (operations []Transaction, err error) {
6161
err = tzkt.json(ctx, "/v1/operations/transactions", filters, &operations)
6262
return
6363
}
6464

6565
// GetReveals -
66-
func (tzkt *API) GetReveals(ctx context.Context, filters map[string]string) (operations []Operation, err error) {
66+
func (tzkt *API) GetReveals(ctx context.Context, filters map[string]string) (operations []Reveal, err error) {
6767
err = tzkt.json(ctx, "/v1/operations/reveals", filters, &operations)
6868
return
6969
}

tzkt/events/signalr/hub.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ func (hub *Hub) Connect() error {
6464
func (hub *Hub) handshake() error {
6565
log.Trace().Msgf("connecting to %s...", hub.url.String())
6666

67-
c, _, err := websocket.DefaultDialer.Dial(hub.url.String(), nil)
67+
c, response, err := websocket.DefaultDialer.Dial(hub.url.String(), nil)
6868
if err != nil {
6969
return errors.Wrap(err, "Connect Dial")
7070
}
71+
defer response.Body.Close()
72+
7173
hub.conn = c
7274

7375
if err := hub.Send(newHandshakeRequest()); err != nil {

0 commit comments

Comments
 (0)