Skip to content

Commit 79443b7

Browse files
committed
fix: use existing fiat symbol helper for bridge input
1 parent 34e0ad0 commit 79443b7

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • app/components/UI/Bridge/hooks/useSourceAmountInput

app/components/UI/Bridge/hooks/useSourceAmountInput/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
22
import { useSelector } from 'react-redux';
33
import { selectCurrentCurrency } from '../../../../../selectors/currencyRateController';
4+
import currencySymbols from '../../../../../util/currency-symbols.json';
45
import { getCurrencySymbol } from '../../../../../util/number/bigint';
56
import { MAX_INPUT_LENGTH } from '../../components/TokenInputArea';
67
import { BridgeToken } from '../../types';
@@ -16,6 +17,15 @@ import { useSourceAmountCursor } from '../useSourceAmountCursor';
1617
import { useTokenFiatRate } from '../useTokenFiatRate';
1718

1819
const FIAT_KEYPAD_CURRENCY = 'SWAPS_FIAT_INPUT';
20+
type CurrencyCode = keyof typeof currencySymbols;
21+
22+
const getInputCurrencySymbol = (currency?: string) => {
23+
const currencyCode = (currency || 'usd').toLowerCase();
24+
25+
return currencyCode in currencySymbols
26+
? getCurrencySymbol(currencyCode as CurrencyCode)
27+
: currencyCode.toUpperCase();
28+
};
1929

2030
export const useSourceAmountInput = ({
2131
sourceAmount,
@@ -192,7 +202,7 @@ export const useSourceAmountInput = ({
192202
}, [canToggle, currentCurrency, isFiatMode, sourceAmount, sourceToken]);
193203

194204
const inputPrefix = isFiatMode
195-
? getCurrencySymbol((currentCurrency || 'usd').toLowerCase())
205+
? getInputCurrencySymbol(currentCurrency)
196206
: undefined;
197207

198208
return {

0 commit comments

Comments
 (0)