Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions node/context_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ type ContextAPI interface {
DelegateVotingPower(ctx context.Context, blockID, pkh string) (int, error)
ActiveDelegatesWithRolls(ctx context.Context, blockID string) ([]string, error)
LiquidityBakingCPMMAddress(ctx context.Context, blockID string) (string, error)
TxRollupState(ctx context.Context, txRollupID string) (TxRollupState, error)
TxRollupCommitment(ctx context.Context, blockID, txRollupID, blockLevel string) (*RollupCommitmentForBlock, error)
TxRollupInbox(ctx context.Context, blockID, txRollupID, blockLevel string) (*TxRollupInbox, error)
TxRollupPendingBondedCommitments(ctx context.Context, blockID, txRollupID, pkh string) (uint64, error)
}

// Context -
Expand Down Expand Up @@ -319,3 +323,47 @@ func (api *Context) LiquidityBakingCPMMAddress(ctx context.Context, blockID stri
err = req.doWithJSONResponse(ctx, api.client, &result)
return result, err
}

// TxRollupState -
func (api *Context) TxRollupState(ctx context.Context, blockID, txRollupID string) (TxRollupState, error) {
req, err := newGetRequest(api.baseURL, fmt.Sprintf("chains/%s/blocks/%s/context/tx_rollup/%s/state", api.chainID, blockID, txRollupID), nil)
if err != nil {
return TxRollupState{}, err
}
var state TxRollupState
err = req.doWithJSONResponse(ctx, api.client, &state)
return state, err
}

// TxRollupCommitment -
func (api *Context) TxRollupCommitment(ctx context.Context, blockID, txRollupID, blockLevel string) (*RollupCommitmentForBlock, error) {
req, err := newGetRequest(api.baseURL, fmt.Sprintf("chains/%s/blocks/%s/context/tx_rollup/%s/commitment/%s", api.chainID, blockID, txRollupID, blockLevel), nil)
if err != nil {
return nil, err
}
result := new(RollupCommitmentForBlock)
err = req.doWithJSONResponse(ctx, api.client, result)
return result, err
}

// TxRollupInbox -
func (api *Context) TxRollupInbox(ctx context.Context, blockID, txRollupID, blockLevel string) (*TxRollupInbox, error) {
req, err := newGetRequest(api.baseURL, fmt.Sprintf("chains/%s/blocks/%s/context/tx_rollup/%s/inbox/%s", api.chainID, blockID, txRollupID, blockLevel), nil)
if err != nil {
return nil, err
}
inbox := new(TxRollupInbox)
err = req.doWithJSONResponse(ctx, api.client, inbox)
return inbox, err
}

// TxRollupPendingBondedCommitments -
func (api *Context) TxRollupPendingBondedCommitments(ctx context.Context, blockID, txRollupID, pkh string) (uint64, error) {
req, err := newGetRequest(api.baseURL, fmt.Sprintf("chains/%s/blocks/%s/context/tx_rollup/%s/pending_bonded_commitments/%s", api.chainID, blockID, txRollupID, pkh), nil)
if err != nil {
return 0, err
}
var response uint64
err = req.doWithJSONResponse(ctx, api.client, &response)
return response, err
}
59 changes: 59 additions & 0 deletions node/context_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,62 @@ const (
InactiveDelegateType DelegateType = "inactive"
AllDelegateType DelegateType = "all"
)

// TxRollupState -
type TxRollupState struct {
LastRemovedCommitmentHashes *LastRemovedCommitmentHashes `json:"last_removed_commitment_hashes,omitempty"`
FinalizedCommitments RollupStateCommitment `json:"finalized_commitments"`
UnfinalizedCommitments RollupStateCommitment `json:"unfinalized_commitments"`
UncommittedInboxes RollupStateCommitment `json:"uncommitted_inboxes"`
CommitmentNewestHash *string `json:"commitment_newest_hash,omitempty"`
TezosHeadLevel *uint64 `json:"tezos_head_level,omitempty"`
BurnPerByte stdJSON.Number `json:"burn_per_byte,omitempty"`
AllocatedStorage stdJSON.Number `json:"allocated_storage"`
OccupiedStorage stdJSON.Number `json:"occupied_storage"`
InboxEma uint64 `json:"inbox_ema"`
CommitmentsWatermark *uint64 `json:"commitments_watermark,omitempty"`
}

// LastRemovedCommitmentHashes -
type LastRemovedCommitmentHashes struct {
LastMessageHash string `json:"last_message_hash"`
CommitmentHash string `json:"commitment_hash"`
}

// RollupStateCommitment -
type RollupStateCommitment struct {
Next *uint64 `json:"next,omitempty"`
Newest *uint64 `json:"newest,omitempty"`
Oldest *uint64 `json:"oldest,omitempty"`
}

// RollupCommitmentForBlock -
type RollupCommitmentForBlock struct {
Commitment RollupCommitment `json:"commitment"`
CommitmentHash string `json:"commitment_hash"`
Committer string `json:"committer"`
SubmittedAt uint64 `json:"submitted_at"`
FinalizedAt uint64 `json:"finalized_at"`
}

// RollupCommitment -
type RollupCommitment struct {
Level uint64 `json:"level"`
Messages RollupCommitmentMessages `json:"messages"`
Predecessor *string `json:"predecessor,omitempty"`
InboxMerkleRoot string `json:"inbox_merkle_root"`
}

// RollupCommitmentMessages -
type RollupCommitmentMessages struct {
Count uint64 `json:"count"`
Root string `json:"root"`
LastMessageResultHash string `json:"last_message_result_hash"`
}

// TxRollupInbox -
type TxRollupInbox struct {
InboxLength uint64 `json:"inbox_length"`
CumulatedSize uint64 `json:"cumulated_size"`
MerkleRoot string `json:"merkle_root"`
}