Skip to content

Commit

Permalink
Use ethers.formatEther to convert ETH value to wei
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadranjbarz committed Dec 6, 2023
1 parent a91f381 commit 1f9018b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/givFarm/givFarmService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export async function getAssignHistory(params: {
const amountBigInt = BigInt(args.args[2]);

// Perform division using BigInt and then convert to Number for storing
const amountNumber = Number(amountBigInt / 10n ** 18n);

// const amountNumber = Number(amountBigInt / 10n ** 18n);
const amountNumber = Ethers.ethers.formatEther(amountBigInt.toString());
assignHistory.push({
blockNumber,
transactionHash,
Expand All @@ -74,8 +74,9 @@ export async function getAssignHistory(params: {

console.log("###############################################");
console.log("Total: ", total / 10n ** 18n);
console.log("Total: ", Ethers.ethers.formatEther(total.toString()));
return {
total: Number(total / 10n ** 18n),
total: Ethers.ethers.formatEther(total.toString()),
assignHistory: assignHistory.reverse()
}
}
Expand Down

0 comments on commit 1f9018b

Please sign in to comment.