@cometh/connect-react-hooks 0.0.12-dev.3 → 0.1.0-dev.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/index.cjs CHANGED
@@ -12,7 +12,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
 
13
13
 
14
14
 
15
-
16
15
  var _connectsdk4337 = require('@cometh/connect-sdk-4337');
17
16
  var _wagmi = require('wagmi');
18
17
  async function createSmartAccount(config) {
@@ -21,7 +20,7 @@ async function createSmartAccount(config) {
21
20
  paymasterUrl,
22
21
  apiKey,
23
22
  chain,
24
- rpcUrl,
23
+ publicClient,
25
24
  baseUrl,
26
25
  comethSignerConfig,
27
26
  safeContractConfig,
@@ -30,10 +29,9 @@ async function createSmartAccount(config) {
30
29
  const account = await _connectsdk4337.createSafeSmartAccount.call(void 0, {
31
30
  apiKey,
32
31
  chain,
33
- rpcUrl,
32
+ publicClient,
34
33
  baseUrl,
35
34
  smartAccountAddress,
36
- entryPoint: _connectsdk4337.ENTRYPOINT_ADDRESS_V07,
37
35
  comethSignerConfig,
38
36
  safeContractConfig
39
37
  });
@@ -42,27 +40,26 @@ async function createSmartAccount(config) {
42
40
  const paymasterClient = await _connectsdk4337.createComethPaymasterClient.call(void 0, {
43
41
  transport: _wagmi.http.call(void 0, paymasterUrl),
44
42
  chain,
45
- entryPoint: _connectsdk4337.ENTRYPOINT_ADDRESS_V07,
46
- rpcUrl
43
+ publicClient
47
44
  });
48
45
  client = _connectsdk4337.createSmartAccountClient.call(void 0, {
49
46
  account,
50
- entryPoint: _connectsdk4337.ENTRYPOINT_ADDRESS_V07,
51
47
  chain,
52
48
  bundlerTransport: _wagmi.http.call(void 0, bundlerUrl),
53
- middleware: {
54
- sponsorUserOperation: paymasterClient.sponsorUserOperation,
55
- gasPrice: paymasterClient.gasPrice
49
+ paymaster: paymasterClient,
50
+ userOperation: {
51
+ estimateFeesPerGas: async () => {
52
+ return await paymasterClient.getUserOperationGasPrice();
53
+ }
56
54
  },
57
- rpcUrl
55
+ publicClient
58
56
  });
59
57
  } else {
60
58
  client = _connectsdk4337.createSmartAccountClient.call(void 0, {
61
59
  account,
62
- entryPoint: _connectsdk4337.ENTRYPOINT_ADDRESS_V07,
63
60
  chain,
64
61
  bundlerTransport: _wagmi.http.call(void 0, bundlerUrl),
65
- rpcUrl
62
+ publicClient
66
63
  });
67
64
  }
68
65
  const address = client.account.address;
@@ -128,7 +125,7 @@ var ConnectProvider = ({
128
125
  console.log(e);
129
126
  }
130
127
  },
131
- [config]
128
+ [config, config.networksConfig[0].chain]
132
129
  );
133
130
  const disconnectSmartAccount = _react.useCallback.call(void 0, async () => {
134
131
  setSmartAccountClient(null);
@@ -230,7 +227,6 @@ var Subscribable = class {
230
227
  // ../../node_modules/@tanstack/query-core/build/modern/utils.js
231
228
  var isServer = typeof window === "undefined" || "Deno" in globalThis;
232
229
  function noop() {
233
- return void 0;
234
230
  }
235
231
  function isValidTimeout(value) {
236
232
  return typeof value === "number" && value >= 0 && value !== Infinity;
@@ -322,6 +318,15 @@ function replaceData(prevData, data, options) {
322
318
  if (typeof options.structuralSharing === "function") {
323
319
  return options.structuralSharing(prevData, data);
324
320
  } else if (options.structuralSharing !== false) {
321
+ if (process.env.NODE_ENV !== "production") {
322
+ try {
323
+ return replaceEqualDeep(prevData, data);
324
+ } catch (error) {
325
+ console.error(
326
+ `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`
327
+ );
328
+ }
329
+ }
325
330
  return replaceEqualDeep(prevData, data);
326
331
  }
327
332
  return data;
@@ -448,6 +453,39 @@ var OnlineManager = (_a2 = class extends Subscribable {
448
453
  }, _online = new WeakMap(), _cleanup2 = new WeakMap(), _setup2 = new WeakMap(), _a2);
449
454
  var onlineManager = new OnlineManager();
450
455
 
456
+ // ../../node_modules/@tanstack/query-core/build/modern/thenable.js
457
+ function pendingThenable() {
458
+ let resolve;
459
+ let reject;
460
+ const thenable = new Promise((_resolve, _reject) => {
461
+ resolve = _resolve;
462
+ reject = _reject;
463
+ });
464
+ thenable.status = "pending";
465
+ thenable.catch(() => {
466
+ });
467
+ function finalize(data) {
468
+ Object.assign(thenable, data);
469
+ delete thenable.resolve;
470
+ delete thenable.reject;
471
+ }
472
+ thenable.resolve = (value) => {
473
+ finalize({
474
+ status: "fulfilled",
475
+ value
476
+ });
477
+ resolve(value);
478
+ };
479
+ thenable.reject = (reason) => {
480
+ finalize({
481
+ status: "rejected",
482
+ reason
483
+ });
484
+ reject(reason);
485
+ };
486
+ return thenable;
487
+ }
488
+
451
489
  // ../../node_modules/@tanstack/query-core/build/modern/retryer.js
452
490
  function canFetch(networkMode) {
453
491
  return (_nullishCoalesce(networkMode, () => ( "online"))) === "online" ? onlineManager.isOnline() : true;
@@ -464,22 +502,6 @@ function createNotifyManager() {
464
502
  callback();
465
503
  };
466
504
  let scheduleFn = (cb) => setTimeout(cb, 0);
467
- const setScheduler = (fn) => {
468
- scheduleFn = fn;
469
- };
470
- const batch = (callback) => {
471
- let result;
472
- transactions++;
473
- try {
474
- result = callback();
475
- } finally {
476
- transactions--;
477
- if (!transactions) {
478
- flush();
479
- }
480
- }
481
- return result;
482
- };
483
505
  const schedule = (callback) => {
484
506
  if (transactions) {
485
507
  queue.push(callback);
@@ -489,13 +511,6 @@ function createNotifyManager() {
489
511
  });
490
512
  }
491
513
  };
492
- const batchCalls = (callback) => {
493
- return (...args) => {
494
- schedule(() => {
495
- callback(...args);
496
- });
497
- };
498
- };
499
514
  const flush = () => {
500
515
  const originalQueue = queue;
501
516
  queue = [];
@@ -509,19 +524,48 @@ function createNotifyManager() {
509
524
  });
510
525
  }
511
526
  };
512
- const setNotifyFunction = (fn) => {
513
- notifyFn = fn;
514
- };
515
- const setBatchNotifyFunction = (fn) => {
516
- batchNotifyFn = fn;
517
- };
518
527
  return {
519
- batch,
520
- batchCalls,
528
+ batch: (callback) => {
529
+ let result;
530
+ transactions++;
531
+ try {
532
+ result = callback();
533
+ } finally {
534
+ transactions--;
535
+ if (!transactions) {
536
+ flush();
537
+ }
538
+ }
539
+ return result;
540
+ },
541
+ /**
542
+ * All calls to the wrapped function will be batched.
543
+ */
544
+ batchCalls: (callback) => {
545
+ return (...args) => {
546
+ schedule(() => {
547
+ callback(...args);
548
+ });
549
+ };
550
+ },
521
551
  schedule,
522
- setNotifyFunction,
523
- setBatchNotifyFunction,
524
- setScheduler
552
+ /**
553
+ * Use this method to set a custom notify function.
554
+ * This can be used to for example wrap notifications with `React.act` while running tests.
555
+ */
556
+ setNotifyFunction: (fn) => {
557
+ notifyFn = fn;
558
+ },
559
+ /**
560
+ * Use this method to set a custom function to batch notifications together into a single tick.
561
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
562
+ */
563
+ setBatchNotifyFunction: (fn) => {
564
+ batchNotifyFn = fn;
565
+ },
566
+ setScheduler: (fn) => {
567
+ scheduleFn = fn;
568
+ }
525
569
  };
526
570
  }
527
571
  var notifyManager = createNotifyManager();
@@ -555,7 +599,7 @@ function getDefaultState() {
555
599
  }
556
600
 
557
601
  // ../../node_modules/@tanstack/query-core/build/modern/queryObserver.js
558
- var _client, _currentQuery, _currentQueryInitialState, _currentResult, _currentResultState, _currentResultOptions, _selectError, _selectFn, _selectResult, _lastQueryWithDefinedData, _staleTimeoutId, _refetchIntervalId, _currentRefetchInterval, _trackedProps, _QueryObserver_instances, executeFetch_fn, updateStaleTimeout_fn, computeRefetchInterval_fn, updateRefetchInterval_fn, updateTimers_fn, clearStaleTimeout_fn, clearRefetchInterval_fn, updateQuery_fn, notify_fn, _a3;
602
+ var _client, _currentQuery, _currentQueryInitialState, _currentResult, _currentResultState, _currentResultOptions, _currentThenable, _selectError, _selectFn, _selectResult, _lastQueryWithDefinedData, _staleTimeoutId, _refetchIntervalId, _currentRefetchInterval, _trackedProps, _QueryObserver_instances, executeFetch_fn, updateStaleTimeout_fn, computeRefetchInterval_fn, updateRefetchInterval_fn, updateTimers_fn, clearStaleTimeout_fn, clearRefetchInterval_fn, updateQuery_fn, notify_fn, _a3;
559
603
  var QueryObserver = (_a3 = class extends Subscribable {
560
604
  constructor(client, options) {
561
605
  super();
@@ -566,6 +610,7 @@ var QueryObserver = (_a3 = class extends Subscribable {
566
610
  __privateAdd(this, _currentResult);
567
611
  __privateAdd(this, _currentResultState);
568
612
  __privateAdd(this, _currentResultOptions);
613
+ __privateAdd(this, _currentThenable);
569
614
  __privateAdd(this, _selectError);
570
615
  __privateAdd(this, _selectFn);
571
616
  __privateAdd(this, _selectResult);
@@ -579,6 +624,12 @@ var QueryObserver = (_a3 = class extends Subscribable {
579
624
  this.options = options;
580
625
  __privateSet(this, _client, client);
581
626
  __privateSet(this, _selectError, null);
627
+ __privateSet(this, _currentThenable, pendingThenable());
628
+ if (!this.options.experimental_prefetchInRender) {
629
+ __privateGet(this, _currentThenable).reject(
630
+ new Error("experimental_prefetchInRender feature flag is not enabled")
631
+ );
632
+ }
582
633
  this.bindMethods();
583
634
  this.setOptions(options);
584
635
  }
@@ -699,7 +750,6 @@ var QueryObserver = (_a3 = class extends Subscribable {
699
750
  fetchOptimistic(options) {
700
751
  const defaultedOptions = __privateGet(this, _client).defaultQueryOptions(options);
701
752
  const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), defaultedOptions);
702
- query.isFetchingOptimistic = true;
703
753
  return query.fetch().then(() => this.createResult(query, defaultedOptions));
704
754
  }
705
755
  fetch(fetchOptions) {
@@ -818,9 +868,42 @@ var QueryObserver = (_a3 = class extends Subscribable {
818
868
  isPlaceholderData,
819
869
  isRefetchError: isError && hasData,
820
870
  isStale: isStale(query, options),
821
- refetch: this.refetch
871
+ refetch: this.refetch,
872
+ promise: __privateGet(this, _currentThenable)
822
873
  };
823
- return result;
874
+ const nextResult = result;
875
+ if (this.options.experimental_prefetchInRender) {
876
+ const finalizeThenableIfPossible = (thenable) => {
877
+ if (nextResult.status === "error") {
878
+ thenable.reject(nextResult.error);
879
+ } else if (nextResult.data !== void 0) {
880
+ thenable.resolve(nextResult.data);
881
+ }
882
+ };
883
+ const recreateThenable = () => {
884
+ const pending = __privateSet(this, _currentThenable, nextResult.promise = pendingThenable());
885
+ finalizeThenableIfPossible(pending);
886
+ };
887
+ const prevThenable = __privateGet(this, _currentThenable);
888
+ switch (prevThenable.status) {
889
+ case "pending":
890
+ if (query.queryHash === prevQuery.queryHash) {
891
+ finalizeThenableIfPossible(prevThenable);
892
+ }
893
+ break;
894
+ case "fulfilled":
895
+ if (nextResult.status === "error" || nextResult.data !== prevThenable.value) {
896
+ recreateThenable();
897
+ }
898
+ break;
899
+ case "rejected":
900
+ if (nextResult.status !== "error" || nextResult.error !== prevThenable.reason) {
901
+ recreateThenable();
902
+ }
903
+ break;
904
+ }
905
+ }
906
+ return nextResult;
824
907
  }
825
908
  updateResult(notifyOptions) {
826
909
  const prevResult = __privateGet(this, _currentResult);
@@ -867,7 +950,7 @@ var QueryObserver = (_a3 = class extends Subscribable {
867
950
  __privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
868
951
  }
869
952
  }
870
- }, _client = new WeakMap(), _currentQuery = new WeakMap(), _currentQueryInitialState = new WeakMap(), _currentResult = new WeakMap(), _currentResultState = new WeakMap(), _currentResultOptions = new WeakMap(), _selectError = new WeakMap(), _selectFn = new WeakMap(), _selectResult = new WeakMap(), _lastQueryWithDefinedData = new WeakMap(), _staleTimeoutId = new WeakMap(), _refetchIntervalId = new WeakMap(), _currentRefetchInterval = new WeakMap(), _trackedProps = new WeakMap(), _QueryObserver_instances = new WeakSet(), executeFetch_fn = function(fetchOptions) {
953
+ }, _client = new WeakMap(), _currentQuery = new WeakMap(), _currentQueryInitialState = new WeakMap(), _currentResult = new WeakMap(), _currentResultState = new WeakMap(), _currentResultOptions = new WeakMap(), _currentThenable = new WeakMap(), _selectError = new WeakMap(), _selectFn = new WeakMap(), _selectResult = new WeakMap(), _lastQueryWithDefinedData = new WeakMap(), _staleTimeoutId = new WeakMap(), _refetchIntervalId = new WeakMap(), _currentRefetchInterval = new WeakMap(), _trackedProps = new WeakMap(), _QueryObserver_instances = new WeakSet(), executeFetch_fn = function(fetchOptions) {
871
954
  __privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
872
955
  let promise = __privateGet(this, _currentQuery).fetch(
873
956
  this.options,
@@ -1123,7 +1206,7 @@ function noop2() {
1123
1206
 
1124
1207
  // ../../node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js
1125
1208
  var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
1126
- if (options.suspense || options.throwOnError) {
1209
+ if (options.suspense || options.throwOnError || options.experimental_prefetchInRender) {
1127
1210
  if (!errorResetBoundary.isReset()) {
1128
1211
  options.retryOnMount = false;
1129
1212
  }
@@ -1144,13 +1227,16 @@ var getHasError = ({
1144
1227
  };
1145
1228
 
1146
1229
  // ../../node_modules/@tanstack/react-query/build/modern/suspense.js
1147
- var ensureStaleTime = (defaultedOptions) => {
1230
+ var ensureSuspenseTimers = (defaultedOptions) => {
1231
+ const originalStaleTime = defaultedOptions.staleTime;
1148
1232
  if (defaultedOptions.suspense) {
1149
- if (typeof defaultedOptions.staleTime !== "number") {
1150
- defaultedOptions.staleTime = 1e3;
1233
+ defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => Math.max(originalStaleTime(...args), 1e3) : Math.max(_nullishCoalesce(originalStaleTime, () => ( 1e3)), 1e3);
1234
+ if (typeof defaultedOptions.gcTime === "number") {
1235
+ defaultedOptions.gcTime = Math.max(defaultedOptions.gcTime, 1e3);
1151
1236
  }
1152
1237
  }
1153
1238
  };
1239
+ var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
1154
1240
  var shouldSuspend = (defaultedOptions, result) => _optionalChain([defaultedOptions, 'optionalAccess', _67 => _67.suspense]) && result.isPending;
1155
1241
  var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
1156
1242
  errorResetBoundary.clearReset();
@@ -1174,9 +1260,10 @@ function useBaseQuery(options, Observer, queryClient) {
1174
1260
  defaultedOptions
1175
1261
  )]);
1176
1262
  defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
1177
- ensureStaleTime(defaultedOptions);
1263
+ ensureSuspenseTimers(defaultedOptions);
1178
1264
  ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
1179
1265
  useClearResetErrorBoundary(errorResetBoundary);
1266
+ const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
1180
1267
  const [observer] = React6.useState(
1181
1268
  () => new Observer(
1182
1269
  client,
@@ -1187,7 +1274,7 @@ function useBaseQuery(options, Observer, queryClient) {
1187
1274
  React6.useSyncExternalStore(
1188
1275
  React6.useCallback(
1189
1276
  (onStoreChange) => {
1190
- const unsubscribe = isRestoring ? () => void 0 : observer.subscribe(notifyManager.batchCalls(onStoreChange));
1277
+ const unsubscribe = isRestoring ? noop2 : observer.subscribe(notifyManager.batchCalls(onStoreChange));
1191
1278
  observer.updateResult();
1192
1279
  return unsubscribe;
1193
1280
  },
@@ -1215,6 +1302,18 @@ function useBaseQuery(options, Observer, queryClient) {
1215
1302
  defaultedOptions,
1216
1303
  result
1217
1304
  )]);
1305
+ if (defaultedOptions.experimental_prefetchInRender && !isServer && willFetch(result, isRestoring)) {
1306
+ const promise = isNewCacheEntry ? (
1307
+ // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
1308
+ fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
1309
+ ) : (
1310
+ // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
1311
+ _optionalChain([client, 'access', _78 => _78.getQueryCache, 'call', _79 => _79(), 'access', _80 => _80.get, 'call', _81 => _81(defaultedOptions.queryHash), 'optionalAccess', _82 => _82.promise])
1312
+ );
1313
+ _optionalChain([promise, 'optionalAccess', _83 => _83.catch, 'call', _84 => _84(noop2), 'access', _85 => _85.finally, 'call', _86 => _86(() => {
1314
+ observer.updateResult();
1315
+ })]);
1316
+ }
1218
1317
  return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
1219
1318
  }
1220
1319
 
@@ -1266,12 +1365,12 @@ var useSendTransaction = (mutationProps) => {
1266
1365
  if (!smartAccountClient) {
1267
1366
  throw new Error("No smart account found");
1268
1367
  }
1269
- const { transactions } = variables;
1270
- if (!Array.isArray(transactions)) {
1271
- return smartAccountClient.sendTransaction(transactions);
1368
+ const { calls } = variables;
1369
+ if (!Array.isArray(calls)) {
1370
+ return smartAccountClient.sendTransaction(calls);
1272
1371
  }
1273
- return smartAccountClient.sendTransactions({
1274
- transactions
1372
+ return smartAccountClient.sendTransaction({
1373
+ calls
1275
1374
  });
1276
1375
  },
1277
1376
  // Spread any additional mutation options provided
@@ -1328,78 +1427,6 @@ var useWriteContract = (mutationProps) => {
1328
1427
  };
1329
1428
  };
1330
1429
 
1331
- // src/hooks/sessionKeys/useSendTransactionWithSessionKey.ts
1332
- var useSendTransactionWithSessionKey = (mutationProps) => {
1333
- const { smartAccountClient, queryClient } = useSmartAccount();
1334
- const { mutate, mutateAsync, ...result } = useMutation(
1335
- {
1336
- mutationFn: (variables) => {
1337
- if (!smartAccountClient) {
1338
- throw new Error("No smart account found");
1339
- }
1340
- const { transactions } = variables;
1341
- if (!Array.isArray(transactions)) {
1342
- return smartAccountClient.sendTransactionWithSessionKey(
1343
- transactions
1344
- );
1345
- }
1346
- return smartAccountClient.sendTransactionsWithSessionKey({
1347
- transactions
1348
- });
1349
- },
1350
- ...mutationProps
1351
- },
1352
- queryClient
1353
- );
1354
- return {
1355
- data: result.data,
1356
- error: result.error,
1357
- isPending: result.isPending,
1358
- isSuccess: result.isSuccess,
1359
- isError: result.isError,
1360
- sendTransaction: mutate,
1361
- sendTransactionAsync: mutateAsync
1362
- };
1363
- };
1364
-
1365
- // src/hooks/sessionKeys/useWriteContractWithSessionKey.ts
1366
-
1367
- var useWriteContractWithSessionKey = (mutationProps) => {
1368
- const { smartAccountClient, queryClient } = useSmartAccount();
1369
- const { mutate, mutateAsync, ...result } = useMutation(
1370
- {
1371
- mutationFn: async (variables) => {
1372
- if (!smartAccountClient) {
1373
- throw new Error("No smart account found");
1374
- }
1375
- const { abi, address, functionName, args, value } = variables;
1376
- const data = _viem.encodeFunctionData.call(void 0, {
1377
- abi,
1378
- functionName,
1379
- args
1380
- });
1381
- const hash = await smartAccountClient.sendTransactionWithSessionKey({
1382
- to: address,
1383
- data,
1384
- value
1385
- });
1386
- return hash;
1387
- },
1388
- ...mutationProps
1389
- },
1390
- queryClient
1391
- );
1392
- return {
1393
- data: result.data,
1394
- error: result.error,
1395
- isPending: result.isPending,
1396
- isSuccess: result.isSuccess,
1397
- isError: result.isError,
1398
- writeContractWithSessionKey: mutate,
1399
- writeContractWithSessionKeyAsync: mutateAsync
1400
- };
1401
- };
1402
-
1403
1430
  // src/hooks/useConnect.ts
1404
1431
 
1405
1432
  var useConnect = () => {
@@ -1415,7 +1442,7 @@ var useConnect = () => {
1415
1442
  setIsPending(true);
1416
1443
  setError(null);
1417
1444
  updateSmartAccountClient(params).then(() => {
1418
- _optionalChain([queryClient, 'optionalAccess', _78 => _78.invalidateQueries, 'call', _79 => _79({
1445
+ _optionalChain([queryClient, 'optionalAccess', _87 => _87.invalidateQueries, 'call', _88 => _88({
1419
1446
  queryKey: ["connect"]
1420
1447
  })]);
1421
1448
  }).catch((e) => {
@@ -1433,7 +1460,7 @@ var useConnect = () => {
1433
1460
  setError(null);
1434
1461
  try {
1435
1462
  await updateSmartAccountClient(params);
1436
- _optionalChain([queryClient, 'optionalAccess', _80 => _80.invalidateQueries, 'call', _81 => _81({ queryKey: ["connect"] })]);
1463
+ _optionalChain([queryClient, 'optionalAccess', _89 => _89.invalidateQueries, 'call', _90 => _90({ queryKey: ["connect"] })]);
1437
1464
  } catch (e) {
1438
1465
  const err = e instanceof Error ? e : new Error("An error occurred");
1439
1466
  setError(err);
@@ -1466,7 +1493,7 @@ var useDisconnect = () => {
1466
1493
  setIsPending(true);
1467
1494
  setError(null);
1468
1495
  disconnectSmartAccount().then(() => {
1469
- _optionalChain([queryClient, 'optionalAccess', _82 => _82.invalidateQueries, 'call', _83 => _83({
1496
+ _optionalChain([queryClient, 'optionalAccess', _91 => _91.invalidateQueries, 'call', _92 => _92({
1470
1497
  queryKey: ["connect"]
1471
1498
  })]);
1472
1499
  }).catch((e) => {
@@ -1481,7 +1508,7 @@ var useDisconnect = () => {
1481
1508
  setError(null);
1482
1509
  try {
1483
1510
  await disconnectSmartAccount();
1484
- _optionalChain([queryClient, 'optionalAccess', _84 => _84.invalidateQueries, 'call', _85 => _85({ queryKey: ["connect"] })]);
1511
+ _optionalChain([queryClient, 'optionalAccess', _93 => _93.invalidateQueries, 'call', _94 => _94({ queryKey: ["connect"] })]);
1485
1512
  } catch (e) {
1486
1513
  const err = e instanceof Error ? e : new Error("An error occurred during disconnection");
1487
1514
  setError(err);
@@ -1584,161 +1611,6 @@ var useGetEnrichedOwners = (queryProps) => {
1584
1611
  );
1585
1612
  };
1586
1613
 
1587
- // src/hooks/sessionKeys/useSessionKeys.ts
1588
- var useAddSessionKey = (mutationProps) => {
1589
- const { smartAccountClient, queryClient } = useSmartAccount();
1590
- const { mutate, mutateAsync, ...result } = useMutation(
1591
- {
1592
- mutationFn: async (params) => {
1593
- if (!smartAccountClient) {
1594
- throw new Error("No smart account found");
1595
- }
1596
- return await smartAccountClient.addSessionKey(params);
1597
- },
1598
- ...mutationProps
1599
- },
1600
- queryClient
1601
- );
1602
- return {
1603
- data: result.data,
1604
- error: result.error,
1605
- isPending: result.isPending,
1606
- isSuccess: result.isSuccess,
1607
- isError: result.isError,
1608
- addSessionKey: mutate,
1609
- addSessionKeyAsync: mutateAsync
1610
- };
1611
- };
1612
- var useRevokeSessionKey = (mutationProps) => {
1613
- const { smartAccountClient, queryClient } = useSmartAccount();
1614
- const { mutate, mutateAsync, ...result } = useMutation(
1615
- {
1616
- mutationFn: async ({
1617
- sessionKey
1618
- }) => {
1619
- if (!smartAccountClient) {
1620
- throw new Error("No smart account found");
1621
- }
1622
- return await smartAccountClient.revokeSessionKey({
1623
- sessionKey
1624
- });
1625
- },
1626
- ...mutationProps
1627
- },
1628
- queryClient
1629
- );
1630
- return {
1631
- data: result.data,
1632
- error: result.error,
1633
- isPending: result.isPending,
1634
- isSuccess: result.isSuccess,
1635
- isError: result.isError,
1636
- revokeSessionKey: mutate,
1637
- revokeSessionKeyAsync: mutateAsync
1638
- };
1639
- };
1640
- var useAddWhitelistDestination = (mutationProps) => {
1641
- const { smartAccountClient, queryClient } = useSmartAccount();
1642
- const { mutate, mutateAsync, ...result } = useMutation(
1643
- {
1644
- mutationFn: async ({
1645
- sessionKey,
1646
- destination
1647
- }) => {
1648
- if (!smartAccountClient) {
1649
- throw new Error("No smart account found");
1650
- }
1651
- return await smartAccountClient.addWhitelistDestination({
1652
- sessionKey,
1653
- destination
1654
- });
1655
- },
1656
- ...mutationProps
1657
- },
1658
- queryClient
1659
- );
1660
- return {
1661
- data: result.data,
1662
- error: result.error,
1663
- isPending: result.isPending,
1664
- isSuccess: result.isSuccess,
1665
- isError: result.isError,
1666
- addWhitelistDestination: mutate,
1667
- addWhitelistDestinationAsync: mutateAsync
1668
- };
1669
- };
1670
- var useRemoveWhitelistDestination = (mutationProps) => {
1671
- const { smartAccountClient, queryClient } = useSmartAccount();
1672
- const { mutate, mutateAsync, ...result } = useMutation(
1673
- {
1674
- mutationFn: async ({
1675
- sessionKey,
1676
- destination
1677
- }) => {
1678
- if (!smartAccountClient) {
1679
- throw new Error("No smart account found");
1680
- }
1681
- return await smartAccountClient.removeWhitelistDestination({
1682
- sessionKey,
1683
- destination
1684
- });
1685
- },
1686
- ...mutationProps
1687
- },
1688
- queryClient
1689
- );
1690
- return {
1691
- data: result.data,
1692
- error: result.error,
1693
- isPending: result.isPending,
1694
- isSuccess: result.isSuccess,
1695
- isError: result.isError,
1696
- removeWhitelistDestination: mutate,
1697
- removeWhitelistDestinationAsync: mutateAsync
1698
- };
1699
- };
1700
- var useGetSessionFromAddress = (sessionKey, queryProps) => {
1701
- const { smartAccountClient, queryClient } = useSmartAccount();
1702
- return useQuery(
1703
- {
1704
- queryKey: ["getSessionFromAddress", sessionKey],
1705
- queryFn: async () => {
1706
- if (!smartAccountClient) {
1707
- throw new Error("No smart account found");
1708
- }
1709
- return await smartAccountClient.getSessionFromAddress({
1710
- sessionKey
1711
- });
1712
- },
1713
- ...queryProps
1714
- },
1715
- queryClient
1716
- );
1717
- };
1718
- var useIsAddressWhitelistDestination = (sessionKey, targetAddress, queryProps) => {
1719
- const { smartAccountClient, queryClient } = useSmartAccount();
1720
- return useQuery(
1721
- {
1722
- queryKey: [
1723
- "isAddressWhitelistDestination",
1724
- sessionKey,
1725
- targetAddress
1726
- ],
1727
- queryFn: async () => {
1728
- if (!smartAccountClient) {
1729
- throw new Error("No smart account found");
1730
- }
1731
- return await smartAccountClient.isAddressWhitelistDestination({
1732
- sessionKey,
1733
- targetAddress
1734
- });
1735
- },
1736
- ...queryProps
1737
- },
1738
- queryClient
1739
- );
1740
- };
1741
-
1742
1614
  // src/hooks/owners/useValidateAddDevice.ts
1743
1615
  var useValidateAddDevice = (mutationProps) => {
1744
1616
  const { smartAccountClient, queryClient } = useSmartAccount();
@@ -1918,7 +1790,7 @@ var useCreateNewSigner = (apiKey, baseUrl) => {
1918
1790
  setIsPending(true);
1919
1791
  setError(null);
1920
1792
  _connectsdk4337.createNewSigner.call(void 0, { apiKey, baseUrl, params }).then((signer) => {
1921
- _optionalChain([queryClient, 'optionalAccess', _86 => _86.invalidateQueries, 'call', _87 => _87({ queryKey: ["signer"] })]);
1793
+ _optionalChain([queryClient, 'optionalAccess', _95 => _95.invalidateQueries, 'call', _96 => _96({ queryKey: ["signer"] })]);
1922
1794
  return signer;
1923
1795
  }).catch((e) => {
1924
1796
  const err = e instanceof Error ? e : new Error("An error occurred");
@@ -1939,7 +1811,7 @@ var useCreateNewSigner = (apiKey, baseUrl) => {
1939
1811
  baseUrl,
1940
1812
  params
1941
1813
  });
1942
- _optionalChain([queryClient, 'optionalAccess', _88 => _88.invalidateQueries, 'call', _89 => _89({ queryKey: ["signer"] })]);
1814
+ _optionalChain([queryClient, 'optionalAccess', _97 => _97.invalidateQueries, 'call', _98 => _98({ queryKey: ["signer"] })]);
1943
1815
  return signer;
1944
1816
  } catch (e) {
1945
1817
  const err = e instanceof Error ? e : new Error("An error occurred");
@@ -2091,10 +1963,8 @@ function useSetUpRecovery() {
2091
1963
  }
2092
1964
  return smartAccountClient.setUpRecoveryModule({
2093
1965
  passKeyName: variables.passKeyName,
2094
- rpcUrl: variables.rpcUrl,
2095
- webAuthnOptions: variables.webAuthnOptions,
2096
- // biome-ignore lint/suspicious/noExplicitAny: TODO: remove any
2097
- middleware: variables.middleware
1966
+ publicClient: variables.publicClient,
1967
+ webAuthnOptions: variables.webAuthnOptions
2098
1968
  });
2099
1969
  }
2100
1970
  },
@@ -2116,7 +1986,7 @@ function useIsRecoveryActive(props = {}) {
2116
1986
  const { smartAccountClient, queryClient } = useSmartAccount();
2117
1987
  return useQuery(
2118
1988
  {
2119
- queryKey: ["isRecoveryActive", props.rpcUrl],
1989
+ queryKey: ["isRecoveryActive", props.publicClient],
2120
1990
  queryFn: async () => {
2121
1991
  if (!smartAccountClient) {
2122
1992
  throw new Error("No smart account found");
@@ -2134,7 +2004,7 @@ function useGetRecoveryRequest(props = {}, queryOptions) {
2134
2004
  const { smartAccountClient, queryClient } = useSmartAccount();
2135
2005
  const { data, isLoading, isError, error } = useQuery(
2136
2006
  {
2137
- queryKey: ["getRecoveryRequest", props.rpcUrl],
2007
+ queryKey: ["getRecoveryRequest", props.publicClient],
2138
2008
  queryFn: async () => {
2139
2009
  if (!smartAccountClient) {
2140
2010
  throw new Error("No smart account found");
@@ -2164,9 +2034,7 @@ function useCancelRecoveryRequest() {
2164
2034
  throw new Error("No smart account found");
2165
2035
  }
2166
2036
  return smartAccountClient.cancelRecoveryRequest({
2167
- rpcUrl: variables.rpcUrl,
2168
- // biome-ignore lint/suspicious/noExplicitAny: TODO: remove any
2169
- middleware: variables.middleware
2037
+ publicClient: variables.publicClient
2170
2038
  });
2171
2039
  }
2172
2040
  },
@@ -2203,17 +2071,17 @@ var useSwitchChain = () => {
2203
2071
  const { chainId } = params;
2204
2072
  if (!networksConfig)
2205
2073
  throw new Error("No current configuration found");
2206
- const selectedNetwork = _optionalChain([networksConfig, 'optionalAccess', _90 => _90.find, 'call', _91 => _91(
2207
- (network) => _optionalChain([network, 'access', _92 => _92.chain, 'optionalAccess', _93 => _93.id]) === chainId
2074
+ const selectedNetwork = _optionalChain([networksConfig, 'optionalAccess', _99 => _99.find, 'call', _100 => _100(
2075
+ (network) => _optionalChain([network, 'access', _101 => _101.chain, 'optionalAccess', _102 => _102.id]) === chainId
2208
2076
  )]);
2209
2077
  if (!selectedNetwork)
2210
2078
  throw new Error("No current configuration found");
2211
2079
  try {
2212
2080
  await updateSmartAccountClient({
2213
- address: _optionalChain([smartAccountClient, 'optionalAccess', _94 => _94.account, 'access', _95 => _95.address]),
2081
+ address: _optionalChain([smartAccountClient, 'optionalAccess', _103 => _103.account, 'access', _104 => _104.address]),
2214
2082
  chain: selectedNetwork.chain
2215
2083
  });
2216
- _optionalChain([queryClient, 'optionalAccess', _96 => _96.invalidateQueries, 'call', _97 => _97({
2084
+ _optionalChain([queryClient, 'optionalAccess', _105 => _105.invalidateQueries, 'call', _106 => _106({
2217
2085
  queryKey: ["switchChain"]
2218
2086
  })]);
2219
2087
  } catch (e) {
@@ -2267,6 +2135,10 @@ var useSwitchChain = () => {
2267
2135
  };
2268
2136
 
2269
2137
  // src/hooks/useGetTransactionCost.ts
2138
+
2139
+
2140
+
2141
+ var _accountabstraction = require('viem/account-abstraction');
2270
2142
  var useGetTransactionCost = (mutationProps) => {
2271
2143
  const { smartAccountClient, queryClient } = useSmartAccount();
2272
2144
  const { mutate, mutateAsync, ...result } = useMutation(
@@ -2275,22 +2147,21 @@ var useGetTransactionCost = (mutationProps) => {
2275
2147
  if (!smartAccountClient) {
2276
2148
  throw new Error("No smart account found");
2277
2149
  }
2278
- const { transactions } = variables;
2279
- const userOperation = await smartAccountClient.account.buildUserOperation(
2280
- transactions
2281
- );
2282
- const estimateGas = await smartAccountClient.estimateGas({
2283
- userOperation
2150
+ const bundlerClient = _accountabstraction.createBundlerClient.call(void 0, {
2151
+ account: smartAccountClient.account,
2152
+ client: smartAccountClient,
2153
+ transport: _viem.http.call(void 0, smartAccountClient.transport.url)
2284
2154
  });
2155
+ const estimateGas = await bundlerClient.estimateUserOperationGas(variables);
2285
2156
  const totalGas = estimateGas.preVerificationGas + estimateGas.verificationGasLimit + estimateGas.callGasLimit;
2286
- return { totalGasCost: totalGas * estimateGas.maxFeePerGas };
2157
+ return { totalGasCost: totalGas };
2287
2158
  },
2288
2159
  ...mutationProps
2289
2160
  },
2290
2161
  queryClient
2291
2162
  );
2292
2163
  return {
2293
- data: _optionalChain([result, 'access', _98 => _98.data, 'optionalAccess', _99 => _99.totalGasCost]),
2164
+ data: _optionalChain([result, 'access', _107 => _107.data, 'optionalAccess', _108 => _108.totalGasCost]),
2294
2165
  error: result.error,
2295
2166
  isPending: result.isPending,
2296
2167
  isSuccess: result.isSuccess,
@@ -2301,6 +2172,12 @@ var useGetTransactionCost = (mutationProps) => {
2301
2172
  };
2302
2173
 
2303
2174
  // src/hooks/useEstimateGas.ts
2175
+
2176
+
2177
+
2178
+
2179
+ var _actions = require('viem/actions');
2180
+ var _utils = require('viem/utils');
2304
2181
  var useEstimateGas = (mutationProps) => {
2305
2182
  const { smartAccountClient, queryClient } = useSmartAccount();
2306
2183
  const { mutate, mutateAsync, ...result } = useMutation(
@@ -2309,14 +2186,37 @@ var useEstimateGas = (mutationProps) => {
2309
2186
  if (!smartAccountClient) {
2310
2187
  throw new Error("No smart account found");
2311
2188
  }
2312
- const { transactions } = variables;
2313
- const userOperation = await smartAccountClient.account.buildUserOperation(
2314
- transactions
2315
- );
2316
- const estimateGas = await smartAccountClient.estimateGas({
2317
- userOperation
2189
+ const publicClient = _viem.createPublicClient.call(void 0, {
2190
+ chain: smartAccountClient.chain,
2191
+ transport: _viem.http.call(void 0, ),
2192
+ cacheTime: 6e4,
2193
+ batch: {
2194
+ multicall: { wait: 50 }
2195
+ }
2196
+ });
2197
+ const maxGasPriceResult = await _utils.getAction.call(void 0,
2198
+ publicClient,
2199
+ _actions.estimateFeesPerGas,
2200
+ "estimateFeesPerGas"
2201
+ )({
2202
+ chain: smartAccountClient.chain,
2203
+ type: "eip1559"
2318
2204
  });
2319
- return estimateGas;
2205
+ const bundlerClient = _accountabstraction.createBundlerClient.call(void 0, {
2206
+ account: smartAccountClient.account,
2207
+ client: smartAccountClient,
2208
+ transport: _viem.http.call(void 0, smartAccountClient.transport.url)
2209
+ });
2210
+ const estimateGas = await bundlerClient.estimateUserOperationGas(variables);
2211
+ return {
2212
+ callGasLimit: estimateGas.callGasLimit,
2213
+ verificationGasLimit: estimateGas.verificationGasLimit,
2214
+ preVerificationGas: estimateGas.preVerificationGas,
2215
+ paymasterVerificationGasLimit: estimateGas.paymasterVerificationGasLimit,
2216
+ paymasterPostOpGasLimit: estimateGas.paymasterPostOpGasLimit,
2217
+ maxFeePerGas: maxGasPriceResult.maxFeePerGas,
2218
+ maxPriorityFeePerGas: maxGasPriceResult.maxPriorityFeePerGas
2219
+ };
2320
2220
  },
2321
2221
  ...mutationProps
2322
2222
  },
@@ -2359,12 +2259,4 @@ var useEstimateGas = (mutationProps) => {
2359
2259
 
2360
2260
 
2361
2261
 
2362
-
2363
-
2364
-
2365
-
2366
-
2367
-
2368
-
2369
-
2370
- exports.ConnectProvider = ConnectProvider; exports.useAccount = useAccount; exports.useAddOwner = useAddOwner; exports.useAddSessionKey = useAddSessionKey; exports.useAddWhitelistDestination = useAddWhitelistDestination; exports.useCancelRecoveryRequest = useCancelRecoveryRequest; exports.useConnect = useConnect; exports.useCreateNewSigner = useCreateNewSigner; exports.useDisconnect = useDisconnect; exports.useEstimateGas = useEstimateGas; exports.useGenerateQRCodeUrl = useGenerateQRCodeUrl; exports.useGetEnrichedOwners = useGetEnrichedOwners; exports.useGetGasPrice = useGetGasPrice; exports.useGetOwners = useGetOwners; exports.useGetRecoveryRequest = useGetRecoveryRequest; exports.useGetSessionFromAddress = useGetSessionFromAddress; exports.useGetTransactionCost = useGetTransactionCost; exports.useIsAddressWhitelistDestination = useIsAddressWhitelistDestination; exports.useIsRecoveryActive = useIsRecoveryActive; exports.useRemoveOwner = useRemoveOwner; exports.useRemoveWhitelistDestination = useRemoveWhitelistDestination; exports.useRetrieveAccountAddressFromPasskeyId = useRetrieveAccountAddressFromPasskeyId; exports.useRetrieveAccountAddressFromPasskeys = useRetrieveAccountAddressFromPasskeys; exports.useRevokeSessionKey = useRevokeSessionKey; exports.useSendTransaction = useSendTransaction; exports.useSendTransactionWithSessionKey = useSendTransactionWithSessionKey; exports.useSerializeUrlWithSignerPayload = useSerializeUrlWithSignerPayload; exports.useSetUpRecovery = useSetUpRecovery; exports.useSignMessage = useSignMessage; exports.useSwitchChain = useSwitchChain; exports.useValidateAddDevice = useValidateAddDevice; exports.useVerifyMessage = useVerifyMessage; exports.useWriteContract = useWriteContract; exports.useWriteContractWithSessionKey = useWriteContractWithSessionKey;
2262
+ exports.ConnectProvider = ConnectProvider; exports.useAccount = useAccount; exports.useAddOwner = useAddOwner; exports.useCancelRecoveryRequest = useCancelRecoveryRequest; exports.useConnect = useConnect; exports.useCreateNewSigner = useCreateNewSigner; exports.useDisconnect = useDisconnect; exports.useEstimateGas = useEstimateGas; exports.useGenerateQRCodeUrl = useGenerateQRCodeUrl; exports.useGetEnrichedOwners = useGetEnrichedOwners; exports.useGetGasPrice = useGetGasPrice; exports.useGetOwners = useGetOwners; exports.useGetRecoveryRequest = useGetRecoveryRequest; exports.useGetTransactionCost = useGetTransactionCost; exports.useIsRecoveryActive = useIsRecoveryActive; exports.useRemoveOwner = useRemoveOwner; exports.useRetrieveAccountAddressFromPasskeyId = useRetrieveAccountAddressFromPasskeyId; exports.useRetrieveAccountAddressFromPasskeys = useRetrieveAccountAddressFromPasskeys; exports.useSendTransaction = useSendTransaction; exports.useSerializeUrlWithSignerPayload = useSerializeUrlWithSignerPayload; exports.useSetUpRecovery = useSetUpRecovery; exports.useSignMessage = useSignMessage; exports.useSwitchChain = useSwitchChain; exports.useValidateAddDevice = useValidateAddDevice; exports.useVerifyMessage = useVerifyMessage; exports.useWriteContract = useWriteContract;