From 53bfb692a0d7fcde24f8a698cf16756450f92574 Mon Sep 17 00:00:00 2001
From: Yashvardhan Jagnani
Date: Sat, 19 Oct 2024 00:50:46 +0530
Subject: [PATCH] fix(gas card): units precision
---
src/components/Molecules/GasCard/GasCard.tsx | 28 +++++++++++++-------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/src/components/Molecules/GasCard/GasCard.tsx b/src/components/Molecules/GasCard/GasCard.tsx
index 409329ac..2683cd22 100644
--- a/src/components/Molecules/GasCard/GasCard.tsx
+++ b/src/components/Molecules/GasCard/GasCard.tsx
@@ -10,7 +10,10 @@ import type { Option } from "@/utils/option";
import { None, Some } from "@/utils/option";
import { useGoldRush } from "@/utils/store";
import type { GasCardData, GasCardProps } from "@/utils/types/molecules.types";
-import { type GoldRushResponse } from "@covalenthq/client-sdk";
+import {
+ calculatePrettyBalance,
+ type GoldRushResponse,
+} from "@covalenthq/client-sdk";
import { useEffect, useMemo, useState } from "react";
export const GasCard: React.FC = ({ chain_name }) => {
@@ -161,12 +164,15 @@ export const GasCard: React.FC = ({ chain_name }) => {
- {Math.round(
- (Number(
+ {calculatePrettyBalance(
+ Number(
result?.[selectedValue]
.base_fee,
- ) ?? 0) / Math.pow(10, 9),
- ).toFixed(2)}{" "}
+ ),
+ 9,
+ true,
+ 4,
+ )}{" "}
Gwei
@@ -200,10 +206,14 @@ export const GasCard: React.FC = ({ chain_name }) => {
{copy[i].content}
- {Math.round(
- Number(gas_price) /
- Math.pow(10, 9),
- ).toFixed(2)}{" "}
+ {calculatePrettyBalance(
+ Number(
+ gas_price ?? 0,
+ ),
+ 9,
+ true,
+ 4,
+ )}{" "}
Gwei
{pretty_total_gas_quote && (