-
Notifications
You must be signed in to change notification settings - Fork 1
/
storage_diff.go
154 lines (121 loc) · 3.96 KB
/
storage_diff.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package lazy
import (
tz "github.com/ecadlabs/gotez/v2"
"github.com/ecadlabs/gotez/v2/encoding"
"github.com/ecadlabs/gotez/v2/protocol/core/expression"
)
//go:generate go run ../../../cmd/genmarshaller.go
type StorageDiff struct {
Contents []DiffKind `tz:"dyn" json:"contents"`
}
type DiffKind interface {
LazyStorageDiffKind() string
}
func init() {
encoding.RegisterEnum(&encoding.Enum[DiffKind]{
Variants: encoding.Variants[DiffKind]{
0: (*BigMap)(nil),
1: (*SaplingState)(nil),
},
})
}
//json:kind=LazyStorageDiffKind()
type BigMap struct {
ID tz.BigInt `json:"id"`
Diff BigMapOp `json:"diff"`
}
func (*BigMap) LazyStorageDiffKind() string { return "big_map" }
type BigMapOp interface {
LazyStorageBigMapOp() string
}
func init() {
encoding.RegisterEnum(&encoding.Enum[BigMapOp]{
Variants: encoding.Variants[BigMapOp]{
0: (*BigMapUpdate)(nil),
1: (*BigMapRemove)(nil),
2: (*BigMapCopy)(nil),
3: (*BigMapAlloc)(nil),
},
})
}
//json:action=LazyStorageBigMapOp()
type BigMapUpdate struct {
Updates []*KeyValue `tz:"dyn" json:"updates"`
}
func (*BigMapUpdate) LazyStorageBigMapOp() string { return "update" }
//json:action=LazyStorageBigMapOp()
type BigMapRemove struct{}
func (*BigMapRemove) LazyStorageBigMapOp() string { return "remove" }
//json:action=LazyStorageBigMapOp()
type BigMapCopy struct {
Source tz.BigInt `json:"source"`
Updates []*KeyValue `tz:"dyn" json:"updates"`
}
func (*BigMapCopy) LazyStorageBigMapOp() string { return "copy" }
//json:action=LazyStorageBigMapOp()
type BigMapAlloc struct {
Updates []*KeyValue `tz:"dyn" json:"updates"`
KeyType expression.Expression `json:"key_type"`
ValueType expression.Expression `json:"value_type"`
}
func (*BigMapAlloc) LazyStorageBigMapOp() string { return "alloc" }
type KeyValue struct {
KeyHash *tz.ScriptExprHash `json:"key_hash"`
Key expression.Expression `json:"key"`
Value tz.Option[expression.Expression] `json:"value"`
}
//json:kind=LazyStorageDiffKind()
type SaplingState struct {
ID tz.BigInt `json:"id"`
Diff SaplingStateOp `json:"diff"`
}
func (*SaplingState) LazyStorageDiffKind() string { return "sapling_state" }
type SaplingStateOp interface {
LazyStorageSaplingStateOp() string
}
func init() {
encoding.RegisterEnum(&encoding.Enum[SaplingStateOp]{
Variants: encoding.Variants[SaplingStateOp]{
0: (*SaplingStateUpdate)(nil),
1: (*SaplingStateRemove)(nil),
2: (*SaplingStateCopy)(nil),
3: (*SaplingStateAlloc)(nil),
},
})
}
//json:action=LazyStorageSaplingStateOp()
type SaplingStateUpdate struct {
Updates SaplingStateUpdates `json:"updates"`
}
func (*SaplingStateUpdate) LazyStorageSaplingStateOp() string { return "update" }
//json:action=LazyStorageSaplingStateOp()
type SaplingStateRemove struct{}
func (*SaplingStateRemove) LazyStorageSaplingStateOp() string { return "remove" }
//json:action=LazyStorageSaplingStateOp()
type SaplingStateCopy struct {
Source tz.BigInt `json:"source"`
Updates SaplingStateUpdates `json:"updates"`
}
func (*SaplingStateCopy) LazyStorageSaplingStateOp() string { return "copy" }
//json:action=LazyStorageSaplingStateOp()
type SaplingStateAlloc struct {
Updates SaplingStateUpdates `json:"updates"`
MemoSize uint16 `json:"memo_size"`
}
func (*SaplingStateAlloc) LazyStorageSaplingStateOp() string { return "alloc" }
type SaplingStateUpdates struct {
CommitmentsAndCiphertexts []*CommitmentAndCiphertext `tz:"dyn" json:"commitments_and_ciphertexts"`
Nullifiers tz.Bytes `tz:"dyn" json:"nullifiers"`
}
type CommitmentAndCiphertext struct {
Commitment *[32]byte `json:"commitment"`
Ciphertext SaplingCiphertext `json:"ciphertext"`
}
type SaplingCiphertext struct {
Cv *[32]byte `json:"cv"`
Epk *[32]byte `json:"epk"`
PayloadEnc []byte `tz:"dyn" json:"payload_enc"`
NonceEnc *[24]byte `json:"nonce_enc"`
PayloadOut *[80]byte `json:"payload_out"`
NonceOut *[24]byte `json:"nonce_out"`
}