How to use the xpring-common-js.Utils.isValidXAddress function in xpring-common-js

To help you get started, we’ve selected a few xpring-common-js 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 xpring-eng / Xpring-JS / src / default-xpring-client.ts View on Github external
public async getBalance(address: string): Promise {
    if (!Utils.isValidXAddress(address)) {
      return Promise.reject(
        new Error(XpringClientErrorMessages.xAddressRequired)
      );
    }

    return this.getAccountInfo(address).then(async accountInfo => {
      const balance = accountInfo.getBalance();
      if (balance === undefined) {
        return Promise.reject(
          new Error(XpringClientErrorMessages.malformedResponse)
        );
      }

      return BigInt(balance.getDrops());
    });
  }
github xpring-eng / Xpring-JS / src / default-xpring-client.ts View on Github external
public async send(
    amount: BigInt | number | string,
    destination: string,
    sender: Wallet
  ): Promise {
    if (!Utils.isValidXAddress(destination)) {
      return Promise.reject(
        new Error(XpringClientErrorMessages.xAddressRequired)
      );
    }

    const normalizedAmount = this.toBigInt(amount);

    return this.getFee().then(async fee => {
      return this.getAccountInfo(sender.getAddress()).then(
        async accountInfo => {
          return this.getLastValidatedLedgerSequence().then(
            async ledgerSequence => {
              if (accountInfo.getSequence() === undefined) {
                return Promise.reject(
                  new Error(XpringClientErrorMessages.malformedResponse)
                );