Skip to content

Commit

Permalink
fix(coinmarket): fix address validator check
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeWall authored and tomasklim committed Jan 4, 2025
1 parent c6d420c commit 32bbc5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 8 additions & 4 deletions packages/suite/src/hooks/wallet/coinmarket/useCoinmarketInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import {
CoinmarketCryptoSelectOptionProps,
CoinmarketInfoProps,
} from 'src/types/coinmarket/coinmarket';
import { parseCryptoId, testnetToProdCryptoId } from 'src/utils/wallet/coinmarket/coinmarketUtils';
import {
cryptoIdToNetwork,
parseCryptoId,
testnetToProdCryptoId,
} from 'src/utils/wallet/coinmarket/coinmarketUtils';

const supportedAddressValidatorSymbols = new Set(
addressValidator.getCurrencies().map(c => c.symbol),
Expand Down Expand Up @@ -103,9 +107,9 @@ export const useCoinmarketInfo = (): CoinmarketInfoProps => {
return;
}

const nativeCoinSymbol = cryptoIdToNativeCoinSymbol(
testnetToProdCryptoId(cryptoId),
);
const nativeCoinSymbol =
cryptoIdToNetwork(testnetToProdCryptoId(cryptoId))?.symbol ??
cryptoIdToNativeCoinSymbol(testnetToProdCryptoId(cryptoId));
if (!nativeCoinSymbol || !supportedAddressValidatorSymbols.has(nativeCoinSymbol)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import {
isCoinmarketBuyContext,
isCoinmarketExchangeContext,
} from 'src/utils/wallet/coinmarket/coinmarketTypingUtils';
import { getCoinmarketNetworkDisplaySymbol } from 'src/utils/wallet/coinmarket/coinmarketUtils';
import {
cryptoIdToNetwork,
getCoinmarketNetworkDisplaySymbol,
} from 'src/utils/wallet/coinmarket/coinmarketUtils';

interface CoinmarketVerifyProps {
coinmarketVerifyAccount: CoinmarketVerifyAccountReturnProps;
Expand Down Expand Up @@ -66,7 +69,8 @@ export const CoinmarketVerify = ({ coinmarketVerifyAccount, cryptoId }: Coinmark
required: translationString('TR_EXCHANGE_RECEIVING_ADDRESS_REQUIRED'),
validate: value => {
if (selectedAccountOption?.type === 'NON_SUITE' && cryptoId) {
const symbol = cryptoIdToNativeCoinSymbol(cryptoId);
const symbol =
cryptoIdToNetwork(cryptoId)?.symbol ?? cryptoIdToNativeCoinSymbol(cryptoId);
if (value && !addressValidator.validate(value, symbol)) {
return translationString('TR_EXCHANGE_RECEIVING_ADDRESS_INVALID');
}
Expand Down

0 comments on commit 32bbc5a

Please sign in to comment.