Skip to content

Commit

Permalink
Lima operaitons
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Nov 29, 2022
1 parent a8abdee commit 48b2245
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 2 deletions.
2 changes: 2 additions & 0 deletions node/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const (
KindEvent = "event"
KindVdfRevelation = "vdf_revelation"
KindIncreasePaidStorage = "Increase_paid_storage"
KindUpdateConsensusKey = "update_consensus_key"
KindDrainDelegate = "drain_delegate"
)

const (
Expand Down
28 changes: 27 additions & 1 deletion node/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ type OperationConstraint interface {
RegisterGlobalConstant | DoublePreendorsementEvidence | SetDepositsLimit |
Preendorsement | Event | VdfRevelation | TxRollupCommit | TxRollupOrigination |
TxRollupDispatchTickets | TxRollupFinalizeCommitment | TxRollupRejection |
TxRollupRemoveCommitment | TxRollupSubmitBatch
TxRollupRemoveCommitment | TxRollupSubmitBatch | UpdateConsensusKey |
DrainDelegate
}

// OperationGroup -
Expand Down Expand Up @@ -93,6 +94,10 @@ func (op *Operation) UnmarshalJSON(data []byte) error {
err = parseOperation[TxRollupRemoveCommitment](data, op)
case KindTxRollupSubmitBatch:
err = parseOperation[TxRollupSubmitBatch](data, op)
case KindUpdateConsensusKey:
err = parseOperation[UpdateConsensusKey](data, op)
case KindDrainDelegate:
err = parseOperation[DrainDelegate](data, op)

}
return err
Expand Down Expand Up @@ -625,3 +630,24 @@ type TxRollupSubmitBatch struct {
Content string `json:"content"`
Metadata *ManagerOperationMetadata `json:"metadata,omitempty"`
}

// UpdateConsensusKey -
type UpdateConsensusKey struct {
Kind string `json:"kind"`
Source string `json:"source"`
Fee string `json:"fee"`
Counter string `json:"counter"`
GasLimit string `json:"gas_limit"`
StorageLimit string `json:"storage_limit"`
Pk string `json:"pk"`
Metadata *ManagerOperationMetadata `json:"metadata,omitempty"`
}

// DrainDelegate -
type DrainDelegate struct {
Kind string `json:"kind"`
ConsensusKey string `json:"consensus_key"`
Delegate string `json:"delegate"`
Destination string `json:"destination"`
Metadata *ManagerOperationMetadata `json:"metadata,omitempty"`
}
12 changes: 12 additions & 0 deletions tzkt/api/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,15 @@ func (tzkt *API) GetIncreasePaidStorage(ctx context.Context, filters map[string]
err = tzkt.json(ctx, "/v1/operations/increase_paid_storage", filters, false, &operations)
return
}

// GetUpdateConsensusKey -
func (tzkt *API) GetUpdateConsensusKey(ctx context.Context, filters map[string]string) (operations []data.UpdateConsensusKey, err error) {
err = tzkt.json(ctx, "/v1/operations/update_consensus_key", filters, false, &operations)
return
}

// GetDrainDelegates -
func (tzkt *API) GetDrainDelegates(ctx context.Context, filters map[string]string) (operations []data.DrainDelegate, err error) {
err = tzkt.json(ctx, "/v1/operations/drain_delegate", filters, false, &operations)
return
}
2 changes: 2 additions & 0 deletions tzkt/data/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const (
KindEndorsingReward = "endorsing_reward"
KindVdfRevelation = "vdf_revelation"
KindIncreasePaidStorage = "increase_paid_storage"
KindUpdateConsensusKey = "update_consensus_key"
KindDrainDelegate = "drain_delegate"
)

// urls
Expand Down
40 changes: 39 additions & 1 deletion tzkt/data/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ type OperationConstraint interface {
Ballot | Proposal | Activation | TransferTicket | TxRollupCommit | TxRollupDispatchTicket |
TxRollupFinalizeCommitment | TxRollupOrigination | TxRollupRejection | TxRollupRemoveCommitment |
TxRollupReturnBond | TxRollupSubmitBatch | NonceRevelation | DoubleBaking | DoubleEndorsing | SetDepositsLimit |
Baking | RevelationPenalty | EndorsingReward | VdfRevelation | IncreasePaidStorage
Baking | RevelationPenalty | EndorsingReward | VdfRevelation | IncreasePaidStorage | DrainDelegate |
UpdateConsensusKey
}

// Operation -
Expand Down Expand Up @@ -660,3 +661,40 @@ type IncreasePaidStorage struct {
Contract Account `json:"contract"`
Amount decimal.Decimal `json:"amount"`
}

// UpdateConsensusKey -
type UpdateConsensusKey struct {
Type string `json:"type"`
ID uint64 `json:"id"`
Level uint64 `json:"level"`
Timestamp time.Time `json:"timestamp"`
Block string `json:"block"`
Hash string `json:"hash"`
Sender Account `json:"sender"`
Counter uint64 `json:"counter"`
GasLimit uint64 `json:"gasLimit"`
GasUsed uint64 `json:"gasUsed"`
StorageLimit uint64 `json:"storageLimit"`
BakerFee uint64 `json:"bakerFee"`
Status string `json:"status"`
ActivationCycle uint64 `json:"activationCycle"`
PublicKey string `json:"publicKey"`
PublicKeyHash string `json:"publicKeyHash"`
Errors []Error `json:"errors,omitempty"`
Quote *Quote `json:"quote,omitempty"`
}

// DrainDelegate -
type DrainDelegate struct {
Type string `json:"type"`
ID uint64 `json:"id"`
Level uint64 `json:"level"`
Timestamp time.Time `json:"timestamp"`
Block string `json:"block"`
Hash string `json:"hash"`
Delegate Account `json:"delegate"`
Target Account `json:"target"`
Amount uint64 `json:"amount"`
Fee uint64 `json:"fee"`
Quote *Quote `json:"quote,omitempty"`
}
8 changes: 8 additions & 0 deletions tzkt/events/tzkt.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ func parseOperations(data []byte) (any, error) {
result = append(result, &tzktData.Baking{})
case tzktData.KindDoublePreendorsing:
result = append(result, &tzktData.DoublePreendorsing{})
case tzktData.KindIncreasePaidStorage:
result = append(result, &tzktData.IncreasePaidStorage{})
case tzktData.KindVdfRevelation:
result = append(result, &tzktData.VdfRevelation{})
case tzktData.KindUpdateConsensusKey:
result = append(result, &tzktData.UpdateConsensusKey{})
case tzktData.KindDrainDelegate:
result = append(result, &tzktData.DrainDelegate{})
default:
result = append(result, make(map[string]interface{}))
}
Expand Down

0 comments on commit 48b2245

Please sign in to comment.