From b8b0e31470b7eada45a04bb56ca8f075d8fe4b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wiktor=20Tkaczy=C5=84ski?= Date: Mon, 26 Feb 2024 09:34:35 +0100 Subject: [PATCH] fix: properly list network in a map --- apps/mana/src/eth/index.ts | 2 +- apps/mana/src/stark/index.ts | 2 +- apps/mana/src/stark/networks.ts | 12 ++++++------ apps/mana/src/stark/rpc.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/mana/src/eth/index.ts b/apps/mana/src/eth/index.ts index 61bf7d97e..7814a2cfa 100644 --- a/apps/mana/src/eth/index.ts +++ b/apps/mana/src/eth/index.ts @@ -11,7 +11,7 @@ const jsonRpcRequestSchema = z.object({ }); const handlers = Object.fromEntries( - Object.keys(NETWORKS).map(chainId => [chainId, createNetworkHandler(parseInt(chainId, 10))]) + Array.from(NETWORKS.keys()).map(chainId => [chainId, createNetworkHandler(chainId)]) ); const router = express.Router(); diff --git a/apps/mana/src/stark/index.ts b/apps/mana/src/stark/index.ts index 83c5dbe3a..b1f3d335b 100644 --- a/apps/mana/src/stark/index.ts +++ b/apps/mana/src/stark/index.ts @@ -12,7 +12,7 @@ const jsonRpcRequestSchema = z.object({ }); const handlers = Object.fromEntries( - Object.keys(NETWORKS).map(chainId => [chainId, createNetworkHandler(chainId)]) + Array.from(NETWORKS.keys()).map(chainId => [chainId, createNetworkHandler(chainId)]) ); const router = express.Router(); diff --git a/apps/mana/src/stark/networks.ts b/apps/mana/src/stark/networks.ts index ab5dfb476..5a97da7c3 100644 --- a/apps/mana/src/stark/networks.ts +++ b/apps/mana/src/stark/networks.ts @@ -9,11 +9,11 @@ import { import { getProvider, createAccountProxy } from './dependencies'; import { NonceManager } from './nonce-manager'; -export const NETWORKS: Record = { - [constants.StarknetChainId.SN_MAIN]: starknetMainnet, - [constants.StarknetChainId.SN_GOERLI]: starknetGoerli, - [constants.StarknetChainId.SN_SEPOLIA]: starknetSepolia -}; +export const NETWORKS = new Map([ + [constants.StarknetChainId.SN_MAIN, starknetMainnet], + [constants.StarknetChainId.SN_GOERLI, starknetGoerli], + [constants.StarknetChainId.SN_SEPOLIA, starknetSepolia] +]); const clientsMap = new Map< string, @@ -34,7 +34,7 @@ export function getClient(chainId: string) { const client = new clients.StarknetTx({ starkProvider: provider, ethUrl: process.env.ETH_RPC_URL as string, - networkConfig: NETWORKS[chainId] + networkConfig: NETWORKS.get(chainId) }); clientsMap.set(chainId, { provider, client, getAccount }); diff --git a/apps/mana/src/stark/rpc.ts b/apps/mana/src/stark/rpc.ts index 957f530ab..8504aa80a 100644 --- a/apps/mana/src/stark/rpc.ts +++ b/apps/mana/src/stark/rpc.ts @@ -5,7 +5,7 @@ import * as herodotus from './herodotus'; import { rpcError, rpcSuccess } from '../utils'; export const createNetworkHandler = (chainId: string) => { - const networkConfig = NETWORKS[chainId]; + const networkConfig = NETWORKS.get(chainId); if (!networkConfig) throw new Error('Unsupported chainId'); const { client, getAccount } = getClient(chainId);