How to use the @hathor/wallet-lib.constants 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 / components / SendTokensOne.js View on Github external
getData = () => {
    let data = {'outputs': [], 'inputs': []};
    for (const output of this.outputs) {
      const address = output.current.address.current.value;
      const valueStr = output.current.value.current.value;

      if (address && valueStr) {
        // Doing the check here because need to validate before doing parseInt
        const tokensValue = valueStr*(10**hathorLib.constants.DECIMAL_PLACES);
        if (tokensValue > hathorLib.constants.MAX_OUTPUT_VALUE) {
          this.props.updateState({ errorMessage: `Token: ${this.state.selected.symbol}. Output: ${output.current.props.index}. Maximum output value is ${hathorLib.helpers.prettyValue(hathorLib.constants.MAX_OUTPUT_VALUE)}` });
          return null;
        }
        let dataOutput = {'address': address, 'value': parseInt(tokensValue, 10), 'tokenData': hathorLib.tokens.getTokenIndex(this.state.selectedTokens, this.state.selected.uid)};

        const hasTimelock = output.current.timelockCheckbox.current.checked;
        if (hasTimelock) {
          const timelock = output.current.timelock.current.value;
          if (!timelock) {
            this.props.updateState({ errorMessage: `Token: ${this.state.selected.symbol}. Output: ${output.current.props.index}. You need to fill a complete date and time` });
            return null;
          }
          const timestamp = hathorLib.dateFormatter.dateToTimestamp(new Date(timelock));
          dataOutput['timelock'] = timestamp;
        }

        data['outputs'].push(dataOutput);
github HathorNetwork / hathor-wallet / src / components / SendTokensOne.js View on Github external
getData = () => {
    let data = {'outputs': [], 'inputs': []};
    for (const output of this.outputs) {
      const address = output.current.address.current.value;
      const valueStr = output.current.value.current.value;

      if (address && valueStr) {
        // Doing the check here because need to validate before doing parseInt
        const tokensValue = valueStr*(10**hathorLib.constants.DECIMAL_PLACES);
        if (tokensValue > hathorLib.constants.MAX_OUTPUT_VALUE) {
          this.props.updateState({ errorMessage: `Token: ${this.state.selected.symbol}. Output: ${output.current.props.index}. Maximum output value is ${hathorLib.helpers.prettyValue(hathorLib.constants.MAX_OUTPUT_VALUE)}` });
          return null;
        }
        let dataOutput = {'address': address, 'value': parseInt(tokensValue, 10), 'tokenData': hathorLib.tokens.getTokenIndex(this.state.selectedTokens, this.state.selected.uid)};

        const hasTimelock = output.current.timelockCheckbox.current.checked;
        if (hasTimelock) {
          const timelock = output.current.timelock.current.value;
          if (!timelock) {
            this.props.updateState({ errorMessage: `Token: ${this.state.selected.symbol}. Output: ${output.current.props.index}. You need to fill a complete date and time` });
            return null;
          }
          const timestamp = hathorLib.dateFormatter.dateToTimestamp(new Date(timelock));
          dataOutput['timelock'] = timestamp;
        }
github HathorNetwork / hathor-wallet / src / components / TokenAdministrative.js View on Github external
const mapStateToProps = (state) => {
  const balance = hathorLib.wallet.calculateBalance(
    Object.values(state.historyTransactions),
    hathorLib.constants.HATHOR_TOKEN_CONFIG.uid
  );
  return {
    htrBalance: balance.available,
    historyTransactions: state.historyTransactions,
  };
};
github HathorNetwork / hathor-wallet / src / components / TokenAdministrative.js View on Github external
const mapStateToProps = (state) => {
  const balance = hathorLib.wallet.calculateBalance(
    Object.values(state.historyTransactions),
    hathorLib.constants.HATHOR_TOKEN_CONFIG.uid
  );
  return {
    htrBalance: balance.available,
    historyTransactions: state.historyTransactions,
  };
};
github HathorNetwork / hathor-wallet / src / components / tokens / TokenMint.js View on Github external
executeMint = (pin) => {
    const amountValue = this.amount.current.value*(10**hathorLib.constants.DECIMAL_PLACES);
    const output = this.props.mintOutputs[0];
    const address = this.chooseAddress.current.checked ? hathorLib.wallet.getAddressToUse() : this.address.current.value;
    const promise = hathorLib.tokens.mintTokens(
      output.tx_id,
      output.index,
      output.decoded.address,
      this.props.token.uid,
      address,
      amountValue,
      pin,
      {
        createAnotherMint: this.createAnother.current.checked
      }
    );
    return { promise, message: `${hathorLib.helpers.prettyValue(amountValue)} ${this.props.token.symbol} minted!` };
  }
github HathorNetwork / hathor-wallet / src / screens / VersionError.js View on Github external
return (
      <div>
        <div>
          <nav>
            <div>
              <img alt="" src="{logo}">
            </div>
            <div id="navbarSupportedContent">
              <div>
                
              </div>
            </div>
          </nav>
        </div>
        <div>
          <p>Your API backend version is not compatible with this admin. We expect at least the version {hathorLib.constants.MIN_API_VERSION}</p>
          <p>Please update you API version and try again</p>
          <button>Try again</button>
          <button>Change Server</button>
        </div>
      </div>
    );
  }
}
github HathorNetwork / hathor-wallet / src / utils / wallet.js View on Github external
decimalToInteger(value) {
    return parseInt(value*(10**hathorLib.constants.DECIMAL_PLACES), 10)
  },
}
github HathorNetwork / hathor-wallet / src / components / tokens / TokenMelt.js View on Github external
executeMelt = (pin) => {
    const amountValue = this.amount.current.value*(10**hathorLib.constants.DECIMAL_PLACES);
    const output = this.props.meltOutputs[0];
    const promise = hathorLib.tokens.meltTokens(
      {tx_id: output.tx_id, index: output.index, address: output.decoded.address},
      this.props.token.uid,
      amountValue,
      pin,
      this.createAnother.current.checked
    );
    if (promise === null) {
      return { promise: null, message: 'Can\'t find outputs to melt the amount requested.' };
    } else {
      return { promise, message: `${hathorLib.helpers.prettyValue(amountValue)} ${this.props.token.symbol} melted!` };
    }
  }
github HathorNetwork / hathor-wallet / src / screens / NewWallet.js View on Github external
create = () => {
    let isValid = this.refs.confirmForm.checkValidity();
    if (isValid) {
      this.refs.confirmForm.classList.remove('was-validated')
      const words = hathorLib.wallet.generateWalletWords(hathorLib.constants.HD_WALLET_ENTROPY);
      this.props.updateWords(words);
      this.setState({ step2: true });
    } else {
      this.refs.confirmForm.classList.add('was-validated')
    }
  }