Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix token transfer to address #3046

Merged
merged 1 commit into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions app/components/Nav/Main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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 };
}
}
}

Expand Down
1 change: 0 additions & 1 deletion app/components/Views/Approval/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down