How to use the @hathor/wallet-lib.helpers 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 / App.js View on Github external
handleWebsocket = (wsData) => {
    if (hathorLib.wallet.loaded()) {
      // We are still receiving lot of ws messages that are destined to the admin-frontend and not this wallet
      // TODO separate those messages
      if (wsData.type === 'wallet:address_history') {
        // If is a new transaction, we send a notification to the user, in case it's turned on
        // We only send the notification if the inputs are not generated from this wallet
        if (!hathorLib.wallet.txExists(wsData.history) && !hathorLib.wallet.areInputsMine(wsData.history)) {
          let message = '';
          if (hathorLib.helpers.isBlock(wsData.history)) {
            message = 'You\'ve found a new block! Click to open it.';
          } else {
            message = 'You\'ve received a new transaction! Click to open it.'
          }
          const notification = wallet.sendNotification(message);
          // Set the notification click, in case we have sent one
          if (notification !== undefined) {
            notification.onclick = () => {
              this.props.history.push(`/transaction/${wsData.history.tx_id}/`);
            }
          }
        }
        wallet.newAddressHistory(wsData.history);
      } else {
        console.log('Websocket message not handled. Type:', wsData.type);
      }
github HathorNetwork / hathor-wallet / src / components / tokens / TokenMelt.js View on Github external
const renderForm = () => {
      return (
        <div>
          <div>
            <div>
              <label>Amount</label>
              <input placeholder="{hathorLib.helpers.prettyValue(0)}" min="{hathorLib.helpers.prettyValue(1)}" step="{hathorLib.helpers.prettyValue(1)}" type="number" required="">
            </div>
          </div>
          <div>
            <div>
              <input id="keepMint" type="checkbox">
              <label>
                Create another melt output for you?
              </label>
            </div>
          </div>
        </div>
      )
    }
github HathorNetwork / hathor-wallet / src / components / WalletBalance.js View on Github external
const renderBalance = () =&gt; {

      return (
        <div>
          <p><strong>Total:</strong> {hathorLib.helpers.prettyValue(this.props.balance.available + this.props.balance.locked)} {symbol}</p>
          <p><strong>Available:</strong> {hathorLib.helpers.prettyValue(this.props.balance.available)} {symbol}</p>
          <p><strong>Locked:</strong> {hathorLib.helpers.prettyValue(this.props.balance.locked)} {symbol}</p>
        </div>
      );
    }
github HathorNetwork / hathor-wallet / src / components / RequestError.js View on Github external
render() {
    return (
      <div aria-hidden="true" aria-labelledby="requestErrorModal" role="dialog" tabindex="-1" id="requestErrorModal">
        <div role="document">
          <div>
            <div>
              <h5 id="exampleModalLabel">Request failed</h5>
              <button aria-label="Close" data-dismiss="modal" type="button">
                <span aria-hidden="true">×</span>
              </button>
            </div>
            <div>
              <p>{this.getErrorMessage()}</p>
              <p>You are connected to <strong>{hathorLib.helpers.getServerURL()}</strong></p>
              <a> this.showAdvanced(e)} ref="showAdvancedLink" href="true"&gt;Show advanced data</a>
              <a> this.hideAdvanced(e)} ref="hideAdvancedLink" href="true" style={{display: 'none'}}&gt;Hide advanced data</a>
              <div style="{{display:">{this.getAdvancedMessage()}</div>
            </div>
            <div>
              <button type="button">Change server</button>
              <button type="button">Retry request</button>
            </div>
          </div>
        </div>
      </div>
    )
  }
}
github HathorNetwork / hathor-wallet / src / components / tokens / TokenMint.js View on Github external
const renderForm = () =&gt; {
      return (
        <div>
          <div>
            <div>
              <label>Amount</label>
              <input placeholder="{hathorLib.helpers.prettyValue(0)}" min="{hathorLib.helpers.prettyValue(1)}" step="{hathorLib.helpers.prettyValue(1)}" type="number" required="">
            </div>
            {renderMintAddress()}
          </div>
          <div>
            <div>
              <input id="keepMint" type="checkbox">
              <label>
                Create another mint output for you?
              </label>
            </div>
          </div>
        </div>
      )
    }
