diff options
author | Daniel Tsui <szehungdanieltsui@gmail.com> | 2017-11-08 09:52:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-08 09:52:08 +0800 |
commit | a21f6f5f6348303cab3bc845c621432c4f753e00 (patch) | |
tree | f2cb10316fd7435c1969c4cf043c29e05eec6527 /ui/app/components | |
parent | da2e9b9765ca32e7439a2a5687e6c3d8ca8bb63c (diff) | |
parent | d1977225a48f381f3a6bda4a54ce9e0e0914357e (diff) | |
download | tangerine-wallet-browser-a21f6f5f6348303cab3bc845c621432c4f753e00.tar tangerine-wallet-browser-a21f6f5f6348303cab3bc845c621432c4f753e00.tar.gz tangerine-wallet-browser-a21f6f5f6348303cab3bc845c621432c4f753e00.tar.bz2 tangerine-wallet-browser-a21f6f5f6348303cab3bc845c621432c4f753e00.tar.lz tangerine-wallet-browser-a21f6f5f6348303cab3bc845c621432c4f753e00.tar.xz tangerine-wallet-browser-a21f6f5f6348303cab3bc845c621432c4f753e00.tar.zst tangerine-wallet-browser-a21f6f5f6348303cab3bc845c621432c4f753e00.zip |
Merge pull request #2549 from danjm/NewUI-flat-send-amount-fixes
[NewUI] Fix issues with amount max
Diffstat (limited to 'ui/app/components')
-rw-r--r-- | ui/app/components/send/currency-display.js | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/ui/app/components/send/currency-display.js b/ui/app/components/send/currency-display.js index 8b72b3e6d..870fbb42a 100644 --- a/ui/app/components/send/currency-display.js +++ b/ui/app/components/send/currency-display.js @@ -11,11 +11,6 @@ function CurrencyDisplay () { Component.call(this) } -function isValidInput (text) { - const re = /^([1-9]\d*|0)(\.|\.\d*)?$/ - return re.test(text) -} - function toHexWei (value) { return conversionUtil(value, { fromNumericBase: 'dec', @@ -36,6 +31,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', @@ -46,17 +63,10 @@ CurrencyDisplay.prototype.render = function () { convertedCurrency, readOnly = false, inError = false, - value, 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', @@ -66,8 +76,6 @@ CurrencyDisplay.prototype.render = function () { conversionRate, }) - const inputSizeMultiplier = readOnly ? 1 : 1.2 - return h('div', { className, style: { |