Skip to content

Commit 698aa3c

Browse files
Remove useCountervalue
1 parent b67a2cb commit 698aa3c

File tree

5 files changed

+10
-64
lines changed

5 files changed

+10
-64
lines changed

packages/profile/src/components/inventory/token/send/amount.tsx

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { Amount } from "@cartridge/ui-next";
2-
import { formatBalance, useCountervalue, useToken } from "@cartridge/utils";
3-
import { TokenPair } from "@cartridge/utils/api/cartridge";
2+
import {
3+
convertTokenAmountToUSD,
4+
formatBalance,
5+
useToken,
6+
} from "@cartridge/utils";
47
import { useCallback } from "react";
58
import { useParams } from "react-router-dom";
69

@@ -27,16 +30,6 @@ export function SendAmount({
2730
[token, setAmount],
2831
);
2932

30-
const { countervalue } = useCountervalue(
31-
{
32-
balance: amount?.toString() ?? "0",
33-
pair: `${token.symbol}_USDC` as TokenPair,
34-
},
35-
{
36-
enabled: token && ["ETH", "STRK"].includes(token.symbol) && !!amount,
37-
},
38-
);
39-
4033
const handleChange = useCallback(
4134
(e: React.ChangeEvent<HTMLInputElement>) => {
4235
const value = e.target.value;
@@ -52,7 +45,11 @@ export function SendAmount({
5245
return (
5346
<Amount
5447
amount={amount}
55-
conversion={countervalue?.formatted}
48+
conversion={
49+
token.balance !== undefined && token.price !== undefined
50+
? convertTokenAmountToUSD(token.balance, token.decimals, token.price)
51+
: undefined
52+
}
5653
balance={parseFloat(formatBalance(token.balance ?? 0n).replace("~", ""))}
5754
symbol={token.symbol}
5855
decimals={token.decimals ?? 18}

packages/utils/src/hooks/countervalue.mock.ts

-8
This file was deleted.

packages/utils/src/hooks/countervalue.ts

-41
This file was deleted.
-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export * from "./api";
22
export * from "./balance";
33
export * from "./posthog";
4-
export * from "./countervalue.mock";

packages/utils/src/hooks/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export * from "./api";
22
export * from "./balance";
3-
export * from "./countervalue";
43
export * from "./posthog";
54
export * from "./tokens";

0 commit comments

Comments
 (0)