Skip to content

Commit

Permalink
fix broken send flow
Browse files Browse the repository at this point in the history
  • Loading branch information
adonesky1 committed Jul 15, 2022
1 parent ecf3eee commit 7a1a809
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions ui/ducks/send/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ import {
isValidHexAddress,
toChecksumHexAddress,
} from '../../../shared/modules/hexstring-utils';
import { sumHexes } from '../../helpers/utils/transactions.util';
import {
isSmartContractAddress,
sumHexes,
} from '../../helpers/utils/transactions.util';
import fetchEstimatedL1Fee from '../../helpers/utils/optimism/fetchEstimatedL1Fee';

import { TOKEN_STANDARDS, ETH } from '../../helpers/constants/common';
Expand Down Expand Up @@ -1852,19 +1855,23 @@ export function updateRecipientUserInput(userInput) {
const inputIsValidHexAddress = isValidHexAddress(userInput);
let isProbablyAnAssetContract = false;
if (inputIsValidHexAddress) {
const { symbol, decimals } = getTokenMetadata(userInput, tokenMap) || {};
const smartContractAddress = await isSmartContractAddress(userInput);
if (smartContractAddress) {
const { symbol, decimals } =
getTokenMetadata(userInput, tokenMap) || {};

isProbablyAnAssetContract = symbol && decimals !== undefined;
isProbablyAnAssetContract = symbol && decimals !== undefined;

if (!isProbablyAnAssetContract) {
try {
const { standard } = await getTokenStandardAndDetails(
userInput,
sendingAddress,
);
isProbablyAnAssetContract = Boolean(standard);
} catch (e) {
console.log(e);
if (!isProbablyAnAssetContract) {
try {
const { standard } = await getTokenStandardAndDetails(
userInput,
sendingAddress,
);
isProbablyAnAssetContract = Boolean(standard);
} catch (e) {
console.log(e);
}
}
}
}
Expand Down Expand Up @@ -1987,16 +1994,18 @@ export function updateSendAsset(
)),
};
await dispatch(hideLoadingIndication());
const balance = addHexPrefix(
calcTokenAmount(details.balance, details.decimals).toString(16),
);

const asset = {
type,
details,
balance,
error: null,
};
if (

if (details.standard === TOKEN_STANDARDS.ERC20) {
asset.balance = addHexPrefix(
calcTokenAmount(details.balance, details.decimals).toString(16),
);
} else if (
details.standard === TOKEN_STANDARDS.ERC1155 &&
type === ASSET_TYPES.COLLECTIBLE
) {
Expand Down Expand Up @@ -2054,7 +2063,6 @@ export function updateSendAsset(
);
// do nothing extra.
}

await dispatch(actions.updateAsset(asset));
}
if (skipComputeEstimatedGasLimit === false) {
Expand Down

0 comments on commit 7a1a809

Please sign in to comment.