From 5d034006e8a73c7d64dee22c856c3733643454f8 Mon Sep 17 00:00:00 2001 From: trejgun Date: Sun, 24 Jun 2018 17:48:02 +0800 Subject: fixes #4307 BigNumber casting issue --- ui/app/conversion-util.js | 2 +- ui/app/conversion-util.test.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 ui/app/conversion-util.test.js diff --git a/ui/app/conversion-util.js b/ui/app/conversion-util.js index 100402d95..90c2226e7 100644 --- a/ui/app/conversion-util.js +++ b/ui/app/conversion-util.js @@ -140,7 +140,7 @@ const addCurrencies = (a, b, options = {}) => { bBase, ...conversionOptions } = options - const value = (new BigNumber(a, aBase)).add(b, bBase) + const value = (new BigNumber(a.toString(), aBase)).add(b.toString(), bBase) return converter({ value, diff --git a/ui/app/conversion-util.test.js b/ui/app/conversion-util.test.js new file mode 100644 index 000000000..c37264855 --- /dev/null +++ b/ui/app/conversion-util.test.js @@ -0,0 +1,23 @@ +import assert from 'assert' +import {addCurrencies} from './conversion-util' + + + +describe('conversion utils', () => { + describe.only('addCurrencies()', () => { + it('add whole numbers', () => { + const result = addCurrencies(3, 5) + assert.equal(result.toNumber(), 8) + }) + + it('add decimals', () => { + const result = addCurrencies(1.3, 1.5) + assert.equal(result.toNumber(), 2.8) + }) + + it('add repeating decimals', () => { + const result = addCurrencies(1/3, 1/7) + assert.equal(result.toNumber(), 0.47619047619047616) + }) + }) +}) -- cgit From 0d0120746d93c9b329bcd57f3819fd39903e6ece Mon Sep 17 00:00:00 2001 From: trejgun Date: Sun, 24 Jun 2018 17:51:31 +0800 Subject: remove .only --- ui/app/conversion-util.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/conversion-util.test.js b/ui/app/conversion-util.test.js index c37264855..51dcd1ece 100644 --- a/ui/app/conversion-util.test.js +++ b/ui/app/conversion-util.test.js @@ -4,7 +4,7 @@ import {addCurrencies} from './conversion-util' describe('conversion utils', () => { - describe.only('addCurrencies()', () => { + describe('addCurrencies()', () => { it('add whole numbers', () => { const result = addCurrencies(3, 5) assert.equal(result.toNumber(), 8) -- cgit From 74080e41f11b7bc2668ffdb42404d940139b68a8 Mon Sep 17 00:00:00 2001 From: trejgun Date: Sun, 24 Jun 2018 17:56:07 +0800 Subject: change numbers --- ui/app/conversion-util.test.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ui/app/conversion-util.test.js b/ui/app/conversion-util.test.js index 51dcd1ece..d956998a1 100644 --- a/ui/app/conversion-util.test.js +++ b/ui/app/conversion-util.test.js @@ -2,22 +2,21 @@ import assert from 'assert' import {addCurrencies} from './conversion-util' - describe('conversion utils', () => { describe('addCurrencies()', () => { it('add whole numbers', () => { - const result = addCurrencies(3, 5) - assert.equal(result.toNumber(), 8) + const result = addCurrencies(3, 9) + assert.equal(result.toNumber(), 12) }) it('add decimals', () => { - const result = addCurrencies(1.3, 1.5) - assert.equal(result.toNumber(), 2.8) + const result = addCurrencies(1.3, 1.9) + assert.equal(result.toNumber(), 3.2) }) it('add repeating decimals', () => { - const result = addCurrencies(1/3, 1/7) - assert.equal(result.toNumber(), 0.47619047619047616) + const result = addCurrencies(1/3, 1/9) + assert.equal(result.toNumber(), 0.4444444444444444) }) }) }) -- cgit From 75581ceebe719e102b177dc20f3b9e232c48e8a4 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 21 Jun 2018 14:57:45 -0230 Subject: Show all errors on account creation screen. --- ui/app/components/pages/create-account/import-account/json.js | 2 +- ui/app/components/pages/create-account/import-account/private-key.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/app/components/pages/create-account/import-account/json.js b/ui/app/components/pages/create-account/import-account/json.js index 1dc2ba534..955b45d74 100644 --- a/ui/app/components/pages/create-account/import-account/json.js +++ b/ui/app/components/pages/create-account/import-account/json.js @@ -114,7 +114,7 @@ class JsonImportSubview extends Component { setSelectedAddress(firstAddress) } }) - .catch(err => displayWarning(err)) + .catch(err => displayWarning(err.message || err)) } } diff --git a/ui/app/components/pages/create-account/import-account/private-key.js b/ui/app/components/pages/create-account/import-account/private-key.js index 5df3777da..0d8ff0db6 100644 --- a/ui/app/components/pages/create-account/import-account/private-key.js +++ b/ui/app/components/pages/create-account/import-account/private-key.js @@ -104,5 +104,5 @@ PrivateKeyImportView.prototype.createNewKeychain = function () { setSelectedAddress(firstAddress) } }) - .catch(err => displayWarning(err)) + .catch(err => displayWarning(err.message || err)) } -- cgit From 03f17d910a17abe3fe8c8dae2ef38a66bb86f222 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 21 Jun 2018 15:53:26 -0230 Subject: Check that error is defined in import-account error catch. --- ui/app/components/pages/create-account/import-account/json.js | 2 +- ui/app/components/pages/create-account/import-account/private-key.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/app/components/pages/create-account/import-account/json.js b/ui/app/components/pages/create-account/import-account/json.js index 955b45d74..c9d14be5f 100644 --- a/ui/app/components/pages/create-account/import-account/json.js +++ b/ui/app/components/pages/create-account/import-account/json.js @@ -114,7 +114,7 @@ class JsonImportSubview extends Component { setSelectedAddress(firstAddress) } }) - .catch(err => displayWarning(err.message || err)) + .catch(err => err && displayWarning(err.message || err)) } } diff --git a/ui/app/components/pages/create-account/import-account/private-key.js b/ui/app/components/pages/create-account/import-account/private-key.js index 0d8ff0db6..c38c39206 100644 --- a/ui/app/components/pages/create-account/import-account/private-key.js +++ b/ui/app/components/pages/create-account/import-account/private-key.js @@ -104,5 +104,5 @@ PrivateKeyImportView.prototype.createNewKeychain = function () { setSelectedAddress(firstAddress) } }) - .catch(err => displayWarning(err.message || err)) + .catch(err => err && displayWarning(err.message || err)) } -- cgit From a6f1734eddb934ce63384951305f86697ba88983 Mon Sep 17 00:00:00 2001 From: trejgun Date: Fri, 29 Jun 2018 16:19:45 +0800 Subject: lint --- ui/app/conversion-util.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/conversion-util.test.js b/ui/app/conversion-util.test.js index d956998a1..368ce3bba 100644 --- a/ui/app/conversion-util.test.js +++ b/ui/app/conversion-util.test.js @@ -15,7 +15,7 @@ describe('conversion utils', () => { }) it('add repeating decimals', () => { - const result = addCurrencies(1/3, 1/9) + const result = addCurrencies(1 / 3, 1 / 9) assert.equal(result.toNumber(), 0.4444444444444444) }) }) -- cgit From 491f2d03cfd790e4246a9fa638a2eecb07a6488a Mon Sep 17 00:00:00 2001 From: trejgun Date: Mon, 2 Jul 2018 09:36:57 +0800 Subject: move removeLeadingZeroes to utils, add test --- ui/app/components/send/currency-display.js | 5 +---- ui/app/components/send_/send.utils.js | 5 +++++ ui/app/components/send_/send.utils.test.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 ui/app/components/send_/send.utils.test.js diff --git a/ui/app/components/send/currency-display.js b/ui/app/components/send/currency-display.js index e410bc070..897ebad84 100644 --- a/ui/app/components/send/currency-display.js +++ b/ui/app/components/send/currency-display.js @@ -2,6 +2,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits const { conversionUtil, multiplyCurrencies } = require('../../conversion-util') +const { removeLeadingZeroes } = require('../send_/send.utils') const currencyFormatter = require('currency-formatter') const currencies = require('currency-formatter/currencies') const ethUtil = require('ethereumjs-util') @@ -92,10 +93,6 @@ CurrencyDisplay.prototype.getConvertedValueToRender = function (nonFormattedValu : convertedValue } -function removeLeadingZeroes (str) { - return str.replace(/^0*(?=\d)/, '') -} - CurrencyDisplay.prototype.handleChange = function (newVal) { this.setState({ valueToRender: removeLeadingZeroes(newVal) }) this.props.onChange(this.getAmount(newVal)) diff --git a/ui/app/components/send_/send.utils.js b/ui/app/components/send_/send.utils.js index dfd459731..313465fed 100644 --- a/ui/app/components/send_/send.utils.js +++ b/ui/app/components/send_/send.utils.js @@ -32,6 +32,7 @@ module.exports = { getToAddressForGasUpdate, isBalanceSufficient, isTokenBalanceSufficient, + removeLeadingZeroes, } function calcGasTotal (gasLimit, gasPrice) { @@ -273,3 +274,7 @@ function estimateGasPriceFromRecentBlocks (recentBlocks) { function getToAddressForGasUpdate (...addresses) { return [...addresses, ''].find(str => str !== undefined && str !== null).toLowerCase() } + +function removeLeadingZeroes (str) { + return str.replace(/^0*(?=\d)/, '') +} diff --git a/ui/app/components/send_/send.utils.test.js b/ui/app/components/send_/send.utils.test.js new file mode 100644 index 000000000..36f3a5c10 --- /dev/null +++ b/ui/app/components/send_/send.utils.test.js @@ -0,0 +1,30 @@ +import assert from 'assert' +import { removeLeadingZeroes } from './send.utils' + + +describe('send utils', () => { + describe('removeLeadingZeroes()', () => { + it('should remove leading zeroes from int when user types', () => { + assert.equal(removeLeadingZeroes('0'), '0') + assert.equal(removeLeadingZeroes('1'), '1') + assert.equal(removeLeadingZeroes('00'), '0') + assert.equal(removeLeadingZeroes('01'), '1') + }) + + it('should remove leading zeroes from int when user copy/paste', () => { + assert.equal(removeLeadingZeroes('001'), '1') + }) + + it('should remove leading zeroes from float when user types', () => { + assert.equal(removeLeadingZeroes('0.'), '0.') + assert.equal(removeLeadingZeroes('0.0'), '0.0') + assert.equal(removeLeadingZeroes('0.00'), '0.00') + assert.equal(removeLeadingZeroes('0.001'), '0.001') + assert.equal(removeLeadingZeroes('0.10'), '0.10') + }) + + it('should remove leading zeroes from float when user copy/paste', () => { + assert.equal(removeLeadingZeroes('00.1'), '0.1') + }) + }) +}) -- cgit From d126887bc3a795d27f54a4ca5178503e522d41d9 Mon Sep 17 00:00:00 2001 From: Sara Reynolds Date: Tue, 3 Jul 2018 09:47:30 -0700 Subject: fixes 4663 --- ui/app/components/pages/create-account/import-account/json.js | 1 + ui/app/components/pages/create-account/import-account/private-key.js | 1 + 2 files changed, 2 insertions(+) diff --git a/ui/app/components/pages/create-account/import-account/json.js b/ui/app/components/pages/create-account/import-account/json.js index 1dc2ba534..453fceb83 100644 --- a/ui/app/components/pages/create-account/import-account/json.js +++ b/ui/app/components/pages/create-account/import-account/json.js @@ -109,6 +109,7 @@ class JsonImportSubview extends Component { .then(({ selectedAddress }) => { if (selectedAddress) { history.push(DEFAULT_ROUTE) + displayWarning(null) } else { displayWarning('Error importing account.') setSelectedAddress(firstAddress) diff --git a/ui/app/components/pages/create-account/import-account/private-key.js b/ui/app/components/pages/create-account/import-account/private-key.js index 5df3777da..7a470c2ad 100644 --- a/ui/app/components/pages/create-account/import-account/private-key.js +++ b/ui/app/components/pages/create-account/import-account/private-key.js @@ -99,6 +99,7 @@ PrivateKeyImportView.prototype.createNewKeychain = function () { .then(({ selectedAddress }) => { if (selectedAddress) { history.push(DEFAULT_ROUTE) + displayWarning(null) } else { displayWarning('Error importing account.') setSelectedAddress(firstAddress) -- cgit From badf0ce3142b97631dc2ba559a68005258625026 Mon Sep 17 00:00:00 2001 From: bitpshr Date: Tue, 3 Jul 2018 13:20:05 -0400 Subject: Conditionally use Promise-based extension API when creating windows --- app/scripts/lib/notification-manager.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/scripts/lib/notification-manager.js b/app/scripts/lib/notification-manager.js index 6b88a7a99..969a9459a 100644 --- a/app/scripts/lib/notification-manager.js +++ b/app/scripts/lib/notification-manager.js @@ -26,15 +26,15 @@ class NotificationManager { // bring focus to existing chrome popup extension.windows.update(popup.id, { focused: true }) } else { + const cb = (currentPopup) => { this._popupId = currentPopup.id } // create new notification popup - extension.windows.create({ + const creation = extension.windows.create({ url: 'notification.html', type: 'popup', width, height, - }).then((currentPopup) => { - this._popupId = currentPopup.id - }) + }, cb) + creation && creation.then && creation.then(cb) } }) } -- cgit From 160bc4daa4567bcc89b7a52fb1dcef2d1d8c18e8 Mon Sep 17 00:00:00 2001 From: brunobar79 Date: Tue, 3 Jul 2018 13:46:38 -0400 Subject: ignore lodash vulnerability --- .nsprc | 3 ++- package-lock.json | 20 +++++++------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.nsprc b/.nsprc index cb37fad49..bd3a4f039 100644 --- a/.nsprc +++ b/.nsprc @@ -1,6 +1,7 @@ { "exceptions": [ "https://nodesecurity.io/advisories/566", - "https://nodesecurity.io/advisories/157" + "https://nodesecurity.io/advisories/157", + "https://nodesecurity.io/advisories/577" ] } diff --git a/package-lock.json b/package-lock.json index 5c05bad5e..f27288f92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8548,13 +8548,12 @@ "resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz", "integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=", "requires": { - "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#4ea2fdfed09e8f99117d9362d17c6b01b64a2bcf", "ethereumjs-util": "^5.1.1" }, "dependencies": { "ethereumjs-abi": { "version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#4ea2fdfed09e8f99117d9362d17c6b01b64a2bcf", - "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git", + "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#4ea2fdfed09e8f99117d9362d17c6b01b64a2bcf", "requires": { "bn.js": "^4.10.0", "ethereumjs-util": "^5.0.0" @@ -20200,7 +20199,7 @@ "requires": { "async": "^1.3.0", "flat-arguments": "^1.0.0", - "lodash": "^4.17.5", + "lodash": "^3.10.0", "minimist": "^1.1.0" }, "dependencies": { @@ -20210,7 +20209,7 @@ "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" }, "lodash": { - "version": "4.17.5", + "version": "3.10.1", "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=" } @@ -30585,7 +30584,6 @@ "version": "3.1.5", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", - "dev": true, "requires": { "is-typedarray": "^1.0.0" } @@ -31609,7 +31607,6 @@ "resolved": "https://registry.npmjs.org/web3/-/web3-0.20.3.tgz", "integrity": "sha1-yqRDc9yIFayHZ73ba6cwc5ZMqos=", "requires": { - "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", "crypto-js": "^3.1.4", "utf8": "^2.1.1", "xhr2": "*", @@ -31618,7 +31615,7 @@ "dependencies": { "bignumber.js": { "version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", - "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git" + "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934" } } }, @@ -32117,8 +32114,7 @@ "dev": true, "requires": { "underscore": "1.8.3", - "web3-core-helpers": "1.0.0-beta.34", - "websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2" + "web3-core-helpers": "1.0.0-beta.34" }, "dependencies": { "underscore": { @@ -32129,8 +32125,7 @@ }, "websocket": { "version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2", - "from": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible", - "dev": true, + "from": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2", "requires": { "debug": "^2.2.0", "nan": "^2.3.3", @@ -33486,8 +33481,7 @@ "yaeti": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", - "integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=", - "dev": true + "integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=" }, "yallist": { "version": "2.1.2", -- cgit