Skip to content

Commit

Permalink
TzKT API: migrations endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Apr 13, 2022
1 parent b2219fd commit c342e37
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
12 changes: 12 additions & 0 deletions tzkt/api/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,15 @@ type Token struct {
Standard string `json:"standard"`
Metadata stdJSON.RawMessage `json:"metadata,omitempty"`
}

// Migration -
type Migration struct {
Type string `json:"type"`
ID uint64 `json:"id"`
Level uint64 `json:"level"`
Timestamp time.Time `json:"timestamp"`
Block string `json:"block"`
Kind string `json:"kind"`
Account Address `json:"account"`
BalanceChange int64 `json:"balanceChange"`
}
10 changes: 9 additions & 1 deletion tzkt/api/operations.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package api

import "context"
import (
"context"
)

// GetEndorsements -
func (tzkt *API) GetEndorsements(ctx context.Context, filters map[string]string) (operations []Operation, err error) {
Expand Down Expand Up @@ -73,3 +75,9 @@ func (tzkt *API) GetRegisterConstants(ctx context.Context, filters map[string]st
err = tzkt.json(ctx, "/v1/operations/register_constants", filters, &operations)
return
}

// GetMigrations -
func (tzkt *API) GetMigrations(ctx context.Context, filters map[string]string) (operations []Migration, err error) {
err = tzkt.json(ctx, "/v1/operations/migrations", filters, &operations)
return
}
1 change: 1 addition & 0 deletions tzkt/events/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
KindDoubleEndorsing = "double_endorsing"
KindNonceRevelation = "nonce_revelation"
KindReveal = "reveal"
KindMigration = "migration"
)

// Base URL
Expand Down
12 changes: 12 additions & 0 deletions tzkt/events/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ type OriginatedContract struct {
CodeHash int64 `json:"codeHash"`
}

// Migration -
type Migration struct {
Type string `json:"type"`
ID uint64 `json:"id"`
Level uint64 `json:"level"`
Timestamp time.Time `json:"timestamp"`
Block string `json:"block"`
Kind string `json:"kind"`
Account Alias `json:"account"`
BalanceChange int64 `json:"balanceChange"`
}

// QuoteShort -
type QuoteShort struct {
BTC decimal.Decimal `json:"btc,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions tzkt/events/tzkt.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ func parseOperations(data []byte) (interface{}, error) {
result = append(result, &Reveal{})
case KindTransaction:
result = append(result, &Transaction{})
case KindMigration:
result = append(result, &Migration{})
default:
result = append(result, make(map[string]interface{}))
}
Expand Down

0 comments on commit c342e37

Please sign in to comment.