Skip to content

Commit 4cc1ce4

Browse files
Some TzKT types
1 parent b79dc92 commit 4cc1ce4

File tree

5 files changed

+113
-5
lines changed

5 files changed

+113
-5
lines changed

tzkt/api/operations.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,27 @@ func (tzkt *API) GetTransferTicket(ctx context.Context, filters map[string]strin
167167
err = tzkt.json(ctx, "/v1/operations/transfer_ticket", filters, false, &operations)
168168
return
169169
}
170+
171+
// GetBakings -
172+
func (tzkt *API) GetBakings(ctx context.Context, filters map[string]string) (operations []data.Baking, err error) {
173+
err = tzkt.json(ctx, "/v1/operations/baking", filters, false, &operations)
174+
return
175+
}
176+
177+
// GetEndorsingRewards -
178+
func (tzkt *API) GetEndorsingRewards(ctx context.Context, filters map[string]string) (operations []data.EndorsingReward, err error) {
179+
err = tzkt.json(ctx, "/v1/operations/endorsing_rewards", filters, false, &operations)
180+
return
181+
}
182+
183+
// GetRevelationPenalties -
184+
func (tzkt *API) GetRevelationPenalties(ctx context.Context, filters map[string]string) (operations []data.RevelationPenalty, err error) {
185+
err = tzkt.json(ctx, "/v1/operations/revelation_penalties", filters, false, &operations)
186+
return
187+
}
188+
189+
// GetDoublePreendorsings -
190+
func (tzkt *API) GetDoublePreendorsings(ctx context.Context, filters map[string]string) (operations []data.DoublePreendorsing, err error) {
191+
err = tzkt.json(ctx, "/v1/operations/double_preendorsing", filters, false, &operations)
192+
return
193+
}

