@wireio/opp-solidity-models 1.0.0
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 -0
- package/contracts/ProtobufRuntime.sol +274 -0
- package/contracts/sysio/opp/Opp.sol +473 -0
- package/contracts/sysio/opp/attestations/Attestations.sol +731 -0
- package/contracts/sysio/opp/types/Types.sol +256 -0
- package/index.mjs +2 -0
- package/package.json +11 -0
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity >=0.8.0 <0.9.0;
|
|
3
|
+
|
|
4
|
+
// Auto-generated by protoc-gen-solidity from sysio/opp/opp.proto
|
|
5
|
+
// DO NOT EDIT
|
|
6
|
+
|
|
7
|
+
import {ProtobufRuntime} from "./ProtobufRuntime.sol";
|
|
8
|
+
|
|
9
|
+
struct Endpoints {
|
|
10
|
+
ChainId start;
|
|
11
|
+
ChainId end;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
struct MessageHeader {
|
|
15
|
+
Endpoints endpoints;
|
|
16
|
+
bytes messageId;
|
|
17
|
+
bytes previousMessageId;
|
|
18
|
+
EncodingFlags encodingFlags;
|
|
19
|
+
uint32 payloadSize;
|
|
20
|
+
bytes payloadChecksum;
|
|
21
|
+
uint64 timestamp;
|
|
22
|
+
bytes headerChecksum;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
struct MessagePayload {
|
|
26
|
+
uint32 version;
|
|
27
|
+
AttestationEntry[] attestations;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
struct AttestationEntry {
|
|
31
|
+
uint64 type;
|
|
32
|
+
uint32 dataSize;
|
|
33
|
+
bytes data;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
struct Message {
|
|
37
|
+
MessageHeader header;
|
|
38
|
+
MessagePayload payload;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
struct Envelope {
|
|
42
|
+
bytes envelopeHash;
|
|
43
|
+
Endpoints endpoints;
|
|
44
|
+
uint64 epochTimestamp;
|
|
45
|
+
uint32 epochIndex;
|
|
46
|
+
uint32 epochEnvelopeIndex;
|
|
47
|
+
bytes merkle;
|
|
48
|
+
bytes previousEnvelopeHash;
|
|
49
|
+
bytes startMessageId;
|
|
50
|
+
bytes endMessageId;
|
|
51
|
+
ChainSignature[] signatures;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
library EndpointsCodec {
|
|
55
|
+
|
|
56
|
+
function encode(Endpoints memory msg) internal pure returns (bytes memory) {
|
|
57
|
+
bytes memory buf = "";
|
|
58
|
+
|
|
59
|
+
// field 1: start
|
|
60
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0xa));
|
|
61
|
+
bytes memory start_encoded = ChainIdCodec.encode(msg.start);
|
|
62
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(start_encoded.length)));
|
|
63
|
+
buf = abi.encodePacked(buf, start_encoded);
|
|
64
|
+
|
|
65
|
+
// field 2: end
|
|
66
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
67
|
+
bytes memory end_encoded = ChainIdCodec.encode(msg.end);
|
|
68
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(end_encoded.length)));
|
|
69
|
+
buf = abi.encodePacked(buf, end_encoded);
|
|
70
|
+
|
|
71
|
+
return buf;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function decode(bytes memory data) internal pure returns (Endpoints memory msg) {
|
|
75
|
+
uint256 pos = 0;
|
|
76
|
+
uint256 end = data.length;
|
|
77
|
+
|
|
78
|
+
while (pos < end) {
|
|
79
|
+
uint64 tag;
|
|
80
|
+
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
81
|
+
|
|
82
|
+
// solhint-disable-next-line no-empty-blocks
|
|
83
|
+
switch (tag) {
|
|
84
|
+
case 10:
|
|
85
|
+
{
|
|
86
|
+
uint64 _len;
|
|
87
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
88
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
89
|
+
msg.start = ChainIdCodec.decode(_sub);
|
|
90
|
+
pos += uint256(_len);
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
case 18:
|
|
94
|
+
{
|
|
95
|
+
uint64 _len;
|
|
96
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
97
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
98
|
+
msg.end = ChainIdCodec.decode(_sub);
|
|
99
|
+
pos += uint256(_len);
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
library MessageHeaderCodec {
|
|
111
|
+
|
|
112
|
+
function encode(MessageHeader memory msg) internal pure returns (bytes memory) {
|
|
113
|
+
bytes memory buf = "";
|
|
114
|
+
|
|
115
|
+
// field 1: endpoints
|
|
116
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0xa));
|
|
117
|
+
bytes memory endpoints_encoded = EndpointsCodec.encode(msg.endpoints);
|
|
118
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(endpoints_encoded.length)));
|
|
119
|
+
buf = abi.encodePacked(buf, endpoints_encoded);
|
|
120
|
+
|
|
121
|
+
// field 2: message_id
|
|
122
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
123
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_bytes(msg.messageId));
|
|
124
|
+
|
|
125
|
+
// field 3: previous_message_id
|
|
126
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x1a));
|
|
127
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_bytes(msg.previousMessageId));
|
|
128
|
+
|
|
129
|
+
// field 4: encoding_flags
|
|
130
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x22));
|
|
131
|
+
bytes memory encodingFlags_encoded = EncodingFlagsCodec.encode(msg.encodingFlags);
|
|
132
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(encodingFlags_encoded.length)));
|
|
133
|
+
buf = abi.encodePacked(buf, encodingFlags_encoded);
|
|
134
|
+
|
|
135
|
+
// field 5: payload_size
|
|
136
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x28));
|
|
137
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(msg.payloadSize));
|
|
138
|
+
|
|
139
|
+
// field 6: payload_checksum
|
|
140
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x32));
|
|
141
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_bytes(msg.payloadChecksum));
|
|
142
|
+
|
|
143
|
+
// field 7: timestamp
|
|
144
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x38));
|
|
145
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(msg.timestamp));
|
|
146
|
+
|
|
147
|
+
// field 8: header_checksum
|
|
148
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x42));
|
|
149
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_bytes(msg.headerChecksum));
|
|
150
|
+
|
|
151
|
+
return buf;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function decode(bytes memory data) internal pure returns (MessageHeader memory msg) {
|
|
155
|
+
uint256 pos = 0;
|
|
156
|
+
uint256 end = data.length;
|
|
157
|
+
|
|
158
|
+
while (pos < end) {
|
|
159
|
+
uint64 tag;
|
|
160
|
+
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
161
|
+
|
|
162
|
+
// solhint-disable-next-line no-empty-blocks
|
|
163
|
+
switch (tag) {
|
|
164
|
+
case 10:
|
|
165
|
+
{
|
|
166
|
+
uint64 _len;
|
|
167
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
168
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
169
|
+
msg.endpoints = EndpointsCodec.decode(_sub);
|
|
170
|
+
pos += uint256(_len);
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
case 18:
|
|
174
|
+
(msg.messageId, pos) = ProtobufRuntime._decode_bytes(data, pos);
|
|
175
|
+
break;
|
|
176
|
+
case 26:
|
|
177
|
+
(msg.previousMessageId, pos) = ProtobufRuntime._decode_bytes(data, pos);
|
|
178
|
+
break;
|
|
179
|
+
case 34:
|
|
180
|
+
{
|
|
181
|
+
uint64 _len;
|
|
182
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
183
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
184
|
+
msg.encodingFlags = EncodingFlagsCodec.decode(_sub);
|
|
185
|
+
pos += uint256(_len);
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
case 40:
|
|
189
|
+
(msg.payloadSize, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
190
|
+
break;
|
|
191
|
+
case 50:
|
|
192
|
+
(msg.payloadChecksum, pos) = ProtobufRuntime._decode_bytes(data, pos);
|
|
193
|
+
break;
|
|
194
|
+
case 56:
|
|
195
|
+
(msg.timestamp, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
196
|
+
break;
|
|
197
|
+
case 66:
|
|
198
|
+
(msg.headerChecksum, pos) = ProtobufRuntime._decode_bytes(data, pos);
|
|
199
|
+
break;
|
|
200
|
+
default:
|
|
201
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
library MessagePayloadCodec {
|
|
209
|
+
|
|
210
|
+
function encode(MessagePayload memory msg) internal pure returns (bytes memory) {
|
|
211
|
+
bytes memory buf = "";
|
|
212
|
+
|
|
213
|
+
// field 1: version
|
|
214
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x8));
|
|
215
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(msg.version));
|
|
216
|
+
|
|
217
|
+
// field 2: attestations
|
|
218
|
+
for (uint256 _i_attestations = 0; _i_attestations < msg.attestations.length; _i_attestations++) {
|
|
219
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
220
|
+
bytes memory _elem = AttestationEntryCodec.encode(msg.attestations[_i_attestations]);
|
|
221
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(_elem.length)));
|
|
222
|
+
buf = abi.encodePacked(buf, _elem);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return buf;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function decode(bytes memory data) internal pure returns (MessagePayload memory msg) {
|
|
229
|
+
uint256 pos = 0;
|
|
230
|
+
uint256 end = data.length;
|
|
231
|
+
|
|
232
|
+
while (pos < end) {
|
|
233
|
+
uint64 tag;
|
|
234
|
+
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
235
|
+
|
|
236
|
+
// solhint-disable-next-line no-empty-blocks
|
|
237
|
+
switch (tag) {
|
|
238
|
+
case 8:
|
|
239
|
+
(msg.version, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
240
|
+
break;
|
|
241
|
+
case 18:
|
|
242
|
+
{
|
|
243
|
+
uint64 _len;
|
|
244
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
245
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
246
|
+
msg.attestations.push(AttestationEntryCodec.decode(_sub));
|
|
247
|
+
pos += uint256(_len);
|
|
248
|
+
}
|
|
249
|
+
break;
|
|
250
|
+
default:
|
|
251
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
library AttestationEntryCodec {
|
|
259
|
+
|
|
260
|
+
function encode(AttestationEntry memory msg) internal pure returns (bytes memory) {
|
|
261
|
+
bytes memory buf = "";
|
|
262
|
+
|
|
263
|
+
// field 1: type
|
|
264
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x8));
|
|
265
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(msg.type));
|
|
266
|
+
|
|
267
|
+
// field 2: data_size
|
|
268
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x10));
|
|
269
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(msg.dataSize));
|
|
270
|
+
|
|
271
|
+
// field 3: data
|
|
272
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x1a));
|
|
273
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_bytes(msg.data));
|
|
274
|
+
|
|
275
|
+
return buf;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function decode(bytes memory data) internal pure returns (AttestationEntry memory msg) {
|
|
279
|
+
uint256 pos = 0;
|
|
280
|
+
uint256 end = data.length;
|
|
281
|
+
|
|
282
|
+
while (pos < end) {
|
|
283
|
+
uint64 tag;
|
|
284
|
+
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
285
|
+
|
|
286
|
+
// solhint-disable-next-line no-empty-blocks
|
|
287
|
+
switch (tag) {
|
|
288
|
+
case 8:
|
|
289
|
+
(msg.type, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
290
|
+
break;
|
|
291
|
+
case 16:
|
|
292
|
+
(msg.dataSize, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
293
|
+
break;
|
|
294
|
+
case 26:
|
|
295
|
+
(msg.data, pos) = ProtobufRuntime._decode_bytes(data, pos);
|
|
296
|
+
break;
|
|
297
|
+
default:
|
|
298
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
library MessageCodec {
|
|
306
|
+
|
|
307
|
+
function encode(Message memory msg) internal pure returns (bytes memory) {
|
|
308
|
+
bytes memory buf = "";
|
|
309
|
+
|
|
310
|
+
// field 1: header
|
|
311
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0xa));
|
|
312
|
+
bytes memory header_encoded = MessageHeaderCodec.encode(msg.header);
|
|
313
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(header_encoded.length)));
|
|
314
|
+
buf = abi.encodePacked(buf, header_encoded);
|
|
315
|
+
|
|
316
|
+
// field 2: payload
|
|
317
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
318
|
+
bytes memory payload_encoded = MessagePayloadCodec.encode(msg.payload);
|
|
319
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(payload_encoded.length)));
|
|
320
|
+
buf = abi.encodePacked(buf, payload_encoded);
|
|
321
|
+
|
|
322
|
+
return buf;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function decode(bytes memory data) internal pure returns (Message memory msg) {
|
|
326
|
+
uint256 pos = 0;
|
|
327
|
+
uint256 end = data.length;
|
|
328
|
+
|
|
329
|
+
while (pos < end) {
|
|
330
|
+
uint64 tag;
|
|
331
|
+
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
332
|
+
|
|
333
|
+
// solhint-disable-next-line no-empty-blocks
|
|
334
|
+
switch (tag) {
|
|
335
|
+
case 10:
|
|
336
|
+
{
|
|
337
|
+
uint64 _len;
|
|
338
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
339
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
340
|
+
msg.header = MessageHeaderCodec.decode(_sub);
|
|
341
|
+
pos += uint256(_len);
|
|
342
|
+
}
|
|
343
|
+
break;
|
|
344
|
+
case 18:
|
|
345
|
+
{
|
|
346
|
+
uint64 _len;
|
|
347
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
348
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
349
|
+
msg.payload = MessagePayloadCodec.decode(_sub);
|
|
350
|
+
pos += uint256(_len);
|
|
351
|
+
}
|
|
352
|
+
break;
|
|
353
|
+
default:
|
|
354
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
library EnvelopeCodec {
|
|
362
|
+
|
|
363
|
+
function encode(Envelope memory msg) internal pure returns (bytes memory) {
|
|
364
|
+
bytes memory buf = "";
|
|
365
|
+
|
|
366
|
+
// field 1: envelope_hash
|
|
367
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0xa));
|
|
368
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_bytes(msg.envelopeHash));
|
|
369
|
+
|
|
370
|
+
// field 2: endpoints
|
|
371
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
372
|
+
bytes memory endpoints_encoded = EndpointsCodec.encode(msg.endpoints);
|
|
373
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(endpoints_encoded.length)));
|
|
374
|
+
buf = abi.encodePacked(buf, endpoints_encoded);
|
|
375
|
+
|
|
376
|
+
// field 5: epoch_timestamp
|
|
377
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x28));
|
|
378
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(msg.epochTimestamp));
|
|
379
|
+
|
|
380
|
+
// field 6: epoch_index
|
|
381
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x30));
|
|
382
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(msg.epochIndex));
|
|
383
|
+
|
|
384
|
+
// field 7: epoch_envelope_index
|
|
385
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x38));
|
|
386
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(msg.epochEnvelopeIndex));
|
|
387
|
+
|
|
388
|
+
// field 15: merkle
|
|
389
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x7a));
|
|
390
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_bytes(msg.merkle));
|
|
391
|
+
|
|
392
|
+
// field 20: previous_envelope_hash
|
|
393
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0xa2));
|
|
394
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_bytes(msg.previousEnvelopeHash));
|
|
395
|
+
|
|
396
|
+
// field 30: start_message_id
|
|
397
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0xf2));
|
|
398
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_bytes(msg.startMessageId));
|
|
399
|
+
|
|
400
|
+
// field 31: end_message_id
|
|
401
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0xfa));
|
|
402
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_bytes(msg.endMessageId));
|
|
403
|
+
|
|
404
|
+
// field 50: signatures
|
|
405
|
+
for (uint256 _i_signatures = 0; _i_signatures < msg.signatures.length; _i_signatures++) {
|
|
406
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x192));
|
|
407
|
+
bytes memory _elem = ChainSignatureCodec.encode(msg.signatures[_i_signatures]);
|
|
408
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(_elem.length)));
|
|
409
|
+
buf = abi.encodePacked(buf, _elem);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return buf;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function decode(bytes memory data) internal pure returns (Envelope memory msg) {
|
|
416
|
+
uint256 pos = 0;
|
|
417
|
+
uint256 end = data.length;
|
|
418
|
+
|
|
419
|
+
while (pos < end) {
|
|
420
|
+
uint64 tag;
|
|
421
|
+
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
422
|
+
|
|
423
|
+
// solhint-disable-next-line no-empty-blocks
|
|
424
|
+
switch (tag) {
|
|
425
|
+
case 10:
|
|
426
|
+
(msg.envelopeHash, pos) = ProtobufRuntime._decode_bytes(data, pos);
|
|
427
|
+
break;
|
|
428
|
+
case 18:
|
|
429
|
+
{
|
|
430
|
+
uint64 _len;
|
|
431
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
432
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
433
|
+
msg.endpoints = EndpointsCodec.decode(_sub);
|
|
434
|
+
pos += uint256(_len);
|
|
435
|
+
}
|
|
436
|
+
break;
|
|
437
|
+
case 40:
|
|
438
|
+
(msg.epochTimestamp, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
439
|
+
break;
|
|
440
|
+
case 48:
|
|
441
|
+
(msg.epochIndex, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
442
|
+
break;
|
|
443
|
+
case 56:
|
|
444
|
+
(msg.epochEnvelopeIndex, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
445
|
+
break;
|
|
446
|
+
case 122:
|
|
447
|
+
(msg.merkle, pos) = ProtobufRuntime._decode_bytes(data, pos);
|
|
448
|
+
break;
|
|
449
|
+
case 162:
|
|
450
|
+
(msg.previousEnvelopeHash, pos) = ProtobufRuntime._decode_bytes(data, pos);
|
|
451
|
+
break;
|
|
452
|
+
case 242:
|
|
453
|
+
(msg.startMessageId, pos) = ProtobufRuntime._decode_bytes(data, pos);
|
|
454
|
+
break;
|
|
455
|
+
case 250:
|
|
456
|
+
(msg.endMessageId, pos) = ProtobufRuntime._decode_bytes(data, pos);
|
|
457
|
+
break;
|
|
458
|
+
case 402:
|
|
459
|
+
{
|
|
460
|
+
uint64 _len;
|
|
461
|
+
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
462
|
+
bytes memory _sub = ProtobufRuntime._slice(data, pos, pos + uint256(_len));
|
|
463
|
+
msg.signatures.push(ChainSignatureCodec.decode(_sub));
|
|
464
|
+
pos += uint256(_len);
|
|
465
|
+
}
|
|
466
|
+
break;
|
|
467
|
+
default:
|
|
468
|
+
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|