From b463e4bf53c7478dc7619bd561fd81bf00178169 Mon Sep 17 00:00:00 2001 From: meriadec Date: Tue, 29 May 2018 18:56:53 +0200 Subject: [PATCH] Create libcoreSyncAccount command --- src/commands/libcoreSyncAccount.js | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/commands/libcoreSyncAccount.js diff --git a/src/commands/libcoreSyncAccount.js b/src/commands/libcoreSyncAccount.js new file mode 100644 index 00000000..b091e575 --- /dev/null +++ b/src/commands/libcoreSyncAccount.js @@ -0,0 +1,37 @@ +// @flow + +import type { AccountRaw } from '@ledgerhq/live-common/lib/types' +import { createCommand, Command } from 'helpers/ipc' +import { Observable } from 'rxjs' +import { syncAccount } from 'helpers/libcore' + +type Input = { + rawAccount: AccountRaw, +} + +type Result = AccountRaw + +const cmd: Command = createCommand( + 'accounts', + 'libcoreSyncAccount', + ({ rawAccount }) => + Observable.create(o => { + // TODO scanAccountsOnDevice should directly return a Observable so we just have to pass-in + syncAccount({ rawAccount }).then( + () => { + o.complete() + }, + e => { + o.error(e) + }, + ) + + function unsubscribe() { + // FIXME not implemented + } + + return unsubscribe + }), +) + +export default cmd