Skip to content

Commit

Permalink
fix: use correct currency id in market list
Browse files Browse the repository at this point in the history
  • Loading branch information
beths-ledger committed Sep 27, 2023
1 parent c719d07 commit c5a6a51
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: (
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit c5a6a51

Please sign in to comment.