Browse Source

Merge pull request #649 from KhalilBellakrid/develop

Fix hard reset which is async now, update ledger-core to 2.0.0-rc.2
master
Meriadec Pillet 7 years ago
committed by GitHub
parent
commit
9c17c64f46
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      package.json
  2. 19
      src/commands/libcoreHardReset.js
  3. 4
      src/helpers/hardReset.js
  4. 1
      static/i18n/en/errors.yml

2
package.json

@ -41,7 +41,7 @@
"@ledgerhq/hw-app-xrp": "^4.13.0", "@ledgerhq/hw-app-xrp": "^4.13.0",
"@ledgerhq/hw-transport": "^4.13.0", "@ledgerhq/hw-transport": "^4.13.0",
"@ledgerhq/hw-transport-node-hid": "^4.13.0", "@ledgerhq/hw-transport-node-hid": "^4.13.0",
"@ledgerhq/ledger-core": "2.0.0-rc.1", "@ledgerhq/ledger-core": "2.0.0-rc.3",
"@ledgerhq/live-common": "2.31.0", "@ledgerhq/live-common": "2.31.0",
"async": "^2.6.1", "async": "^2.6.1",
"axios": "^0.18.0", "axios": "^0.18.0",

19
src/commands/libcoreHardReset.js

@ -1,20 +1,21 @@
// @flow // @flow
import { createCommand } from 'helpers/ipc' import { createCommand } from 'helpers/ipc'
import { Observable } from 'rxjs' import { fromPromise } from 'rxjs/observable/fromPromise'
import withLibcore from 'helpers/withLibcore' import withLibcore from 'helpers/withLibcore'
import createCustomErrorClass from 'helpers/createCustomErrorClass'
const HardResetFail = createCustomErrorClass('HardResetFail')
const cmd = createCommand('libcoreHardReset', () => const cmd = createCommand('libcoreHardReset', () =>
Observable.create(o => { fromPromise(
withLibcore(async core => { withLibcore(async core => {
try { const result = await core.getPoolInstance().eraseDataSince(new Date(0))
core.getPoolInstance().eraseDataSince(new Date(0)) if (result !== core.ERROR_CODE.FUTURE_WAS_SUCCESSFULL) {
o.complete() throw new HardResetFail(`Hard reset fail with ${result} (check core.ERROR_CODE)`)
} catch (e) {
o.error(e)
} }
}) }),
}), ),
) )
export default cmd export default cmd

4
src/helpers/hardReset.js

@ -5,9 +5,7 @@ import db from 'helpers/db'
import { delay } from 'helpers/promise' import { delay } from 'helpers/promise'
export default async function hardReset() { export default async function hardReset() {
// TODO: wait for the libcoreHardReset to be finished await libcoreHardReset.send()
// actually, libcore doesnt goes back to js thread
await Promise.race([libcoreHardReset.send().toPromise(), delay(500)])
disableDBMiddleware() disableDBMiddleware()
db.resetAll() db.resetAll()
await delay(500) await delay(500)

1
static/i18n/en/errors.yml

@ -20,3 +20,4 @@ DeviceSocketFail: Device socket failure
DeviceSocketNoBulkStatus: Device socket failure (bulk) DeviceSocketNoBulkStatus: Device socket failure (bulk)
DeviceSocketNoHandler: Device socket failure (handler {{query}}) DeviceSocketNoHandler: Device socket failure (handler {{query}})
LatestMCUInstalledError: The latest MCU is already installed on the Device LatestMCUInstalledError: The latest MCU is already installed on the Device
HardResetFail: Hard reset failure

Loading…
Cancel
Save