@latticexyz/entrykit 2.2.22-7367a813d9b394415ba70678c4295cc90562c304 → 2.2.22-7382971451b731dc451a2a3834bb20c5c7756917

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.
@@ -562,39 +562,13 @@ import { useEffect as useEffect15, useMemo as useMemo4, useRef as useRef5, useSt
562
562
  import { twMerge as twMerge18 } from "tailwind-merge";
563
563
 
564
564
  // src/onboarding/usePrerequisites.ts
565
- import { useClient as useClient6, useConfig } from "wagmi";
566
- import { getBalanceQueryOptions as getBalanceQueryOptions2 } from "wagmi/query";
567
- import { queryOptions as queryOptions6, skipToken as skipToken6, useQuery as useQuery7, useQueryClient } from "@tanstack/react-query";
565
+ import { useClient as useClient7, useConfig as useConfig2 } from "wagmi";
566
+ import { queryOptions as queryOptions7, useQuery as useQuery8, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
568
567
 
569
- // src/getPaymaster.ts
570
- function getPaymaster(chain) {
571
- const contracts = chain.contracts ?? {};
572
- if ("quarryPaymaster" in contracts && contracts.quarryPaymaster != null) {
573
- if ("address" in contracts.quarryPaymaster) {
574
- return {
575
- type: "quarry",
576
- address: contracts.quarryPaymaster.address,
577
- isGasPass: !!chain.rpcUrls.quarryPassIssuer?.http?.[0]
578
- };
579
- }
580
- }
581
- if ("paymaster" in contracts && contracts.paymaster != null) {
582
- if ("address" in contracts.paymaster) {
583
- return {
584
- type: "simple",
585
- address: contracts.paymaster.address
586
- };
587
- }
588
- }
589
- }
590
-
591
- // src/onboarding/quarry/useAllowance.ts
568
+ // src/onboarding/quarry/useSpender.ts
592
569
  import { useClient } from "wagmi";
593
570
  import { queryOptions, skipToken, useQuery as useQuery2 } from "@tanstack/react-query";
594
571
 
595
- // src/quarry/getAllowance.ts
596
- import { numberToHex as numberToHex2 } from "viem";
597
-
598
572
  // src/quarry/common.ts
599
573
  import { defineStore } from "@latticexyz/store";
600
574
  import { parseAbi } from "viem";
@@ -671,64 +645,36 @@ var paymasterConfig = defineStore({
671
645
  });
672
646
  var paymasterTables = paymasterConfig.namespaces.root.tables;
673
647
 
674
- // src/quarry/getAllowance.ts
675
- import { getRecord, getStaticDataLocation } from "@latticexyz/store/internal";
676
- import { getKeyTuple } from "@latticexyz/protocol-parser/internal";
677
- import { setStorageAt } from "viem/actions";
678
- async function getAllowance({ client, userAddress }) {
679
- const paymaster = getPaymaster(client.chain);
680
- if (paymaster?.type !== "quarry") return null;
681
- const record = await getRecord(client, {
682
- address: paymaster.address,
683
- table: paymasterTables.Allowance,
684
- key: { user: userAddress },
685
- blockTag: "pending"
686
- });
687
- return record.allowance;
688
- }
689
- async function setAllowanceSlot({ client, userAddress, allowance }) {
690
- const paymaster = getPaymaster(client.chain);
691
- if (paymaster?.type !== "quarry") return;
692
- const slot = getStaticDataLocation(
693
- paymasterTables.Allowance.tableId,
694
- getKeyTuple(paymasterTables.Allowance, { user: userAddress })
695
- );
696
- await setStorageAt(
697
- client.extend(() => ({ mode: "anvil" })),
698
- {
699
- address: paymaster.address,
700
- index: slot,
701
- value: numberToHex2(allowance, { size: 32 })
702
- }
703
- );
704
- }
648
+ // src/onboarding/quarry/getSpender.ts
649
+ import { getRecord } from "@latticexyz/store/internal";
705
650
 
706
- // src/onboarding/quarry/useAllowance.ts
707
- function getAllowanceQueryOptions({
708
- client,
709
- userAddress
710
- }) {
711
- return queryOptions({
712
- queryKey: ["getAllowance", client?.uid, userAddress],
713
- queryFn: client && userAddress ? () => getAllowance({ client, userAddress }) : skipToken
714
- });
715
- }
716
- function useAllowance(userAddress) {
717
- const { chainId } = useEntryKitConfig();
718
- const client = useClient({ chainId });
719
- return useQuery2(getAllowanceQueryOptions({ client, userAddress }));
651
+ // src/getPaymaster.ts
652
+ function getPaymaster(chain) {
653
+ const contracts = chain.contracts ?? {};
654
+ if ("quarryPaymaster" in contracts && contracts.quarryPaymaster != null) {
655
+ if ("address" in contracts.quarryPaymaster) {
656
+ return {
657
+ type: "quarry",
658
+ address: contracts.quarryPaymaster.address,
659
+ isGasPass: !!chain.rpcUrls.quarryPassIssuer?.http?.[0]
660
+ };
661
+ }
662
+ }
663
+ if ("paymaster" in contracts && contracts.paymaster != null) {
664
+ if ("address" in contracts.paymaster) {
665
+ return {
666
+ type: "simple",
667
+ address: contracts.paymaster.address
668
+ };
669
+ }
670
+ }
720
671
  }
721
672
 
722
- // src/onboarding/quarry/useSpender.ts
723
- import { useClient as useClient2 } from "wagmi";
724
- import { queryOptions as queryOptions2, skipToken as skipToken2, useQuery as useQuery3 } from "@tanstack/react-query";
725
-
726
673
  // src/onboarding/quarry/getSpender.ts
727
- import { getRecord as getRecord2 } from "@latticexyz/store/internal";
728
674
  async function getSpender({ client, userAddress, sessionAddress }) {
729
675
  const paymaster = getPaymaster(client.chain);
730
676
  if (paymaster?.type !== "quarry") return null;
731
- const record = await getRecord2(client, {
677
+ const record = await getRecord(client, {
732
678
  address: paymaster.address,
733
679
  table: paymasterTables.Spender,
734
680
  key: { spender: sessionAddress },
@@ -743,18 +689,18 @@ function getSpenderQueryOptions({
743
689
  userAddress,
744
690
  sessionAddress
745
691
  }) {
746
- return queryOptions2({
692
+ return queryOptions({
747
693
  queryKey: ["getSpender", client?.uid, userAddress, sessionAddress],
748
- queryFn: client && userAddress && sessionAddress ? () => getSpender({ client, userAddress, sessionAddress }) : skipToken2
694
+ queryFn: client && userAddress && sessionAddress ? () => getSpender({ client, userAddress, sessionAddress }) : skipToken
749
695
  });
750
696
  }
751
697
 
752
698
  // src/onboarding/useDelegation.ts
753
- import { useClient as useClient3 } from "wagmi";
754
- import { queryOptions as queryOptions3, skipToken as skipToken3, useQuery as useQuery4 } from "@tanstack/react-query";
699
+ import { useClient as useClient2 } from "wagmi";
700
+ import { queryOptions as queryOptions2, skipToken as skipToken2, useQuery as useQuery3 } from "@tanstack/react-query";
755
701
 
756
702
  // src/onboarding/getDelegation.ts
757
- import { getRecord as getRecord3 } from "@latticexyz/store/internal";
703
+ import { getRecord as getRecord2 } from "@latticexyz/store/internal";
758
704
 
759
705
  // src/common.ts
760
706
  import { resourceToHex } from "@latticexyz/common";
@@ -778,7 +724,7 @@ async function getDelegation({
778
724
  // TODO: move everything to latest instead of pending
779
725
  blockTag = "pending"
780
726
  }) {
781
- const record = await getRecord3(client, {
727
+ const record = await getRecord2(client, {
782
728
  address: worldAddress,
783
729
  table: worldTables.UserDelegationControl,
784
730
  key: { delegator: userAddress, delegatee: sessionAddress },
@@ -794,15 +740,15 @@ function getDelegationQueryOptions({
794
740
  userAddress,
795
741
  sessionAddress
796
742
  }) {
797
- return queryOptions3({
743
+ return queryOptions2({
798
744
  queryKey: ["getDelegation", client?.uid, worldAddress, userAddress, sessionAddress],
799
- queryFn: client && userAddress && sessionAddress ? () => getDelegation({ client, worldAddress, userAddress, sessionAddress }) : skipToken3
745
+ queryFn: client && userAddress && sessionAddress ? () => getDelegation({ client, worldAddress, userAddress, sessionAddress }) : skipToken2
800
746
  });
801
747
  }
802
748
 
803
749
  // src/useSessionAccount.ts
804
- import { useClient as useClient4 } from "wagmi";
805
- import { queryOptions as queryOptions4, skipToken as skipToken4, useQuery as useQuery5 } from "@tanstack/react-query";
750
+ import { useClient as useClient3 } from "wagmi";
751
+ import { queryOptions as queryOptions3, skipToken as skipToken3, useQuery as useQuery4 } from "@tanstack/react-query";
806
752
 
807
753
  // src/getSessionAccount.ts
808
754
  import { toSimpleSmartAccount } from "permissionless/accounts";
@@ -866,15 +812,73 @@ function getSessionAccountQueryOptions({
866
812
  client,
867
813
  userAddress
868
814
  }) {
869
- return queryOptions4({
815
+ return queryOptions3({
870
816
  queryKey: ["getSessionAccount", client?.uid, userAddress],
871
- queryFn: client && userAddress ? () => getSessionAccount({ client, userAddress }) : skipToken4,
817
+ queryFn: client && userAddress ? () => getSessionAccount({ client, userAddress }) : skipToken3,
872
818
  staleTime: Infinity,
873
819
  // TODO: replace with function to retry only connection errors
874
820
  retry: false
875
821
  });
876
822
  }
877
823
 
824
+ // src/useFunds.ts
825
+ import { useClient as useClient6, useConfig } from "wagmi";
826
+ import { getBalanceQueryOptions as getBalanceQueryOptions2 } from "wagmi/query";
827
+ import { queryOptions as queryOptions6, useQuery as useQuery7, useQueryClient } from "@tanstack/react-query";
828
+
829
+ // src/onboarding/quarry/useAllowance.ts
830
+ import { useClient as useClient4 } from "wagmi";
831
+ import { queryOptions as queryOptions4, skipToken as skipToken4, useQuery as useQuery5 } from "@tanstack/react-query";
832
+
833
+ // src/quarry/getAllowance.ts
834
+ import { numberToHex as numberToHex2 } from "viem";
835
+ import { getRecord as getRecord3, getStaticDataLocation } from "@latticexyz/store/internal";
836
+ import { getKeyTuple } from "@latticexyz/protocol-parser/internal";
837
+ import { setStorageAt } from "viem/actions";
838
+ async function getAllowance({ client, userAddress }) {
839
+ const paymaster = getPaymaster(client.chain);
840
+ if (paymaster?.type !== "quarry") return null;
841
+ const record = await getRecord3(client, {
842
+ address: paymaster.address,
843
+ table: paymasterTables.Allowance,
844
+ key: { user: userAddress },
845
+ blockTag: "pending"
846
+ });
847
+ return record.allowance;
848
+ }
849
+ async function setAllowanceSlot({ client, userAddress, allowance }) {
850
+ const paymaster = getPaymaster(client.chain);
851
+ if (paymaster?.type !== "quarry") return;
852
+ const slot = getStaticDataLocation(
853
+ paymasterTables.Allowance.tableId,
854
+ getKeyTuple(paymasterTables.Allowance, { user: userAddress })
855
+ );
856
+ await setStorageAt(
857
+ client.extend(() => ({ mode: "anvil" })),
858
+ {
859
+ address: paymaster.address,
860
+ index: slot,
861
+ value: numberToHex2(allowance, { size: 32 })
862
+ }
863
+ );
864
+ }
865
+
866
+ // src/onboarding/quarry/useAllowance.ts
867
+ function getAllowanceQueryOptions({
868
+ client,
869
+ userAddress
870
+ }) {
871
+ return queryOptions4({
872
+ queryKey: ["getAllowance", client?.uid, userAddress],
873
+ queryFn: client && userAddress ? () => getAllowance({ client, userAddress }) : skipToken4
874
+ });
875
+ }
876
+ function useAllowance(userAddress) {
877
+ const { chainId } = useEntryKitConfig();
878
+ const client = useClient4({ chainId });
879
+ return useQuery5(getAllowanceQueryOptions({ client, userAddress }));
880
+ }
881
+
878
882
  // src/onboarding/quarry/useBalance.ts
879
883
  import { useClient as useClient5 } from "wagmi";
880
884
  import { queryOptions as queryOptions5, skipToken as skipToken5, useQuery as useQuery6 } from "@tanstack/react-query";
@@ -909,6 +913,43 @@ function useBalance(userAddress) {
909
913
  return useQuery6(getBalanceQueryOptions({ client, userAddress }));
910
914
  }
911
915
 
916
+ // src/useFunds.ts
917
+ function getFundsQueryOptions({
918
+ queryClient,
919
+ config,
920
+ client,
921
+ userAddress
922
+ }) {
923
+ return queryOptions6({
924
+ queryKey: ["getFunds", client?.uid, userAddress],
925
+ queryFn: async () => {
926
+ if (!client) throw new Error("Viem client not ready.");
927
+ if (!userAddress) throw new Error("User not connected.");
928
+ const {
929
+ account: { address: sessionAddress }
930
+ } = await queryClient.fetchQuery(getSessionAccountQueryOptions({ client, userAddress }));
931
+ const [sessionBalance, paymasterAllowance, paymasterBalance] = await Promise.all([
932
+ queryClient.fetchQuery(getBalanceQueryOptions2(config, { chainId: client.chain.id, address: sessionAddress })),
933
+ queryClient.fetchQuery(getAllowanceQueryOptions({ client, userAddress })),
934
+ queryClient.fetchQuery(getBalanceQueryOptions({ client, userAddress }))
935
+ ]);
936
+ return {
937
+ sessionBalance: sessionBalance?.value ?? null,
938
+ paymasterAllowance,
939
+ paymasterBalance
940
+ };
941
+ },
942
+ retry: false
943
+ });
944
+ }
945
+ function useFunds(userAddress) {
946
+ const queryClient = useQueryClient();
947
+ const config = useConfig();
948
+ const { chainId } = useEntryKitConfig();
949
+ const client = useClient6({ chainId });
950
+ return useQuery7(getFundsQueryOptions({ queryClient, config, client, userAddress }), queryClient);
951
+ }
952
+
912
953
  // src/onboarding/usePrerequisites.ts
913
954
  function getPrequisitesQueryOptions({
914
955
  queryClient,
@@ -917,26 +958,23 @@ function getPrequisitesQueryOptions({
917
958
  userAddress,
918
959
  worldAddress
919
960
  }) {
920
- return queryOptions6({
961
+ return queryOptions7({
921
962
  queryKey: ["getPrerequisites", client?.uid, userAddress],
922
- queryFn: client && userAddress ? async () => {
923
- const paymaster = getPaymaster(client.chain);
963
+ queryFn: async () => {
964
+ if (!client) throw new Error("Viem client not ready.");
965
+ if (!userAddress) throw new Error("User not connected.");
924
966
  const {
925
967
  account: { address: sessionAddress }
926
968
  } = await queryClient.fetchQuery(getSessionAccountQueryOptions({ client, userAddress }));
927
- const [sessionBalance, allowance, spender, quarryBalance, hasDelegation] = await Promise.all([
928
- !paymaster ? queryClient.fetchQuery(
929
- getBalanceQueryOptions2(config, { chainId: client.chain.id, address: sessionAddress })
930
- ) : null,
931
- paymaster?.type === "quarry" ? queryClient.fetchQuery(getAllowanceQueryOptions({ client, userAddress })) : null,
932
- paymaster?.type === "quarry" ? queryClient.fetchQuery(getSpenderQueryOptions({ client, userAddress, sessionAddress })) : null,
933
- paymaster?.type === "quarry" ? queryClient.fetchQuery(getBalanceQueryOptions({ client, userAddress })) : null,
969
+ const [funds, spender, hasDelegation] = await Promise.all([
970
+ queryClient.fetchQuery(getFundsQueryOptions({ queryClient, config, client, userAddress })),
971
+ queryClient.fetchQuery(getSpenderQueryOptions({ client, userAddress, sessionAddress })),
934
972
  queryClient.fetchQuery(getDelegationQueryOptions({ client, worldAddress, userAddress, sessionAddress }))
935
973
  ]);
936
- const hasAllowance = allowance == null || allowance > 0n;
974
+ const hasAllowance = funds.paymasterAllowance == null || funds.paymasterAllowance > 0n;
937
975
  const isSpender = spender == null ? true : spender;
938
- const hasGasBalance = sessionBalance == null || sessionBalance.value > 0n;
939
- const hasQuarryGasBalance = quarryBalance == null || quarryBalance > 0n;
976
+ const hasGasBalance = funds.sessionBalance == null || funds.sessionBalance > 0n;
977
+ const hasQuarryGasBalance = funds.paymasterBalance == null || funds.paymasterBalance > 0n;
940
978
  return {
941
979
  sessionAddress,
942
980
  hasAllowance,
@@ -947,16 +985,16 @@ function getPrequisitesQueryOptions({
947
985
  // we intentionally don't enforce an allowance/gas balance here
948
986
  complete: isSpender && hasDelegation
949
987
  };
950
- } : skipToken6,
988
+ },
951
989
  retry: false
952
990
  });
953
991
  }
954
992
  function usePrerequisites(userAddress) {
955
- const queryClient = useQueryClient();
956
- const config = useConfig();
993
+ const queryClient = useQueryClient2();
994
+ const config = useConfig2();
957
995
  const { chainId, worldAddress } = useEntryKitConfig();
958
- const client = useClient6({ chainId });
959
- const prereqs = useQuery7(
996
+ const client = useClient7({ chainId });
997
+ const prereqs = useQuery8(
960
998
  getPrequisitesQueryOptions({
961
999
  queryClient,
962
1000
  config,
@@ -973,10 +1011,10 @@ function usePrerequisites(userAddress) {
973
1011
  import { useDisconnect } from "wagmi";
974
1012
 
975
1013
  // src/useENS.ts
976
- import { useQuery as useQuery8 } from "@tanstack/react-query";
1014
+ import { useQuery as useQuery9 } from "@tanstack/react-query";
977
1015
  function useENS(address) {
978
1016
  const normalizedAddress = address?.toLowerCase();
979
- return useQuery8({
1017
+ return useQuery9({
980
1018
  enabled: !!normalizedAddress,
981
1019
  queryKey: ["ens", normalizedAddress],
982
1020
  queryFn: async () => {
@@ -1100,7 +1138,7 @@ import { parseEther as parseEther3 } from "viem";
1100
1138
 
1101
1139
  // src/onboarding/quarry/useClaimGasPass.ts
1102
1140
  import { parseEther as parseEther2 } from "viem";
1103
- import { useMutation, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
1141
+ import { useMutation, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
1104
1142
 
1105
1143
  // src/quarry/transports/quarryPassIssuer.ts
1106
1144
  import { http as http2 } from "viem";
@@ -1129,11 +1167,11 @@ async function claimGasPass({ chain, userAddress }) {
1129
1167
  }
1130
1168
 
1131
1169
  // src/onboarding/quarry/useClaimGasPass.ts
1132
- import { useClient as useClient7 } from "wagmi";
1170
+ import { useClient as useClient8 } from "wagmi";
1133
1171
  function useClaimGasPass() {
1134
- const queryClient = useQueryClient2();
1172
+ const queryClient = useQueryClient3();
1135
1173
  const { chain } = useEntryKitConfig();
1136
- const client = useClient7({ chainId: chain.id });
1174
+ const client = useClient8({ chainId: chain.id });
1137
1175
  const mutationKey = ["claimGasPass", chain.id];
1138
1176
  return useMutation({
1139
1177
  retry: 0,
@@ -1147,6 +1185,7 @@ function useClaimGasPass() {
1147
1185
  }
1148
1186
  await Promise.all([
1149
1187
  queryClient.invalidateQueries({ queryKey: ["getAllowance"] }),
1188
+ queryClient.invalidateQueries({ queryKey: ["getFunds"] }),
1150
1189
  queryClient.invalidateQueries({ queryKey: ["getPrerequisites"] })
1151
1190
  ]);
1152
1191
  }
@@ -1253,7 +1292,7 @@ import { useEffect as useEffect7 } from "react";
1253
1292
 
1254
1293
  // src/onboarding/useSetupSession.ts
1255
1294
  import { encodeFunctionData } from "viem";
1256
- import { useMutation as useMutation2, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
1295
+ import { useMutation as useMutation2, useQueryClient as useQueryClient4 } from "@tanstack/react-query";
1257
1296
  import { getAction as getAction4 } from "viem/utils";
1258
1297
  import { sendUserOperation as sendUserOperation2, waitForUserOperationReceipt } from "viem/account-abstraction";
1259
1298
  import { waitForTransactionReceipt as waitForTransactionReceipt2 } from "viem/actions";
@@ -1264,7 +1303,7 @@ function defineCall(call) {
1264
1303
  }
1265
1304
 
1266
1305
  // src/onboarding/useSetupSession.ts
1267
- import { useClient as useClient8 } from "wagmi";
1306
+ import { useClient as useClient9 } from "wagmi";
1268
1307
  import { resourceToHex as resourceToHex2 } from "@latticexyz/common";
1269
1308
  import IBaseWorldAbi from "@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json";
1270
1309
 
@@ -1346,9 +1385,9 @@ async function callWithSignature({
1346
1385
  // src/onboarding/useSetupSession.ts
1347
1386
  import { systemsConfig as worldSystemsConfig } from "@latticexyz/world/mud.config";
1348
1387
  function useSetupSession({ userClient }) {
1349
- const queryClient = useQueryClient3();
1388
+ const queryClient = useQueryClient4();
1350
1389
  const { chainId, worldAddress } = useEntryKitConfig();
1351
- const client = useClient8({ chainId });
1390
+ const client = useClient9({ chainId });
1352
1391
  const mutationKey = ["setupSession", client?.chain.id, userClient.account.address];
1353
1392
  return useMutation2({
1354
1393
  retry: 0,
@@ -1455,12 +1494,11 @@ function useSetupSession({ userClient }) {
1455
1494
  }
1456
1495
 
1457
1496
  // src/useSessionClient.ts
1458
- import { useClient as useClient9 } from "wagmi";
1497
+ import { useClient as useClient10 } from "wagmi";
1459
1498
  import {
1460
- queryOptions as queryOptions7,
1461
- skipToken as skipToken7,
1462
- useQuery as useQuery9,
1463
- useQueryClient as useQueryClient4
1499
+ queryOptions as queryOptions8,
1500
+ useQuery as useQuery10,
1501
+ useQueryClient as useQueryClient5
1464
1502
  } from "@tanstack/react-query";
1465
1503
 
1466
1504
  // src/getSessionClient.ts
@@ -1544,9 +1582,10 @@ function getSessionClientQueryOptions({
1544
1582
  userAddress,
1545
1583
  worldAddress
1546
1584
  }) {
1547
- return queryOptions7({
1585
+ return queryOptions8({
1548
1586
  queryKey: ["getSessionClient", client?.uid, userAddress, worldAddress],
1549
- queryFn: userAddress ? async () => {
1587
+ queryFn: async () => {
1588
+ if (!userAddress) throw new Error("User not connected.");
1550
1589
  const { account: sessionAccount, signer: sessionSigner } = await queryClient.fetchQuery(
1551
1590
  getSessionAccountQueryOptions({ client, userAddress })
1552
1591
  );
@@ -1556,17 +1595,17 @@ function getSessionClientQueryOptions({
1556
1595
  userAddress,
1557
1596
  worldAddress
1558
1597
  });
1559
- } : skipToken7,
1598
+ },
1560
1599
  staleTime: Infinity,
1561
1600
  // TODO: replace with function to retry only connection errors
1562
1601
  retry: false
1563
1602
  });
1564
1603
  }
1565
1604
  function useSessionClient(userAddress) {
1566
- const queryClient = useQueryClient4();
1605
+ const queryClient = useQueryClient5();
1567
1606
  const { chainId, worldAddress } = useEntryKitConfig();
1568
- const client = useClient9({ chainId });
1569
- return useQuery9(
1607
+ const client = useClient10({ chainId });
1608
+ return useQuery10(
1570
1609
  getSessionClientQueryOptions({
1571
1610
  queryClient,
1572
1611
  client,
@@ -1635,7 +1674,7 @@ function Session({ isActive, isExpanded, userClient, registerSpender, registerDe
1635
1674
  // src/onboarding/GasBalance.tsx
1636
1675
  import { useEffect as useEffect9, useState as useState2 } from "react";
1637
1676
  import { parseEther as parseEther4 } from "viem";
1638
- import { useQueryClient as useQueryClient6 } from "@tanstack/react-query";
1677
+ import { useQueryClient as useQueryClient7 } from "@tanstack/react-query";
1639
1678
  import { useBalance as useBalance2, useWatchBlockNumber } from "wagmi";
1640
1679
 
1641
1680
  // src/data/relayChains.json
@@ -1919,13 +1958,13 @@ var relayChains_default = {
1919
1958
  };
1920
1959
 
1921
1960
  // src/onboarding/useSetBalance.ts
1922
- import { useQueryClient as useQueryClient5, useMutation as useMutation3 } from "@tanstack/react-query";
1961
+ import { useQueryClient as useQueryClient6, useMutation as useMutation3 } from "@tanstack/react-query";
1923
1962
  import { setBalance as setBalance2 } from "viem/actions";
1924
- import { useClient as useClient10 } from "wagmi";
1963
+ import { useClient as useClient11 } from "wagmi";
1925
1964
  function useSetBalance() {
1926
- const queryClient = useQueryClient5();
1965
+ const queryClient = useQueryClient6();
1927
1966
  const { chainId } = useEntryKitConfig();
1928
- const client = useClient10({ chainId });
1967
+ const client = useClient11({ chainId });
1929
1968
  return useMutation3({
1930
1969
  retry: 0,
1931
1970
  mutationKey: ["setBalance", chainId],
@@ -1934,6 +1973,7 @@ function useSetBalance() {
1934
1973
  await setBalance2({ ...client, mode: "anvil" }, params);
1935
1974
  await Promise.all([
1936
1975
  queryClient.invalidateQueries({ queryKey: ["balance"] }),
1976
+ queryClient.invalidateQueries({ queryKey: ["getFunds"] }),
1937
1977
  queryClient.invalidateQueries({ queryKey: ["getPrerequisites"] })
1938
1978
  ]);
1939
1979
  return null;
@@ -2003,7 +2043,7 @@ function CheckIcon(props) {
2003
2043
  // src/onboarding/GasBalance.tsx
2004
2044
  import { Fragment, jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
2005
2045
  function GasBalance({ isActive, isExpanded, sessionAddress }) {
2006
- const queryClient = useQueryClient6();
2046
+ const queryClient = useQueryClient7();
2007
2047
  const { chain } = useEntryKitConfig();
2008
2048
  const [copied, setCopied] = useState2(false);
2009
2049
  const balance = useShowQueryError(useBalance2({ chainId: chain.id, address: sessionAddress }));
@@ -2018,6 +2058,7 @@ function GasBalance({ isActive, isExpanded, sessionAddress }) {
2018
2058
  };
2019
2059
  useEffect9(() => {
2020
2060
  if (balance.data != null && prevBalance?.value === 0n && balance.data.value > 0n) {
2061
+ queryClient.invalidateQueries({ queryKey: ["getFunds"] });
2021
2062
  queryClient.invalidateQueries({ queryKey: ["getPrerequisites"] });
2022
2063
  }
2023
2064
  }, [balance.data, prevBalance, setBalance3, sessionAddress, queryClient]);
@@ -2091,7 +2132,7 @@ function GasBalance({ isActive, isExpanded, sessionAddress }) {
2091
2132
 
2092
2133
  // src/onboarding/quarry/GasBalance.tsx
2093
2134
  import { useEffect as useEffect14 } from "react";
2094
- import { useQueryClient as useQueryClient9 } from "@tanstack/react-query";
2135
+ import { useQueryClient as useQueryClient10 } from "@tanstack/react-query";
2095
2136
 
2096
2137
  // src/onboarding/deposit/DepositFormContainer.tsx
2097
2138
  import { useState as useState4 } from "react";
@@ -2100,7 +2141,7 @@ import { useChains as useChains4, useChainId } from "wagmi";
2100
2141
  // src/onboarding/deposit/DepositViaTransferForm.tsx
2101
2142
  import { useAccount as useAccount4, useWriteContract, usePrepareTransactionRequest, usePublicClient } from "wagmi";
2102
2143
  import { encodeFunctionData as encodeFunctionData2 } from "viem";
2103
- import { useMutation as useMutation4, useQuery as useQuery12 } from "@tanstack/react-query";
2144
+ import { useMutation as useMutation4, useQuery as useQuery13 } from "@tanstack/react-query";
2104
2145
 
2105
2146
  // src/onboarding/deposit/DepositForm.tsx
2106
2147
  import { useEffect as useEffect11, useRef as useRef4 } from "react";
@@ -2228,12 +2269,12 @@ import {
2228
2269
  createClient as createClient2,
2229
2270
  LogLevel
2230
2271
  } from "@reservoir0x/relay-sdk";
2231
- import { useQuery as useQuery10 } from "@tanstack/react-query";
2272
+ import { useQuery as useQuery11 } from "@tanstack/react-query";
2232
2273
  function useRelay() {
2233
2274
  const { chain } = useEntryKitConfig();
2234
2275
  const appOrigin = location.host;
2235
2276
  const baseApiUrl = chain.testnet ? TESTNET_RELAY_API : MAINNET_RELAY_API;
2236
- return useQuery10({
2277
+ return useQuery11({
2237
2278
  queryKey: ["relayChains", baseApiUrl, appOrigin],
2238
2279
  queryFn: async () => {
2239
2280
  debug("fetching relay chains from", baseApiUrl);
@@ -2257,13 +2298,13 @@ function useRelay() {
2257
2298
  // src/onboarding/deposit/useChainBalances.ts
2258
2299
  import { useAccount, useConfig as useWagmiConfig } from "wagmi";
2259
2300
  import { getBalance as getBalance2 } from "wagmi/actions";
2260
- import { useQuery as useQuery11, skipToken as skipToken8 } from "@tanstack/react-query";
2301
+ import { useQuery as useQuery12, skipToken as skipToken6 } from "@tanstack/react-query";
2261
2302
  import { isNotNull } from "@latticexyz/common/utils";
2262
2303
  function useChainBalances({ chains }) {
2263
2304
  const { address: userAddress } = useAccount();
2264
2305
  const wagmiConfig = useWagmiConfig();
2265
2306
  const chainIds = chains.map((chain) => chain.id);
2266
- return useQuery11({
2307
+ return useQuery12({
2267
2308
  queryKey: ["chainBalances", chainIds, userAddress],
2268
2309
  queryFn: userAddress ? async () => {
2269
2310
  const chainBalances = await Promise.allSettled(
@@ -2273,7 +2314,7 @@ function useChainBalances({ chains }) {
2273
2314
  })
2274
2315
  );
2275
2316
  return chainBalances.map((result) => result.status === "fulfilled" ? result.value : null).filter(isNotNull);
2276
- } : skipToken8,
2317
+ } : skipToken6,
2277
2318
  refetchInterval: 1e3 * 60,
2278
2319
  retry: 1
2279
2320
  });
@@ -2612,7 +2653,7 @@ function DepositViaTransferForm({ amount, setAmount, sourceChain, setSourceChain
2612
2653
  if (!userAddress) {
2613
2654
  throw new Error("User address not found");
2614
2655
  }
2615
- const { data: gasPrice } = useQuery12({
2656
+ const { data: gasPrice } = useQuery13({
2616
2657
  queryKey: ["gasPrice", sourceChain.id],
2617
2658
  queryFn: async () => {
2618
2659
  if (!publicClient) throw new Error("Public client not available");
@@ -2703,7 +2744,7 @@ function DepositViaTransferForm({ amount, setAmount, sourceChain, setSourceChain
2703
2744
  // src/onboarding/deposit/DepositViaRelayForm.tsx
2704
2745
  import { encodeFunctionData as encodeFunctionData3 } from "viem";
2705
2746
  import { useAccount as useAccount5, useWalletClient } from "wagmi";
2706
- import { useMutation as useMutation5, useQuery as useQuery13 } from "@tanstack/react-query";
2747
+ import { useMutation as useMutation5, useQuery as useQuery14 } from "@tanstack/react-query";
2707
2748
  import { jsx as jsx31 } from "react/jsx-runtime";
2708
2749
  var ETH_ADDRESS = "0x0000000000000000000000000000000000000000";
2709
2750
  function DepositViaRelayForm({ amount, setAmount, sourceChain, setSourceChainId }) {
@@ -2714,7 +2755,7 @@ function DepositViaRelayForm({ amount, setAmount, sourceChain, setSourceChainId
2714
2755
  const { addDeposit } = useDeposits();
2715
2756
  const { data: relay } = useRelay();
2716
2757
  const relayClient = relay?.client;
2717
- const quote = useQuery13({
2758
+ const quote = useQuery14({
2718
2759
  queryKey: ["relayBridgeQuote", sourceChain.id, amount?.toString()],
2719
2760
  queryFn: async () => {
2720
2761
  if (!relayClient) throw new Error("No Relay client found.");
@@ -2824,10 +2865,10 @@ function DepositViaRelayForm({ amount, setAmount, sourceChain, setSourceChainId
2824
2865
 
2825
2866
  // src/onboarding/deposit/Deposits.tsx
2826
2867
  import { useEffect as useEffect13 } from "react";
2827
- import { useQuery as useQuery16, useQueryClient as useQueryClient7 } from "@tanstack/react-query";
2868
+ import { useQuery as useQuery17, useQueryClient as useQueryClient8 } from "@tanstack/react-query";
2828
2869
 
2829
2870
  // src/onboarding/deposit/TransferDepositStatus.tsx
2830
- import { useQuery as useQuery14 } from "@tanstack/react-query";
2871
+ import { useQuery as useQuery15 } from "@tanstack/react-query";
2831
2872
 
2832
2873
  // src/onboarding/deposit/DepositStatus.tsx
2833
2874
  import { useEffect as useEffect12, useState as useState3 } from "react";
@@ -2910,7 +2951,7 @@ function TransferDepositStatus({
2910
2951
  }) {
2911
2952
  const chains = useChains2();
2912
2953
  const chain = chains.find((chain2) => chain2.id === chainL1Id);
2913
- const receipt = useQuery14({
2954
+ const receipt = useQuery15({
2914
2955
  queryKey: ["transferDepositStatus", hash],
2915
2956
  queryFn: () => receiptPromise
2916
2957
  });
@@ -2978,7 +3019,7 @@ function TransferDepositStatus({
2978
3019
  }
2979
3020
 
2980
3021
  // src/onboarding/deposit/RelayDepositStatus.tsx
2981
- import { useQuery as useQuery15 } from "@tanstack/react-query";
3022
+ import { useQuery as useQuery16 } from "@tanstack/react-query";
2982
3023
  import { useChains as useChains3 } from "wagmi";
2983
3024
  import { Fragment as Fragment5, jsx as jsx35, jsxs as jsxs21 } from "react/jsx-runtime";
2984
3025
  function RelayDepositStatus({
@@ -2993,7 +3034,7 @@ function RelayDepositStatus({
2993
3034
  const chains = useChains3();
2994
3035
  const chainL1 = chains.find((chain) => chain.id === chainL1Id);
2995
3036
  const chainL2 = chains.find((chain) => chain.id === chainL2Id);
2996
- const deposit = useQuery15({
3037
+ const deposit = useQuery16({
2997
3038
  queryKey: ["relayDepositPromise", chainL1Id, chainL2Id, amount.toString(), start.toISOString()],
2998
3039
  queryFn: () => depositPromise
2999
3040
  });
@@ -3034,15 +3075,15 @@ function RelayDepositStatus({
3034
3075
  }
3035
3076
 
3036
3077
  // src/onboarding/deposit/Deposits.tsx
3037
- import { useAccount as useAccount6, useClient as useClient11 } from "wagmi";
3078
+ import { useAccount as useAccount6, useClient as useClient12 } from "wagmi";
3038
3079
  import { jsx as jsx36 } from "react/jsx-runtime";
3039
3080
  function Deposits() {
3040
- const queryClient = useQueryClient7();
3081
+ const queryClient = useQueryClient8();
3041
3082
  const { chainId } = useEntryKitConfig();
3042
- const client = useClient11({ chainId });
3083
+ const client = useClient12({ chainId });
3043
3084
  const { address: userAddress } = useAccount6();
3044
3085
  const { deposits, removeDeposit } = useDeposits();
3045
- const { data: isComplete } = useQuery16({
3086
+ const { data: isComplete } = useQuery17({
3046
3087
  queryKey: ["depositsComplete", deposits.map((deposit) => deposit.uid)],
3047
3088
  queryFn: async () => {
3048
3089
  if (!deposits.length) return false;
@@ -3116,18 +3157,18 @@ function ArrowLeftIcon(props) {
3116
3157
  // src/onboarding/quarry/WithdrawGasBalanceButton.tsx
3117
3158
  import { getAction as getAction6 } from "viem/utils";
3118
3159
  import { waitForTransactionReceipt as waitForTransactionReceipt3 } from "viem/actions";
3119
- import { useAccount as useAccount7, useClient as useClient12, useSwitchChain as useSwitchChain3, useWriteContract as useWriteContract2 } from "wagmi";
3160
+ import { useAccount as useAccount7, useClient as useClient13, useSwitchChain as useSwitchChain3, useWriteContract as useWriteContract2 } from "wagmi";
3120
3161
  import { twMerge as twMerge17 } from "tailwind-merge";
3121
3162
  import { useMutation as useMutation6 } from "@tanstack/react-query";
3122
- import { useQueryClient as useQueryClient8 } from "@tanstack/react-query";
3163
+ import { useQueryClient as useQueryClient9 } from "@tanstack/react-query";
3123
3164
  import { jsx as jsx39, jsxs as jsxs23 } from "react/jsx-runtime";
3124
3165
  function WithdrawGasBalanceButton({ userAddress }) {
3125
3166
  const { writeContractAsync } = useWriteContract2();
3126
3167
  const { switchChain } = useSwitchChain3();
3127
3168
  const { chain, chainId } = useEntryKitConfig();
3128
3169
  const { chainId: userChainId } = useAccount7();
3129
- const queryClient = useQueryClient8();
3130
- const client = useClient12({ chainId });
3170
+ const queryClient = useQueryClient9();
3171
+ const client = useClient13({ chainId });
3131
3172
  const paymaster = getPaymaster(chain);
3132
3173
  const balance = useShowQueryError(useBalance(userAddress));
3133
3174
  const shouldSwitchChain = chainId != null && chainId !== userChainId;
@@ -3148,6 +3189,7 @@ function WithdrawGasBalanceButton({ userAddress }) {
3148
3189
  await getAction6(client, waitForTransactionReceipt3, "waitForTransactionReceipt")({ hash });
3149
3190
  await Promise.all([
3150
3191
  queryClient.invalidateQueries({ queryKey: ["balance"] }),
3192
+ queryClient.invalidateQueries({ queryKey: ["getFunds"] }),
3151
3193
  queryClient.invalidateQueries({ queryKey: ["getPrerequisites"] })
3152
3194
  ]);
3153
3195
  } catch (error2) {
@@ -3197,7 +3239,7 @@ function WithdrawGasBalanceButton({ userAddress }) {
3197
3239
  // src/onboarding/quarry/GasBalance.tsx
3198
3240
  import { jsx as jsx40, jsxs as jsxs24 } from "react/jsx-runtime";
3199
3241
  function GasBalance2({ isActive, isExpanded, isFocused, setFocused, userAddress }) {
3200
- const queryClient = useQueryClient9();
3242
+ const queryClient = useQueryClient10();
3201
3243
  const balance = useShowQueryError(useBalance(userAddress));
3202
3244
  const prevBalance = usePrevious(balance.data || 0n);
3203
3245
  useEffect14(() => {
@@ -3626,7 +3668,7 @@ function AccountButton() {
3626
3668
  "hover:bg-orange-400",
3627
3669
  "active:bg-orange-600"
3628
3670
  ),
3629
- "aria-busy": accountModalOpen,
3671
+ "aria-busy": accountModalOpen || prereqs.isPending,
3630
3672
  onClick: openAccountModal,
3631
3673
  children: [
3632
3674
  /* @__PURE__ */ jsxs29("span", { className: "pointer-events-none inline-grid place-items-center -ml-3", children: [
@@ -3670,8 +3712,9 @@ function useSessionClientReady() {
3670
3712
  const userAddress = userClient.data?.account.address;
3671
3713
  const prerequisites = usePrerequisites(userAddress);
3672
3714
  const sessionClient = useSessionClient(userAddress);
3673
- if (!userClient.isSuccess) return { ...userClient, data: void 0 };
3674
- if (!prerequisites.isSuccess || !prerequisites.data.complete) return { ...prerequisites, data: void 0 };
3715
+ if (!prerequisites.isSuccess || !prerequisites.data.complete) {
3716
+ return { ...prerequisites, data: void 0 };
3717
+ }
3675
3718
  return sessionClient;
3676
3719
  }
3677
3720
 
@@ -4099,9 +4142,11 @@ export {
4099
4142
  EntryKitProvider,
4100
4143
  createWagmiConfig,
4101
4144
  defineConfig,
4145
+ getFundsQueryOptions,
4102
4146
  internal_validateSigner,
4103
4147
  useAccountModal,
4104
4148
  useEntryKitConfig,
4149
+ useFunds,
4105
4150
  useSessionClientReady as useSessionClient
4106
4151
  };
4107
4152
  //# sourceMappingURL=internal.js.map