@naculus/connect-appkit-vue 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -287,27 +287,506 @@ function useNotification(options = {}) {
287
287
  };
288
288
  }
289
289
 
290
+ // src/useSimulateTransfer.ts
291
+ import { resolveSimulationEndpoint } from "@naculus/connect-appkit-core";
292
+ import {
293
+ SimulationManager
294
+ } from "@naculus/connect-core";
295
+ import { onScopeDispose as onScopeDispose2, shallowRef as shallowRef2, unref as unref2 } from "vue";
296
+ function useSimulateTransfer(options = {}) {
297
+ const result = shallowRef2(null);
298
+ const loading = shallowRef2(false);
299
+ const error = shallowRef2(null);
300
+ let manager;
301
+ let generation = 0;
302
+ let disposed = false;
303
+ const simulate = async (tokenAddress, from, to, amount, callOptions) => {
304
+ const own = ++generation;
305
+ loading.value = true;
306
+ error.value = null;
307
+ try {
308
+ const fallbackRpcUrl = unref2(options.rpcUrl);
309
+ const endpoint = resolveSimulationEndpoint(
310
+ callOptions?.chainId,
311
+ unref2(options.chainId),
312
+ callOptions?.rpcUrl,
313
+ fallbackRpcUrl
314
+ );
315
+ manager ??= new SimulationManager({
316
+ enabled: true,
317
+ rpcUrl: fallbackRpcUrl,
318
+ autoSimulate: false
319
+ });
320
+ const value = await manager.simulateERC20Transfer(
321
+ tokenAddress,
322
+ from,
323
+ to,
324
+ amount,
325
+ endpoint.chainId,
326
+ callOptions?.decimals,
327
+ endpoint.rpcUrl
328
+ );
329
+ if (!disposed && own === generation) result.value = value;
330
+ return value;
331
+ } catch (cause) {
332
+ const normalized = cause instanceof Error ? cause : new Error(String(cause));
333
+ if (!disposed && own === generation) error.value = normalized;
334
+ throw normalized;
335
+ } finally {
336
+ if (!disposed && own === generation) loading.value = false;
337
+ }
338
+ };
339
+ const reset = () => {
340
+ generation++;
341
+ result.value = null;
342
+ error.value = null;
343
+ loading.value = false;
344
+ };
345
+ onScopeDispose2(() => {
346
+ disposed = true;
347
+ generation++;
348
+ });
349
+ return { result, loading, error, simulate, reset };
350
+ }
351
+
352
+ // src/useTransactionSimulation.ts
353
+ import {
354
+ simulateTransactionPreview
355
+ } from "@naculus/connect-appkit-core";
356
+ import { onScopeDispose as onScopeDispose3, shallowRef as shallowRef3, toValue as toValue2, unref as unref3, watch } from "vue";
357
+ function useTransactionSimulation(tx, options = {}) {
358
+ const result = shallowRef3(void 0);
359
+ const isSimulating = shallowRef3(false);
360
+ const error = shallowRef3(null);
361
+ let timer;
362
+ let generation = 0;
363
+ let disposed = false;
364
+ const simulate = async () => {
365
+ const own = ++generation;
366
+ const transaction = toValue2(tx);
367
+ if (transaction) {
368
+ isSimulating.value = true;
369
+ error.value = null;
370
+ }
371
+ try {
372
+ const value = await simulateTransactionPreview(transaction, {
373
+ chainId: unref3(options.chainId),
374
+ currentChain: unref3(options.currentChain),
375
+ publicClient: unref3(options.publicClient),
376
+ evmAccount: unref3(options.evmAccount)
377
+ });
378
+ if (!disposed && own === generation) result.value = value;
379
+ return value;
380
+ } catch (cause) {
381
+ const normalized = cause instanceof Error ? cause : new Error("Simulation failed");
382
+ if (!disposed && own === generation) error.value = normalized;
383
+ throw normalized;
384
+ } finally {
385
+ if (transaction && !disposed && own === generation)
386
+ isSimulating.value = false;
387
+ }
388
+ };
389
+ watch(
390
+ [
391
+ () => toValue2(tx),
392
+ () => unref3(options.chainId),
393
+ () => unref3(options.currentChain),
394
+ () => unref3(options.publicClient),
395
+ () => unref3(options.evmAccount)
396
+ ],
397
+ ([transaction]) => {
398
+ generation++;
399
+ if (timer) clearTimeout(timer);
400
+ if (!transaction) return;
401
+ timer = setTimeout(() => {
402
+ timer = void 0;
403
+ void simulate().catch(() => {
404
+ });
405
+ }, 300);
406
+ },
407
+ { immediate: true }
408
+ );
409
+ const reset = () => {
410
+ generation++;
411
+ result.value = void 0;
412
+ error.value = null;
413
+ isSimulating.value = false;
414
+ };
415
+ onScopeDispose3(() => {
416
+ disposed = true;
417
+ generation++;
418
+ if (timer) clearTimeout(timer);
419
+ });
420
+ return { result, isSimulating, error, simulate, reset };
421
+ }
422
+
423
+ // src/useERC20Transfer.ts
424
+ import {
425
+ createDecimalsCache,
426
+ encodeErc20Transfer,
427
+ readDecimals,
428
+ writeDecimals
429
+ } from "@naculus/connect-appkit-core";
430
+ import {
431
+ ERC20_MIN_ABI,
432
+ parseUnits,
433
+ WalletError as WalletError2
434
+ } from "@naculus/connect-core";
435
+ import { onScopeDispose as onScopeDispose4, shallowRef as shallowRef4, toValue as toValue3, unref as unref4, watch as watch2 } from "vue";
436
+
437
+ // src/erc20.ts
438
+ import {
439
+ bareEvmAddress,
440
+ tokenChainMismatch
441
+ } from "@naculus/connect-appkit-core";
442
+ import { WalletError } from "@naculus/connect-core";
443
+ function assertErc20Context(token, chainId, account, connected) {
444
+ if (!connected || !account) {
445
+ throw new WalletError("wallet_unavailable", "No connected account");
446
+ }
447
+ const mismatch = tokenChainMismatch(token, chainId);
448
+ if (mismatch) throw mismatch;
449
+ const bare = bareEvmAddress(account);
450
+ if (!bare) {
451
+ throw new WalletError("wallet_unavailable", "No valid EVM account");
452
+ }
453
+ return bare;
454
+ }
455
+
456
+ // src/useERC20Transfer.ts
457
+ function useERC20Transfer(options) {
458
+ const initialToken = toValue3(options.token);
459
+ const decimals = createDecimalsCache(initialToken, initialToken.decimals);
460
+ const isSending = shallowRef4(false);
461
+ const error = shallowRef4(null);
462
+ let generation = 0;
463
+ let disposed = false;
464
+ watch2(
465
+ [
466
+ () => toValue3(options.token).address,
467
+ () => toValue3(options.token).chainId,
468
+ () => toValue3(options.token).decimals,
469
+ () => toValue3(options.account),
470
+ () => toValue3(options.chainId),
471
+ () => toValue3(options.connected),
472
+ () => toValue3(options.publicClient),
473
+ () => unref4(options.sendTransaction)
474
+ ],
475
+ () => {
476
+ generation++;
477
+ isSending.value = false;
478
+ error.value = null;
479
+ },
480
+ { flush: "sync" }
481
+ );
482
+ const sendTransfer = async (to, amount) => {
483
+ const own = ++generation;
484
+ const token = toValue3(options.token);
485
+ const reader = toValue3(options.publicClient);
486
+ const stillCurrent = () => !disposed && own === generation;
487
+ error.value = null;
488
+ isSending.value = true;
489
+ try {
490
+ assertErc20Context(
491
+ token,
492
+ toValue3(options.chainId),
493
+ toValue3(options.account),
494
+ toValue3(options.connected)
495
+ );
496
+ if (!reader) {
497
+ throw new WalletError2(
498
+ "wallet_unavailable",
499
+ "No public client available"
500
+ );
501
+ }
502
+ let precision = readDecimals(decimals, token, token.decimals);
503
+ if (precision === void 0) {
504
+ precision = Number(
505
+ await reader.readContract({
506
+ address: token.address,
507
+ abi: ERC20_MIN_ABI,
508
+ functionName: "decimals"
509
+ })
510
+ );
511
+ if (!stillCurrent()) {
512
+ throw new WalletError2(
513
+ "session_inactive",
514
+ "Wallet or token context changed. Retry the transfer."
515
+ );
516
+ }
517
+ writeDecimals(decimals, token, precision);
518
+ }
519
+ const data = encodeErc20Transfer(to, parseUnits(amount, precision));
520
+ return await unref4(options.sendTransaction)({
521
+ to: token.address,
522
+ data,
523
+ value: "0"
524
+ });
525
+ } catch (cause) {
526
+ const normalized = cause instanceof Error ? cause : new Error("Transfer failed");
527
+ if (stillCurrent()) error.value = normalized;
528
+ throw normalized;
529
+ } finally {
530
+ if (stillCurrent()) isSending.value = false;
531
+ }
532
+ };
533
+ onScopeDispose4(() => {
534
+ disposed = true;
535
+ generation++;
536
+ });
537
+ return { sendTransfer, isSending, error };
538
+ }
539
+
540
+ // src/useERC20Approve.ts
541
+ import {
542
+ createDecimalsCache as createDecimalsCache2,
543
+ encodeErc20Approve,
544
+ readDecimals as readDecimals2,
545
+ writeDecimals as writeDecimals2
546
+ } from "@naculus/connect-appkit-core";
547
+ import {
548
+ ERC20_MIN_ABI as ERC20_MIN_ABI2,
549
+ formatUnits,
550
+ parseUnits as parseUnits2,
551
+ WalletError as WalletError3
552
+ } from "@naculus/connect-core";
553
+ import {
554
+ computed as computed3,
555
+ onScopeDispose as onScopeDispose5,
556
+ shallowRef as shallowRef5,
557
+ toValue as toValue4,
558
+ unref as unref5,
559
+ watch as watch3
560
+ } from "vue";
561
+ var MAX_UINT256 = (1n << 256n) - 1n;
562
+ function useERC20Approve(options) {
563
+ const initialToken = toValue4(options.token);
564
+ const decimals = createDecimalsCache2(initialToken, initialToken.decimals);
565
+ const allowanceRaw = shallowRef5(null);
566
+ const isApproving = shallowRef5(false);
567
+ const isFetchingAllowance = shallowRef5(false);
568
+ const error = shallowRef5(null);
569
+ let generation = 0;
570
+ let allowanceGeneration = 0;
571
+ let disposed = false;
572
+ watch3(
573
+ [
574
+ () => toValue4(options.token).address,
575
+ () => toValue4(options.token).chainId,
576
+ () => toValue4(options.token).decimals,
577
+ () => toValue4(options.spender),
578
+ () => toValue4(options.account),
579
+ () => toValue4(options.chainId),
580
+ () => toValue4(options.connected),
581
+ () => toValue4(options.publicClient),
582
+ () => unref5(options.sendTransaction)
583
+ ],
584
+ () => {
585
+ generation++;
586
+ allowanceGeneration++;
587
+ allowanceRaw.value = null;
588
+ isApproving.value = false;
589
+ isFetchingAllowance.value = false;
590
+ error.value = null;
591
+ },
592
+ { flush: "sync" }
593
+ );
594
+ const context = () => {
595
+ const token = toValue4(options.token);
596
+ const account = assertErc20Context(
597
+ token,
598
+ toValue4(options.chainId),
599
+ toValue4(options.account),
600
+ toValue4(options.connected)
601
+ );
602
+ const reader = toValue4(options.publicClient);
603
+ if (!reader)
604
+ throw new WalletError3("wallet_unavailable", "No public client");
605
+ return { token, account, reader, spender: toValue4(options.spender) };
606
+ };
607
+ const readPrecision = async () => {
608
+ const { token, reader } = context();
609
+ let precision = readDecimals2(decimals, token, token.decimals);
610
+ if (precision === void 0) {
611
+ precision = Number(
612
+ await reader.readContract({
613
+ address: token.address,
614
+ abi: ERC20_MIN_ABI2,
615
+ functionName: "decimals"
616
+ })
617
+ );
618
+ writeDecimals2(decimals, token, precision);
619
+ }
620
+ return precision;
621
+ };
622
+ const refetchAllowance = async () => {
623
+ const own = ++allowanceGeneration;
624
+ allowanceRaw.value = null;
625
+ error.value = null;
626
+ isFetchingAllowance.value = true;
627
+ try {
628
+ const { token, account, reader, spender } = context();
629
+ const raw = BigInt(
630
+ await reader.readContract({
631
+ address: token.address,
632
+ abi: ERC20_MIN_ABI2,
633
+ functionName: "allowance",
634
+ args: [account, spender]
635
+ })
636
+ );
637
+ if (disposed || own !== allowanceGeneration) return null;
638
+ allowanceRaw.value = raw;
639
+ return raw;
640
+ } catch (cause) {
641
+ if (!disposed && own === allowanceGeneration) {
642
+ error.value = cause instanceof Error ? cause : new Error("Failed to fetch allowance");
643
+ }
644
+ return null;
645
+ } finally {
646
+ if (!disposed && own === allowanceGeneration)
647
+ isFetchingAllowance.value = false;
648
+ }
649
+ };
650
+ const doApprove = async (rawAmount) => {
651
+ const own = ++generation;
652
+ error.value = null;
653
+ isApproving.value = true;
654
+ try {
655
+ const { token, spender } = context();
656
+ const hash = await unref5(options.sendTransaction)({
657
+ to: token.address,
658
+ data: encodeErc20Approve(spender, rawAmount),
659
+ value: "0"
660
+ });
661
+ if (!disposed && own === generation) void refetchAllowance();
662
+ return hash;
663
+ } catch (cause) {
664
+ const normalized = cause instanceof Error ? cause : new Error("Approve failed");
665
+ if (!disposed && own === generation) error.value = normalized;
666
+ throw normalized;
667
+ } finally {
668
+ if (!disposed && own === generation) isApproving.value = false;
669
+ }
670
+ };
671
+ const approve = async (amount) => {
672
+ const contextGeneration = generation;
673
+ let rawAmount;
674
+ try {
675
+ const precision = await readPrecision();
676
+ if (contextGeneration !== generation || disposed) {
677
+ throw new WalletError3(
678
+ "session_inactive",
679
+ "Wallet or token context changed. Retry the approval."
680
+ );
681
+ }
682
+ rawAmount = parseUnits2(amount, precision);
683
+ } catch (cause) {
684
+ const normalized = cause instanceof Error ? cause : new Error("Approve failed");
685
+ if (!disposed && contextGeneration === generation)
686
+ error.value = normalized;
687
+ throw normalized;
688
+ }
689
+ return doApprove(rawAmount);
690
+ };
691
+ const approveMax = () => doApprove(MAX_UINT256);
692
+ const hasAllowance = async (required) => {
693
+ const raw = allowanceRaw.value ?? await refetchAllowance();
694
+ if (raw === null) return false;
695
+ return raw >= parseUnits2(required, await readPrecision());
696
+ };
697
+ const allowance = computed3(() => {
698
+ if (allowanceRaw.value === null) return null;
699
+ const token = toValue4(options.token);
700
+ const precision = readDecimals2(decimals, token, token.decimals);
701
+ return precision === void 0 ? null : formatUnits(allowanceRaw.value, precision);
702
+ });
703
+ onScopeDispose5(() => {
704
+ disposed = true;
705
+ generation++;
706
+ allowanceGeneration++;
707
+ });
708
+ return {
709
+ approve,
710
+ approveMax,
711
+ allowanceRaw,
712
+ allowance,
713
+ hasAllowance,
714
+ isApproving,
715
+ isFetchingAllowance,
716
+ error,
717
+ refetchAllowance
718
+ };
719
+ }
720
+
721
+ // src/useERC20TransferSimulation.ts
722
+ import { chainNumber, encodeErc20Transfer as encodeErc20Transfer2 } from "@naculus/connect-appkit-core";
723
+ import { parseUnits as parseUnits3 } from "@naculus/connect-core";
724
+ import { computed as computed4, toValue as toValue5 } from "vue";
725
+ function useERC20TransferSimulation(options) {
726
+ const transaction = computed4(() => {
727
+ const token = toValue5(options.token);
728
+ if (!toValue5(options.connected) || !toValue5(options.evmAccount))
729
+ return void 0;
730
+ try {
731
+ if (token.decimals === void 0) return void 0;
732
+ return {
733
+ to: token.address,
734
+ data: encodeErc20Transfer2(
735
+ toValue5(options.to),
736
+ parseUnits3(toValue5(options.amount), token.decimals)
737
+ ),
738
+ value: "0"
739
+ };
740
+ } catch {
741
+ return void 0;
742
+ }
743
+ });
744
+ const chainId = computed4(() => {
745
+ const token = toValue5(options.token);
746
+ if (token.chainId !== void 0) return token.chainId;
747
+ const currentChain = toValue5(options.currentChain);
748
+ return currentChain ? chainNumber(currentChain) ?? void 0 : void 0;
749
+ });
750
+ const simulation = useTransactionSimulation(transaction, {
751
+ chainId,
752
+ currentChain: options.currentChain,
753
+ publicClient: options.publicClient,
754
+ evmAccount: options.evmAccount
755
+ });
756
+ return {
757
+ result: computed4(
758
+ () => transaction.value ? simulation.result.value : void 0
759
+ ),
760
+ isSimulating: computed4(
761
+ () => !!transaction.value && simulation.isSimulating.value
762
+ ),
763
+ error: computed4(() => transaction.value ? simulation.error.value : null),
764
+ reSimulate: simulation.simulate,
765
+ reset: simulation.reset
766
+ };
767
+ }
768
+
290
769
  // src/useAccount.ts
