From fcc7f555ef902f0024b5c73f3a7fbbaa67dbcb5d Mon Sep 17 00:00:00 2001 From: George Lima Date: Mon, 18 Mar 2019 11:15:05 -0300 Subject: [PATCH] fix(send): fix maxAmount button --- app/views/send.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/views/send.js b/app/views/send.js index a1c6855..d719d0d 100644 --- a/app/views/send.js +++ b/app/views/send.js @@ -449,6 +449,15 @@ class Component extends PureComponent { return new BigNumber(amount).plus(feeValue).toNumber(); }; + getMaxAmountWithoutFee = () => { + const { balance } = this.props; + const { fee } = this.state; + + const max = new BigNumber(balance).minus(fee || 0); + + return max.isNegative() ? 0 : max.toNumber(); + }; + handleChange = (field: string) => (value: string | number) => { const { validateAddress, getAddressBalance, balance } = this.props; const { amount } = this.state; @@ -752,7 +761,7 @@ class Component extends PureComponent { ( this.handleChange('amount')(balance - (Number(fee) || 0))} + onClick={() => this.handleChange('amount')(this.getMaxAmountWithoutFee())} disabled={!from} >