@cometh/connect-react-hooks 0.1.0-dev.1 → 1.0.0

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/index.js CHANGED
@@ -79,8 +79,7 @@ var ConnectContext = createContext({
79
79
  queryClient: void 0,
80
80
  smartAccountClient: null,
81
81
  smartAccountAddress: void 0,
82
- updateSmartAccountClient: async () => {
83
- },
82
+ updateSmartAccountClient: async () => null,
84
83
  disconnectSmartAccount: async () => {
85
84
  },
86
85
  networksConfig: void 0
@@ -101,9 +100,9 @@ var ConnectProvider = ({
101
100
  const paymasterUrl = config.networksConfig.find(
102
101
  (network) => network.chain?.id === chain.id
103
102
  )?.paymasterUrl;
104
- const rpcUrl = config.networksConfig.find(
103
+ const publicClient = config.networksConfig.find(
105
104
  (network) => network.chain?.id === chain.id
106
- )?.rpcUrl;
105
+ )?.publicClient;
107
106
  if (!bundlerUrl) throw new Error("Bundler url not found");
108
107
  try {
109
108
  const { client, address: newAddress } = await createSmartAccount({
@@ -111,7 +110,7 @@ var ConnectProvider = ({
111
110
  chain,
112
111
  bundlerUrl,
113
112
  paymasterUrl,
114
- rpcUrl,
113
+ publicClient,
115
114
  smartAccountAddress: params.address,
116
115
  comethSignerConfig: {
117
116
  ...config.comethSignerConfig,
@@ -121,8 +120,10 @@ var ConnectProvider = ({
121
120
  setSmartAccountClient(client);
122
121
  setSmartAccountAddress(newAddress);
123
122
  localStorage.setItem(CHAIN_STORAGE_KEY, JSON.stringify(chain));
123
+ return client;
124
124
  } catch (e) {
125
125
  console.log(e);
126
+ return smartAccountClient;
126
127
  }
127
128
  },
128
129
  [config, config.networksConfig[0].chain]
@@ -1271,14 +1272,15 @@ function useBaseQuery(options, Observer, queryClient) {
1271
1272
  )
1272
1273
  );
1273
1274
  const result = observer.getOptimisticResult(defaultedOptions);
1275
+ const shouldSubscribe = !isRestoring && options.subscribed !== false;
1274
1276
  React6.useSyncExternalStore(
1275
1277
  React6.useCallback(
1276
1278
  (onStoreChange) => {
1277
- const unsubscribe = isRestoring ? noop2 : observer.subscribe(notifyManager.batchCalls(onStoreChange));
1279
+ const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop2;
1278
1280
  observer.updateResult();
1279
1281
  return unsubscribe;
1280
1282
  },
1281
- [observer, isRestoring]
1283
+ [observer, shouldSubscribe]
1282
1284
  ),
1283
1285
  () => observer.getCurrentResult(),
1284
1286
  () => observer.getCurrentResult()
@@ -1957,15 +1959,11 @@ function useSetUpRecovery() {
1957
1959
  const { smartAccountClient, queryClient } = useSmartAccount();
1958
1960
  const { mutate, mutateAsync, ...result } = useMutation(
1959
1961
  {
1960
- mutationFn: async (variables) => {
1962
+ mutationFn: async () => {
1961
1963
  if (!smartAccountClient) {
1962
1964
  throw new Error("No smart account found");
1963
1965
  }
1964
- return smartAccountClient.setUpRecoveryModule({
1965
- passKeyName: variables.passKeyName,
1966
- publicClient: variables.publicClient,
1967
- webAuthnOptions: variables.webAuthnOptions
1968
- });
1966
+ return smartAccountClient.setUpRecoveryModule();
1969
1967
  }
1970
1968
  },
1971
1969
  queryClient
@@ -1986,7 +1984,7 @@ function useIsRecoveryActive(props = {}) {
1986
1984
  const { smartAccountClient, queryClient } = useSmartAccount();
1987
1985
  return useQuery(
1988
1986
  {
1989
- queryKey: ["isRecoveryActive", props.publicClient],
1987
+ queryKey: ["isRecoveryActive"],
1990
1988
  queryFn: async () => {
1991
1989
  if (!smartAccountClient) {
1992
1990
  throw new Error("No smart account found");
@@ -2004,7 +2002,7 @@ function useGetRecoveryRequest(props = {}, queryOptions) {
2004
2002
  const { smartAccountClient, queryClient } = useSmartAccount();
2005
2003
  const { data, isLoading, isError, error } = useQuery(
2006
2004
  {
2007
- queryKey: ["getRecoveryRequest", props.publicClient],
2005
+ queryKey: ["getRecoveryRequest"],
2008
2006
  queryFn: async () => {
2009
2007
  if (!smartAccountClient) {
2010
2008
  throw new Error("No smart account found");
@@ -2034,7 +2032,7 @@ function useCancelRecoveryRequest() {
2034
2032
  throw new Error("No smart account found");
2035
2033
  }
2036
2034
  return smartAccountClient.cancelRecoveryRequest({
2037
- publicClient: variables.publicClient
2035
+ effectiveDelayAddress: variables.effectiveDelayAddress
2038
2036
  });
2039
2037
  }
2040
2038
  },
@@ -2077,13 +2075,14 @@ var useSwitchChain = () => {
2077
2075
  if (!selectedNetwork)
2078
2076
  throw new Error("No current configuration found");
2079
2077
  try {
2080
- await updateSmartAccountClient({
2078
+ const client = await updateSmartAccountClient({
2081
2079
  address: smartAccountClient?.account.address,
2082
2080
  chain: selectedNetwork.chain
2083
2081
  });
2084
2082
  queryClient?.invalidateQueries({
2085
2083
  queryKey: ["switchChain"]
2086
2084
  });
2085
+ return client;
2087
2086
  } catch (e) {
2088
2087
  throw e instanceof Error ? e : new Error("An error occurred while switching chain");
2089
2088
  }
@@ -2099,7 +2098,7 @@ var useSwitchChain = () => {
2099
2098
  (params) => {
2100
2099
  setIsPending(true);
2101
2100
  setError(null);
2102
- switchChainInternal(params).catch((e) => {
2101
+ return switchChainInternal(params).catch((e) => {
2103
2102
  const err = e instanceof Error ? e : new Error(
2104
2103
  "An error occurred while switching chain"
2105
2104
  );
@@ -2115,7 +2114,8 @@ var useSwitchChain = () => {
2115
2114
  setIsPending(true);
2116
2115
  setError(null);
2117
2116
  try {
2118
- await switchChainInternal(params);
2117
+ const client = await switchChainInternal(params);
2118
+ return client;
2119
2119
  } catch (e) {
2120
2120
  const err = e instanceof Error ? e : new Error("An error occurred while switching chain");
2121
2121
  setError(err);
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "https://twitter.com/slovaye"
8
8
  }
9
9
  ],
10
- "version": "0.1.0-dev.1",
10
+ "version": "1.0.0",
11
11
  "description": "React hooks Connect 4337",
12
12
  "repository": "https://github.com/cometh-hq/connect-sdk-4337.git",
13
13
  "keywords": [
@@ -58,7 +58,7 @@
58
58
  "typescript": "^5"
59
59
  },
60
60
  "dependencies": {
61
- "@cometh/connect-sdk-4337": "^0.3.0-dev.1",
61
+ "@cometh/connect-sdk-4337": "^1.0.1",
62
62
  "permissionless": "^0.2.23"
63
63
  }
64
64
  }