aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-11-08 09:17:14 +0800
committerDan <danjm.com@gmail.com>2017-11-08 09:17:14 +0800
commitc156c85eaa064b971ce0202df0bb1681eb0e22dd (patch)
tree81695898875f9e607bd34ce47fdfc4a25014d3fa /ui/app/components
parentda2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c (diff)
downloadtangerine-wallet-browser-c156c85eaa064b971ce0202df0bb1681eb0e22dd.tar
tangerine-wallet-browser-c156c85eaa064b971ce0202df0bb1681eb0e22dd.tar.gz
tangerine-wallet-browser-c156c85eaa064b971ce0202df0bb1681eb0e22dd.tar.bz2
tangerine-wallet-browser-c156c85eaa064b971ce0202df0bb1681eb0e22dd.tar.lz
tangerine-wallet-browser-c156c85eaa064b971ce0202df0bb1681eb0e22dd.tar.xz
tangerine-wallet-browser-c156c85eaa064b971ce0202df0bb1681eb0e22dd.tar.zst
tangerine-wallet-browser-c156c85eaa064b971ce0202df0bb1681eb0e22dd.zip
Fix amount max for sending token.
Diffstat (limited to 'ui/app/components')
-rw-r--r--ui/app/components/send/currency-display.js30
1 files changed, 23 insertions, 7 deletions
diff --git a/ui/app/components/send/currency-display.js b/ui/app/components/send/currency-display.js
index 8b72b3e6d..49df5b0b7 100644
--- a/ui/app/components/send/currency-display.js
+++ b/ui/app/components/send/currency-display.js
@@ -36,6 +36,28 @@ CurrencyDisplay.prototype.getAmount = function (value) {
: toHexWei(value)
}
+CurrencyDisplay.prototype.getValueToRender = function () {
+ const { selectedToken, conversionRate, value } = this.props
+
+ const { decimals, symbol } = selectedToken || {}
+ const multiplier = Math.pow(10, Number(decimals || 0))
+
+ return selectedToken
+ ? conversionUtil(value, {
+ fromNumericBase: 'hex',
+ toCurrency: symbol,
+ conversionRate: multiplier,
+ invertConversionRate: true,
+ })
+ : conversionUtil(value, {
+ fromNumericBase: 'hex',
+ toNumericBase: 'dec',
+ fromDenomination: 'WEI',
+ numberOfDecimals: 6,
+ conversionRate,
+ })
+}
+
CurrencyDisplay.prototype.render = function () {
const {
className = 'currency-display',
@@ -50,13 +72,7 @@ CurrencyDisplay.prototype.render = function () {
handleChange,
} = this.props
- const valueToRender = conversionUtil(value, {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- fromDenomination: 'WEI',
- numberOfDecimals: 6,
- conversionRate,
- })
+ const valueToRender = this.getValueToRender()
const convertedValue = conversionUtil(valueToRender, {
fromNumericBase: 'dec',