diff options
author | Dan <danjm.com@gmail.com> | 2017-10-31 02:07:30 +0800 |
---|---|---|
committer | Dan <danjm.com@gmail.com> | 2017-11-07 03:33:04 +0800 |
commit | c420249fb9115f7dc871acfd8c5cf832ebf5e890 (patch) | |
tree | e99ce24eeb12d8f5696053b7f9da83b7532e310b /ui | |
parent | 319779ab081f70343b5ef77531450878292a90d6 (diff) | |
download | tangerine-wallet-browser-c420249fb9115f7dc871acfd8c5cf832ebf5e890.tar.gz tangerine-wallet-browser-c420249fb9115f7dc871acfd8c5cf832ebf5e890.tar.zst tangerine-wallet-browser-c420249fb9115f7dc871acfd8c5cf832ebf5e890.zip |
Adds max amount feature for send token
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/send-v2.js | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index 412aa417c..6f3b48be6 100644 --- a/ui/app/send-v2.js +++ b/ui/app/send-v2.js @@ -321,18 +321,25 @@ SendTransactionScreen.prototype.setAmountToMax = function () { updateGasPrice, updateGasLimit, updateGasTotal, + tokenBalance, + selectedToken, } = this.props + const { decimals } = selectedToken || {} + const multiplier = Math.pow(10, Number(decimals || 0)) - const maxAmount = subtractCurrencies( - ethUtil.addHexPrefix(balance), - ethUtil.addHexPrefix(MIN_GAS_TOTAL), - { toNumericBase: 'hex' } - ) + const maxAmount = selectedToken + ? multiplyCurrencies(tokenBalance, multiplier, {toNumericBase: 'hex'}) + : subtractCurrencies( + ethUtil.addHexPrefix(balance), + ethUtil.addHexPrefix(gasTotal), + { toNumericBase: 'hex' } + ) updateSendErrors({ amount: null }) updateGasPrice(MIN_GAS_PRICE_HEX) updateGasLimit(MIN_GAS_LIMIT_HEX) updateGasTotal(MIN_GAS_TOTAL) + updateSendAmount(maxAmount) } |