How to use the @taquito/taquito.Tezos.format function in @taquito/taquito

To help you get started, we’ve selected a few @taquito/taquito 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 ecadlabs / taquito / packages / taquito-react-components / src / format.ts View on Github external
export function tzFormatter(amount: string | BigNumber, format?: 'tz' | 'mtz') {
  const bigNum = new BigNumber(amount);
  if (bigNum.isNaN()) {
    return amount;
  }

  if (format === 'tz') {
    return `${Tezos.format('mutez', 'tz', amount)} ꜩ`;
  } else if (format === 'mtz') {
    return `${Tezos.format('mutez', 'mtz', amount)} mꜩ`;
  } else {
    return bigNum.toString();
  }
}
github ecadlabs / taquito / packages / taquito-react-components / src / format.ts View on Github external
export function tzFormatter(amount: string | BigNumber, format?: 'tz' | 'mtz') {
  const bigNum = new BigNumber(amount);
  if (bigNum.isNaN()) {
    return amount;
  }

  if (format === 'tz') {
    return `${Tezos.format('mutez', 'tz', amount)} ꜩ`;
  } else if (format === 'mtz') {
    return `${Tezos.format('mutez', 'mtz', amount)} mꜩ`;
  } else {
    return bigNum.toString();
  }
}
github ecadlabs / taquito / demo / src / app / tz.pipe.ts View on Github external
transform(amount: any, ...args: any[]): any {
    const bigNum = new BigNumber(amount);
    if (bigNum.isNaN()) {
      return amount;
    }

    return `${new BigNumber(Tezos.format('mutez', 'tz', amount)).toFixed(2)} ꜩ`;
  }
}