Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
coreOperations.length === 0
? getNewAccountPlaceholderName({
currency,
index: accountIndex,
derivationMode,
})
: getAccountPlaceholderName({
currency,
index: accountIndex,
derivationMode,
});
// retrieve xpub
const xpub = await coreAccount.getRestoreKey();
const accountId = encodeAccountId({
type: "libcore",
version: "1",
currencyId: currency.id,
xpubOrAddress: xpub,
derivationMode,
});
// build operations with the minimal diff & call to libcore possible
let operations = [];
let existingOps = existingOperations;
let immutableOpCmpDoneOnce = false;
for (let i = coreOperations.length - 1; i >= 0; i--) {
const coreOperation = coreOperations[i];
const newOp = await buildOperation({
core,
coreOperations.length === 0
? getNewAccountPlaceholderName({
currency,
index: accountIndex,
derivationMode,
})
: getAccountPlaceholderName({
currency,
index: accountIndex,
derivationMode,
});
// retrieve xpub
const { value: xpub } = await core.coreAccount.getRestoreKey(coreAccount);
const id = encodeAccountId({
type: "libcore",
version: "1",
currencyId: currency.id,
xpubOrAddress: xpub,
derivationMode,
});
// build operations
const operations = await Promise.all(
coreOperations.map(coreOperation =>
buildOperation({
core,
coreOperation,
accountId: id,
}),
),
xpubArray.map(xpub => {
const account: $Exact = {
type: "Account",
name:
cur.name +
" " +
(derivationMode || "legacy") +
" " +
shortAddressPreview(xpub),
xpub,
seedIdentifier: xpub,
id: encodeAccountId({
type: getEnv("BRIDGE_FORCE_IMPLEMENTATION") || "libcore",
version: "1",
currencyId: cur.id,
xpubOrAddress: xpub,
derivationMode: asDerivationMode(derivationMode || "")
}),
derivationMode: asDerivationMode(derivationMode),
currency: cur,
unit: cur.units[0],
index: 0,
freshAddress: xpub, // HACK for JS impl force mode that would only support address version
freshAddressPath: "",
freshAddresses: [],
lastSyncDate: new Date(0),
blockHeight: 0,
balance: new BigNumber(0),
implementations.forEach(impl => {
const account = fromAccountRaw({
...accountData.raw,
id: encodeAccountId({
...decodeAccountId(accountData.raw.id),
type: impl
})
});
accountsRelated.push({
currencyData,
accountData,
account,
impl
});
})
);
ops.sort((a, b) => b.getDate() - a.getDate())
const operations = ops.map(op => buildOperationRaw({ core, op, xpub }))
const name =
operations.length === 0
? getNewAccountPlaceholderName({ currency, index: accountIndex, derivationMode })
: getAccountPlaceholderName({
currency,
index: accountIndex,
derivationMode,
})
const rawAccount: AccountRaw = {
id: encodeAccountId({
type: 'libcore',
version: '1',
currencyId: currency.id,
xpubOrAddress: xpub,
derivationMode,
}),
seedIdentifier,
derivationMode,
xpub,
path: walletPath,
name,
freshAddress,
freshAddressPath,
balance,
blockHeight,
archived: false,