From 487a9b9ee2c57af0413d2f2ebb22ff8ece5dbc2f Mon Sep 17 00:00:00 2001 From: Beth Swingler Date: Tue, 26 Sep 2023 15:54:10 +0100 Subject: [PATCH] fix: use correct currency id in market list --- .../src/renderer/screens/market/MarketList.tsx | 8 ++++++-- .../providers/RampCatalogProvider/useRampCatalog.ts | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/ledger-live-desktop/src/renderer/screens/market/MarketList.tsx b/apps/ledger-live-desktop/src/renderer/screens/market/MarketList.tsx index ffd3bb3f3112..bb7da39bd777 100644 --- a/apps/ledger-live-desktop/src/renderer/screens/market/MarketList.tsx +++ b/apps/ledger-live-desktop/src/renderer/screens/market/MarketList.tsx @@ -226,7 +226,7 @@ const CurrencyRow = memo(function CurrencyRowItem({ swapAvailableIds, style, }: { - data: CurrencyData[]; + data: CurrencyData[]; // NB: CurrencyData.id is different to Currency.id index: number; counterCurrency?: string; loading: boolean; @@ -243,7 +243,11 @@ const CurrencyRow = memo(function CurrencyRowItem({ const isStarred = currency && starredMarketCoins.includes(currency.id); const { isCurrencyAvailable } = useRampCatalog(); - const availableOnBuy = !!currency && isCurrencyAvailable(currency.id, "onRamp"); + + const availableOnBuy = + !!internalCurrency && + !!internalCurrency?.id && + isCurrencyAvailable(internalCurrency.id, "onRamp"); const availableOnSwap = internalCurrency && swapAvailableIds.includes(internalCurrency.id); const stakeProgramsFeatureFlag = useFeature("stakePrograms"); diff --git a/libs/ledger-live-common/src/platform/providers/RampCatalogProvider/useRampCatalog.ts b/libs/ledger-live-common/src/platform/providers/RampCatalogProvider/useRampCatalog.ts index 4af2c6ac41a8..62d0d81f6a24 100644 --- a/libs/ledger-live-common/src/platform/providers/RampCatalogProvider/useRampCatalog.ts +++ b/libs/ledger-live-common/src/platform/providers/RampCatalogProvider/useRampCatalog.ts @@ -2,6 +2,7 @@ import { useCallback, useEffect } from "react"; import { getCryptoCurrencyIds, isCurrencyInCatalog } from "./helpers"; import { useRampCatalogContext } from "./index"; import type { CryptoCurrency } from "@ledgerhq/wallet-api-core/lib/currencies/types"; +import { CryptoCurrencyId, CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets"; type UseRampCatalog = { isCurrencyAvailable: ( @@ -31,7 +32,10 @@ export function useRampCatalog(): UseRampCatalog { * @returns true if the currency is supported, false if not, null if the catalog is not loaded yet. */ const isCurrencyAvailable = useCallback( - (currencyId: CryptoCurrency["id"] | string, mode: "onRamp" | "offRamp") => { + ( + currencyId: CryptoCurrency["id"] | CryptoCurrencyId | CryptoOrTokenCurrency["id"], + mode: "onRamp" | "offRamp", + ) => { if (!state.value) { return null; }