How to use the @ledgerhq/errors.SyncError function in @ledgerhq/errors

To help you get started, we’ve selected a few @ledgerhq/errors 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-common / src / bridge / mockHelpers.js View on Github external
const sync = () => {
      if (initialAccount.name.includes("crash")) {
        o.error(new SyncError("mock failure"));
        return;
      }
      const ops = broadcasted[accountId] || [];
      broadcasted[accountId] = [];
      o.next(acc => {
        const balance = ops.reduce(
          (sum, op) => sum.plus(getOperationAmountNumber(op)),
          acc.balance
        );
        return {
          ...acc,
          blockHeight: acc.blockHeight + 1,
          lastSyncDate: new Date(),
          operations: ops.concat(acc.operations.slice(0)),
          pendingOperations: [],
          balance,
github LedgerHQ / ledger-live-common / src / bridge / makeMockBridge.js View on Github external
async function job() {
        if (Math.random() > scanAccountDeviceSuccessRate) {
          await delay(1000);
          if (!unsubscribed) o.error(new SyncError("scan failed"));
          return;
        }
        const nbAccountToGen = 3;
        for (let i = 0; i < nbAccountToGen && !unsubscribed; i++) {
          const isLast = i === 2;
          await delay(500);
          const account = genAccount(`${MOCK_DATA_SEED}_${currency.id}_${i}`, {
            operationsSize: isLast ? 0 : transactionsSizeTarget,
            currency
          });
          account.unit = currency.units[0];
          account.index = i;
          account.operations = isLast
            ? []
            : account.operations.map(operation => ({
                ...operation,
github LedgerHQ / ledger-live-common / src / libcore / syncAccount.js View on Github external
const account = await buildAccount({
      coreWallet,
      coreAccount,
      currency,
      accountIndex,
      derivationMode,
      seedIdentifier,
      existingAccount,
      logId,
      syncConfig
    });

    return account;
  } catch (e) {
    if (e.name !== "Error") throw remapLibcoreErrors(e);
    throw new SyncError(e.message);
  }
}
github LedgerHQ / ledger-live-common / src / bridge / makeMockBridge.js View on Github external
const sync = () => {
        if (initialAccount.name.includes("crash")) {
          o.error(new SyncError("mock failure"));
          return;
        }
        const ops = broadcasted[accountId] || [];
        broadcasted[accountId] = [];
        o.next(acc => {
          const account = { ...acc };
          account.lastSyncDate = new Date();
          account.blockHeight++;
          for (const op of ops) {
            account.balance = account.balance.plus(
              getOperationAmountNumber(op)
            );
            account.operations = ops.concat(
              account.operations.slice(0).reverse()
            );
            account.pendingOperations = [];