Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed Oct 23, 2024
1 parent 1116c9d commit 6256e6b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions app/util/dappTransactions/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { remove0x } from '@metamask/utils';
import { isBN, hexToBN } from '../number';
import { safeToChecksumAddress } from '../address';
import Engine from '../../core/Engine';
Expand Down Expand Up @@ -123,7 +124,7 @@ const getTokenBalance = async (
const checksummedFrom = safeToChecksumAddress(from) || '';
if (selectedAddress === from && contractBalances[selectedAsset.address]) {
return hexToBN(
contractBalances[selectedAsset.address].toString(),
remove0x(contractBalances[selectedAsset.address].toString()),
);
} else {

Check failure on line 129 in app/util/dappTransactions/index.ts

View workflow job for this annotation

GitHub Actions / scripts (lint)

Unnecessary 'else' after 'return'
try {
Expand All @@ -133,10 +134,9 @@ const getTokenBalance = async (
selectedAsset.address,
checksummedFrom,
);
const contractBalanceForAddressBN = new BN4(contractBalanceForAddress.toString(10), 10);
const contractBalanceForAddressBN = hexToBN(contractBalanceForAddress.toString(16));
return contractBalanceForAddressBN;
} catch (e) {
console.error('BARCATCH', { e });
// Don't validate balance if error
}
}
Expand All @@ -157,7 +157,6 @@ export const validateTokenAmount = async (
contractBalances: ContractBalances,
allowEmpty = true,
): Promise<string | undefined> => {
console.error('HELLO', { value, contractBalances, allowEmpty });
if (!allowEmpty) {

if (!value) {
Expand All @@ -177,7 +176,6 @@ export const validateTokenAmount = async (
}

const contractBalanceForAddress = await getTokenBalance(from, selectedAsset, selectedAddress, contractBalances);
console.error('ZUP', { contractBalanceForAddress, value });
if (contractBalanceForAddress?.lt(value)) {
return strings('transaction.insufficient');
}
Expand Down

0 comments on commit 6256e6b

Please sign in to comment.