Skip to content

Commit

Permalink
fix: added fallback values and fixing instances where minimalInput er…
Browse files Browse the repository at this point in the history
…ror could be thrown
  • Loading branch information
vinnyhoward committed Sep 4, 2024
1 parent f936991 commit 59a0c9c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ function SendTransaction() {
tokenIcon = { uri: orderData.cryptoCurrency.logo };
}

const cryptoAmount = (order.cryptoAmount || '0').toString(10);
return (
<ScreenLayout>
<ScreenLayout.Body>
Expand All @@ -225,7 +226,7 @@ function SendTransaction() {
<Text variant={TextVariant.HeadingMD}>
{fromTokenMinimalUnitString(
toTokenMinimalUnit(
order.cryptoAmount || '0',
cryptoAmount,
orderData.cryptoCurrency.decimals,
).toString(),
orderData.cryptoCurrency.decimals,
Expand Down
4 changes: 3 additions & 1 deletion app/components/UI/Swaps/components/QuotesModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ function QuotesModal({
<Text small>{strings('swaps.guaranteed_amount')}</Text>
<Text primary>
{fromTokenMinimalUnitString(
selectedDetailsQuote.destinationAmount,
(
selectedDetailsQuote.destinationAmount || '0'
).toString(10),
destinationToken.decimals,
)}{' '}
<Text reset bold>
Expand Down
10 changes: 5 additions & 5 deletions app/components/Views/confirmations/SendFlow/Amount/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,9 @@ class Amount extends PureComponent {
contractExchangeRates,
} = this.props;
const { internalPrimaryCurrencyIsCrypto, estimatedTotalGas } = this.state;
const tokenBalance = (
contractBalances[selectedAsset.address] || '0'
).toString(10);
let input;
if (selectedAsset.isETH) {
const balanceBN = hexToBN(accounts[selectedAddress].balance);
Expand All @@ -907,15 +910,12 @@ class Amount extends PureComponent {
: undefined;
if (internalPrimaryCurrencyIsCrypto || !exchangeRate) {
input = fromTokenMinimalUnitString(
(contractBalances[selectedAsset.address] || '0').toString(),
tokenBalance,
selectedAsset.decimals,
);
} else {
input = `${balanceToFiatNumber(
fromTokenMinimalUnitString(
(contractBalances[selectedAsset.address] || '0').toString(),
selectedAsset.decimals,
),
fromTokenMinimalUnitString(tokenBalance, selectedAsset.decimals),
conversionRate,
exchangeRate,
)}`;
Expand Down

0 comments on commit 59a0c9c

Please sign in to comment.