How to use the @ledgerhq/live-common/lib/account.encodeAccountId function in @ledgerhq/live-common

To help you get started, we’ve selected a few @ledgerhq/live-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LedgerHQ / ledger-live-mobile / src / libcore / buildAccount.js View on Github external
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,
github LedgerHQ / ledger-live-mobile / src / libcore / index.js View on Github external
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,
      }),
    ),
github LedgerHQ / ledger-live-common / cli / src / scan.js View on Github external
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),
github LedgerHQ / ledger-live-common / cli / src / __tests__ / bridges.js View on Github external
implementations.forEach(impl => {
        const account = fromAccountRaw({
          ...accountData.raw,
          id: encodeAccountId({
            ...decodeAccountId(accountData.raw.id),
            type: impl
          })
        });
        accountsRelated.push({
          currencyData,
          accountData,
          account,
          impl
        });
      })
    );
github LedgerHQ / ledger-live-desktop / src / helpers / libcore.js View on Github external
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,