@lodestar/types 1.35.0-dev.fcf8d024ea → 1.35.0-dev.feed916580
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/lib/altair/sszTypes.d.ts +1 -1
- package/lib/bellatrix/sszTypes.d.ts +15 -15
- package/lib/capella/sszTypes.d.ts +41 -41
- package/lib/deneb/sszTypes.d.ts +44 -44
- package/lib/electra/sszTypes.d.ts +67 -67
- package/lib/fulu/sszTypes.d.ts +22 -22
- package/lib/gloas/sszTypes.d.ts +234 -535
- package/lib/gloas/sszTypes.js +3 -162
- package/lib/gloas/sszTypes.js.map +1 -1
- package/lib/gloas/types.d.ts +0 -13
- package/lib/sszTypes.d.ts +1446 -1664
- package/lib/types.d.ts +4 -3
- package/lib/types.js.map +1 -1
- package/package.json +8 -14
- package/lib/altair/index.d.ts.map +0 -1
- package/lib/altair/sszTypes.d.ts.map +0 -1
- package/lib/altair/types.d.ts.map +0 -1
- package/lib/bellatrix/index.d.ts.map +0 -1
- package/lib/bellatrix/sszTypes.d.ts.map +0 -1
- package/lib/bellatrix/types.d.ts.map +0 -1
- package/lib/capella/index.d.ts.map +0 -1
- package/lib/capella/sszTypes.d.ts.map +0 -1
- package/lib/capella/types.d.ts.map +0 -1
- package/lib/deneb/index.d.ts.map +0 -1
- package/lib/deneb/sszTypes.d.ts.map +0 -1
- package/lib/deneb/types.d.ts.map +0 -1
- package/lib/electra/index.d.ts.map +0 -1
- package/lib/electra/sszTypes.d.ts.map +0 -1
- package/lib/electra/types.d.ts.map +0 -1
- package/lib/fulu/index.d.ts.map +0 -1
- package/lib/fulu/sszTypes.d.ts.map +0 -1
- package/lib/fulu/types.d.ts.map +0 -1
- package/lib/gloas/index.d.ts.map +0 -1
- package/lib/gloas/sszTypes.d.ts.map +0 -1
- package/lib/gloas/types.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/phase0/index.d.ts.map +0 -1
- package/lib/phase0/sszTypes.d.ts.map +0 -1
- package/lib/phase0/types.d.ts.map +0 -1
- package/lib/phase0/validator.d.ts.map +0 -1
- package/lib/primitive/index.d.ts.map +0 -1
- package/lib/primitive/sszTypes.d.ts.map +0 -1
- package/lib/primitive/types.d.ts.map +0 -1
- package/lib/sszTypes.d.ts.map +0 -1
- package/lib/types.d.ts.map +0 -1
- package/lib/utils/container.d.ts.map +0 -1
- package/lib/utils/executionAddress.d.ts.map +0 -1
- package/lib/utils/stringType.d.ts.map +0 -1
- package/lib/utils/typeguards.d.ts.map +0 -1
- package/lib/utils/validatorStatus.d.ts.map +0 -1
- package/src/altair/index.ts +0 -5
- package/src/altair/sszTypes.ts +0 -243
- package/src/altair/types.ts +0 -24
- package/src/bellatrix/index.ts +0 -5
- package/src/bellatrix/sszTypes.ts +0 -238
- package/src/bellatrix/types.ts +0 -24
- package/src/capella/index.ts +0 -5
- package/src/capella/sszTypes.ts +0 -281
- package/src/capella/types.ts +0 -33
- package/src/deneb/index.ts +0 -5
- package/src/deneb/sszTypes.ts +0 -329
- package/src/deneb/types.ts +0 -55
- package/src/electra/index.ts +0 -5
- package/src/electra/sszTypes.ts +0 -451
- package/src/electra/types.ts +0 -54
- package/src/fulu/index.ts +0 -5
- package/src/fulu/sszTypes.ts +0 -138
- package/src/fulu/types.ts +0 -31
- package/src/gloas/index.ts +0 -5
- package/src/gloas/sszTypes.ts +0 -234
- package/src/gloas/types.ts +0 -20
- package/src/index.ts +0 -15
- package/src/phase0/index.ts +0 -6
- package/src/phase0/sszTypes.ts +0 -514
- package/src/phase0/types.ts +0 -46
- package/src/phase0/validator.ts +0 -78
- package/src/primitive/index.ts +0 -3
- package/src/primitive/sszTypes.ts +0 -70
- package/src/primitive/types.ts +0 -53
- package/src/sszTypes.ts +0 -86
- package/src/types.ts +0 -374
- package/src/utils/container.ts +0 -38
- package/src/utils/executionAddress.ts +0 -48
- package/src/utils/stringType.ts +0 -58
- package/src/utils/typeguards.ts +0 -98
- package/src/utils/validatorStatus.ts +0 -52
package/src/utils/stringType.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {BasicType} from "@chainsafe/ssz";
|
|
2
|
-
|
|
3
|
-
export class StringType<T extends string = string> extends BasicType<T> {
|
|
4
|
-
readonly typeName = "string";
|
|
5
|
-
byteLength = 0;
|
|
6
|
-
fixedSize = 0;
|
|
7
|
-
minSize = 0;
|
|
8
|
-
maxSize = 0;
|
|
9
|
-
|
|
10
|
-
defaultValue(): T {
|
|
11
|
-
return "" as T;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Serialization + deserialization
|
|
15
|
-
|
|
16
|
-
value_serializeToBytes(): number {
|
|
17
|
-
throw Error("Not supported in String type");
|
|
18
|
-
}
|
|
19
|
-
value_deserializeFromBytes(): T {
|
|
20
|
-
throw Error("Not supported in String type");
|
|
21
|
-
}
|
|
22
|
-
tree_serializeToBytes(): number {
|
|
23
|
-
throw Error("Not supported in String type");
|
|
24
|
-
}
|
|
25
|
-
tree_deserializeFromBytes(): never {
|
|
26
|
-
throw Error("Not supported in String type");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Fast tree opts
|
|
30
|
-
|
|
31
|
-
tree_getFromNode(): T {
|
|
32
|
-
throw Error("Not supported in String type");
|
|
33
|
-
}
|
|
34
|
-
tree_setToNode(): void {
|
|
35
|
-
throw Error("Not supported in String type");
|
|
36
|
-
}
|
|
37
|
-
tree_getFromPackedNode(): T {
|
|
38
|
-
throw Error("Not supported in String type");
|
|
39
|
-
}
|
|
40
|
-
tree_setToPackedNode(): void {
|
|
41
|
-
throw Error("Not supported in String type");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// JSON
|
|
45
|
-
|
|
46
|
-
fromJson(json: unknown): T {
|
|
47
|
-
if (typeof json !== "string") {
|
|
48
|
-
throw Error(`JSON invalid type ${typeof json} expected string`);
|
|
49
|
-
}
|
|
50
|
-
return json as T;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
toJson(value: T): unknown {
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const stringType = new StringType();
|
package/src/utils/typeguards.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import {FINALIZED_ROOT_DEPTH_ELECTRA, ForkPostBellatrix, ForkPostDeneb, ForkPostElectra} from "@lodestar/params";
|
|
2
|
-
import {
|
|
3
|
-
Attestation,
|
|
4
|
-
BeaconBlock,
|
|
5
|
-
BeaconBlockBody,
|
|
6
|
-
BlindedBeaconBlock,
|
|
7
|
-
BlindedBeaconBlockBody,
|
|
8
|
-
BlockContents,
|
|
9
|
-
ExecutionPayload,
|
|
10
|
-
ExecutionPayloadAndBlobsBundle,
|
|
11
|
-
ExecutionPayloadHeader,
|
|
12
|
-
LightClientFinalityUpdate,
|
|
13
|
-
LightClientUpdate,
|
|
14
|
-
SignedBeaconBlock,
|
|
15
|
-
SignedBlindedBeaconBlock,
|
|
16
|
-
SignedBlockContents,
|
|
17
|
-
SingleAttestation,
|
|
18
|
-
} from "../types.js";
|
|
19
|
-
|
|
20
|
-
export function isExecutionPayload<F extends ForkPostBellatrix>(
|
|
21
|
-
payload: ExecutionPayload<F> | ExecutionPayloadHeader<F>
|
|
22
|
-
): payload is ExecutionPayload<F> {
|
|
23
|
-
// we just check transactionsRoot for determining as it the base field
|
|
24
|
-
// that is present and differs from ExecutionPayload for all forks
|
|
25
|
-
return (payload as ExecutionPayload<F>).transactions !== undefined;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function isExecutionPayloadHeader<F extends ForkPostBellatrix>(
|
|
29
|
-
payload: ExecutionPayload<F> | ExecutionPayloadHeader<F>
|
|
30
|
-
): payload is ExecutionPayloadHeader<F> {
|
|
31
|
-
// we just check transactionsRoot for determining as it the base field
|
|
32
|
-
// that is present and differs from ExecutionPayload for all forks
|
|
33
|
-
return (payload as ExecutionPayloadHeader<F>).transactionsRoot !== undefined;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function isExecutionPayloadAndBlobsBundle<F extends ForkPostDeneb>(
|
|
37
|
-
data: ExecutionPayload<ForkPostBellatrix> | ExecutionPayloadAndBlobsBundle<F>
|
|
38
|
-
): data is ExecutionPayloadAndBlobsBundle<F> {
|
|
39
|
-
return (data as ExecutionPayloadAndBlobsBundle<ForkPostDeneb>).blobsBundle !== undefined;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function isBlindedBeaconBlock<F extends ForkPostBellatrix>(
|
|
43
|
-
block: BeaconBlock | BlockContents | SignedBeaconBlock | SignedBlockContents
|
|
44
|
-
): block is BlindedBeaconBlock<F> {
|
|
45
|
-
return (block as BeaconBlock).body !== null && isBlindedBeaconBlockBody((block as BeaconBlock).body);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function isBlindedSignedBeaconBlock<F extends ForkPostBellatrix>(
|
|
49
|
-
signedBlock: SignedBeaconBlock | SignedBlockContents
|
|
50
|
-
): signedBlock is SignedBlindedBeaconBlock<F> {
|
|
51
|
-
return (signedBlock as SignedBlindedBeaconBlock<F>).message.body.executionPayloadHeader !== undefined;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function isBlindedBeaconBlockBody<F extends ForkPostBellatrix>(
|
|
55
|
-
body: BeaconBlockBody | BlindedBeaconBlockBody
|
|
56
|
-
): body is BlindedBeaconBlockBody<F> {
|
|
57
|
-
return (body as BlindedBeaconBlockBody).executionPayloadHeader !== undefined;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function isDenebBlockContents(
|
|
61
|
-
data: BeaconBlock | BlockContents | SignedBeaconBlock | SignedBlockContents
|
|
62
|
-
): data is BlockContents<ForkPostDeneb> {
|
|
63
|
-
return (data as BlockContents<ForkPostDeneb>).kzgProofs !== undefined;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function isDenebSignedBlockContents(
|
|
67
|
-
data: BeaconBlock | BlockContents | SignedBeaconBlock | SignedBlockContents
|
|
68
|
-
): data is SignedBlockContents<ForkPostDeneb> {
|
|
69
|
-
return (data as SignedBlockContents<ForkPostDeneb>).kzgProofs !== undefined;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function isElectraAttestation(attestation: Attestation): attestation is Attestation<ForkPostElectra> {
|
|
73
|
-
return (attestation as Attestation<ForkPostElectra>).committeeBits !== undefined;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function isElectraSingleAttestation(
|
|
77
|
-
singleAttestation: SingleAttestation
|
|
78
|
-
): singleAttestation is SingleAttestation<ForkPostElectra> {
|
|
79
|
-
return (singleAttestation as SingleAttestation<ForkPostElectra>).committeeIndex !== undefined;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function isElectraLightClientUpdate(update: LightClientUpdate): update is LightClientUpdate<ForkPostElectra> {
|
|
83
|
-
const updatePostElectra = update as LightClientUpdate<ForkPostElectra>;
|
|
84
|
-
return (
|
|
85
|
-
updatePostElectra.finalityBranch !== undefined &&
|
|
86
|
-
updatePostElectra.finalityBranch.length === FINALIZED_ROOT_DEPTH_ELECTRA
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function isELectraLightClientFinalityUpdate(
|
|
91
|
-
update: LightClientFinalityUpdate
|
|
92
|
-
): update is LightClientFinalityUpdate<ForkPostElectra> {
|
|
93
|
-
const updatePostElectra = update as LightClientUpdate<ForkPostElectra>;
|
|
94
|
-
return (
|
|
95
|
-
updatePostElectra.finalityBranch !== undefined &&
|
|
96
|
-
updatePostElectra.finalityBranch.length === FINALIZED_ROOT_DEPTH_ELECTRA
|
|
97
|
-
);
|
|
98
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import {FAR_FUTURE_EPOCH} from "@lodestar/params";
|
|
2
|
-
import {Epoch, phase0} from "../types.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* [Validator status specification](https://hackmd.io/ofFJ5gOmQpu1jjHilHbdQQ)
|
|
6
|
-
*/
|
|
7
|
-
export type ValidatorStatus =
|
|
8
|
-
| "pending_initialized"
|
|
9
|
-
| "pending_queued"
|
|
10
|
-
| "active_ongoing"
|
|
11
|
-
| "active_exiting"
|
|
12
|
-
| "active_slashed"
|
|
13
|
-
| "exited_unslashed"
|
|
14
|
-
| "exited_slashed"
|
|
15
|
-
| "withdrawal_possible"
|
|
16
|
-
| "withdrawal_done";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Get the status of the validator
|
|
20
|
-
* based on conditions outlined in https://hackmd.io/ofFJ5gOmQpu1jjHilHbdQQ
|
|
21
|
-
*/
|
|
22
|
-
export function getValidatorStatus(validator: phase0.Validator, currentEpoch: Epoch): ValidatorStatus {
|
|
23
|
-
// pending
|
|
24
|
-
if (validator.activationEpoch > currentEpoch) {
|
|
25
|
-
if (validator.activationEligibilityEpoch === FAR_FUTURE_EPOCH) {
|
|
26
|
-
return "pending_initialized";
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (validator.activationEligibilityEpoch < FAR_FUTURE_EPOCH) {
|
|
30
|
-
return "pending_queued";
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
// active
|
|
34
|
-
if (validator.activationEpoch <= currentEpoch && currentEpoch < validator.exitEpoch) {
|
|
35
|
-
if (validator.exitEpoch === FAR_FUTURE_EPOCH) {
|
|
36
|
-
return "active_ongoing";
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (validator.exitEpoch < FAR_FUTURE_EPOCH) {
|
|
40
|
-
return validator.slashed ? "active_slashed" : "active_exiting";
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
// exited
|
|
44
|
-
if (validator.exitEpoch <= currentEpoch && currentEpoch < validator.withdrawableEpoch) {
|
|
45
|
-
return validator.slashed ? "exited_slashed" : "exited_unslashed";
|
|
46
|
-
}
|
|
47
|
-
// withdrawal
|
|
48
|
-
if (validator.withdrawableEpoch <= currentEpoch) {
|
|
49
|
-
return validator.effectiveBalance !== 0 ? "withdrawal_possible" : "withdrawal_done";
|
|
50
|
-
}
|
|
51
|
-
throw new Error("ValidatorStatus unknown");
|
|
52
|
-
}
|