|
|
@ -1,8 +1,7 @@ |
|
|
|
// @flow
|
|
|
|
import React from 'react' |
|
|
|
import { Observable } from 'rxjs' |
|
|
|
import LRU from 'lru-cache' |
|
|
|
import { map } from 'rxjs/operators' |
|
|
|
import LRU from 'lru-cache' |
|
|
|
import type { Account } from '@ledgerhq/live-common/lib/types' |
|
|
|
import { decodeAccount, encodeAccount } from 'reducers/accounts' |
|
|
|
import FeesBitcoinKind from 'components/FeesField/BitcoinKind' |
|
|
@ -110,18 +109,10 @@ const LibcoreBridge: WalletBridge<Transaction> = { |
|
|
|
}, |
|
|
|
|
|
|
|
synchronize: account => |
|
|
|
Observable.create(o => { |
|
|
|
// FIXME TODO:
|
|
|
|
// - when you implement addPendingOperation you also here need to:
|
|
|
|
// - if there were pendingOperations that are now in operations, remove them as well.
|
|
|
|
// - if there are pendingOperations that is older than a threshold (that depends on blockchain speed typically)
|
|
|
|
// then we probably should trash them out? it's a complex question for UI
|
|
|
|
;(async () => { |
|
|
|
try { |
|
|
|
const rawAccount = encodeAccount(account) |
|
|
|
const rawSyncedAccount = await libcoreSyncAccount.send({ rawAccount }).toPromise() |
|
|
|
libcoreSyncAccount.send({ rawAccount: encodeAccount(account) }).pipe( |
|
|
|
map(rawSyncedAccount => { |
|
|
|
const syncedAccount = decodeAccount(rawSyncedAccount) |
|
|
|
o.next(account => { |
|
|
|
return account => { |
|
|
|
const accountOps = account.operations |
|
|
|
const syncedOps = syncedAccount.operations |
|
|
|
const patch: $Shape<Account> = { |
|
|
@ -150,18 +141,9 @@ const LibcoreBridge: WalletBridge<Transaction> = { |
|
|
|
...account, |
|
|
|
...patch, |
|
|
|
} |
|
|
|
}) |
|
|
|
o.complete() |
|
|
|
} catch (e) { |
|
|
|
o.error(e) |
|
|
|
} |
|
|
|
})() |
|
|
|
return { |
|
|
|
unsubscribe() { |
|
|
|
// LibcoreBridge: unsub sync not currently implemented
|
|
|
|
}, |
|
|
|
} |
|
|
|
}), |
|
|
|
), |
|
|
|
|
|
|
|
pullMoreOperations: () => Promise.reject(notImplemented), |
|
|
|
|
|
|
|