4 changed files with 52 additions and 24 deletions
@ -1,37 +1,21 @@ |
|||
// @flow
|
|||
|
|||
import type { AccountRaw } from '@ledgerhq/live-common/lib/types' |
|||
import { fromPromise } from 'rxjs/observable/fromPromise' |
|||
|
|||
import { createCommand, Command } from 'helpers/ipc' |
|||
import { Observable } from 'rxjs' |
|||
import { syncAccount } from 'helpers/libcore' |
|||
import withLibcore from 'helpers/withLibcore' |
|||
|
|||
type Input = { |
|||
core: Object, |
|||
rawAccount: AccountRaw, |
|||
} |
|||
|
|||
type Result = AccountRaw |
|||
|
|||
const cmd: Command<Input, Result> = 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 |
|||
}), |
|||
const cmd: Command<Input, Result> = createCommand('libcoreSyncAccount', ({ rawAccount }) => |
|||
fromPromise(withLibcore(core => syncAccount({ rawAccount, core }))), |
|||
) |
|||
|
|||
export default cmd |
|||
|
Loading…
Reference in new issue