@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 +232 -343
- package/dist/index.d.cts +1194 -4838
- package/dist/index.d.ts +1194 -4838
- package/dist/index.js +221 -332
- package/package.json +4 -4
package/dist/index.js
CHANGED
@@ -9,7 +9,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
9
9
|
|
10
10
|
// src/actions/createSmartAccount.ts
|
11
11
|
import {
|
12
|
-
ENTRYPOINT_ADDRESS_V07,
|
13
12
|
createComethPaymasterClient,
|
14
13
|
createSafeSmartAccount,
|
15
14
|
createSmartAccountClient
|
@@ -21,7 +20,7 @@ async function createSmartAccount(config) {
|
|
21
20
|
paymasterUrl,
|
22
21
|
apiKey,
|
23
22
|
chain,
|
24
|
-
|
23
|
+
publicClient,
|
25
24
|
baseUrl,
|
26
25
|
comethSignerConfig,
|
27
26
|
safeContractConfig,
|
@@ -30,10 +29,9 @@ async function createSmartAccount(config) {
|
|
30
29
|
const account = await createSafeSmartAccount({
|
31
30
|
apiKey,
|
32
31
|
chain,
|
33
|
-
|
32
|
+
publicClient,
|
34
33
|
baseUrl,
|
35
34
|
smartAccountAddress,
|
36
|
-
entryPoint: ENTRYPOINT_ADDRESS_V07,
|
37
35
|
comethSignerConfig,
|
38
36
|
safeContractConfig
|
39
37
|
});
|
@@ -42,27 +40,26 @@ async function createSmartAccount(config) {
|
|
42
40
|
const paymasterClient = await createComethPaymasterClient({
|
43
41
|
transport: http(paymasterUrl),
|
44
42
|
chain,
|
45
|
-
|
46
|
-
rpcUrl
|
43
|
+
publicClient
|
47
44
|
});
|
48
45
|
client = createSmartAccountClient({
|
49
46
|
account,
|
50
|
-
entryPoint: ENTRYPOINT_ADDRESS_V07,
|
51
47
|
chain,
|
52
48
|
bundlerTransport: http(bundlerUrl),
|
53
|
-
|
54
|
-
|
55
|
-
|
49
|
+
paymaster: paymasterClient,
|
50
|
+
userOperation: {
|
51
|
+
estimateFeesPerGas: async () => {
|
52
|
+
return await paymasterClient.getUserOperationGasPrice();
|
53
|
+
}
|
56
54
|
},
|
57
|
-
|
55
|
+
publicClient
|
58
56
|
});
|
59
57
|
} else {
|
60
58
|
client = createSmartAccountClient({
|
61
59
|
account,
|
62
|
-
entryPoint: ENTRYPOINT_ADDRESS_V07,
|
63
60
|
chain,
|
64
61
|
bundlerTransport: http(bundlerUrl),
|
65
|
-
|
62
|
+
publicClient
|
66
63
|
});
|
67
64
|
}
|
68
65
|
const address = client.account.address;
|
@@ -103,9 +100,9 @@ var ConnectProvider = ({
|
|
103
100
|
const paymasterUrl = config.networksConfig.find(
|
104
101
|
(network) => network.chain?.id === chain.id
|
105
102
|
)?.paymasterUrl;
|
106
|
-
const
|
103
|
+
const publicClient = config.networksConfig.find(
|
107
104
|
(network) => network.chain?.id === chain.id
|
108
|
-
)?.
|
105
|
+
)?.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
|
-
|
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 = useCallback(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 (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
|
-
|
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
|
-
|
524
|
-
|
525
|
-
|
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
|
-
|
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
|
1231
|
+
var ensureSuspenseTimers = (defaultedOptions) => {
|
1232
|
+
const originalStaleTime = defaultedOptions.staleTime;
|
1149
1233
|
if (defaultedOptions.suspense) {
|
1150
|
-
|
1151
|
-
|
1234
|
+
defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => Math.max(originalStaleTime(...args), 1e3) : Math.max(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) => defaultedOptions?.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
|
-
|
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 =
|
1279
|
+
const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop2;
|
1192
1280
|
observer.updateResult();
|
1193
1281
|
return unsubscribe;
|
1194
1282
|
},
|
1195
|
-
[observer,
|
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
|
+
client.getQueryCache().get(defaultedOptions.queryHash)?.promise
|
1314
|
+
);
|
1315
|
+
promise?.catch(noop2).finally(() => {
|
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 {
|
1271
|
-
if (!Array.isArray(
|
1272
|
-
return smartAccountClient.sendTransaction(
|
1370
|
+
const { calls } = variables;
|
1371
|
+
if (!Array.isArray(calls)) {
|
1372
|
+
return smartAccountClient.sendTransaction(calls);
|
1273
1373
|
}
|
1274
|
-
return smartAccountClient.
|
1275
|
-
|
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
|
-
import { encodeFunctionData as encodeFunctionData2 } from "viem";
|
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 = encodeFunctionData2({
|
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
|
import { useCallback as useCallback4, useContext as useContext6, useState as useState5 } from "react";
|
1406
1434
|
var useConnect = () => {
|
@@ -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();
|
@@ -2086,17 +1959,11 @@ function useSetUpRecovery() {
|
|
2086
1959
|
const { smartAccountClient, queryClient } = useSmartAccount();
|
2087
1960
|
const { mutate, mutateAsync, ...result } = useMutation(
|
2088
1961
|
{
|
2089
|
-
mutationFn: async (
|
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"
|
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"
|
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
|
-
|
2169
|
-
// biome-ignore lint/suspicious/noExplicitAny: TODO: remove any
|
2170
|
-
middleware: variables.middleware
|
2035
|
+
effectiveDelayAddress: variables.effectiveDelayAddress
|
2171
2036
|
});
|
2172
2037
|
}
|
2173
2038
|
},
|
@@ -2270,6 +2135,10 @@ var useSwitchChain = () => {
|
|
2270
2135
|
};
|
2271
2136
|
|
2272
2137
|
// src/hooks/useGetTransactionCost.ts
|
2138
|
+
import { http as http3 } from "viem";
|
2139
|
+
import {
|
2140
|
+
createBundlerClient
|
2141
|
+
} from "viem/account-abstraction";
|
2273
2142
|
var useGetTransactionCost = (mutationProps) => {
|
2274
2143
|
const { smartAccountClient, queryClient } = useSmartAccount();
|
2275
2144
|
const { mutate, mutateAsync, ...result } = useMutation(
|
@@ -2278,15 +2147,14 @@ var useGetTransactionCost = (mutationProps) => {
|
|
2278
2147
|
if (!smartAccountClient) {
|
2279
2148
|
throw new Error("No smart account found");
|
2280
2149
|
}
|
2281
|
-
const
|
2282
|
-
|
2283
|
-
|
2284
|
-
|
2285
|
-
const estimateGas = await smartAccountClient.estimateGas({
|
2286
|
-
userOperation
|
2150
|
+
const bundlerClient = createBundlerClient({
|
2151
|
+
account: smartAccountClient.account,
|
2152
|
+
client: smartAccountClient,
|
2153
|
+
transport: http3(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
|
2157
|
+
return { totalGasCost: totalGas };
|
2290
2158
|
},
|
2291
2159
|
...mutationProps
|
2292
2160
|
},
|
@@ -2304,6 +2172,12 @@ var useGetTransactionCost = (mutationProps) => {
|
|
2304
2172
|
};
|
2305
2173
|
|
2306
2174
|
// src/hooks/useEstimateGas.ts
|
2175
|
+
import { http as http4, createPublicClient as createPublicClient2 } from "viem";
|
2176
|
+
import {
|
2177
|
+
createBundlerClient as createBundlerClient2
|
2178
|
+
} from "viem/account-abstraction";
|
2179
|
+
import { estimateFeesPerGas } from "viem/actions";
|
2180
|
+
import { getAction } from "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
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2189
|
+
const publicClient = createPublicClient2({
|
2190
|
+
chain: smartAccountClient.chain,
|
2191
|
+
transport: http4(),
|
2192
|
+
cacheTime: 6e4,
|
2193
|
+
batch: {
|
2194
|
+
multicall: { wait: 50 }
|
2195
|
+
}
|
2196
|
+
});
|
2197
|
+
const maxGasPriceResult = await getAction(
|
2198
|
+
publicClient,
|
2199
|
+
estimateFeesPerGas,
|
2200
|
+
"estimateFeesPerGas"
|
2201
|
+
)({
|
2202
|
+
chain: smartAccountClient.chain,
|
2203
|
+
type: "eip1559"
|
2321
2204
|
});
|
2322
|
-
|
2205
|
+
const bundlerClient = createBundlerClient2({
|
2206
|
+
account: smartAccountClient.account,
|
2207
|
+
client: smartAccountClient,
|
2208
|
+
transport: http4(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
|
},
|
@@ -2339,8 +2236,6 @@ export {
|
|
2339
2236
|
ConnectProvider,
|
2340
2237
|
useAccount,
|
2341
2238
|
useAddOwner,
|
2342
|
-
useAddSessionKey,
|
2343
|
-
useAddWhitelistDestination,
|
2344
2239
|
useCancelRecoveryRequest,
|
2345
2240
|
useConnect,
|
2346
2241
|
useCreateNewSigner,
|
@@ -2351,23 +2246,17 @@ export {
|
|
2351
2246
|
useGetGasPrice,
|
2352
2247
|
useGetOwners,
|
2353
2248
|
useGetRecoveryRequest,
|
2354
|
-
useGetSessionFromAddress,
|
2355
2249
|
useGetTransactionCost,
|
2356
|
-
useIsAddressWhitelistDestination,
|
2357
2250
|
useIsRecoveryActive,
|
2358
2251
|
useRemoveOwner,
|
2359
|
-
useRemoveWhitelistDestination,
|
2360
2252
|
useRetrieveAccountAddressFromPasskeyId,
|
2361
2253
|
useRetrieveAccountAddressFromPasskeys,
|
2362
|
-
useRevokeSessionKey,
|
2363
2254
|
useSendTransaction,
|
2364
|
-
useSendTransactionWithSessionKey,
|
2365
2255
|
useSerializeUrlWithSignerPayload,
|
2366
2256
|
useSetUpRecovery,
|
2367
2257
|
useSignMessage,
|
2368
2258
|
useSwitchChain,
|
2369
2259
|
useValidateAddDevice,
|
2370
2260
|
useVerifyMessage,
|
2371
|
-
useWriteContract
|
2372
|
-
useWriteContractWithSessionKey
|
2261
|
+
useWriteContract
|
2373
2262
|
};
|