UNPKG

@lodestar/types

Version:

Typescript types required for lodestar

51 lines 2.38 kB
import { ForkName } from "@lodestar/params"; import { ssz as altairSsz } from "./altair/index.js"; import { ssz as bellatrixSsz } from "./bellatrix/index.js"; import { ssz as capellaSsz } from "./capella/index.js"; import { ssz as denebSsz } from "./deneb/index.js"; import { ssz as electraSsz } from "./electra/index.js"; import { ssz as fuluSsz } from "./fulu/index.js"; import { ssz as gloasSsz } from "./gloas/index.js"; import { ssz as phase0Ssz } from "./phase0/index.js"; export * from "./primitive/sszTypes.js"; /** * Index the ssz types that differ by fork * A record of AllForksSSZTypes indexed by fork */ const typesByFork = { [ForkName.phase0]: { ...phase0Ssz }, [ForkName.altair]: { ...phase0Ssz, ...altairSsz }, [ForkName.bellatrix]: { ...phase0Ssz, ...altairSsz, ...bellatrixSsz }, [ForkName.capella]: { ...phase0Ssz, ...altairSsz, ...bellatrixSsz, ...capellaSsz }, [ForkName.deneb]: { ...phase0Ssz, ...altairSsz, ...bellatrixSsz, ...capellaSsz, ...denebSsz }, [ForkName.electra]: { ...phase0Ssz, ...altairSsz, ...bellatrixSsz, ...capellaSsz, ...denebSsz, ...electraSsz }, [ForkName.fulu]: { ...phase0Ssz, ...altairSsz, ...bellatrixSsz, ...capellaSsz, ...denebSsz, ...electraSsz, ...fuluSsz }, [ForkName.gloas]: { ...phase0Ssz, ...altairSsz, ...bellatrixSsz, ...capellaSsz, ...denebSsz, ...electraSsz, ...fuluSsz, ...gloasSsz, }, }; // Export these types to ensure that each fork is a superset of the previous one (with overridden types obviously) // This allows us to only declare types that change in each fork in each fork subdirectory export const phase0 = typesByFork[ForkName.phase0]; export const altair = typesByFork[ForkName.altair]; export const bellatrix = typesByFork[ForkName.bellatrix]; export const capella = typesByFork[ForkName.capella]; export const deneb = typesByFork[ForkName.deneb]; export const electra = typesByFork[ForkName.electra]; export const fulu = typesByFork[ForkName.fulu]; export const gloas = typesByFork[ForkName.gloas]; export function sszTypesFor(fork, typeName) { const sszTypes = typesByFork[fork]; if (sszTypes === undefined) { throw Error(`SSZ types for fork ${fork} are not defined`); } return (typeName === undefined ? sszTypes : sszTypes[typeName]); } //# sourceMappingURL=sszTypes.js.map