This repository was archived by the owner on Aug 30, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { SupportedChainId } from "../../constants/chain";
22import { useThirdwebConfigContext } from "../../contexts/thirdweb-config" ;
33import { ContractAddress } from "../../types" ;
44import { cacheKeys } from "../../utils/cache-keys" ;
5+ import { useAddress } from "../useAddress" ;
56import { useChainId } from "../useChainId" ;
67import { useSigner } from "../useSigner" ;
78import { UserWallet } from "@thirdweb-dev/sdk/dist/browser" ;
@@ -19,6 +20,7 @@ export function useBalance(tokenAddress?: ContractAddress) {
1920 const { rpcUrlMap } = useThirdwebConfigContext ( ) ;
2021 const chainId = useChainId ( ) as SupportedChainId ;
2122 const signer = useSigner ( ) ;
23+ const walletAddress = useAddress ( ) ;
2224
2325 const walletSDK = useMemo ( ( ) => {
2426 if ( signer ) {
@@ -32,9 +34,6 @@ export function useBalance(tokenAddress?: ContractAddress) {
3234 return undefined ;
3335 } , [ signer , chainId ] ) ;
3436
35- // this is ugly but it works
36- const walletAddress = ( walletSDK as any ) ?. connection ?. signer ?. _address ;
37-
3837 const cacheKey = useMemo ( ( ) => {
3938 return cacheKeys . wallet . balance ( chainId , walletAddress , tokenAddress ) ;
4039 } , [ chainId , tokenAddress , walletAddress ] ) ;
You can’t perform that action at this time.
0 commit comments