@cometh/connect-react-hooks 0.0.13-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.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;
@@ -103,9 +100,9 @@ var ConnectProvider = ({
103
100
  const paymasterUrl = _optionalChain([config, 'access', _8 => _8.networksConfig, 'access', _9 => _9.find, 'call', _10 => _10(
104
101
  (network) => _optionalChain([network, 'access', _11 => _11.chain, 'optionalAccess', _12 => _12.id]) === chain.id
105
102
  ), 'optionalAccess', _13 => _13.paymasterUrl]);
106
- const rpcUrl = _optionalChain([config, 'access', _14 => _14.networksConfig, 'access', _15 => _15.find, 'call', _16 => _16(
103
+ const publicClient = _optionalChain([config, 'access', _14 => _14.networksConfig, 'access', _15 => _15.find, 'call', _16 => _16(
107
104
  (network) => _optionalChain([network, 'access', _17 => _17.chain, 'optionalAccess', _18 => _18.id]) === chain.id
108
- ), 'optionalAccess', _19 => _19.rpcUrl]);
105
+ ), 'optionalAccess', _19 => _19.publicClient]);
109
106
  if (!bundlerUrl) throw new Error("Bundler url not found");
110
107
  try {
111
108
  const { client, address: newAddress } = await createSmartAccount({
@@ -113,7 +110,7 @@ var ConnectProvider = ({
113
110
  chain,
114
111
  bundlerUrl,
115
112
  paymasterUrl,
116
- rpcUrl,
113
+ publicClient,
117
114
  smartAccountAddress: params.address,
118
115
  comethSignerConfig: {
119
116
  ...config.comethSignerConfig,
@@ -129,7 +126,7 @@ var ConnectProvider = ({
129
126
  return smartAccountClient;
130
127
  }
131
128
  },
132
- [config]
129
+ [config, config.networksConfig[0].chain]
133
130
  );
134
131
  const disconnectSmartAccount = _react.useCallback.call(void 0, async () => {
135
132
  setSmartAccountClient(null);
@@ -231,7 +228,6 @@ var Subscribable = class {
231
228
  // ../../node_modules/@tanstack/query-core/build/modern/utils.js
232
229
  var isServer = typeof window === "undefined" || "Deno" in globalThis;
233
230
  function noop() {
234
- return void 0;
235
231
  }
236
232
  function isValidTimeout(value) {
237
233
  return typeof value === "number" && value >= 0 && value !== Infinity;
@@ -323,6 +319,15 @@ function replaceData(prevData, data, options) {
323
319
  if (typeof options.structuralSharing === "function") {
324
320
  return options.structuralSharing(prevData, data);
325
321
  } else if (options.structuralSharing !== false) {
322
+ if (process.env.NODE_ENV !== "production") {
323
+ try {
324
+ return replaceEqualDeep(prevData, data);
325
+ } catch (error) {
326
+ console.error(
327
+ `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}`
328
+ );
329
+ }
330
+ }
326
331
  return replaceEqualDeep(prevData, data);
327
332
  }
328
333
  return data;
@@ -449,6 +454,39 @@ var OnlineManager = (_a2 = class extends Subscribable {
449
454
  }, _online = new WeakMap(), _cleanup2 = new WeakMap(), _setup2 = new WeakMap(), _a2);
450
455
  var onlineManager = new OnlineManager();
451
456
 
457
+ // ../../node_modules/@tanstack/query-core/build/modern/thenable.js
458
+ function pendingThenable() {
459
+ let resolve;
460
+ let reject;
461
+ const thenable = new Promise((_resolve, _reject) => {
462
+ resolve = _resolve;
463
+ reject = _reject;
464
+ });
465
+ thenable.status = "pending";
466
+ thenable.catch(() => {
467
+ });
468
+ function finalize(data) {
469
+ Object.assign(thenable, data);
470
+ delete thenable.resolve;
471
+ delete thenable.reject;
472
+ }
473
+ thenable.resolve = (value) => {
474
+ finalize({
475
+ status: "fulfilled",
476
+ value
477
+ });
478
+ resolve(value);
479
+ };
480
+ thenable.reject = (reason) => {
481
+ finalize({
482
+ status: "rejected",
483
+ reason
484
+ });
485
+ reject(reason);
486
+ };
487
+ return thenable;
488
+ }
489
+
452
490
  // ../../node_modules/@tanstack/query-core/build/modern/retryer.js
453
491
  function canFetch(networkMode) {
454
492
  return (_nullishCoalesce(networkMode, () => ( "online"))) === "online" ? onlineManager.isOnline() : true;
@@ -465,22 +503,6 @@ function createNotifyManager() {
465
503
  callback();
466
504
  };
467
505
  let scheduleFn = (cb) => setTimeout(cb, 0);
468
- const setScheduler = (fn) => {
469
- scheduleFn = fn;
470
- };
471
- const batch = (callback) => {
472
- let result;
473
- transactions++;
474
- try {
475
- result = callback();
476
- } finally {
477
- transactions--;
478
- if (!transactions) {
479
- flush();
480
- }
481
- }
482
- return result;
483
- };
484
506
  const schedule = (callback) => {
485
507
  if (transactions) {
486
508
  queue.push(callback);
@@ -490,13 +512,6 @@ function createNotifyManager() {
490
512
  });
491
513
  }
492
514
  };
493
- const batchCalls = (callback) => {
494
- return (...args) => {
495
- schedule(() => {
496
- callback(...args);
497
- });
498
- };
499
- };
500
515
  const flush = () => {
501
516
  const originalQueue = queue;
502
517
  queue = [];
@@ -510,19 +525,48 @@ function createNotifyManager() {
510
525
  });
511
526
  }
512
527
  };
513
- const setNotifyFunction = (fn) => {
514
- notifyFn = fn;
515
- };
516
- const setBatchNotifyFunction = (fn) => {
517
- batchNotifyFn = fn;
518
- };
519
528
  return {
520
- batch,
521
- batchCalls,
529
+ batch: (callback) => {
530
+ let result;
531
+ transactions++;
532
+ try {
533
+ result = callback();
534
+ } finally {
535
+ transactions--;
536
+ if (!transactions) {
537
+ flush();
538
+ }
539
+ }
540
+ return result;
541
+ },
542
+ /**
543
+ * All calls to the wrapped function will be batched.
544
+ */
545
+ batchCalls: (callback) => {
546
+ return (...args) => {
547
+ schedule(() => {
548
+ callback(...args);
549
+ });
550
+ };
551
+ },
522
552
  schedule,
523
- setNotifyFunction,
524
- setBatchNotifyFunction,
525
- setScheduler
553
+ /**
554
+ * Use this method to set a custom notify function.
555
+ * This can be used to for example wrap notifications with `React.act` while running tests.
556
+ */
557
+ setNotifyFunction: (fn) => {
558
+ notifyFn = fn;
559
+ },
560
+ /**
561
+ * Use this method to set a custom function to batch notifications together into a single tick.
562
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
563
+ */
564
+ setBatchNotifyFunction: (fn) => {
565
+ batchNotifyFn = fn;
566
+ },
567
+ setScheduler: (fn) => {
568
+ scheduleFn = fn;
569
+ }
526
570
  };
527
571
  }
528
572
  var notifyManager = createNotifyManager();
@@ -556,7 +600,7 @@ function getDefaultState() {
556
600
  }
557
601
 
558
602
  // ../../node_modules/@tanstack/query-core/build/modern/queryObserver.js
559
- 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;
603
+ 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;
560
604
  var QueryObserver = (_a3 = class extends Subscribable {
561
605
  constructor(client, options) {
562
606
  super();
@@ -567,6 +611,7 @@ var QueryObserver = (_a3 = class extends Subscribable {
567
611
  __privateAdd(this, _currentResult);
568
612
  __privateAdd(this, _currentResultState);
569
613
  __privateAdd(this, _currentResultOptions);
614
+ __privateAdd(this, _currentThenable);
570
615
  __privateAdd(this, _selectError);
571
616
  __privateAdd(this, _selectFn);
572
617
  __privateAdd(this, _selectResult);
@@ -580,6 +625,12 @@ var QueryObserver = (_a3 = class extends Subscribable {
580
625
  this.options = options;
581
626
  __privateSet(this, _client, client);
582
627
  __privateSet(this, _selectError, null);
628
+ __privateSet(this, _currentThenable, pendingThenable());
629
+ if (!this.options.experimental_prefetchInRender) {
630
+ __privateGet(this, _currentThenable).reject(
631
+ new Error("experimental_prefetchInRender feature flag is not enabled")
632
+ );
633
+ }
583
634
  this.bindMethods();
584
635
  this.setOptions(options);
585
636
  }
@@ -700,7 +751,6 @@ var QueryObserver = (_a3 = class extends Subscribable {
700
751
  fetchOptimistic(options) {
701
752
  const defaultedOptions = __privateGet(this, _client).defaultQueryOptions(options);
702
753
  const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), defaultedOptions);
703
- query.isFetchingOptimistic = true;
704
754
  return query.fetch().then(() => this.createResult(query, defaultedOptions));
705
755
  }
706
756
  fetch(fetchOptions) {
@@ -819,9 +869,42 @@ var QueryObserver = (_a3 = class extends Subscribable {
819
869
  isPlaceholderData,
820
870
  isRefetchError: isError && hasData,
821
871
  isStale: isStale(query, options),
822
- refetch: this.refetch
872
+ refetch: this.refetch,
873
+ promise: __privateGet(this, _currentThenable)
823
874
  };
824
- return result;
875
+ const nextResult = result;
876
+ if (this.options.experimental_prefetchInRender) {
877
+ const finalizeThenableIfPossible = (thenable) => {
878
+ if (nextResult.status === "error") {
879
+ thenable.reject(nextResult.error);
880
+ } else if (nextResult.data !== void 0) {
881
+ thenable.resolve(nextResult.data);
882
+ }
883
+ };
884
+ const recreateThenable = () => {
885
+ const pending = __privateSet(this, _currentThenable, nextResult.promise = pendingThenable());
886
+ finalizeThenableIfPossible(pending);
887
+ };
888
+ const prevThenable = __privateGet(this, _currentThenable);
889
+ switch (prevThenable.status) {
890
+ case "pending":
891
+ if (query.queryHash === prevQuery.queryHash) {
892
+ finalizeThenableIfPossible(prevThenable);
893
+ }
894
+ break;
895
+ case "fulfilled":
896
+ if (nextResult.status === "error" || nextResult.data !== prevThenable.value) {
897
+ recreateThenable();
898
+ }
899
+ break;
900
+ case "rejected":
901
+ if (nextResult.status !== "error" || nextResult.error !== prevThenable.reason) {
902
+ recreateThenable();
903
+ }
904
+ break;
905
+ }
906
+ }
907
+ return nextResult;
825
908
  }
826
909
  updateResult(notifyOptions) {
827
910
  const prevResult = __privateGet(this, _currentResult);
@@ -868,7 +951,7 @@ var QueryObserver = (_a3 = class extends Subscribable {
868
951
  __privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
869
952
  }
870
953
  }
871
- }, _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) {
954
+ }, _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) {
872
955
  __privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
873
956
  let promise = __privateGet(this, _currentQuery).fetch(
874
957
  this.options,
@@ -1124,7 +1207,7 @@ function noop2() {
1124
1207
 
1125
1208
  // ../../node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js
1126
1209
  var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
1127
- if (options.suspense || options.throwOnError) {
1210
+ if (options.suspense || options.throwOnError || options.experimental_prefetchInRender) {
1128
1211
  if (!errorResetBoundary.isReset()) {
1129
1212
  options.retryOnMount = false;
1130
1213
  }
@@ -1145,13 +1228,16 @@ var getHasError = ({
1145
1228
  };
1146
1229
 
1147
1230
  // ../../node_modules/@tanstack/react-query/build/modern/suspense.js
1148
- var ensureStaleTime = (defaultedOptions) => {
1231
+ var ensureSuspenseTimers = (defaultedOptions) => {
1232
+ const originalStaleTime = defaultedOptions.staleTime;
1149
1233
  if (defaultedOptions.suspense) {
1150
- if (typeof defaultedOptions.staleTime !== "number") {
1151
- defaultedOptions.staleTime = 1e3;
1234
+ defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => Math.max(originalStaleTime(...args), 1e3) : Math.max(_nullishCoalesce(originalStaleTime, () => ( 1e3)), 1e3);
1235
+ if (typeof defaultedOptions.gcTime === "number") {
1236
+ defaultedOptions.gcTime = Math.max(defaultedOptions.gcTime, 1e3);
1152
1237
  }
1153
1238
  }
1154
1239
  };
1240
+ var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
1155
1241
  var shouldSuspend = (defaultedOptions, result) => _optionalChain([defaultedOptions, 'optionalAccess', _67 => _67.suspense]) && result.isPending;
1156
1242
  var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
1157
1243
  errorResetBoundary.clearReset();
@@ -1175,9 +1261,10 @@ function useBaseQuery(options, Observer, queryClient) {
1175
1261
  defaultedOptions
1176
1262
  )]);
1177
1263
  defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
1178
- ensureStaleTime(defaultedOptions);
1264
+ ensureSuspenseTimers(defaultedOptions);
1179
1265
  ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
1180
1266
  useClearResetErrorBoundary(errorResetBoundary);
1267
+ const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
1181
1268
  const [observer] = React6.useState(
1182
1269
  () => new Observer(
1183
1270
  client,
@@ -1185,14 +1272,15 @@ function useBaseQuery(options, Observer, queryClient) {
1185
1272
  )
1186
1273
  );
1187
1274
  const result = observer.getOptimisticResult(defaultedOptions);
1275
+ const shouldSubscribe = !isRestoring && options.subscribed !== false;
1188
1276
  React6.useSyncExternalStore(
1189
1277
  React6.useCallback(
1190
1278
  (onStoreChange) => {
1191
- const unsubscribe = isRestoring ? () => void 0 : observer.subscribe(notifyManager.batchCalls(onStoreChange));
1279
+ const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop2;
1192
1280
  observer.updateResult();
1193
1281
  return unsubscribe;
1194
1282
  },
1195
- [observer, isRestoring]
1283
+ [observer, shouldSubscribe]
1196
1284
  ),
1197
1285
  () => observer.getCurrentResult(),
1198
1286
  () => observer.getCurrentResult()
@@ -1216,6 +1304,18 @@ function useBaseQuery(options, Observer, queryClient) {
1216
1304
  defaultedOptions,
1217
1305
  result
1218
1306
  )]);
1307
+ if (defaultedOptions.experimental_prefetchInRender && !isServer && willFetch(result, isRestoring)) {
1308
+ const promise = isNewCacheEntry ? (
1309
+ // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
1310
+ fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
1311
+ ) : (
1312
+ // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
1313
+ _optionalChain([client, 'access', _78 => _78.getQueryCache, 'call', _79 => _79(), 'access', _80 => _80.get, 'call', _81 => _81(defaultedOptions.queryHash), 'optionalAccess', _82 => _82.promise])
1314
+ );
1315
+ _optionalChain([promise, 'optionalAccess', _83 => _83.catch, 'call', _84 => _84(noop2), 'access', _85 => _85.finally, 'call', _86 => _86(() => {
1316
+ observer.updateResult();
1317
+ })]);
1318
+ }
1219
1319
  return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
1220
1320
  }
1221
1321
 
@@ -1267,12 +1367,12 @@ var useSendTransaction = (mutationProps) => {
1267
1367
  if (!smartAccountClient) {
1268
1368
  throw new Error("No smart account found");
1269
1369
  }
1270
- const { transactions } = variables;
1271
- if (!Array.isArray(transactions)) {
1272
- return smartAccountClient.sendTransaction(transactions);
1370
+ const { calls } = variables;
1371
+ if (!Array.isArray(calls)) {
1372
+ return smartAccountClient.sendTransaction(calls);
1273
1373
  }
1274
- return smartAccountClient.sendTransactions({
1275
- transactions
1374
+ return smartAccountClient.sendTransaction({
1375
+ calls
1276
1376
  });
1277
1377
  },
1278
1378
  // Spread any additional mutation options provided
@@ -1329,78 +1429,6 @@ var useWriteContract = (mutationProps) => {
1329
1429
  };
1330
1430
  };
1331
1431
 
1332
- // src/hooks/sessionKeys/useSendTransactionWithSessionKey.ts
1333
- var useSendTransactionWithSessionKey = (mutationProps) => {
1334
- const { smartAccountClient, queryClient } = useSmartAccount();
1335
- const { mutate, mutateAsync, ...result } = useMutation(
1336
- {
1337
- mutationFn: (variables) => {
1338
- if (!smartAccountClient) {
1339
- throw new Error("No smart account found");
1340
- }
1341
- const { transactions } = variables;
1342
- if (!Array.isArray(transactions)) {
1343
- return smartAccountClient.sendTransactionWithSessionKey(
1344
- transactions
1345
- );
1346
- }
1347
- return smartAccountClient.sendTransactionsWithSessionKey({
1348
- transactions
1349
- });
1350
- },
1351
- ...mutationProps
1352
- },
1353
- queryClient
1354
- );
1355
- return {
1356
- data: result.data,
1357
- error: result.error,
1358
- isPending: result.isPending,
1359
- isSuccess: result.isSuccess,
1360
- isError: result.isError,
1361
- sendTransaction: mutate,
1362
- sendTransactionAsync: mutateAsync
1363
- };
1364
- };
1365
-
1366
- // src/hooks/sessionKeys/useWriteContractWithSessionKey.ts
1367
-
1368
- var useWriteContractWithSessionKey = (mutationProps) => {
1369
- const { smartAccountClient, queryClient } = useSmartAccount();
1370
- const { mutate, mutateAsync, ...result } = useMutation(
1371
- {
1372
- mutationFn: async (variables) => {
1373
- if (!smartAccountClient) {
1374
- throw new Error("No smart account found");
1375
- }
1376
- const { abi, address, functionName, args, value } = variables;
1377
- const data = _viem.encodeFunctionData.call(void 0, {
1378
- abi,
1379
- functionName,
1380
- args
1381
- });
1382
- const hash = await smartAccountClient.sendTransactionWithSessionKey({
1383
- to: address,
1384
- data,
1385
- value
1386
- });
1387
- return hash;
1388
- },
1389
- ...mutationProps
1390
- },
1391
- queryClient
1392
- );
1393
- return {
1394
- data: result.data,
1395
- error: result.error,
1396
- isPending: result.isPending,
1397
- isSuccess: result.isSuccess,
1398
- isError: result.isError,
1399
- writeContractWithSessionKey: mutate,
1400
- writeContractWithSessionKeyAsync: mutateAsync
1401
- };
1402
- };
1403
-
1404
1432
  // src/hooks/useConnect.ts
1405
1433
 
1406
1434
  var useConnect = () => {
@@ -1416,7 +1444,7 @@ var useConnect = () => {
1416
1444
  setIsPending(true);
1417
1445
  setError(null);
1418
1446
  updateSmartAccountClient(params).then(() => {
1419
- _optionalChain([queryClient, 'optionalAccess', _78 => _78.invalidateQueries, 'call', _79 => _79({
1447
+ _optionalChain([queryClient, 'optionalAccess', _87 => _87.invalidateQueries, 'call', _88 => _88({
1420
1448
  queryKey: ["connect"]
1421
1449
  })]);
1422
1450
  }).catch((e) => {
@@ -1434,7 +1462,7 @@ var useConnect = () => {
1434
1462
  setError(null);
1435
1463
  try {
1436
1464
  await updateSmartAccountClient(params);
1437
- _optionalChain([queryClient, 'optionalAccess', _80 => _80.invalidateQueries, 'call', _81 => _81({ queryKey: ["connect"] })]);
1465
+ _optionalChain([queryClient, 'optionalAccess', _89 => _89.invalidateQueries, 'call', _90 => _90({ queryKey: ["connect"] })]);
1438
1466
  } catch (e) {
1439
1467
  const err = e instanceof Error ? e : new Error("An error occurred");
1440
1468
  setError(err);
@@ -1467,7 +1495,7 @@ var useDisconnect = () => {
1467
1495
  setIsPending(true);
1468
1496
  setError(null);
1469
1497
  disconnectSmartAccount().then(() => {
1470
- _optionalChain([queryClient, 'optionalAccess', _82 => _82.invalidateQueries, 'call', _83 => _83({
1498
+ _optionalChain([queryClient, 'optionalAccess', _91 => _91.invalidateQueries, 'call', _92 => _92({
1471
1499
  queryKey: ["connect"]
1472
1500
  })]);
1473
1501
  }).catch((e) => {
@@ -1482,7 +1510,7 @@ var useDisconnect = () => {
1482
1510
  setError(null);
1483
1511
  try {
1484
1512
  await disconnectSmartAccount();
1485
- _optionalChain([queryClient, 'optionalAccess', _84 => _84.invalidateQueries, 'call', _85 => _85({ queryKey: ["connect"] })]);
1513
+ _optionalChain([queryClient, 'optionalAccess', _93 => _93.invalidateQueries, 'call', _94 => _94({ queryKey: ["connect"] })]);
1486
1514
  } catch (e) {
1487
1515
  const err = e instanceof Error ? e : new Error("An error occurred during disconnection");
1488
1516
  setError(err);
@@ -1585,161 +1613,6 @@ var useGetEnrichedOwners = (queryProps) => {
1585
1613
  );
1586
1614
  };
1587
1615
 
1588
- // src/hooks/sessionKeys/useSessionKeys.ts
1589
- var useAddSessionKey = (mutationProps) => {
1590
- const { smartAccountClient, queryClient } = useSmartAccount();
1591
- const { mutate, mutateAsync, ...result } = useMutation(
1592
- {
1593
- mutationFn: async (params) => {
1594
- if (!smartAccountClient) {
1595
- throw new Error("No smart account found");
1596
- }
1597
- return await smartAccountClient.addSessionKey(params);
1598
- },
1599
- ...mutationProps
1600
- },
1601
- queryClient
1602
- );
1603
- return {
1604
- data: result.data,
1605
- error: result.error,
1606
- isPending: result.isPending,
1607
- isSuccess: result.isSuccess,
1608
- isError: result.isError,
1609
- addSessionKey: mutate,
1610
- addSessionKeyAsync: mutateAsync
1611
- };
1612
- };
1613
- var useRevokeSessionKey = (mutationProps) => {
1614
- const { smartAccountClient, queryClient } = useSmartAccount();
1615
- const { mutate, mutateAsync, ...result } = useMutation(
1616
- {
1617
- mutationFn: async ({
1618
- sessionKey
1619
- }) => {
1620
- if (!smartAccountClient) {
1621
- throw new Error("No smart account found");
1622
- }
1623
- return await smartAccountClient.revokeSessionKey({
1624
- sessionKey
1625
- });
1626
- },
1627
- ...mutationProps
1628
- },
1629
- queryClient
1630
- );
1631
- return {
1632
- data: result.data,
1633
- error: result.error,
1634
- isPending: result.isPending,
1635
- isSuccess: result.isSuccess,
1636
- isError: result.isError,
1637
- revokeSessionKey: mutate,
1638
- revokeSessionKeyAsync: mutateAsync
1639
- };
1640
- };
1641
- var useAddWhitelistDestination = (mutationProps) => {
1642
- const { smartAccountClient, queryClient } = useSmartAccount();
1643
- const { mutate, mutateAsync, ...result } = useMutation(
1644
- {
1645
- mutationFn: async ({
1646
- sessionKey,
1647
- destination
1648
- }) => {
1649
- if (!smartAccountClient) {
1650
- throw new Error("No smart account found");
1651
- }
1652
- return await smartAccountClient.addWhitelistDestination({
1653
- sessionKey,
1654
- destination
1655
- });
1656
- },
1657
- ...mutationProps
1658
- },
1659
- queryClient
1660
- );
1661
- return {
1662
- data: result.data,
1663
- error: result.error,
1664
- isPending: result.isPending,
1665
- isSuccess: result.isSuccess,
1666
- isError: result.isError,
1667
- addWhitelistDestination: mutate,
1668
- addWhitelistDestinationAsync: mutateAsync
1669
- };
1670
- };
1671
- var useRemoveWhitelistDestination = (mutationProps) => {
1672
- const { smartAccountClient, queryClient } = useSmartAccount();
1673
- const { mutate, mutateAsync, ...result } = useMutation(
1674
- {
1675
- mutationFn: async ({
1676
- sessionKey,
1677
- destination
1678
- }) => {
1679
- if (!smartAccountClient) {
1680
- throw new Error("No smart account found");
1681
- }
1682
- return await smartAccountClient.removeWhitelistDestination({
1683
- sessionKey,
1684
- destination
1685
- });
1686
- },
1687
- ...mutationProps
1688
- },
1689
- queryClient
1690
- );
1691
- return {
1692
- data: result.data,
1693
- error: result.error,
1694
- isPending: result.isPending,
1695
- isSuccess: result.isSuccess,
1696
- isError: result.isError,
1697
- removeWhitelistDestination: mutate,
1698
- removeWhitelistDestinationAsync: mutateAsync
1699
- };
1700
- };
1701
- var useGetSessionFromAddress = (sessionKey, queryProps) => {
1702
- const { smartAccountClient, queryClient } = useSmartAccount();
1703
- return useQuery(
1704
- {
1705
- queryKey: ["getSessionFromAddress", sessionKey],
1706
- queryFn: async () => {
1707
- if (!smartAccountClient) {
1708
- throw new Error("No smart account found");
1709
- }
1710
- return await smartAccountClient.getSessionFromAddress({
1711
- sessionKey
1712
- });
1713
- },
1714
- ...queryProps
1715
- },
1716
- queryClient
1717
- );
1718
- };
1719
- var useIsAddressWhitelistDestination = (sessionKey, targetAddress, queryProps) => {
1720
- const { smartAccountClient, queryClient } = useSmartAccount();
1721
- return useQuery(
1722
- {
1723
- queryKey: [
1724
- "isAddressWhitelistDestination",
1725
- sessionKey,
1726
- targetAddress
1727
- ],
1728
- queryFn: async () => {
1729
- if (!smartAccountClient) {
1730
- throw new Error("No smart account found");
1731
- }
1732
- return await smartAccountClient.isAddressWhitelistDestination({
1733
- sessionKey,
1734
- targetAddress
1735
- });
1736
- },
1737
- ...queryProps
1738
- },
1739
- queryClient
1740
- );
1741
- };
1742
-
1743
1616
  // src/hooks/owners/useValidateAddDevice.ts
1744
1617
  var useValidateAddDevice = (mutationProps) => {
1745
1618
  const { smartAccountClient, queryClient } = useSmartAccount();
@@ -1919,7 +1792,7 @@ var useCreateNewSigner = (apiKey, baseUrl) => {
1919
1792
  setIsPending(true);
1920
1793
  setError(null);
1921
1794
  _connectsdk4337.createNewSigner.call(void 0, { apiKey, baseUrl, params }).then((signer) => {
1922
- _optionalChain([queryClient, 'optionalAccess', _86 => _86.invalidateQueries, 'call', _87 => _87({ queryKey: ["signer"] })]);
1795
+ _optionalChain([queryClient, 'optionalAccess', _95 => _95.invalidateQueries, 'call', _96 => _96({ queryKey: ["signer"] })]);
1923
1796
  return signer;
1924
1797
  }).catch((e) => {
1925
1798
  const err = e instanceof Error ? e : new Error("An error occurred");
@@ -1940,7 +1813,7 @@ var useCreateNewSigner = (apiKey, baseUrl) => {
1940
1813
  baseUrl,
1941
1814
  params
1942
1815
  });
1943
- _optionalChain([queryClient, 'optionalAccess', _88 => _88.invalidateQueries, 'call', _89 => _89({ queryKey: ["signer"] })]);
1816
+ _optionalChain([queryClient, 'optionalAccess', _97 => _97.invalidateQueries, 'call', _98 => _98({ queryKey: ["signer"] })]);
1944
1817
  return signer;
1945
1818
  } catch (e) {
1946
1819
  const err = e instanceof Error ? e : new Error("An error occurred");
@@ -2086,17 +1959,11 @@ function useSetUpRecovery() {
2086
1959
  const { smartAccountClient, queryClient } = useSmartAccount();
2087
1960
  const { mutate, mutateAsync, ...result } = useMutation(
2088
1961
  {
2089
- mutationFn: async (variables) => {
1962
+ mutationFn: async () => {
2090
1963
  if (!smartAccountClient) {
2091
1964
  throw new Error("No smart account found");
2092
1965
  }
2093
- return smartAccountClient.setUpRecoveryModule({
2094
- passKeyName: variables.passKeyName,
2095
- rpcUrl: variables.rpcUrl,
2096
- webAuthnOptions: variables.webAuthnOptions,
2097
- // biome-ignore lint/suspicious/noExplicitAny: TODO: remove any
2098
- middleware: variables.middleware
2099
- });
1966
+ return smartAccountClient.setUpRecoveryModule();
2100
1967
  }
2101
1968
  },
2102
1969
  queryClient
@@ -2117,7 +1984,7 @@ function useIsRecoveryActive(props = {}) {
2117
1984
  const { smartAccountClient, queryClient } = useSmartAccount();
2118
1985
  return useQuery(
2119
1986
  {
2120
- queryKey: ["isRecoveryActive", props.rpcUrl],
1987
+ queryKey: ["isRecoveryActive"],
2121
1988
  queryFn: async () => {
2122
1989
  if (!smartAccountClient) {
2123
1990
  throw new Error("No smart account found");
@@ -2135,7 +2002,7 @@ function useGetRecoveryRequest(props = {}, queryOptions) {
2135
2002
  const { smartAccountClient, queryClient } = useSmartAccount();
2136
2003
  const { data, isLoading, isError, error } = useQuery(
2137
2004
  {
2138
- queryKey: ["getRecoveryRequest", props.rpcUrl],
2005
+ queryKey: ["getRecoveryRequest"],
2139
2006
  queryFn: async () => {
2140
2007
  if (!smartAccountClient) {
2141
2008
  throw new Error("No smart account found");
@@ -2165,9 +2032,7 @@ function useCancelRecoveryRequest() {
2165
2032
  throw new Error("No smart account found");
2166
2033
  }
2167
2034
  return smartAccountClient.cancelRecoveryRequest({
2168
- rpcUrl: variables.rpcUrl,
2169
- // biome-ignore lint/suspicious/noExplicitAny: TODO: remove any
2170
- middleware: variables.middleware
2035
+ effectiveDelayAddress: variables.effectiveDelayAddress
2171
2036
  });
2172
2037
  }
2173
2038
  },
@@ -2204,17 +2069,17 @@ var useSwitchChain = () => {
2204
2069
  const { chainId } = params;
2205
2070
  if (!networksConfig)
2206
2071
  throw new Error("No current configuration found");
2207
- const selectedNetwork = _optionalChain([networksConfig, 'optionalAccess', _90 => _90.find, 'call', _91 => _91(
2208
- (network) => _optionalChain([network, 'access', _92 => _92.chain, 'optionalAccess', _93 => _93.id]) === chainId
2072
+ const selectedNetwork = _optionalChain([networksConfig, 'optionalAccess', _99 => _99.find, 'call', _100 => _100(
2073
+ (network) => _optionalChain([network, 'access', _101 => _101.chain, 'optionalAccess', _102 => _102.id]) === chainId
2209
2074
  )]);
2210
2075
  if (!selectedNetwork)
2211
2076
  throw new Error("No current configuration found");
2212
2077
  try {
2213
2078
  const client = await updateSmartAccountClient({
2214
- address: _optionalChain([smartAccountClient, 'optionalAccess', _94 => _94.account, 'access', _95 => _95.address]),
2079
+ address: _optionalChain([smartAccountClient, 'optionalAccess', _103 => _103.account, 'access', _104 => _104.address]),
2215
2080
  chain: selectedNetwork.chain
2216
2081
  });
2217
- _optionalChain([queryClient, 'optionalAccess', _96 => _96.invalidateQueries, 'call', _97 => _97({
2082
+ _optionalChain([queryClient, 'optionalAccess', _105 => _105.invalidateQueries, 'call', _106 => _106({
2218
2083
  queryKey: ["switchChain"]
2219
2084
  })]);
2220
2085
  return client;
@@ -2270,6 +2135,10 @@ var useSwitchChain = () => {
2270
2135
  };
2271
2136
 
2272
2137
  // src/hooks/useGetTransactionCost.ts
2138
+
2139
+
2140
+
2141
+ var _accountabstraction = require('viem/account-abstraction');
2273
2142
  var useGetTransactionCost = (mutationProps) => {
2274
2143
  const { smartAccountClient, queryClient } = useSmartAccount();
2275
2144
  const { mutate, mutateAsync, ...result } = useMutation(
@@ -2278,22 +2147,21 @@ var useGetTransactionCost = (mutationProps) => {
2278
2147
  if (!smartAccountClient) {
2279
2148
  throw new Error("No smart account found");
2280
2149
  }
2281
- const { transactions } = variables;
2282
- const userOperation = await smartAccountClient.account.buildUserOperation(
2283
- transactions
2284
- );
2285
- const estimateGas = await smartAccountClient.estimateGas({
2286
- 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)
2287
2154
  });
2155
+ const estimateGas = await bundlerClient.estimateUserOperationGas(variables);
2288
2156
  const totalGas = estimateGas.preVerificationGas + estimateGas.verificationGasLimit + estimateGas.callGasLimit;
2289
- return { totalGasCost: totalGas * estimateGas.maxFeePerGas };
2157
+ return { totalGasCost: totalGas };
2290
2158
  },
2291
2159
  ...mutationProps
2292
2160
  },
2293
2161
  queryClient
2294
2162
  );
2295
2163
  return {
2296
- data: _optionalChain([result, 'access', _98 => _98.data, 'optionalAccess', _99 => _99.totalGasCost]),
2164
+ data: _optionalChain([result, 'access', _107 => _107.data, 'optionalAccess', _108 => _108.totalGasCost]),
2297
2165
  error: result.error,
2298
2166
  isPending: result.isPending,
2299
2167
  isSuccess: result.isSuccess,
@@ -2304,6 +2172,12 @@ var useGetTransactionCost = (mutationProps) => {
2304
2172
  };
2305
2173
 
2306
2174
  // src/hooks/useEstimateGas.ts
2175
+
2176
+
2177
+
2178
+
2179
+ var _actions = require('viem/actions');
2180
+ var _utils = require('viem/utils');
2307
2181
  var useEstimateGas = (mutationProps) => {
2308
2182
  const { smartAccountClient, queryClient } = useSmartAccount();
2309
2183
  const { mutate, mutateAsync, ...result } = useMutation(
@@ -2312,14 +2186,37 @@ var useEstimateGas = (mutationProps) => {
2312
2186
  if (!smartAccountClient) {
2313
2187
  throw new Error("No smart account found");
2314
2188
  }
2315
- const { transactions } = variables;
2316
- const userOperation = await smartAccountClient.account.buildUserOperation(
2317
- transactions
2318
- );
2319
- const estimateGas = await smartAccountClient.estimateGas({
2320
- 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"
2321
2204
  });
2322
- 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
+ };
2323
2220
  },
2324
2221
  ...mutationProps
2325
2222
  },
@@ -2362,12 +2259,4 @@ var useEstimateGas = (mutationProps) => {
2362
2259
 
2363
2260
 
2364
2261
 
2365
-
2366
-
2367
-
2368
-
2369
-
2370
-
2371
-
2372
-
2373
- 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;