@wireio/opp-solidity-models 1.0.0 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/contracts/sysio/opp/Opp.sol +182 -208
- package/contracts/sysio/opp/attestations/Attestations.sol +294 -329
- package/contracts/sysio/opp/types/Types.sol +66 -91
- package/index.mjs +2 -2
- package/package.json +11 -11
|
@@ -4,7 +4,9 @@ pragma solidity >=0.8.0 <0.9.0;
|
|
|
4
4
|
// Auto-generated by protoc-gen-solidity from sysio/opp/attestations/attestations.proto
|
|
5
5
|
// DO NOT EDIT
|
|
6
6
|
|
|
7
|
-
import {ProtobufRuntime} from "
|
|
7
|
+
import {ProtobufRuntime} from "../../../ProtobufRuntime.sol";
|
|
8
|
+
import {ChainAddress, ChainAddressCodec, ChainId, ChainIdCodec, ChainSignature, ChainSignatureCodec, TokenAmount, TokenAmountCodec} from "../types/Types.sol";
|
|
9
|
+
import {Message, MessageCodec} from "../Opp.sol";
|
|
8
10
|
|
|
9
11
|
struct ChainReserveBalanceSheet {
|
|
10
12
|
uint64 kind;
|
|
@@ -45,7 +47,7 @@ struct WireTokenPurchase {
|
|
|
45
47
|
struct OperatorAction {
|
|
46
48
|
uint64 actionType;
|
|
47
49
|
ChainAddress actor;
|
|
48
|
-
uint64
|
|
50
|
+
uint64 type_;
|
|
49
51
|
uint64 status;
|
|
50
52
|
TokenAmount amount;
|
|
51
53
|
}
|
|
@@ -71,17 +73,17 @@ struct ProtocolState {
|
|
|
71
73
|
|
|
72
74
|
library ChainReserveBalanceSheetCodec {
|
|
73
75
|
|
|
74
|
-
function encode(ChainReserveBalanceSheet memory
|
|
76
|
+
function encode(ChainReserveBalanceSheet memory chainReserveBalanceSheet) internal pure returns (bytes memory) {
|
|
75
77
|
bytes memory buf = "";
|
|
76
78
|
|
|
77
79
|
// field 1: kind
|
|
78
80
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x8));
|
|
79
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(
|
|
81
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(chainReserveBalanceSheet.kind));
|
|
80
82
|
|
|
81
83
|
// field 2: amounts
|
|
82
|
-
for (uint256 _i_amounts = 0; _i_amounts <
|
|
84
|
+
for (uint256 _i_amounts = 0; _i_amounts < chainReserveBalanceSheet.amounts.length; _i_amounts++) {
|
|
83
85
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
84
|
-
bytes memory _elem = TokenAmountCodec.encode(
|
|
86
|
+
bytes memory _elem = TokenAmountCodec.encode(chainReserveBalanceSheet.amounts[_i_amounts]);
|
|
85
87
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(_elem.length)));
|
|
86
88
|
buf = abi.encodePacked(buf, _elem);
|
|
87
89
|
}
|
|
@@ -89,31 +91,37 @@ library ChainReserveBalanceSheetCodec {
|
|
|
89
91
|
return buf;
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
function decode(bytes memory data) internal pure returns (ChainReserveBalanceSheet memory
|
|
94
|
+
function decode(bytes memory data) internal pure returns (ChainReserveBalanceSheet memory chainReserveBalanceSheet) {
|
|
93
95
|
uint256 pos = 0;
|
|
94
96
|
uint256 end = data.length;
|
|
95
97
|
|
|
98
|
+
uint256 _count_amounts = 0;
|
|
99
|
+
{
|
|
100
|
+
uint256 _pos = 0;
|
|
101
|
+
while (_pos < end) {
|
|
102
|
+
uint64 _tag;
|
|
103
|
+
(_tag, _pos) = ProtobufRuntime._decode_key(data, _pos);
|
|
104
|
+
if (_tag == 18) { _count_amounts++; }
|
|
105
|
+
_pos = ProtobufRuntime._skip_field(data, _pos, _tag & 0x07);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
chainReserveBalanceSheet.amounts = new TokenAmount[](_count_amounts);
|
|
109
|
+
uint256 _idx_amounts = 0;
|
|
110
|
+
|
|
96
111
|
while (pos < end) {
|
|
97
112
|
uint64 tag;
|
|
98
113
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
99
114
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
msg.amounts.push(TokenAmountCodec.decode(_sub));
|
|
111
|
-
pos += uint256(_len);
|
|
112
|
-
}
|
|
113
|
-
break;
|
|
114
|
-
default:
|
|
115
|
-
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
116
|
-
break;
|
|
115
|
+
if (tag == 8) {
|
|
116
|
+
(chainReserveBalanceSheet.kind, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
117
|
+
} else if (tag == 18) {
|
|
118
|
+
uint64 _len;
|
|
119
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
120
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
121
|
+
chainReserveBalanceSheet.amounts[_idx_amounts++] = TokenAmountCodec.decode(_sub);
|
|
122
|
+
pos += uint256(_len);
|
|
123
|
+
} else {
|
|
124
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
117
125
|
}
|
|
118
126
|
}
|
|
119
127
|
}
|
|
@@ -121,33 +129,33 @@ library ChainReserveBalanceSheetCodec {
|
|
|
121
129
|
|
|
122
130
|
library PretokenStakeChangeCodec {
|
|
123
131
|
|
|
124
|
-
function encode(PretokenStakeChange memory
|
|
132
|
+
function encode(PretokenStakeChange memory pretokenStakeChange) internal pure returns (bytes memory) {
|
|
125
133
|
bytes memory buf = "";
|
|
126
134
|
|
|
127
135
|
// field 1: actor
|
|
128
136
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0xa));
|
|
129
|
-
bytes memory actor_encoded = ChainAddressCodec.encode(
|
|
137
|
+
bytes memory actor_encoded = ChainAddressCodec.encode(pretokenStakeChange.actor);
|
|
130
138
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(actor_encoded.length)));
|
|
131
139
|
buf = abi.encodePacked(buf, actor_encoded);
|
|
132
140
|
|
|
133
141
|
// field 2: amount
|
|
134
142
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
135
|
-
bytes memory amount_encoded = TokenAmountCodec.encode(
|
|
143
|
+
bytes memory amount_encoded = TokenAmountCodec.encode(pretokenStakeChange.amount);
|
|
136
144
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(amount_encoded.length)));
|
|
137
145
|
buf = abi.encodePacked(buf, amount_encoded);
|
|
138
146
|
|
|
139
147
|
// field 10: index_at_mint
|
|
140
148
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x50));
|
|
141
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(
|
|
149
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(pretokenStakeChange.indexAtMint)));
|
|
142
150
|
|
|
143
151
|
// field 11: index_at_burn
|
|
144
152
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x58));
|
|
145
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(
|
|
153
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(pretokenStakeChange.indexAtBurn)));
|
|
146
154
|
|
|
147
155
|
return buf;
|
|
148
156
|
}
|
|
149
157
|
|
|
150
|
-
function decode(bytes memory data) internal pure returns (PretokenStakeChange memory
|
|
158
|
+
function decode(bytes memory data) internal pure returns (PretokenStakeChange memory pretokenStakeChange) {
|
|
151
159
|
uint256 pos = 0;
|
|
152
160
|
uint256 end = data.length;
|
|
153
161
|
|
|
@@ -155,35 +163,28 @@ library PretokenStakeChangeCodec {
|
|
|
155
163
|
uint64 tag;
|
|
156
164
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
157
165
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
break;
|
|
181
|
-
case 88:
|
|
182
|
-
(msg.indexAtBurn, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
183
|
-
break;
|
|
184
|
-
default:
|
|
185
|
-
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
186
|
-
break;
|
|
166
|
+
if (tag == 10) {
|
|
167
|
+
uint64 _len;
|
|
168
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
169
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
170
|
+
pretokenStakeChange.actor = ChainAddressCodec.decode(_sub);
|
|
171
|
+
pos += uint256(_len);
|
|
172
|
+
} else if (tag == 18) {
|
|
173
|
+
uint64 _len;
|
|
174
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
175
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
176
|
+
pretokenStakeChange.amount = TokenAmountCodec.decode(_sub);
|
|
177
|
+
pos += uint256(_len);
|
|
178
|
+
} else if (tag == 80) {
|
|
179
|
+
{ uint64 _v;
|
|
180
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
181
|
+
pretokenStakeChange.indexAtMint = int64(_v); }
|
|
182
|
+
} else if (tag == 88) {
|
|
183
|
+
{ uint64 _v;
|
|
184
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
185
|
+
pretokenStakeChange.indexAtBurn = int64(_v); }
|
|
186
|
+
} else {
|
|
187
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
}
|
|
@@ -191,33 +192,33 @@ library PretokenStakeChangeCodec {
|
|
|
191
192
|
|
|
192
193
|
library PretokenPurchaseCodec {
|
|
193
194
|
|
|
194
|
-
function encode(PretokenPurchase memory
|
|
195
|
+
function encode(PretokenPurchase memory pretokenPurchase) internal pure returns (bytes memory) {
|
|
195
196
|
bytes memory buf = "";
|
|
196
197
|
|
|
197
198
|
// field 1: actor
|
|
198
199
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0xa));
|
|
199
|
-
bytes memory actor_encoded = ChainAddressCodec.encode(
|
|
200
|
+
bytes memory actor_encoded = ChainAddressCodec.encode(pretokenPurchase.actor);
|
|
200
201
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(actor_encoded.length)));
|
|
201
202
|
buf = abi.encodePacked(buf, actor_encoded);
|
|
202
203
|
|
|
203
204
|
// field 2: amount
|
|
204
205
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
205
|
-
bytes memory amount_encoded = TokenAmountCodec.encode(
|
|
206
|
+
bytes memory amount_encoded = TokenAmountCodec.encode(pretokenPurchase.amount);
|
|
206
207
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(amount_encoded.length)));
|
|
207
208
|
buf = abi.encodePacked(buf, amount_encoded);
|
|
208
209
|
|
|
209
210
|
// field 3: pretoken_count
|
|
210
211
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x18));
|
|
211
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(
|
|
212
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(pretokenPurchase.pretokenCount)));
|
|
212
213
|
|
|
213
214
|
// field 10: index_at_mint
|
|
214
215
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x50));
|
|
215
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(
|
|
216
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(pretokenPurchase.indexAtMint)));
|
|
216
217
|
|
|
217
218
|
return buf;
|
|
218
219
|
}
|
|
219
220
|
|
|
220
|
-
function decode(bytes memory data) internal pure returns (PretokenPurchase memory
|
|
221
|
+
function decode(bytes memory data) internal pure returns (PretokenPurchase memory pretokenPurchase) {
|
|
221
222
|
uint256 pos = 0;
|
|
222
223
|
uint256 end = data.length;
|
|
223
224
|
|
|
@@ -225,35 +226,28 @@ library PretokenPurchaseCodec {
|
|
|
225
226
|
uint64 tag;
|
|
226
227
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
227
228
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
break;
|
|
251
|
-
case 80:
|
|
252
|
-
(msg.indexAtMint, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
253
|
-
break;
|
|
254
|
-
default:
|
|
255
|
-
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
256
|
-
break;
|
|
229
|
+
if (tag == 10) {
|
|
230
|
+
uint64 _len;
|
|
231
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
232
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
233
|
+
pretokenPurchase.actor = ChainAddressCodec.decode(_sub);
|
|
234
|
+
pos += uint256(_len);
|
|
235
|
+
} else if (tag == 18) {
|
|
236
|
+
uint64 _len;
|
|
237
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
238
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
239
|
+
pretokenPurchase.amount = TokenAmountCodec.decode(_sub);
|
|
240
|
+
pos += uint256(_len);
|
|
241
|
+
} else if (tag == 24) {
|
|
242
|
+
{ uint64 _v;
|
|
243
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
244
|
+
pretokenPurchase.pretokenCount = int64(_v); }
|
|
245
|
+
} else if (tag == 80) {
|
|
246
|
+
{ uint64 _v;
|
|
247
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
248
|
+
pretokenPurchase.indexAtMint = int64(_v); }
|
|
249
|
+
} else {
|
|
250
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
257
251
|
}
|
|
258
252
|
}
|
|
259
253
|
}
|
|
@@ -261,29 +255,29 @@ library PretokenPurchaseCodec {
|
|
|
261
255
|
|
|
262
256
|
library PretokenYieldCodec {
|
|
263
257
|
|
|
264
|
-
function encode(PretokenYield memory
|
|
258
|
+
function encode(PretokenYield memory pretokenYield) internal pure returns (bytes memory) {
|
|
265
259
|
bytes memory buf = "";
|
|
266
260
|
|
|
267
261
|
// field 1: actor
|
|
268
262
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0xa));
|
|
269
|
-
bytes memory actor_encoded = ChainAddressCodec.encode(
|
|
263
|
+
bytes memory actor_encoded = ChainAddressCodec.encode(pretokenYield.actor);
|
|
270
264
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(actor_encoded.length)));
|
|
271
265
|
buf = abi.encodePacked(buf, actor_encoded);
|
|
272
266
|
|
|
273
267
|
// field 2: amount
|
|
274
268
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
275
|
-
bytes memory amount_encoded = TokenAmountCodec.encode(
|
|
269
|
+
bytes memory amount_encoded = TokenAmountCodec.encode(pretokenYield.amount);
|
|
276
270
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(amount_encoded.length)));
|
|
277
271
|
buf = abi.encodePacked(buf, amount_encoded);
|
|
278
272
|
|
|
279
273
|
// field 3: index_at_mint
|
|
280
274
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x18));
|
|
281
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(
|
|
275
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(pretokenYield.indexAtMint)));
|
|
282
276
|
|
|
283
277
|
return buf;
|
|
284
278
|
}
|
|
285
279
|
|
|
286
|
-
function decode(bytes memory data) internal pure returns (PretokenYield memory
|
|
280
|
+
function decode(bytes memory data) internal pure returns (PretokenYield memory pretokenYield) {
|
|
287
281
|
uint256 pos = 0;
|
|
288
282
|
uint256 end = data.length;
|
|
289
283
|
|
|
@@ -291,32 +285,24 @@ library PretokenYieldCodec {
|
|
|
291
285
|
uint64 tag;
|
|
292
286
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
293
287
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
break;
|
|
314
|
-
case 24:
|
|
315
|
-
(msg.indexAtMint, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
316
|
-
break;
|
|
317
|
-
default:
|
|
318
|
-
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
319
|
-
break;
|
|
288
|
+
if (tag == 10) {
|
|
289
|
+
uint64 _len;
|
|
290
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
291
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
292
|
+
pretokenYield.actor = ChainAddressCodec.decode(_sub);
|
|
293
|
+
pos += uint256(_len);
|
|
294
|
+
} else if (tag == 18) {
|
|
295
|
+
uint64 _len;
|
|
296
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
297
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
298
|
+
pretokenYield.amount = TokenAmountCodec.decode(_sub);
|
|
299
|
+
pos += uint256(_len);
|
|
300
|
+
} else if (tag == 24) {
|
|
301
|
+
{ uint64 _v;
|
|
302
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
303
|
+
pretokenYield.indexAtMint = int64(_v); }
|
|
304
|
+
} else {
|
|
305
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
320
306
|
}
|
|
321
307
|
}
|
|
322
308
|
}
|
|
@@ -324,29 +310,29 @@ library PretokenYieldCodec {
|
|
|
324
310
|
|
|
325
311
|
library StakeUpdateCodec {
|
|
326
312
|
|
|
327
|
-
function encode(StakeUpdate memory
|
|
313
|
+
function encode(StakeUpdate memory stakeUpdate) internal pure returns (bytes memory) {
|
|
328
314
|
bytes memory buf = "";
|
|
329
315
|
|
|
330
316
|
// field 1: actor
|
|
331
317
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0xa));
|
|
332
|
-
bytes memory actor_encoded = ChainAddressCodec.encode(
|
|
318
|
+
bytes memory actor_encoded = ChainAddressCodec.encode(stakeUpdate.actor);
|
|
333
319
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(actor_encoded.length)));
|
|
334
320
|
buf = abi.encodePacked(buf, actor_encoded);
|
|
335
321
|
|
|
336
322
|
// field 2: status
|
|
337
323
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x10));
|
|
338
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(
|
|
324
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(stakeUpdate.status));
|
|
339
325
|
|
|
340
326
|
// field 3: amount
|
|
341
327
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x1a));
|
|
342
|
-
bytes memory amount_encoded = TokenAmountCodec.encode(
|
|
328
|
+
bytes memory amount_encoded = TokenAmountCodec.encode(stakeUpdate.amount);
|
|
343
329
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(amount_encoded.length)));
|
|
344
330
|
buf = abi.encodePacked(buf, amount_encoded);
|
|
345
331
|
|
|
346
332
|
return buf;
|
|
347
333
|
}
|
|
348
334
|
|
|
349
|
-
function decode(bytes memory data) internal pure returns (StakeUpdate memory
|
|
335
|
+
function decode(bytes memory data) internal pure returns (StakeUpdate memory stakeUpdate) {
|
|
350
336
|
uint256 pos = 0;
|
|
351
337
|
uint256 end = data.length;
|
|
352
338
|
|
|
@@ -354,32 +340,22 @@ library StakeUpdateCodec {
|
|
|
354
340
|
uint64 tag;
|
|
355
341
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
356
342
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
uint64 _len;
|
|
374
|
-
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
375
|
-
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
376
|
-
msg.amount = TokenAmountCodec.decode(_sub);
|
|
377
|
-
pos += uint256(_len);
|
|
378
|
-
}
|
|
379
|
-
break;
|
|
380
|
-
default:
|
|
381
|
-
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
382
|
-
break;
|
|
343
|
+
if (tag == 10) {
|
|
344
|
+
uint64 _len;
|
|
345
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
346
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
347
|
+
stakeUpdate.actor = ChainAddressCodec.decode(_sub);
|
|
348
|
+
pos += uint256(_len);
|
|
349
|
+
} else if (tag == 16) {
|
|
350
|
+
(stakeUpdate.status, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
351
|
+
} else if (tag == 26) {
|
|
352
|
+
uint64 _len;
|
|
353
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
354
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
355
|
+
stakeUpdate.amount = TokenAmountCodec.decode(_sub);
|
|
356
|
+
pos += uint256(_len);
|
|
357
|
+
} else {
|
|
358
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
383
359
|
}
|
|
384
360
|
}
|
|
385
361
|
}
|
|
@@ -387,19 +363,19 @@ library StakeUpdateCodec {
|
|
|
387
363
|
|
|
388
364
|
library WireTokenPurchaseCodec {
|
|
389
365
|
|
|
390
|
-
function encode(WireTokenPurchase memory
|
|
366
|
+
function encode(WireTokenPurchase memory wireTokenPurchase) internal pure returns (bytes memory) {
|
|
391
367
|
bytes memory buf = "";
|
|
392
368
|
|
|
393
369
|
// field 1: actor
|
|
394
370
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0xa));
|
|
395
|
-
bytes memory actor_encoded = ChainAddressCodec.encode(
|
|
371
|
+
bytes memory actor_encoded = ChainAddressCodec.encode(wireTokenPurchase.actor);
|
|
396
372
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(actor_encoded.length)));
|
|
397
373
|
buf = abi.encodePacked(buf, actor_encoded);
|
|
398
374
|
|
|
399
375
|
// field 2: amounts
|
|
400
|
-
for (uint256 _i_amounts = 0; _i_amounts <
|
|
376
|
+
for (uint256 _i_amounts = 0; _i_amounts < wireTokenPurchase.amounts.length; _i_amounts++) {
|
|
401
377
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
402
|
-
bytes memory _elem = TokenAmountCodec.encode(
|
|
378
|
+
bytes memory _elem = TokenAmountCodec.encode(wireTokenPurchase.amounts[_i_amounts]);
|
|
403
379
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(_elem.length)));
|
|
404
380
|
buf = abi.encodePacked(buf, _elem);
|
|
405
381
|
}
|
|
@@ -407,37 +383,41 @@ library WireTokenPurchaseCodec {
|
|
|
407
383
|
return buf;
|
|
408
384
|
}
|
|
409
385
|
|
|
410
|
-
function decode(bytes memory data) internal pure returns (WireTokenPurchase memory
|
|
386
|
+
function decode(bytes memory data) internal pure returns (WireTokenPurchase memory wireTokenPurchase) {
|
|
411
387
|
uint256 pos = 0;
|
|
412
388
|
uint256 end = data.length;
|
|
413
389
|
|
|
390
|
+
uint256 _count_amounts = 0;
|
|
391
|
+
{
|
|
392
|
+
uint256 _pos = 0;
|
|
393
|
+
while (_pos < end) {
|
|
394
|
+
uint64 _tag;
|
|
395
|
+
(_tag, _pos) = ProtobufRuntime._decode_key(data, _pos);
|
|
396
|
+
if (_tag == 18) { _count_amounts++; }
|
|
397
|
+
_pos = ProtobufRuntime._skip_field(data, _pos, _tag & 0x07);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
wireTokenPurchase.amounts = new TokenAmount[](_count_amounts);
|
|
401
|
+
uint256 _idx_amounts = 0;
|
|
402
|
+
|
|
414
403
|
while (pos < end) {
|
|
415
404
|
uint64 tag;
|
|
416
405
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
417
406
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
433
|
-
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
434
|
-
msg.amounts.push(TokenAmountCodec.decode(_sub));
|
|
435
|
-
pos += uint256(_len);
|
|
436
|
-
}
|
|
437
|
-
break;
|
|
438
|
-
default:
|
|
439
|
-
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
440
|
-
break;
|
|
407
|
+
if (tag == 10) {
|
|
408
|
+
uint64 _len;
|
|
409
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
410
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
411
|
+
wireTokenPurchase.actor = ChainAddressCodec.decode(_sub);
|
|
412
|
+
pos += uint256(_len);
|
|
413
|
+
} else if (tag == 18) {
|
|
414
|
+
uint64 _len;
|
|
415
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
416
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
417
|
+
wireTokenPurchase.amounts[_idx_amounts++] = TokenAmountCodec.decode(_sub);
|
|
418
|
+
pos += uint256(_len);
|
|
419
|
+
} else {
|
|
420
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
441
421
|
}
|
|
442
422
|
}
|
|
443
423
|
}
|
|
@@ -445,37 +425,37 @@ library WireTokenPurchaseCodec {
|
|
|
445
425
|
|
|
446
426
|
library OperatorActionCodec {
|
|
447
427
|
|
|
448
|
-
function encode(OperatorAction memory
|
|
428
|
+
function encode(OperatorAction memory operatorAction) internal pure returns (bytes memory) {
|
|
449
429
|
bytes memory buf = "";
|
|
450
430
|
|
|
451
431
|
// field 1: action_type
|
|
452
432
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x8));
|
|
453
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(
|
|
433
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(operatorAction.actionType));
|
|
454
434
|
|
|
455
435
|
// field 2: actor
|
|
456
436
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
457
|
-
bytes memory actor_encoded = ChainAddressCodec.encode(
|
|
437
|
+
bytes memory actor_encoded = ChainAddressCodec.encode(operatorAction.actor);
|
|
458
438
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(actor_encoded.length)));
|
|
459
439
|
buf = abi.encodePacked(buf, actor_encoded);
|
|
460
440
|
|
|
461
441
|
// field 3: type
|
|
462
442
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x18));
|
|
463
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(
|
|
443
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(operatorAction.type_));
|
|
464
444
|
|
|
465
445
|
// field 4: status
|
|
466
446
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x20));
|
|
467
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(
|
|
447
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(operatorAction.status));
|
|
468
448
|
|
|
469
449
|
// field 10: amount
|
|
470
450
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x52));
|
|
471
|
-
bytes memory amount_encoded = TokenAmountCodec.encode(
|
|
451
|
+
bytes memory amount_encoded = TokenAmountCodec.encode(operatorAction.amount);
|
|
472
452
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(amount_encoded.length)));
|
|
473
453
|
buf = abi.encodePacked(buf, amount_encoded);
|
|
474
454
|
|
|
475
455
|
return buf;
|
|
476
456
|
}
|
|
477
457
|
|
|
478
|
-
function decode(bytes memory data) internal pure returns (OperatorAction memory
|
|
458
|
+
function decode(bytes memory data) internal pure returns (OperatorAction memory operatorAction) {
|
|
479
459
|
uint256 pos = 0;
|
|
480
460
|
uint256 end = data.length;
|
|
481
461
|
|
|
@@ -483,38 +463,26 @@ library OperatorActionCodec {
|
|
|
483
463
|
uint64 tag;
|
|
484
464
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
485
465
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
case 82:
|
|
507
|
-
{
|
|
508
|
-
uint64 _len;
|
|
509
|
-
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
510
|
-
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
511
|
-
msg.amount = TokenAmountCodec.decode(_sub);
|
|
512
|
-
pos += uint256(_len);
|
|
513
|
-
}
|
|
514
|
-
break;
|
|
515
|
-
default:
|
|
516
|
-
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
517
|
-
break;
|
|
466
|
+
if (tag == 8) {
|
|
467
|
+
(operatorAction.actionType, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
468
|
+
} else if (tag == 18) {
|
|
469
|
+
uint64 _len;
|
|
470
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
471
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
472
|
+
operatorAction.actor = ChainAddressCodec.decode(_sub);
|
|
473
|
+
pos += uint256(_len);
|
|
474
|
+
} else if (tag == 24) {
|
|
475
|
+
(operatorAction.type_, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
476
|
+
} else if (tag == 32) {
|
|
477
|
+
(operatorAction.status, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
478
|
+
} else if (tag == 82) {
|
|
479
|
+
uint64 _len;
|
|
480
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
481
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
482
|
+
operatorAction.amount = TokenAmountCodec.decode(_sub);
|
|
483
|
+
pos += uint256(_len);
|
|
484
|
+
} else {
|
|
485
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
518
486
|
}
|
|
519
487
|
}
|
|
520
488
|
}
|
|
@@ -522,25 +490,25 @@ library OperatorActionCodec {
|
|
|
522
490
|
|
|
523
491
|
library ReserveDisbursementCodec {
|
|
524
492
|
|
|
525
|
-
function encode(ReserveDisbursement memory
|
|
493
|
+
function encode(ReserveDisbursement memory reserveDisbursement) internal pure returns (bytes memory) {
|
|
526
494
|
bytes memory buf = "";
|
|
527
495
|
|
|
528
496
|
// field 1: actor
|
|
529
497
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0xa));
|
|
530
|
-
bytes memory actor_encoded = ChainAddressCodec.encode(
|
|
498
|
+
bytes memory actor_encoded = ChainAddressCodec.encode(reserveDisbursement.actor);
|
|
531
499
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(actor_encoded.length)));
|
|
532
500
|
buf = abi.encodePacked(buf, actor_encoded);
|
|
533
501
|
|
|
534
502
|
// field 2: amount
|
|
535
503
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
536
|
-
bytes memory amount_encoded = TokenAmountCodec.encode(
|
|
504
|
+
bytes memory amount_encoded = TokenAmountCodec.encode(reserveDisbursement.amount);
|
|
537
505
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(amount_encoded.length)));
|
|
538
506
|
buf = abi.encodePacked(buf, amount_encoded);
|
|
539
507
|
|
|
540
508
|
// field 3: signature
|
|
541
|
-
for (uint256 _i_signature = 0; _i_signature <
|
|
509
|
+
for (uint256 _i_signature = 0; _i_signature < reserveDisbursement.signature.length; _i_signature++) {
|
|
542
510
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x1a));
|
|
543
|
-
bytes memory _elem = ChainSignatureCodec.encode(
|
|
511
|
+
bytes memory _elem = ChainSignatureCodec.encode(reserveDisbursement.signature[_i_signature]);
|
|
544
512
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(_elem.length)));
|
|
545
513
|
buf = abi.encodePacked(buf, _elem);
|
|
546
514
|
}
|
|
@@ -548,46 +516,47 @@ library ReserveDisbursementCodec {
|
|
|
548
516
|
return buf;
|
|
549
517
|
}
|
|
550
518
|
|
|
551
|
-
function decode(bytes memory data) internal pure returns (ReserveDisbursement memory
|
|
519
|
+
function decode(bytes memory data) internal pure returns (ReserveDisbursement memory reserveDisbursement) {
|
|
552
520
|
uint256 pos = 0;
|
|
553
521
|
uint256 end = data.length;
|
|
554
522
|
|
|
523
|
+
uint256 _count_signature = 0;
|
|
524
|
+
{
|
|
525
|
+
uint256 _pos = 0;
|
|
526
|
+
while (_pos < end) {
|
|
527
|
+
uint64 _tag;
|
|
528
|
+
(_tag, _pos) = ProtobufRuntime._decode_key(data, _pos);
|
|
529
|
+
if (_tag == 26) { _count_signature++; }
|
|
530
|
+
_pos = ProtobufRuntime._skip_field(data, _pos, _tag & 0x07);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
reserveDisbursement.signature = new ChainSignature[](_count_signature);
|
|
534
|
+
uint256 _idx_signature = 0;
|
|
535
|
+
|
|
555
536
|
while (pos < end) {
|
|
556
537
|
uint64 tag;
|
|
557
538
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
558
539
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
case 26:
|
|
580
|
-
{
|
|
581
|
-
uint64 _len;
|
|
582
|
-
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
583
|
-
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
584
|
-
msg.signature.push(ChainSignatureCodec.decode(_sub));
|
|
585
|
-
pos += uint256(_len);
|
|
586
|
-
}
|
|
587
|
-
break;
|
|
588
|
-
default:
|
|
589
|
-
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
590
|
-
break;
|
|
540
|
+
if (tag == 10) {
|
|
541
|
+
uint64 _len;
|
|
542
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
543
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
544
|
+
reserveDisbursement.actor = ChainAddressCodec.decode(_sub);
|
|
545
|
+
pos += uint256(_len);
|
|
546
|
+
} else if (tag == 18) {
|
|
547
|
+
uint64 _len;
|
|
548
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
549
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
550
|
+
reserveDisbursement.amount = TokenAmountCodec.decode(_sub);
|
|
551
|
+
pos += uint256(_len);
|
|
552
|
+
} else if (tag == 26) {
|
|
553
|
+
uint64 _len;
|
|
554
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
555
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
556
|
+
reserveDisbursement.signature[_idx_signature++] = ChainSignatureCodec.decode(_sub);
|
|
557
|
+
pos += uint256(_len);
|
|
558
|
+
} else {
|
|
559
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
591
560
|
}
|
|
592
561
|
}
|
|
593
562
|
}
|
|
@@ -595,23 +564,23 @@ library ReserveDisbursementCodec {
|
|
|
595
564
|
|
|
596
565
|
library TimestampedMessageCodec {
|
|
597
566
|
|
|
598
|
-
function encode(TimestampedMessage memory
|
|
567
|
+
function encode(TimestampedMessage memory timestampedMessage) internal pure returns (bytes memory) {
|
|
599
568
|
bytes memory buf = "";
|
|
600
569
|
|
|
601
570
|
// field 1: timestamp
|
|
602
571
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x8));
|
|
603
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(
|
|
572
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(timestampedMessage.timestamp));
|
|
604
573
|
|
|
605
574
|
// field 2: message
|
|
606
575
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
607
|
-
bytes memory message_encoded = MessageCodec.encode(
|
|
576
|
+
bytes memory message_encoded = MessageCodec.encode(timestampedMessage.message);
|
|
608
577
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(message_encoded.length)));
|
|
609
578
|
buf = abi.encodePacked(buf, message_encoded);
|
|
610
579
|
|
|
611
580
|
return buf;
|
|
612
581
|
}
|
|
613
582
|
|
|
614
|
-
function decode(bytes memory data) internal pure returns (TimestampedMessage memory
|
|
583
|
+
function decode(bytes memory data) internal pure returns (TimestampedMessage memory timestampedMessage) {
|
|
615
584
|
uint256 pos = 0;
|
|
616
585
|
uint256 end = data.length;
|
|
617
586
|
|
|
@@ -619,23 +588,16 @@ library TimestampedMessageCodec {
|
|
|
619
588
|
uint64 tag;
|
|
620
589
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
621
590
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
msg.message = MessageCodec.decode(_sub);
|
|
633
|
-
pos += uint256(_len);
|
|
634
|
-
}
|
|
635
|
-
break;
|
|
636
|
-
default:
|
|
637
|
-
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
638
|
-
break;
|
|
591
|
+
if (tag == 8) {
|
|
592
|
+
(timestampedMessage.timestamp, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
593
|
+
} else if (tag == 18) {
|
|
594
|
+
uint64 _len;
|
|
595
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
596
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
597
|
+
timestampedMessage.message = MessageCodec.decode(_sub);
|
|
598
|
+
pos += uint256(_len);
|
|
599
|
+
} else {
|
|
600
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
639
601
|
}
|
|
640
602
|
}
|
|
641
603
|
}
|
|
@@ -643,35 +605,35 @@ library TimestampedMessageCodec {
|
|
|
643
605
|
|
|
644
606
|
library ProtocolStateCodec {
|
|
645
607
|
|
|
646
|
-
function encode(ProtocolState memory
|
|
608
|
+
function encode(ProtocolState memory protocolState) internal pure returns (bytes memory) {
|
|
647
609
|
bytes memory buf = "";
|
|
648
610
|
|
|
649
611
|
// field 1: chain_id
|
|
650
612
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0xa));
|
|
651
|
-
bytes memory chainId_encoded = ChainIdCodec.encode(
|
|
613
|
+
bytes memory chainId_encoded = ChainIdCodec.encode(protocolState.chainId);
|
|
652
614
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(chainId_encoded.length)));
|
|
653
615
|
buf = abi.encodePacked(buf, chainId_encoded);
|
|
654
616
|
|
|
655
617
|
// field 2: current_message_id
|
|
656
618
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
657
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_bytes(
|
|
619
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_bytes(protocolState.currentMessageId));
|
|
658
620
|
|
|
659
621
|
// field 3: processed_message_id
|
|
660
622
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x1a));
|
|
661
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_bytes(
|
|
623
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_bytes(protocolState.processedMessageId));
|
|
662
624
|
|
|
663
625
|
// field 4: incoming_messages
|
|
664
|
-
for (uint256 _i_incomingMessages = 0; _i_incomingMessages <
|
|
626
|
+
for (uint256 _i_incomingMessages = 0; _i_incomingMessages < protocolState.incomingMessages.length; _i_incomingMessages++) {
|
|
665
627
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x22));
|
|
666
|
-
bytes memory _elem = TimestampedMessageCodec.encode(
|
|
628
|
+
bytes memory _elem = TimestampedMessageCodec.encode(protocolState.incomingMessages[_i_incomingMessages]);
|
|
667
629
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(_elem.length)));
|
|
668
630
|
buf = abi.encodePacked(buf, _elem);
|
|
669
631
|
}
|
|
670
632
|
|
|
671
633
|
// field 5: outgoing
|
|
672
|
-
for (uint256 _i_outgoing = 0; _i_outgoing <
|
|
634
|
+
for (uint256 _i_outgoing = 0; _i_outgoing < protocolState.outgoing.length; _i_outgoing++) {
|
|
673
635
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x2a));
|
|
674
|
-
bytes memory _elem = MessageCodec.encode(
|
|
636
|
+
bytes memory _elem = MessageCodec.encode(protocolState.outgoing[_i_outgoing]);
|
|
675
637
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(_elem.length)));
|
|
676
638
|
buf = abi.encodePacked(buf, _elem);
|
|
677
639
|
}
|
|
@@ -679,52 +641,55 @@ library ProtocolStateCodec {
|
|
|
679
641
|
return buf;
|
|
680
642
|
}
|
|
681
643
|
|
|
682
|
-
function decode(bytes memory data) internal pure returns (ProtocolState memory
|
|
644
|
+
function decode(bytes memory data) internal pure returns (ProtocolState memory protocolState) {
|
|
683
645
|
uint256 pos = 0;
|
|
684
646
|
uint256 end = data.length;
|
|
685
647
|
|
|
648
|
+
uint256 _count_incomingMessages = 0;
|
|
649
|
+
uint256 _count_outgoing = 0;
|
|
650
|
+
{
|
|
651
|
+
uint256 _pos = 0;
|
|
652
|
+
while (_pos < end) {
|
|
653
|
+
uint64 _tag;
|
|
654
|
+
(_tag, _pos) = ProtobufRuntime._decode_key(data, _pos);
|
|
655
|
+
if (_tag == 34) { _count_incomingMessages++; }
|
|
656
|
+
if (_tag == 42) { _count_outgoing++; }
|
|
657
|
+
_pos = ProtobufRuntime._skip_field(data, _pos, _tag & 0x07);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
protocolState.incomingMessages = new TimestampedMessage[](_count_incomingMessages);
|
|
661
|
+
protocolState.outgoing = new Message[](_count_outgoing);
|
|
662
|
+
uint256 _idx_incomingMessages = 0;
|
|
663
|
+
uint256 _idx_outgoing = 0;
|
|
664
|
+
|
|
686
665
|
while (pos < end) {
|
|
687
666
|
uint64 tag;
|
|
688
667
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
689
668
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
}
|
|
715
|
-
break;
|
|
716
|
-
case 42:
|
|
717
|
-
{
|
|
718
|
-
uint64 _len;
|
|
719
|
-
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
720
|
-
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
721
|
-
msg.outgoing.push(MessageCodec.decode(_sub));
|
|
722
|
-
pos += uint256(_len);
|
|
723
|
-
}
|
|
724
|
-
break;
|
|
725
|
-
default:
|
|
726
|
-
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
727
|
-
break;
|
|
669
|
+
if (tag == 10) {
|
|
670
|
+
uint64 _len;
|
|
671
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
672
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
673
|
+
protocolState.chainId = ChainIdCodec.decode(_sub);
|
|
674
|
+
pos += uint256(_len);
|
|
675
|
+
} else if (tag == 18) {
|
|
676
|
+
(protocolState.currentMessageId, pos) = ProtobufRuntime._decode_bytes(data, pos);
|
|
677
|
+
} else if (tag == 26) {
|
|
678
|
+
(protocolState.processedMessageId, pos) = ProtobufRuntime._decode_bytes(data, pos);
|
|
679
|
+
} else if (tag == 34) {
|
|
680
|
+
uint64 _len;
|
|
681
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
682
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
683
|
+
protocolState.incomingMessages[_idx_incomingMessages++] = TimestampedMessageCodec.decode(_sub);
|
|
684
|
+
pos += uint256(_len);
|
|
685
|
+
} else if (tag == 42) {
|
|
686
|
+
uint64 _len;
|
|
687
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
688
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
689
|
+
protocolState.outgoing[_idx_outgoing++] = MessageCodec.decode(_sub);
|
|
690
|
+
pos += uint256(_len);
|
|
691
|
+
} else {
|
|
692
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
728
693
|
}
|
|
729
694
|
}
|
|
730
695
|
}
|