11package events
22
3- import "fmt"
3+ import (
4+ stdJSON "encoding/json"
5+ "fmt"
6+ "time"
7+
8+ "github.com/shopspring/decimal"
9+ )
410
511// MessageType - TzKT message type
612type MessageType int
@@ -15,9 +21,9 @@ const (
1521// Message - message struct
1622type Message struct {
1723 Channel string
18- Type MessageType
19- State uint64
20- Body interface {}
24+ Type MessageType `json:"type"`
25+ State uint64 `json:"state"`
26+ Body interface {} `json:"data"`
2127}
2228
2329// String -
@@ -28,3 +34,141 @@ func (msg Message) String() string {
2834 }
2935 return s
3036}
37+
38+ // Packet -
39+ type Packet struct {
40+ Type MessageType `json:"type"`
41+ State uint64 `json:"state"`
42+ Data stdJSON.RawMessage `json:"data,omitempty"`
43+ }
44+
45+ // Head -
46+ type Head struct {
47+ Chain string `json:"chain"`
48+ ChainID string `json:"chainId"`
49+ Cycle int64 `json:"cycle"`
50+ Level int64 `json:"level"`
51+ Hash string `json:"hash"`
52+ Protocol string `json:"protocol"`
53+ Timestamp time.Time `json:"timestamp"`
54+ VotingEpoch int64 `json:"votingEpoch"`
55+ VotingPeriod int64 `json:"votingPeriod"`
56+ KnownLevel int64 `json:"knownLevel"`
57+ LastSync time.Time `json:"lastSync"`
58+ Synced bool `json:"synced"`
59+ QuoteLevel int64 `json:"quoteLevel"`
60+ QuoteBtc decimal.Decimal `json:"quoteBtc"`
61+ QuoteEur decimal.Decimal `json:"quoteEur"`
62+ QuoteUsd decimal.Decimal `json:"quoteUsd"`
63+ QuoteCny decimal.Decimal `json:"quoteCny"`
64+ QuoteJpy decimal.Decimal `json:"quoteJpy"`
65+ QuoteKrw decimal.Decimal `json:"quoteKrw"`
66+ QuoteEth decimal.Decimal `json:"quoteEth"`
67+ }
68+
69+ // Block -
70+ type Block struct {
71+ Cycle int64 `json:"cycle"`
72+ Level int64 `json:"level"`
73+ Hash string `json:"hash"`
74+ Timestamp time.Time `json:"timestamp"`
75+ Proto int64 `json:"proto"`
76+ Priority int64 `json:"priority"`
77+ Validations int64 `json:"validations"`
78+ Deposit int64 `json:"deposit"`
79+ Reward int64 `json:"reward"`
80+ Fees int64 `json:"fees"`
81+ NonceRevealed bool `json:"nonceRevealed"`
82+ Baker Address `json:"baker"`
83+ Software struct {
84+ Version string `json:"version"`
85+ Date time.Time `json:"date"`
86+ } `json:"software"`
87+ LbEscapeVote bool `json:"lbEscapeVote"`
88+ LbEscapeEma int64 `json:"lbEscapeEma"`
89+ }
90+
91+ // Address -
92+ type Address struct {
93+ Alias string `json:"alias"`
94+ Address string `json:"address"`
95+ }
96+
97+ // Account -
98+ type Account struct {
99+ Type string `json:"type"`
100+ Address string `json:"address"`
101+ Kind string `json:"kind"`
102+ Tzips []string `json:"tzips"`
103+ Alias string `json:"alias"`
104+ Balance int64 `json:"balance"`
105+ Creator Address `json:"creator"`
106+ NumContracts int64 `json:"numContracts"`
107+ NumDelegations int64 `json:"numDelegations"`
108+ NumOriginations int64 `json:"numOriginations"`
109+ NumTransactions int64 `json:"numTransactions"`
110+ NumReveals int64 `json:"numReveals"`
111+ NumMigrations int64 `json:"numMigrations"`
112+ FirstActivity int64 `json:"firstActivity"`
113+ FirstActivityTime time.Time `json:"firstActivityTime"`
114+ LastActivity int64 `json:"lastActivity"`
115+ LastActivityTime time.Time `json:"lastActivityTime"`
116+ TypeHash int64 `json:"typeHash"`
117+ CodeHash int64 `json:"codeHash"`
118+ }
119+
120+ // BigMapUpdate -
121+ type BigMapUpdate struct {
122+ ID int64 `json:"id"`
123+ Level int64 `json:"level"`
124+ Timestamp time.Time `json:"timestamp"`
125+ Bigmap int64 `json:"bigmap"`
126+ Contract Address `json:"contract"`
127+ Path string `json:"path"`
128+ Action string `json:"action"`
129+ Content * Content `json:"content,omitempty"`
130+ }
131+
132+ // Content -
133+ type Content struct {
134+ Hash string `json:"hash"`
135+ Key string `json:"key"`
136+ Value stdJSON.RawMessage `json:"value"`
137+ }
138+
139+ // Operation -
140+ type Operation struct {
141+ Type string `json:"type"`
142+ }
143+
144+ // Transaction -
145+ type Transaction struct {
146+ Operation
147+
148+ Sender Address `json:"sender"`
149+ Target Address `json:"target"`
150+ Amount decimal.Decimal `json:"amount"`
151+ Parameter Parameter `json:"parameter"`
152+ Timestamp time.Time `json:"timestamp"`
153+ ID int64 `json:"id"`
154+ Level int64 `json:"level"`
155+ Counter int64 `json:"counter"`
156+ GasLimit int64 `json:"gasLimit"`
157+ GasUsed int64 `json:"gasUsed"`
158+ StorageLimit int64 `json:"storageLimit"`
159+ StorageUsed int64 `json:"storageUsed"`
160+ BakerFee int64 `json:"bakerFee"`
161+ StorageFee int64 `json:"storageFee"`
162+ AllocationFee int64 `json:"allocationFee"`
163+ Status string `json:"status"`
164+ Parameters string `json:"parameters"`
165+ Block string `json:"block"`
166+ Hash string `json:"hash"`
167+ HasInternals bool `json:"hasInternals"`
168+ }
169+
170+ // Parameter -
171+ type Parameter struct {
172+ Entrypoint string `json:"entrypoint"`
173+ Value stdJSON.RawMessage `json:"value"`
174+ }
0 commit comments