Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gas card): units precision #223

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading