How to use the @ledgerhq/errors.InvalidAddress 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 / families / ethereum / bridge / mock.js View on Github external
: BigNumber(t.amount);

  if (amount.gt(0) && estimatedFees.times(10).gt(amount)) {
    warnings.feeTooHigh = new FeeTooHigh();
  }

  // Fill up transaction errors...
  if (totalSpent.gt(account.balance)) {
    errors.amount = new NotEnoughBalance();
  }

  // Fill up recipient errors...
  if (!t.recipient) {
    errors.recipient = new RecipientRequired("");
  } else if (isInvalidRecipient(t.recipient)) {
    errors.recipient = new InvalidAddress("");
  }

  return Promise.resolve({
    errors,
    warnings,
    estimatedFees,
    amount,
    totalSpent
  });
};
github LedgerHQ / ledger-live-common / src / families / bitcoin / bridge / mock.js View on Github external
: BigNumber(t.amount);

  if (amount.gt(0) && estimatedFees.times(10).gt(amount)) {
    warnings.feeTooHigh = new FeeTooHigh();
  }

  // Fill up transaction errors...
  if (totalSpent.gt(account.balance)) {
    errors.amount = new NotEnoughBalance();
  }

  // Fill up recipient errors...
  if (!t.recipient) {
    errors.recipient = new RecipientRequired("");
  } else if (isInvalidRecipient(t.recipient)) {
    errors.recipient = new InvalidAddress("");
  }

  return Promise.resolve({
    errors,
    warnings,
    estimatedFees,
    amount,
    totalSpent
  });
};
github LedgerHQ / ledger-live-common / src / families / ripple / bridge / mock.js View on Github external
errors.amount = new NotEnoughSpendableBalance();
  } else if (
    minimalBaseAmount &&
    t.recipient.includes("new") &&
    amount.lt(minimalBaseAmount)
  ) {
    // mimic XRP base minimal for new addresses
    errors.amount = new NotEnoughBalanceBecauseDestinationNotCreated(null, {
      minimalAmount: `XRP Minimum reserve`
    });
  }

  if (!t.recipient) {
    errors.recipient = new RecipientRequired("");
  } else if (isInvalidRecipient(t.recipient)) {
    errors.recipient = new InvalidAddress("");
  } else if (a.freshAddress === t.recipient) {
    errors.recipient = new InvalidAddressBecauseDestinationIsAlsoSource();
  }

  return Promise.resolve({
    errors,
    warnings,
    estimatedFees,
    amount,
    totalSpent
  });
};
github LedgerHQ / ledger-live-common / src / families / bitcoin / test-specifics.js View on Github external
test("Lowercase recipient address should have a recipientError", async () => {
      let t = {
        ...bridge.createTransaction(account),
        recipient: "dcovduyafuefmk2qvuw5xdtaunla2lp72n"
      };
      let status = await bridge.getTransactionStatus(account, t);
      expect(status.errors.recipient).toEqual(new InvalidAddress());
    });
github LedgerHQ / ledger-live-common / src / libcore / isValidRecipient.js View on Github external
return Promise.reject(new RecipientRequired(""));
  }
  const custom = customAddressValidationByFamily[arg.currency.family];
  if (custom) {
    const res = await custom(core, arg);
    return res;
  }
  const poolInstance = core.getPoolInstance();
  const currencyCore = await poolInstance.getCurrency(currency.id);
  const value = await core.Address.isValid(recipient, currencyCore);
  if (value) {
    return Promise.resolve(null);
  }

  return Promise.reject(
    new InvalidAddress(null, { currencyName: currency.name })
  );
});
github LedgerHQ / ledger-live-common / src / bridge / LibcoreEthereumAccountBridge.js View on Github external
(account, recipient) => {
    if (!recipient)
      return Promise.reject(
        new InvalidAddress("", { currencyName: account.currency.name })
      );
    return isValidRecipient({ currency: account.currency, recipient });
  },
  (currency, recipient) => `${currency.id}_${recipient}`
github LedgerHQ / ledger-live-common / src / bridge / LibcoreBitcoinAccountBridge.js View on Github external
(account, recipient) => {
    if (!recipient)
      return Promise.reject(
        new InvalidAddress("", { currencyName: account.currency.name })
      );
    return isValidRecipient({ currency: account.currency, recipient });
  },
  (currency, recipient) => `${currency.id}_${recipient}`
github LedgerHQ / ledger-live-desktop / src / bridge / LibcoreBridge.js View on Github external
(account, recipient) => {
    if (!recipient)
      return Promise.reject(new InvalidAddress('', { currencyName: account.currency.name }))
    return libcoreValidAddress
      .send({
        address: recipient,
        currencyId: account.currency.id,
      })
      .toPromise()
  },
  (currency, recipient) => `${currency.id}_${recipient}`,
github LedgerHQ / ledger-live-mobile / src / bridge / RNLibcoreAccountBridge.js View on Github external
(account, recipient) => {
    if (!recipient)
      return Promise.reject(
        new InvalidAddress("", { currencyName: account.currency.name }),
      );
    return isValidRecipient({ currency: account.currency, recipient });
  },
  (currency, recipient) => `${currency.id}_${recipient}`,
github LedgerHQ / ledger-live-desktop / src / bridge / EthereumJSBridge.js View on Github external
checkValidRecipient: (account, recipient) =>
    isRecipientValid(account.currency, recipient)
      ? Promise.resolve(getRecipientWarning(account.currency, recipient))
      : Promise.reject(new InvalidAddress('', { currencyName: account.currency.name })),