Skip to content

Commit 75e0eab

Browse files
committed
fix: requested changes
1 parent 91d4ddf commit 75e0eab

File tree

3 files changed

+5
-21
lines changed

3 files changed

+5
-21
lines changed

packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ export function useTransactionDetails({
7878
encode(transaction).catch(() => "0x"),
7979
]);
8080

81-
const account = wallet?.getAccount();
82-
if (!account) {
83-
throw new Error("No active account");
84-
}
85-
8681
const [tokenInfo, gasCostWei] = await Promise.all([
8782
getToken(
8883
client,

packages/thirdweb/src/react/web/ui/Bridge/TransactionPayment.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ import { WithHeader } from "./common/WithHeader.js";
3030
import { useQuery } from "@tanstack/react-query";
3131
import { getWalletBalance } from "../../../../wallets/utils/getWalletBalance.js";
3232
import { resolvePromisedValue } from "../../../../utils/promise/resolve-promised-value.js";
33-
import { decimals } from "../../../../extensions/erc20/read/decimals.js";
34-
import { getContract } from "../../../../contract/contract.js";
3533
import { NATIVE_TOKEN_ADDRESS } from "../../../../constants/addresses.js";
36-
import { toTokens } from "../../../../utils/units.js";
3734

3835
export interface TransactionPaymentProps {
3936
/**
@@ -92,25 +89,16 @@ export function TransactionPayment({
9289
return "0";
9390
}
9491
const erc20Value = await resolvePromisedValue(uiOptions.transaction.erc20Value);
95-
const tokenDecimals = erc20Value?.tokenAddress.toLowerCase() !== NATIVE_TOKEN_ADDRESS && erc20Value
96-
? await decimals({
97-
contract: getContract({
98-
address: erc20Value.tokenAddress,
99-
chain: uiOptions.transaction.chain,
100-
client,
101-
}),
102-
})
103-
: 18;
10492
const walletBalance = await getWalletBalance({
10593
address: activeAccount?.address,
10694
chain: uiOptions.transaction.chain,
10795
tokenAddress: erc20Value?.tokenAddress.toLowerCase() !== NATIVE_TOKEN_ADDRESS ? erc20Value?.tokenAddress : undefined,
10896
client,
10997
});
11098

111-
return toTokens(walletBalance.value, tokenDecimals);
99+
return walletBalance.displayValue
112100
},
113-
queryKey: ["active-account-address"],
101+
queryKey: ["user-balance", activeAccount?.address]
114102
});
115103

116104
const contractName =

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { Img } from "../../components/Img.js";
1717
import { Spacer } from "../../components/Spacer.js";
1818
import { Spinner } from "../../components/Spinner.js";
1919
import { Text } from "../../components/text.js";
20+
import { formatNumber } from "../../../../../utils/formatNumber.js";
2021

2122
interface FiatProviderSelectionProps {
2223
client: ThirdwebClient;
@@ -171,10 +172,10 @@ export function FiatProviderSelection({
171172
{quote.currency}
172173
</Text>
173174
<Text color="secondaryText" size="xs">
174-
{toTokens(
175+
{formatNumber(Number(toTokens(
175176
quote.destinationAmount,
176177
quote.destinationToken.decimals,
177-
)}{" "}
178+
)), 4)}{" "}
178179
{quote.destinationToken.symbol}
179180
</Text>
180181
</Container>

0 commit comments

Comments
 (0)