Skip to content

Commit 80e0bfe

Browse files
authored
[React SDK] Fix: Properly read current wallet erc20 balance (#4478)
1 parent 371edea commit 80e0bfe

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.changeset/unlucky-socks-repeat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Fix ERC20 balance read when showing pay modal

packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait
1010
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
1111
import { resolvePromisedValue } from "../../../../utils/promise/resolve-promised-value.js";
1212
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
13+
import { getTokenBalance } from "../../../../wallets/utils/getTokenBalance.js";
1314
import { getWalletBalance } from "../../../../wallets/utils/getWalletBalance.js";
1415
import type { LocaleId } from "../../../web/ui/types.js";
1516
import type { Theme } from "../../design-system/index.js";
@@ -175,10 +176,11 @@ export function useSendTransactionCore(args: {
175176
chain: tx.chain,
176177
}),
177178
_erc20Value?.tokenAddress
178-
? getWalletBalance({
179+
? getTokenBalance({
179180
client: tx.client,
180-
address: account.address,
181+
account,
181182
chain: tx.chain,
183+
tokenAddress: _erc20Value.tokenAddress,
182184
})
183185
: undefined,
184186
getTotalTxCostForBuy(tx, account.address),

0 commit comments

Comments
 (0)