Skip to content

Commit

Permalink
fix(gas card): units precision (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
jagnani73 authored Oct 18, 2024
1 parent 026d4b7 commit d290364
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/components/Molecules/GasCard/GasCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<GasCardProps> = ({ chain_name }) => {
Expand Down Expand Up @@ -161,12 +164,15 @@ export const GasCard: React.FC<GasCardProps> = ({ chain_name }) => {
</p>

<p className="text-lg">
{Math.round(
(Number(
{calculatePrettyBalance(
Number(
result?.[selectedValue]
.base_fee,
) ?? 0) / Math.pow(10, 9),
).toFixed(2)}{" "}
),
9,
true,
4,
)}{" "}
Gwei
</p>
</div>
Expand Down Expand Up @@ -200,10 +206,14 @@ export const GasCard: React.FC<GasCardProps> = ({ chain_name }) => {
{copy[i].content}

<p>
{Math.round(
Number(gas_price) /
Math.pow(10, 9),
).toFixed(2)}{" "}
{calculatePrettyBalance(
Number(
gas_price ?? 0,
),
9,
true,
4,
)}{" "}
Gwei
{pretty_total_gas_quote && (
<span className="ml-1 text-sm text-secondary-light dark:text-secondary-dark">
Expand Down

0 comments on commit d290364

Please sign in to comment.