@apibara/beaconchain 2.1.0-beta.22 → 2.1.0-beta.24
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/dist/index.cjs +429 -409
- package/dist/index.d.cts +488 -1146
- package/dist/index.d.mts +488 -1146
- package/dist/index.d.ts +488 -1146
- package/dist/index.mjs +425 -403
- package/package.json +2 -3
- package/src/block.ts +113 -106
- package/src/common.ts +162 -90
- package/src/filter.ts +69 -72
- package/src/common.test.ts +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apibara/beaconchain",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
"vitest": "^1.6.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@apibara/
|
|
39
|
-
"@apibara/protocol": "2.1.0-beta.22",
|
|
38
|
+
"@apibara/protocol": "2.1.0-beta.24",
|
|
40
39
|
"@effect/schema": "^0.67.15",
|
|
41
40
|
"effect": "^3.2.6",
|
|
42
41
|
"long": "^5.2.1",
|
package/src/block.ts
CHANGED
|
@@ -1,127 +1,134 @@
|
|
|
1
|
-
import { AccessListItem } from "@apibara/evm";
|
|
2
1
|
import { BytesFromUint8Array } from "@apibara/protocol";
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
ArrayCodec,
|
|
4
|
+
BigIntCodec,
|
|
5
|
+
BooleanCodec,
|
|
6
|
+
type Codec,
|
|
7
|
+
type CodecType,
|
|
8
|
+
DateCodec,
|
|
9
|
+
MessageCodec,
|
|
10
|
+
NumberCodec,
|
|
11
|
+
OptionalCodec,
|
|
12
|
+
RequiredCodec,
|
|
13
|
+
} from "@apibara/protocol/codec";
|
|
5
14
|
import { Address, B256, B384, U128, U256, ValidatorStatus } from "./common";
|
|
6
15
|
import * as proto from "./proto";
|
|
7
16
|
|
|
8
|
-
export const ExecutionPayload =
|
|
9
|
-
parentHash: B256,
|
|
10
|
-
feeRecipient: Address,
|
|
11
|
-
stateRoot: B256,
|
|
12
|
-
receiptsRoot: B256,
|
|
13
|
-
logsBloom: BytesFromUint8Array,
|
|
14
|
-
prevRandao: B256,
|
|
15
|
-
blockNumber:
|
|
16
|
-
timestamp:
|
|
17
|
+
export const ExecutionPayload = MessageCodec({
|
|
18
|
+
parentHash: RequiredCodec(B256),
|
|
19
|
+
feeRecipient: RequiredCodec(Address),
|
|
20
|
+
stateRoot: RequiredCodec(B256),
|
|
21
|
+
receiptsRoot: RequiredCodec(B256),
|
|
22
|
+
logsBloom: RequiredCodec(BytesFromUint8Array),
|
|
23
|
+
prevRandao: RequiredCodec(B256),
|
|
24
|
+
blockNumber: RequiredCodec(BigIntCodec),
|
|
25
|
+
timestamp: RequiredCodec(DateCodec),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export type ExecutionPayload = CodecType<typeof ExecutionPayload>;
|
|
29
|
+
|
|
30
|
+
export const BlockHeader = MessageCodec({
|
|
31
|
+
slot: RequiredCodec(BigIntCodec),
|
|
32
|
+
proposerIndex: RequiredCodec(NumberCodec),
|
|
33
|
+
parentRoot: RequiredCodec(B256),
|
|
34
|
+
stateRoot: RequiredCodec(B256),
|
|
35
|
+
randaoReveal: RequiredCodec(BytesFromUint8Array),
|
|
36
|
+
depositCount: RequiredCodec(BigIntCodec),
|
|
37
|
+
depositRoot: RequiredCodec(B256),
|
|
38
|
+
blockHash: RequiredCodec(B256),
|
|
39
|
+
graffiti: RequiredCodec(B256),
|
|
40
|
+
executionPayload: OptionalCodec(ExecutionPayload),
|
|
41
|
+
blobKzgCommitments: ArrayCodec(B384),
|
|
17
42
|
});
|
|
18
43
|
|
|
19
|
-
export type
|
|
20
|
-
|
|
21
|
-
export const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
44
|
+
export type BlockHeader = CodecType<typeof BlockHeader>;
|
|
45
|
+
|
|
46
|
+
export const Validator = MessageCodec({
|
|
47
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
48
|
+
validatorIndex: RequiredCodec(NumberCodec),
|
|
49
|
+
balance: RequiredCodec(BigIntCodec),
|
|
50
|
+
status: RequiredCodec(ValidatorStatus),
|
|
51
|
+
pubkey: RequiredCodec(B384),
|
|
52
|
+
withdrawalCredentials: RequiredCodec(B256),
|
|
53
|
+
effectiveBalance: RequiredCodec(BigIntCodec),
|
|
54
|
+
slashed: RequiredCodec(BooleanCodec),
|
|
55
|
+
activationEligibilityEpoch: RequiredCodec(BigIntCodec),
|
|
56
|
+
activationEpoch: RequiredCodec(BigIntCodec),
|
|
57
|
+
exitEpoch: RequiredCodec(BigIntCodec),
|
|
58
|
+
withdrawableEpoch: RequiredCodec(BigIntCodec),
|
|
33
59
|
});
|
|
34
60
|
|
|
35
|
-
export type
|
|
36
|
-
|
|
37
|
-
export const
|
|
38
|
-
filterIds:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
activationEpoch: Schema.BigIntFromSelf,
|
|
48
|
-
exitEpoch: Schema.BigIntFromSelf,
|
|
49
|
-
withdrawableEpoch: Schema.BigIntFromSelf,
|
|
61
|
+
export type Validator = CodecType<typeof Validator>;
|
|
62
|
+
|
|
63
|
+
export const Blob = MessageCodec({
|
|
64
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
65
|
+
blobIndex: RequiredCodec(NumberCodec),
|
|
66
|
+
blob: RequiredCodec(BytesFromUint8Array),
|
|
67
|
+
kzgCommitment: RequiredCodec(B384),
|
|
68
|
+
kzgProof: RequiredCodec(B384),
|
|
69
|
+
kzgCommitmentInclusionProof: ArrayCodec(B256),
|
|
70
|
+
blobHash: RequiredCodec(B256),
|
|
71
|
+
transactionIndex: RequiredCodec(NumberCodec),
|
|
72
|
+
transactionHash: RequiredCodec(B256),
|
|
50
73
|
});
|
|
51
74
|
|
|
52
|
-
export type
|
|
53
|
-
|
|
54
|
-
export const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
kzgProof: B384,
|
|
60
|
-
kzgCommitmentInclusionProof: Schema.Array(B256),
|
|
61
|
-
blobHash: B256,
|
|
62
|
-
transactionIndex: Schema.Number,
|
|
63
|
-
transactionHash: B256,
|
|
75
|
+
export type Blob = CodecType<typeof Blob>;
|
|
76
|
+
|
|
77
|
+
export const Signature = MessageCodec({
|
|
78
|
+
r: OptionalCodec(U256),
|
|
79
|
+
s: OptionalCodec(U256),
|
|
80
|
+
v: OptionalCodec(U256),
|
|
81
|
+
YParity: OptionalCodec(BooleanCodec),
|
|
64
82
|
});
|
|
65
83
|
|
|
66
|
-
export type
|
|
84
|
+
export type Signature = CodecType<typeof Signature>;
|
|
67
85
|
|
|
68
|
-
export const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
v: Schema.optional(U256),
|
|
72
|
-
YParity: Schema.optional(Schema.Boolean),
|
|
86
|
+
export const AccessListItem = MessageCodec({
|
|
87
|
+
address: RequiredCodec(Address),
|
|
88
|
+
storageKeys: ArrayCodec(B256),
|
|
73
89
|
});
|
|
74
90
|
|
|
75
|
-
export type
|
|
76
|
-
|
|
77
|
-
export const Transaction =
|
|
78
|
-
filterIds:
|
|
79
|
-
transactionHash: B256,
|
|
80
|
-
nonce:
|
|
81
|
-
transactionIndex:
|
|
82
|
-
from: Address,
|
|
83
|
-
to:
|
|
84
|
-
value: U256,
|
|
85
|
-
gasPrice:
|
|
86
|
-
gasLimit:
|
|
87
|
-
maxFeePerGas:
|
|
88
|
-
maxPriorityFeePerGas:
|
|
89
|
-
input:
|
|
90
|
-
signature:
|
|
91
|
-
chainId:
|
|
92
|
-
accessList:
|
|
93
|
-
transactionType:
|
|
94
|
-
maxFeePerBlobGas:
|
|
95
|
-
blobVersionedHashes:
|
|
91
|
+
export type AccessListItem = CodecType<typeof AccessListItem>;
|
|
92
|
+
|
|
93
|
+
export const Transaction = MessageCodec({
|
|
94
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
95
|
+
transactionHash: RequiredCodec(B256),
|
|
96
|
+
nonce: RequiredCodec(BigIntCodec),
|
|
97
|
+
transactionIndex: RequiredCodec(NumberCodec),
|
|
98
|
+
from: RequiredCodec(Address),
|
|
99
|
+
to: OptionalCodec(Address),
|
|
100
|
+
value: RequiredCodec(U256),
|
|
101
|
+
gasPrice: OptionalCodec(U128),
|
|
102
|
+
gasLimit: OptionalCodec(U128),
|
|
103
|
+
maxFeePerGas: OptionalCodec(U128),
|
|
104
|
+
maxPriorityFeePerGas: OptionalCodec(U128),
|
|
105
|
+
input: RequiredCodec(BytesFromUint8Array),
|
|
106
|
+
signature: OptionalCodec(Signature),
|
|
107
|
+
chainId: OptionalCodec(BigIntCodec),
|
|
108
|
+
accessList: ArrayCodec(AccessListItem),
|
|
109
|
+
transactionType: RequiredCodec(BigIntCodec),
|
|
110
|
+
maxFeePerBlobGas: OptionalCodec(U128),
|
|
111
|
+
blobVersionedHashes: ArrayCodec(B256),
|
|
96
112
|
});
|
|
97
113
|
|
|
98
|
-
export type Transaction = typeof Transaction
|
|
114
|
+
export type Transaction = CodecType<typeof Transaction>;
|
|
99
115
|
|
|
100
|
-
export const Block =
|
|
101
|
-
header: BlockHeader,
|
|
102
|
-
validators:
|
|
103
|
-
blobs:
|
|
104
|
-
transactions:
|
|
116
|
+
export const Block = MessageCodec({
|
|
117
|
+
header: RequiredCodec(BlockHeader),
|
|
118
|
+
validators: ArrayCodec(Validator),
|
|
119
|
+
blobs: ArrayCodec(Blob),
|
|
120
|
+
transactions: ArrayCodec(Transaction),
|
|
105
121
|
});
|
|
106
122
|
|
|
107
|
-
export type Block = typeof Block
|
|
108
|
-
|
|
109
|
-
export const BlockFromBytes =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
return proto.data.Block.decode(value);
|
|
119
|
-
},
|
|
120
|
-
encode(value) {
|
|
121
|
-
if (value === null) {
|
|
122
|
-
return new Uint8Array();
|
|
123
|
-
}
|
|
124
|
-
return proto.data.Block.encode(value).finish();
|
|
125
|
-
},
|
|
123
|
+
export type Block = CodecType<typeof Block>;
|
|
124
|
+
|
|
125
|
+
export const BlockFromBytes: Codec<Block, Uint8Array> = {
|
|
126
|
+
encode(x) {
|
|
127
|
+
const block = Block.encode(x);
|
|
128
|
+
return proto.data.Block.encode(block).finish();
|
|
129
|
+
},
|
|
130
|
+
decode(p) {
|
|
131
|
+
const block = proto.data.Block.decode(p);
|
|
132
|
+
return Block.decode(block);
|
|
126
133
|
},
|
|
127
|
-
|
|
134
|
+
};
|
package/src/common.ts
CHANGED
|
@@ -1,97 +1,169 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { hexToBytes, pad } from "viem";
|
|
3
|
-
|
|
1
|
+
import type { Codec, CodecType } from "@apibara/protocol/codec";
|
|
4
2
|
import * as proto from "./proto";
|
|
5
3
|
|
|
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
|
-
active_exiting: proto.common.ValidatorStatus.ACTIVE_EXITING,
|
|
49
|
-
active_slashed: proto.common.ValidatorStatus.ACTIVE_SLASHED,
|
|
50
|
-
exited_unslashed: proto.common.ValidatorStatus.EXITED_UNSLASHED,
|
|
51
|
-
exited_slashed: proto.common.ValidatorStatus.EXITED_SLASHED,
|
|
52
|
-
withdrawal_possible: proto.common.ValidatorStatus.WITHDRAWAL_POSSIBLE,
|
|
53
|
-
withdrawal_done: proto.common.ValidatorStatus.WITHDRAWAL_DONE,
|
|
54
|
-
unknown: proto.common.ValidatorStatus.UNKNOWN,
|
|
55
|
-
} as const;
|
|
56
|
-
|
|
57
|
-
return enumMap[value] ?? proto.common.ValidatorStatus.UNKNOWN;
|
|
58
|
-
},
|
|
4
|
+
const MAX_U64 = 0xffffffffffffffffn;
|
|
5
|
+
const MAX_U32 = 0xffffffffn;
|
|
6
|
+
|
|
7
|
+
/** An Ethereum address. */
|
|
8
|
+
export const Address: Codec<`0x${string}`, proto.common.Address> = {
|
|
9
|
+
encode(x) {
|
|
10
|
+
const bn = BigInt(x);
|
|
11
|
+
// Ethereum address is 20 bytes (160 bits)
|
|
12
|
+
// Splitting into two 64-bit chunks and one 32-bit chunk
|
|
13
|
+
const x2 = bn & MAX_U32;
|
|
14
|
+
const x1 = (bn >> 32n) & MAX_U64;
|
|
15
|
+
const x0 = (bn >> 96n) & MAX_U64;
|
|
16
|
+
return { x0, x1, x2: Number(x2) };
|
|
17
|
+
},
|
|
18
|
+
decode(p) {
|
|
19
|
+
const x0 = p.x0 ?? 0n;
|
|
20
|
+
const x1 = p.x1 ?? 0n;
|
|
21
|
+
const x2 = BigInt(p.x2 ?? 0);
|
|
22
|
+
const bn = x2 + (x1 << 32n) + (x0 << 96n);
|
|
23
|
+
return `0x${bn.toString(16).padStart(40, "0")}` as `0x${string}`;
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type Address = CodecType<typeof Address>;
|
|
28
|
+
|
|
29
|
+
/** Data with length 256 bits. */
|
|
30
|
+
export const B256: Codec<`0x${string}`, proto.common.B256> = {
|
|
31
|
+
encode(x) {
|
|
32
|
+
const bn = BigInt(x);
|
|
33
|
+
const x3 = bn & MAX_U64;
|
|
34
|
+
const x2 = (bn >> 64n) & MAX_U64;
|
|
35
|
+
const x1 = (bn >> 128n) & MAX_U64;
|
|
36
|
+
const x0 = (bn >> 192n) & MAX_U64;
|
|
37
|
+
return { x0, x1, x2, x3 };
|
|
38
|
+
},
|
|
39
|
+
decode(p) {
|
|
40
|
+
const x0 = p.x0 ?? 0n;
|
|
41
|
+
const x1 = p.x1 ?? 0n;
|
|
42
|
+
const x2 = p.x2 ?? 0n;
|
|
43
|
+
const x3 = p.x3 ?? 0n;
|
|
44
|
+
const bn = x3 + (x2 << 64n) + (x1 << 128n) + (x0 << 192n);
|
|
45
|
+
return `0x${bn.toString(16).padStart(64, "0")}` as `0x${string}`;
|
|
59
46
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
export type
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type B256 = CodecType<typeof B256>;
|
|
50
|
+
|
|
51
|
+
/** Data with length 256 bits. */
|
|
52
|
+
export const U256: Codec<bigint, proto.common.U256> = {
|
|
53
|
+
encode(x) {
|
|
54
|
+
const bn = BigInt(x);
|
|
55
|
+
const x3 = bn & MAX_U64;
|
|
56
|
+
const x2 = (bn >> 64n) & MAX_U64;
|
|
57
|
+
const x1 = (bn >> 128n) & MAX_U64;
|
|
58
|
+
const x0 = (bn >> 192n) & MAX_U64;
|
|
59
|
+
return { x0, x1, x2, x3 };
|
|
60
|
+
},
|
|
61
|
+
decode(p) {
|
|
62
|
+
const x0 = p.x0 ?? 0n;
|
|
63
|
+
const x1 = p.x1 ?? 0n;
|
|
64
|
+
const x2 = p.x2 ?? 0n;
|
|
65
|
+
const x3 = p.x3 ?? 0n;
|
|
66
|
+
return x3 + (x2 << 64n) + (x1 << 128n) + (x0 << 192n);
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type U256 = CodecType<typeof U256>;
|
|
71
|
+
|
|
72
|
+
/** Data with length 128 bits. */
|
|
73
|
+
export const U128: Codec<bigint, proto.common.U128> = {
|
|
74
|
+
encode(x) {
|
|
75
|
+
const x1 = x & MAX_U64;
|
|
76
|
+
const x0 = (x >> 64n) & MAX_U64;
|
|
77
|
+
return { x0, x1 };
|
|
83
78
|
},
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
79
|
+
decode(p) {
|
|
80
|
+
const x0 = p.x0 ?? 0n;
|
|
81
|
+
const x1 = p.x1 ?? 0n;
|
|
82
|
+
return x1 + (x0 << 64n);
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type U128 = CodecType<typeof U128>;
|
|
87
|
+
|
|
88
|
+
export const B384: Codec<`0x${string}`, proto.common.B384> = {
|
|
89
|
+
encode(x) {
|
|
90
|
+
const bn = BigInt(x);
|
|
91
|
+
const x5 = bn & MAX_U64;
|
|
92
|
+
const x4 = (bn >> 64n) & MAX_U64;
|
|
93
|
+
const x3 = (bn >> 128n) & MAX_U64;
|
|
94
|
+
const x2 = (bn >> 192n) & MAX_U64;
|
|
95
|
+
const x1 = (bn >> 256n) & MAX_U64;
|
|
96
|
+
const x0 = (bn >> 320n) & MAX_U64;
|
|
93
97
|
return { x0, x1, x2, x3, x4, x5 };
|
|
94
98
|
},
|
|
95
|
-
|
|
99
|
+
decode(p) {
|
|
100
|
+
const x0 = p.x0 ?? 0n;
|
|
101
|
+
const x1 = p.x1 ?? 0n;
|
|
102
|
+
const x2 = p.x2 ?? 0n;
|
|
103
|
+
const x3 = p.x3 ?? 0n;
|
|
104
|
+
const x4 = p.x4 ?? 0n;
|
|
105
|
+
const x5 = p.x5 ?? 0n;
|
|
106
|
+
const bn =
|
|
107
|
+
x5 +
|
|
108
|
+
(x4 << 64n) +
|
|
109
|
+
(x3 << 128n) +
|
|
110
|
+
(x2 << 192n) +
|
|
111
|
+
(x1 << 256n) +
|
|
112
|
+
(x0 << 320n);
|
|
113
|
+
|
|
114
|
+
return `0x${bn.toString(16).padStart(96, "0")}` as `0x${string}`;
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export type B384 = CodecType<typeof B384>;
|
|
119
|
+
|
|
120
|
+
export const ValidatorStatus: Codec<
|
|
121
|
+
| "pending_initialized"
|
|
122
|
+
| "pending_queued"
|
|
123
|
+
| "active_ongoing"
|
|
124
|
+
| "active_exiting"
|
|
125
|
+
| "active_slashed"
|
|
126
|
+
| "exited_unslashed"
|
|
127
|
+
| "exited_slashed"
|
|
128
|
+
| "withdrawal_possible"
|
|
129
|
+
| "withdrawal_done"
|
|
130
|
+
| "unknown",
|
|
131
|
+
proto.common.ValidatorStatus
|
|
132
|
+
> = {
|
|
133
|
+
encode(x) {
|
|
134
|
+
const enumMap = {
|
|
135
|
+
pending_initialized: proto.common.ValidatorStatus.PENDING_INITIALIZED,
|
|
136
|
+
pending_queued: proto.common.ValidatorStatus.PENDING_QUEUED,
|
|
137
|
+
active_ongoing: proto.common.ValidatorStatus.ACTIVE_ONGOING,
|
|
138
|
+
active_exiting: proto.common.ValidatorStatus.ACTIVE_EXITING,
|
|
139
|
+
active_slashed: proto.common.ValidatorStatus.ACTIVE_SLASHED,
|
|
140
|
+
exited_unslashed: proto.common.ValidatorStatus.EXITED_UNSLASHED,
|
|
141
|
+
exited_slashed: proto.common.ValidatorStatus.EXITED_SLASHED,
|
|
142
|
+
withdrawal_possible: proto.common.ValidatorStatus.WITHDRAWAL_POSSIBLE,
|
|
143
|
+
withdrawal_done: proto.common.ValidatorStatus.WITHDRAWAL_DONE,
|
|
144
|
+
unknown: proto.common.ValidatorStatus.UNKNOWN,
|
|
145
|
+
} as const;
|
|
146
|
+
|
|
147
|
+
return enumMap[x] ?? proto.common.ValidatorStatus.UNKNOWN;
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
decode(p) {
|
|
151
|
+
const enumMap = {
|
|
152
|
+
[proto.common.ValidatorStatus.PENDING_INITIALIZED]: "pending_initialized",
|
|
153
|
+
[proto.common.ValidatorStatus.PENDING_QUEUED]: "pending_queued",
|
|
154
|
+
[proto.common.ValidatorStatus.ACTIVE_ONGOING]: "active_ongoing",
|
|
155
|
+
[proto.common.ValidatorStatus.ACTIVE_EXITING]: "active_exiting",
|
|
156
|
+
[proto.common.ValidatorStatus.ACTIVE_SLASHED]: "active_slashed",
|
|
157
|
+
[proto.common.ValidatorStatus.EXITED_UNSLASHED]: "exited_unslashed",
|
|
158
|
+
[proto.common.ValidatorStatus.EXITED_SLASHED]: "exited_slashed",
|
|
159
|
+
[proto.common.ValidatorStatus.WITHDRAWAL_POSSIBLE]: "withdrawal_possible",
|
|
160
|
+
[proto.common.ValidatorStatus.WITHDRAWAL_DONE]: "withdrawal_done",
|
|
161
|
+
[proto.common.ValidatorStatus.UNKNOWN]: "unknown",
|
|
162
|
+
[proto.common.ValidatorStatus.UNRECOGNIZED]: "unknown",
|
|
163
|
+
} as const;
|
|
164
|
+
|
|
165
|
+
return enumMap[p] ?? "unknown";
|
|
166
|
+
},
|
|
167
|
+
};
|
|
96
168
|
|
|
97
|
-
export type
|
|
169
|
+
export type ValidatorStatus = CodecType<typeof ValidatorStatus>;
|