tzkt/data/blocks.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,23 @@ import (
88

99
// Block -
1010
type Block struct {
11+
Cycle int64 `json:"cycle"`
1112
Level uint64 `json:"level"`
1213
Hash string `json:"hash"`
1314
Timestamp time.Time `json:"timestamp"`
1415
Proto int64 `json:"proto"`
1516
Priority int64 `json:"priority"`
1617
Validations int64 `json:"validations"`
18+
BlockRound uint64 `json:"blockRound"`
19+
PayloadRound uint64 `josn:"payloadRound"`
1720
Deposit int64 `json:"deposit"`
1821
Reward int64 `json:"reward"`
1922
Fees int64 `json:"fees"`
23+
Bonus int64 `json:"bonus"`
2024
LbEscapeEma int64 `json:"lbEscapeEma"`
2125
NonceRevealed bool `json:"nonceRevealed"`
2226
LbEscapeVote bool `json:"lbEscapeVote"`
27+
LbToggleEma uint64 `json:"lbToggleEma"`
2328
Baker Address `json:"baker"`
2429
}
2530

tzkt/data/consts.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const (
1010
KindProposal = "proposal"
1111
KindDoubleBaking = "double_baking"
1212
KindDoubleEndorsing = "double_endorsing"
13+
KindDoublePreendorsing = "double_preendorsing"
1314
KindActivation = "activation"
1415
KindMigration = "migration"
1516
KindNonceRevelation = "nonce_revelation"
@@ -26,6 +27,9 @@ const (
2627
KindRollupReturnBond = "tx_rollup_return_bond"
2728
KindRollupSubmitBatch = "tx_rollup_submit_batch"
2829
KindSetDepositsLimit = "set_deposits_limit"
30+
KindRevelationPenalty = "revelation_penalty"
31+
KindBaking = "baking"
32+
KindEndorsingReward = "endorsing_reward"
2933
)
3034

3135
// urls

tzkt/data/operations.go

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ type OperationConstraint interface {
1313
Transaction | Origination | Delegation | Reveal | RegisterConstant | Endorsement | Preendorsement |
1414
Ballot | Proposal | Activation | TransferTicket | TxRollupCommit | TxRollupDispatchTicket |
1515
TxRollupFinalizeCommitment | TxRollupOrigination | TxRollupRejection | TxRollupRemoveCommitment |
16-
TxRollupReturnBond | TxRollupSubmitBatch | NonceRevelation | DoubleBaking | DoubleEndorsing | SetDepositsLimit
16+
TxRollupReturnBond | TxRollupSubmitBatch | NonceRevelation | DoubleBaking | DoubleEndorsing | SetDepositsLimit |
17+
Baking | RevelationPenalty | EndorsingReward
1718
}
1819

1920
// Operation -
@@ -307,7 +308,7 @@ type TxRollupCommit struct {
307308
StorageLimit uint64 `json:"storageLimit"`
308309
StorageUsed uint64 `json:"storageUsed"`
309310
BakerFee uint64 `json:"bakerFee"`
310-
Bond int64 `json:"bond"`
311+
Bond uint64 `json:"bond"`
311312
Sender Address `json:"sender"`
312313
Rollup Address `json:"rollup"`
313314
Errors []Error `json:"errors,omitempty"`
@@ -393,8 +394,8 @@ type TxRollupRejection struct {
393394
StorageLimit uint64 `json:"storageLimit"`
394395
StorageUsed uint64 `json:"storageUsed"`
395396
BakerFee uint64 `json:"bakerFee"`
396-
Reward int64 `json:"reward"`
397-
Loss int64 `json:"loss"`
397+
Reward uint64 `json:"reward"`
398+
Loss uint64 `json:"loss"`
398399
Rollup Address `json:"rollup"`
399400
Sender Address `json:"sender"`
400401
Committer Address `json:"committer"`
@@ -438,7 +439,7 @@ type TxRollupReturnBond struct {
438439
StorageLimit uint64 `json:"storageLimit"`
439440
StorageUsed uint64 `json:"storageUsed"`
440441
BakerFee uint64 `json:"bakerFee"`
441-
Bond int64 `json:"bond"`
442+
Bond uint64 `json:"bond"`
442443
Timestamp time.Time `json:"timestamp"`
443444
Rollup Address `json:"rollup"`
444445
Sender Address `json:"sender"`
@@ -556,3 +557,69 @@ type Quote struct {
556557
type Error struct {
557558
Type string `json:"type"`
558559
}
560+
561+
// Baking -
562+
type Baking struct {
563+
Type string `json:"type"`
564+
ID uint64 `json:"id"`
565+
Level uint64 `json:"level"`
566+
Timestamp time.Time `json:"timestamp"`
567+
Block string `json:"block"`
568+
Proposer *Account `json:"proposer"`
569+
Producer *Account `json:"producer"`
570+
PayloadRound int `json:"payloadRound"`
571+
BlockRound int `json:"blockRound"`
572+
Deposit int64 `json:"deposit"`
573+
Reward int64 `json:"reward"`
574+
Bonus int64 `json:"bonus"`
575+
Fees int64 `json:"fees"`
576+
Baker Account `json:"baker"`
577+
Priority int `json:"priority"`
578+
Quote *Quote `json:"quote,omitempty"`
579+
}
580+
581+
// EndorsingReward -
582+
type EndorsingReward struct {
583+
Type string `json:"type"`
584+
ID uint64 `json:"id"`
585+
Level uint64 `json:"level"`
586+
Timestamp time.Time `json:"timestamp"`
587+
Block string `json:"block"`
588+
Baker *Account `json:"baker"`
589+
Expected int64 `json:"expected"`
590+
Received int64 `json:"received"`
591+
Quote *Quote `json:"quote,omitempty"`
592+
}
593+
594+
// RevelationPenalty -
595+
type RevelationPenalty struct {
596+
Type string `json:"type"`
597+
ID uint64 `json:"id"`
598+
Level uint64 `json:"level"`
599+
Timestamp time.Time `json:"timestamp"`
600+
Block string `json:"block"`
601+
Baker *Account `json:"baker"`
602+
MissedLevel int64 `json:"missedLevel"`
603+
Loss int64 `json:"loss"`
604+
Quote *Quote `json:"quote,omitempty"`
605+
}
606+
607+
// DoublePreendorsing -
608+
type DoublePreendorsing struct {
609+
Type string `json:"type"`
610+
ID uint64 `json:"id"`
611+
Level uint64 `json:"level"`
612+
Timestamp time.Time `json:"timestamp"`
613+
Block string `json:"block"`
614+
Hash string `json:"hash"`
615+
AccusedLevel uint64 `json:"accusedLevel"`
616+
Accuser *Account `json:"accuser"`
617+
AccuserReward int64 `json:"accuserReward"`
618+
Offender *Account `json:"offender"`
619+
OffenderLoss int64 `json:"offenderLoss"`
620+
Quote *Quote `json:"quote,omitempty"`
621+
AccuserRewards int64 `json:"accuserRewards,omitempty"`
622+
OffenderLostDeposits int64 `json:"offenderLostDeposits,omitempty"`
623+
OffenderLostRewards int64 `json:"offenderLostRewards,omitempty"`
624+
OffenderLostFees int64 `json:"offenderLostFees,omitempty"`
625+
}

tzkt/events/tzkt.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ func parseOperations(data []byte) (any, error) {
296296
result = append(result, &tzktData.TxRollupRejection{})
297297
case tzktData.KindTxRollupRemoveCommitment:
298298
result = append(result, &tzktData.TxRollupRemoveCommitment{})
299+
case tzktData.KindRevelationPenalty:
300+
result = append(result, &tzktData.RevelationPenalty{})
301+
case tzktData.KindEndorsingReward:
302+
result = append(result, &tzktData.EndorsingReward{})
303+
case tzktData.KindBaking:
304+
result = append(result, &tzktData.Baking{})
305+
case tzktData.KindDoublePreendorsing:
306+
result = append(result, &tzktData.DoublePreendorsing{})
299307
default:
300308
result = append(result, make(map[string]interface{}))
301309
}

0 commit comments

Comments
 (0)