github HathorNetwork / hathor-wallet / src / components / TokenAdministrative.js View on Github external
const renderMintMeltWrapper = () =&gt; {
      if (this.state.mintOutputs.length === 0 &amp;&amp; this.state.meltOutputs.length === 0) {
        return <p>You have no more authority outputs for this token</p>;
      }

      return (
        <div>
          <div>
            <p><strong>Mint authority management</strong></p>
            <p>You are the owner of {this.state.mintOutputs.length} mint {hathorLib.helpers.plural(this.state.mintOutputs.length, 'output', 'outputs')}</p>
            {this.state.mintOutputs.length &gt; 0 &amp;&amp; renderMintLinks()}
          </div>
          <div>
            <p><strong>Melt authority management</strong></p>
            <p>You are the owner of {this.state.meltOutputs.length} melt {hathorLib.helpers.plural(this.state.meltOutputs.length, 'output', 'outputs')}</p>
            {this.state.meltOutputs.length &gt; 0 &amp;&amp; renderMeltLinks()}
          </div>
        </div>
      );
    }
github HathorNetwork / hathor-wallet / src / components / TokenAdministrative.js View on Github external
const renderMintMeltWrapper = () =&gt; {
      if (this.state.mintOutputs.length === 0 &amp;&amp; this.state.meltOutputs.length === 0) {
        return <p>You have no more authority outputs for this token</p>;
      }

      return (
        <div>
          <div>
            <p><strong>Mint authority management</strong></p>
            <p>You are the owner of {this.state.mintOutputs.length} mint {hathorLib.helpers.plural(this.state.mintOutputs.length, 'output', 'outputs')}</p>
            {this.state.mintOutputs.length &gt; 0 &amp;&amp; renderMintLinks()}
          </div>
          <div>
            <p><strong>Melt authority management</strong></p>
            <p>You are the owner of {this.state.meltOutputs.length} melt {hathorLib.helpers.plural(this.state.meltOutputs.length, 'output', 'outputs')}</p>
            {this.state.meltOutputs.length &gt; 0 &amp;&amp; renderMeltLinks()}
          </div>
        </div>
      );
    }
github HathorNetwork / hathor-wallet / src / components / TokenGeneralInfo.js View on Github external
const renderTokenInfo = () =&gt; {
      return (
        <div>
          <p><strong>UID: </strong>{this.props.token.uid}</p>
          <p><strong>Name: </strong>{this.props.token.name}</p>
          <p><strong>Symbol: </strong>{this.props.token.symbol}</p>
          <p><strong>Total supply: </strong>{hathorLib.helpers.prettyValue(this.state.totalSupply)} {this.props.token.symbol}</p>
          <p><strong>Can mint new tokens: </strong>{this.state.canMint ? 'Yes' : 'No'}</p>
          <p>Indicates whether the token owner can create new tokens, increasing the total supply</p>
          <p><strong>Can melt tokens: </strong>{this.state.canMelt ? 'Yes' : 'No'}</p>
          <p>Indicates whether the token owner can destroy tokens, decreasing the total supply</p>
          <p><strong>Total number of transactions: </strong>{this.state.transactionsCount}</p>
        </div>
      );
    }
github HathorNetwork / hathor-wallet / src / components / RequestError.js View on Github external
modalHiddenRetry = () => {
    let config = this.props.lastFailedRequest;
    let axios = createRequestInstance(config.resolve);
    hathorLib.helpers.fixAxiosConfig(axios, config);
    axios(config).then((response) => {
      config.resolve(response.data);
    });
    this.setState({ retry: false });
  }