This repository has been archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
tx_rollup.go
96 lines (78 loc) · 2.78 KB
/
tx_rollup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright (c) 2022 Blockwatch Data Inc.
// Author: alex@blockwatch.cc
package rpc
import (
"encoding/json"
"blockwatch.cc/tzgo/tezos"
)
// Ensure TxRollup implements the TypedOperation interface.
var _ TypedOperation = (*TxRollup)(nil)
// TxRollup represents any kind of rollup operation
type TxRollup struct {
// common
Manager
// rollup address (used by most ops)
Rollup tezos.Address `json:"rollup"`
// tx_rollup_origination has no data
// tx_rollup_submit_batch
Batch TxRollupBatch `json:"-"`
// tx_rollup_rejection
Reject TxRollupRejection `json:"-"`
// tx_rollup_dispatch_tickets
Dispatch TxRollupDispatch `json:"-"`
// tx_rollup_commit
Commit TxRollupCommit `json:"commitment"`
}
type TxRollupResult struct {
OriginatedRollup tezos.Address `json:"originated_rollup"` // v013 tx_rollup_originate
Level int64 `json:"level"` // v013 ?? here or in metadata??
}
func (r *TxRollup) UnmarshalJSON(data []byte) error {
type alias *TxRollup
if err := json.Unmarshal(data, alias(r)); err != nil {
return err
}
switch r.Kind() {
case tezos.OpTypeTxRollupSubmitBatch:
return json.Unmarshal(data, &r.Batch)
case tezos.OpTypeTxRollupRejection:
return json.Unmarshal(data, &r.Reject)
case tezos.OpTypeTxRollupDispatchTickets:
return json.Unmarshal(data, &r.Dispatch)
}
return nil
}
func (r *TxRollup) Target() tezos.Address {
if r.Dispatch.TxRollup.IsValid() {
return r.Dispatch.TxRollup
}
return r.Rollup
}
type TxRollupBatch struct {
Content tezos.HexBytes `json:"content"`
// BurnLimit int64 `json:"burn_limit,string,omitempty"`
}
type TxRollupCommit struct {
Level int64 `json:"level"`
Messages []string `json:"messages"`
Predecessor string `json:"predecessor,omitempty"`
InboxMerkleRoot string `json:"inbox_merkle_root"`
}
type TxRollupRejection struct {
Level int64 `json:"level"`
Message json.RawMessage `json:"commitment,omitempty"`
MessagePosition tezos.Z `json:"message_position"`
MessagePath []string `json:"message_path,omitempty"`
MessageResultHash string `json:"message_result_hash"`
MessageResultPath []string `json:"message_result_path,omitempty"`
PreviousMessageResult json.RawMessage `json:"previous_message_result,omitempty"`
PreviousMessageResultPath []string `json:"previous_message_result_path,omitempty"`
Proof json.RawMessage `json:"proof,omitempty"`
}
type TxRollupDispatch struct {
Level int64 `json:"level"`
TxRollup tezos.Address `json:"tx_rollup"`
ContextHash string `json:"context_hash"`
MessageIndex int64 `json:"message_index"`
TicketsInfo json.RawMessage `json:"tickets_info"`
}