@wireio/opp-solidity-models 1.0.9 → 1.0.11
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.
|
@@ -5,7 +5,7 @@ pragma solidity >=0.8.0 <0.9.0;
|
|
|
5
5
|
// DO NOT EDIT
|
|
6
6
|
|
|
7
7
|
import {ProtobufRuntime} from "../../ProtobufRuntime.sol";
|
|
8
|
-
import {ChainId, ChainIdCodec, ChainSignature, ChainSignatureCodec, EncodingFlags, EncodingFlagsCodec} from "./types/Types.sol";
|
|
8
|
+
import {AttestationType, AttestationTypeLib, ChainId, ChainIdCodec, ChainSignature, ChainSignatureCodec, EncodingFlags, EncodingFlagsCodec} from "./types/Types.sol";
|
|
9
9
|
|
|
10
10
|
struct Endpoints {
|
|
11
11
|
ChainId start;
|
|
@@ -29,7 +29,7 @@ struct MessagePayload {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
struct AttestationEntry {
|
|
32
|
-
|
|
32
|
+
AttestationType type_;
|
|
33
33
|
uint32 dataSize;
|
|
34
34
|
bytes data;
|
|
35
35
|
}
|
|
@@ -249,7 +249,7 @@ library AttestationEntryCodec {
|
|
|
249
249
|
|
|
250
250
|
// field 1: type
|
|
251
251
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x8));
|
|
252
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(attestationEntry.type_));
|
|
252
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(AttestationType.unwrap(attestationEntry.type_))));
|
|
253
253
|
|
|
254
254
|
// field 2: data_size
|
|
255
255
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x10));
|
|
@@ -271,7 +271,9 @@ library AttestationEntryCodec {
|
|
|
271
271
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
272
272
|
|
|
273
273
|
if (tag == 8) {
|
|
274
|
-
|
|
274
|
+
{ uint64 _v;
|
|
275
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
276
|
+
attestationEntry.type_ = AttestationType.wrap(uint16(_v)); }
|
|
275
277
|
} else if (tag == 16) {
|
|
276
278
|
{ uint64 _v;
|
|
277
279
|
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
@@ -5,11 +5,25 @@ pragma solidity >=0.8.0 <0.9.0;
|
|
|
5
5
|
// DO NOT EDIT
|
|
6
6
|
|
|
7
7
|
import {ProtobufRuntime} from "../../../ProtobufRuntime.sol";
|
|
8
|
-
import {ChainAddress, ChainAddressCodec, ChainId, ChainIdCodec, ChainSignature, ChainSignatureCodec, TokenAmount, TokenAmountCodec} from "../types/Types.sol";
|
|
8
|
+
import {ChainAddress, ChainAddressCodec, ChainId, ChainIdCodec, ChainKind, ChainKindLib, ChainSignature, ChainSignatureCodec, OperatorStatus, OperatorStatusLib, OperatorType, OperatorTypeLib, StakeStatus, StakeStatusLib, TokenAmount, TokenAmountCodec} from "../types/Types.sol";
|
|
9
9
|
import {Message, MessageCodec} from "../Opp.sol";
|
|
10
10
|
|
|
11
|
+
type ActionType is uint8;
|
|
12
|
+
|
|
13
|
+
using {ActionTypeLib.isValid} for ActionType global;
|
|
14
|
+
|
|
15
|
+
library ActionTypeLib {
|
|
16
|
+
ActionType constant ACTION_TYPE_UNKNOWN = ActionType.wrap(0);
|
|
17
|
+
ActionType constant ACTION_TYPE_DEPOSIT = ActionType.wrap(1);
|
|
18
|
+
ActionType constant ACTION_TYPE_WITHDRAW = ActionType.wrap(2);
|
|
19
|
+
|
|
20
|
+
function isValid(ActionType _v) internal pure returns (bool) {
|
|
21
|
+
return ActionType.unwrap(_v) <= ActionType.unwrap(ACTION_TYPE_WITHDRAW);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
11
25
|
struct ChainReserveBalanceSheet {
|
|
12
|
-
|
|
26
|
+
ChainKind kind;
|
|
13
27
|
TokenAmount[] amounts;
|
|
14
28
|
}
|
|
15
29
|
|
|
@@ -35,7 +49,7 @@ struct PretokenYield {
|
|
|
35
49
|
|
|
36
50
|
struct StakeUpdate {
|
|
37
51
|
ChainAddress actor;
|
|
38
|
-
|
|
52
|
+
StakeStatus status;
|
|
39
53
|
TokenAmount amount;
|
|
40
54
|
}
|
|
41
55
|
|
|
@@ -45,10 +59,10 @@ struct WireTokenPurchase {
|
|
|
45
59
|
}
|
|
46
60
|
|
|
47
61
|
struct OperatorAction {
|
|
48
|
-
|
|
62
|
+
ActionType actionType;
|
|
49
63
|
ChainAddress actor;
|
|
50
|
-
|
|
51
|
-
|
|
64
|
+
OperatorType type_;
|
|
65
|
+
OperatorStatus status;
|
|
52
66
|
TokenAmount amount;
|
|
53
67
|
}
|
|
54
68
|
|
|
@@ -73,7 +87,7 @@ library ChainReserveBalanceSheetCodec {
|
|
|
73
87
|
|
|
74
88
|
// field 1: kind
|
|
75
89
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x8));
|
|
76
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(chainReserveBalanceSheet.kind));
|
|
90
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(ChainKind.unwrap(chainReserveBalanceSheet.kind))));
|
|
77
91
|
|
|
78
92
|
// field 2: amounts
|
|
79
93
|
for (uint256 _i_amounts = 0; _i_amounts < chainReserveBalanceSheet.amounts.length; _i_amounts++) {
|
|
@@ -108,7 +122,9 @@ library ChainReserveBalanceSheetCodec {
|
|
|
108
122
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
109
123
|
|
|
110
124
|
if (tag == 8) {
|
|
111
|
-
|
|
125
|
+
{ uint64 _v;
|
|
126
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
127
|
+
chainReserveBalanceSheet.kind = ChainKind.wrap(uint8(_v)); }
|
|
112
128
|
} else if (tag == 18) {
|
|
113
129
|
uint64 _len;
|
|
114
130
|
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
@@ -316,7 +332,7 @@ library StakeUpdateCodec {
|
|
|
316
332
|
|
|
317
333
|
// field 2: status
|
|
318
334
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x10));
|
|
319
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(stakeUpdate.status));
|
|
335
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(StakeStatus.unwrap(stakeUpdate.status))));
|
|
320
336
|
|
|
321
337
|
// field 3: amount
|
|
322
338
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x1a));
|
|
@@ -342,7 +358,9 @@ library StakeUpdateCodec {
|
|
|
342
358
|
stakeUpdate.actor = ChainAddressCodec.decode(_sub);
|
|
343
359
|
pos += uint256(_len);
|
|
344
360
|
} else if (tag == 16) {
|
|
345
|
-
|
|
361
|
+
{ uint64 _v;
|
|
362
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
363
|
+
stakeUpdate.status = StakeStatus.wrap(uint8(_v)); }
|
|
346
364
|
} else if (tag == 26) {
|
|
347
365
|
uint64 _len;
|
|
348
366
|
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
@@ -425,7 +443,7 @@ library OperatorActionCodec {
|
|
|
425
443
|
|
|
426
444
|
// field 1: action_type
|
|
427
445
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x8));
|
|
428
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(operatorAction.actionType));
|
|
446
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(ActionType.unwrap(operatorAction.actionType))));
|
|
429
447
|
|
|
430
448
|
// field 2: actor
|
|
431
449
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
@@ -435,11 +453,11 @@ library OperatorActionCodec {
|
|
|
435
453
|
|
|
436
454
|
// field 3: type
|
|
437
455
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x18));
|
|
438
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(operatorAction.type_));
|
|
456
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(OperatorType.unwrap(operatorAction.type_))));
|
|
439
457
|
|
|
440
458
|
// field 4: status
|
|
441
459
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x20));
|
|
442
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(operatorAction.status));
|
|
460
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(OperatorStatus.unwrap(operatorAction.status))));
|
|
443
461
|
|
|
444
462
|
// field 10: amount
|
|
445
463
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x52));
|
|
@@ -459,7 +477,9 @@ library OperatorActionCodec {
|
|
|
459
477
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
460
478
|
|
|
461
479
|
if (tag == 8) {
|
|
462
|
-
|
|
480
|
+
{ uint64 _v;
|
|
481
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
482
|
+
operatorAction.actionType = ActionType.wrap(uint8(_v)); }
|
|
463
483
|
} else if (tag == 18) {
|
|
464
484
|
uint64 _len;
|
|
465
485
|
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
@@ -467,9 +487,13 @@ library OperatorActionCodec {
|
|
|
467
487
|
operatorAction.actor = ChainAddressCodec.decode(_sub);
|
|
468
488
|
pos += uint256(_len);
|
|
469
489
|
} else if (tag == 24) {
|
|
470
|
-
|
|
490
|
+
{ uint64 _v;
|
|
491
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
492
|
+
operatorAction.type_ = OperatorType.wrap(uint8(_v)); }
|
|
471
493
|
} else if (tag == 32) {
|
|
472
|
-
|
|
494
|
+
{ uint64 _v;
|
|
495
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
496
|
+
operatorAction.status = OperatorStatus.wrap(uint8(_v)); }
|
|
473
497
|
} else if (tag == 82) {
|
|
474
498
|
uint64 _len;
|
|
475
499
|
(_len, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
@@ -6,31 +6,195 @@ pragma solidity >=0.8.0 <0.9.0;
|
|
|
6
6
|
|
|
7
7
|
import {ProtobufRuntime} from "../../../ProtobufRuntime.sol";
|
|
8
8
|
|
|
9
|
+
type ChainKind is uint8;
|
|
10
|
+
|
|
11
|
+
using {ChainKindLib.isValid} for ChainKind global;
|
|
12
|
+
|
|
13
|
+
library ChainKindLib {
|
|
14
|
+
ChainKind constant CHAIN_KIND_UNKNOWN = ChainKind.wrap(0);
|
|
15
|
+
ChainKind constant CHAIN_KIND_WIRE = ChainKind.wrap(1);
|
|
16
|
+
ChainKind constant CHAIN_KIND_ETHEREUM = ChainKind.wrap(2);
|
|
17
|
+
ChainKind constant CHAIN_KIND_SOLANA = ChainKind.wrap(3);
|
|
18
|
+
ChainKind constant CHAIN_KIND_SUI = ChainKind.wrap(4);
|
|
19
|
+
|
|
20
|
+
function isValid(ChainKind _v) internal pure returns (bool) {
|
|
21
|
+
return ChainKind.unwrap(_v) <= ChainKind.unwrap(CHAIN_KIND_SUI);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type ChainKeyType is uint8;
|
|
26
|
+
|
|
27
|
+
using {ChainKeyTypeLib.isValid} for ChainKeyType global;
|
|
28
|
+
|
|
29
|
+
library ChainKeyTypeLib {
|
|
30
|
+
ChainKeyType constant CHAIN_KEY_TYPE_UNKNOWN = ChainKeyType.wrap(0);
|
|
31
|
+
ChainKeyType constant CHAIN_KEY_TYPE_WIRE = ChainKeyType.wrap(1);
|
|
32
|
+
ChainKeyType constant CHAIN_KEY_TYPE_WIRE_BLS = ChainKeyType.wrap(2);
|
|
33
|
+
ChainKeyType constant CHAIN_KEY_TYPE_ETHEREUM = ChainKeyType.wrap(3);
|
|
34
|
+
ChainKeyType constant CHAIN_KEY_TYPE_SOLANA = ChainKeyType.wrap(4);
|
|
35
|
+
ChainKeyType constant CHAIN_KEY_TYPE_SUI = ChainKeyType.wrap(5);
|
|
36
|
+
|
|
37
|
+
function isValid(ChainKeyType _v) internal pure returns (bool) {
|
|
38
|
+
return ChainKeyType.unwrap(_v) <= ChainKeyType.unwrap(CHAIN_KEY_TYPE_SUI);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type TokenKind is uint16;
|
|
43
|
+
|
|
44
|
+
using {TokenKindLib.isValid} for TokenKind global;
|
|
45
|
+
|
|
46
|
+
library TokenKindLib {
|
|
47
|
+
TokenKind constant TOKEN_KIND_WIRE = TokenKind.wrap(0);
|
|
48
|
+
TokenKind constant TOKEN_KIND_ETH = TokenKind.wrap(256);
|
|
49
|
+
TokenKind constant TOKEN_KIND_LIQETH = TokenKind.wrap(496);
|
|
50
|
+
TokenKind constant TOKEN_KIND_SOL = TokenKind.wrap(512);
|
|
51
|
+
TokenKind constant TOKEN_KIND_LIQSOL = TokenKind.wrap(752);
|
|
52
|
+
|
|
53
|
+
function isValid(TokenKind _v) internal pure returns (bool) {
|
|
54
|
+
return TokenKind.unwrap(_v) <= TokenKind.unwrap(TOKEN_KIND_LIQSOL);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type Endianness is uint8;
|
|
59
|
+
|
|
60
|
+
using {EndiannessLib.isValid} for Endianness global;
|
|
61
|
+
|
|
62
|
+
library EndiannessLib {
|
|
63
|
+
Endianness constant ENDIANNESS_BIG = Endianness.wrap(0);
|
|
64
|
+
Endianness constant ENDIANNESS_LITTLE = Endianness.wrap(1);
|
|
65
|
+
|
|
66
|
+
function isValid(Endianness _v) internal pure returns (bool) {
|
|
67
|
+
return Endianness.unwrap(_v) <= Endianness.unwrap(ENDIANNESS_LITTLE);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type HashAlgorithm is uint8;
|
|
72
|
+
|
|
73
|
+
using {HashAlgorithmLib.isValid} for HashAlgorithm global;
|
|
74
|
+
|
|
75
|
+
library HashAlgorithmLib {
|
|
76
|
+
HashAlgorithm constant HASH_ALGORITHM_KECCAK256 = HashAlgorithm.wrap(0);
|
|
77
|
+
HashAlgorithm constant HASH_ALGORITHM_SHA256 = HashAlgorithm.wrap(1);
|
|
78
|
+
HashAlgorithm constant HASH_ALGORITHM_RESERVED_1 = HashAlgorithm.wrap(2);
|
|
79
|
+
HashAlgorithm constant HASH_ALGORITHM_RESERVED_2 = HashAlgorithm.wrap(3);
|
|
80
|
+
|
|
81
|
+
function isValid(HashAlgorithm _v) internal pure returns (bool) {
|
|
82
|
+
return HashAlgorithm.unwrap(_v) <= HashAlgorithm.unwrap(HASH_ALGORITHM_RESERVED_2);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type LengthEncoding is uint8;
|
|
87
|
+
|
|
88
|
+
using {LengthEncodingLib.isValid} for LengthEncoding global;
|
|
89
|
+
|
|
90
|
+
library LengthEncodingLib {
|
|
91
|
+
LengthEncoding constant LENGTH_ENCODING_VARUINT = LengthEncoding.wrap(0);
|
|
92
|
+
LengthEncoding constant LENGTH_ENCODING_UINT32 = LengthEncoding.wrap(1);
|
|
93
|
+
|
|
94
|
+
function isValid(LengthEncoding _v) internal pure returns (bool) {
|
|
95
|
+
return LengthEncoding.unwrap(_v) <= LengthEncoding.unwrap(LENGTH_ENCODING_UINT32);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
type AttestationType is uint16;
|
|
100
|
+
|
|
101
|
+
using {AttestationTypeLib.isValid} for AttestationType global;
|
|
102
|
+
|
|
103
|
+
library AttestationTypeLib {
|
|
104
|
+
AttestationType constant ATTESTATION_TYPE_UNSPECIFIED = AttestationType.wrap(0);
|
|
105
|
+
AttestationType constant ATTESTATION_TYPE_OPERATOR_ACTION = AttestationType.wrap(2001);
|
|
106
|
+
AttestationType constant ATTESTATION_TYPE_STAKE = AttestationType.wrap(3001);
|
|
107
|
+
AttestationType constant ATTESTATION_TYPE_UNSTAKE = AttestationType.wrap(3002);
|
|
108
|
+
AttestationType constant ATTESTATION_TYPE_PRETOKEN_PURCHASE = AttestationType.wrap(3004);
|
|
109
|
+
AttestationType constant ATTESTATION_TYPE_PRETOKEN_YIELD = AttestationType.wrap(3006);
|
|
110
|
+
AttestationType constant ATTESTATION_TYPE_RESERVE_BALANCE_SHEET = AttestationType.wrap(43520);
|
|
111
|
+
AttestationType constant ATTESTATION_TYPE_STAKE_UPDATE = AttestationType.wrap(60928);
|
|
112
|
+
AttestationType constant ATTESTATION_TYPE_NATIVE_YIELD_REWARD = AttestationType.wrap(60929);
|
|
113
|
+
AttestationType constant ATTESTATION_TYPE_WIRE_TOKEN_PURCHASE = AttestationType.wrap(60930);
|
|
114
|
+
AttestationType constant ATTESTATION_TYPE_OPERATOR_REG_DEREG = AttestationType.wrap(60931);
|
|
115
|
+
AttestationType constant ATTESTATION_TYPE_CHALLENGE_RESPONSE = AttestationType.wrap(60932);
|
|
116
|
+
AttestationType constant ATTESTATION_TYPE_SLASH_OPERATOR = AttestationType.wrap(60933);
|
|
117
|
+
|
|
118
|
+
function isValid(AttestationType _v) internal pure returns (bool) {
|
|
119
|
+
return AttestationType.unwrap(_v) <= AttestationType.unwrap(ATTESTATION_TYPE_SLASH_OPERATOR);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
type StakeStatus is uint8;
|
|
124
|
+
|
|
125
|
+
using {StakeStatusLib.isValid} for StakeStatus global;
|
|
126
|
+
|
|
127
|
+
library StakeStatusLib {
|
|
128
|
+
StakeStatus constant STAKE_STATUS_UNKNOWN = StakeStatus.wrap(0);
|
|
129
|
+
StakeStatus constant STAKE_STATUS_WARMUP = StakeStatus.wrap(1);
|
|
130
|
+
StakeStatus constant STAKE_STATUS_COOLDOWN = StakeStatus.wrap(2);
|
|
131
|
+
StakeStatus constant STAKE_STATUS_ACTIVE = StakeStatus.wrap(3);
|
|
132
|
+
StakeStatus constant STAKE_STATUS_TERMINATED = StakeStatus.wrap(240);
|
|
133
|
+
StakeStatus constant STAKE_STATUS_SLASHED = StakeStatus.wrap(241);
|
|
134
|
+
|
|
135
|
+
function isValid(StakeStatus _v) internal pure returns (bool) {
|
|
136
|
+
return StakeStatus.unwrap(_v) <= StakeStatus.unwrap(STAKE_STATUS_SLASHED);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
type OperatorType is uint8;
|
|
141
|
+
|
|
142
|
+
using {OperatorTypeLib.isValid} for OperatorType global;
|
|
143
|
+
|
|
144
|
+
library OperatorTypeLib {
|
|
145
|
+
OperatorType constant OPERATOR_TYPE_UNKNOWN = OperatorType.wrap(0);
|
|
146
|
+
OperatorType constant OPERATOR_TYPE_PRODUCER = OperatorType.wrap(1);
|
|
147
|
+
OperatorType constant OPERATOR_TYPE_BATCH = OperatorType.wrap(2);
|
|
148
|
+
OperatorType constant OPERATOR_TYPE_UNDERWRITER = OperatorType.wrap(3);
|
|
149
|
+
OperatorType constant OPERATOR_TYPE_CHALLENGER = OperatorType.wrap(4);
|
|
150
|
+
|
|
151
|
+
function isValid(OperatorType _v) internal pure returns (bool) {
|
|
152
|
+
return OperatorType.unwrap(_v) <= OperatorType.unwrap(OPERATOR_TYPE_CHALLENGER);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
type OperatorStatus is uint8;
|
|
157
|
+
|
|
158
|
+
using {OperatorStatusLib.isValid} for OperatorStatus global;
|
|
159
|
+
|
|
160
|
+
library OperatorStatusLib {
|
|
161
|
+
OperatorStatus constant OPERATOR_STATUS_UNKNOWN = OperatorStatus.wrap(0);
|
|
162
|
+
OperatorStatus constant OPERATOR_STATUS_WARMUP = OperatorStatus.wrap(1);
|
|
163
|
+
OperatorStatus constant OPERATOR_STATUS_COOLDOWN = OperatorStatus.wrap(2);
|
|
164
|
+
OperatorStatus constant OPERATOR_STATUS_ACTIVE = OperatorStatus.wrap(3);
|
|
165
|
+
OperatorStatus constant OPERATOR_STATUS_TERMINATED = OperatorStatus.wrap(240);
|
|
166
|
+
OperatorStatus constant OPERATOR_STATUS_SLASHED = OperatorStatus.wrap(241);
|
|
167
|
+
|
|
168
|
+
function isValid(OperatorStatus _v) internal pure returns (bool) {
|
|
169
|
+
return OperatorStatus.unwrap(_v) <= OperatorStatus.unwrap(OPERATOR_STATUS_SLASHED);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
9
173
|
struct ChainId {
|
|
10
|
-
|
|
174
|
+
ChainKind kind;
|
|
11
175
|
uint32 id;
|
|
12
176
|
}
|
|
13
177
|
|
|
14
178
|
struct ChainAddress {
|
|
15
|
-
|
|
179
|
+
ChainKind kind;
|
|
16
180
|
bytes address_;
|
|
17
181
|
}
|
|
18
182
|
|
|
19
183
|
struct ChainSignature {
|
|
20
184
|
ChainAddress actor;
|
|
21
|
-
|
|
185
|
+
ChainKeyType keyType;
|
|
22
186
|
bytes signature;
|
|
23
187
|
}
|
|
24
188
|
|
|
25
189
|
struct TokenAmount {
|
|
26
|
-
|
|
190
|
+
TokenKind kind;
|
|
27
191
|
int64 amount;
|
|
28
192
|
}
|
|
29
193
|
|
|
30
194
|
struct EncodingFlags {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
195
|
+
Endianness endianness;
|
|
196
|
+
HashAlgorithm hashAlgorithm;
|
|
197
|
+
LengthEncoding lengthEncoding;
|
|
34
198
|
}
|
|
35
199
|
|
|
36
200
|
library ChainIdCodec {
|
|
@@ -40,7 +204,7 @@ library ChainIdCodec {
|
|
|
40
204
|
|
|
41
205
|
// field 1: kind
|
|
42
206
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x8));
|
|
43
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(chainId.kind));
|
|
207
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(ChainKind.unwrap(chainId.kind))));
|
|
44
208
|
|
|
45
209
|
// field 2: id
|
|
46
210
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x10));
|
|
@@ -58,7 +222,9 @@ library ChainIdCodec {
|
|
|
58
222
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
59
223
|
|
|
60
224
|
if (tag == 8) {
|
|
61
|
-
|
|
225
|
+
{ uint64 _v;
|
|
226
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
227
|
+
chainId.kind = ChainKind.wrap(uint8(_v)); }
|
|
62
228
|
} else if (tag == 16) {
|
|
63
229
|
{ uint64 _v;
|
|
64
230
|
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
@@ -77,7 +243,7 @@ library ChainAddressCodec {
|
|
|
77
243
|
|
|
78
244
|
// field 1: kind
|
|
79
245
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x8));
|
|
80
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(chainAddress.kind));
|
|
246
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(ChainKind.unwrap(chainAddress.kind))));
|
|
81
247
|
|
|
82
248
|
// field 2: address
|
|
83
249
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x12));
|
|
@@ -95,7 +261,9 @@ library ChainAddressCodec {
|
|
|
95
261
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
96
262
|
|
|
97
263
|
if (tag == 8) {
|
|
98
|
-
|
|
264
|
+
{ uint64 _v;
|
|
265
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
266
|
+
chainAddress.kind = ChainKind.wrap(uint8(_v)); }
|
|
99
267
|
} else if (tag == 18) {
|
|
100
268
|
(chainAddress.address_, pos) = ProtobufRuntime._decode_bytes(data, pos);
|
|
101
269
|
} else {
|
|
@@ -118,7 +286,7 @@ library ChainSignatureCodec {
|
|
|
118
286
|
|
|
119
287
|
// field 2: key_type
|
|
120
288
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x10));
|
|
121
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(chainSignature.keyType));
|
|
289
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(ChainKeyType.unwrap(chainSignature.keyType))));
|
|
122
290
|
|
|
123
291
|
// field 3: signature
|
|
124
292
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x1a));
|
|
@@ -142,7 +310,9 @@ library ChainSignatureCodec {
|
|
|
142
310
|
chainSignature.actor = ChainAddressCodec.decode(_sub);
|
|
143
311
|
pos += uint256(_len);
|
|
144
312
|
} else if (tag == 16) {
|
|
145
|
-
|
|
313
|
+
{ uint64 _v;
|
|
314
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
315
|
+
chainSignature.keyType = ChainKeyType.wrap(uint8(_v)); }
|
|
146
316
|
} else if (tag == 26) {
|
|
147
317
|
(chainSignature.signature, pos) = ProtobufRuntime._decode_bytes(data, pos);
|
|
148
318
|
} else {
|
|
@@ -159,7 +329,7 @@ library TokenAmountCodec {
|
|
|
159
329
|
|
|
160
330
|
// field 1: kind
|
|
161
331
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x8));
|
|
162
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(tokenAmount.kind));
|
|
332
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(TokenKind.unwrap(tokenAmount.kind))));
|
|
163
333
|
|
|
164
334
|
// field 2: amount
|
|
165
335
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x10));
|
|
@@ -177,7 +347,9 @@ library TokenAmountCodec {
|
|
|
177
347
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
178
348
|
|
|
179
349
|
if (tag == 8) {
|
|
180
|
-
|
|
350
|
+
{ uint64 _v;
|
|
351
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
352
|
+
tokenAmount.kind = TokenKind.wrap(uint16(_v)); }
|
|
181
353
|
} else if (tag == 16) {
|
|
182
354
|
{ uint64 _v;
|
|
183
355
|
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
@@ -196,15 +368,15 @@ library EncodingFlagsCodec {
|
|
|
196
368
|
|
|
197
369
|
// field 1: endianness
|
|
198
370
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x8));
|
|
199
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(encodingFlags.endianness));
|
|
371
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(Endianness.unwrap(encodingFlags.endianness))));
|
|
200
372
|
|
|
201
373
|
// field 2: hash_algorithm
|
|
202
374
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x10));
|
|
203
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(encodingFlags.hashAlgorithm));
|
|
375
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(HashAlgorithm.unwrap(encodingFlags.hashAlgorithm))));
|
|
204
376
|
|
|
205
377
|
// field 3: length_encoding
|
|
206
378
|
buf = abi.encodePacked(buf, ProtobufRuntime._encode_key(0x18));
|
|
207
|
-
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(encodingFlags.lengthEncoding));
|
|
379
|
+
buf = abi.encodePacked(buf, ProtobufRuntime._encode_varint(uint64(LengthEncoding.unwrap(encodingFlags.lengthEncoding))));
|
|
208
380
|
|
|
209
381
|
return buf;
|
|
210
382
|
}
|
|
@@ -218,11 +390,17 @@ library EncodingFlagsCodec {
|
|
|
218
390
|
(tag, pos) = ProtobufRuntime._decode_key(data, pos);
|
|
219
391
|
|
|
220
392
|
if (tag == 8) {
|
|
221
|
-
|
|
393
|
+
{ uint64 _v;
|
|
394
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
395
|
+
encodingFlags.endianness = Endianness.wrap(uint8(_v)); }
|
|
222
396
|
} else if (tag == 16) {
|
|
223
|
-
|
|
397
|
+
{ uint64 _v;
|
|
398
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
399
|
+
encodingFlags.hashAlgorithm = HashAlgorithm.wrap(uint8(_v)); }
|
|
224
400
|
} else if (tag == 24) {
|
|
225
|
-
|
|
401
|
+
{ uint64 _v;
|
|
402
|
+
(_v, pos) = ProtobufRuntime._decode_varint(data, pos);
|
|
403
|
+
encodingFlags.lengthEncoding = LengthEncoding.wrap(uint8(_v)); }
|
|
226
404
|
} else {
|
|
227
405
|
pos = ProtobufRuntime._skip_field(data, pos, tag & 0x07);
|
|
228
406
|
}
|