@naculus/connect-appkit-vue 0.6.0 → 0.8.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/README.md +10 -0
- package/dist/index.cjs +738 -505
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -5
- package/dist/index.d.ts +40 -5
- package/dist/index.js +485 -244
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -209,6 +209,55 @@ function useAccounts(accounts) {
|
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
+
// src/useAuthorizations.ts
|
|
213
|
+
import {
|
|
214
|
+
listAuthorizations,
|
|
215
|
+
revokeListedAuthorization
|
|
216
|
+
} from "@naculus/connect-core";
|
|
217
|
+
import { onScopeDispose, shallowRef, unref, watch } from "vue";
|
|
218
|
+
function useAuthorizations({
|
|
219
|
+
managers
|
|
220
|
+
}) {
|
|
221
|
+
const entries = shallowRef([]);
|
|
222
|
+
const loading = shallowRef(false);
|
|
223
|
+
const error = shallowRef(null);
|
|
224
|
+
let generation = 0;
|
|
225
|
+
let disposed = false;
|
|
226
|
+
const refresh = async () => {
|
|
227
|
+
const own = ++generation;
|
|
228
|
+
loading.value = true;
|
|
229
|
+
error.value = null;
|
|
230
|
+
try {
|
|
231
|
+
const next = await listAuthorizations(unref(managers));
|
|
232
|
+
if (!disposed && own === generation) entries.value = next;
|
|
233
|
+
} catch (cause) {
|
|
234
|
+
if (!disposed && own === generation) {
|
|
235
|
+
error.value = cause instanceof Error ? cause : new Error("Failed to list authorizations");
|
|
236
|
+
}
|
|
237
|
+
} finally {
|
|
238
|
+
if (!disposed && own === generation) loading.value = false;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
const stop = watch(() => unref(managers), refresh, { immediate: true });
|
|
242
|
+
onScopeDispose(() => {
|
|
243
|
+
disposed = true;
|
|
244
|
+
generation += 1;
|
|
245
|
+
stop();
|
|
246
|
+
});
|
|
247
|
+
const revoke = async (entry) => {
|
|
248
|
+
try {
|
|
249
|
+
const result = await revokeListedAuthorization(unref(managers), entry);
|
|
250
|
+
await refresh();
|
|
251
|
+
return result;
|
|
252
|
+
} catch (cause) {
|
|
253
|
+
const normalized = cause instanceof Error ? cause : new Error("Failed to revoke authorization");
|
|
254
|
+
if (!disposed) error.value = normalized;
|
|
255
|
+
throw normalized;
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
return { entries, loading, error, refresh, revoke };
|
|
259
|
+
}
|
|
260
|
+
|
|
212
261
|
// src/useNotification.ts
|
|
213
262
|
import {
|
|
214
263
|
addInAppNotification,
|
|
@@ -219,40 +268,56 @@ import {
|
|
|
219
268
|
loadNotificationSettings,
|
|
220
269
|
mutedChainSettings,
|
|
221
270
|
saveNotificationSettings,
|
|
271
|
+
replayNotificationSettings,
|
|
222
272
|
updateNotificationSettings
|
|
223
273
|
} from "@naculus/connect-appkit-core";
|
|
224
274
|
import {
|
|
225
275
|
InAppChannel
|
|
226
276
|
} from "@naculus/connect-core";
|
|
227
|
-
import { computed as computed2, onScopeDispose, shallowRef, unref } from "vue";
|
|
277
|
+
import { computed as computed2, onScopeDispose as onScopeDispose2, shallowRef as shallowRef2, unref as unref2 } from "vue";
|
|
228
278
|
function useNotification(options = {}) {
|
|
229
|
-
const channel =
|
|
230
|
-
const storage =
|
|
231
|
-
const notifications =
|
|
232
|
-
const settings =
|
|
279
|
+
const channel = unref2(options.channel) ?? new InAppChannel();
|
|
280
|
+
const storage = unref2(options.storage) ?? createNotificationSettingsStorage();
|
|
281
|
+
const notifications = shallowRef2(channel.getHistory());
|
|
282
|
+
const settings = shallowRef2(
|
|
233
283
|
DEFAULT_NOTIFICATION_SETTINGS
|
|
234
284
|
);
|
|
235
285
|
const unreadCount = computed2(
|
|
236
286
|
() => notifications.value.filter((item) => !item.read).length
|
|
237
287
|
);
|
|
238
288
|
let disposed = false;
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
289
|
+
let pending = [];
|
|
290
|
+
const settle = (saved) => {
|
|
291
|
+
const queued = pending ?? [];
|
|
292
|
+
pending = null;
|
|
293
|
+
if (disposed) return;
|
|
294
|
+
if (queued.length === 0) {
|
|
295
|
+
if (saved) settings.value = saved;
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
settings.value = replayNotificationSettings(saved, queued);
|
|
299
|
+
saveNotificationSettings(storage, settings.value);
|
|
300
|
+
};
|
|
301
|
+
void loadNotificationSettings(storage).then(settle, () => settle(null));
|
|
242
302
|
channel.onNotification = (item) => {
|
|
243
303
|
if (!disposed) notifications.value = [...notifications.value, item];
|
|
244
304
|
};
|
|
245
305
|
void channel.restore().then(() => {
|
|
246
306
|
if (!disposed) notifications.value = channel.getHistory();
|
|
247
307
|
});
|
|
248
|
-
|
|
308
|
+
onScopeDispose2(() => {
|
|
249
309
|
disposed = true;
|
|
250
310
|
channel.onNotification = void 0;
|
|
251
311
|
});
|
|
252
|
-
const
|
|
253
|
-
|
|
312
|
+
const applySettings = (compute) => {
|
|
313
|
+
pending?.push(compute);
|
|
314
|
+
settings.value = updateNotificationSettings(
|
|
315
|
+
settings.value,
|
|
316
|
+
compute(settings.value)
|
|
317
|
+
);
|
|
254
318
|
saveNotificationSettings(storage, settings.value);
|
|
255
319
|
};
|
|
320
|
+
const updateSettings = (update) => applySettings(() => update);
|
|
256
321
|
return {
|
|
257
322
|
notifications,
|
|
258
323
|
unreadCount,
|
|
@@ -282,8 +347,8 @@ function useNotification(options = {}) {
|
|
|
282
347
|
},
|
|
283
348
|
updateSettings,
|
|
284
349
|
setChannels: (channels) => updateSettings(channelsUpdate(channels)),
|
|
285
|
-
muteChain: (chainId) =>
|
|
286
|
-
unmuteChain: (chainId) =>
|
|
350
|
+
muteChain: (chainId) => applySettings((current) => mutedChainSettings(current, chainId, true)),
|
|
351
|
+
unmuteChain: (chainId) => applySettings((current) => mutedChainSettings(current, chainId, false))
|
|
287
352
|
};
|
|
288
353
|
}
|
|
289
354
|
|
|
@@ -292,13 +357,13 @@ import { resolveSimulationEndpoint } from "@naculus/connect-appkit-core";
|
|
|
292
357
|
import {
|
|
293
358
|
SimulationManager
|
|
294
359
|
} from "@naculus/connect-core";
|
|
295
|
-
import { shallowRef as
|
|
360
|
+
import { shallowRef as shallowRef4, unref as unref3 } from "vue";
|
|
296
361
|
|
|
297
362
|
// src/internal/action-guard.ts
|
|
298
|
-
import { onScopeDispose as
|
|
363
|
+
import { onScopeDispose as onScopeDispose3, shallowRef as shallowRef3 } from "vue";
|
|
299
364
|
function useActionGuard() {
|
|
300
|
-
const busy =
|
|
301
|
-
const error =
|
|
365
|
+
const busy = shallowRef3(false);
|
|
366
|
+
const error = shallowRef3(null);
|
|
302
367
|
let active = 0;
|
|
303
368
|
let generation = 0;
|
|
304
369
|
let disposed = false;
|
|
@@ -339,24 +404,24 @@ function useActionGuard() {
|
|
|
339
404
|
disposed = true;
|
|
340
405
|
generation++;
|
|
341
406
|
};
|
|
342
|
-
|
|
407
|
+
onScopeDispose3(dispose);
|
|
343
408
|
return { busy, error, run, clearError, reset, invalidate, dispose };
|
|
344
409
|
}
|
|
345
410
|
|
|
346
411
|
// src/useSimulateTransfer.ts
|
|
347
412
|
function useSimulateTransfer(options = {}) {
|
|
348
413
|
const guard = useActionGuard();
|
|
349
|
-
const result =
|
|
350
|
-
const loading =
|
|
414
|
+
const result = shallowRef4(null);
|
|
415
|
+
const loading = shallowRef4(false);
|
|
351
416
|
let manager;
|
|
352
417
|
const simulate = async (tokenAddress, from, to, amount, callOptions) => {
|
|
353
418
|
loading.value = true;
|
|
354
419
|
return await guard.run(
|
|
355
420
|
async (commit) => {
|
|
356
|
-
const fallbackRpcUrl =
|
|
421
|
+
const fallbackRpcUrl = unref3(options.rpcUrl);
|
|
357
422
|
const endpoint = resolveSimulationEndpoint(
|
|
358
423
|
callOptions?.chainId,
|
|
359
|
-
|
|
424
|
+
unref3(options.chainId),
|
|
360
425
|
callOptions?.rpcUrl,
|
|
361
426
|
fallbackRpcUrl
|
|
362
427
|
);
|
|
@@ -400,11 +465,11 @@ function useSimulateTransfer(options = {}) {
|
|
|
400
465
|
import {
|
|
401
466
|
simulateTransactionPreview
|
|
402
467
|
} from "@naculus/connect-appkit-core";
|
|
403
|
-
import { onScopeDispose as
|
|
468
|
+
import { onScopeDispose as onScopeDispose4, shallowRef as shallowRef5, toValue as toValue2, unref as unref4, watch as watch2 } from "vue";
|
|
404
469
|
function useTransactionSimulation(tx, options = {}) {
|
|
405
470
|
const guard = useActionGuard();
|
|
406
|
-
const result =
|
|
407
|
-
const isSimulating =
|
|
471
|
+
const result = shallowRef5(void 0);
|
|
472
|
+
const isSimulating = shallowRef5(false);
|
|
408
473
|
let timer;
|
|
409
474
|
const simulate = async () => {
|
|
410
475
|
const transaction = toValue2(tx);
|
|
@@ -412,10 +477,10 @@ function useTransactionSimulation(tx, options = {}) {
|
|
|
412
477
|
return await guard.run(
|
|
413
478
|
async (commit) => {
|
|
414
479
|
const value = await simulateTransactionPreview(transaction, {
|
|
415
|
-
chainId:
|
|
416
|
-
currentChain:
|
|
417
|
-
publicClient:
|
|
418
|
-
evmAccount:
|
|
480
|
+
chainId: unref4(options.chainId),
|
|
481
|
+
currentChain: unref4(options.currentChain),
|
|
482
|
+
publicClient: unref4(options.publicClient),
|
|
483
|
+
evmAccount: unref4(options.evmAccount)
|
|
419
484
|
});
|
|
420
485
|
commit(() => {
|
|
421
486
|
result.value = value;
|
|
@@ -432,13 +497,13 @@ function useTransactionSimulation(tx, options = {}) {
|
|
|
432
497
|
}
|
|
433
498
|
);
|
|
434
499
|
};
|
|
435
|
-
|
|
500
|
+
watch2(
|
|
436
501
|
[
|
|
437
502
|
() => toValue2(tx),
|
|
438
|
-
() =>
|
|
439
|
-
() =>
|
|
440
|
-
() =>
|
|
441
|
-
() =>
|
|
503
|
+
() => unref4(options.chainId),
|
|
504
|
+
() => unref4(options.currentChain),
|
|
505
|
+
() => unref4(options.publicClient),
|
|
506
|
+
() => unref4(options.evmAccount)
|
|
442
507
|
],
|
|
443
508
|
([transaction]) => {
|
|
444
509
|
guard.invalidate();
|
|
@@ -460,7 +525,7 @@ function useTransactionSimulation(tx, options = {}) {
|
|
|
460
525
|
result.value = void 0;
|
|
461
526
|
isSimulating.value = false;
|
|
462
527
|
};
|
|
463
|
-
|
|
528
|
+
onScopeDispose4(() => {
|
|
464
529
|
if (timer) clearTimeout(timer);
|
|
465
530
|
});
|
|
466
531
|
return { result, isSimulating, error: guard.error, simulate, reset };
|
|
@@ -478,7 +543,7 @@ import {
|
|
|
478
543
|
parseUnits,
|
|
479
544
|
WalletError as WalletError2
|
|
480
545
|
} from "@naculus/connect-core";
|
|
481
|
-
import { onScopeDispose as
|
|
546
|
+
import { onScopeDispose as onScopeDispose5, shallowRef as shallowRef6, toValue as toValue3, unref as unref5, watch as watch3 } from "vue";
|
|
482
547
|
|
|
483
548
|
// src/erc20.ts
|
|
484
549
|
import {
|
|
@@ -503,11 +568,11 @@ function assertErc20Context(token, chainId, account, connected) {
|
|
|
503
568
|
function useERC20Transfer(options) {
|
|
504
569
|
const initialToken = toValue3(options.token);
|
|
505
570
|
const decimals = createDecimalsCache(initialToken, initialToken.decimals);
|
|
506
|
-
const isSending =
|
|
507
|
-
const error =
|
|
571
|
+
const isSending = shallowRef6(false);
|
|
572
|
+
const error = shallowRef6(null);
|
|
508
573
|
let generation = 0;
|
|
509
574
|
let disposed = false;
|
|
510
|
-
|
|
575
|
+
watch3(
|
|
511
576
|
[
|
|
512
577
|
() => toValue3(options.token).address,
|
|
513
578
|
() => toValue3(options.token).chainId,
|
|
@@ -516,7 +581,7 @@ function useERC20Transfer(options) {
|
|
|
516
581
|
() => toValue3(options.chainId),
|
|
517
582
|
() => toValue3(options.connected),
|
|
518
583
|
() => toValue3(options.publicClient),
|
|
519
|
-
() =>
|
|
584
|
+
() => unref5(options.sendTransaction)
|
|
520
585
|
],
|
|
521
586
|
() => {
|
|
522
587
|
generation++;
|
|
@@ -563,7 +628,7 @@ function useERC20Transfer(options) {
|
|
|
563
628
|
writeDecimals(decimals, token, precision);
|
|
564
629
|
}
|
|
565
630
|
const data = encodeErc20Transfer(to, parseUnits(amount, precision));
|
|
566
|
-
return await
|
|
631
|
+
return await unref5(options.sendTransaction)({
|
|
567
632
|
to: token.address,
|
|
568
633
|
data,
|
|
569
634
|
value: "0"
|
|
@@ -576,7 +641,7 @@ function useERC20Transfer(options) {
|
|
|
576
641
|
if (stillCurrent()) isSending.value = false;
|
|
577
642
|
}
|
|
578
643
|
};
|
|
579
|
-
|
|
644
|
+
onScopeDispose5(() => {
|
|
580
645
|
disposed = true;
|
|
581
646
|
generation++;
|
|
582
647
|
});
|
|
@@ -598,24 +663,24 @@ import {
|
|
|
598
663
|
} from "@naculus/connect-core";
|
|
599
664
|
import {
|
|
600
665
|
computed as computed3,
|
|
601
|
-
onScopeDispose as
|
|
602
|
-
shallowRef as
|
|
666
|
+
onScopeDispose as onScopeDispose6,
|
|
667
|
+
shallowRef as shallowRef7,
|
|
603
668
|
toValue as toValue4,
|
|
604
|
-
unref as
|
|
605
|
-
watch as
|
|
669
|
+
unref as unref6,
|
|
670
|
+
watch as watch4
|
|
606
671
|
} from "vue";
|
|
607
672
|
var MAX_UINT256 = (1n << 256n) - 1n;
|
|
608
673
|
function useERC20Approve(options) {
|
|
609
674
|
const initialToken = toValue4(options.token);
|
|
610
675
|
const decimals = createDecimalsCache2(initialToken, initialToken.decimals);
|
|
611
|
-
const allowanceRaw =
|
|
612
|
-
const isApproving =
|
|
613
|
-
const isFetchingAllowance =
|
|
614
|
-
const error =
|
|
676
|
+
const allowanceRaw = shallowRef7(null);
|
|
677
|
+
const isApproving = shallowRef7(false);
|
|
678
|
+
const isFetchingAllowance = shallowRef7(false);
|
|
679
|
+
const error = shallowRef7(null);
|
|
615
680
|
let generation = 0;
|
|
616
681
|
let allowanceGeneration = 0;
|
|
617
682
|
let disposed = false;
|
|
618
|
-
|
|
683
|
+
watch4(
|
|
619
684
|
[
|
|
620
685
|
() => toValue4(options.token).address,
|
|
621
686
|
() => toValue4(options.token).chainId,
|
|
@@ -625,7 +690,7 @@ function useERC20Approve(options) {
|
|
|
625
690
|
() => toValue4(options.chainId),
|
|
626
691
|
() => toValue4(options.connected),
|
|
627
692
|
() => toValue4(options.publicClient),
|
|
628
|
-
() =>
|
|
693
|
+
() => unref6(options.sendTransaction)
|
|
629
694
|
],
|
|
630
695
|
() => {
|
|
631
696
|
generation++;
|
|
@@ -699,7 +764,7 @@ function useERC20Approve(options) {
|
|
|
699
764
|
isApproving.value = true;
|
|
700
765
|
try {
|
|
701
766
|
const { token, spender } = context();
|
|
702
|
-
const hash = await
|
|
767
|
+
const hash = await unref6(options.sendTransaction)({
|
|
703
768
|
to: token.address,
|
|
704
769
|
data: encodeErc20Approve(spender, rawAmount),
|
|
705
770
|
value: "0"
|
|
@@ -746,7 +811,7 @@ function useERC20Approve(options) {
|
|
|
746
811
|
const precision = readDecimals2(decimals, token, token.decimals);
|
|
747
812
|
return precision === void 0 ? null : formatUnits(allowanceRaw.value, precision);
|
|
748
813
|
});
|
|
749
|
-
|
|
814
|
+
onScopeDispose6(() => {
|
|
750
815
|
disposed = true;
|
|
751
816
|
generation++;
|
|
752
817
|
allowanceGeneration++;
|
|
@@ -832,7 +897,7 @@ function useAccount(accounts, connected) {
|
|
|
832
897
|
}
|
|
833
898
|
|
|
834
899
|
// src/useSession.ts
|
|
835
|
-
import { computed as computed6, shallowRef as
|
|
900
|
+
import { computed as computed6, shallowRef as shallowRef8, toValue as toValue7, watch as watch5 } from "vue";
|
|
836
901
|
function readSession(manager) {
|
|
837
902
|
const bundle = manager?.getActiveBundle();
|
|
838
903
|
if (!bundle) {
|
|
@@ -851,8 +916,8 @@ function readSession(manager) {
|
|
|
851
916
|
};
|
|
852
917
|
}
|
|
853
918
|
function useSession(manager) {
|
|
854
|
-
const snapshot =
|
|
855
|
-
|
|
919
|
+
const snapshot = shallowRef8(readSession(toValue7(manager)));
|
|
920
|
+
watch5(
|
|
856
921
|
() => toValue7(manager),
|
|
857
922
|
(current, _previous, onCleanup) => {
|
|
858
923
|
const update = () => {
|
|
@@ -886,13 +951,13 @@ function useSession(manager) {
|
|
|
886
951
|
|
|
887
952
|
// src/useConnect.ts
|
|
888
953
|
import { WalletError as WalletError4 } from "@naculus/connect-core";
|
|
889
|
-
import { computed as computed7, toValue as toValue8, unref as
|
|
954
|
+
import { computed as computed7, toValue as toValue8, unref as unref7 } from "vue";
|
|
890
955
|
function useConnect(action, status) {
|
|
891
956
|
const guard = useActionGuard();
|
|
892
957
|
let inFlight = null;
|
|
893
958
|
const connect = () => {
|
|
894
959
|
if (inFlight) return inFlight;
|
|
895
|
-
const invoke =
|
|
960
|
+
const invoke = unref7(action);
|
|
896
961
|
const pending = guard.run(
|
|
897
962
|
() => Promise.resolve().then(() => invoke()),
|
|
898
963
|
"Connection failed",
|
|
@@ -917,14 +982,14 @@ function useConnect(action, status) {
|
|
|
917
982
|
}
|
|
918
983
|
|
|
919
984
|
// src/useDisconnect.ts
|
|
920
|
-
import { toValue as toValue9, unref as
|
|
985
|
+
import { toValue as toValue9, unref as unref8 } from "vue";
|
|
921
986
|
function useDisconnect(action, status) {
|
|
922
987
|
const guard = useActionGuard();
|
|
923
988
|
let inFlight = null;
|
|
924
989
|
const disconnect = () => {
|
|
925
990
|
if (inFlight) return inFlight;
|
|
926
991
|
if (toValue9(status) === "disconnected") return Promise.resolve();
|
|
927
|
-
const invoke =
|
|
992
|
+
const invoke = unref8(action);
|
|
928
993
|
const pending = guard.run(() => Promise.resolve().then(() => invoke()), "Disconnect failed").catch(() => {
|
|
929
994
|
}).finally(() => {
|
|
930
995
|
if (inFlight === pending) inFlight = null;
|
|
@@ -945,11 +1010,11 @@ function useDisconnect(action, status) {
|
|
|
945
1010
|
|
|
946
1011
|
// src/useSwitchChain.ts
|
|
947
1012
|
import { toChainSwitchError } from "@naculus/connect-appkit-core";
|
|
948
|
-
import { computed as computed8, toValue as toValue10, unref as
|
|
1013
|
+
import { computed as computed8, toValue as toValue10, unref as unref9 } from "vue";
|
|
949
1014
|
function useSwitchChain(action, chainId) {
|
|
950
1015
|
const guard = useActionGuard();
|
|
951
1016
|
const switchChain = (targetChainId) => {
|
|
952
|
-
const invoke =
|
|
1017
|
+
const invoke = unref9(action);
|
|
953
1018
|
return guard.run(async () => {
|
|
954
1019
|
try {
|
|
955
1020
|
await invoke(targetChainId);
|
|
@@ -968,11 +1033,11 @@ function useSwitchChain(action, chainId) {
|
|
|
968
1033
|
}
|
|
969
1034
|
|
|
970
1035
|
// src/useSignMessage.ts
|
|
971
|
-
import { unref as
|
|
1036
|
+
import { unref as unref10 } from "vue";
|
|
972
1037
|
function useSignMessage(action) {
|
|
973
1038
|
const guard = useActionGuard();
|
|
974
1039
|
const signMessage = (message) => {
|
|
975
|
-
const invoke =
|
|
1040
|
+
const invoke = unref10(action);
|
|
976
1041
|
return guard.run(() => invoke(message), "Signing failed");
|
|
977
1042
|
};
|
|
978
1043
|
return {
|
|
@@ -984,12 +1049,12 @@ function useSignMessage(action) {
|
|
|
984
1049
|
}
|
|
985
1050
|
|
|
986
1051
|
// src/useSendTransaction.ts
|
|
987
|
-
import { computed as computed9, shallowRef as
|
|
1052
|
+
import { computed as computed9, shallowRef as shallowRef9, unref as unref11 } from "vue";
|
|
988
1053
|
function useSendTransaction(action) {
|
|
989
1054
|
const guard = useActionGuard();
|
|
990
|
-
const status =
|
|
1055
|
+
const status = shallowRef9("idle");
|
|
991
1056
|
const sendTransaction = (transaction) => {
|
|
992
|
-
const invoke =
|
|
1057
|
+
const invoke = unref11(action);
|
|
993
1058
|
status.value = "awaiting_approval";
|
|
994
1059
|
return guard.run(async (commit) => {
|
|
995
1060
|
const hash = await invoke(transaction);
|
|
@@ -1016,15 +1081,15 @@ function useSendTransaction(action) {
|
|
|
1016
1081
|
}
|
|
1017
1082
|
|
|
1018
1083
|
// src/useSolanaTransaction.ts
|
|
1019
|
-
import { shallowRef as
|
|
1084
|
+
import { shallowRef as shallowRef10, unref as unref12 } from "vue";
|
|
1020
1085
|
function useSolanaTransaction(options) {
|
|
1021
1086
|
const guard = useActionGuard();
|
|
1022
|
-
const isSigning =
|
|
1023
|
-
const isSending =
|
|
1087
|
+
const isSigning = shallowRef10(false);
|
|
1088
|
+
const isSending = shallowRef10(false);
|
|
1024
1089
|
let signing = 0;
|
|
1025
1090
|
let sending = 0;
|
|
1026
1091
|
const signTransaction = (transaction) => {
|
|
1027
|
-
const invoke =
|
|
1092
|
+
const invoke = unref12(options.signTransaction);
|
|
1028
1093
|
signing++;
|
|
1029
1094
|
isSigning.value = true;
|
|
1030
1095
|
return guard.run(() => invoke(transaction), "Signing failed").finally(() => {
|
|
@@ -1033,7 +1098,7 @@ function useSolanaTransaction(options) {
|
|
|
1033
1098
|
});
|
|
1034
1099
|
};
|
|
1035
1100
|
const sendTransaction = (transaction) => {
|
|
1036
|
-
const invoke =
|
|
1101
|
+
const invoke = unref12(options.sendTransaction);
|
|
1037
1102
|
sending++;
|
|
1038
1103
|
isSending.value = true;
|
|
1039
1104
|
return guard.run(() => invoke(transaction), "Send failed").finally(() => {
|
|
@@ -1041,7 +1106,7 @@ function useSolanaTransaction(options) {
|
|
|
1041
1106
|
isSending.value = sending > 0;
|
|
1042
1107
|
});
|
|
1043
1108
|
};
|
|
1044
|
-
const getStatus = (signature) =>
|
|
1109
|
+
const getStatus = (signature) => unref12(options.getStatus)(signature);
|
|
1045
1110
|
return {
|
|
1046
1111
|
signTransaction,
|
|
1047
1112
|
sendTransaction,
|
|
@@ -1054,12 +1119,12 @@ function useSolanaTransaction(options) {
|
|
|
1054
1119
|
}
|
|
1055
1120
|
|
|
1056
1121
|
// src/useSignInWithX.ts
|
|
1057
|
-
import { shallowRef as
|
|
1122
|
+
import { shallowRef as shallowRef11, unref as unref13 } from "vue";
|
|
1058
1123
|
function useSignInWithX(action) {
|
|
1059
1124
|
const guard = useActionGuard();
|
|
1060
|
-
const result =
|
|
1125
|
+
const result = shallowRef11(null);
|
|
1061
1126
|
const signIn = (options) => {
|
|
1062
|
-
const invoke =
|
|
1127
|
+
const invoke = unref13(action);
|
|
1063
1128
|
return guard.run(async (commit) => {
|
|
1064
1129
|
const next = await invoke(options);
|
|
1065
1130
|
commit(() => {
|
|
@@ -1088,17 +1153,17 @@ function useSignInWithEthereum(action) {
|
|
|
1088
1153
|
}
|
|
1089
1154
|
|
|
1090
1155
|
// src/useExecuteCalls.ts
|
|
1091
|
-
import { computed as computed10, toValue as toValue11, unref as
|
|
1156
|
+
import { computed as computed10, toValue as toValue11, unref as unref14 } from "vue";
|
|
1092
1157
|
function useExecuteCalls(options) {
|
|
1093
1158
|
const guard = useActionGuard();
|
|
1094
|
-
const preview = (callCount, atomicity) =>
|
|
1159
|
+
const preview = (callCount, atomicity) => unref14(options.preview)(callCount, atomicity);
|
|
1095
1160
|
const execute = (calls, atomicity) => {
|
|
1096
|
-
const invoke =
|
|
1161
|
+
const invoke = unref14(options.execute);
|
|
1097
1162
|
return guard.run(() => invoke(calls, atomicity), "Execution failed");
|
|
1098
1163
|
};
|
|
1099
1164
|
const reset = () => {
|
|
1100
1165
|
guard.reset();
|
|
1101
|
-
|
|
1166
|
+
unref14(options.reset)();
|
|
1102
1167
|
};
|
|
1103
1168
|
return {
|
|
1104
1169
|
preview,
|
|
@@ -1119,24 +1184,24 @@ import {
|
|
|
1119
1184
|
} from "@naculus/connect-appkit-core";
|
|
1120
1185
|
import {
|
|
1121
1186
|
computed as computed12,
|
|
1122
|
-
onScopeDispose as
|
|
1123
|
-
shallowRef as
|
|
1187
|
+
onScopeDispose as onScopeDispose8,
|
|
1188
|
+
shallowRef as shallowRef13,
|
|
1124
1189
|
toValue as toValue13,
|
|
1125
|
-
unref as
|
|
1126
|
-
watch as
|
|
1190
|
+
unref as unref15,
|
|
1191
|
+
watch as watch7
|
|
1127
1192
|
} from "vue";
|
|
1128
1193
|
|
|
1129
1194
|
// src/useSessionKeys.ts
|
|
1130
1195
|
import { getSharedSessionKeyManager } from "@naculus/connect-appkit-core";
|
|
1131
|
-
import { computed as computed11, onScopeDispose as
|
|
1196
|
+
import { computed as computed11, onScopeDispose as onScopeDispose7, shallowRef as shallowRef12, toValue as toValue12, watch as watch6 } from "vue";
|
|
1132
1197
|
function resolveManager(config, options) {
|
|
1133
1198
|
return options.manager ?? getSharedSessionKeyManager(config);
|
|
1134
1199
|
}
|
|
1135
1200
|
function useSessionKeys(connected, config, options = {}) {
|
|
1136
1201
|
const manager = resolveManager(config, options);
|
|
1137
|
-
const sessions =
|
|
1138
|
-
const loading =
|
|
1139
|
-
const error =
|
|
1202
|
+
const sessions = shallowRef12([]);
|
|
1203
|
+
const loading = shallowRef12(false);
|
|
1204
|
+
const error = shallowRef12(null);
|
|
1140
1205
|
let generation = 0;
|
|
1141
1206
|
let disposed = false;
|
|
1142
1207
|
const refresh = async () => {
|
|
@@ -1158,14 +1223,14 @@ function useSessionKeys(connected, config, options = {}) {
|
|
|
1158
1223
|
if (!disposed && own === generation) loading.value = false;
|
|
1159
1224
|
}
|
|
1160
1225
|
};
|
|
1161
|
-
|
|
1226
|
+
watch6(
|
|
1162
1227
|
() => toValue12(connected),
|
|
1163
1228
|
() => {
|
|
1164
1229
|
void refresh();
|
|
1165
1230
|
},
|
|
1166
1231
|
{ immediate: true }
|
|
1167
1232
|
);
|
|
1168
|
-
|
|
1233
|
+
onScopeDispose7(() => {
|
|
1169
1234
|
disposed = true;
|
|
1170
1235
|
generation++;
|
|
1171
1236
|
});
|
|
@@ -1186,7 +1251,7 @@ function useSessionKeys(connected, config, options = {}) {
|
|
|
1186
1251
|
function useCreateSessionKey(config, options = {}) {
|
|
1187
1252
|
const manager = resolveManager(config, options);
|
|
1188
1253
|
const guard = useActionGuard();
|
|
1189
|
-
const lastCreated =
|
|
1254
|
+
const lastCreated = shallowRef12(null);
|
|
1190
1255
|
return {
|
|
1191
1256
|
createSessionKey: (scope, signerAddress) => guard.run(async () => {
|
|
1192
1257
|
const info = await manager.createSessionKey(scope, signerAddress);
|
|
@@ -1237,9 +1302,9 @@ function useDelegationPolicy(options) {
|
|
|
1237
1302
|
manager
|
|
1238
1303
|
});
|
|
1239
1304
|
const guard = useActionGuard();
|
|
1240
|
-
const verifiedIds =
|
|
1241
|
-
const isVerifying =
|
|
1242
|
-
const verifyError =
|
|
1305
|
+
const verifiedIds = shallowRef13(/* @__PURE__ */ new Set());
|
|
1306
|
+
const isVerifying = shallowRef13(false);
|
|
1307
|
+
const verifyError = shallowRef13(null);
|
|
1243
1308
|
let verifyGeneration = 0;
|
|
1244
1309
|
let disposed = false;
|
|
1245
1310
|
const origin = options.origin ?? (typeof window !== "undefined" ? window.location.origin : "unknown");
|
|
@@ -1247,12 +1312,12 @@ function useDelegationPolicy(options) {
|
|
|
1247
1312
|
manager,
|
|
1248
1313
|
origin,
|
|
1249
1314
|
signer: () => bareEvmAddress2(toValue13(options.account)),
|
|
1250
|
-
signMessage: (message) =>
|
|
1251
|
-
verifySignature: (input) =>
|
|
1252
|
-
previewExecution: (callCount, atomicity) =>
|
|
1315
|
+
signMessage: (message) => unref15(options.signMessage)(message),
|
|
1316
|
+
verifySignature: (input) => unref15(options.verifySignature)(input),
|
|
1317
|
+
previewExecution: (callCount, atomicity) => unref15(options.previewExecution)(callCount, atomicity),
|
|
1253
1318
|
sponsorship: options.sponsorship,
|
|
1254
1319
|
adapter: options.adapter,
|
|
1255
|
-
signTypedData: options.signTypedData ? (typedData) =>
|
|
1320
|
+
signTypedData: options.signTypedData ? (typedData) => unref15(
|
|
1256
1321
|
options.signTypedData
|
|
1257
1322
|
)(typedData) : void 0,
|
|
1258
1323
|
chainId: () => toValue13(options.chainId) ?? null,
|
|
@@ -1261,7 +1326,7 @@ function useDelegationPolicy(options) {
|
|
|
1261
1326
|
storageAvailable: () => sessionKeys.storageAvailable,
|
|
1262
1327
|
refresh: sessionKeys.refresh
|
|
1263
1328
|
});
|
|
1264
|
-
|
|
1329
|
+
watch7(
|
|
1265
1330
|
() => sessionKeys.sessions.value,
|
|
1266
1331
|
(sessions) => {
|
|
1267
1332
|
const own = ++verifyGeneration;
|
|
@@ -1291,7 +1356,7 @@ function useDelegationPolicy(options) {
|
|
|
1291
1356
|
},
|
|
1292
1357
|
{ immediate: true }
|
|
1293
1358
|
);
|
|
1294
|
-
|
|
1359
|
+
onScopeDispose8(() => {
|
|
1295
1360
|
disposed = true;
|
|
1296
1361
|
verifyGeneration++;
|
|
1297
1362
|
});
|
|
@@ -1334,18 +1399,18 @@ import {
|
|
|
1334
1399
|
import { WalletError as WalletError5 } from "@naculus/connect-core";
|
|
1335
1400
|
import {
|
|
1336
1401
|
computed as computed13,
|
|
1337
|
-
onScopeDispose as
|
|
1338
|
-
shallowRef as
|
|
1402
|
+
onScopeDispose as onScopeDispose9,
|
|
1403
|
+
shallowRef as shallowRef14,
|
|
1339
1404
|
toValue as toValue14,
|
|
1340
|
-
unref as
|
|
1341
|
-
watch as
|
|
1405
|
+
unref as unref16,
|
|
1406
|
+
watch as watch8
|
|
1342
1407
|
} from "vue";
|
|
1343
1408
|
function useSmartAccount(options) {
|
|
1344
|
-
const address =
|
|
1345
|
-
const isDeployed =
|
|
1346
|
-
const accountInfo =
|
|
1409
|
+
const address = shallowRef14(null);
|
|
1410
|
+
const isDeployed = shallowRef14(false);
|
|
1411
|
+
const accountInfo = shallowRef14(null);
|
|
1347
1412
|
const guard = useActionGuard();
|
|
1348
|
-
const managerRef =
|
|
1413
|
+
const managerRef = shallowRef14(null);
|
|
1349
1414
|
let generation = 0;
|
|
1350
1415
|
let inFlight = false;
|
|
1351
1416
|
let disposed = false;
|
|
@@ -1355,7 +1420,7 @@ function useSmartAccount(options) {
|
|
|
1355
1420
|
toValue14(options.connectedChainId)
|
|
1356
1421
|
)
|
|
1357
1422
|
);
|
|
1358
|
-
|
|
1423
|
+
watch8(
|
|
1359
1424
|
[
|
|
1360
1425
|
() => toValue14(options.manager),
|
|
1361
1426
|
() => toValue14(options.rpcUrl),
|
|
@@ -1435,7 +1500,7 @@ function useSmartAccount(options) {
|
|
|
1435
1500
|
return info;
|
|
1436
1501
|
}, "Failed to create smart account");
|
|
1437
1502
|
const deployWallet = () => operate(async (manager, cfg, commit) => {
|
|
1438
|
-
const send =
|
|
1503
|
+
const send = unref16(options.sendTransaction);
|
|
1439
1504
|
if (!send) {
|
|
1440
1505
|
throw new WalletError5(
|
|
1441
1506
|
"wallet_unavailable",
|
|
@@ -1465,7 +1530,7 @@ function useSmartAccount(options) {
|
|
|
1465
1530
|
});
|
|
1466
1531
|
return addr;
|
|
1467
1532
|
}, "Failed to get smart account address");
|
|
1468
|
-
|
|
1533
|
+
onScopeDispose9(() => {
|
|
1469
1534
|
disposed = true;
|
|
1470
1535
|
generation++;
|
|
1471
1536
|
});
|
|
@@ -1489,13 +1554,13 @@ import {
|
|
|
1489
1554
|
resolveUserOpChain
|
|
1490
1555
|
} from "@naculus/connect-appkit-core";
|
|
1491
1556
|
import { WalletError as WalletError6 } from "@naculus/connect-core";
|
|
1492
|
-
import { onScopeDispose as
|
|
1557
|
+
import { onScopeDispose as onScopeDispose10, shallowRef as shallowRef15, toValue as toValue15, unref as unref17 } from "vue";
|
|
1493
1558
|
function useSendUserOperation(options) {
|
|
1494
|
-
const userOpHash =
|
|
1495
|
-
const receipt =
|
|
1496
|
-
const isPending =
|
|
1497
|
-
const isEstimating =
|
|
1498
|
-
const error =
|
|
1559
|
+
const userOpHash = shallowRef15(null);
|
|
1560
|
+
const receipt = shallowRef15(null);
|
|
1561
|
+
const isPending = shallowRef15(false);
|
|
1562
|
+
const isEstimating = shallowRef15(false);
|
|
1563
|
+
const error = shallowRef15(null);
|
|
1499
1564
|
let requestId = 0;
|
|
1500
1565
|
let inFlight = false;
|
|
1501
1566
|
let disposed = false;
|
|
@@ -1529,7 +1594,7 @@ function useSendUserOperation(options) {
|
|
|
1529
1594
|
} catch (chainError) {
|
|
1530
1595
|
return fail(chainError);
|
|
1531
1596
|
}
|
|
1532
|
-
const signer =
|
|
1597
|
+
const signer = unref17(options.signer);
|
|
1533
1598
|
const own = ++requestId;
|
|
1534
1599
|
inFlight = true;
|
|
1535
1600
|
isPending.value = true;
|
|
@@ -1580,7 +1645,7 @@ function useSendUserOperation(options) {
|
|
|
1580
1645
|
isEstimating.value = false;
|
|
1581
1646
|
error.value = null;
|
|
1582
1647
|
};
|
|
1583
|
-
|
|
1648
|
+
onScopeDispose10(() => {
|
|
1584
1649
|
disposed = true;
|
|
1585
1650
|
requestId++;
|
|
1586
1651
|
});
|
|
@@ -1600,15 +1665,15 @@ import {
|
|
|
1600
1665
|
fetchUserOperationReceipt,
|
|
1601
1666
|
InvalidUserOperationReceiptError
|
|
1602
1667
|
} from "@naculus/connect-appkit-core";
|
|
1603
|
-
import { onScopeDispose as
|
|
1668
|
+
import { onScopeDispose as onScopeDispose11, shallowRef as shallowRef16, toValue as toValue16 } from "vue";
|
|
1604
1669
|
function useUserOpStatus(options) {
|
|
1605
|
-
const status =
|
|
1606
|
-
const receipt =
|
|
1607
|
-
const userOpHash =
|
|
1608
|
-
const error =
|
|
1609
|
-
const isPolling =
|
|
1610
|
-
const elapsedMs =
|
|
1611
|
-
const attempts =
|
|
1670
|
+
const status = shallowRef16("idle");
|
|
1671
|
+
const receipt = shallowRef16(null);
|
|
1672
|
+
const userOpHash = shallowRef16(null);
|
|
1673
|
+
const error = shallowRef16(null);
|
|
1674
|
+
const isPolling = shallowRef16(false);
|
|
1675
|
+
const elapsedMs = shallowRef16(0);
|
|
1676
|
+
const attempts = shallowRef16(0);
|
|
1612
1677
|
const pollInterval = options.pollInterval ?? 2e3;
|
|
1613
1678
|
const maxRetries = options.maxRetries ?? 30;
|
|
1614
1679
|
let generation = 0;
|
|
@@ -1714,7 +1779,7 @@ function useUserOpStatus(options) {
|
|
|
1714
1779
|
attempts.value = 0;
|
|
1715
1780
|
elapsedMs.value = 0;
|
|
1716
1781
|
};
|
|
1717
|
-
|
|
1782
|
+
onScopeDispose11(stop);
|
|
1718
1783
|
return {
|
|
1719
1784
|
status,
|
|
1720
1785
|
receipt,
|
|
@@ -1730,17 +1795,17 @@ function useUserOpStatus(options) {
|
|
|
1730
1795
|
}
|
|
1731
1796
|
|
|
1732
1797
|
// src/useSendCalls.ts
|
|
1733
|
-
import { computed as computed14, onScopeDispose as
|
|
1798
|
+
import { computed as computed14, onScopeDispose as onScopeDispose12, shallowRef as shallowRef17, toValue as toValue17, unref as unref18 } from "vue";
|
|
1734
1799
|
function useSendCalls(options) {
|
|
1735
|
-
const status =
|
|
1736
|
-
const error =
|
|
1737
|
-
const batchHash =
|
|
1738
|
-
const callsStatus =
|
|
1800
|
+
const status = shallowRef17("idle");
|
|
1801
|
+
const error = shallowRef17(null);
|
|
1802
|
+
const batchHash = shallowRef17(null);
|
|
1803
|
+
const callsStatus = shallowRef17(null);
|
|
1739
1804
|
let sendGeneration = 0;
|
|
1740
1805
|
let statusGeneration = 0;
|
|
1741
1806
|
let disposed = false;
|
|
1742
1807
|
const sendCalls = async (calls, input) => {
|
|
1743
|
-
const invoke =
|
|
1808
|
+
const invoke = unref18(options.sendCalls);
|
|
1744
1809
|
const own = ++sendGeneration;
|
|
1745
1810
|
status.value = "awaiting_approval";
|
|
1746
1811
|
error.value = null;
|
|
@@ -1762,13 +1827,13 @@ function useSendCalls(options) {
|
|
|
1762
1827
|
}
|
|
1763
1828
|
};
|
|
1764
1829
|
const getCallsStatus = async (hash) => {
|
|
1765
|
-
const invoke =
|
|
1830
|
+
const invoke = unref18(options.getCallsStatus);
|
|
1766
1831
|
const own = ++statusGeneration;
|
|
1767
1832
|
const result = await invoke(hash);
|
|
1768
1833
|
if (!disposed && own === statusGeneration) callsStatus.value = result;
|
|
1769
1834
|
return result;
|
|
1770
1835
|
};
|
|
1771
|
-
const showCallsStatus = (hash) =>
|
|
1836
|
+
const showCallsStatus = (hash) => unref18(options.showCallsStatus)(hash);
|
|
1772
1837
|
const reset = () => {
|
|
1773
1838
|
sendGeneration++;
|
|
1774
1839
|
statusGeneration++;
|
|
@@ -1777,7 +1842,7 @@ function useSendCalls(options) {
|
|
|
1777
1842
|
batchHash.value = null;
|
|
1778
1843
|
callsStatus.value = null;
|
|
1779
1844
|
};
|
|
1780
|
-
|
|
1845
|
+
onScopeDispose12(() => {
|
|
1781
1846
|
disposed = true;
|
|
1782
1847
|
sendGeneration++;
|
|
1783
1848
|
statusGeneration++;
|
|
@@ -1797,7 +1862,7 @@ function useSendCalls(options) {
|
|
|
1797
1862
|
}
|
|
1798
1863
|
|
|
1799
1864
|
// src/useEmbeddedWallet.ts
|
|
1800
|
-
import { computed as computed15, toValue as toValue18, unref as
|
|
1865
|
+
import { computed as computed15, toValue as toValue18, unref as unref19 } from "vue";
|
|
1801
1866
|
function useEmbeddedWallet(options) {
|
|
1802
1867
|
const guard = useActionGuard();
|
|
1803
1868
|
const run = (action) => guard.run(action, "Embedded wallet action failed");
|
|
@@ -1811,17 +1876,17 @@ function useEmbeddedWallet(options) {
|
|
|
1811
1876
|
backupPending: computed15(() => toValue18(options.backupPending)),
|
|
1812
1877
|
storageSecurityLevel: computed15(() => toValue18(options.storageSecurityLevel)),
|
|
1813
1878
|
securityReport: computed15(() => toValue18(options.securityReport)),
|
|
1814
|
-
connectEmbedded: () => run(() =>
|
|
1815
|
-
restoreWallet: () => run(() =>
|
|
1816
|
-
generateWallet: () => run(() =>
|
|
1817
|
-
importFromMnemonic: (value) => run(() =>
|
|
1818
|
-
importFromPrivateKey: (value) => run(() =>
|
|
1819
|
-
wipe: () => run(() =>
|
|
1820
|
-
setActiveNamespace: (value) =>
|
|
1821
|
-
backfillAccounts: () => run(() =>
|
|
1822
|
-
getSeedPhrase: () =>
|
|
1823
|
-
getPrivateKey: () =>
|
|
1824
|
-
confirmBackup: () =>
|
|
1879
|
+
connectEmbedded: () => run(() => unref19(options.connectEmbedded)()),
|
|
1880
|
+
restoreWallet: () => run(() => unref19(options.restoreWallet)()),
|
|
1881
|
+
generateWallet: () => run(() => unref19(options.generateWallet)()),
|
|
1882
|
+
importFromMnemonic: (value) => run(() => unref19(options.importFromMnemonic)(value)),
|
|
1883
|
+
importFromPrivateKey: (value) => run(() => unref19(options.importFromPrivateKey)(value)),
|
|
1884
|
+
wipe: () => run(() => unref19(options.wipe)()),
|
|
1885
|
+
setActiveNamespace: (value) => unref19(options.setActiveNamespace)(value),
|
|
1886
|
+
backfillAccounts: () => run(() => unref19(options.backfillAccounts)()),
|
|
1887
|
+
getSeedPhrase: () => unref19(options.getSeedPhrase)(),
|
|
1888
|
+
getPrivateKey: () => unref19(options.getPrivateKey)(),
|
|
1889
|
+
confirmBackup: () => unref19(options.confirmBackup)(),
|
|
1825
1890
|
isBusy: guard.busy,
|
|
1826
1891
|
error: guard.error,
|
|
1827
1892
|
clearError: guard.clearError
|
|
@@ -1840,7 +1905,7 @@ function useSIWxLogin(action) {
|
|
|
1840
1905
|
}
|
|
1841
1906
|
|
|
1842
1907
|
// src/useSIWxSession.ts
|
|
1843
|
-
import { computed as computed16, toValue as toValue19, unref as
|
|
1908
|
+
import { computed as computed16, toValue as toValue19, unref as unref20 } from "vue";
|
|
1844
1909
|
function useSIWxSession(options) {
|
|
1845
1910
|
const guard = useActionGuard();
|
|
1846
1911
|
return {
|
|
@@ -1852,25 +1917,25 @@ function useSIWxSession(options) {
|
|
|
1852
1917
|
isSigningIn: guard.busy,
|
|
1853
1918
|
isExpired: computed16(() => toValue19(options.isExpired)),
|
|
1854
1919
|
timeUntilExpiry: computed16(() => toValue19(options.timeUntilExpiry)),
|
|
1855
|
-
signIn: (input) => guard.run(() =>
|
|
1920
|
+
signIn: (input) => guard.run(() => unref20(options.signIn)(input), "SIWX sign-in failed"),
|
|
1856
1921
|
signOut: async () => {
|
|
1857
|
-
await
|
|
1922
|
+
await unref20(options.signOut)();
|
|
1858
1923
|
guard.clearError();
|
|
1859
1924
|
},
|
|
1860
|
-
refresh: () => guard.run(() =>
|
|
1925
|
+
refresh: () => guard.run(() => unref20(options.refresh)(), "Session refresh failed"),
|
|
1861
1926
|
error: guard.error,
|
|
1862
1927
|
clearError: guard.clearError
|
|
1863
1928
|
};
|
|
1864
1929
|
}
|
|
1865
1930
|
|
|
1866
1931
|
// src/useSiwxAuthSession.ts
|
|
1867
|
-
import { computed as computed17, toValue as toValue20, unref as
|
|
1932
|
+
import { computed as computed17, toValue as toValue20, unref as unref21 } from "vue";
|
|
1868
1933
|
function useSiwxAuthSession(options) {
|
|
1869
1934
|
const guard = useActionGuard();
|
|
1870
|
-
const signIn = (input) => guard.run(() =>
|
|
1935
|
+
const signIn = (input) => guard.run(() => unref21(options.signIn)(input), "SIWX sign-in failed");
|
|
1871
1936
|
const signOut = async () => {
|
|
1872
1937
|
guard.reset();
|
|
1873
|
-
await
|
|
1938
|
+
await unref21(options.signOut)();
|
|
1874
1939
|
guard.clearError();
|
|
1875
1940
|
};
|
|
1876
1941
|
const siwxResult = computed17(() => toValue20(options.result));
|
|
@@ -1889,11 +1954,11 @@ function useSiwxAuthSession(options) {
|
|
|
1889
1954
|
// src/useBalance.ts
|
|
1890
1955
|
import { bareEvmAddress as bareEvmAddress5 } from "@naculus/connect-appkit-core";
|
|
1891
1956
|
import { formatUnits as formatUnits2 } from "@naculus/connect-core";
|
|
1892
|
-
import { computed as computed18, onScopeDispose as
|
|
1957
|
+
import { computed as computed18, onScopeDispose as onScopeDispose13, shallowRef as shallowRef18, toValue as toValue21, watch as watch9 } from "vue";
|
|
1893
1958
|
function useBalance(account, client, options = {}) {
|
|
1894
1959
|
const guard = useActionGuard();
|
|
1895
|
-
const balance =
|
|
1896
|
-
const isFetching =
|
|
1960
|
+
const balance = shallowRef18(null);
|
|
1961
|
+
const isFetching = shallowRef18(false);
|
|
1897
1962
|
let timer = null;
|
|
1898
1963
|
const refetch = async () => {
|
|
1899
1964
|
const reader = toValue21(client);
|
|
@@ -1933,7 +1998,7 @@ function useBalance(account, client, options = {}) {
|
|
|
1933
1998
|
if (timer) clearInterval(timer);
|
|
1934
1999
|
timer = null;
|
|
1935
2000
|
};
|
|
1936
|
-
|
|
2001
|
+
watch9(
|
|
1937
2002
|
[
|
|
1938
2003
|
() => toValue21(account),
|
|
1939
2004
|
() => toValue21(client),
|
|
@@ -1946,7 +2011,7 @@ function useBalance(account, client, options = {}) {
|
|
|
1946
2011
|
},
|
|
1947
2012
|
{ immediate: true }
|
|
1948
2013
|
);
|
|
1949
|
-
|
|
2014
|
+
onScopeDispose13(stopTimer);
|
|
1950
2015
|
return {
|
|
1951
2016
|
balance,
|
|
1952
2017
|
formatted: computed18(
|
|
@@ -1963,11 +2028,11 @@ function useBalance(account, client, options = {}) {
|
|
|
1963
2028
|
import {
|
|
1964
2029
|
isQuotableInput
|
|
1965
2030
|
} from "@naculus/connect-appkit-core";
|
|
1966
|
-
import { onScopeDispose as
|
|
2031
|
+
import { onScopeDispose as onScopeDispose14, shallowRef as shallowRef19, toValue as toValue22, unref as unref22, watch as watch10 } from "vue";
|
|
1967
2032
|
function useRouteQuote(input, getQuotes, options = {}) {
|
|
1968
2033
|
const guard = useActionGuard();
|
|
1969
|
-
const quotes =
|
|
1970
|
-
const loading =
|
|
2034
|
+
const quotes = shallowRef19([]);
|
|
2035
|
+
const loading = shallowRef19(false);
|
|
1971
2036
|
let timer = null;
|
|
1972
2037
|
const clearTimer = () => {
|
|
1973
2038
|
if (timer) clearTimeout(timer);
|
|
@@ -1980,7 +2045,7 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
1980
2045
|
quotes.value = [];
|
|
1981
2046
|
return null;
|
|
1982
2047
|
}
|
|
1983
|
-
const fn =
|
|
2048
|
+
const fn = unref22(getQuotes);
|
|
1984
2049
|
if (!fn) {
|
|
1985
2050
|
guard.invalidate();
|
|
1986
2051
|
loading.value = false;
|
|
@@ -2024,14 +2089,14 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
2024
2089
|
).catch(() => {
|
|
2025
2090
|
});
|
|
2026
2091
|
};
|
|
2027
|
-
|
|
2092
|
+
watch10(
|
|
2028
2093
|
[
|
|
2029
2094
|
() => toValue22(input).fromChain,
|
|
2030
2095
|
() => toValue22(input).toChain,
|
|
2031
2096
|
() => toValue22(input).fromToken,
|
|
2032
2097
|
() => toValue22(input).toToken,
|
|
2033
2098
|
() => toValue22(input).amount,
|
|
2034
|
-
() =>
|
|
2099
|
+
() => unref22(getQuotes)
|
|
2035
2100
|
],
|
|
2036
2101
|
() => {
|
|
2037
2102
|
clearTimer();
|
|
@@ -2044,7 +2109,7 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
2044
2109
|
},
|
|
2045
2110
|
{ immediate: true }
|
|
2046
2111
|
);
|
|
2047
|
-
|
|
2112
|
+
onScopeDispose14(clearTimer);
|
|
2048
2113
|
return {
|
|
2049
2114
|
quotes,
|
|
2050
2115
|
loading,
|
|
@@ -2063,14 +2128,14 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
2063
2128
|
import {
|
|
2064
2129
|
compareCostsKey
|
|
2065
2130
|
} from "@naculus/connect-appkit-core";
|
|
2066
|
-
import { shallowRef as
|
|
2131
|
+
import { shallowRef as shallowRef20, toValue as toValue23, unref as unref23, watch as watch11 } from "vue";
|
|
2067
2132
|
function useCompareCosts(input, compareCosts) {
|
|
2068
2133
|
const guard = useActionGuard();
|
|
2069
|
-
const comparisons =
|
|
2070
|
-
const loading =
|
|
2134
|
+
const comparisons = shallowRef20([]);
|
|
2135
|
+
const loading = shallowRef20(false);
|
|
2071
2136
|
const fetchComparisons = async () => {
|
|
2072
2137
|
const { operation, chains, options } = toValue23(input);
|
|
2073
|
-
const fn =
|
|
2138
|
+
const fn = unref23(compareCosts);
|
|
2074
2139
|
if (!chains || chains.length === 0) {
|
|
2075
2140
|
guard.invalidate();
|
|
2076
2141
|
loading.value = false;
|
|
@@ -2107,8 +2172,8 @@ function useCompareCosts(input, compareCosts) {
|
|
|
2107
2172
|
).catch(() => {
|
|
2108
2173
|
});
|
|
2109
2174
|
};
|
|
2110
|
-
|
|
2111
|
-
[() => compareCostsKey(toValue23(input)), () =>
|
|
2175
|
+
watch11(
|
|
2176
|
+
[() => compareCostsKey(toValue23(input)), () => unref23(compareCosts)],
|
|
2112
2177
|
() => {
|
|
2113
2178
|
void fetchComparisons();
|
|
2114
2179
|
},
|
|
@@ -2127,15 +2192,15 @@ import {
|
|
|
2127
2192
|
toExecuteRouteError,
|
|
2128
2193
|
validateRouteRecipient
|
|
2129
2194
|
} from "@naculus/connect-appkit-core";
|
|
2130
|
-
import { onScopeDispose as
|
|
2195
|
+
import { onScopeDispose as onScopeDispose15, shallowRef as shallowRef21, unref as unref24 } from "vue";
|
|
2131
2196
|
function useExecuteRoute(executeRoute) {
|
|
2132
|
-
const executing =
|
|
2133
|
-
const result =
|
|
2134
|
-
const error =
|
|
2197
|
+
const executing = shallowRef21(false);
|
|
2198
|
+
const result = shallowRef21(null);
|
|
2199
|
+
const error = shallowRef21(null);
|
|
2135
2200
|
let inFlight = false;
|
|
2136
2201
|
let disposed = false;
|
|
2137
2202
|
const execute = async (quote, recipient, options) => {
|
|
2138
|
-
const fn =
|
|
2203
|
+
const fn = unref24(executeRoute);
|
|
2139
2204
|
if (!fn) {
|
|
2140
2205
|
error.value = {
|
|
2141
2206
|
code: "no_executor",
|
|
@@ -2173,7 +2238,7 @@ function useExecuteRoute(executeRoute) {
|
|
|
2173
2238
|
if (!disposed) executing.value = false;
|
|
2174
2239
|
}
|
|
2175
2240
|
};
|
|
2176
|
-
|
|
2241
|
+
onScopeDispose15(() => {
|
|
2177
2242
|
disposed = true;
|
|
2178
2243
|
});
|
|
2179
2244
|
return {
|
|
@@ -2194,15 +2259,15 @@ import { eip155ChainIdToNumber } from "@naculus/connect-appkit-core";
|
|
|
2194
2259
|
import {
|
|
2195
2260
|
TokenListManager
|
|
2196
2261
|
} from "@naculus/connect-core";
|
|
2197
|
-
import { shallowRef as
|
|
2262
|
+
import { shallowRef as shallowRef22, toValue as toValue24, watch as watch12 } from "vue";
|
|
2198
2263
|
function useTokenList(chainId, options = {}) {
|
|
2199
2264
|
const config = {};
|
|
2200
2265
|
if (options.sources) config.sources = options.sources;
|
|
2201
2266
|
const manager = options.manager ?? new TokenListManager(config);
|
|
2202
2267
|
const guard = useActionGuard();
|
|
2203
|
-
const tokens =
|
|
2204
|
-
const isLoading =
|
|
2205
|
-
const isLoaded =
|
|
2268
|
+
const tokens = shallowRef22([]);
|
|
2269
|
+
const isLoading = shallowRef22(options.autoLoad !== false);
|
|
2270
|
+
const isLoaded = shallowRef22(false);
|
|
2206
2271
|
const select = () => {
|
|
2207
2272
|
const id = toValue24(chainId);
|
|
2208
2273
|
const numeric = id ? eip155ChainIdToNumber(id) : void 0;
|
|
@@ -2230,7 +2295,7 @@ function useTokenList(chainId, options = {}) {
|
|
|
2230
2295
|
).catch(() => {
|
|
2231
2296
|
});
|
|
2232
2297
|
};
|
|
2233
|
-
|
|
2298
|
+
watch12(
|
|
2234
2299
|
() => toValue24(chainId),
|
|
2235
2300
|
() => {
|
|
2236
2301
|
if (options.autoLoad !== false) void run(() => manager.load());
|
|
@@ -2251,7 +2316,7 @@ import { eip155ChainIdToNumber as eip155ChainIdToNumber2 } from "@naculus/connec
|
|
|
2251
2316
|
import {
|
|
2252
2317
|
TokenListManager as TokenListManager2
|
|
2253
2318
|
} from "@naculus/connect-core";
|
|
2254
|
-
import { onScopeDispose as
|
|
2319
|
+
import { onScopeDispose as onScopeDispose16, shallowRef as shallowRef23, toValue as toValue25, watch as watch13 } from "vue";
|
|
2255
2320
|
var DEBOUNCE_MS = 300;
|
|
2256
2321
|
var EMPTY = { exact: [], fuzzy: [], hasMore: false };
|
|
2257
2322
|
var sharedManager = null;
|
|
@@ -2264,14 +2329,14 @@ function getSharedManager() {
|
|
|
2264
2329
|
return sharedManager;
|
|
2265
2330
|
}
|
|
2266
2331
|
function useTokenSearch(query, chainId, options = {}) {
|
|
2267
|
-
const results =
|
|
2268
|
-
const isSearching =
|
|
2332
|
+
const results = shallowRef23(EMPTY);
|
|
2333
|
+
const isSearching = shallowRef23(false);
|
|
2269
2334
|
let timer = null;
|
|
2270
2335
|
const clear = () => {
|
|
2271
2336
|
if (timer) clearTimeout(timer);
|
|
2272
2337
|
timer = null;
|
|
2273
2338
|
};
|
|
2274
|
-
|
|
2339
|
+
watch13(
|
|
2275
2340
|
[() => (toValue25(query) ?? "").trim(), () => toValue25(chainId)],
|
|
2276
2341
|
([q, id]) => {
|
|
2277
2342
|
clear();
|
|
@@ -2294,7 +2359,7 @@ function useTokenSearch(query, chainId, options = {}) {
|
|
|
2294
2359
|
},
|
|
2295
2360
|
{ immediate: true }
|
|
2296
2361
|
);
|
|
2297
|
-
|
|
2362
|
+
onScopeDispose16(clear);
|
|
2298
2363
|
return { results, isSearching };
|
|
2299
2364
|
}
|
|
2300
2365
|
|
|
@@ -2312,14 +2377,14 @@ function useValidateDestination(address) {
|
|
|
2312
2377
|
// src/useTokenBalance.ts
|
|
2313
2378
|
import { bareEvmAddress as bareEvmAddress6 } from "@naculus/connect-appkit-core";
|
|
2314
2379
|
import { ERC20_MIN_ABI as ERC20_MIN_ABI3, formatUnits as formatUnits3 } from "@naculus/connect-core";
|
|
2315
|
-
import { onScopeDispose as
|
|
2380
|
+
import { onScopeDispose as onScopeDispose17, shallowRef as shallowRef24, toValue as toValue27, watch as watch14 } from "vue";
|
|
2316
2381
|
function tokensKey(tokens) {
|
|
2317
2382
|
return tokens.map((t) => `${t.address.toLowerCase()}|${t.decimals}|${t.symbol}`).join(",");
|
|
2318
2383
|
}
|
|
2319
2384
|
function useTokenBalance(account, client, tokens, options = {}) {
|
|
2320
2385
|
const guard = useActionGuard();
|
|
2321
|
-
const tokenBalances =
|
|
2322
|
-
const isFetching =
|
|
2386
|
+
const tokenBalances = shallowRef24([]);
|
|
2387
|
+
const isFetching = shallowRef24(false);
|
|
2323
2388
|
let timer = null;
|
|
2324
2389
|
const refetch = async () => {
|
|
2325
2390
|
const reader = toValue27(client);
|
|
@@ -2379,7 +2444,7 @@ function useTokenBalance(account, client, tokens, options = {}) {
|
|
|
2379
2444
|
if (timer) clearInterval(timer);
|
|
2380
2445
|
timer = null;
|
|
2381
2446
|
};
|
|
2382
|
-
|
|
2447
|
+
watch14(
|
|
2383
2448
|
[
|
|
2384
2449
|
() => toValue27(account),
|
|
2385
2450
|
() => toValue27(client),
|
|
@@ -2393,7 +2458,7 @@ function useTokenBalance(account, client, tokens, options = {}) {
|
|
|
2393
2458
|
},
|
|
2394
2459
|
{ immediate: true }
|
|
2395
2460
|
);
|
|
2396
|
-
|
|
2461
|
+
onScopeDispose17(stopTimer);
|
|
2397
2462
|
return {
|
|
2398
2463
|
tokenBalances,
|
|
2399
2464
|
isFetching,
|
|
@@ -2413,11 +2478,11 @@ import {
|
|
|
2413
2478
|
REVOKE_DELEGATE,
|
|
2414
2479
|
WalletError as WalletError7
|
|
2415
2480
|
} from "@naculus/connect-core";
|
|
2416
|
-
import { onScopeDispose as
|
|
2481
|
+
import { onScopeDispose as onScopeDispose18, shallowRef as shallowRef25, toValue as toValue28, watch as watch15 } from "vue";
|
|
2417
2482
|
function useDelegate(options) {
|
|
2418
|
-
const result =
|
|
2419
|
-
const isPending =
|
|
2420
|
-
const error =
|
|
2483
|
+
const result = shallowRef25(null);
|
|
2484
|
+
const isPending = shallowRef25(false);
|
|
2485
|
+
const error = shallowRef25(null);
|
|
2421
2486
|
let requestId = 0;
|
|
2422
2487
|
let inFlight = false;
|
|
2423
2488
|
let disposed = false;
|
|
@@ -2479,7 +2544,7 @@ function useDelegate(options) {
|
|
|
2479
2544
|
isPending.value = false;
|
|
2480
2545
|
error.value = null;
|
|
2481
2546
|
};
|
|
2482
|
-
|
|
2547
|
+
watch15(
|
|
2483
2548
|
[
|
|
2484
2549
|
() => toValue28(options.session),
|
|
2485
2550
|
() => toValue28(options.account),
|
|
@@ -2488,7 +2553,7 @@ function useDelegate(options) {
|
|
|
2488
2553
|
reset,
|
|
2489
2554
|
{ flush: "sync" }
|
|
2490
2555
|
);
|
|
2491
|
-
|
|
2556
|
+
onScopeDispose18(() => {
|
|
2492
2557
|
disposed = true;
|
|
2493
2558
|
requestId++;
|
|
2494
2559
|
});
|
|
@@ -2508,11 +2573,11 @@ import {
|
|
|
2508
2573
|
readDelegation,
|
|
2509
2574
|
UNKNOWN_DELEGATION
|
|
2510
2575
|
} from "@naculus/connect-core";
|
|
2511
|
-
import { computed as computed20, shallowRef as
|
|
2576
|
+
import { computed as computed20, shallowRef as shallowRef26, toValue as toValue29, watch as watch16 } from "vue";
|
|
2512
2577
|
function useDelegation(account, client, chainId) {
|
|
2513
2578
|
const guard = useActionGuard();
|
|
2514
|
-
const status =
|
|
2515
|
-
const isFetching =
|
|
2579
|
+
const status = shallowRef26(UNKNOWN_DELEGATION);
|
|
2580
|
+
const isFetching = shallowRef26(false);
|
|
2516
2581
|
const refetch = async () => {
|
|
2517
2582
|
const reader = toValue29(client);
|
|
2518
2583
|
const address = bareEvmAddress8(toValue29(account));
|
|
@@ -2547,7 +2612,7 @@ function useDelegation(account, client, chainId) {
|
|
|
2547
2612
|
).catch(() => {
|
|
2548
2613
|
});
|
|
2549
2614
|
};
|
|
2550
|
-
|
|
2615
|
+
watch16(
|
|
2551
2616
|
[() => toValue29(account), () => toValue29(client), () => toValue29(chainId)],
|
|
2552
2617
|
() => {
|
|
2553
2618
|
void refetch();
|
|
@@ -2565,23 +2630,65 @@ function useDelegation(account, client, chainId) {
|
|
|
2565
2630
|
|
|
2566
2631
|
// src/usePaymentFetch.ts
|
|
2567
2632
|
import {
|
|
2633
|
+
applySettlementVerification,
|
|
2634
|
+
DEFAULT_VERIFY_RETRY,
|
|
2568
2635
|
describePayment
|
|
2569
2636
|
} from "@naculus/connect-appkit-core";
|
|
2570
|
-
import { onScopeDispose as
|
|
2571
|
-
function usePaymentFetch(pay) {
|
|
2637
|
+
import { onScopeDispose as onScopeDispose19, shallowRef as shallowRef27, unref as unref25 } from "vue";
|
|
2638
|
+
function usePaymentFetch(pay, options = {}) {
|
|
2572
2639
|
const guard = useActionGuard();
|
|
2573
|
-
const lastPayment =
|
|
2640
|
+
const lastPayment = shallowRef27(null);
|
|
2574
2641
|
let epoch = 0;
|
|
2575
|
-
|
|
2642
|
+
let verification = 0;
|
|
2643
|
+
onScopeDispose19(() => {
|
|
2576
2644
|
epoch++;
|
|
2645
|
+
verification++;
|
|
2577
2646
|
});
|
|
2578
2647
|
const payFetch = (input, init) => {
|
|
2579
|
-
const invoke =
|
|
2648
|
+
const invoke = unref25(pay);
|
|
2580
2649
|
const own = epoch;
|
|
2581
2650
|
return guard.run(async () => {
|
|
2582
2651
|
const result = await invoke(input, init);
|
|
2583
|
-
|
|
2584
|
-
if (payment && own === epoch)
|
|
2652
|
+
let payment = describePayment(input, result);
|
|
2653
|
+
if (payment && own === epoch) {
|
|
2654
|
+
const verify = options.verify;
|
|
2655
|
+
if (!verify) {
|
|
2656
|
+
lastPayment.value = payment;
|
|
2657
|
+
} else {
|
|
2658
|
+
payment = applySettlementVerification(payment, { status: "pending" });
|
|
2659
|
+
lastPayment.value = payment;
|
|
2660
|
+
const verificationOwn = ++verification;
|
|
2661
|
+
const retry = options.verifyRetry ?? DEFAULT_VERIFY_RETRY;
|
|
2662
|
+
void Promise.resolve().then(async () => {
|
|
2663
|
+
let outcome = { status: "pending" };
|
|
2664
|
+
for (let attempt = 0; attempt < retry.attempts; attempt += 1) {
|
|
2665
|
+
if (attempt > 0) {
|
|
2666
|
+
await new Promise(
|
|
2667
|
+
(resolve) => setTimeout(resolve, retry.delayMs)
|
|
2668
|
+
);
|
|
2669
|
+
}
|
|
2670
|
+
if (own !== epoch || verificationOwn !== verification) return;
|
|
2671
|
+
try {
|
|
2672
|
+
outcome = await verify(result);
|
|
2673
|
+
} catch (cause) {
|
|
2674
|
+
outcome = {
|
|
2675
|
+
status: "unavailable",
|
|
2676
|
+
reason: cause instanceof Error ? cause.message : "Settlement verification failed"
|
|
2677
|
+
};
|
|
2678
|
+
}
|
|
2679
|
+
if (outcome.status !== "pending") break;
|
|
2680
|
+
}
|
|
2681
|
+
if (own === epoch && verificationOwn === verification) {
|
|
2682
|
+
const current = lastPayment.value;
|
|
2683
|
+
if (current)
|
|
2684
|
+
lastPayment.value = applySettlementVerification(
|
|
2685
|
+
current,
|
|
2686
|
+
outcome
|
|
2687
|
+
);
|
|
2688
|
+
}
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
}
|
|
2585
2692
|
return result;
|
|
2586
2693
|
}, "Paid request failed");
|
|
2587
2694
|
};
|
|
@@ -2592,24 +2699,156 @@ function usePaymentFetch(pay) {
|
|
|
2592
2699
|
error: guard.error,
|
|
2593
2700
|
reset: () => {
|
|
2594
2701
|
epoch++;
|
|
2702
|
+
verification++;
|
|
2595
2703
|
guard.reset();
|
|
2596
2704
|
lastPayment.value = null;
|
|
2597
2705
|
}
|
|
2598
2706
|
};
|
|
2599
2707
|
}
|
|
2600
2708
|
|
|
2709
|
+
// src/useMppSession.ts
|
|
2710
|
+
import {
|
|
2711
|
+
readCurrentMppSessionChannel,
|
|
2712
|
+
readMppRecoveryChannelId,
|
|
2713
|
+
readMppSessionReceipt
|
|
2714
|
+
} from "@naculus/connect-appkit-core";
|
|
2715
|
+
import { onScopeDispose as onScopeDispose20, shallowRef as shallowRef28, unref as unref26, watch as watch17 } from "vue";
|
|
2716
|
+
function useMppSession(session) {
|
|
2717
|
+
const current = () => unref26(session);
|
|
2718
|
+
const pending = shallowRef28(current().meter.pending);
|
|
2719
|
+
const channel = shallowRef28(
|
|
2720
|
+
readCurrentMppSessionChannel(current())
|
|
2721
|
+
);
|
|
2722
|
+
const lastReceipt = shallowRef28(null);
|
|
2723
|
+
const recoveryChannelId = shallowRef28(null);
|
|
2724
|
+
const isPending = shallowRef28(false);
|
|
2725
|
+
const error = shallowRef28(null);
|
|
2726
|
+
let active = 0;
|
|
2727
|
+
let generation = 0;
|
|
2728
|
+
let epoch = 0;
|
|
2729
|
+
let disposed = false;
|
|
2730
|
+
watch17(
|
|
2731
|
+
() => unref26(session),
|
|
2732
|
+
(value) => {
|
|
2733
|
+
generation++;
|
|
2734
|
+
epoch++;
|
|
2735
|
+
active = 0;
|
|
2736
|
+
isPending.value = false;
|
|
2737
|
+
pending.value = value.meter.pending;
|
|
2738
|
+
channel.value = readCurrentMppSessionChannel(value);
|
|
2739
|
+
lastReceipt.value = null;
|
|
2740
|
+
recoveryChannelId.value = null;
|
|
2741
|
+
error.value = null;
|
|
2742
|
+
},
|
|
2743
|
+
{ flush: "sync" }
|
|
2744
|
+
);
|
|
2745
|
+
onScopeDispose20(() => {
|
|
2746
|
+
disposed = true;
|
|
2747
|
+
generation++;
|
|
2748
|
+
epoch++;
|
|
2749
|
+
});
|
|
2750
|
+
const run = (operation, publish, clearsRecovery = false) => {
|
|
2751
|
+
const own = ++generation;
|
|
2752
|
+
const ownEpoch = epoch;
|
|
2753
|
+
const invokedSession = current();
|
|
2754
|
+
active++;
|
|
2755
|
+
isPending.value = true;
|
|
2756
|
+
error.value = null;
|
|
2757
|
+
return operation(invokedSession).then((result) => {
|
|
2758
|
+
if (!disposed && ownEpoch === epoch) {
|
|
2759
|
+
publish?.(result);
|
|
2760
|
+
const currentChannel = readCurrentMppSessionChannel(invokedSession);
|
|
2761
|
+
channel.value = currentChannel;
|
|
2762
|
+
pending.value = invokedSession.meter.pending;
|
|
2763
|
+
if (clearsRecovery || !currentChannel) {
|
|
2764
|
+
recoveryChannelId.value = null;
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
return result;
|
|
2768
|
+
}).catch((cause) => {
|
|
2769
|
+
const normalized = cause instanceof Error ? cause : new Error("MPP session operation failed");
|
|
2770
|
+
if (!disposed && ownEpoch === epoch) {
|
|
2771
|
+
const currentChannel = readCurrentMppSessionChannel(invokedSession);
|
|
2772
|
+
channel.value = currentChannel;
|
|
2773
|
+
pending.value = invokedSession.meter.pending;
|
|
2774
|
+
const recovery = readMppRecoveryChannelId(cause);
|
|
2775
|
+
if (recovery) recoveryChannelId.value = recovery;
|
|
2776
|
+
else if (!currentChannel) recoveryChannelId.value = null;
|
|
2777
|
+
if (own === generation) error.value = normalized;
|
|
2778
|
+
}
|
|
2779
|
+
throw normalized;
|
|
2780
|
+
}).finally(() => {
|
|
2781
|
+
if (ownEpoch === epoch) {
|
|
2782
|
+
active--;
|
|
2783
|
+
if (!disposed) isPending.value = active > 0;
|
|
2784
|
+
}
|
|
2785
|
+
});
|
|
2786
|
+
};
|
|
2787
|
+
const fetch = (input, init) => run(
|
|
2788
|
+
(value) => value(input, init),
|
|
2789
|
+
(result) => {
|
|
2790
|
+
const receipt = readMppSessionReceipt(result.receipt);
|
|
2791
|
+
if (receipt) lastReceipt.value = receipt;
|
|
2792
|
+
}
|
|
2793
|
+
);
|
|
2794
|
+
const close = () => run(
|
|
2795
|
+
(value) => value.close(),
|
|
2796
|
+
(result) => {
|
|
2797
|
+
const receipt = readMppSessionReceipt(result.receipt);
|
|
2798
|
+
if (receipt) lastReceipt.value = receipt;
|
|
2799
|
+
},
|
|
2800
|
+
true
|
|
2801
|
+
);
|
|
2802
|
+
const forceClose = () => run((value) => value.forceClose(), void 0, true);
|
|
2803
|
+
const add = (units) => {
|
|
2804
|
+
try {
|
|
2805
|
+
current().meter.add(units);
|
|
2806
|
+
pending.value = current().meter.pending;
|
|
2807
|
+
error.value = null;
|
|
2808
|
+
} catch (cause) {
|
|
2809
|
+
const normalized = cause instanceof Error ? cause : new Error("MPP session operation failed");
|
|
2810
|
+
error.value = normalized;
|
|
2811
|
+
recoveryChannelId.value = readMppRecoveryChannelId(cause);
|
|
2812
|
+
throw normalized;
|
|
2813
|
+
}
|
|
2814
|
+
};
|
|
2815
|
+
return {
|
|
2816
|
+
fetch,
|
|
2817
|
+
meter: { add },
|
|
2818
|
+
pending,
|
|
2819
|
+
channel,
|
|
2820
|
+
lastReceipt,
|
|
2821
|
+
recoveryChannelId,
|
|
2822
|
+
isPending,
|
|
2823
|
+
error,
|
|
2824
|
+
close,
|
|
2825
|
+
forceClose,
|
|
2826
|
+
reset: () => {
|
|
2827
|
+
generation++;
|
|
2828
|
+
epoch++;
|
|
2829
|
+
active = 0;
|
|
2830
|
+
isPending.value = false;
|
|
2831
|
+
pending.value = current().meter.pending;
|
|
2832
|
+
channel.value = readCurrentMppSessionChannel(current());
|
|
2833
|
+
lastReceipt.value = null;
|
|
2834
|
+
recoveryChannelId.value = null;
|
|
2835
|
+
error.value = null;
|
|
2836
|
+
}
|
|
2837
|
+
};
|
|
2838
|
+
}
|
|
2839
|
+
|
|
2601
2840
|
// src/useSolanaSessionKey.ts
|
|
2602
2841
|
import {
|
|
2603
2842
|
createSolanaSessionKeyFlow
|
|
2604
2843
|
} from "@naculus/connect-appkit-core";
|
|
2605
|
-
import { onScopeDispose as
|
|
2844
|
+
import { onScopeDispose as onScopeDispose21, shallowRef as shallowRef29, unref as unref27, watch as watch18 } from "vue";
|
|
2606
2845
|
function useSolanaSessionKey(deps) {
|
|
2607
2846
|
const guard = useActionGuard();
|
|
2608
|
-
const keys =
|
|
2847
|
+
const keys = shallowRef29([]);
|
|
2609
2848
|
let flow = null;
|
|
2610
2849
|
let generation = 0;
|
|
2611
2850
|
let disposed = false;
|
|
2612
|
-
|
|
2851
|
+
onScopeDispose21(() => {
|
|
2613
2852
|
disposed = true;
|
|
2614
2853
|
});
|
|
2615
2854
|
const refresh = async () => {
|
|
@@ -2617,8 +2856,8 @@ function useSolanaSessionKey(deps) {
|
|
|
2617
2856
|
const next = flow ? await flow.list() : [];
|
|
2618
2857
|
if (!disposed && own === generation) keys.value = next;
|
|
2619
2858
|
};
|
|
2620
|
-
|
|
2621
|
-
() =>
|
|
2859
|
+
watch18(
|
|
2860
|
+
() => unref27(deps),
|
|
2622
2861
|
(next) => {
|
|
2623
2862
|
flow = next ? createSolanaSessionKeyFlow(next) : null;
|
|
2624
2863
|
guard.invalidate();
|
|
@@ -2652,11 +2891,11 @@ function useSolanaSessionKey(deps) {
|
|
|
2652
2891
|
|
|
2653
2892
|
// src/name-lookup.ts
|
|
2654
2893
|
import { getResolver } from "@naculus/connect-appkit-core";
|
|
2655
|
-
import { computed as computed21, shallowRef as
|
|
2894
|
+
import { computed as computed21, shallowRef as shallowRef30, toValue as toValue30, watch as watch19 } from "vue";
|
|
2656
2895
|
function useNameLookup(options) {
|
|
2657
2896
|
const guard = useActionGuard();
|
|
2658
|
-
const data =
|
|
2659
|
-
const loading =
|
|
2897
|
+
const data = shallowRef30(null);
|
|
2898
|
+
const loading = shallowRef30(false);
|
|
2660
2899
|
const run = () => {
|
|
2661
2900
|
const input = toValue30(options.input).trim();
|
|
2662
2901
|
const skip = toValue30(options.skip) ?? false;
|
|
@@ -2696,7 +2935,7 @@ function useNameLookup(options) {
|
|
|
2696
2935
|
).catch(() => {
|
|
2697
2936
|
});
|
|
2698
2937
|
};
|
|
2699
|
-
|
|
2938
|
+
watch19(
|
|
2700
2939
|
() => [
|
|
2701
2940
|
toValue30(options.input),
|
|
2702
2941
|
toValue30(options.skip),
|
|
@@ -2784,13 +3023,13 @@ function useChain(chains, chainId) {
|
|
|
2784
3023
|
}
|
|
2785
3024
|
|
|
2786
3025
|
// src/usePassphraseGate.ts
|
|
2787
|
-
import { onScopeDispose as
|
|
3026
|
+
import { onScopeDispose as onScopeDispose22, readonly, shallowRef as shallowRef31 } from "vue";
|
|
2788
3027
|
function usePassphraseGate(gate) {
|
|
2789
|
-
const request =
|
|
3028
|
+
const request = shallowRef31(gate.getSnapshot());
|
|
2790
3029
|
const unsubscribe = gate.subscribe(() => {
|
|
2791
3030
|
request.value = gate.getSnapshot();
|
|
2792
3031
|
});
|
|
2793
|
-
|
|
3032
|
+
onScopeDispose22(unsubscribe);
|
|
2794
3033
|
return {
|
|
2795
3034
|
request: readonly(request),
|
|
2796
3035
|
submit: (passphrase) => gate.submit(passphrase),
|
|
@@ -2801,10 +3040,10 @@ function usePassphraseGate(gate) {
|
|
|
2801
3040
|
|
|
2802
3041
|
// src/useSolanaBalance.ts
|
|
2803
3042
|
import { getSolanaBalance } from "@naculus/connect-core";
|
|
2804
|
-
import { ref, shallowRef as
|
|
3043
|
+
import { ref, shallowRef as shallowRef32, toValue as toValue33, watchEffect } from "vue";
|
|
2805
3044
|
function useSolanaBalance(address, rpcUrl) {
|
|
2806
3045
|
const guard = useActionGuard();
|
|
2807
|
-
const balance =
|
|
3046
|
+
const balance = shallowRef32(null);
|
|
2808
3047
|
const isFetching = ref(false);
|
|
2809
3048
|
const refetch = async () => {
|
|
2810
3049
|
const addr = toValue33(address);
|
|
@@ -2849,12 +3088,12 @@ function useSolanaBalance(address, rpcUrl) {
|
|
|
2849
3088
|
}
|
|
2850
3089
|
|
|
2851
3090
|
// src/useLastTx.ts
|
|
2852
|
-
import { shallowRef as
|
|
3091
|
+
import { shallowRef as shallowRef33, toValue as toValue34, watch as watch20 } from "vue";
|
|
2853
3092
|
function useLastTx(monitor) {
|
|
2854
|
-
const lastTx =
|
|
2855
|
-
const lastConfirmedTx =
|
|
2856
|
-
const lastFailedTx =
|
|
2857
|
-
|
|
3093
|
+
const lastTx = shallowRef33(null);
|
|
3094
|
+
const lastConfirmedTx = shallowRef33(null);
|
|
3095
|
+
const lastFailedTx = shallowRef33(null);
|
|
3096
|
+
watch20(
|
|
2858
3097
|
() => toValue34(monitor),
|
|
2859
3098
|
(activeMonitor, _previous, onCleanup) => {
|
|
2860
3099
|
if (!activeMonitor) return;
|
|
@@ -2893,11 +3132,11 @@ function useLastTx(monitor) {
|
|
|
2893
3132
|
}
|
|
2894
3133
|
|
|
2895
3134
|
// src/useTxHistory.ts
|
|
2896
|
-
import { computed as computed24, shallowRef as
|
|
3135
|
+
import { computed as computed24, shallowRef as shallowRef34, toValue as toValue35, watch as watch21 } from "vue";
|
|
2897
3136
|
function useTxHistory(address, chainId, monitor) {
|
|
2898
3137
|
const guard = useActionGuard();
|
|
2899
|
-
const entries =
|
|
2900
|
-
const isLoading =
|
|
3138
|
+
const entries = shallowRef34([]);
|
|
3139
|
+
const isLoading = shallowRef34(false);
|
|
2901
3140
|
const refresh = async () => {
|
|
2902
3141
|
const activeMonitor = toValue35(monitor);
|
|
2903
3142
|
if (!activeMonitor) {
|
|
@@ -2927,7 +3166,7 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
2927
3166
|
).catch(() => {
|
|
2928
3167
|
});
|
|
2929
3168
|
};
|
|
2930
|
-
|
|
3169
|
+
watch21(
|
|
2931
3170
|
[() => toValue35(monitor), () => toValue35(address), () => toValue35(chainId)],
|
|
2932
3171
|
([activeMonitor], _previous, onCleanup) => {
|
|
2933
3172
|
if (!activeMonitor) {
|
|
@@ -2957,11 +3196,11 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
2957
3196
|
}
|
|
2958
3197
|
|
|
2959
3198
|
// src/useTxMonitor.ts
|
|
2960
|
-
import { computed as computed25, shallowRef as
|
|
3199
|
+
import { computed as computed25, shallowRef as shallowRef35, toValue as toValue36, watch as watch22 } from "vue";
|
|
2961
3200
|
function useTxMonitor(hash, chainId, monitor) {
|
|
2962
|
-
const entry =
|
|
2963
|
-
const isLoading =
|
|
2964
|
-
const isWatching =
|
|
3201
|
+
const entry = shallowRef35(null);
|
|
3202
|
+
const isLoading = shallowRef35(false);
|
|
3203
|
+
const isWatching = shallowRef35(false);
|
|
2965
3204
|
const guard = useActionGuard();
|
|
2966
3205
|
const error = guard.error;
|
|
2967
3206
|
let generation = 0;
|
|
@@ -3018,7 +3257,7 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
3018
3257
|
activeMonitor.stopWatching(activeHash, activeChainId ?? void 0);
|
|
3019
3258
|
isWatching.value = false;
|
|
3020
3259
|
};
|
|
3021
|
-
|
|
3260
|
+
watch22(
|
|
3022
3261
|
[() => toValue36(monitor), () => toValue36(hash), () => toValue36(chainId)],
|
|
3023
3262
|
([activeMonitor, activeHash, activeChainId], _previous, onCleanup) => {
|
|
3024
3263
|
const mine = ++generation;
|
|
@@ -3076,13 +3315,13 @@ import {
|
|
|
3076
3315
|
normalizeCapabilities,
|
|
3077
3316
|
selectChainCapabilities
|
|
3078
3317
|
} from "@naculus/connect-appkit-core";
|
|
3079
|
-
import { computed as computed26, shallowRef as
|
|
3318
|
+
import { computed as computed26, shallowRef as shallowRef36, toValue as toValue37, watchEffect as watchEffect2 } from "vue";
|
|
3080
3319
|
function useCapabilities(client, session, chainId) {
|
|
3081
3320
|
const guard = useActionGuard();
|
|
3082
|
-
const capabilities =
|
|
3321
|
+
const capabilities = shallowRef36(
|
|
3083
3322
|
null
|
|
3084
3323
|
);
|
|
3085
|
-
const isFetching =
|
|
3324
|
+
const isFetching = shallowRef36(false);
|
|
3086
3325
|
const refetch = async () => {
|
|
3087
3326
|
const activeClient = toValue37(client);
|
|
3088
3327
|
const activeSession = toValue37(session);
|
|
@@ -3184,6 +3423,7 @@ export {
|
|
|
3184
3423
|
AppkitTooltip,
|
|
3185
3424
|
useAccount,
|
|
3186
3425
|
useAccounts,
|
|
3426
|
+
useAuthorizations,
|
|
3187
3427
|
useBalance,
|
|
3188
3428
|
useCapabilities,
|
|
3189
3429
|
useChain,
|
|
@@ -3202,6 +3442,7 @@ export {
|
|
|
3202
3442
|
useExecuteRoute,
|
|
3203
3443
|
useLastTx,
|
|
3204
3444
|
useLookupAddress,
|
|
3445
|
+
useMppSession,
|
|
3205
3446
|
useNotification,
|
|
3206
3447
|
usePassphraseGate,
|
|
3207
3448
|
usePaymentFetch,
|