291
- import { computed as computed3, toValue as toValue2 } from "vue";
770
+ import { computed as computed5, toValue as toValue6 } from "vue";
292
771
  function useAccount(accounts, connected) {
293
772
  const parsed = useAccounts(accounts);
294
- const isConnected = computed3(() => toValue2(connected));
295
- const accountList = computed3(() => toValue2(accounts) ?? []);
773
+ const isConnected = computed5(() => toValue6(connected));
774
+ const accountList = computed5(() => toValue6(accounts) ?? []);
296
775
  return {
297
- accounts: computed3(
776
+ accounts: computed5(
298
777
  () => isConnected.value && accountList.value.length > 0 ? parsed.accounts.value : null
299
778
  ),
300
- evmAccount: computed3(
779
+ evmAccount: computed5(
301
780
  () => isConnected.value ? parsed.evmAccount.value : null
302
781
  ),
303
- primaryAccount: computed3(() => accountList.value[0] ?? null),
782
+ primaryAccount: computed5(() => accountList.value[0] ?? null),
304
783
  isConnected,
305
- count: computed3(() => accountList.value.length)
784
+ count: computed5(() => accountList.value.length)
306
785
  };
307
786
  }
308
787
 
309
788
  // src/useSession.ts
310
- import { computed as computed4, shallowRef as shallowRef2, toValue as toValue3, watch } from "vue";
789
+ import { computed as computed6, shallowRef as shallowRef6, toValue as toValue7, watch as watch4 } from "vue";
311
790
  function readSession(manager) {
312
791
  const bundle = manager?.getActiveBundle();
313
792
  if (!bundle) {
@@ -326,9 +805,9 @@ function readSession(manager) {
326
805
  };
327
806
  }
328
807
  function useSession(manager) {
329
- const snapshot = shallowRef2(readSession(toValue3(manager)));
330
- watch(
331
- () => toValue3(manager),
808
+ const snapshot = shallowRef6(readSession(toValue7(manager)));
809
+ watch4(
810
+ () => toValue7(manager),
332
811
  (current, _previous, onCleanup) => {
333
812
  const update = () => {
334
813
  snapshot.value = readSession(current);
@@ -338,145 +817,1097 @@ function useSession(manager) {
338
817
  current.on("sessionConnected", update);
339
818
  current.on("sessionDisconnected", update);
340
819
  current.on("chainChanged", update);
820
+ current.on("sessionScopeChanged", update);
821
+ current.on("sessionRevoked", update);
341
822
  onCleanup(() => {
342
823
  current.off("sessionConnected", update);
343
824
  current.off("sessionDisconnected", update);
344
825
  current.off("chainChanged", update);
826
+ current.off("sessionScopeChanged", update);
827
+ current.off("sessionRevoked", update);
828
+ });
829
+ },
830
+ { immediate: true }
831
+ );
832
+ return {
833
+ session: computed6(() => snapshot.value.session),
834
+ chainSessions: computed6(() => snapshot.value.chainSessions),
835
+ activeChainId: computed6(() => snapshot.value.activeChainId),
836
+ isConnected: computed6(() => snapshot.value.session !== null),
837
+ connectorId: computed6(() => snapshot.value.connectorId)
838
+ };
839
+ }
840
+
841
+ // src/useConnect.ts
842
+ import { WalletError as WalletError4 } from "@naculus/connect-core";
843
+ import { computed as computed7, toValue as toValue8, unref as unref6 } from "vue";
844
+
845
+ // src/internal/action-guard.ts
846
+ import { onScopeDispose as onScopeDispose6, shallowRef as shallowRef7 } from "vue";
847
+ function useActionGuard() {
848
+ const busy = shallowRef7(false);
849
+ const error = shallowRef7(null);
850
+ let active = 0;
851
+ let generation = 0;
852
+ let disposed = false;
853
+ const run = async (action, fallbackMessage, normalizeError) => {
854
+ const own = ++generation;
855
+ const commit = (write) => {
856
+ if (!disposed && own === generation) write();
857
+ };
858
+ active++;
859
+ busy.value = true;
860
+ error.value = null;
861
+ try {
862
+ return await action(commit);
863
+ } catch (cause) {
864
+ const normalized = normalizeError ? normalizeError(cause) : cause instanceof Error ? cause : new Error(fallbackMessage);
865
+ if (!disposed && own === generation) error.value = normalized;
866
+ throw normalized;
867
+ } finally {
868
+ active--;
869
+ if (!disposed) busy.value = active > 0;
870
+ }
871
+ };
872
+ const reset = () => {
873
+ generation++;
874
+ error.value = null;
875
+ };
876
+ const clearError = () => {
877
+ error.value = null;
878
+ };
879
+ const dispose = () => {
880
+ disposed = true;
881
+ generation++;
882
+ };
883
+ onScopeDispose6(dispose);
884
+ return { busy, error, run, clearError, reset, dispose };
885
+ }
886
+
887
+ // src/useConnect.ts
888
+ function useConnect(action, status) {
889
+ const guard = useActionGuard();
890
+ let inFlight = null;
891
+ const connect = () => {
892
+ if (inFlight) return inFlight;
893
+ const invoke = unref6(action);
894
+ const pending = guard.run(
895
+ () => Promise.resolve().then(() => invoke()),
896
+ "Connection failed",
897
+ (cause) => {
898
+ const message = cause instanceof Error ? cause.message : "Connection failed";
899
+ return cause instanceof WalletError4 ? cause : new Error(message);
900
+ }
901
+ ).catch(() => {
902
+ }).finally(() => {
903
+ if (inFlight === pending) inFlight = null;
904
+ });
905
+ inFlight = pending;
906
+ return pending;
907
+ };
908
+ return {
909
+ connect,
910
+ isConnecting: computed7(
911
+ () => guard.busy.value || toValue8(status) === "connecting"
912
+ ),
913
+ error: guard.error
914
+ };
915
+ }
916
+
917
+ // src/useDisconnect.ts
918
+ import { toValue as toValue9, unref as unref7 } from "vue";
919
+ function useDisconnect(action, status) {
920
+ const guard = useActionGuard();
921
+ let inFlight = null;
922
+ const disconnect = () => {
923
+ if (inFlight) return inFlight;
924
+ if (toValue9(status) === "disconnected") return Promise.resolve();
925
+ const invoke = unref7(action);
926
+ const pending = guard.run(() => Promise.resolve().then(() => invoke()), "Disconnect failed").catch(() => {
927
+ }).finally(() => {
928
+ if (inFlight === pending) inFlight = null;
929
+ });
930
+ inFlight = pending;
931
+ return pending;
932
+ };
933
+ const cleanup = () => {
934
+ guard.dispose();
935
+ };
936
+ return {
937
+ disconnect,
938
+ isDisconnecting: guard.busy,
939
+ error: guard.error,
940
+ cleanup
941
+ };
942
+ }
943
+
944
+ // src/useSwitchChain.ts
945
+ import { toChainSwitchError } from "@naculus/connect-appkit-core";
946
+ import { computed as computed8, toValue as toValue10, unref as unref8 } from "vue";
947
+ function useSwitchChain(action, chainId) {
948
+ const guard = useActionGuard();
949
+ const switchChain = (targetChainId) => {
950
+ const invoke = unref8(action);
951
+ return guard.run(async () => {
952
+ try {
953
+ await invoke(targetChainId);
954
+ } catch (cause) {
955
+ throw toChainSwitchError(cause);
956
+ }
957
+ }, "Failed to switch chain");
958
+ };
959
+ return {
960
+ switchChain,
961
+ isSwitching: guard.busy,
962
+ currentChainId: computed8(() => toValue10(chainId) ?? null),
963
+ error: guard.error,
964
+ clearError: guard.clearError
965
+ };
966
+ }
967
+
968
+ // src/useSignMessage.ts
969
+ import { unref as unref9 } from "vue";
970
+ function useSignMessage(action) {
971
+ const guard = useActionGuard();
972
+ const signMessage = (message) => {
973
+ const invoke = unref9(action);
974
+ return guard.run(() => invoke(message), "Signing failed");
975
+ };
976
+ return {
977
+ signMessage,
978
+ isSigning: guard.busy,
979
+ error: guard.error,
980
+ reset: guard.reset
981
+ };
982
+ }
983
+
984
+ // src/useSendTransaction.ts
985
+ import { computed as computed9, shallowRef as shallowRef8, unref as unref10 } from "vue";
986
+ function useSendTransaction(action) {
987
+ const guard = useActionGuard();
988
+ const status = shallowRef8("idle");
989
+ const sendTransaction = (transaction) => {
990
+ const invoke = unref10(action);
991
+ status.value = "awaiting_approval";
992
+ return guard.run(async (commit) => {
993
+ const hash = await invoke(transaction);
994
+ commit(() => {
995
+ status.value = "submitted";
996
+ });
997
+ return hash;
998
+ }, "Transaction failed").catch((cause) => {
999
+ if (guard.error.value === cause) status.value = "failed";
1000
+ throw cause;
1001
+ });
1002
+ };
1003
+ const reset = () => {
1004
+ guard.reset();
1005
+ status.value = "idle";
1006
+ };
1007
+ return {
1008
+ sendTransaction,
1009
+ status,
1010
+ error: guard.error,
1011
+ reset,
1012
+ isSending: computed9(() => status.value === "awaiting_approval")
1013
+ };
1014
+ }
1015
+
1016
+ // src/useSolanaTransaction.ts
1017
+ import { shallowRef as shallowRef9, unref as unref11 } from "vue";
1018
+ function useSolanaTransaction(options) {
1019
+ const guard = useActionGuard();
1020
+ const isSigning = shallowRef9(false);
1021
+ const isSending = shallowRef9(false);
1022
+ let signing = 0;
1023
+ let sending = 0;
1024
+ const signTransaction = (transaction) => {
1025
+ const invoke = unref11(options.signTransaction);
1026
+ signing++;
1027
+ isSigning.value = true;
1028
+ return guard.run(() => invoke(transaction), "Signing failed").finally(() => {
1029
+ signing--;
1030
+ isSigning.value = signing > 0;
1031
+ });
1032
+ };
1033
+ const sendTransaction = (transaction) => {
1034
+ const invoke = unref11(options.sendTransaction);
1035
+ sending++;
1036
+ isSending.value = true;
1037
+ return guard.run(() => invoke(transaction), "Send failed").finally(() => {
1038
+ sending--;
1039
+ isSending.value = sending > 0;
1040
+ });
1041
+ };
1042
+ const getStatus = (signature) => unref11(options.getStatus)(signature);
1043
+ return {
1044
+ signTransaction,
1045
+ sendTransaction,
1046
+ getStatus,
1047
+ isSigning,
1048
+ isSending,
1049
+ error: guard.error,
1050
+ reset: guard.reset
1051
+ };
1052
+ }
1053
+
1054
+ // src/useSignInWithX.ts
1055
+ import { onScopeDispose as onScopeDispose7, shallowRef as shallowRef10, unref as unref12 } from "vue";
1056
+ function useSignInWithX(action) {
1057
+ const isSigningIn = shallowRef10(false);
1058
+ const result = shallowRef10(null);
1059
+ const error = shallowRef10(null);
1060
+ let generation = 0;
1061
+ let active = 0;
1062
+ let disposed = false;
1063
+ const signIn = async (options) => {
1064
+ const invoke = unref12(action);
1065
+ const own = ++generation;
1066
+ active++;
1067
+ isSigningIn.value = true;
1068
+ error.value = null;
1069
+ try {
1070
+ const next = await invoke(options);
1071
+ if (!disposed && own === generation) result.value = next;
1072
+ return next;
1073
+ } catch (cause) {
1074
+ const normalized = cause instanceof Error ? cause : new Error("SIWX sign-in failed");
1075
+ if (!disposed && own === generation) error.value = normalized;
1076
+ throw normalized;
1077
+ } finally {
1078
+ active--;
1079
+ if (!disposed) isSigningIn.value = active > 0;
1080
+ }
1081
+ };
1082
+ const clearError = () => {
1083
+ error.value = null;
1084
+ };
1085
+ const reset = () => {
1086
+ generation++;
1087
+ result.value = null;
1088
+ error.value = null;
1089
+ };
1090
+ onScopeDispose7(() => {
1091
+ disposed = true;
1092
+ generation++;
1093
+ });
1094
+ return { signIn, isSigningIn, result, error, clearError, reset };
1095
+ }
1096
+
1097
+ // src/useSignInWithEthereum.ts
1098
+ function useSignInWithEthereum(action) {
1099
+ return useSignInWithX(action);
1100
+ }
1101
+
1102
+ // src/useExecuteCalls.ts
1103
+ import { computed as computed10, toValue as toValue11, unref as unref13 } from "vue";
1104
+ function useExecuteCalls(options) {
1105
+ const guard = useActionGuard();
1106
+ const preview = (callCount, atomicity) => unref13(options.preview)(callCount, atomicity);
1107
+ const execute = (calls, atomicity) => {
1108
+ const invoke = unref13(options.execute);
1109
+ return guard.run(() => invoke(calls, atomicity), "Execution failed");
1110
+ };
1111
+ const reset = () => {
1112
+ guard.reset();
1113
+ unref13(options.reset)();
1114
+ };
1115
+ return {
1116
+ preview,
1117
+ execute,
1118
+ isExecuting: guard.busy,
1119
+ error: guard.error,
1120
+ lastRoute: computed10(() => toValue11(options.lastRoute)),
1121
+ reset
1122
+ };
1123
+ }
1124
+
1125
+ // src/useDelegationPolicy.ts
1126
+ import {
1127
+ bareEvmAddress as bareEvmAddress2,
1128
+ createDelegationPolicyFlow,
1129
+ getSharedSessionKeyManager as getSharedSessionKeyManager2,
1130
+ isVerifiablePolicy
1131
+ } from "@naculus/connect-appkit-core";
1132
+ import {
1133
+ computed as computed12,
1134
+ onScopeDispose as onScopeDispose9,
1135
+ shallowRef as shallowRef12,
1136
+ toValue as toValue13,
1137
+ unref as unref14,
1138
+ watch as watch6
1139
+ } from "vue";
1140
+
1141
+ // src/useSessionKeys.ts
1142
+ import { getSharedSessionKeyManager } from "@naculus/connect-appkit-core";
1143
+ import { computed as computed11, onScopeDispose as onScopeDispose8, shallowRef as shallowRef11, toValue as toValue12, watch as watch5 } from "vue";
1144
+ function resolveManager(config, options) {
1145
+ return options.manager ?? getSharedSessionKeyManager(config);
1146
+ }
1147
+ function useSessionKeys(connected, config, options = {}) {
1148
+ const manager = resolveManager(config, options);
1149
+ const sessions = shallowRef11([]);
1150
+ const loading = shallowRef11(false);
1151
+ const error = shallowRef11(null);
1152
+ let generation = 0;
1153
+ let disposed = false;
1154
+ const refresh = async () => {
1155
+ const own = ++generation;
1156
+ if (!toValue12(connected)) {
1157
+ sessions.value = [];
1158
+ return;
1159
+ }
1160
+ loading.value = true;
1161
+ error.value = null;
1162
+ try {
1163
+ const keys = await manager.listSessions();
1164
+ if (!disposed && own === generation) sessions.value = keys;
1165
+ } catch (cause) {
1166
+ if (!disposed && own === generation) {
1167
+ error.value = cause instanceof Error ? cause : new Error("Failed to load session keys");
1168
+ }
1169
+ } finally {
1170
+ if (!disposed && own === generation) loading.value = false;
1171
+ }
1172
+ };
1173
+ watch5(
1174
+ () => toValue12(connected),
1175
+ () => {
1176
+ void refresh();
1177
+ },
1178
+ { immediate: true }
1179
+ );
1180
+ onScopeDispose8(() => {
1181
+ disposed = true;
1182
+ generation++;
1183
+ });
1184
+ return {
1185
+ sessions,
1186
+ activeSessions: computed11(
1187
+ () => sessions.value.filter((s) => s.status === "active")
1188
+ ),
1189
+ loading,
1190
+ error,
1191
+ refresh,
1192
+ clearError: () => {
1193
+ error.value = null;
1194
+ },
1195
+ storageAvailable: manager.isStorageAvailable()
1196
+ };
1197
+ }
1198
+ function useCreateSessionKey(config, options = {}) {
1199
+ const manager = resolveManager(config, options);
1200
+ const guard = useActionGuard();
1201
+ const lastCreated = shallowRef11(null);
1202
+ return {
1203
+ createSessionKey: (scope, signerAddress) => guard.run(async () => {
1204
+ const info = await manager.createSessionKey(scope, signerAddress);
1205
+ lastCreated.value = info;
1206
+ return info;
1207
+ }, "Failed to create session key"),
1208
+ lastCreated,
1209
+ isCreating: guard.busy,
1210
+ error: guard.error,
1211
+ clearError: guard.reset
1212
+ };
1213
+ }
1214
+ function useRevokeSession(config, options = {}) {
1215
+ const manager = resolveManager(config, options);
1216
+ const guard = useActionGuard();
1217
+ return {
1218
+ revokeSession: (sessionId) => guard.run(
1219
+ () => manager.revokeSession(sessionId),
1220
+ "Failed to revoke session key"
1221
+ ),
1222
+ isRevoking: guard.busy,
1223
+ error: guard.error,
1224
+ clearError: guard.reset
1225
+ };
1226
+ }
1227
+ function useSendWithSession(config, options = {}) {
1228
+ const manager = resolveManager(config, options);
1229
+ const guard = useActionGuard();
1230
+ return {
1231
+ signWithSession: (sessionId, messageHash, tx) => guard.run(
1232
+ () => manager.signWithSessionKey(sessionId, messageHash, tx),
1233
+ "Failed to sign with session key"
1234
+ ),
1235
+ checkScope: (sessionId, tx) => guard.run(
1236
+ () => manager.checkSessionScope(sessionId, tx),
1237
+ "Failed to check session scope"
1238
+ ),
1239
+ isBusy: guard.busy,
1240
+ error: guard.error,
1241
+ clearError: guard.reset
1242
+ };
1243
+ }
1244
+
1245
+ // src/useDelegationPolicy.ts
1246
+ function useDelegationPolicy(options) {
1247
+ const manager = options.manager ?? getSharedSessionKeyManager2(options.managerConfig);
1248
+ const sessionKeys = useSessionKeys(options.connected, options.managerConfig, {
1249
+ manager
1250
+ });
1251
+ const guard = useActionGuard();
1252
+ const verifiedIds = shallowRef12(/* @__PURE__ */ new Set());
1253
+ const isVerifying = shallowRef12(false);
1254
+ const verifyError = shallowRef12(null);
1255
+ let verifyGeneration = 0;
1256
+ let disposed = false;
1257
+ const origin = options.origin ?? (typeof window !== "undefined" ? window.location.origin : "unknown");
1258
+ const flow = createDelegationPolicyFlow({
1259
+ manager,
1260
+ origin,
1261
+ signer: () => bareEvmAddress2(toValue13(options.account)),
1262
+ signMessage: (message) => unref14(options.signMessage)(message),
1263
+ verifySignature: (input) => unref14(options.verifySignature)(input),
1264
+ previewExecution: (callCount, atomicity) => unref14(options.previewExecution)(callCount, atomicity),
1265
+ sponsorship: options.sponsorship,
1266
+ adapter: options.adapter,
1267
+ delegation: () => toValue13(options.delegation),
1268
+ encryptionKeyConfigured: Boolean(options.managerConfig?.encryptionKey),
1269
+ storageAvailable: () => sessionKeys.storageAvailable,
1270
+ refresh: sessionKeys.refresh
1271
+ });
1272
+ watch6(
1273
+ () => sessionKeys.sessions.value,
1274
+ (sessions) => {
1275
+ const own = ++verifyGeneration;
1276
+ const candidates = sessions.filter(isVerifiablePolicy);
1277
+ if (candidates.length === 0) {
1278
+ verifiedIds.value = /* @__PURE__ */ new Set();
1279
+ isVerifying.value = false;
1280
+ return;
1281
+ }
1282
+ isVerifying.value = true;
1283
+ void Promise.all(
1284
+ candidates.map(
1285
+ async (policy) => [policy.id, await flow.verifyStoredPolicy(policy)]
1286
+ )
1287
+ ).then((results) => {
1288
+ if (disposed || own !== verifyGeneration) return;
1289
+ verifiedIds.value = new Set(
1290
+ results.filter(([, ok]) => ok).map(([id]) => id)
1291
+ );
1292
+ }).catch((cause) => {
1293
+ if (disposed || own !== verifyGeneration) return;
1294
+ verifiedIds.value = /* @__PURE__ */ new Set();
1295
+ verifyError.value = cause instanceof Error ? cause : new Error("Policy verification failed");
1296
+ }).finally(() => {
1297
+ if (!disposed && own === verifyGeneration) isVerifying.value = false;
345
1298
  });
346
1299
  },
347
1300
  { immediate: true }
348
1301
  );
1302
+ onScopeDispose9(() => {
1303
+ disposed = true;
1304
+ verifyGeneration++;
1305
+ });
349
1306
  return {
350
- session: computed4(() => snapshot.value.session),
351
- chainSessions: computed4(() => snapshot.value.chainSessions),
352
- activeChainId: computed4(() => snapshot.value.activeChainId),
353
- isConnected: computed4(() => snapshot.value.session !== null),
354
- connectorId: computed4(() => snapshot.value.connectorId)
1307
+ policies: sessionKeys.sessions,
1308
+ activePolicies: computed12(
1309
+ () => sessionKeys.activeSessions.value.filter(
1310
+ (p) => verifiedIds.value.has(p.id)
1311
+ )
1312
+ ),
1313
+ storageAvailable: sessionKeys.storageAvailable,
1314
+ loading: computed12(() => sessionKeys.loading.value || isVerifying.value),
1315
+ isBusy: guard.busy,
1316
+ error: computed12(
1317
+ () => guard.error.value ?? verifyError.value ?? sessionKeys.error.value
1318
+ ),
1319
+ createPolicy: (scope) => guard.run(() => flow.createPolicy(scope), "Policy creation failed"),
1320
+ revokePolicy: (policyId) => guard.run(() => flow.revokePolicy(policyId), "Policy revocation failed"),
1321
+ previewPolicyExecution: flow.previewPolicyExecution,
1322
+ signPolicyDigest: flow.signPolicyDigest,
1323
+ executePolicy: (policyId, tx) => guard.run(
1324
+ () => flow.executePolicy(policyId, tx),
1325
+ "Policy execution failed"
1326
+ ),
1327
+ refresh: sessionKeys.refresh,
1328
+ clearError: () => {
1329
+ guard.reset();
1330
+ verifyError.value = null;
1331
+ sessionKeys.clearError();
1332
+ }
355
1333
  };
356
1334
  }
357
1335
 
358
- // src/useConnect.ts
359
- import { WalletError } from "@naculus/connect-core";
360
- import { computed as computed5, onScopeDispose as onScopeDispose2, shallowRef as shallowRef3, toValue as toValue4, unref as unref2 } from "vue";
361
- function useConnect(action, status) {
362
- const isLoading = shallowRef3(false);
363
- const error = shallowRef3(null);
1336
+ // src/useSmartAccount.ts
1337
+ import {
1338
+ bareEvmAddress as bareEvmAddress3,
1339
+ buildSmartAccountConfig,
1340
+ resolveEvmChainId
1341
+ } from "@naculus/connect-appkit-core";
1342
+ import { WalletError as WalletError5 } from "@naculus/connect-core";
1343
+ import {
1344
+ computed as computed13,
1345
+ onScopeDispose as onScopeDispose10,
1346
+ shallowRef as shallowRef13,
1347
+ toValue as toValue14,
1348
+ unref as unref15,
1349
+ watch as watch7
1350
+ } from "vue";
1351
+ function useSmartAccount(options) {
1352
+ const address = shallowRef13(null);
1353
+ const isDeployed = shallowRef13(false);
1354
+ const accountInfo = shallowRef13(null);
1355
+ const guard = useActionGuard();
1356
+ const managerRef = shallowRef13(null);
1357
+ let generation = 0;
1358
+ let inFlight = false;
364
1359
  let disposed = false;
365
- let inFlight = null;
366
- const connect = () => {
367
- if (inFlight) return inFlight;
368
- const invoke = unref2(action);
369
- isLoading.value = true;
370
- error.value = null;
371
- const pending = Promise.resolve().then(() => invoke()).catch((cause) => {
372
- if (disposed) return;
373
- const message = cause instanceof Error ? cause.message : "Connection failed";
374
- error.value = cause instanceof WalletError ? cause : new Error(message);
375
- }).finally(() => {
376
- if (inFlight === pending) inFlight = null;
377
- if (!disposed) isLoading.value = false;
1360
+ const chainId = computed13(
1361
+ () => resolveEvmChainId(
1362
+ toValue14(options.chainId),
1363
+ toValue14(options.connectedChainId)
1364
+ )
1365
+ );
1366
+ watch7(
1367
+ [
1368
+ () => toValue14(options.manager),
1369
+ () => toValue14(options.rpcUrl),
1370
+ () => toValue14(options.bundlerUrl),
1371
+ () => chainId.value
1372
+ ],
1373
+ ([supplied, rpcUrl, bundlerUrl, chain]) => {
1374
+ const own = ++generation;
1375
+ managerRef.value = null;
1376
+ if (supplied) {
1377
+ managerRef.value = supplied;
1378
+ return;
1379
+ }
1380
+ if (!rpcUrl || !chain) return;
1381
+ import("@naculus/connect-core").then(({ SmartAccountManager }) => {
1382
+ if (disposed || own !== generation) return;
1383
+ managerRef.value = new SmartAccountManager({
1384
+ rpcUrl,
1385
+ chainId: chain,
1386
+ bundlerClient: { url: bundlerUrl ?? "" }
1387
+ });
1388
+ }).catch((cause) => {
1389
+ if (disposed || own !== generation) return;
1390
+ guard.error.value = cause instanceof Error ? cause : new Error("Failed to load account-abstraction module");
1391
+ });
1392
+ },
1393
+ { immediate: true }
1394
+ );
1395
+ const config = computed13(() => {
1396
+ const owner = bareEvmAddress3(toValue14(options.account));
1397
+ const chain = chainId.value;
1398
+ if (!owner || !chain || !managerRef.value) return null;
1399
+ return buildSmartAccountConfig(owner, chain, {
1400
+ accountType: options.accountType,
1401
+ entryPoint: options.entryPoint,
1402
+ salt: options.salt
378
1403
  });
379
- inFlight = pending;
380
- return pending;
1404
+ });
1405
+ const apply = (info) => {
1406
+ address.value = info.address;
1407
+ isDeployed.value = info.isDeployed;
1408
+ accountInfo.value = info;
381
1409
  };
382
- onScopeDispose2(() => {
1410
+ const operate = async (action, fallback) => {
1411
+ const cfg = config.value;
1412
+ const manager = managerRef.value;
1413
+ if (!cfg || !manager) {
1414
+ guard.error.value = new Error("Smart account not configured");
1415
+ return null;
1416
+ }
1417
+ if (inFlight) {
1418
+ guard.error.value = new Error(
1419
+ "Smart account operation already in progress"
1420
+ );
1421
+ return null;
1422
+ }
1423
+ inFlight = true;
1424
+ const own = generation;
1425
+ const current = () => !disposed && own === generation;
1426
+ const commit = (write) => {
1427
+ if (current()) write();
1428
+ };
1429
+ try {
1430
+ return await guard.run(async () => {
1431
+ const result = await action(manager, cfg, commit);
1432
+ return current() ? result : null;
1433
+ }, fallback);
1434
+ } catch {
1435
+ return null;
1436
+ } finally {
1437
+ inFlight = false;
1438
+ }
1439
+ };
1440
+ const createWallet = () => operate(async (manager, cfg, commit) => {
1441
+ const info = await manager.createAccount(cfg);
1442
+ commit(() => apply(info));
1443
+ return info;
1444
+ }, "Failed to create smart account");
1445
+ const deployWallet = () => operate(async (manager, cfg, commit) => {
1446
+ const send = unref15(options.sendTransaction);
1447
+ if (!send) {
1448
+ throw new WalletError5(
1449
+ "wallet_unavailable",
1450
+ "deployWallet needs the connected wallet's sendTransaction"
1451
+ );
1452
+ }
1453
+ const before = await manager.createAccount(cfg);
1454
+ if (before.isDeployed) {
1455
+ commit(() => apply(before));
1456
+ return before.address;
1457
+ }
1458
+ const deployTx = await manager.getDeployCallData(cfg);
1459
+ const hash = await send({
1460
+ to: deployTx.to,
1461
+ data: deployTx.data,
1462
+ value: deployTx.value.toString(),
1463
+ chainId: cfg.chainId
1464
+ });
1465
+ const after = await manager.createAccount(cfg);
1466
+ commit(() => apply(after));
1467
+ return hash;
1468
+ }, "Failed to deploy smart account");
1469
+ const getAddress = () => operate(async (manager, cfg, commit) => {
1470
+ const addr = await manager.getAccountAddress(cfg);
1471
+ commit(() => {
1472
+ address.value = addr;
1473
+ });
1474
+ return addr;
1475
+ }, "Failed to get smart account address");
1476
+ onScopeDispose10(() => {
383
1477
  disposed = true;
1478
+ generation++;
384
1479
  });
385
1480
  return {
386
- connect,
387
- isConnecting: computed5(
388
- () => isLoading.value || toValue4(status) === "connecting"
389
- ),
390
- error
1481
+ address,
1482
+ isDeployed,
1483
+ accountInfo,
1484
+ isLoading: guard.busy,
1485
+ error: guard.error,
1486
+ config,
1487
+ createWallet,
1488
+ deployWallet,
1489
+ getAddress
391
1490
  };
392
1491
  }
393
1492
 
394
- // src/useDisconnect.ts
395
- import { onScopeDispose as onScopeDispose3, shallowRef as shallowRef4, toValue as toValue5, unref as unref3 } from "vue";
396
- function useDisconnect(action, status) {
397
- const isDisconnecting = shallowRef4(false);
398
- const error = shallowRef4(null);
1493
+ // src/useSendUserOperation.ts
1494
+ import {
1495
+ bareEvmAddress as bareEvmAddress4,
1496
+ buildSmartAccountConfig as buildSmartAccountConfig2,
1497
+ resolveUserOpChain
1498
+ } from "@naculus/connect-appkit-core";
1499
+ import { WalletError as WalletError6 } from "@naculus/connect-core";
1500
+ import { onScopeDispose as onScopeDispose11, shallowRef as shallowRef14, toValue as toValue15, unref as unref16 } from "vue";
1501
+ function useSendUserOperation(options) {
1502
+ const userOpHash = shallowRef14(null);
1503
+ const receipt = shallowRef14(null);
1504
+ const isPending = shallowRef14(false);
1505
+ const isEstimating = shallowRef14(false);
1506
+ const error = shallowRef14(null);
1507
+ let requestId = 0;
1508
+ let inFlight = false;
399
1509
  let disposed = false;
400
- let inFlight = null;
401
- const disconnect = () => {
402
- if (inFlight) return inFlight;
403
- if (toValue5(status) === "disconnected") return Promise.resolve();
404
- const invoke = unref3(action);
405
- isDisconnecting.value = true;
1510
+ const fail = (cause) => {
1511
+ error.value = cause;
1512
+ return null;
1513
+ };
1514
+ const sendUserOp = async (calls, opts) => {
1515
+ const rpcUrl = toValue15(options.rpcUrl);
1516
+ const bundlerUrl = toValue15(options.bundlerUrl);
1517
+ if (!rpcUrl) return fail(new Error("RPC URL not configured"));
1518
+ if (!bundlerUrl) return fail(new Error("Bundler URL not configured"));
1519
+ if (!calls.length) return fail(new Error("At least one call is required"));
1520
+ if (inFlight) {
1521
+ return fail(new Error("A UserOperation is already in progress"));
1522
+ }
1523
+ const owner = bareEvmAddress4(
1524
+ toValue15(options.owner) ?? toValue15(options.account)
1525
+ );
1526
+ if (!owner) {
1527
+ return fail(
1528
+ new WalletError6("wallet_unavailable", "No EVM account found")
1529
+ );
1530
+ }
1531
+ let targetChainId;
1532
+ try {
1533
+ targetChainId = resolveUserOpChain(
1534
+ toValue15(options.chainId),
1535
+ toValue15(options.connectedChainId)
1536
+ );
1537
+ } catch (chainError) {
1538
+ return fail(chainError);
1539
+ }
1540
+ const signer = unref16(options.signer);
1541
+ const own = ++requestId;
1542
+ inFlight = true;
1543
+ isPending.value = true;
1544
+ isEstimating.value = true;
406
1545
  error.value = null;
407
- const pending = Promise.resolve().then(() => invoke()).catch((cause) => {
408
- if (!disposed) {
409
- error.value = cause instanceof Error ? cause : new Error("Disconnect failed");
1546
+ userOpHash.value = null;
1547
+ receipt.value = null;
1548
+ try {
1549
+ const { SmartAccountManager } = await import("@naculus/connect-core");
1550
+ const manager = new SmartAccountManager({
1551
+ rpcUrl,
1552
+ bundlerClient: { url: bundlerUrl },
1553
+ chainId: targetChainId,
1554
+ signer,
1555
+ signerMode: options.signerMode ?? "eip191"
1556
+ });
1557
+ const config = buildSmartAccountConfig2(owner, targetChainId, {
1558
+ accountType: options.accountType,
1559
+ entryPoint: options.entryPoint,
1560
+ salt: options.salt
1561
+ });
1562
+ const response = await manager.sendUserOperation(config, calls, opts);
1563
+ if (disposed || own !== requestId) return null;
1564
+ isEstimating.value = false;
1565
+ userOpHash.value = response.userOpHash;
1566
+ void manager.getUserOperationReceipt(response.userOpHash).then((next) => {
1567
+ if (!disposed && own === requestId) receipt.value = next;
1568
+ }).catch(() => void 0);
1569
+ return response;
1570
+ } catch (cause) {
1571
+ if (disposed || own !== requestId) return null;
1572
+ return fail(
1573
+ cause instanceof Error ? cause : new Error("Failed to send UserOperation")
1574
+ );
1575
+ } finally {
1576
+ inFlight = false;
1577
+ if (!disposed && own === requestId) {
1578
+ isPending.value = false;
1579
+ isEstimating.value = false;
410
1580
  }
411
- }).finally(() => {
412
- if (inFlight === pending) inFlight = null;
413
- if (!disposed) isDisconnecting.value = false;
414
- });
415
- inFlight = pending;
416
- return pending;
1581
+ }
417
1582
  };
418
- const cleanup = () => {
1583
+ const reset = () => {
1584
+ requestId++;
1585
+ userOpHash.value = null;
1586
+ receipt.value = null;
1587
+ isPending.value = false;
1588
+ isEstimating.value = false;
1589
+ error.value = null;
1590
+ };
1591
+ onScopeDispose11(() => {
419
1592
  disposed = true;
1593
+ requestId++;
1594
+ });
1595
+ return {
1596
+ sendUserOp,
1597
+ userOpHash,
1598
+ receipt,
1599
+ isPending,
1600
+ isEstimating,
1601
+ error,
1602
+ reset
420
1603
  };
421
- onScopeDispose3(cleanup);
422
- return { disconnect, isDisconnecting, error, cleanup };
423
1604
  }
424
1605
 
425
- // src/useSwitchChain.ts
426
- import { toChainSwitchError } from "@naculus/connect-appkit-core";
427
- import { computed as computed6, onScopeDispose as onScopeDispose4, shallowRef as shallowRef5, toValue as toValue6, unref as unref4 } from "vue";
428
- function useSwitchChain(action, chainId) {
429
- const isSwitching = shallowRef5(false);
430
- const error = shallowRef5(null);
1606
+ // src/useUserOpStatus.ts
1607
+ import {
1608
+ fetchUserOperationReceipt,
1609
+ InvalidUserOperationReceiptError
1610
+ } from "@naculus/connect-appkit-core";
1611
+ import { onScopeDispose as onScopeDispose12, shallowRef as shallowRef15, toValue as toValue16 } from "vue";
1612
+ function useUserOpStatus(options) {
1613
+ const status = shallowRef15("idle");
1614
+ const receipt = shallowRef15(null);
1615
+ const userOpHash = shallowRef15(null);
1616
+ const error = shallowRef15(null);
1617
+ const isPolling = shallowRef15(false);
1618
+ const elapsedMs = shallowRef15(0);
1619
+ const attempts = shallowRef15(0);
1620
+ const pollInterval = options.pollInterval ?? 2e3;
1621
+ const maxRetries = options.maxRetries ?? 30;
431
1622
  let generation = 0;
432
- let active = 0;
1623
+ let startedAt = 0;
1624
+ let ticker = null;
1625
+ let timer = null;
1626
+ let controller = null;
1627
+ const clearTimers = () => {
1628
+ if (ticker) clearInterval(ticker);
1629
+ if (timer) clearTimeout(timer);
1630
+ ticker = null;
1631
+ timer = null;
1632
+ };
1633
+ const finish = (next, cause) => {
1634
+ status.value = next;
1635
+ error.value = cause;
1636
+ isPolling.value = false;
1637
+ clearTimers();
1638
+ };
1639
+ const poll = async (hash, own) => {
1640
+ const bundlerUrl = toValue16(options.bundlerUrl);
1641
+ if (!bundlerUrl || own !== generation) return;
1642
+ const attempt = ++attempts.value;
1643
+ const abort = new AbortController();
1644
+ controller = abort;
1645
+ try {
1646
+ const next = await fetchUserOperationReceipt(
1647
+ bundlerUrl,
1648
+ hash,
1649
+ abort.signal
1650
+ );
1651
+ if (own !== generation) return;
1652
+ if (next) {
1653
+ receipt.value = next;
1654
+ finish(next.success ? "confirmed" : "failed", null);
1655
+ return;
1656
+ }
1657
+ status.value = "pending";
1658
+ if (attempt <= maxRetries) {
1659
+ timer = setTimeout(() => void poll(hash, own), pollInterval);
1660
+ } else {
1661
+ finish(
1662
+ "not_found",
1663
+ new Error("UserOperation not included after maximum retries")
1664
+ );
1665
+ }
1666
+ } catch (cause) {
1667
+ if (own !== generation || abort.signal.aborted) return;
1668
+ const next = cause instanceof Error ? cause : new Error("Unknown bundler response failure");
1669
+ if (next instanceof InvalidUserOperationReceiptError) {
1670
+ finish("not_found", next);
1671
+ return;
1672
+ }
1673
+ if (attempt <= maxRetries) {
1674
+ timer = setTimeout(() => void poll(hash, own), pollInterval);
1675
+ } else {
1676
+ finish(
1677
+ "not_found",
1678
+ new Error(
1679
+ `UserOperation status unavailable after ${attempt} attempt${attempt === 1 ? "" : "s"}: ${next.message}`
1680
+ )
1681
+ );
1682
+ }
1683
+ } finally {
1684
+ if (controller === abort) controller = null;
1685
+ }
1686
+ };
1687
+ const start = (hash) => {
1688
+ const own = ++generation;
1689
+ controller?.abort();
1690
+ controller = null;
1691
+ clearTimers();
1692
+ userOpHash.value = hash;
1693
+ receipt.value = null;
1694
+ error.value = null;
1695
+ attempts.value = 0;
1696
+ elapsedMs.value = 0;
1697
+ if (!toValue16(options.bundlerUrl)) {
1698
+ finish("not_found", new Error("Bundler URL not configured"));
1699
+ return;
1700
+ }
1701
+ status.value = "pending";
1702
+ isPolling.value = true;
1703
+ startedAt = Date.now();
1704
+ ticker = setInterval(() => {
1705
+ elapsedMs.value = Date.now() - startedAt;
1706
+ }, 1e3);
1707
+ void poll(hash, own);
1708
+ };
1709
+ const stop = () => {
1710
+ generation++;
1711
+ controller?.abort();
1712
+ controller = null;
1713
+ clearTimers();
1714
+ isPolling.value = false;
1715
+ };
1716
+ const reset = () => {
1717
+ stop();
1718
+ status.value = "idle";
1719
+ receipt.value = null;
1720
+ userOpHash.value = null;
1721
+ error.value = null;
1722
+ attempts.value = 0;
1723
+ elapsedMs.value = 0;
1724
+ };
1725
+ onScopeDispose12(stop);
1726
+ return {
1727
+ status,
1728
+ receipt,
1729
+ userOpHash,
1730
+ error,
1731
+ isPolling,
1732
+ elapsedMs,
1733
+ attempts,
1734
+ start,
1735
+ stop,
1736
+ reset
1737
+ };
1738
+ }
1739
+
1740
+ // src/useSendCalls.ts
1741
+ import { computed as computed14, onScopeDispose as onScopeDispose13, shallowRef as shallowRef16, toValue as toValue17, unref as unref17 } from "vue";
1742
+ function useSendCalls(options) {
1743
+ const status = shallowRef16("idle");
1744
+ const error = shallowRef16(null);
1745
+ const batchHash = shallowRef16(null);
1746
+ const callsStatus = shallowRef16(null);
1747
+ let sendGeneration = 0;
1748
+ let statusGeneration = 0;
433
1749
  let disposed = false;
434
- const switchChain = async (targetChainId) => {
435
- const invoke = unref4(action);
436
- const mine = ++generation;
437
- active++;
438
- isSwitching.value = true;
1750
+ const sendCalls = async (calls, input) => {
1751
+ const invoke = unref17(options.sendCalls);
1752
+ const own = ++sendGeneration;
1753
+ status.value = "awaiting_approval";
439
1754
  error.value = null;
1755
+ batchHash.value = null;
440
1756
  try {
441
- await invoke(targetChainId);
1757
+ const hash = await invoke(calls, input);
1758
+ if (!disposed && own === sendGeneration) {
1759
+ status.value = "submitted";
1760
+ batchHash.value = hash;
1761
+ }
1762
+ return hash;
442
1763
  } catch (cause) {
443
- const walletError = toChainSwitchError(cause);
444
- if (!disposed && mine === generation) error.value = walletError;
445
- throw walletError;
446
- } finally {
447
- active--;
448
- if (!disposed) isSwitching.value = active > 0;
1764
+ const normalized = cause instanceof Error ? cause : new Error("sendCalls failed");
1765
+ if (!disposed && own === sendGeneration) {
1766
+ status.value = "failed";
1767
+ error.value = normalized;
1768
+ }
1769
+ throw normalized;
449
1770
  }
450
1771
  };
451
- onScopeDispose4(() => {
1772
+ const getCallsStatus = async (hash) => {
1773
+ const invoke = unref17(options.getCallsStatus);
1774
+ const own = ++statusGeneration;
1775
+ const result = await invoke(hash);
1776
+ if (!disposed && own === statusGeneration) callsStatus.value = result;
1777
+ return result;
1778
+ };
1779
+ const showCallsStatus = (hash) => unref17(options.showCallsStatus)(hash);
1780
+ const reset = () => {
1781
+ sendGeneration++;
1782
+ statusGeneration++;
1783
+ status.value = "idle";
1784
+ error.value = null;
1785
+ batchHash.value = null;
1786
+ callsStatus.value = null;
1787
+ };
1788
+ onScopeDispose13(() => {
452
1789
  disposed = true;
453
- generation++;
1790
+ sendGeneration++;
1791
+ statusGeneration++;
454
1792
  });
455
1793
  return {
456
- switchChain,
457
- isSwitching,
458
- currentChainId: computed6(() => toValue6(chainId) ?? null),
1794
+ sendCalls,
1795
+ getCallsStatus,
1796
+ showCallsStatus,
1797
+ status,
459
1798
  error,
460
- clearError: () => {
461
- error.value = null;
462
- }
1799
+ batchHash,
1800
+ callsStatus,
1801
+ execution: computed14(() => toValue17(options.execution) ?? null),
1802
+ isSending: computed14(() => status.value === "awaiting_approval"),
1803
+ reset
1804
+ };
1805
+ }
1806
+
1807
+ // src/useEmbeddedWallet.ts
1808
+ import { computed as computed15, toValue as toValue18, unref as unref18 } from "vue";
1809
+ function useEmbeddedWallet(options) {
1810
+ const guard = useActionGuard();
1811
+ const run = (action) => guard.run(action, "Embedded wallet action failed");
1812
+ const wallet = computed15(() => toValue18(options.wallet));
1813
+ return {
1814
+ wallet,
1815
+ hasWallet: computed15(() => wallet.value !== null),
1816
+ address: computed15(() => wallet.value?.address ?? null),
1817
+ accounts: computed15(() => wallet.value?.accounts ?? []),
1818
+ activeNamespace: computed15(() => wallet.value?.activeNamespace ?? null),
1819
+ backupPending: computed15(() => toValue18(options.backupPending)),
1820
+ storageSecurityLevel: computed15(() => toValue18(options.storageSecurityLevel)),
1821
+ securityReport: computed15(() => toValue18(options.securityReport)),
1822
+ connectEmbedded: () => run(() => unref18(options.connectEmbedded)()),
1823
+ restoreWallet: () => run(() => unref18(options.restoreWallet)()),
1824
+ generateWallet: () => run(() => unref18(options.generateWallet)()),
1825
+ importFromMnemonic: (value) => run(() => unref18(options.importFromMnemonic)(value)),
1826
+ importFromPrivateKey: (value) => run(() => unref18(options.importFromPrivateKey)(value)),
1827
+ wipe: () => run(() => unref18(options.wipe)()),
1828
+ setActiveNamespace: (value) => unref18(options.setActiveNamespace)(value),
1829
+ backfillAccounts: () => run(() => unref18(options.backfillAccounts)()),
1830
+ getSeedPhrase: () => unref18(options.getSeedPhrase)(),
1831
+ getPrivateKey: () => unref18(options.getPrivateKey)(),
1832
+ confirmBackup: () => unref18(options.confirmBackup)(),
1833
+ isBusy: guard.busy,
1834
+ error: guard.error,
1835
+ clearError: guard.clearError
1836
+ };
1837
+ }
1838
+
1839
+ // src/useSIWxLogin.ts
1840
+ function useSIWxLogin(action) {
1841
+ const state = useSignInWithX(action);
1842
+ return {
1843
+ signIn: state.signIn,
1844
+ isSigningIn: state.isSigningIn,
1845
+ error: state.error,
1846
+ clearError: state.clearError
1847
+ };
1848
+ }
1849
+
1850
+ // src/useSIWxSession.ts
1851
+ import { computed as computed16, toValue as toValue19, unref as unref19 } from "vue";
1852
+ function useSIWxSession(options) {
1853
+ const guard = useActionGuard();
1854
+ return {
1855
+ session: computed16(() => toValue19(options.session)),
1856
+ isAuthenticated: computed16(
1857
+ () => toValue19(options.session) !== null && !toValue19(options.isExpired)
1858
+ ),
1859
+ isRestoring: computed16(() => toValue19(options.isRestoring)),
1860
+ isSigningIn: guard.busy,
1861
+ isExpired: computed16(() => toValue19(options.isExpired)),
1862
+ timeUntilExpiry: computed16(() => toValue19(options.timeUntilExpiry)),
1863
+ signIn: (input) => guard.run(() => unref19(options.signIn)(input), "SIWX sign-in failed"),
1864
+ signOut: async () => {
1865
+ await unref19(options.signOut)();
1866
+ guard.clearError();
1867
+ },
1868
+ refresh: () => guard.run(() => unref19(options.refresh)(), "Session refresh failed"),
1869
+ error: guard.error,
1870
+ clearError: guard.clearError
1871
+ };
1872
+ }
1873
+
1874
+ // src/useSiwxAuthSession.ts
1875
+ import { computed as computed17, toValue as toValue20, unref as unref20 } from "vue";
1876
+ function useSiwxAuthSession(options) {
1877
+ const guard = useActionGuard();
1878
+ const signIn = (input) => guard.run(() => unref20(options.signIn)(input), "SIWX sign-in failed");
1879
+ const signOut = async () => {
1880
+ guard.reset();
1881
+ await unref20(options.signOut)();
1882
+ guard.clearError();
1883
+ };
1884
+ const siwxResult = computed17(() => toValue20(options.result));
1885
+ return {
1886
+ isSignedIn: computed17(() => siwxResult.value !== null),
1887
+ isRestoring: computed17(() => toValue20(options.isRestoring)),
1888
+ siwxResult,
1889
+ isSigningIn: guard.busy,
1890
+ error: guard.error,
1891
+ signIn,
1892
+ signOut,
1893
+ clearError: guard.clearError
463
1894
  };
464
1895
  }
465
1896
 
466
1897
  // src/useBalance.ts
467
- import { bareEvmAddress } from "@naculus/connect-appkit-core";
468
- import { formatUnits } from "@naculus/connect-core";
469
- import { computed as computed7, onScopeDispose as onScopeDispose5, shallowRef as shallowRef6, toValue as toValue7, watch as watch2 } from "vue";
1898
+ import { bareEvmAddress as bareEvmAddress5 } from "@naculus/connect-appkit-core";
1899
+ import { formatUnits as formatUnits2 } from "@naculus/connect-core";
1900
+ import { computed as computed18, onScopeDispose as onScopeDispose14, shallowRef as shallowRef17, toValue as toValue21, watch as watch8 } from "vue";
470
1901
  function useBalance(account, client, options = {}) {
471
- const balance = shallowRef6(null);
472
- const isFetching = shallowRef6(false);
473
- const error = shallowRef6(null);
1902
+ const balance = shallowRef17(null);
1903
+ const isFetching = shallowRef17(false);
1904
+ const error = shallowRef17(null);
474
1905
  let generation = 0;
475
1906
  let disposed = false;
476
1907
  let timer = null;
477
1908
  const refetch = async () => {
478
- const reader = toValue7(client);
479
- const address = bareEvmAddress(toValue7(account));
1909
+ const reader = toValue21(client);
1910
+ const address = bareEvmAddress5(toValue21(account));
480
1911
  const own = ++generation;
481
1912
  if (!reader || !address) {
482
1913
  balance.value = null;
@@ -502,11 +1933,11 @@ function useBalance(account, client, options = {}) {
502
1933
  if (timer) clearInterval(timer);
503
1934
  timer = null;
504
1935
  };
505
- watch2(
1936
+ watch8(
506
1937
  [
507
- () => toValue7(account),
508
- () => toValue7(client),
509
- () => toValue7(options.refreshInterval) ?? 0
1938
+ () => toValue21(account),
1939
+ () => toValue21(client),
1940
+ () => toValue21(options.refreshInterval) ?? 0
510
1941
  ],
511
1942
  ([, , interval]) => {
512
1943
  stopTimer();
@@ -515,17 +1946,17 @@ function useBalance(account, client, options = {}) {
515
1946
  },
516
1947
  { immediate: true }
517
1948
  );
518
- onScopeDispose5(() => {
1949
+ onScopeDispose14(() => {
519
1950
  disposed = true;
520
1951
  generation++;
521
1952
  stopTimer();
522
1953
  });
523
1954
  return {
524
1955
  balance,
525
- formatted: computed7(
526
- () => balance.value === null ? null : formatUnits(BigInt(balance.value), toValue7(options.decimals) ?? 18)
1956
+ formatted: computed18(
1957
+ () => balance.value === null ? null : formatUnits2(BigInt(balance.value), toValue21(options.decimals) ?? 18)
527
1958
  ),
528
- symbol: computed7(() => toValue7(options.symbol) ?? null),
1959
+ symbol: computed18(() => toValue21(options.symbol) ?? null),
529
1960
  isFetching,
530
1961
  error,
531
1962
  refetch
@@ -536,11 +1967,11 @@ function useBalance(account, client, options = {}) {
536
1967
  import {
537
1968
  isQuotableInput
538
1969
  } from "@naculus/connect-appkit-core";
539
- import { onScopeDispose as onScopeDispose6, shallowRef as shallowRef7, toValue as toValue8, unref as unref5, watch as watch3 } from "vue";
1970
+ import { onScopeDispose as onScopeDispose15, shallowRef as shallowRef18, toValue as toValue22, unref as unref21, watch as watch9 } from "vue";
540
1971
  function useRouteQuote(input, getQuotes, options = {}) {
541
- const quotes = shallowRef7([]);
542
- const loading = shallowRef7(false);
543
- const error = shallowRef7(null);
1972
+ const quotes = shallowRef18([]);
1973
+ const loading = shallowRef18(false);
1974
+ const error = shallowRef18(null);
544
1975
  let generation = 0;
545
1976
  let disposed = false;
546
1977
  let timer = null;
@@ -549,8 +1980,8 @@ function useRouteQuote(input, getQuotes, options = {}) {
549
1980
  timer = null;
550
1981
  };
551
1982
  const fetchQuotes = async () => {
552
- const current = toValue8(input);
553
- const fn = unref5(getQuotes);
1983
+ const current = toValue22(input);
1984
+ const fn = unref21(getQuotes);
554
1985
  const own = ++generation;
555
1986
  if (!isQuotableInput(current)) {
556
1987
  quotes.value = [];
@@ -578,14 +2009,14 @@ function useRouteQuote(input, getQuotes, options = {}) {
578
2009
  if (!disposed && own === generation) loading.value = false;
579
2010
  }
580
2011
  };
581
- watch3(
2012
+ watch9(
582
2013
  [
583
- () => toValue8(input).fromChain,
584
- () => toValue8(input).toChain,
585
- () => toValue8(input).fromToken,
586
- () => toValue8(input).toToken,
587
- () => toValue8(input).amount,
588
- () => unref5(getQuotes)
2014
+ () => toValue22(input).fromChain,
2015
+ () => toValue22(input).toChain,
2016
+ () => toValue22(input).fromToken,
2017
+ () => toValue22(input).toToken,
2018
+ () => toValue22(input).amount,
2019
+ () => unref21(getQuotes)
589
2020
  ],
590
2021
  ([fromChain, toChain, fromToken, , amount]) => {
591
2022
  clearTimer();
@@ -600,7 +2031,7 @@ function useRouteQuote(input, getQuotes, options = {}) {
600
2031
  },
601
2032
  { immediate: true }
602
2033
  );
603
- onScopeDispose6(() => {
2034
+ onScopeDispose15(() => {
604
2035
  disposed = true;
605
2036
  generation++;
606
2037
  clearTimer();
@@ -624,16 +2055,16 @@ function useRouteQuote(input, getQuotes, options = {}) {
624
2055
  import {
625
2056
  compareCostsKey
626
2057
  } from "@naculus/connect-appkit-core";
627
- import { onScopeDispose as onScopeDispose7, shallowRef as shallowRef8, toValue as toValue9, unref as unref6, watch as watch4 } from "vue";
2058
+ import { onScopeDispose as onScopeDispose16, shallowRef as shallowRef19, toValue as toValue23, unref as unref22, watch as watch10 } from "vue";
628
2059
  function useCompareCosts(input, compareCosts) {
629
- const comparisons = shallowRef8([]);
630
- const loading = shallowRef8(false);
631
- const error = shallowRef8(null);
2060
+ const comparisons = shallowRef19([]);
2061
+ const loading = shallowRef19(false);
2062
+ const error = shallowRef19(null);
632
2063
  let generation = 0;
633
2064
  let disposed = false;
634
2065
  const fetchComparisons = async () => {
635
- const { operation, chains, options } = toValue9(input);
636
- const fn = unref6(compareCosts);
2066
+ const { operation, chains, options } = toValue23(input);
2067
+ const fn = unref22(compareCosts);
637
2068
  const own = ++generation;
638
2069
  if (!chains || chains.length === 0) {
639
2070
  comparisons.value = [];
@@ -654,14 +2085,14 @@ function useCompareCosts(input, compareCosts) {
654
2085
  if (!disposed && own === generation) loading.value = false;
655
2086
  }
656
2087
  };
657
- watch4(
658
- [() => compareCostsKey(toValue9(input)), () => unref6(compareCosts)],
2088
+ watch10(
2089
+ [() => compareCostsKey(toValue23(input)), () => unref22(compareCosts)],
659
2090
  () => {
660
2091
  void fetchComparisons();
661
2092
  },
662
2093
  { immediate: true }
663
2094
  );
664
- onScopeDispose7(() => {
2095
+ onScopeDispose16(() => {
665
2096
  disposed = true;
666
2097
  generation++;
667
2098
  });
@@ -673,15 +2104,15 @@ import {
673
2104
  toExecuteRouteError,
674
2105
  validateRouteRecipient
675
2106
  } from "@naculus/connect-appkit-core";
676
- import { onScopeDispose as onScopeDispose8, shallowRef as shallowRef9, unref as unref7 } from "vue";
2107
+ import { onScopeDispose as onScopeDispose17, shallowRef as shallowRef20, unref as unref23 } from "vue";
677
2108
  function useExecuteRoute(executeRoute) {
678
- const executing = shallowRef9(false);
679
- const result = shallowRef9(null);
680
- const error = shallowRef9(null);
2109
+ const executing = shallowRef20(false);
2110
+ const result = shallowRef20(null);
2111
+ const error = shallowRef20(null);
681
2112
  let inFlight = false;
682
2113
  let disposed = false;
683
2114
  const execute = async (quote, recipient, options) => {
684
- const fn = unref7(executeRoute);
2115
+ const fn = unref23(executeRoute);
685
2116
  if (!fn) {
686
2117
  error.value = {
687
2118
  code: "no_executor",
@@ -719,7 +2150,7 @@ function useExecuteRoute(executeRoute) {
719
2150
  if (!disposed) executing.value = false;
720
2151
  }
721
2152
  };
722
- onScopeDispose8(() => {
2153
+ onScopeDispose17(() => {
723
2154
  disposed = true;
724
2155
  });
725
2156
  return {
@@ -740,19 +2171,19 @@ import { eip155ChainIdToNumber } from "@naculus/connect-appkit-core";
740
2171
  import {
741
2172
  TokenListManager
742
2173
  } from "@naculus/connect-core";
743
- import { onScopeDispose as onScopeDispose9, shallowRef as shallowRef10, toValue as toValue10, watch as watch5 } from "vue";
2174
+ import { onScopeDispose as onScopeDispose18, shallowRef as shallowRef21, toValue as toValue24, watch as watch11 } from "vue";
744
2175
  function useTokenList(chainId, options = {}) {
745
2176
  const config = {};
746
2177
  if (options.sources) config.sources = options.sources;
747
2178
  const manager = options.manager ?? new TokenListManager(config);
748
- const tokens = shallowRef10([]);
749
- const isLoading = shallowRef10(options.autoLoad !== false);
750
- const isLoaded = shallowRef10(false);
751
- const error = shallowRef10(null);
2179
+ const tokens = shallowRef21([]);
2180
+ const isLoading = shallowRef21(options.autoLoad !== false);
2181
+ const isLoaded = shallowRef21(false);
2182
+ const error = shallowRef21(null);
752
2183
  let generation = 0;
753
2184
  let disposed = false;
754
2185
  const select = () => {
755
- const id = toValue10(chainId);
2186
+ const id = toValue24(chainId);
756
2187
  const numeric = id ? eip155ChainIdToNumber(id) : void 0;
757
2188
  return manager.getTokens(
758
2189
  numeric !== void 0 ? { chainId: numeric } : void 0
@@ -774,14 +2205,14 @@ function useTokenList(chainId, options = {}) {
774
2205
  if (!disposed && own === generation) isLoading.value = false;
775
2206
  }
776
2207
  };
777
- watch5(
778
- () => toValue10(chainId),
2208
+ watch11(
2209
+ () => toValue24(chainId),
779
2210
  () => {
780
2211
  if (options.autoLoad !== false) void run(() => manager.load());
781
2212
  },
782
2213
  { immediate: true }
783
2214
  );
784
- onScopeDispose9(() => {
2215
+ onScopeDispose18(() => {
785
2216
  disposed = true;
786
2217
  generation++;
787
2218
  });
@@ -799,7 +2230,7 @@ import { eip155ChainIdToNumber as eip155ChainIdToNumber2 } from "@naculus/connec
799
2230
  import {
800
2231
  TokenListManager as TokenListManager2
801
2232
  } from "@naculus/connect-core";
802
- import { onScopeDispose as onScopeDispose10, shallowRef as shallowRef11, toValue as toValue11, watch as watch6 } from "vue";
2233
+ import { onScopeDispose as onScopeDispose19, shallowRef as shallowRef22, toValue as toValue25, watch as watch12 } from "vue";
803
2234
  var DEBOUNCE_MS = 300;
804
2235
  var EMPTY = { exact: [], fuzzy: [], hasMore: false };
805
2236
  var sharedManager = null;
@@ -812,15 +2243,15 @@ function getSharedManager() {
812
2243
  return sharedManager;
813
2244
  }
814
2245
  function useTokenSearch(query, chainId, options = {}) {
815
- const results = shallowRef11(EMPTY);
816
- const isSearching = shallowRef11(false);
2246
+ const results = shallowRef22(EMPTY);
2247
+ const isSearching = shallowRef22(false);
817
2248
  let timer = null;
818
2249
  const clear = () => {
819
2250
  if (timer) clearTimeout(timer);
820
2251
  timer = null;
821
2252
  };
822
- watch6(
823
- [() => (toValue11(query) ?? "").trim(), () => toValue11(chainId)],
2253
+ watch12(
2254
+ [() => (toValue25(query) ?? "").trim(), () => toValue25(chainId)],
824
2255
  ([q, id]) => {
825
2256
  clear();
826
2257
  if (!q) {
@@ -842,7 +2273,7 @@ function useTokenSearch(query, chainId, options = {}) {
842
2273
  },
843
2274
  { immediate: true }
844
2275
  );
845
- onScopeDispose10(clear);
2276
+ onScopeDispose19(clear);
846
2277
  return { results, isSearching };
847
2278
  }
848
2279
 
@@ -850,31 +2281,31 @@ function useTokenSearch(query, chainId, options = {}) {
850
2281
  import {
851
2282
  validateDestination
852
2283
  } from "@naculus/connect-appkit-core";
853
- import { computed as computed8, toValue as toValue12 } from "vue";
2284
+ import { computed as computed19, toValue as toValue26 } from "vue";
854
2285
  function useValidateDestination(address) {
855
2286
  return {
856
- validation: computed8(() => validateDestination(toValue12(address) ?? ""))
2287
+ validation: computed19(() => validateDestination(toValue26(address) ?? ""))
857
2288
  };
858
2289
  }
859
2290
 
860
2291
  // src/useTokenBalance.ts
861
- import { bareEvmAddress as bareEvmAddress2 } from "@naculus/connect-appkit-core";
862
- import { ERC20_MIN_ABI, formatUnits as formatUnits2 } from "@naculus/connect-core";
863
- import { onScopeDispose as onScopeDispose11, shallowRef as shallowRef12, toValue as toValue13, watch as watch7 } from "vue";
2292
+ import { bareEvmAddress as bareEvmAddress6 } from "@naculus/connect-appkit-core";
2293
+ import { ERC20_MIN_ABI as ERC20_MIN_ABI3, formatUnits as formatUnits3 } from "@naculus/connect-core";
2294
+ import { onScopeDispose as onScopeDispose20, shallowRef as shallowRef23, toValue as toValue27, watch as watch13 } from "vue";
864
2295
  function tokensKey(tokens) {
865
2296
  return tokens.map((t) => `${t.address.toLowerCase()}|${t.decimals}|${t.symbol}`).join(",");
866
2297
  }
867
2298
  function useTokenBalance(account, client, tokens, options = {}) {
868
- const tokenBalances = shallowRef12([]);
869
- const isFetching = shallowRef12(false);
870
- const error = shallowRef12(null);
2299
+ const tokenBalances = shallowRef23([]);
2300
+ const isFetching = shallowRef23(false);
2301
+ const error = shallowRef23(null);
871
2302
  let generation = 0;
872
2303
  let disposed = false;
873
2304
  let timer = null;
874
2305
  const refetch = async () => {
875
- const reader = toValue13(client);
876
- const address = bareEvmAddress2(toValue13(account));
877
- const list = toValue13(tokens) ?? [];
2306
+ const reader = toValue27(client);
2307
+ const address = bareEvmAddress6(toValue27(account));
2308
+ const list = toValue27(tokens) ?? [];
878
2309
  const own = ++generation;
879
2310
  if (!reader || !address || list.length === 0) {
880
2311
  tokenBalances.value = [];
@@ -890,7 +2321,7 @@ function useTokenBalance(account, client, tokens, options = {}) {
890
2321
  try {
891
2322
  const raw = await reader.readContract({
892
2323
  address: token.address,
893
- abi: ERC20_MIN_ABI,
2324
+ abi: ERC20_MIN_ABI3,
894
2325
  functionName: "balanceOf",
895
2326
  args: [address]
896
2327
  });
@@ -898,7 +2329,7 @@ function useTokenBalance(account, client, tokens, options = {}) {
898
2329
  return {
899
2330
  ...token,
900
2331
  balance: value.toString(),
901
- formatted: formatUnits2(value, token.decimals)
2332
+ formatted: formatUnits3(value, token.decimals)
902
2333
  };
903
2334
  } catch {
904
2335
  return { ...token, balance: null, formatted: null };
@@ -919,12 +2350,12 @@ function useTokenBalance(account, client, tokens, options = {}) {
919
2350
  if (timer) clearInterval(timer);
920
2351
  timer = null;
921
2352
  };
922
- watch7(
2353
+ watch13(
923
2354
  [
924
- () => toValue13(account),
925
- () => toValue13(client),
926
- () => tokensKey(toValue13(tokens) ?? []),
927
- () => toValue13(options.refreshInterval) ?? 0
2355
+ () => toValue27(account),
2356
+ () => toValue27(client),
2357
+ () => tokensKey(toValue27(tokens) ?? []),
2358
+ () => toValue27(options.refreshInterval) ?? 0
928
2359
  ],
929
2360
  ([, , , interval]) => {
930
2361
  stopTimer();
@@ -933,7 +2364,7 @@ function useTokenBalance(account, client, tokens, options = {}) {
933
2364
  },
934
2365
  { immediate: true }
935
2366
  );
936
- onScopeDispose11(() => {
2367
+ onScopeDispose20(() => {
937
2368
  disposed = true;
938
2369
  generation++;
939
2370
  stopTimer();
@@ -949,23 +2380,120 @@ function useTokenBalance(account, client, tokens, options = {}) {
949
2380
  };
950
2381
  }
951
2382
 
2383
+ // src/useDelegate.ts
2384
+ import { bareEvmAddress as bareEvmAddress7 } from "@naculus/connect-appkit-core";
2385
+ import {
2386
+ delegateAccount,
2387
+ eip155Reference,
2388
+ REVOKE_DELEGATE,
2389
+ WalletError as WalletError7
2390
+ } from "@naculus/connect-core";
2391
+ import { onScopeDispose as onScopeDispose21, shallowRef as shallowRef24, toValue as toValue28, watch as watch14 } from "vue";
2392
+ function useDelegate(options) {
2393
+ const result = shallowRef24(null);
2394
+ const isPending = shallowRef24(false);
2395
+ const error = shallowRef24(null);
2396
+ let requestId = 0;
2397
+ let inFlight = false;
2398
+ let disposed = false;
2399
+ const fail = (cause) => {
2400
+ error.value = cause;
2401
+ return null;
2402
+ };
2403
+ const run = async (target, allowlist) => {
2404
+ if (inFlight) return fail(new Error("A delegation is already in progress"));
2405
+ const session = toValue28(options.session);
2406
+ const account = bareEvmAddress7(toValue28(options.account));
2407
+ const chainId = toValue28(options.chainId);
2408
+ if (!session || !account || !chainId) {
2409
+ return fail(
2410
+ new WalletError7("wallet_unavailable", "No connected EVM account")
2411
+ );
2412
+ }
2413
+ const reader = toValue28(options.client);
2414
+ if (!reader || reader.chain?.id !== eip155Reference(chainId)) {
2415
+ return fail(
2416
+ new WalletError7(
2417
+ "chain_mismatch",
2418
+ `No RPC client for ${chainId}; refusing to read the nonce elsewhere.`
2419
+ )
2420
+ );
2421
+ }
2422
+ const connector = toValue28(options.connector) ?? {};
2423
+ const own = ++requestId;
2424
+ inFlight = true;
2425
+ isPending.value = true;
2426
+ error.value = null;
2427
+ result.value = null;
2428
+ try {
2429
+ const sent = await delegateAccount({
2430
+ connector,
2431
+ session,
2432
+ account,
2433
+ chainId,
2434
+ delegate: target,
2435
+ allowlist,
2436
+ getTransactionCount: (address, blockTag) => reader.getTransactionCount({ address, blockTag })
2437
+ });
2438
+ if (disposed || own !== requestId) return null;
2439
+ result.value = sent;
2440
+ return sent;
2441
+ } catch (cause) {
2442
+ if (disposed || own !== requestId) return null;
2443
+ return fail(
2444
+ cause instanceof Error ? cause : new Error("Failed to send delegation")
2445
+ );
2446
+ } finally {
2447
+ inFlight = false;
2448
+ if (!disposed && own === requestId) isPending.value = false;
2449
+ }
2450
+ };
2451
+ const reset = () => {
2452
+ requestId++;
2453
+ result.value = null;
2454
+ isPending.value = false;
2455
+ error.value = null;
2456
+ };
2457
+ watch14(
2458
+ [
2459
+ () => toValue28(options.session),
2460
+ () => toValue28(options.account),
2461
+ () => toValue28(options.chainId)
2462
+ ],
2463
+ reset,
2464
+ { flush: "sync" }
2465
+ );
2466
+ onScopeDispose21(() => {
2467
+ disposed = true;
2468
+ requestId++;
2469
+ });
2470
+ return {
2471
+ delegate: (target) => run(target, toValue28(options.allowlist)),
2472
+ revoke: () => run(REVOKE_DELEGATE, []),
2473
+ result,
2474
+ isPending,
2475
+ error,
2476
+ reset
2477
+ };
2478
+ }
2479
+
952
2480
  // src/useDelegation.ts
953
- import { bareEvmAddress as bareEvmAddress3 } from "@naculus/connect-appkit-core";
2481
+ import { bareEvmAddress as bareEvmAddress8 } from "@naculus/connect-appkit-core";
954
2482
  import {
955
2483
  readDelegation,
956
2484
  UNKNOWN_DELEGATION
957
2485
  } from "@naculus/connect-core";
958
- import { computed as computed9, onScopeDispose as onScopeDispose12, shallowRef as shallowRef13, toValue as toValue14, watch as watch8 } from "vue";
2486
+ import { computed as computed20, onScopeDispose as onScopeDispose22, shallowRef as shallowRef25, toValue as toValue29, watch as watch15 } from "vue";
959
2487
  function useDelegation(account, client, chainId) {
960
- const status = shallowRef13(UNKNOWN_DELEGATION);
961
- const isFetching = shallowRef13(false);
962
- const error = shallowRef13(null);
2488
+ const status = shallowRef25(UNKNOWN_DELEGATION);
2489
+ const isFetching = shallowRef25(false);
2490
+ const error = shallowRef25(null);
963
2491
  let generation = 0;
964
2492
  let disposed = false;
965
2493
  const refetch = async () => {
966
2494
  const mine = ++generation;
967
- const reader = toValue14(client);
968
- const address = bareEvmAddress3(toValue14(account));
2495
+ const reader = toValue29(client);
2496
+ const address = bareEvmAddress8(toValue29(account));
969
2497
  status.value = UNKNOWN_DELEGATION;
970
2498
  error.value = null;
971
2499
  if (!reader || !address) {
@@ -987,20 +2515,20 @@ function useDelegation(account, client, chainId) {
987
2515
  if (!disposed && mine === generation) isFetching.value = false;
988
2516
  }
989
2517
  };
990
- watch8(
991
- () => [toValue14(account), toValue14(client), toValue14(chainId)],
2518
+ watch15(
2519
+ [() => toValue29(account), () => toValue29(client), () => toValue29(chainId)],
992
2520
  () => {
993
2521
  void refetch();
994
2522
  },
995
2523
  { immediate: true, flush: "sync" }
996
2524
  );
997
- onScopeDispose12(() => {
2525
+ onScopeDispose22(() => {
998
2526
  disposed = true;
999
2527
  generation++;
1000
2528
  });
1001
2529
  return {
1002
- delegated: computed9(() => status.value.delegated),
1003
- delegate: computed9(() => status.value.delegate),
2530
+ delegated: computed20(() => status.value.delegated),
2531
+ delegate: computed20(() => status.value.delegate),
1004
2532
  isFetching,
1005
2533
  error,
1006
2534
  refetch
@@ -1009,18 +2537,18 @@ function useDelegation(account, client, chainId) {
1009
2537
 
1010
2538
  // src/name-lookup.ts
1011
2539
  import { getResolver } from "@naculus/connect-appkit-core";
1012
- import { computed as computed10, onScopeDispose as onScopeDispose13, shallowRef as shallowRef14, toValue as toValue15, watch as watch9 } from "vue";
2540
+ import { computed as computed21, onScopeDispose as onScopeDispose23, shallowRef as shallowRef26, toValue as toValue30, watch as watch16 } from "vue";
1013
2541
  function useNameLookup(options) {
1014
- const data = shallowRef14(null);
1015
- const loading = shallowRef14(false);
1016
- const error = shallowRef14(null);
2542
+ const data = shallowRef26(null);
2543
+ const loading = shallowRef26(false);
2544
+ const error = shallowRef26(null);
1017
2545
  let generation = 0;
1018
2546
  let disposed = false;
1019
2547
  const run = () => {
1020
- const input = toValue15(options.input).trim();
1021
- const skip = toValue15(options.skip) ?? false;
1022
- const scope = toValue15(options.scope);
1023
- const config = toValue15(options.resolverConfig);
2548
+ const input = toValue30(options.input).trim();
2549
+ const skip = toValue30(options.skip) ?? false;
2550
+ const scope = toValue30(options.scope);
2551
+ const config = toValue30(options.resolverConfig);
1024
2552
  const mine = ++generation;
1025
2553
  if (!input || skip) {
1026
2554
  data.value = null;
@@ -1042,23 +2570,23 @@ function useNameLookup(options) {
1042
2570
  loading.value = false;
1043
2571
  });
1044
2572
  };
1045
- watch9(
2573
+ watch16(
1046
2574
  () => [
1047
- toValue15(options.input),
1048
- toValue15(options.skip),
1049
- toValue15(options.scope),
1050
- toValue15(options.resolverConfig)
2575
+ toValue30(options.input),
2576
+ toValue30(options.skip),
2577
+ toValue30(options.scope),
2578
+ toValue30(options.resolverConfig)
1051
2579
  ],
1052
2580
  run,
1053
2581
  { immediate: true, flush: "sync", deep: true }
1054
2582
  );
1055
- onScopeDispose13(() => {
2583
+ onScopeDispose23(() => {
1056
2584
  disposed = true;
1057
2585
  generation++;
1058
2586
  });
1059
2587
  return {
1060
2588
  data,
1061
- isLoading: computed10(() => loading.value),
2589
+ isLoading: computed21(() => loading.value),
1062
2590
  error,
1063
2591
  refetch: run
1064
2592
  };
@@ -1086,21 +2614,21 @@ function useLookupAddress(address, options) {
1086
2614
  }
1087
2615
 
1088
2616
  // src/useSolanaAccount.ts
1089
- import { computed as computed11, toValue as toValue16 } from "vue";
2617
+ import { computed as computed22, toValue as toValue31 } from "vue";
1090
2618
  function useSolanaAccount(accounts, connected) {
1091
- const isConnected = computed11(() => toValue16(connected));
1092
- const caip10 = computed11(
1093
- () => isConnected.value ? (toValue16(accounts) ?? []).find(
2619
+ const isConnected = computed22(() => toValue31(connected));
2620
+ const caip10 = computed22(
2621
+ () => isConnected.value ? (toValue31(accounts) ?? []).find(
1094
2622
  (account) => account.startsWith("solana:")
1095
2623
  ) ?? null : null
1096
2624
  );
1097
- const parts = computed11(() => caip10.value?.split(":") ?? []);
2625
+ const parts = computed22(() => caip10.value?.split(":") ?? []);
1098
2626
  return {
1099
- address: computed11(
2627
+ address: computed22(
1100
2628
  () => parts.value.length >= 3 ? parts.value.at(-1) ?? null : null
1101
2629
  ),
1102
2630
  caip10,
1103
- chainId: computed11(
2631
+ chainId: computed22(
1104
2632
  () => parts.value.length >= 3 ? parts.value.slice(0, -1).join(":") : null
1105
2633
  ),
1106
2634
  isConnected
@@ -1110,37 +2638,37 @@ function useSolanaAccount(accounts, connected) {
1110
2638
  // src/useChain.ts
1111
2639
  import {
1112
2640
  chainNamespace,
1113
- chainNumber,
2641
+ chainNumber as chainNumber2,
1114
2642
  chainsForNamespace,
1115
2643
  describeChain,
1116
2644
  resolveChain
1117
2645
  } from "@naculus/connect-appkit-core";
1118
- import { computed as computed12, toValue as toValue17 } from "vue";
2646
+ import { computed as computed23, toValue as toValue32 } from "vue";
1119
2647
  function useChain(chains, chainId) {
1120
- const list = computed12(() => toValue17(chains) ?? []);
1121
- const id = computed12(() => toValue17(chainId) ?? null);
1122
- const currentChain = computed12(() => resolveChain(list.value, id.value));
2648
+ const list = computed23(() => toValue32(chains) ?? []);
2649
+ const id = computed23(() => toValue32(chainId) ?? null);
2650
+ const currentChain = computed23(() => resolveChain(list.value, id.value));
1123
2651
  return {
1124
2652
  currentChain,
1125
- chainInfo: computed12(() => describeChain(list.value, id.value)),
1126
- availableChains: computed12(() => chainsForNamespace(list.value, id.value)),
1127
- currentChainNumber: computed12(
1128
- () => currentChain.value ? chainNumber(currentChain.value) : null
2653
+ chainInfo: computed23(() => describeChain(list.value, id.value)),
2654
+ availableChains: computed23(() => chainsForNamespace(list.value, id.value)),
2655
+ currentChainNumber: computed23(
2656
+ () => currentChain.value ? chainNumber2(currentChain.value) : null
1129
2657
  ),
1130
- namespace: computed12(
2658
+ namespace: computed23(
1131
2659
  () => currentChain.value ? chainNamespace(currentChain.value) : null
1132
2660
  )
1133
2661
  };
1134
2662
  }
1135
2663
 
1136
2664
  // src/usePassphraseGate.ts
1137
- import { onScopeDispose as onScopeDispose14, readonly, shallowRef as shallowRef15 } from "vue";
2665
+ import { onScopeDispose as onScopeDispose24, readonly, shallowRef as shallowRef27 } from "vue";
1138
2666
  function usePassphraseGate(gate) {
1139
- const request = shallowRef15(gate.getSnapshot());
2667
+ const request = shallowRef27(gate.getSnapshot());
1140
2668
  const unsubscribe = gate.subscribe(() => {
1141
2669
  request.value = gate.getSnapshot();
1142
2670
  });
1143
- onScopeDispose14(unsubscribe);
2671
+ onScopeDispose24(unsubscribe);
1144
2672
  return {
1145
2673
  request: readonly(request),
1146
2674
  submit: (passphrase) => gate.submit(passphrase),
@@ -1153,16 +2681,16 @@ function usePassphraseGate(gate) {
1153
2681
  import {
1154
2682
  getSolanaBalance
1155
2683
  } from "@naculus/connect-core";
1156
- import { onScopeDispose as onScopeDispose15, ref, shallowRef as shallowRef16, toValue as toValue18, watchEffect } from "vue";
2684
+ import { onScopeDispose as onScopeDispose25, ref, shallowRef as shallowRef28, toValue as toValue33, watchEffect } from "vue";
1157
2685
  function useSolanaBalance(address, rpcUrl) {
1158
- const balance = shallowRef16(null);
2686
+ const balance = shallowRef28(null);
1159
2687
  const isFetching = ref(false);
1160
- const error = shallowRef16(null);
2688
+ const error = shallowRef28(null);
1161
2689
  let generation = 0;
1162
2690
  let disposed = false;
1163
2691
  const refetch = async () => {
1164
- const addr = toValue18(address);
1165
- const url = toValue18(rpcUrl);
2692
+ const addr = toValue33(address);
2693
+ const url = toValue33(rpcUrl);
1166
2694
  if (!addr || !url) {
1167
2695
  balance.value = null;
1168
2696
  return;
@@ -1183,24 +2711,24 @@ function useSolanaBalance(address, rpcUrl) {
1183
2711
  }
1184
2712
  };
1185
2713
  watchEffect(() => {
1186
- toValue18(address);
1187
- toValue18(rpcUrl);
2714
+ toValue33(address);
2715
+ toValue33(rpcUrl);
1188
2716
  void refetch();
1189
2717
  });
1190
- onScopeDispose15(() => {
2718
+ onScopeDispose25(() => {
1191
2719
  disposed = true;
1192
2720
  });
1193
2721
  return { balance, isFetching, error, refetch };
1194
2722
  }
1195
2723
 
1196
2724
  // src/useLastTx.ts
1197
- import { shallowRef as shallowRef17, toValue as toValue19, watch as watch10 } from "vue";
2725
+ import { shallowRef as shallowRef29, toValue as toValue34, watch as watch17 } from "vue";
1198
2726
  function useLastTx(monitor) {
1199
- const lastTx = shallowRef17(null);
1200
- const lastConfirmedTx = shallowRef17(null);
1201
- const lastFailedTx = shallowRef17(null);
1202
- watch10(
1203
- () => toValue19(monitor),
2727
+ const lastTx = shallowRef29(null);
2728
+ const lastConfirmedTx = shallowRef29(null);
2729
+ const lastFailedTx = shallowRef29(null);
2730
+ watch17(
2731
+ () => toValue34(monitor),
1204
2732
  (activeMonitor, _previous, onCleanup) => {
1205
2733
  if (!activeMonitor) return;
1206
2734
  const recordLatest = (entry) => {
@@ -1238,15 +2766,15 @@ function useLastTx(monitor) {
1238
2766
  }
1239
2767
 
1240
2768
  // src/useTxHistory.ts
1241
- import { computed as computed13, shallowRef as shallowRef18, toValue as toValue20, watch as watch11 } from "vue";
2769
+ import { computed as computed24, shallowRef as shallowRef30, toValue as toValue35, watch as watch18 } from "vue";
1242
2770
  function useTxHistory(address, chainId, monitor) {
1243
- const entries = shallowRef18([]);
1244
- const isLoading = shallowRef18(false);
1245
- const error = shallowRef18(null);
2771
+ const entries = shallowRef30([]);
2772
+ const isLoading = shallowRef30(false);
2773
+ const error = shallowRef30(null);
1246
2774
  let generation = 0;
1247
2775
  const refresh = async () => {
1248
2776
  const mine = ++generation;
1249
- const activeMonitor = toValue20(monitor);
2777
+ const activeMonitor = toValue35(monitor);
1250
2778
  if (!activeMonitor) {
1251
2779
  entries.value = [];
1252
2780
  isLoading.value = false;
@@ -1257,8 +2785,8 @@ function useTxHistory(address, chainId, monitor) {
1257
2785
  error.value = null;
1258
2786
  try {
1259
2787
  const result = await activeMonitor.getTxHistory(
1260
- toValue20(address) ?? void 0,
1261
- toValue20(chainId) ?? void 0
2788
+ toValue35(address) ?? void 0,
2789
+ toValue35(chainId) ?? void 0
1262
2790
  );
1263
2791
  if (mine === generation) entries.value = result;
1264
2792
  } catch (err) {
@@ -1268,8 +2796,8 @@ function useTxHistory(address, chainId, monitor) {
1268
2796
  if (mine === generation) isLoading.value = false;
1269
2797
  }
1270
2798
  };
1271
- watch11(
1272
- () => [toValue20(monitor), toValue20(address), toValue20(chainId)],
2799
+ watch18(
2800
+ [() => toValue35(monitor), () => toValue35(address), () => toValue35(chainId)],
1273
2801
  ([activeMonitor], _previous, onCleanup) => {
1274
2802
  if (!activeMonitor) {
1275
2803
  void refresh();
@@ -1289,7 +2817,7 @@ function useTxHistory(address, chainId, monitor) {
1289
2817
  isLoading,
1290
2818
  error,
1291
2819
  refresh,
1292
- summary: computed13(() => ({
2820
+ summary: computed24(() => ({
1293
2821
  pending: entries.value.filter((item) => item.status === "pending").length,
1294
2822
  confirmed: entries.value.filter((item) => item.status === "confirmed").length,
1295
2823
  failed: entries.value.filter((item) => item.status === "failed").length
@@ -1298,22 +2826,17 @@ function useTxHistory(address, chainId, monitor) {
1298
2826
  }
1299
2827
 
1300
2828
  // src/useTxMonitor.ts
1301
- import {
1302
- computed as computed14,
1303
- shallowRef as shallowRef19,
1304
- toValue as toValue21,
1305
- watch as watch12
1306
- } from "vue";
2829
+ import { computed as computed25, shallowRef as shallowRef31, toValue as toValue36, watch as watch19 } from "vue";
1307
2830
  function useTxMonitor(hash, chainId, monitor) {
1308
- const entry = shallowRef19(null);
1309
- const isLoading = shallowRef19(false);
1310
- const isWatching = shallowRef19(false);
1311
- const error = shallowRef19(null);
2831
+ const entry = shallowRef31(null);
2832
+ const isLoading = shallowRef31(false);
2833
+ const isWatching = shallowRef31(false);
2834
+ const error = shallowRef31(null);
1312
2835
  let generation = 0;
1313
2836
  const refresh = async () => {
1314
- const activeMonitor = toValue21(monitor);
1315
- const activeHash = toValue21(hash);
1316
- const activeChainId = toValue21(chainId);
2837
+ const activeMonitor = toValue36(monitor);
2838
+ const activeHash = toValue36(hash);
2839
+ const activeChainId = toValue36(chainId);
1317
2840
  if (!activeMonitor || !activeHash) return;
1318
2841
  isLoading.value = true;
1319
2842
  error.value = null;
@@ -1331,15 +2854,15 @@ function useTxMonitor(hash, chainId, monitor) {
1331
2854
  }
1332
2855
  };
1333
2856
  const stopWatching = () => {
1334
- const activeMonitor = toValue21(monitor);
1335
- const activeHash = toValue21(hash);
1336
- const activeChainId = toValue21(chainId);
2857
+ const activeMonitor = toValue36(monitor);
2858
+ const activeHash = toValue36(hash);
2859
+ const activeChainId = toValue36(chainId);
1337
2860
  if (!activeMonitor || !activeHash) return;
1338
2861
  activeMonitor.stopWatching(activeHash, activeChainId ?? void 0);
1339
2862
  isWatching.value = false;
1340
2863
  };
1341
- watch12(
1342
- () => [toValue21(monitor), toValue21(hash), toValue21(chainId)],
2864
+ watch19(
2865
+ [() => toValue36(monitor), () => toValue36(hash), () => toValue36(chainId)],
1343
2866
  ([activeMonitor, activeHash, activeChainId], _previous, onCleanup) => {
1344
2867
  const mine = ++generation;
1345
2868
  if (!activeMonitor || !activeHash || !activeChainId) {
@@ -1379,7 +2902,7 @@ function useTxMonitor(hash, chainId, monitor) {
1379
2902
  );
1380
2903
  return {
1381
2904
  entry,
1382
- status: computed14(() => entry.value?.status ?? "idle"),
2905
+ status: computed25(() => entry.value?.status ?? "idle"),
1383
2906
  isLoading,
1384
2907
  isWatching,
1385
2908
  error,
@@ -1394,18 +2917,18 @@ import {
1394
2917
  normalizeCapabilities,
1395
2918
  selectChainCapabilities
1396
2919
  } from "@naculus/connect-appkit-core";
1397
- import { computed as computed15, shallowRef as shallowRef20, toValue as toValue22, watchEffect as watchEffect2 } from "vue";
2920
+ import { computed as computed26, shallowRef as shallowRef32, toValue as toValue37, watchEffect as watchEffect2 } from "vue";
1398
2921
  function useCapabilities(client, session, chainId) {
1399
- const capabilities = shallowRef20(
2922
+ const capabilities = shallowRef32(
1400
2923
  null
1401
2924
  );
1402
- const isFetching = shallowRef20(false);
1403
- const error = shallowRef20(null);
2925
+ const isFetching = shallowRef32(false);
2926
+ const error = shallowRef32(null);
1404
2927
  let generation = 0;
1405
2928
  const refetch = async () => {
1406
2929
  const mine = ++generation;
1407
- const activeClient = toValue22(client);
1408
- const activeSession = toValue22(session);
2930
+ const activeClient = toValue37(client);
2931
+ const activeSession = toValue37(session);
1409
2932
  if (!activeClient?.getCapabilities || !activeSession) {
1410
2933
  capabilities.value = null;
1411
2934
  isFetching.value = false;
@@ -1427,17 +2950,17 @@ function useCapabilities(client, session, chainId) {
1427
2950
  }
1428
2951
  };
1429
2952
  watchEffect2(() => {
1430
- void toValue22(client);
1431
- void toValue22(session);
2953
+ void toValue37(client);
2954
+ void toValue37(session);
1432
2955
  void refetch();
1433
2956
  });
1434
2957
  return {
1435
2958
  capabilities,
1436
- current: computed15(
1437
- () => selectChainCapabilities(capabilities.value, toValue22(chainId))
2959
+ current: computed26(
2960
+ () => selectChainCapabilities(capabilities.value, toValue37(chainId))
1438
2961
  ),
1439
- atomic: computed15(
1440
- () => atomicSupportFor(capabilities.value, toValue22(chainId))
2962
+ atomic: computed26(
2963
+ () => atomicSupportFor(capabilities.value, toValue37(chainId))
1441
2964
  ),
1442
2965
  isFetching,
1443
2966
  error,
@@ -1449,17 +2972,17 @@ function useCapabilities(client, session, chainId) {
1449
2972
  import {
1450
2973
  readSolanaRoles
1451
2974
  } from "@naculus/connect-appkit-core";
1452
- import { computed as computed16, toValue as toValue23 } from "vue";
2975
+ import { computed as computed27, toValue as toValue38 } from "vue";
1453
2976
  function useSolanaRoles(connector, session) {
1454
- const state = computed16(
1455
- () => readSolanaRoles(toValue23(connector), toValue23(session))
2977
+ const state = computed27(
2978
+ () => readSolanaRoles(toValue38(connector), toValue38(session))
1456
2979
  );
1457
2980
  return {
1458
- roles: computed16(() => state.value.roles),
1459
- absence: computed16(() => state.value.absence),
1460
- identity: computed16(() => state.value.roles?.identity ?? null),
1461
- signer: computed16(() => state.value.roles?.signer ?? null),
1462
- payer: computed16(() => state.value.roles?.payer ?? null)
2981
+ roles: computed27(() => state.value.roles),
2982
+ absence: computed27(() => state.value.absence),
2983
+ identity: computed27(() => state.value.roles?.identity ?? null),
2984
+ signer: computed27(() => state.value.roles?.signer ?? null),
2985
+ payer: computed27(() => state.value.roles?.payer ?? null)
1463
2986
  };
1464
2987
  }
1465
2988
  export {
@@ -1498,25 +3021,50 @@ export {
1498
3021
  useChain,
1499
3022
  useCompareCosts,
1500
3023
  useConnect,
3024
+ useCreateSessionKey,
3025
+ useDelegate,
1501
3026
  useDelegation,
3027
+ useDelegationPolicy,
1502
3028
  useDisconnect,
3029
+ useERC20Approve,
3030
+ useERC20Transfer,
3031
+ useERC20TransferSimulation,
3032
+ useEmbeddedWallet,
3033
+ useExecuteCalls,
1503
3034
  useExecuteRoute,
1504
3035
  useLastTx,
1505
3036
  useLookupAddress,
1506
3037
  useNotification,
1507
3038
  usePassphraseGate,
1508
3039
  useResolveName,
3040
+ useRevokeSession,
1509
3041
  useRouteQuote,
3042
+ useSIWxLogin,
3043
+ useSIWxSession,
3044
+ useSendCalls,
3045
+ useSendTransaction,
3046
+ useSendUserOperation,
3047
+ useSendWithSession,
1510
3048
  useSession,
3049
+ useSessionKeys,
3050
+ useSignInWithEthereum,
3051
+ useSignInWithX,
3052
+ useSignMessage,
3053
+ useSimulateTransfer,
3054
+ useSiwxAuthSession,
3055
+ useSmartAccount,
1511
3056
  useSolanaAccount,
1512
3057
  useSolanaBalance,
1513
3058
  useSolanaRoles,
3059
+ useSolanaTransaction,
1514
3060
  useSwitchChain,
1515
3061
  useTokenBalance,
1516
3062
  useTokenList,
1517
3063
  useTokenSearch,
3064
+ useTransactionSimulation,
1518
3065
  useTxHistory,
1519
3066
  useTxMonitor,
3067
+ useUserOpStatus,
1520
3068
  useValidateDestination
1521
3069
  };
1522
3070
  //# sourceMappingURL=index.js.map