Fix transfer token decimal calculation (#3445)

* Fix decimal calculation

* Recalc when shorcutting estimate
This commit is contained in:
Jaco Greeff 2016-11-15 22:00:14 +01:00 committed by Arkadiy Paronyan
parent 3addae9313
commit df901379b3

View File

@ -314,7 +314,7 @@ export default class Transfer extends Component {
} }
const token = balance.tokens.find((balance) => balance.token.tag === tag).token; const token = balance.tokens.find((balance) => balance.token.tag === tag).token;
const s = new BigNumber(num).mul(token.format || 1).toString(); const s = new BigNumber(num).mul(token.format || 1).toFixed();
if (s.indexOf('.') !== -1) { if (s.indexOf('.') !== -1) {
return ERRORS.invalidDecimals; return ERRORS.invalidDecimals;
@ -516,6 +516,13 @@ export default class Transfer extends Component {
} }
recalculateGas = () => { recalculateGas = () => {
if (!this.isValid()) {
this.setState({
gas: '0'
}, this.recalculate);
return;
}
(this.state.isEth (this.state.isEth
? this._estimateGasEth() ? this._estimateGasEth()
: this._estimateGasToken() : this._estimateGasToken()