From 6cb1b2ae78613216143468d13964603baf652eb5 Mon Sep 17 00:00:00 2001 From: spsjvc Date: Thu, 3 Oct 2024 14:11:45 +0200 Subject: [PATCH] more --- src/types/ParentChain.ts | 4 +--- src/utils/getParentChainFromId.ts | 10 ++++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/types/ParentChain.ts b/src/types/ParentChain.ts index 8ee24a15..7fe0d6c6 100644 --- a/src/types/ParentChain.ts +++ b/src/types/ParentChain.ts @@ -6,9 +6,7 @@ import { chains, nitroTestnodeL3 } from '../chains'; export type ParentChain = Exclude<(typeof chains)[number], { id: typeof nitroTestnodeL3.id }>; export type ParentChainId = ParentChain['id']; -export function isValidParentChainId( - parentChainId: number | undefined, -): parentChainId is ParentChainId { +function isValidParentChainId(parentChainId: number | undefined): parentChainId is ParentChainId { const ids = chains // exclude nitro-testnode L3 from the list of parent chains .filter((chain) => chain.id !== nitroTestnodeL3.id) diff --git a/src/utils/getParentChainFromId.ts b/src/utils/getParentChainFromId.ts index 1ca8631f..ff2ebddb 100644 --- a/src/utils/getParentChainFromId.ts +++ b/src/utils/getParentChainFromId.ts @@ -1,15 +1,13 @@ import { extractChain } from 'viem'; -import { ParentChain, isValidParentChainId } from '../types/ParentChain'; + import { chains } from '../chains'; +import { ParentChain, validateParentChain } from '../types/ParentChain'; export function getParentChainFromId(chainId: number): ParentChain { - // Just throws if the chainId is not valid - if (!isValidParentChainId(chainId)) { - throw new Error(`Parent chain not supported: ${chainId}`); - } + const parentChainId = validateParentChain(chainId); return extractChain({ chains, - id: chainId, + id: parentChainId, }) as ParentChain; }