From b1e6cf3087fa105ec732960cbff214319e8a30ca Mon Sep 17 00:00:00 2001 From: woodenfurniture <125113430+woodenfurniture@users.noreply.github.com> Date: Tue, 7 Jan 2025 11:57:08 +1100 Subject: [PATCH] chore: exhaustiveness for assetNamespace switch --- src/lib/coingecko/utils.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/coingecko/utils.ts b/src/lib/coingecko/utils.ts index 7d956418127..5dac81bf74c 100644 --- a/src/lib/coingecko/utils.ts +++ b/src/lib/coingecko/utils.ts @@ -20,6 +20,7 @@ import { getConfig } from 'config' import { queryClient } from 'context/QueryClientProvider/queryClient' import type { CoinGeckoSortKey } from 'lib/market-service/coingecko/coingecko' import type { CoinGeckoMarketCap } from 'lib/market-service/coingecko/coingecko-types' +import { assertUnreachable } from 'lib/utils' import { COINGECKO_NATIVE_ASSET_ID_TO_ASSET_ID } from './constants' import type { @@ -65,7 +66,8 @@ const getCoinDetails = async ( if (!chainId) return const assetNamespace = (() => { - switch (chainId) { + const knownChainId = chainId as KnownChainIds + switch (knownChainId) { case KnownChainIds.BnbSmartChainMainnet: return ASSET_NAMESPACE.bep20 case KnownChainIds.SolanaMainnet: @@ -86,8 +88,9 @@ const getCoinDetails = async ( case KnownChainIds.BitcoinCashMainnet: case KnownChainIds.DogecoinMainnet: case KnownChainIds.LitecoinMainnet: - default: throw Error(`Unhandled case '${chainId}'`) + default: + return assertUnreachable(knownChainId) } })()