From 4e45a4a6c3f5478fed4d2a52301f0fc2d0cc2f96 Mon Sep 17 00:00:00 2001 From: BenRey <44082144+Ben-Rey@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:30:26 +0100 Subject: [PATCH] add network mapping and utility function for chain IDs (#696) --- src/utils/networks.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/utils/networks.ts b/src/utils/networks.ts index 8f7f4baf..2871d161 100644 --- a/src/utils/networks.ts +++ b/src/utils/networks.ts @@ -18,6 +18,17 @@ export const CHAIN_ID = { Buildnet: 77658366n, } +export function getNetworkNameByChainId( + chainId: bigint +): NetworkName | undefined { + for (const [key, value] of Object.entries(CHAIN_ID)) { + if (value === chainId) { + return NetworkName[key as keyof typeof NetworkName] + } + } + return undefined +} + export type Network = { name: NetworkName | string chainId: bigint