|
@ -10,7 +10,7 @@ import type { NJSAccount, NJSOperation } from '@ledgerhq/ledger-core/src/ledgerc |
|
|
import * as accountIdHelper from 'helpers/accountId' |
|
|
import * as accountIdHelper from 'helpers/accountId' |
|
|
|
|
|
|
|
|
type Props = { |
|
|
type Props = { |
|
|
core: Object, |
|
|
core: *, |
|
|
devicePath: string, |
|
|
devicePath: string, |
|
|
currencyId: string, |
|
|
currencyId: string, |
|
|
onAccountScanned: AccountRaw => void, |
|
|
onAccountScanned: AccountRaw => void, |
|
@ -82,7 +82,7 @@ async function scanAccountsOnDeviceBySegwit({ |
|
|
isSegwit, |
|
|
isSegwit, |
|
|
showNewAccount, |
|
|
showNewAccount, |
|
|
}: { |
|
|
}: { |
|
|
core: Object, |
|
|
core: *, |
|
|
hwApp: Object, |
|
|
hwApp: Object, |
|
|
currencyId: string, |
|
|
currencyId: string, |
|
|
onAccountScanned: AccountRaw => void, |
|
|
onAccountScanned: AccountRaw => void, |
|
@ -118,7 +118,7 @@ async function scanAccountsOnDeviceBySegwit({ |
|
|
async function scanNextAccount(props: { |
|
|
async function scanNextAccount(props: { |
|
|
// $FlowFixMe
|
|
|
// $FlowFixMe
|
|
|
wallet: NJSWallet, |
|
|
wallet: NJSWallet, |
|
|
core: Object, |
|
|
core: *, |
|
|
hwApp: Object, |
|
|
hwApp: Object, |
|
|
currencyId: string, |
|
|
currencyId: string, |
|
|
accountsCount: number, |
|
|
accountsCount: number, |
|
@ -183,7 +183,7 @@ async function scanNextAccount(props: { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function getOrCreateWallet( |
|
|
async function getOrCreateWallet( |
|
|
core: Object, |
|
|
core: *, |
|
|
WALLET_IDENTIFIER: string, |
|
|
WALLET_IDENTIFIER: string, |
|
|
currencyId: string, |
|
|
currencyId: string, |
|
|
isSegwit: boolean, |
|
|
isSegwit: boolean, |
|
@ -220,7 +220,7 @@ async function buildAccountRaw({ |
|
|
wallet: NJSWallet, |
|
|
wallet: NJSWallet, |
|
|
currencyId: string, |
|
|
currencyId: string, |
|
|
accountIndex: number, |
|
|
accountIndex: number, |
|
|
core: Object, |
|
|
core: *, |
|
|
// $FlowFixMe
|
|
|
// $FlowFixMe
|
|
|
ops: NJSOperation[], |
|
|
ops: NJSOperation[], |
|
|
}): Promise<AccountRaw> { |
|
|
}): Promise<AccountRaw> { |
|
@ -262,7 +262,12 @@ async function buildAccountRaw({ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const rawAccount: AccountRaw = { |
|
|
const rawAccount: AccountRaw = { |
|
|
id: accountIdHelper.encode({ type: 'libcore', xpub, walletName: wallet.getName() }), |
|
|
id: accountIdHelper.encode({ |
|
|
|
|
|
type: 'libcore', |
|
|
|
|
|
version: '1', |
|
|
|
|
|
xpub, |
|
|
|
|
|
walletName: wallet.getName(), |
|
|
|
|
|
}), |
|
|
xpub, |
|
|
xpub, |
|
|
path: walletPath, |
|
|
path: walletPath, |
|
|
name, |
|
|
name, |
|
@ -288,7 +293,7 @@ function buildOperationRaw({ |
|
|
op, |
|
|
op, |
|
|
xpub, |
|
|
xpub, |
|
|
}: { |
|
|
}: { |
|
|
core: Object, |
|
|
core: *, |
|
|
op: NJSOperation, |
|
|
op: NJSOperation, |
|
|
xpub: string, |
|
|
xpub: string, |
|
|
}): OperationRaw { |
|
|
}): OperationRaw { |
|
@ -322,15 +327,15 @@ function buildOperationRaw({ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export async function getNJSAccount({ |
|
|
export async function getNJSAccount({ |
|
|
account, |
|
|
accountRaw, |
|
|
njsWalletPool, |
|
|
njsWalletPool, |
|
|
}: { |
|
|
}: { |
|
|
accountId: string, |
|
|
accountRaw: AccountRaw, |
|
|
njsWalletPool: any, |
|
|
njsWalletPool: *, |
|
|
}) { |
|
|
}) { |
|
|
const decodedAccountId = accountIdHelper.decode(account.id) |
|
|
const decodedAccountId = accountIdHelper.decode(accountRaw.id) |
|
|
const njsWallet = await njsWalletPool.getWallet(decodedAccountId.walletName) |
|
|
const njsWallet = await njsWalletPool.getWallet(decodedAccountId.walletName) |
|
|
const njsAccount = await njsWallet.getAccount(account.index) |
|
|
const njsAccount = await njsWallet.getAccount(accountRaw.index) |
|
|
return njsAccount |
|
|
return njsAccount |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -339,9 +344,9 @@ export async function syncAccount({ |
|
|
core, |
|
|
core, |
|
|
njsWalletPool, |
|
|
njsWalletPool, |
|
|
}: { |
|
|
}: { |
|
|
core: Object, |
|
|
core: *, |
|
|
rawAccount: AccountRaw, |
|
|
rawAccount: AccountRaw, |
|
|
njsWalletPool: Object, |
|
|
njsWalletPool: *, |
|
|
}) { |
|
|
}) { |
|
|
const decodedAccountId = accountIdHelper.decode(rawAccount.id) |
|
|
const decodedAccountId = accountIdHelper.decode(rawAccount.id) |
|
|
const njsWallet = await njsWalletPool.getWallet(decodedAccountId.walletName) |
|
|
const njsWallet = await njsWalletPool.getWallet(decodedAccountId.walletName) |
|
|