Skip to content

Commit

Permalink
improve query keys and enabled state
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderKolberg committed Feb 18, 2025
1 parent 44e2361 commit 0197e29
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getMarketplaceClient,
} from '../../../../_internal';
import { useWallet } from '../../../../_internal/wallet/useWallet';
import { useAccount } from 'wagmi';

export interface UseGetTokenApprovalDataArgs {
chainId: string;
Expand All @@ -29,6 +30,7 @@ export const useGetTokenApprovalData = (
) => {
const config = useConfig();
const { wallet } = useWallet();
const { address } = useAccount();
const marketplaceClient = getMarketplaceClient(params.chainId, config);

const listing = {
Expand All @@ -39,10 +41,14 @@ export const useGetTokenApprovalData = (
expiry: String(Number(dateToUnixTime(new Date())) + ONE_DAY_IN_SECONDS),
} satisfies CreateReq;

const isEnabled = wallet && params.query?.enabled !== false;
const isEnabled =
wallet &&
address &&
(params.query?.enabled ?? true) &&
!!params.currencyAddress;

const { data, isLoading, isSuccess } = useQuery({
queryKey: ['token-approval-data', params.currencyAddress],
queryKey: ['token-approval-data', params, address],
queryFn: isEnabled
? async () => {
const args = {
Expand Down

0 comments on commit 0197e29

Please sign in to comment.