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

bugfix: token transfer deeplink #1047

Merged
merged 6 commits into from
Aug 30, 2019
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
6 changes: 1 addition & 5 deletions app/components/UI/TransactionEdit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,10 @@ class TransactionEdit extends PureComponent {

componentDidUpdate = prevProps => {
if (this.props.transaction.data !== prevProps.transaction.data) {
this.onTransactionDataChange();
this.updateData(this.props.transaction.data);
}
};

onTransactionDataChange = () => {
this.setState({ data: this.props.transaction.data });
};

fillMax = () => {
const { gas, gasPrice, from, selectedAsset, assetType, paymentChannelTransaction } = this.props.transaction;
const { balance } = this.props.accounts[from];
Expand Down
27 changes: 18 additions & 9 deletions app/components/Views/Send/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Analytics from '../../../core/Analytics';
import ANALYTICS_EVENT_OPTS from '../../../util/analytics';
import { getTransactionReviewActionKey, decodeTransferData } from '../../../util/transactions';
import Logger from '../../../util/Logger';
import { isENS } from '../../../util/address';

const REVIEW = 'review';
const EDIT = 'edit';
Expand Down Expand Up @@ -166,6 +167,19 @@ class Send extends PureComponent {
}
}

/**
* Handle deeplink txMeta recipient
*/
handleNewTxMetaRecipient = recipient => {
let ensRecipient, to;
if (isENS(recipient)) {
ensRecipient = recipient;
} else if (recipient && recipient.toLowerCase().substr(0, 2) === '0x') {
to = toChecksumAddress(recipient);
}
return { ensRecipient, to };
};

/**
* Handle txMeta object, setting neccesary state to make a transaction
*/
Expand All @@ -185,14 +199,9 @@ class Send extends PureComponent {
newTxMeta = {
symbol: 'ETH',
assetType: 'ETH',
type: 'ETHER_TRANSACTION'
type: 'ETHER_TRANSACTION',
...this.handleNewTxMetaRecipient(target_address)
};
if (target_address.toLowerCase().substr(0, 2) === '0x') {
newTxMeta.to = toChecksumAddress(target_address);
} else {
// ENS Name
newTxMeta.ensRecipient = target_address;
}
if (parameters && parameters.value) {
newTxMeta.value = toBN(parameters.value);
newTxMeta.readableValue = fromWei(newTxMeta.value);
Expand All @@ -203,9 +212,9 @@ class Send extends PureComponent {
newTxMeta = {
assetType: 'ERC20',
type: 'INDIVIDUAL_TOKEN_TRANSACTION',
selectedAsset
selectedAsset,
...this.handleNewTxMetaRecipient(parameters.address)
};
newTxMeta.to = toChecksumAddress(parameters.address);
if (parameters && parameters.uint256) {
newTxMeta.value = toTokenMinimalUnit(parameters.uint256, selectedAsset.decimals);
newTxMeta.readableValue = String(
Expand Down