Skip to content

Commit c342e37

Browse files
TzKT API: migrations endpoint
1 parent b2219fd commit c342e37

File tree

5 files changed

+36
-1
lines changed

5 files changed

+36
-1
lines changed

tzkt/api/data.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,15 @@ type Token struct {
363363
Standard string `json:"standard"`
364364
Metadata stdJSON.RawMessage `json:"metadata,omitempty"`
365365
}
366+
367+
// Migration -
368+
type Migration struct {
369+
Type string `json:"type"`
370+
ID uint64 `json:"id"`
371+
Level uint64 `json:"level"`
372+
Timestamp time.Time `json:"timestamp"`
373+
Block string `json:"block"`
374+
Kind string `json:"kind"`
375+
Account Address `json:"account"`
376+
BalanceChange int64 `json:"balanceChange"`
377+
}

tzkt/api/operations.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package api
22

3-
import "context"
3+
import (
4+
"context"
5+
)
46

57
// GetEndorsements -
68
func (tzkt *API) GetEndorsements(ctx context.Context, filters map[string]string) (operations []Operation, err error) {
@@ -73,3 +75,9 @@ func (tzkt *API) GetRegisterConstants(ctx context.Context, filters map[string]st
7375
err = tzkt.json(ctx, "/v1/operations/register_constants", filters, &operations)
7476
return
7577
}
78+
79+
// GetMigrations -
80+
func (tzkt *API) GetMigrations(ctx context.Context, filters map[string]string) (operations []Migration, err error) {
81+
err = tzkt.json(ctx, "/v1/operations/migrations", filters, &operations)
82+
return
83+
}

tzkt/events/consts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const (
3333
KindDoubleEndorsing = "double_endorsing"
3434
KindNonceRevelation = "nonce_revelation"
3535
KindReveal = "reveal"
36+
KindMigration = "migration"
3637
)
3738

3839
// Base URL

tzkt/events/message.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,18 @@ type OriginatedContract struct {
259259
CodeHash int64 `json:"codeHash"`
260260
}
261261

262+
// Migration -
263+
type Migration struct {
264+
Type string `json:"type"`
265+
ID uint64 `json:"id"`
266+
Level uint64 `json:"level"`
267+
Timestamp time.Time `json:"timestamp"`
268+
Block string `json:"block"`
269+
Kind string `json:"kind"`
270+
Account Alias `json:"account"`
271+
BalanceChange int64 `json:"balanceChange"`
272+
}
273+
262274
// QuoteShort -
263275
type QuoteShort struct {
264276
BTC decimal.Decimal `json:"btc,omitempty"`

tzkt/events/tzkt.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ func parseOperations(data []byte) (interface{}, error) {
254254
result = append(result, &Reveal{})
255255
case KindTransaction:
256256
result = append(result, &Transaction{})
257+
case KindMigration:
258+
result = append(result, &Migration{})
257259
default:
258260
result = append(result, make(map[string]interface{}))
259261
}

0 commit comments

Comments
 (0)