@@ -8,7 +8,6 @@ import type { CompilerMetadata } from "../../../contract/actions/compiler-metada
88import { getCompilerMetadata } from "../../../contract/actions/get-compiler-metadata.js" ;
99import { getContract } from "../../../contract/contract.js" ;
1010import { decimals } from "../../../extensions/erc20/read/decimals.js" ;
11- import { getBalance } from "../../../extensions/erc20/read/getBalance.js" ;
1211import { getToken } from "../../../pay/convert/get-token.js" ;
1312import type { SupportedFiatCurrency } from "../../../pay/convert/type.js" ;
1413import { encode } from "../../../transaction/actions/encode.js" ;
@@ -18,7 +17,6 @@ import { resolvePromisedValue } from "../../../utils/promise/resolve-promised-va
1817import { toTokens } from "../../../utils/units.js" ;
1918import type { Wallet } from "../../../wallets/interfaces/wallet.js" ;
2019import { hasSponsoredTransactionsEnabled } from "../../../wallets/smart/is-smart-wallet.js" ;
21- import { getWalletBalance } from "../../../wallets/utils/getWalletBalance.js" ;
2220import {
2321 formatCurrencyAmount ,
2422 formatTokenAmount ,
@@ -32,8 +30,6 @@ interface TransactionDetails {
3230 selector : string ;
3331 description ?: string ;
3432 } ;
35- userBalance : string ;
36- userBalanceWei : bigint ;
3733 usdValueDisplay : string | null ;
3834 txCostDisplay : string ;
3935 gasCostDisplay : string | null ;
@@ -87,28 +83,12 @@ export function useTransactionDetails({
8783 throw new Error ( "No active account" ) ;
8884 }
8985
90- const [ tokenInfo , userBalance , gasCostWei ] = await Promise . all ( [
86+ const [ tokenInfo , gasCostWei ] = await Promise . all ( [
9187 getToken (
9288 client ,
93- erc20Value ? erc20Value . tokenAddress : NATIVE_TOKEN_ADDRESS ,
89+ erc20Value ? .tokenAddress || NATIVE_TOKEN_ADDRESS ,
9490 transaction . chain . id ,
9591 ) . catch ( ( ) => null ) ,
96- ( async ( ) =>
97- erc20Value &&
98- erc20Value . tokenAddress . toLowerCase ( ) !== NATIVE_TOKEN_ADDRESS
99- ? getBalance ( {
100- contract : getContract ( {
101- address : erc20Value . tokenAddress ,
102- chain : transaction . chain ,
103- client,
104- } ) ,
105- address : account . address ,
106- } )
107- : getWalletBalance ( {
108- address : account . address ,
109- chain : transaction . chain ,
110- client,
111- } ) ) ( ) . then ( ( result ) => result ?. value || 0n ) ,
11292 hasSponsoredTransactions
11393 ? 0n
11494 : getTransactionGasCost ( transaction ) . catch ( ( ) => null ) ,
@@ -178,7 +158,7 @@ export function useTransactionDetails({
178158
179159 const totalCostWei =
180160 erc20Value &&
181- erc20Value . tokenAddress . toLowerCase ( ) !== NATIVE_TOKEN_ADDRESS
161+ erc20Value . tokenAddress . toLowerCase ( ) !== NATIVE_TOKEN_ADDRESS
182162 ? erc20Value . amountWei
183163 : ( value || 0n ) + ( gasCostWei || 0n ) ;
184164 const totalCost = toTokens ( totalCostWei , decimal ) ;
@@ -190,8 +170,6 @@ export function useTransactionDetails({
190170 contractMetadata,
191171 costWei,
192172 functionInfo,
193- userBalance : toTokens ( userBalance , decimal ) ,
194- userBalanceWei : userBalance ,
195173 gasCostDisplay : gasCostWei
196174 ? `${ formatTokenAmount ( gasCostWei , 18 ) } ${ nativeTokenSymbol } `
197175 : null ,
0 commit comments