@mysten/dapp-kit 0.10.0 → 0.10.2

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.
package/dist/esm/index.js CHANGED
@@ -884,19 +884,24 @@ import { useRef } from "react";
884
884
 
885
885
  // src/hooks/wallet/useAutoConnectWallet.ts
886
886
  import { useQuery as useQuery2 } from "@tanstack/react-query";
887
+ import { useLayoutEffect, useState as useState3 } from "react";
887
888
  function useAutoConnectWallet() {
888
889
  const { mutateAsync: connectWallet } = useConnectWallet();
889
890
  const autoConnectEnabled = useWalletStore((state) => state.autoConnectEnabled);
890
891
  const lastConnectedWalletName = useWalletStore((state) => state.lastConnectedWalletName);
891
892
  const lastConnectedAccountAddress = useWalletStore((state) => state.lastConnectedAccountAddress);
892
893
  const wallets = useWallets();
893
- const { isDisconnected } = useCurrentWallet();
894
+ const { isConnected } = useCurrentWallet();
895
+ const [clientOnly, setClientOnly] = useState3(false);
896
+ useLayoutEffect(() => {
897
+ setClientOnly(true);
898
+ }, []);
894
899
  const { data, isError } = useQuery2({
895
900
  queryKey: [
896
901
  "@mysten/dapp-kit",
897
902
  "autoconnect",
898
903
  {
899
- isDisconnected,
904
+ isConnected,
900
905
  autoConnectEnabled,
901
906
  lastConnectedWalletName,
902
907
  lastConnectedAccountAddress,
@@ -907,7 +912,7 @@ function useAutoConnectWallet() {
907
912
  if (!autoConnectEnabled) {
908
913
  return "disabled";
909
914
  }
910
- if (!lastConnectedWalletName || !lastConnectedAccountAddress || !isDisconnected) {
915
+ if (!lastConnectedWalletName || !lastConnectedAccountAddress || isConnected) {
911
916
  return "attempted";
912
917
  }
913
918
  const wallet = wallets.find((wallet2) => wallet2.name === lastConnectedWalletName);
@@ -924,6 +929,7 @@ function useAutoConnectWallet() {
924
929
  persister: void 0,
925
930
  gcTime: 0,
926
931
  staleTime: 0,
932
+ networkMode: "always",
927
933
  retry: false,
928
934
  retryOnMount: false,
929
935
  refetchInterval: false,
@@ -935,6 +941,12 @@ function useAutoConnectWallet() {
935
941
  if (!autoConnectEnabled) {
936
942
  return "disabled";
937
943
  }
944
+ if (!clientOnly) {
945
+ return "idle";
946
+ }
947
+ if (isConnected) {
948
+ return "attempted";
949
+ }
938
950
  if (!lastConnectedWalletName) {
939
951
  return "attempted";
940
952
  }
@@ -1249,7 +1261,7 @@ function createWalletStore({
1249
1261
  const currentAccount = get().currentAccount;
1250
1262
  set(() => ({
1251
1263
  accounts,
1252
- currentAccount: currentAccount ? accounts.find(({ address }) => address === currentAccount.address) : accounts[0]
1264
+ currentAccount: currentAccount && accounts.find(({ address }) => address === currentAccount.address) || accounts[0]
1253
1265
  }));
1254
1266
  }
1255
1267
  }),
@@ -1468,6 +1480,28 @@ function useSuiClientMutation(method, options = {}) {
1468
1480
  });
1469
1481
  }
1470
1482
 
1483
+ // src/hooks/useSuiClientQueries.ts
1484
+ import { useQueries } from "@tanstack/react-query";
1485
+ function useSuiClientQueries({
1486
+ queries,
1487
+ combine
1488
+ }) {
1489
+ const suiContext = useSuiClientContext();
1490
+ return useQueries({
1491
+ combine,
1492
+ queries: queries.map((query) => {
1493
+ const { method, params, options: { queryKey = [], ...restOptions } = {} } = query;
1494
+ return {
1495
+ ...restOptions,
1496
+ queryKey: [suiContext.network, method, params, ...queryKey],
1497
+ queryFn: async () => {
1498
+ return await suiContext.client[method](params);
1499
+ }
1500
+ };
1501
+ })
1502
+ });
1503
+ }
1504
+
1471
1505
  // src/hooks/wallet/useSignAndExecuteTransactionBlock.ts
1472
1506
  import { useMutation as useMutation5 } from "@tanstack/react-query";
1473
1507
  function useSignAndExecuteTransactionBlock({
@@ -1630,6 +1664,7 @@ export {
1630
1664
  useSuiClientContext,
1631
1665
  useSuiClientInfiniteQuery,
1632
1666
  useSuiClientMutation,
1667
+ useSuiClientQueries,
1633
1668
  useSuiClientQuery,
1634
1669
  useSwitchAccount,
1635
1670
  useWallets