Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
}
}
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();
}
}
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)} ꜩ`;
}
}