From 021d9478a756c3cac73b85aa2cd4b6949e440b71 Mon Sep 17 00:00:00 2001 From: harkamal Date: Mon, 21 Aug 2023 13:18:25 +0530 Subject: [PATCH] refac forktypes --- packages/api/src/beacon/routes/validator.ts | 4 +--- packages/params/src/forkName.ts | 12 ++++++++---- packages/params/src/index.ts | 12 +----------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/packages/api/src/beacon/routes/validator.ts b/packages/api/src/beacon/routes/validator.ts index 6ee489d72f17..4743c9cd2803 100644 --- a/packages/api/src/beacon/routes/validator.ts +++ b/packages/api/src/beacon/routes/validator.ts @@ -1,5 +1,5 @@ import {ContainerType, fromHexString, toHexString, Type} from "@chainsafe/ssz"; -import {ForkName, ForkBlobs, isForkBlobs, isForkExecution} from "@lodestar/params"; +import {ForkName, ForkBlobs, isForkBlobs, isForkExecution, ForkPreBlobs} from "@lodestar/params"; import { allForks, altair, @@ -44,8 +44,6 @@ import { } from "../../utils/routes.js"; import {ExecutionOptimistic} from "./beacon/block.js"; -type ForkPreBlobs = ForkName.phase0 | ForkName.altair | ForkName.bellatrix | ForkName.capella; - export type ProduceBlockOrContentsRes = {executionPayloadValue: Wei} & ( | {data: allForks.BeaconBlock; version: ForkPreBlobs} | {data: BlockContents; version: ForkBlobs} diff --git a/packages/params/src/forkName.ts b/packages/params/src/forkName.ts index a8b3579c6114..f6a31c458aee 100644 --- a/packages/params/src/forkName.ts +++ b/packages/params/src/forkName.ts @@ -20,22 +20,26 @@ export enum ForkSeq { deneb = 4, } -export type ForkLightClient = Exclude; +export type ForkPreLightClient = ForkName.phase0; +export type ForkLightClient = Exclude; export function isForkLightClient(fork: ForkName): fork is ForkLightClient { return fork !== ForkName.phase0; } -export type ForkExecution = Exclude; +export type ForkPreExecution = ForkPreLightClient | ForkName.altair; +export type ForkExecution = Exclude; export function isForkExecution(fork: ForkName): fork is ForkExecution { return isForkLightClient(fork) && fork !== ForkName.altair; } -export type ForkWithdrawals = Exclude; +export type ForkPreWithdrawals = ForkPreExecution | ForkName.bellatrix; +export type ForkWithdrawals = Exclude; export function isForkWithdrawals(fork: ForkName): fork is ForkWithdrawals { return isForkExecution(fork) && fork !== ForkName.bellatrix; } -export type ForkBlobs = Exclude; +export type ForkPreBlobs = ForkPreWithdrawals | ForkName.capella; +export type ForkBlobs = Exclude; export function isForkBlobs(fork: ForkName): fork is ForkBlobs { return isForkWithdrawals(fork) && fork !== ForkName.capella; } diff --git a/packages/params/src/index.ts b/packages/params/src/index.ts index b167f25ffd97..6ee841fd584f 100644 --- a/packages/params/src/index.ts +++ b/packages/params/src/index.ts @@ -6,17 +6,7 @@ import {presetStatus} from "./presetStatus.js"; import {userSelectedPreset, userOverrides} from "./setPreset.js"; export {BeaconPreset} from "./types.js"; -export { - ForkName, - ForkSeq, - ForkLightClient, - ForkExecution, - ForkBlobs, - isForkExecution, - isForkWithdrawals, - isForkBlobs, - isForkLightClient, -} from "./forkName.js"; +export * from "./forkName.js"; export {presetToJson} from "./json.js"; export {PresetName};