Browse Source

Fix hard reset which is async now, update ledger-core to 2.0.0-rc.2

master
KhalilBellakrid 7 years ago
parent
commit
3b7642e1ec
  1. 2
      package.json
  2. 10
      src/commands/libcoreHardReset.js
  3. 3
      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.2",
"@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",

10
src/commands/libcoreHardReset.js

@ -3,15 +3,15 @@
import { createCommand } from 'helpers/ipc' import { createCommand } from 'helpers/ipc'
import { Observable } from 'rxjs' import { Observable } from 'rxjs'
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 => { Observable.create(o => {
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)
} }
}) })
}), }),

3
src/helpers/hardReset.js

@ -7,7 +7,8 @@ import { delay } from 'helpers/promise'
export default async function hardReset() { export default async function hardReset() {
// TODO: wait for the libcoreHardReset to be finished // TODO: wait for the libcoreHardReset to be finished
// actually, libcore doesnt goes back to js thread // actually, libcore doesnt goes back to js thread
await Promise.race([libcoreHardReset.send().toPromise(), delay(500)]) await libcoreHardReset.send()
//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