@latticexyz/entrykit 2.2.22-0e714cf3a76af8d526debc4ca830b53a7fab74d2 → 2.2.22-0f5c75bd8fc963e3697ff1720ec3608d119d4b5e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -564,7 +564,7 @@ import { twMerge as twMerge18 } from "tailwind-merge";
564
564
  // src/onboarding/usePrerequisites.ts
565
565
  import { useClient as useClient6, useConfig } from "wagmi";
566
566
  import { getBalanceQueryOptions as getBalanceQueryOptions2 } from "wagmi/query";
567
- import { queryOptions as queryOptions6, useQuery as useQuery7, useQueryClient } from "@tanstack/react-query";
567
+ import { queryOptions as queryOptions6, skipToken as skipToken6, useQuery as useQuery7, useQueryClient } from "@tanstack/react-query";
568
568
 
569
569
  // src/getPaymaster.ts
570
570
  function getPaymaster(chain) {
@@ -919,9 +919,7 @@ function getPrequisitesQueryOptions({
919
919
  }) {
920
920
  return queryOptions6({
921
921
  queryKey: ["getPrerequisites", client?.uid, userAddress],
922
- queryFn: async () => {
923
- if (!client) throw new Error("Viem client not ready.");
924
- if (!userAddress) throw new Error("User not connected.");
922
+ queryFn: client && userAddress ? async () => {
925
923
  const paymaster = getPaymaster(client.chain);
926
924
  const {
927
925
  account: { address: sessionAddress }
@@ -949,7 +947,7 @@ function getPrequisitesQueryOptions({
949
947
  // we intentionally don't enforce an allowance/gas balance here
950
948
  complete: isSpender && hasDelegation
951
949
  };
952
- },
950
+ } : skipToken6,
953
951
  retry: false
954
952
  });
955
953
  }
@@ -1460,6 +1458,7 @@ function useSetupSession({ userClient }) {
1460
1458
  import { useClient as useClient9 } from "wagmi";
1461
1459
  import {
1462
1460
  queryOptions as queryOptions7,
1461
+ skipToken as skipToken7,
1463
1462
  useQuery as useQuery9,
1464
1463
  useQueryClient as useQueryClient4
1465
1464
  } from "@tanstack/react-query";
@@ -1547,8 +1546,7 @@ function getSessionClientQueryOptions({
1547
1546
  }) {
1548
1547
  return queryOptions7({
1549
1548
  queryKey: ["getSessionClient", client?.uid, userAddress, worldAddress],
1550
- queryFn: async () => {
1551
- if (!userAddress) throw new Error("User not connected.");
1549
+ queryFn: userAddress ? async () => {
1552
1550
  const { account: sessionAccount, signer: sessionSigner } = await queryClient.fetchQuery(
1553
1551
  getSessionAccountQueryOptions({ client, userAddress })
1554
1552
  );
@@ -1558,7 +1556,7 @@ function getSessionClientQueryOptions({
1558
1556
  userAddress,
1559
1557
  worldAddress
1560
1558
  });
1561
- },
1559
+ } : skipToken7,
1562
1560
  staleTime: Infinity,
1563
1561
  // TODO: replace with function to retry only connection errors
1564
1562
  retry: false
@@ -2259,7 +2257,7 @@ function useRelay() {
2259
2257
  // src/onboarding/deposit/useChainBalances.ts
2260
2258
  import { useAccount, useConfig as useWagmiConfig } from "wagmi";
2261
2259
  import { getBalance as getBalance2 } from "wagmi/actions";
2262
- import { useQuery as useQuery11, skipToken as skipToken6 } from "@tanstack/react-query";
2260
+ import { useQuery as useQuery11, skipToken as skipToken8 } from "@tanstack/react-query";
2263
2261
  import { isNotNull } from "@latticexyz/common/utils";
2264
2262
  function useChainBalances({ chains }) {
2265
2263
  const { address: userAddress } = useAccount();
@@ -2275,7 +2273,7 @@ function useChainBalances({ chains }) {
2275
2273
  })
2276
2274
  );
2277
2275
  return chainBalances.map((result) => result.status === "fulfilled" ? result.value : null).filter(isNotNull);
2278
- } : skipToken6,
2276
+ } : skipToken8,
2279
2277
  refetchInterval: 1e3 * 60,
2280
2278
  retry: 1
2281
2279
  });
@@ -3628,7 +3626,7 @@ function AccountButton() {
3628
3626
  "hover:bg-orange-400",
3629
3627
  "active:bg-orange-600"
3630
3628
  ),
3631
- "aria-busy": accountModalOpen || prereqs.isPending,
3629
+ "aria-busy": accountModalOpen,
3632
3630
  onClick: openAccountModal,
3633
3631
  children: [
3634
3632
  /* @__PURE__ */ jsxs29("span", { className: "pointer-events-none inline-grid place-items-center -ml-3", children: [
@@ -3664,14 +3662,16 @@ function AccountButton() {
3664
3662
  }
3665
3663
 
3666
3664
  // src/useSessionClientReady.ts
3667
- import { useAccount as useAccount10 } from "wagmi";
3665
+ import { useConnectorClient as useConnectorClient2 } from "wagmi";
3668
3666
  function useSessionClientReady() {
3669
- const { address: userAddress } = useAccount10();
3667
+ const { chainId } = useEntryKitConfig();
3668
+ const userClient = useConnectorClient2({ chainId });
3669
+ if (userClient.error) console.error("Error retrieving user client", userClient.error);
3670
+ const userAddress = userClient.data?.account.address;
3670
3671
  const prerequisites = usePrerequisites(userAddress);
3671
3672
  const sessionClient = useSessionClient(userAddress);
3672
- if (!prerequisites.isSuccess || !prerequisites.data.complete) {
3673
- return { ...prerequisites, data: void 0 };
3674
- }
3673
+ if (!userClient.isSuccess) return { ...userClient, data: void 0 };
3674
+ if (!prerequisites.isSuccess || !prerequisites.data.complete) return { ...prerequisites, data: void 0 };
3675
3675
  return sessionClient;
3676
3676
  }
3677
3677