How to use the @hathor/wallet-lib.errors function in @hathor/wallet-lib

To help you get started, we’ve selected a few @hathor/wallet-lib 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 HathorNetwork / hathor-wallet / src / screens / SendTokens.js View on Github external
if (!isValid) return;
    let data = this.getData();
    if (!data) return;
    data.tokens = hathorLib.tokens.filterTokens(this.state.txTokens, hathorLib.constants.HATHOR_TOKEN_CONFIG).map((token) => token.uid);
    this.setState({ errorMessage: '', loading: true });
    try {
      const promise = hathorLib.transaction.sendTransaction(data, this.state.pin);
      promise.then(() => {
        // Must update the shared address, in case we have used one for the change
        wallet.updateSharedAddress();
        this.props.history.push('/wallet/');
      }, (message) => {
        this.setState({ errorMessage: message, loading: false });
      });
    } catch(e) {
      if (e instanceof hathorLib.errors.AddressError || e instanceof hathorLib.errors.OutputValueError) {
        this.setState({ errorMessage: e.message, loading: false });
      } else {
        // Unhandled error
        throw e;
      }
    }
  }