How to use the @zilliqa-js/util.units.Units function in @zilliqa-js/util

To help you get started, we’ve selected a few @zilliqa-js/util 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 zilpay / zil-pay / src / views / Popup.vue View on Github external
mounted() {
    this.upadteAllState();
    this.gasPrice = units.fromQa(
      new BN(this.CONFIRM_TX.gasPrice),
      units.Units.Li
    ).toString();
    this.gasLimit = this.CONFIRM_TX.gasLimit;
  }
}
github Zilliqa / nucleus-wallet / src / utils.ts View on Github external
export const formatSendAmountInZil = (
  amountInZil: string,
  balanceInZil: string,
  minGasPriceInZil: string
): string => {
  const amountInQaBN: BN = units.toQa(amountInZil, units.Units.Zil);
  const balanceInQaBN: BN = units.toQa(balanceInZil, units.Units.Zil);
  const minGasPriceInQaBN: BN = units.toQa(minGasPriceInZil, units.Units.Zil);

  const maxAmountInQaBN = balanceInQaBN.sub(minGasPriceInQaBN);

  if (amountInQaBN.lte(minGasPriceInQaBN)) {
    return units.fromQa(minGasPriceInQaBN, units.Units.Zil).toString();
  } else if (amountInQaBN.gt(maxAmountInQaBN)) {
    return units.fromQa(maxAmountInQaBN, units.Units.Zil).toString();
  } else {
    return units.fromQa(amountInQaBN, units.Units.Zil).toString();
  }
};