Skip to content

Commit 17d2f69

Browse files
Add Transaction types to events
1 parent 25a2601 commit 17d2f69

File tree

2 files changed

+127
-26
lines changed

2 files changed

+127
-26
lines changed

tzkt/events/message.go

Lines changed: 121 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ type Head struct {
4747
Chain string `json:"chain"`
4848
ChainID string `json:"chainId"`
4949
Cycle int64 `json:"cycle"`
50-
Level int64 `json:"level"`
50+
Level uint64 `json:"level"`
5151
Hash string `json:"hash"`
5252
Protocol string `json:"protocol"`
5353
Timestamp time.Time `json:"timestamp"`
5454
VotingEpoch int64 `json:"votingEpoch"`
5555
VotingPeriod int64 `json:"votingPeriod"`
56-
KnownLevel int64 `json:"knownLevel"`
56+
KnownLevel uint64 `json:"knownLevel"`
5757
LastSync time.Time `json:"lastSync"`
5858
Synced bool `json:"synced"`
59-
QuoteLevel int64 `json:"quoteLevel"`
59+
QuoteLevel uint64 `json:"quoteLevel"`
6060
QuoteBtc decimal.Decimal `json:"quoteBtc"`
6161
QuoteEur decimal.Decimal `json:"quoteEur"`
6262
QuoteUsd decimal.Decimal `json:"quoteUsd"`
@@ -68,8 +68,8 @@ type Head struct {
6868

6969
// Block -
7070
type Block struct {
71-
Cycle int64 `json:"cycle"`
72-
Level int64 `json:"level"`
71+
Cycle uint64 `json:"cycle"`
72+
Level uint64 `json:"level"`
7373
Hash string `json:"hash"`
7474
Timestamp time.Time `json:"timestamp"`
7575
Proto int64 `json:"proto"`
@@ -79,7 +79,7 @@ type Block struct {
7979
Reward int64 `json:"reward"`
8080
Fees int64 `json:"fees"`
8181
LbEscapeEma int64 `json:"lbEscapeEma"`
82-
Baker Address `json:"baker"`
82+
Baker Alias `json:"baker"`
8383
Software struct {
8484
Version string `json:"version"`
8585
Date time.Time `json:"date"`
@@ -88,8 +88,8 @@ type Block struct {
8888
LbEscapeVote bool `json:"lbEscapeVote"`
8989
}
9090

91-
// Address -
92-
type Address struct {
91+
// Alias -
92+
type Alias struct {
9393
Alias string `json:"alias"`
9494
Address string `json:"address"`
9595
}
@@ -102,7 +102,7 @@ type Account struct {
102102
Tzips []string `json:"tzips"`
103103
Alias string `json:"alias"`
104104
Balance int64 `json:"balance"`
105-
Creator Address `json:"creator"`
105+
Creator Alias `json:"creator"`
106106
NumContracts int64 `json:"numContracts"`
107107
NumDelegations int64 `json:"numDelegations"`
108108
NumOriginations int64 `json:"numOriginations"`
@@ -119,11 +119,11 @@ type Account struct {
119119

120120
// BigMapUpdate -
121121
type BigMapUpdate struct {
122-
ID int64 `json:"id"`
123-
Level int64 `json:"level"`
122+
ID uint64 `json:"id"`
123+
Level uint64 `json:"level"`
124124
Timestamp time.Time `json:"timestamp"`
125125
Bigmap int64 `json:"bigmap"`
126-
Contract Address `json:"contract"`
126+
Contract Alias `json:"contract"`
127127
Path string `json:"path"`
128128
Action string `json:"action"`
129129
Content *Content `json:"content,omitempty"`
@@ -145,22 +145,22 @@ type Operation struct {
145145
type Transaction struct {
146146
Operation
147147

148-
Sender Address `json:"sender"`
149-
Target Address `json:"target"`
150-
Initiator Address `json:"initiator"`
148+
Sender Alias `json:"sender"`
149+
Target Alias `json:"target"`
150+
Initiator Alias `json:"initiator"`
151151
Amount decimal.Decimal `json:"amount"`
152-
Parameter Parameter `json:"parameter"`
152+
Parameter *Parameter `json:"parameter"`
153153
Timestamp time.Time `json:"timestamp"`
154-
ID int64 `json:"id"`
155-
Level int64 `json:"level"`
156-
Counter int64 `json:"counter"`
157-
GasLimit int64 `json:"gasLimit"`
158-
GasUsed int64 `json:"gasUsed"`
159-
StorageLimit int64 `json:"storageLimit"`
160-
StorageUsed int64 `json:"storageUsed"`
161-
BakerFee int64 `json:"bakerFee"`
162-
StorageFee int64 `json:"storageFee"`
163-
AllocationFee int64 `json:"allocationFee"`
154+
ID uint64 `json:"id"`
155+
Level uint64 `json:"level"`
156+
Counter uint64 `json:"counter"`
157+
GasLimit uint64 `json:"gasLimit"`
158+
GasUsed uint64 `json:"gasUsed"`
159+
StorageLimit uint64 `json:"storageLimit"`
160+
StorageUsed uint64 `json:"storageUsed"`
161+
BakerFee uint64 `json:"bakerFee"`
162+
StorageFee uint64 `json:"storageFee"`
163+
AllocationFee uint64 `json:"allocationFee"`
164164
Status string `json:"status"`
165165
Parameters string `json:"parameters"`
166166
Block string `json:"block"`
@@ -173,3 +173,98 @@ type Parameter struct {
173173
Entrypoint string `json:"entrypoint"`
174174
Value stdJSON.RawMessage `json:"value"`
175175
}
176+
177+
// Origination -
178+
type Origination struct {
179+
Operation
180+
181+
ID uint64 `json:"id"`
182+
Level uint64 `json:"level"`
183+
Timestamp time.Time `json:"timestamp"`
184+
Block string `json:"block"`
185+
Hash string `json:"hash"`
186+
Counter uint64 `json:"counter"`
187+
Initiator *Alias `json:"initiator"`
188+
Sender *Alias `json:"sender"`
189+
Nonce *uint64 `json:"nonce"`
190+
GasLimit uint64 `json:"gasLimit"`
191+
GasUsed uint64 `json:"gasUsed"`
192+
StorageLimit uint64 `json:"storageLimit"`
193+
StorageUsed uint64 `json:"storageUsed"`
194+
BakerFee uint64 `json:"bakerFee"`
195+
StorageFee uint64 `json:"storageFee"`
196+
AllocationFee uint64 `json:"allocationFee"`
197+
ContractBalance uint64 `json:"contractBalance"`
198+
ContractManager *Alias `json:"contractManager"`
199+
ContractDelegate *Alias `json:"contractDelegate"`
200+
Code stdJSON.RawMessage `json:"code"`
201+
Storage stdJSON.RawMessage `json:"storage"`
202+
Diffs stdJSON.RawMessage `json:"diffs"`
203+
Status string `json:"status"`
204+
Errors stdJSON.RawMessage `json:"errors,omitempty"`
205+
OriginatedContract *OriginatedContract `json:"originatedContract,omitempty"`
206+
Quote *QuoteShort `json:"quote,omitempty"`
207+
}
208+
209+
// Reveal -
210+
type Reveal struct {
211+
Operation
212+
213+
ID uint64 `json:"id"`
214+
Level uint64 `json:"level"`
215+
Timestamp time.Time `json:"timestamp"`
216+
Block string `json:"block"`
217+
Hash string `json:"hash"`
218+
Sender *Alias `json:"sender"`
219+
Counter uint64 `json:"counter"`
220+
GasLimit uint64 `json:"gasLimit"`
221+
GasUsed uint64 `json:"gasUsed"`
222+
BakerFee uint64 `json:"bakerFee"`
223+
Status string `json:"status"`
224+
Errors stdJSON.RawMessage `json:"errors,omitempty"`
225+
Quote *QuoteShort `json:"quote,omitempty"`
226+
}
227+
228+
// Delegation -
229+
type Delegation struct {
230+
Operation
231+
232+
ID uint64 `json:"id"`
233+
Level uint64 `json:"level"`
234+
Timestamp time.Time `json:"timestamp"`
235+
Block string `json:"block"`
236+
Hash string `json:"hash"`
237+
Counter uint64 `json:"counter"`
238+
Initiator *Account `json:"initiator"`
239+
Sender *Account `json:"sender"`
240+
Nonce uint64 `json:"nonce"`
241+
GasLimit uint64 `json:"gasLimit"`
242+
GasUsed uint64 `json:"gasUsed"`
243+
BakerFee uint64 `json:"bakerFee"`
244+
Amount uint64 `json:"amount"`
245+
PrevDelegate *Account `json:"prevDelegate"`
246+
NewDelegate *Account `json:"newDelegate"`
247+
Status string `json:"status"`
248+
Errors stdJSON.RawMessage `json:"errors,omitempty"`
249+
Quote *QuoteShort `json:"quote,omitempty"`
250+
}
251+
252+
// OriginatedContract -
253+
type OriginatedContract struct {
254+
Kind string `json:"kind"`
255+
Alias string `json:"alias,omitempty"`
256+
Address string `json:"address,omitempty"`
257+
TypeHash int64 `json:"typeHash"`
258+
CodeHash int64 `json:"codeHash"`
259+
}
260+
261+
// QuoteShort -
262+
type QuoteShort struct {
263+
BTC decimal.Decimal `json:"btc,omitempty"`
264+
EUR decimal.Decimal `json:"eur,omitempty"`
265+
USD decimal.Decimal `json:"usd,omitempty"`
266+
CNY decimal.Decimal `json:"cny,omitempty"`
267+
JPY decimal.Decimal `json:"jpy,omitempty"`
268+
KRW decimal.Decimal `json:"krw,omitempty"`
269+
ETH decimal.Decimal `json:"eth,omitempty"`
270+
}

tzkt/events/tzkt.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ func parseOperations(data []byte) (interface{}, error) {
212212
result := make([]interface{}, 0)
213213
for i := range operations {
214214
switch operations[i].Type {
215+
case KindDelegation:
216+
result = append(result, &Delegation{})
217+
case KindOrigination:
218+
result = append(result, &Origination{})
219+
case KindReveal:
220+
result = append(result, &Reveal{})
215221
case KindTransaction:
216222
result = append(result, &Transaction{})
217223
default:

0 commit comments

Comments
 (0)