How to use the @ledgerhq/live-common/lib/account.getNewAccountPlaceholderName 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 / index.js View on Github external
);
  const [
    { value: freshAddressStr },
    { value: freshAddressPath },
  ] = await Promise.all([
    core.coreAddress.toString(coreFreshAddress),
    core.coreAddress.getDerivationPath(coreFreshAddress),
  ]);
  const freshAddress = {
    str: freshAddressStr,
    path: `${accountPath}/${freshAddressPath}`,
  };

  const name =
    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",
github LedgerHQ / ledger-live-mobile / src / libcore / buildAccount.js View on Github external
const freshAddresses = await coreAccount.getFreshPublicAddresses();
  const [coreFreshAddress] = freshAddresses;
  if (!coreFreshAddress) throw new Error("expected at least one fresh address");
  const [freshAddressStr, freshAddressPath] = await Promise.all([
    coreFreshAddress.toString(),
    coreFreshAddress.getDerivationPath(),
  ]);
  if (!freshAddressPath) throw new Error("expected freshAddressPath");
  const freshAddress = {
    str: freshAddressStr,
    path: `${accountPath}/${freshAddressPath}`,
  };

  const name =
    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",
github LedgerHQ / ledger-live-desktop / src / bridge / EthereumJSBridge.js View on Github external
if (txs.length === 0 && balance.isZero()) {
          // this is an empty account
          if (derivationMode === '') {
            // is standard derivation
            if (newAccountCount === 0) {
              // first zero account will emit one account as opportunity to create a new account..
              const account: $Exact = {
                type: 'Account',
                id: accountId,
                seedIdentifier: freshAddress,
                freshAddress,
                freshAddressPath,
                freshAddresses: [{ address: freshAddress, derivationPath: freshAddressPath }],
                derivationMode,
                name: getNewAccountPlaceholderName({
                  currency,
                  index,
                  derivationMode,
                }),
                balance,
                blockHeight: currentBlock.height,
                index,
                currency,
                operations: [],
                pendingOperations: [],
                unit: currency.units[0],
                lastSyncDate: new Date(),
              }
              return { account, complete: true }
            }
            newAccountCount++
github LedgerHQ / ledger-live-desktop / src / bridge / RippleJSBridge.js View on Github external
}
              }

              // fresh address is address. ripple never changes.
              const freshAddress = address

              if (!info) {
                // account does not exist in Ripple server
                // we are generating a new account locally
                if (derivationMode === '') {
                  o.next({
                    type: 'Account',
                    id: accountId,
                    seedIdentifier: freshAddress,
                    derivationMode,
                    name: getNewAccountPlaceholderName({
                      currency,
                      index,
                      derivationMode,
                    }),
                    freshAddress,
                    freshAddressPath,
                    freshAddresses: [{ address: freshAddress, derivationPath: freshAddressPath }],
                    balance: BigNumber(0),
                    blockHeight: maxLedgerVersion,
                    index,
                    currency,
                    operations: [],
                    pendingOperations: [],
                    unit: currency.units[0],
                    archived: false,
                    lastSyncDate: new Date(),
github LedgerHQ / ledger-live-desktop / src / helpers / libcore.js View on Github external
path: `${accountPath}/${njsAddress.getDerivationPath()}`,
  }))

  if (addresses.length === 0) {
    throw new NoAddressesFound()
  }

  const { str: freshAddress, path: freshAddressPath } = addresses[0]

  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,