diff options
author | Kevin Serrano <kevin.serrano@consensys.net> | 2017-05-24 05:26:37 +0800 |
---|---|---|
committer | Kevin Serrano <kevin.serrano@consensys.net> | 2017-05-24 05:26:37 +0800 |
commit | 31d17c9e25458cd47f8c18ec3b967aecff236ba6 (patch) | |
tree | cc933238d05bd3d32f2a2db3bfd4209617998800 | |
parent | 97d19f0f7970feb6fb3170fd85211d0c765cabea (diff) | |
download | tangerine-wallet-browser-31d17c9e25458cd47f8c18ec3b967aecff236ba6.tar tangerine-wallet-browser-31d17c9e25458cd47f8c18ec3b967aecff236ba6.tar.gz tangerine-wallet-browser-31d17c9e25458cd47f8c18ec3b967aecff236ba6.tar.bz2 tangerine-wallet-browser-31d17c9e25458cd47f8c18ec3b967aecff236ba6.tar.lz tangerine-wallet-browser-31d17c9e25458cd47f8c18ec3b967aecff236ba6.tar.xz tangerine-wallet-browser-31d17c9e25458cd47f8c18ec3b967aecff236ba6.tar.zst tangerine-wallet-browser-31d17c9e25458cd47f8c18ec3b967aecff236ba6.zip |
Fix test, create new value for precision/scale
-rw-r--r-- | test/unit/components/bn-as-decimal-input-test.js | 5 | ||||
-rw-r--r-- | ui/app/components/bn-as-decimal-input.js | 6 | ||||
-rw-r--r-- | ui/app/components/pending-tx.js | 2 |
3 files changed, 8 insertions, 5 deletions
diff --git a/test/unit/components/bn-as-decimal-input-test.js b/test/unit/components/bn-as-decimal-input-test.js index f515003bb..6fe684dc5 100644 --- a/test/unit/components/bn-as-decimal-input-test.js +++ b/test/unit/components/bn-as-decimal-input-test.js @@ -10,7 +10,6 @@ var BnInput = require('../../../ui/app/components/bn-as-decimal-input') describe('BnInput', function () { it('can tolerate a gas decimal number at a high precision', function (done) { - const renderer = ReactTestUtils.createRenderer() let valueStr = '20' @@ -27,10 +26,12 @@ describe('BnInput', function () { } const target = new BN(targetStr, 10) - const precision = 1e18 // ether precision + const precision = 13 // ether precision + const scale = 13 const props = { value, + scale, precision, onChange: (newBn) => { assert.equal(newBn.toString(), target.toString(), 'should tolerate increase') diff --git a/ui/app/components/bn-as-decimal-input.js b/ui/app/components/bn-as-decimal-input.js index fbe36abfb..8f56f29ab 100644 --- a/ui/app/components/bn-as-decimal-input.js +++ b/ui/app/components/bn-as-decimal-input.js @@ -26,12 +26,12 @@ BnAsDecimalInput.prototype.render = function () { const props = this.props const state = this.state - const { value, precision, onChange, min, max } = props + const { value, scale, precision, onChange, min, max } = props const suffix = props.suffix const style = props.style const valueString = value.toString(10) - const newValue = downsize(valueString, precision, precision) + const newValue = downsize(valueString, scale, precision) return ( h('.flex-column', [ @@ -65,7 +65,7 @@ BnAsDecimalInput.prototype.render = function () { const value = (event.target.value === '') ? '' : event.target.value - const scaledNumber = upsize(value, precision, precision) + const scaledNumber = upsize(value, scale, precision) const precisionBN = new BN(scaledNumber, 10) onChange(precisionBN) }, diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index 5b238187c..eed0fd9ae 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -156,6 +156,7 @@ PendingTx.prototype.render = function () { name: 'Gas Limit', value: gasBn, precision: 0, + scale: 0, // The hard lower limit for gas. min: MIN_GAS_LIMIT_BN.toString(10), suffix: 'UNITS', @@ -179,6 +180,7 @@ PendingTx.prototype.render = function () { name: 'Gas Price', value: gasPriceBn, precision: 9, + scale: 9, suffix: 'GWEI', min: MIN_GAS_PRICE_GWEI_BN.toString(10), style: { |