Skip to content

Commit

Permalink
fix more issues where ethers formatUnits won't accept a BigNumber any…
Browse files Browse the repository at this point in the history
…more, but will take a string version of it
  • Loading branch information
chuckbergeron committed Aug 16, 2023
1 parent 696da00 commit 9198fec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/library/src/claimerProfitablePrizeTxs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ const getClaimInfo = async (

// FEES USD
claimFeesUsd =
parseFloat(ethers.utils.formatUnits(claimFees, context.feeToken.decimals)) *
parseFloat(ethers.utils.formatUnits(claimFees.toString(), context.feeToken.decimals)) *
context.feeToken.assetRateUsd;
if (claimCount > 0) {
logBigNumber(
Expand Down
16 changes: 8 additions & 8 deletions packages/library/src/utils/logging.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ethers } from "ethers";
import chalk from "chalk";
import { ethers } from 'ethers';
import chalk from 'chalk';

export const logTable = (obj: any) => {
if (console.table.name === "table") {
if (console.table.name === 'table') {
console.table(obj);
} else {
console.log(obj);
Expand All @@ -15,20 +15,20 @@ export const logStringValue = (str: string, val: any) => {

export const logBigNumber = (title, bigNumber, decimals, symbol = null) => {
try {
const formatted = ethers.utils.formatUnits(bigNumber, decimals);
const formatted = ethers.utils.formatUnits(bigNumber.toString(), decimals);

logStringValue(
title,
`${formatted}${symbol !== null && ` ${symbol}`} (${bigNumber.toString()} wei)`
`${formatted}${symbol !== null && ` ${symbol}`} (${bigNumber.toString()} wei)`,
);
} catch (e) {
console.log(chalk.dim("Unable to log BigNumber:", title));
console.log(chalk.dim('Unable to log BigNumber:', title));
}
};

export const printAsterisks = () => {
printSpacer();
console.log(chalk.blue("******************"));
console.log(chalk.blue('******************'));
};

export const printSpacer = () => console.log("");
export const printSpacer = () => console.log('');

0 comments on commit 9198fec

Please sign in to comment.