Fix "no bignumber" Error (#155)

* provide link to mailchimp based subscription

* only estimate gas when the amount value is a number
This commit is contained in:
Daniel Ternyak 2017-08-31 17:01:34 -07:00 committed by GitHub
parent f6b5e8f426
commit c2c9f39c6b

View File

@ -21,7 +21,6 @@ import BaseWallet from 'libs/wallet/base';
import customMessages from './messages';
import { donationAddressMap } from 'config/data';
import { isValidETHAddress } from 'libs/validators';
import { toUnit } from 'libs/units';
import {
getNodeLib,
getNetworkConfig,
@ -337,33 +336,33 @@ export class SendTransaction extends React.Component {
async getTransactionInfoFromState(): Promise<TransactionWithoutGas> {
const { wallet } = this.props;
const { token } = this.state;
const { token, unit, value, to, data } = this.state;
if (this.state.unit === 'ether') {
if (unit === 'ether') {
return {
to: this.state.to,
to,
from: await wallet.getAddress(),
value: valueToHex(this.state.value),
data: this.state.data
value: valueToHex(value),
data
};
} else {
if (!token) {
throw new Error('No matching token');
}
const bigAmount = new Big(value);
return {
to: token.address,
from: await wallet.getAddress(),
value: '0x0',
data: ERC20.transfer(
this.state.to,
toTokenUnit(new Big(this.state.value), token)
)
data: ERC20.transfer(to, toTokenUnit(bigAmount, token))
};
}
}
async estimateGas() {
if (!isNaN(parseInt(this.state.value))) {
try {
const transaction = await this.getTransactionInfoFromState();
// Grab a reference to state. If it has changed by the time the estimateGas
@ -379,6 +378,7 @@ export class SendTransaction extends React.Component {
this.props.showNotification('danger', error.message, 5000);
}
}
}
// FIXME use mkTx instead or something that could take care of default gas/data and whatnot,
onNewTx = (
@ -439,6 +439,7 @@ export class SendTransaction extends React.Component {
value = tokenBalance.balance.toString();
}
}
let token = this.props.tokens.find(x => x.symbol === unit);
this.setState({