@mysten/dapp-kit 0.9.1 → 0.10.1

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,9 @@ function useAutoConnectWallet() {
935
941
  if (!autoConnectEnabled) {
936
942
  return "disabled";
937
943
  }
944
+ if (!clientOnly) {
945
+ return "idle";
946
+ }
938
947
  if (!lastConnectedWalletName) {
939
948
  return "attempted";
940
949
  }
@@ -1249,7 +1258,7 @@ function createWalletStore({
1249
1258
  const currentAccount = get().currentAccount;
1250
1259
  set(() => ({
1251
1260
  accounts,
1252
- currentAccount: currentAccount ? accounts.find(({ address }) => address === currentAccount.address) : accounts[0]
1261
+ currentAccount: currentAccount && accounts.find(({ address }) => address === currentAccount.address) || accounts[0]
1253
1262
  }));
1254
1263
  }
1255
1264
  }),