From d575ae9eea9694da5c84ccfed220d59eddeef273 Mon Sep 17 00:00:00 2001 From: meriadec Date: Wed, 23 May 2018 11:11:09 +0200 Subject: [PATCH] Flow and feedback fixes --- package.json | 4 ++-- src/bridge/EthereumJSBridge.js | 8 ++++---- src/components/DeviceCheckAddress.js | 17 +++++++++++++++-- yarn.lock | 12 ++++++------ 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index b6ec1bed..29965f00 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@ledgerhq/hw-transport": "^4.12.0", "@ledgerhq/hw-transport-node-hid": "^4.12.0", "@ledgerhq/ledger-core": "^1.0.1", - "@ledgerhq/live-common": "^2.7.2", + "@ledgerhq/live-common": "^2.7.5", "axios": "^0.18.0", "babel-runtime": "^6.26.0", "bcryptjs": "^2.4.3", @@ -83,7 +83,7 @@ "redux-thunk": "^2.2.0", "reselect": "^3.0.1", "rxjs": "^6.2.0", - "rxjs-compat": "^6.2.0", + "rxjs-compat": "^6.1.0", "smooth-scrollbar": "^8.2.7", "source-map": "0.7.2", "source-map-support": "^0.5.4", diff --git a/src/bridge/EthereumJSBridge.js b/src/bridge/EthereumJSBridge.js index 794d617b..4f820111 100644 --- a/src/bridge/EthereumJSBridge.js +++ b/src/bridge/EthereumJSBridge.js @@ -97,12 +97,12 @@ const EthereumBridge: WalletBridge = { const account: Account = { id: accountId, xpub: '', - path, + path, // FIXME we probably not want the address path in the account.path walletPath: String(index), name: 'New Account', isSegwit: false, address, - addresses: [address], + addresses: [{ str: address, path, }], balance, blockHeight: currentBlock.height, archived: true, @@ -128,12 +128,12 @@ const EthereumBridge: WalletBridge = { const account: Account = { id: accountId, xpub: '', - path, + path, // FIXME we probably not want the address path in the account.path walletPath: String(index), name: address.slice(32), isSegwit: false, address, - addresses: [address], + addresses: [{ str: address, path, }], balance, blockHeight: currentBlock.height, archived: true, diff --git a/src/components/DeviceCheckAddress.js b/src/components/DeviceCheckAddress.js index 84a6ec78..0ee2a324 100644 --- a/src/components/DeviceCheckAddress.js +++ b/src/components/DeviceCheckAddress.js @@ -27,6 +27,19 @@ class CheckAddress extends PureComponent { this.verifyAddress({ device, account }) } + componentWillUnmount() { + this._isUnmounted = true + } + + _isUnmounted = false + + safeSetState = (...args: *) => { + if (this._isUnmounted) { + return + } + this.setState(...args) + } + verifyAddress = async ({ device, account }: { device: Device, account: Account }) => { try { // TODO: this will work only for BTC-like accounts @@ -49,10 +62,10 @@ class CheckAddress extends PureComponent { throw new Error('Confirmed address is different') } - this.setState({ isVerified: true }) + this.safeSetState({ isVerified: true }) this.props.onCheck(true) } catch (err) { - this.setState({ isVerified: false }) + this.safeSetState({ isVerified: false }) this.props.onCheck(false) } } diff --git a/yarn.lock b/yarn.lock index cc07b02a..f3e7fa88 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1473,9 +1473,9 @@ npm "^5.7.1" prebuild-install "^2.2.2" -"@ledgerhq/live-common@^2.7.2": - version "2.7.2" - resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-2.7.2.tgz#abfa71428c186220006d35baca44261a1c3ef9ed" +"@ledgerhq/live-common@^2.7.5": + version "2.7.5" + resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-2.7.5.tgz#5434bf2e708aaca471be4ca823e613cf27ba700c" dependencies: axios "^0.18.0" invariant "^2.2.2" @@ -12051,9 +12051,9 @@ rx@2.3.24: version "2.3.24" resolved "https://registry.yarnpkg.com/rx/-/rx-2.3.24.tgz#14f950a4217d7e35daa71bbcbe58eff68ea4b2b7" -rxjs-compat@^6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/rxjs-compat/-/rxjs-compat-6.2.0.tgz#2eb49cc6ac20d0d7057c6887d1895beaab0966f9" +rxjs-compat@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/rxjs-compat/-/rxjs-compat-6.1.0.tgz#935059623ee4c167728c9dd03ee6e4468cc5b583" rxjs@^5.1.1, rxjs@^5.4.2, rxjs@^5.5.2: version "5.5.10"