diff --git a/app/components/Nav/Main/index.js b/app/components/Nav/Main/index.js index 6d15a73e28b..d62d983aea8 100644 --- a/app/components/Nav/Main/index.js +++ b/app/components/Nav/Main/index.js @@ -65,6 +65,7 @@ import Analytics from '../../../core/Analytics'; import { ANALYTICS_EVENT_OPTS } from '../../../util/analytics'; import BigNumber from 'bignumber.js'; import { setInfuraAvailabilityBlocked, setInfuraAvailabilityNotBlocked } from '../../../actions/infuraAvailability'; +import { toLowerCaseEquals } from '../../../util/general'; const styles = StyleSheet.create({ flex: { @@ -342,17 +343,26 @@ const Main = props => { to && (await getMethodData(data)).name === TOKEN_METHOD_TRANSFER ) { - let asset = props.tokens.find(({ address }) => address === to); - if (!asset && contractMap[to]) { - asset = contractMap[to]; - } else if (!asset) { - try { - asset = {}; - asset.decimals = await AssetsContractController.getTokenDecimals(to); - asset.symbol = await AssetsContractController.getAssetSymbol(to); - } catch (e) { - // This could fail when requesting a transfer in other network - asset = { symbol: 'ERC20', decimals: new BN(0) }; + let asset = props.tokens.find(({ address }) => toLowerCaseEquals(address, to)); + if (!asset) { + // try to lookup contract by lowercased address `to` + const contractMapKey = Object.keys(contractMap).find(key => toLowerCaseEquals(key, to)); + if (contractMapKey) { + asset = contractMap[contractMapKey]; + } + + if (!asset) { + try { + asset = {}; + asset.decimals = await AssetsContractController.getTokenDecimals(to); + asset.symbol = await AssetsContractController.getAssetSymbol(to); + // adding `to` here as well + asset.address = to; + } catch (e) { + // This could fail when requesting a transfer in other network + // adding `to` here as well + asset = { symbol: 'ERC20', decimals: new BN(0), address: to }; + } } } diff --git a/app/components/Views/Approval/index.js b/app/components/Views/Approval/index.js index 2c8e9f42597..055e66a823f 100644 --- a/app/components/Views/Approval/index.js +++ b/app/components/Views/Approval/index.js @@ -337,7 +337,6 @@ class Approval extends PureComponent { transactionToSend.gas = EIP1559GasData.gasLimitHex; transactionToSend.maxFeePerGas = addHexPrefix(EIP1559GasData.suggestedMaxFeePerGasHex); //'0x2540be400' transactionToSend.maxPriorityFeePerGas = addHexPrefix(EIP1559GasData.suggestedMaxPriorityFeePerGasHex); //'0x3b9aca00'; - transactionToSend.to = safeToChecksumAddress(transaction.to); delete transactionToSend.gasPrice; } else { transactionToSend.gas = BNToHex(transaction.gas);