@naculus/connect-appkit-vue 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -80,6 +80,7 @@ __export(index_exports, {
80
80
  useLookupAddress: () => useLookupAddress,
81
81
  useNotification: () => useNotification,
82
82
  usePassphraseGate: () => usePassphraseGate,
83
+ usePaymentFetch: () => usePaymentFetch,
83
84
  useResolveName: () => useResolveName,
84
85
  useRevokeSession: () => useRevokeSession,
85
86
  useRouteQuote: () => useRouteQuote,
@@ -100,6 +101,7 @@ __export(index_exports, {
100
101
  useSolanaAccount: () => useSolanaAccount,
101
102
  useSolanaBalance: () => useSolanaBalance,
102
103
  useSolanaRoles: () => useSolanaRoles,
104
+ useSolanaSessionKey: () => useSolanaSessionKey,
103
105
  useSolanaTransaction: () => useSolanaTransaction,
104
106
  useSwitchChain: () => useSwitchChain,
105
107
  useTokenBalance: () => useTokenBalance,
@@ -393,110 +395,159 @@ function useNotification(options = {}) {
393
395
  // src/useSimulateTransfer.ts
394
396
  var import_connect_appkit_core2 = require("@naculus/connect-appkit-core");
395
397
  var import_connect_core3 = require("@naculus/connect-core");
398
+ var import_vue4 = require("vue");
399
+
400
+ // src/internal/action-guard.ts
396
401
  var import_vue3 = require("vue");
397
- function useSimulateTransfer(options = {}) {
398
- const result = (0, import_vue3.shallowRef)(null);
399
- const loading = (0, import_vue3.shallowRef)(false);
402
+ function useActionGuard() {
403
+ const busy = (0, import_vue3.shallowRef)(false);
400
404
  const error = (0, import_vue3.shallowRef)(null);
401
- let manager;
405
+ let active = 0;
402
406
  let generation = 0;
403
407
  let disposed = false;
404
- const simulate = async (tokenAddress, from, to, amount, callOptions) => {
408
+ const run = async (action, fallbackMessage, normalizeError, options = {}) => {
405
409
  const own = ++generation;
406
- loading.value = true;
407
- error.value = null;
410
+ const commit = (write) => {
411
+ if (!disposed && own === generation) write();
412
+ };
413
+ active++;
414
+ busy.value = true;
415
+ if (!options.keepError) error.value = null;
408
416
  try {
409
- const fallbackRpcUrl = (0, import_vue3.unref)(options.rpcUrl);
410
- const endpoint = (0, import_connect_appkit_core2.resolveSimulationEndpoint)(
411
- callOptions?.chainId,
412
- (0, import_vue3.unref)(options.chainId),
413
- callOptions?.rpcUrl,
414
- fallbackRpcUrl
415
- );
416
- manager ??= new import_connect_core3.SimulationManager({
417
- enabled: true,
418
- rpcUrl: fallbackRpcUrl,
419
- autoSimulate: false
420
- });
421
- const value = await manager.simulateERC20Transfer(
422
- tokenAddress,
423
- from,
424
- to,
425
- amount,
426
- endpoint.chainId,
427
- callOptions?.decimals,
428
- endpoint.rpcUrl
429
- );
430
- if (!disposed && own === generation) result.value = value;
431
- return value;
417
+ return await action(commit);
432
418
  } catch (cause) {
433
- const normalized = cause instanceof Error ? cause : new Error(String(cause));
419
+ const normalized = normalizeError ? normalizeError(cause) : cause instanceof Error ? cause : new Error(fallbackMessage);
434
420
  if (!disposed && own === generation) error.value = normalized;
435
421
  throw normalized;
436
422
  } finally {
437
- if (!disposed && own === generation) loading.value = false;
423
+ try {
424
+ if (options.onSettled) commit(options.onSettled);
425
+ } finally {
426
+ active--;
427
+ if (!disposed) busy.value = active > 0;
428
+ }
438
429
  }
439
430
  };
440
- const reset = () => {
431
+ const invalidate = () => {
441
432
  generation++;
442
- result.value = null;
433
+ };
434
+ const reset = () => {
435
+ invalidate();
436
+ error.value = null;
437
+ };
438
+ const clearError = () => {
443
439
  error.value = null;
444
- loading.value = false;
445
440
  };
446
- (0, import_vue3.onScopeDispose)(() => {
441
+ const dispose = () => {
447
442
  disposed = true;
448
443
  generation++;
449
- });
450
- return { result, loading, error, simulate, reset };
444
+ };
445
+ (0, import_vue3.onScopeDispose)(dispose);
446
+ return { busy, error, run, clearError, reset, invalidate, dispose };
447
+ }
448
+
449
+ // src/useSimulateTransfer.ts
450
+ function useSimulateTransfer(options = {}) {
451
+ const guard = useActionGuard();
452
+ const result = (0, import_vue4.shallowRef)(null);
453
+ const loading = (0, import_vue4.shallowRef)(false);
454
+ let manager;
455
+ const simulate = async (tokenAddress, from, to, amount, callOptions) => {
456
+ loading.value = true;
457
+ return await guard.run(
458
+ async (commit) => {
459
+ const fallbackRpcUrl = (0, import_vue4.unref)(options.rpcUrl);
460
+ const endpoint = (0, import_connect_appkit_core2.resolveSimulationEndpoint)(
461
+ callOptions?.chainId,
462
+ (0, import_vue4.unref)(options.chainId),
463
+ callOptions?.rpcUrl,
464
+ fallbackRpcUrl
465
+ );
466
+ manager ??= new import_connect_core3.SimulationManager({
467
+ enabled: true,
468
+ rpcUrl: fallbackRpcUrl,
469
+ autoSimulate: false
470
+ });
471
+ const value = await manager.simulateERC20Transfer(
472
+ tokenAddress,
473
+ from,
474
+ to,
475
+ amount,
476
+ endpoint.chainId,
477
+ callOptions?.decimals,
478
+ endpoint.rpcUrl
479
+ );
480
+ commit(() => {
481
+ result.value = value;
482
+ });
483
+ return value;
484
+ },
485
+ "Simulation failed",
486
+ (cause) => cause instanceof Error ? cause : new Error(String(cause)),
487
+ {
488
+ onSettled: () => {
489
+ loading.value = false;
490
+ }
491
+ }
492
+ );
493
+ };
494
+ const reset = () => {
495
+ guard.reset();
496
+ result.value = null;
497
+ loading.value = false;
498
+ };
499
+ return { result, loading, error: guard.error, simulate, reset };
451
500
  }
452
501
 
453
502
  // src/useTransactionSimulation.ts
454
503
  var import_connect_appkit_core3 = require("@naculus/connect-appkit-core");
455
- var import_vue4 = require("vue");
504
+ var import_vue5 = require("vue");
456
505
  function useTransactionSimulation(tx, options = {}) {
457
- const result = (0, import_vue4.shallowRef)(void 0);
458
- const isSimulating = (0, import_vue4.shallowRef)(false);
459
- const error = (0, import_vue4.shallowRef)(null);
506
+ const guard = useActionGuard();
507
+ const result = (0, import_vue5.shallowRef)(void 0);
508
+ const isSimulating = (0, import_vue5.shallowRef)(false);
460
509
  let timer;
461
- let generation = 0;
462
- let disposed = false;
463
510
  const simulate = async () => {
464
- const own = ++generation;
465
- const transaction = (0, import_vue4.toValue)(tx);
466
- if (transaction) {
467
- isSimulating.value = true;
468
- error.value = null;
469
- }
470
- try {
471
- const value = await (0, import_connect_appkit_core3.simulateTransactionPreview)(transaction, {
472
- chainId: (0, import_vue4.unref)(options.chainId),
473
- currentChain: (0, import_vue4.unref)(options.currentChain),
474
- publicClient: (0, import_vue4.unref)(options.publicClient),
475
- evmAccount: (0, import_vue4.unref)(options.evmAccount)
476
- });
477
- if (!disposed && own === generation) result.value = value;
478
- return value;
479
- } catch (cause) {
480
- const normalized = cause instanceof Error ? cause : new Error("Simulation failed");
481
- if (!disposed && own === generation) error.value = normalized;
482
- throw normalized;
483
- } finally {
484
- if (transaction && !disposed && own === generation)
485
- isSimulating.value = false;
486
- }
511
+ const transaction = (0, import_vue5.toValue)(tx);
512
+ if (transaction) isSimulating.value = true;
513
+ return await guard.run(
514
+ async (commit) => {
515
+ const value = await (0, import_connect_appkit_core3.simulateTransactionPreview)(transaction, {
516
+ chainId: (0, import_vue5.unref)(options.chainId),
517
+ currentChain: (0, import_vue5.unref)(options.currentChain),
518
+ publicClient: (0, import_vue5.unref)(options.publicClient),
519
+ evmAccount: (0, import_vue5.unref)(options.evmAccount)
520
+ });
521
+ commit(() => {
522
+ result.value = value;
523
+ });
524
+ return value;
525
+ },
526
+ "Simulation failed",
527
+ void 0,
528
+ {
529
+ keepError: !transaction,
530
+ onSettled: transaction ? () => {
531
+ isSimulating.value = false;
532
+ } : void 0
533
+ }
534
+ );
487
535
  };
488
- (0, import_vue4.watch)(
536
+ (0, import_vue5.watch)(
489
537
  [
490
- () => (0, import_vue4.toValue)(tx),
491
- () => (0, import_vue4.unref)(options.chainId),
492
- () => (0, import_vue4.unref)(options.currentChain),
493
- () => (0, import_vue4.unref)(options.publicClient),
494
- () => (0, import_vue4.unref)(options.evmAccount)
538
+ () => (0, import_vue5.toValue)(tx),
539
+ () => (0, import_vue5.unref)(options.chainId),
540
+ () => (0, import_vue5.unref)(options.currentChain),
541
+ () => (0, import_vue5.unref)(options.publicClient),
542
+ () => (0, import_vue5.unref)(options.evmAccount)
495
543
  ],
496
544
  ([transaction]) => {
497
- generation++;
545
+ guard.invalidate();
498
546
  if (timer) clearTimeout(timer);
499
- if (!transaction) return;
547
+ if (!transaction) {
548
+ isSimulating.value = false;
549
+ return;
550
+ }
500
551
  timer = setTimeout(() => {
501
552
  timer = void 0;
502
553
  void simulate().catch(() => {
@@ -506,23 +557,20 @@ function useTransactionSimulation(tx, options = {}) {
506
557
  { immediate: true }
507
558
  );
508
559
  const reset = () => {
509
- generation++;
560
+ guard.reset();
510
561
  result.value = void 0;
511
- error.value = null;
512
562
  isSimulating.value = false;
513
563
  };
514
- (0, import_vue4.onScopeDispose)(() => {
515
- disposed = true;
516
- generation++;
564
+ (0, import_vue5.onScopeDispose)(() => {
517
565
  if (timer) clearTimeout(timer);
518
566
  });
519
- return { result, isSimulating, error, simulate, reset };
567
+ return { result, isSimulating, error: guard.error, simulate, reset };
520
568
  }
521
569
 
522
570
  // src/useERC20Transfer.ts
523
571
  var import_connect_appkit_core5 = require("@naculus/connect-appkit-core");
524
572
  var import_connect_core5 = require("@naculus/connect-core");
525
- var import_vue5 = require("vue");
573
+ var import_vue6 = require("vue");
526
574
 
527
575
  // src/erc20.ts
528
576
  var import_connect_appkit_core4 = require("@naculus/connect-appkit-core");
@@ -542,22 +590,22 @@ function assertErc20Context(token, chainId, account, connected) {
542
590
 
543
591
  // src/useERC20Transfer.ts
544
592
  function useERC20Transfer(options) {
545
- const initialToken = (0, import_vue5.toValue)(options.token);
593
+ const initialToken = (0, import_vue6.toValue)(options.token);
546
594
  const decimals = (0, import_connect_appkit_core5.createDecimalsCache)(initialToken, initialToken.decimals);
547
- const isSending = (0, import_vue5.shallowRef)(false);
548
- const error = (0, import_vue5.shallowRef)(null);
595
+ const isSending = (0, import_vue6.shallowRef)(false);
596
+ const error = (0, import_vue6.shallowRef)(null);
549
597
  let generation = 0;
550
598
  let disposed = false;
551
- (0, import_vue5.watch)(
599
+ (0, import_vue6.watch)(
552
600
  [
553
- () => (0, import_vue5.toValue)(options.token).address,
554
- () => (0, import_vue5.toValue)(options.token).chainId,
555
- () => (0, import_vue5.toValue)(options.token).decimals,
556
- () => (0, import_vue5.toValue)(options.account),
557
- () => (0, import_vue5.toValue)(options.chainId),
558
- () => (0, import_vue5.toValue)(options.connected),
559
- () => (0, import_vue5.toValue)(options.publicClient),
560
- () => (0, import_vue5.unref)(options.sendTransaction)
601
+ () => (0, import_vue6.toValue)(options.token).address,
602
+ () => (0, import_vue6.toValue)(options.token).chainId,
603
+ () => (0, import_vue6.toValue)(options.token).decimals,
604
+ () => (0, import_vue6.toValue)(options.account),
605
+ () => (0, import_vue6.toValue)(options.chainId),
606
+ () => (0, import_vue6.toValue)(options.connected),
607
+ () => (0, import_vue6.toValue)(options.publicClient),
608
+ () => (0, import_vue6.unref)(options.sendTransaction)
561
609
  ],
562
610
  () => {
563
611
  generation++;
@@ -568,17 +616,17 @@ function useERC20Transfer(options) {
568
616
  );
569
617
  const sendTransfer = async (to, amount) => {
570
618
  const own = ++generation;
571
- const token = (0, import_vue5.toValue)(options.token);
572
- const reader = (0, import_vue5.toValue)(options.publicClient);
619
+ const token = (0, import_vue6.toValue)(options.token);
620
+ const reader = (0, import_vue6.toValue)(options.publicClient);
573
621
  const stillCurrent = () => !disposed && own === generation;
574
622
  error.value = null;
575
623
  isSending.value = true;
576
624
  try {
577
625
  assertErc20Context(
578
626
  token,
579
- (0, import_vue5.toValue)(options.chainId),
580
- (0, import_vue5.toValue)(options.account),
581
- (0, import_vue5.toValue)(options.connected)
627
+ (0, import_vue6.toValue)(options.chainId),
628
+ (0, import_vue6.toValue)(options.account),
629
+ (0, import_vue6.toValue)(options.connected)
582
630
  );
583
631
  if (!reader) {
584
632
  throw new import_connect_core5.WalletError(
@@ -604,7 +652,7 @@ function useERC20Transfer(options) {
604
652
  (0, import_connect_appkit_core5.writeDecimals)(decimals, token, precision);
605
653
  }
606
654
  const data = (0, import_connect_appkit_core5.encodeErc20Transfer)(to, (0, import_connect_core5.parseUnits)(amount, precision));
607
- return await (0, import_vue5.unref)(options.sendTransaction)({
655
+ return await (0, import_vue6.unref)(options.sendTransaction)({
608
656
  to: token.address,
609
657
  data,
610
658
  value: "0"
@@ -617,7 +665,7 @@ function useERC20Transfer(options) {
617
665
  if (stillCurrent()) isSending.value = false;
618
666
  }
619
667
  };
620
- (0, import_vue5.onScopeDispose)(() => {
668
+ (0, import_vue6.onScopeDispose)(() => {
621
669
  disposed = true;
622
670
  generation++;
623
671
  });
@@ -627,29 +675,29 @@ function useERC20Transfer(options) {
627
675
  // src/useERC20Approve.ts
628
676
  var import_connect_appkit_core6 = require("@naculus/connect-appkit-core");
629
677
  var import_connect_core6 = require("@naculus/connect-core");
630
- var import_vue6 = require("vue");
678
+ var import_vue7 = require("vue");
631
679
  var MAX_UINT256 = (1n << 256n) - 1n;
632
680
  function useERC20Approve(options) {
633
- const initialToken = (0, import_vue6.toValue)(options.token);
681
+ const initialToken = (0, import_vue7.toValue)(options.token);
634
682
  const decimals = (0, import_connect_appkit_core6.createDecimalsCache)(initialToken, initialToken.decimals);
635
- const allowanceRaw = (0, import_vue6.shallowRef)(null);
636
- const isApproving = (0, import_vue6.shallowRef)(false);
637
- const isFetchingAllowance = (0, import_vue6.shallowRef)(false);
638
- const error = (0, import_vue6.shallowRef)(null);
683
+ const allowanceRaw = (0, import_vue7.shallowRef)(null);
684
+ const isApproving = (0, import_vue7.shallowRef)(false);
685
+ const isFetchingAllowance = (0, import_vue7.shallowRef)(false);
686
+ const error = (0, import_vue7.shallowRef)(null);
639
687
  let generation = 0;
640
688
  let allowanceGeneration = 0;
641
689
  let disposed = false;
642
- (0, import_vue6.watch)(
690
+ (0, import_vue7.watch)(
643
691
  [
644
- () => (0, import_vue6.toValue)(options.token).address,
645
- () => (0, import_vue6.toValue)(options.token).chainId,
646
- () => (0, import_vue6.toValue)(options.token).decimals,
647
- () => (0, import_vue6.toValue)(options.spender),
648
- () => (0, import_vue6.toValue)(options.account),
649
- () => (0, import_vue6.toValue)(options.chainId),
650
- () => (0, import_vue6.toValue)(options.connected),
651
- () => (0, import_vue6.toValue)(options.publicClient),
652
- () => (0, import_vue6.unref)(options.sendTransaction)
692
+ () => (0, import_vue7.toValue)(options.token).address,
693
+ () => (0, import_vue7.toValue)(options.token).chainId,
694
+ () => (0, import_vue7.toValue)(options.token).decimals,
695
+ () => (0, import_vue7.toValue)(options.spender),
696
+ () => (0, import_vue7.toValue)(options.account),
697
+ () => (0, import_vue7.toValue)(options.chainId),
698
+ () => (0, import_vue7.toValue)(options.connected),
699
+ () => (0, import_vue7.toValue)(options.publicClient),
700
+ () => (0, import_vue7.unref)(options.sendTransaction)
653
701
  ],
654
702
  () => {
655
703
  generation++;
@@ -662,17 +710,17 @@ function useERC20Approve(options) {
662
710
  { flush: "sync" }
663
711
  );
664
712
  const context = () => {
665
- const token = (0, import_vue6.toValue)(options.token);
713
+ const token = (0, import_vue7.toValue)(options.token);
666
714
  const account = assertErc20Context(
667
715
  token,
668
- (0, import_vue6.toValue)(options.chainId),
669
- (0, import_vue6.toValue)(options.account),
670
- (0, import_vue6.toValue)(options.connected)
716
+ (0, import_vue7.toValue)(options.chainId),
717
+ (0, import_vue7.toValue)(options.account),
718
+ (0, import_vue7.toValue)(options.connected)
671
719
  );
672
- const reader = (0, import_vue6.toValue)(options.publicClient);
720
+ const reader = (0, import_vue7.toValue)(options.publicClient);
673
721
  if (!reader)
674
722
  throw new import_connect_core6.WalletError("wallet_unavailable", "No public client");
675
- return { token, account, reader, spender: (0, import_vue6.toValue)(options.spender) };
723
+ return { token, account, reader, spender: (0, import_vue7.toValue)(options.spender) };
676
724
  };
677
725
  const readPrecision = async () => {
678
726
  const { token, reader } = context();
@@ -723,7 +771,7 @@ function useERC20Approve(options) {
723
771
  isApproving.value = true;
724
772
  try {
725
773
  const { token, spender } = context();
726
- const hash = await (0, import_vue6.unref)(options.sendTransaction)({
774
+ const hash = await (0, import_vue7.unref)(options.sendTransaction)({
727
775
  to: token.address,
728
776
  data: (0, import_connect_appkit_core6.encodeErc20Approve)(spender, rawAmount),
729
777
  value: "0"
@@ -764,13 +812,13 @@ function useERC20Approve(options) {
764
812
  if (raw === null) return false;
765
813
  return raw >= (0, import_connect_core6.parseUnits)(required, await readPrecision());
766
814
  };
767
- const allowance = (0, import_vue6.computed)(() => {
815
+ const allowance = (0, import_vue7.computed)(() => {
768
816
  if (allowanceRaw.value === null) return null;
769
- const token = (0, import_vue6.toValue)(options.token);
817
+ const token = (0, import_vue7.toValue)(options.token);
770
818
  const precision = (0, import_connect_appkit_core6.readDecimals)(decimals, token, token.decimals);
771
819
  return precision === void 0 ? null : (0, import_connect_core6.formatUnits)(allowanceRaw.value, precision);
772
820
  });
773
- (0, import_vue6.onScopeDispose)(() => {
821
+ (0, import_vue7.onScopeDispose)(() => {
774
822
  disposed = true;
775
823
  generation++;
776
824
  allowanceGeneration++;
@@ -791,19 +839,19 @@ function useERC20Approve(options) {
791
839
  // src/useERC20TransferSimulation.ts
792
840
  var import_connect_appkit_core7 = require("@naculus/connect-appkit-core");
793
841
  var import_connect_core7 = require("@naculus/connect-core");
794
- var import_vue7 = require("vue");
842
+ var import_vue8 = require("vue");
795
843
  function useERC20TransferSimulation(options) {
796
- const transaction = (0, import_vue7.computed)(() => {
797
- const token = (0, import_vue7.toValue)(options.token);
798
- if (!(0, import_vue7.toValue)(options.connected) || !(0, import_vue7.toValue)(options.evmAccount))
844
+ const transaction = (0, import_vue8.computed)(() => {
845
+ const token = (0, import_vue8.toValue)(options.token);
846
+ if (!(0, import_vue8.toValue)(options.connected) || !(0, import_vue8.toValue)(options.evmAccount))
799
847
  return void 0;
800
848
  try {
801
849
  if (token.decimals === void 0) return void 0;
802
850
  return {
803
851
  to: token.address,
804
852
  data: (0, import_connect_appkit_core7.encodeErc20Transfer)(
805
- (0, import_vue7.toValue)(options.to),
806
- (0, import_connect_core7.parseUnits)((0, import_vue7.toValue)(options.amount), token.decimals)
853
+ (0, import_vue8.toValue)(options.to),
854
+ (0, import_connect_core7.parseUnits)((0, import_vue8.toValue)(options.amount), token.decimals)
807
855
  ),
808
856
  value: "0"
809
857
  };
@@ -811,10 +859,10 @@ function useERC20TransferSimulation(options) {
811
859
  return void 0;
812
860
  }
813
861
  });
814
- const chainId = (0, import_vue7.computed)(() => {
815
- const token = (0, import_vue7.toValue)(options.token);
862
+ const chainId = (0, import_vue8.computed)(() => {
863
+ const token = (0, import_vue8.toValue)(options.token);
816
864
  if (token.chainId !== void 0) return token.chainId;
817
- const currentChain = (0, import_vue7.toValue)(options.currentChain);
865
+ const currentChain = (0, import_vue8.toValue)(options.currentChain);
818
866
  return currentChain ? (0, import_connect_appkit_core7.chainNumber)(currentChain) ?? void 0 : void 0;
819
867
  });
820
868
  const simulation = useTransactionSimulation(transaction, {
@@ -824,39 +872,39 @@ function useERC20TransferSimulation(options) {
824
872
  evmAccount: options.evmAccount
825
873
  });
826
874
  return {
827
- result: (0, import_vue7.computed)(
875
+ result: (0, import_vue8.computed)(
828
876
  () => transaction.value ? simulation.result.value : void 0
829
877
  ),
830
- isSimulating: (0, import_vue7.computed)(
878
+ isSimulating: (0, import_vue8.computed)(
831
879
  () => !!transaction.value && simulation.isSimulating.value
832
880
  ),
833
- error: (0, import_vue7.computed)(() => transaction.value ? simulation.error.value : null),
881
+ error: (0, import_vue8.computed)(() => transaction.value ? simulation.error.value : null),
834
882
  reSimulate: simulation.simulate,
835
883
  reset: simulation.reset
836
884
  };
837
885
  }
838
886
 
839
887
  // src/useAccount.ts
840
- var import_vue8 = require("vue");
888
+ var import_vue9 = require("vue");
841
889
  function useAccount(accounts, connected) {
842
890
  const parsed = useAccounts(accounts);
843
- const isConnected = (0, import_vue8.computed)(() => (0, import_vue8.toValue)(connected));
844
- const accountList = (0, import_vue8.computed)(() => (0, import_vue8.toValue)(accounts) ?? []);
891
+ const isConnected = (0, import_vue9.computed)(() => (0, import_vue9.toValue)(connected));
892
+ const accountList = (0, import_vue9.computed)(() => (0, import_vue9.toValue)(accounts) ?? []);
845
893
  return {
846
- accounts: (0, import_vue8.computed)(
894
+ accounts: (0, import_vue9.computed)(
847
895
  () => isConnected.value && accountList.value.length > 0 ? parsed.accounts.value : null
848
896
  ),
849
- evmAccount: (0, import_vue8.computed)(
897
+ evmAccount: (0, import_vue9.computed)(
850
898
  () => isConnected.value ? parsed.evmAccount.value : null
851
899
  ),
852
- primaryAccount: (0, import_vue8.computed)(() => accountList.value[0] ?? null),
900
+ primaryAccount: (0, import_vue9.computed)(() => accountList.value[0] ?? null),
853
901
  isConnected,
854
- count: (0, import_vue8.computed)(() => accountList.value.length)
902
+ count: (0, import_vue9.computed)(() => accountList.value.length)
855
903
  };
856
904
  }
857
905
 
858
906
  // src/useSession.ts
859
- var import_vue9 = require("vue");
907
+ var import_vue10 = require("vue");
860
908
  function readSession(manager) {
861
909
  const bundle = manager?.getActiveBundle();
862
910
  if (!bundle) {
@@ -875,9 +923,9 @@ function readSession(manager) {
875
923
  };
876
924
  }
877
925
  function useSession(manager) {
878
- const snapshot = (0, import_vue9.shallowRef)(readSession((0, import_vue9.toValue)(manager)));
879
- (0, import_vue9.watch)(
880
- () => (0, import_vue9.toValue)(manager),
926
+ const snapshot = (0, import_vue10.shallowRef)(readSession((0, import_vue10.toValue)(manager)));
927
+ (0, import_vue10.watch)(
928
+ () => (0, import_vue10.toValue)(manager),
881
929
  (current, _previous, onCleanup) => {
882
930
  const update = () => {
883
931
  snapshot.value = readSession(current);
@@ -900,61 +948,17 @@ function useSession(manager) {
900
948
  { immediate: true }
901
949
  );
902
950
  return {
903
- session: (0, import_vue9.computed)(() => snapshot.value.session),
904
- chainSessions: (0, import_vue9.computed)(() => snapshot.value.chainSessions),
905
- activeChainId: (0, import_vue9.computed)(() => snapshot.value.activeChainId),
906
- isConnected: (0, import_vue9.computed)(() => snapshot.value.session !== null),
907
- connectorId: (0, import_vue9.computed)(() => snapshot.value.connectorId)
951
+ session: (0, import_vue10.computed)(() => snapshot.value.session),
952
+ chainSessions: (0, import_vue10.computed)(() => snapshot.value.chainSessions),
953
+ activeChainId: (0, import_vue10.computed)(() => snapshot.value.activeChainId),
954
+ isConnected: (0, import_vue10.computed)(() => snapshot.value.session !== null),
955
+ connectorId: (0, import_vue10.computed)(() => snapshot.value.connectorId)
908
956
  };
909
957
  }
910
958
 
911
959
  // src/useConnect.ts
912
960
  var import_connect_core8 = require("@naculus/connect-core");
913
961
  var import_vue11 = require("vue");
914
-
915
- // src/internal/action-guard.ts
916
- var import_vue10 = require("vue");
917
- function useActionGuard() {
918
- const busy = (0, import_vue10.shallowRef)(false);
919
- const error = (0, import_vue10.shallowRef)(null);
920
- let active = 0;
921
- let generation = 0;
922
- let disposed = false;
923
- const run = async (action, fallbackMessage, normalizeError) => {
924
- const own = ++generation;
925
- const commit = (write) => {
926
- if (!disposed && own === generation) write();
927
- };
928
- active++;
929
- busy.value = true;
930
- error.value = null;
931
- try {
932
- return await action(commit);
933
- } catch (cause) {
934
- const normalized = normalizeError ? normalizeError(cause) : cause instanceof Error ? cause : new Error(fallbackMessage);
935
- if (!disposed && own === generation) error.value = normalized;
936
- throw normalized;
937
- } finally {
938
- active--;
939
- if (!disposed) busy.value = active > 0;
940
- }
941
- };
942
- const reset = () => {
943
- generation++;
944
- error.value = null;
945
- };
946
- const clearError = () => {
947
- error.value = null;
948
- };
949
- const dispose = () => {
950
- disposed = true;
951
- generation++;
952
- };
953
- (0, import_vue10.onScopeDispose)(dispose);
954
- return { busy, error, run, clearError, reset, dispose };
955
- }
956
-
957
- // src/useConnect.ts
958
962
  function useConnect(action, status) {
959
963
  const guard = useActionGuard();
960
964
  let inFlight = null;
@@ -1124,44 +1128,30 @@ function useSolanaTransaction(options) {
1124
1128
  // src/useSignInWithX.ts
1125
1129
  var import_vue17 = require("vue");
1126
1130
  function useSignInWithX(action) {
1127
- const isSigningIn = (0, import_vue17.shallowRef)(false);
1131
+ const guard = useActionGuard();
1128
1132
  const result = (0, import_vue17.shallowRef)(null);
1129
- const error = (0, import_vue17.shallowRef)(null);
1130
- let generation = 0;
1131
- let active = 0;
1132
- let disposed = false;
1133
- const signIn = async (options) => {
1133
+ const signIn = (options) => {
1134
1134
  const invoke = (0, import_vue17.unref)(action);
1135
- const own = ++generation;
1136
- active++;
1137
- isSigningIn.value = true;
1138
- error.value = null;
1139
- try {
1135
+ return guard.run(async (commit) => {
1140
1136
  const next = await invoke(options);
1141
- if (!disposed && own === generation) result.value = next;
1137
+ commit(() => {
1138
+ result.value = next;
1139
+ });
1142
1140
  return next;
1143
- } catch (cause) {
1144
- const normalized = cause instanceof Error ? cause : new Error("SIWX sign-in failed");
1145
- if (!disposed && own === generation) error.value = normalized;
1146
- throw normalized;
1147
- } finally {
1148
- active--;
1149
- if (!disposed) isSigningIn.value = active > 0;
1150
- }
1151
- };
1152
- const clearError = () => {
1153
- error.value = null;
1141
+ }, "SIWX sign-in failed");
1154
1142
  };
1155
1143
  const reset = () => {
1156
- generation++;
1144
+ guard.reset();
1157
1145
  result.value = null;
1158
- error.value = null;
1159
1146
  };
1160
- (0, import_vue17.onScopeDispose)(() => {
1161
- disposed = true;
1162
- generation++;
1163
- });
1164
- return { signIn, isSigningIn, result, error, clearError, reset };
1147
+ return {
1148
+ signIn,
1149
+ isSigningIn: guard.busy,
1150
+ result,
1151
+ error: guard.error,
1152
+ clearError: guard.clearError,
1153
+ reset
1154
+ };
1165
1155
  }
1166
1156
 
1167
1157
  // src/useSignInWithEthereum.ts
@@ -1322,6 +1312,10 @@ function useDelegationPolicy(options) {
1322
1312
  previewExecution: (callCount, atomicity) => (0, import_vue20.unref)(options.previewExecution)(callCount, atomicity),
1323
1313
  sponsorship: options.sponsorship,
1324
1314
  adapter: options.adapter,
1315
+ signTypedData: options.signTypedData ? (typedData) => (0, import_vue20.unref)(
1316
+ options.signTypedData
1317
+ )(typedData) : void 0,
1318
+ chainId: () => (0, import_vue20.toValue)(options.chainId) ?? null,
1325
1319
  delegation: () => (0, import_vue20.toValue)(options.delegation),
1326
1320
  encryptionKeyConfigured: Boolean(options.managerConfig?.encryptionKey),
1327
1321
  storageAvailable: () => sessionKeys.storageAvailable,
@@ -1939,35 +1933,43 @@ var import_connect_appkit_core14 = require("@naculus/connect-appkit-core");
1939
1933
  var import_connect_core11 = require("@naculus/connect-core");
1940
1934
  var import_vue28 = require("vue");
1941
1935
  function useBalance(account, client, options = {}) {
1936
+ const guard = useActionGuard();
1942
1937
  const balance = (0, import_vue28.shallowRef)(null);
1943
1938
  const isFetching = (0, import_vue28.shallowRef)(false);
1944
- const error = (0, import_vue28.shallowRef)(null);
1945
- let generation = 0;
1946
- let disposed = false;
1947
1939
  let timer = null;
1948
1940
  const refetch = async () => {
1949
1941
  const reader = (0, import_vue28.toValue)(client);
1950
1942
  const address = (0, import_connect_appkit_core14.bareEvmAddress)((0, import_vue28.toValue)(account));
1951
- const own = ++generation;
1952
1943
  if (!reader || !address) {
1944
+ guard.reset();
1953
1945
  balance.value = null;
1954
- error.value = null;
1955
1946
  isFetching.value = false;
1956
1947
  return;
1957
1948
  }
1958
1949
  isFetching.value = true;
1959
- error.value = null;
1960
- try {
1961
- const next = await reader.getBalance({ address });
1962
- if (disposed || own !== generation) return;
1963
- balance.value = next.toString();
1964
- } catch (cause) {
1965
- if (disposed || own !== generation) return;
1966
- balance.value = null;
1967
- error.value = cause instanceof Error ? cause : new Error("Balance read failed");
1968
- } finally {
1969
- if (!disposed && own === generation) isFetching.value = false;
1970
- }
1950
+ await guard.run(
1951
+ async (commit) => {
1952
+ try {
1953
+ const next = await reader.getBalance({ address });
1954
+ commit(() => {
1955
+ balance.value = next.toString();
1956
+ });
1957
+ } catch (cause) {
1958
+ commit(() => {
1959
+ balance.value = null;
1960
+ });
1961
+ throw cause;
1962
+ }
1963
+ },
1964
+ "Balance read failed",
1965
+ void 0,
1966
+ {
1967
+ onSettled: () => {
1968
+ isFetching.value = false;
1969
+ }
1970
+ }
1971
+ ).catch(() => {
1972
+ });
1971
1973
  };
1972
1974
  const stopTimer = () => {
1973
1975
  if (timer) clearInterval(timer);
@@ -1986,11 +1988,7 @@ function useBalance(account, client, options = {}) {
1986
1988
  },
1987
1989
  { immediate: true }
1988
1990
  );
1989
- (0, import_vue28.onScopeDispose)(() => {
1990
- disposed = true;
1991
- generation++;
1992
- stopTimer();
1993
- });
1991
+ (0, import_vue28.onScopeDispose)(stopTimer);
1994
1992
  return {
1995
1993
  balance,
1996
1994
  formatted: (0, import_vue28.computed)(
@@ -1998,7 +1996,7 @@ function useBalance(account, client, options = {}) {
1998
1996
  ),
1999
1997
  symbol: (0, import_vue28.computed)(() => (0, import_vue28.toValue)(options.symbol) ?? null),
2000
1998
  isFetching,
2001
- error,
1999
+ error: guard.error,
2002
2000
  refetch
2003
2001
  };
2004
2002
  }
@@ -2007,45 +2005,64 @@ function useBalance(account, client, options = {}) {
2007
2005
  var import_connect_appkit_core15 = require("@naculus/connect-appkit-core");
2008
2006
  var import_vue29 = require("vue");
2009
2007
  function useRouteQuote(input, getQuotes, options = {}) {
2008
+ const guard = useActionGuard();
2010
2009
  const quotes = (0, import_vue29.shallowRef)([]);
2011
2010
  const loading = (0, import_vue29.shallowRef)(false);
2012
- const error = (0, import_vue29.shallowRef)(null);
2013
- let generation = 0;
2014
- let disposed = false;
2015
2011
  let timer = null;
2016
2012
  const clearTimer = () => {
2017
2013
  if (timer) clearTimeout(timer);
2018
2014
  timer = null;
2019
2015
  };
2020
- const fetchQuotes = async () => {
2021
- const current = (0, import_vue29.toValue)(input);
2022
- const fn = (0, import_vue29.unref)(getQuotes);
2023
- const own = ++generation;
2016
+ const requestable = (current) => {
2024
2017
  if (!(0, import_connect_appkit_core15.isQuotableInput)(current)) {
2018
+ guard.invalidate();
2019
+ loading.value = false;
2025
2020
  quotes.value = [];
2026
- return;
2021
+ return null;
2022
+ }
2023
+ const fn = (0, import_vue29.unref)(getQuotes);
2024
+ if (!fn) {
2025
+ guard.invalidate();
2026
+ loading.value = false;
2027
+ return null;
2027
2028
  }
2029
+ return fn;
2030
+ };
2031
+ const fetchQuotes = async () => {
2032
+ const current = (0, import_vue29.toValue)(input);
2033
+ const fn = requestable(current);
2028
2034
  if (!fn) return;
2029
2035
  loading.value = true;
2030
- error.value = null;
2031
- try {
2032
- const result = await fn(
2033
- current.fromChain,
2034
- current.toChain,
2035
- current.fromToken,
2036
- current.amount,
2037
- current.options,
2038
- current.toToken
2039
- );
2040
- if (disposed || own !== generation) return;
2041
- quotes.value = result;
2042
- } catch (cause) {
2043
- if (disposed || own !== generation) return;
2044
- error.value = cause instanceof Error ? cause : new Error(String(cause));
2045
- quotes.value = [];
2046
- } finally {
2047
- if (!disposed && own === generation) loading.value = false;
2048
- }
2036
+ await guard.run(
2037
+ async (commit) => {
2038
+ try {
2039
+ const result = await fn(
2040
+ current.fromChain,
2041
+ current.toChain,
2042
+ current.fromToken,
2043
+ current.amount,
2044
+ current.options,
2045
+ current.toToken
2046
+ );
2047
+ commit(() => {
2048
+ quotes.value = result;
2049
+ });
2050
+ } catch (cause) {
2051
+ commit(() => {
2052
+ quotes.value = [];
2053
+ });
2054
+ throw cause;
2055
+ }
2056
+ },
2057
+ "Route quote failed",
2058
+ (cause) => cause instanceof Error ? cause : new Error(String(cause)),
2059
+ {
2060
+ onSettled: () => {
2061
+ loading.value = false;
2062
+ }
2063
+ }
2064
+ ).catch(() => {
2065
+ });
2049
2066
  };
2050
2067
  (0, import_vue29.watch)(
2051
2068
  [
@@ -2056,12 +2073,10 @@ function useRouteQuote(input, getQuotes, options = {}) {
2056
2073
  () => (0, import_vue29.toValue)(input).amount,
2057
2074
  () => (0, import_vue29.unref)(getQuotes)
2058
2075
  ],
2059
- ([fromChain, toChain, fromToken, , amount]) => {
2076
+ () => {
2060
2077
  clearTimer();
2061
- if (!fromChain || !toChain || !fromToken || !amount) {
2062
- quotes.value = [];
2063
- return;
2064
- }
2078
+ guard.invalidate();
2079
+ if (!requestable((0, import_vue29.toValue)(input))) return;
2065
2080
  timer = setTimeout(() => {
2066
2081
  timer = null;
2067
2082
  void fetchQuotes();
@@ -2069,21 +2084,16 @@ function useRouteQuote(input, getQuotes, options = {}) {
2069
2084
  },
2070
2085
  { immediate: true }
2071
2086
  );
2072
- (0, import_vue29.onScopeDispose)(() => {
2073
- disposed = true;
2074
- generation++;
2075
- clearTimer();
2076
- });
2087
+ (0, import_vue29.onScopeDispose)(clearTimer);
2077
2088
  return {
2078
2089
  quotes,
2079
2090
  loading,
2080
- error,
2091
+ error: guard.error,
2081
2092
  refresh: fetchQuotes,
2082
2093
  clear: () => {
2083
2094
  clearTimer();
2084
- generation++;
2095
+ guard.reset();
2085
2096
  quotes.value = [];
2086
- error.value = null;
2087
2097
  loading.value = false;
2088
2098
  }
2089
2099
  };
@@ -2093,33 +2103,47 @@ function useRouteQuote(input, getQuotes, options = {}) {
2093
2103
  var import_connect_appkit_core16 = require("@naculus/connect-appkit-core");
2094
2104
  var import_vue30 = require("vue");
2095
2105
  function useCompareCosts(input, compareCosts) {
2106
+ const guard = useActionGuard();
2096
2107
  const comparisons = (0, import_vue30.shallowRef)([]);
2097
2108
  const loading = (0, import_vue30.shallowRef)(false);
2098
- const error = (0, import_vue30.shallowRef)(null);
2099
- let generation = 0;
2100
- let disposed = false;
2101
2109
  const fetchComparisons = async () => {
2102
2110
  const { operation, chains, options } = (0, import_vue30.toValue)(input);
2103
2111
  const fn = (0, import_vue30.unref)(compareCosts);
2104
- const own = ++generation;
2105
2112
  if (!chains || chains.length === 0) {
2113
+ guard.invalidate();
2114
+ loading.value = false;
2106
2115
  comparisons.value = [];
2107
2116
  return;
2108
2117
  }
2109
- if (!fn) return;
2110
- loading.value = true;
2111
- error.value = null;
2112
- try {
2113
- const result = await fn(operation, chains, options);
2114
- if (disposed || own !== generation) return;
2115
- comparisons.value = result;
2116
- } catch (cause) {
2117
- if (disposed || own !== generation) return;
2118
- error.value = cause instanceof Error ? cause : new Error(String(cause));
2119
- comparisons.value = [];
2120
- } finally {
2121
- if (!disposed && own === generation) loading.value = false;
2118
+ if (!fn) {
2119
+ guard.invalidate();
2120
+ loading.value = false;
2121
+ return;
2122
2122
  }
2123
+ loading.value = true;
2124
+ await guard.run(
2125
+ async (commit) => {
2126
+ try {
2127
+ const result = await fn(operation, chains, options);
2128
+ commit(() => {
2129
+ comparisons.value = result;
2130
+ });
2131
+ } catch (cause) {
2132
+ commit(() => {
2133
+ comparisons.value = [];
2134
+ });
2135
+ throw cause;
2136
+ }
2137
+ },
2138
+ "Cost comparison failed",
2139
+ (cause) => cause instanceof Error ? cause : new Error(String(cause)),
2140
+ {
2141
+ onSettled: () => {
2142
+ loading.value = false;
2143
+ }
2144
+ }
2145
+ ).catch(() => {
2146
+ });
2123
2147
  };
2124
2148
  (0, import_vue30.watch)(
2125
2149
  [() => (0, import_connect_appkit_core16.compareCostsKey)((0, import_vue30.toValue)(input)), () => (0, import_vue30.unref)(compareCosts)],
@@ -2128,11 +2152,12 @@ function useCompareCosts(input, compareCosts) {
2128
2152
  },
2129
2153
  { immediate: true }
2130
2154
  );
2131
- (0, import_vue30.onScopeDispose)(() => {
2132
- disposed = true;
2133
- generation++;
2134
- });
2135
- return { comparisons, loading, error, refresh: fetchComparisons };
2155
+ return {
2156
+ comparisons,
2157
+ loading,
2158
+ error: guard.error,
2159
+ refresh: fetchComparisons
2160
+ };
2136
2161
  }
2137
2162
 
2138
2163
  // src/useExecuteRoute.ts
@@ -2207,12 +2232,10 @@ function useTokenList(chainId, options = {}) {
2207
2232
  const config = {};
2208
2233
  if (options.sources) config.sources = options.sources;
2209
2234
  const manager = options.manager ?? new import_connect_core12.TokenListManager(config);
2235
+ const guard = useActionGuard();
2210
2236
  const tokens = (0, import_vue32.shallowRef)([]);
2211
2237
  const isLoading = (0, import_vue32.shallowRef)(options.autoLoad !== false);
2212
2238
  const isLoaded = (0, import_vue32.shallowRef)(false);
2213
- const error = (0, import_vue32.shallowRef)(null);
2214
- let generation = 0;
2215
- let disposed = false;
2216
2239
  const select = () => {
2217
2240
  const id = (0, import_vue32.toValue)(chainId);
2218
2241
  const numeric = id ? (0, import_connect_appkit_core18.eip155ChainIdToNumber)(id) : void 0;
@@ -2221,20 +2244,24 @@ function useTokenList(chainId, options = {}) {
2221
2244
  );
2222
2245
  };
2223
2246
  const run = async (op) => {
2224
- const own = ++generation;
2225
2247
  isLoading.value = true;
2226
- error.value = null;
2227
- try {
2228
- await op();
2229
- if (disposed || own !== generation) return;
2230
- tokens.value = select();
2231
- isLoaded.value = true;
2232
- } catch (cause) {
2233
- if (disposed || own !== generation) return;
2234
- error.value = cause instanceof Error ? cause : new Error(String(cause));
2235
- } finally {
2236
- if (!disposed && own === generation) isLoading.value = false;
2237
- }
2248
+ await guard.run(
2249
+ async (commit) => {
2250
+ await op();
2251
+ commit(() => {
2252
+ tokens.value = select();
2253
+ isLoaded.value = true;
2254
+ });
2255
+ },
2256
+ "Token list load failed",
2257
+ (cause) => cause instanceof Error ? cause : new Error(String(cause)),
2258
+ {
2259
+ onSettled: () => {
2260
+ isLoading.value = false;
2261
+ }
2262
+ }
2263
+ ).catch(() => {
2264
+ });
2238
2265
  };
2239
2266
  (0, import_vue32.watch)(
2240
2267
  () => (0, import_vue32.toValue)(chainId),
@@ -2243,15 +2270,11 @@ function useTokenList(chainId, options = {}) {
2243
2270
  },
2244
2271
  { immediate: true }
2245
2272
  );
2246
- (0, import_vue32.onScopeDispose)(() => {
2247
- disposed = true;
2248
- generation++;
2249
- });
2250
2273
  return {
2251
2274
  tokens,
2252
2275
  isLoading,
2253
2276
  isLoaded,
2254
- error,
2277
+ error: guard.error,
2255
2278
  refetch: () => run(() => manager.refresh())
2256
2279
  };
2257
2280
  }
@@ -2323,55 +2346,63 @@ function tokensKey(tokens) {
2323
2346
  return tokens.map((t) => `${t.address.toLowerCase()}|${t.decimals}|${t.symbol}`).join(",");
2324
2347
  }
2325
2348
  function useTokenBalance(account, client, tokens, options = {}) {
2349
+ const guard = useActionGuard();
2326
2350
  const tokenBalances = (0, import_vue35.shallowRef)([]);
2327
2351
  const isFetching = (0, import_vue35.shallowRef)(false);
2328
- const error = (0, import_vue35.shallowRef)(null);
2329
- let generation = 0;
2330
- let disposed = false;
2331
2352
  let timer = null;
2332
2353
  const refetch = async () => {
2333
2354
  const reader = (0, import_vue35.toValue)(client);
2334
2355
  const address = (0, import_connect_appkit_core21.bareEvmAddress)((0, import_vue35.toValue)(account));
2335
2356
  const list = (0, import_vue35.toValue)(tokens) ?? [];
2336
- const own = ++generation;
2337
2357
  if (!reader || !address || list.length === 0) {
2358
+ guard.reset();
2338
2359
  tokenBalances.value = [];
2339
- error.value = null;
2340
2360
  isFetching.value = false;
2341
2361
  return;
2342
2362
  }
2343
2363
  isFetching.value = true;
2344
- error.value = null;
2345
- try {
2346
- const results = await Promise.all(
2347
- list.map(async (token) => {
2348
- try {
2349
- const raw = await reader.readContract({
2350
- address: token.address,
2351
- abi: import_connect_core14.ERC20_MIN_ABI,
2352
- functionName: "balanceOf",
2353
- args: [address]
2354
- });
2355
- const value = BigInt(raw);
2356
- return {
2357
- ...token,
2358
- balance: value.toString(),
2359
- formatted: (0, import_connect_core14.formatUnits)(value, token.decimals)
2360
- };
2361
- } catch {
2362
- return { ...token, balance: null, formatted: null };
2363
- }
2364
- })
2365
- );
2366
- if (disposed || own !== generation) return;
2367
- tokenBalances.value = results;
2368
- } catch (cause) {
2369
- if (disposed || own !== generation) return;
2370
- tokenBalances.value = [];
2371
- error.value = cause instanceof Error ? cause : new Error("Failed to fetch token balances");
2372
- } finally {
2373
- if (!disposed && own === generation) isFetching.value = false;
2374
- }
2364
+ await guard.run(
2365
+ async (commit) => {
2366
+ try {
2367
+ const results = await Promise.all(
2368
+ list.map(async (token) => {
2369
+ try {
2370
+ const raw = await reader.readContract({
2371
+ address: token.address,
2372
+ abi: import_connect_core14.ERC20_MIN_ABI,
2373
+ functionName: "balanceOf",
2374
+ args: [address]
2375
+ });
2376
+ const value = BigInt(raw);
2377
+ return {
2378
+ ...token,
2379
+ balance: value.toString(),
2380
+ formatted: (0, import_connect_core14.formatUnits)(value, token.decimals)
2381
+ };
2382
+ } catch {
2383
+ return { ...token, balance: null, formatted: null };
2384
+ }
2385
+ })
2386
+ );
2387
+ commit(() => {
2388
+ tokenBalances.value = results;
2389
+ });
2390
+ } catch (cause) {
2391
+ commit(() => {
2392
+ tokenBalances.value = [];
2393
+ });
2394
+ throw cause;
2395
+ }
2396
+ },
2397
+ "Failed to fetch token balances",
2398
+ void 0,
2399
+ {
2400
+ onSettled: () => {
2401
+ isFetching.value = false;
2402
+ }
2403
+ }
2404
+ ).catch(() => {
2405
+ });
2375
2406
  };
2376
2407
  const stopTimer = () => {
2377
2408
  if (timer) clearInterval(timer);
@@ -2391,15 +2422,11 @@ function useTokenBalance(account, client, tokens, options = {}) {
2391
2422
  },
2392
2423
  { immediate: true }
2393
2424
  );
2394
- (0, import_vue35.onScopeDispose)(() => {
2395
- disposed = true;
2396
- generation++;
2397
- stopTimer();
2398
- });
2425
+ (0, import_vue35.onScopeDispose)(stopTimer);
2399
2426
  return {
2400
2427
  tokenBalances,
2401
2428
  isFetching,
2402
- error,
2429
+ error: guard.error,
2403
2430
  refetch,
2404
2431
  getTokenBalance: (tokenAddress) => tokenBalances.value.find(
2405
2432
  (t) => t.address.toLowerCase() === tokenAddress.toLowerCase()
@@ -2504,35 +2531,42 @@ var import_connect_appkit_core23 = require("@naculus/connect-appkit-core");
2504
2531
  var import_connect_core16 = require("@naculus/connect-core");
2505
2532
  var import_vue37 = require("vue");
2506
2533
  function useDelegation(account, client, chainId) {
2534
+ const guard = useActionGuard();
2507
2535
  const status = (0, import_vue37.shallowRef)(import_connect_core16.UNKNOWN_DELEGATION);
2508
2536
  const isFetching = (0, import_vue37.shallowRef)(false);
2509
- const error = (0, import_vue37.shallowRef)(null);
2510
- let generation = 0;
2511
- let disposed = false;
2512
2537
  const refetch = async () => {
2513
- const mine = ++generation;
2514
2538
  const reader = (0, import_vue37.toValue)(client);
2515
2539
  const address = (0, import_connect_appkit_core23.bareEvmAddress)((0, import_vue37.toValue)(account));
2516
2540
  status.value = import_connect_core16.UNKNOWN_DELEGATION;
2517
- error.value = null;
2518
2541
  if (!reader || !address) {
2542
+ guard.reset();
2519
2543
  isFetching.value = false;
2520
2544
  return;
2521
2545
  }
2522
2546
  isFetching.value = true;
2523
- try {
2524
- const code = await reader.getCode({ address });
2525
- if (!disposed && mine === generation) {
2526
- status.value = (0, import_connect_core16.readDelegation)(code ?? "0x");
2527
- }
2528
- } catch (cause) {
2529
- if (!disposed && mine === generation) {
2530
- status.value = import_connect_core16.UNKNOWN_DELEGATION;
2531
- error.value = cause instanceof Error ? cause : new Error("Code read failed");
2547
+ await guard.run(
2548
+ async (commit) => {
2549
+ try {
2550
+ const code = await reader.getCode({ address });
2551
+ commit(() => {
2552
+ status.value = (0, import_connect_core16.readDelegation)(code ?? "0x");
2553
+ });
2554
+ } catch (cause) {
2555
+ commit(() => {
2556
+ status.value = import_connect_core16.UNKNOWN_DELEGATION;
2557
+ });
2558
+ throw cause;
2559
+ }
2560
+ },
2561
+ "Code read failed",
2562
+ void 0,
2563
+ {
2564
+ onSettled: () => {
2565
+ isFetching.value = false;
2566
+ }
2532
2567
  }
2533
- } finally {
2534
- if (!disposed && mine === generation) isFetching.value = false;
2535
- }
2568
+ ).catch(() => {
2569
+ });
2536
2570
  };
2537
2571
  (0, import_vue37.watch)(
2538
2572
  [() => (0, import_vue37.toValue)(account), () => (0, import_vue37.toValue)(client), () => (0, import_vue37.toValue)(chainId)],
@@ -2541,72 +2575,158 @@ function useDelegation(account, client, chainId) {
2541
2575
  },
2542
2576
  { immediate: true, flush: "sync" }
2543
2577
  );
2544
- (0, import_vue37.onScopeDispose)(() => {
2545
- disposed = true;
2546
- generation++;
2547
- });
2548
2578
  return {
2549
2579
  delegated: (0, import_vue37.computed)(() => status.value.delegated),
2550
2580
  delegate: (0, import_vue37.computed)(() => status.value.delegate),
2551
2581
  isFetching,
2552
- error,
2582
+ error: guard.error,
2553
2583
  refetch
2554
2584
  };
2555
2585
  }
2556
2586
 
2557
- // src/name-lookup.ts
2587
+ // src/usePaymentFetch.ts
2558
2588
  var import_connect_appkit_core24 = require("@naculus/connect-appkit-core");
2559
2589
  var import_vue38 = require("vue");
2560
- function useNameLookup(options) {
2561
- const data = (0, import_vue38.shallowRef)(null);
2562
- const loading = (0, import_vue38.shallowRef)(false);
2563
- const error = (0, import_vue38.shallowRef)(null);
2590
+ function usePaymentFetch(pay) {
2591
+ const guard = useActionGuard();
2592
+ const lastPayment = (0, import_vue38.shallowRef)(null);
2593
+ let epoch = 0;
2594
+ (0, import_vue38.onScopeDispose)(() => {
2595
+ epoch++;
2596
+ });
2597
+ const payFetch = (input, init) => {
2598
+ const invoke = (0, import_vue38.unref)(pay);
2599
+ const own = epoch;
2600
+ return guard.run(async () => {
2601
+ const result = await invoke(input, init);
2602
+ const payment = (0, import_connect_appkit_core24.describePayment)(input, result);
2603
+ if (payment && own === epoch) lastPayment.value = payment;
2604
+ return result;
2605
+ }, "Paid request failed");
2606
+ };
2607
+ return {
2608
+ payFetch,
2609
+ isPending: guard.busy,
2610
+ lastPayment,
2611
+ error: guard.error,
2612
+ reset: () => {
2613
+ epoch++;
2614
+ guard.reset();
2615
+ lastPayment.value = null;
2616
+ }
2617
+ };
2618
+ }
2619
+
2620
+ // src/useSolanaSessionKey.ts
2621
+ var import_connect_appkit_core25 = require("@naculus/connect-appkit-core");
2622
+ var import_vue39 = require("vue");
2623
+ function useSolanaSessionKey(deps) {
2624
+ const guard = useActionGuard();
2625
+ const keys = (0, import_vue39.shallowRef)([]);
2626
+ let flow = null;
2564
2627
  let generation = 0;
2565
2628
  let disposed = false;
2629
+ (0, import_vue39.onScopeDispose)(() => {
2630
+ disposed = true;
2631
+ });
2632
+ const refresh = async () => {
2633
+ const own = ++generation;
2634
+ const next = flow ? await flow.list() : [];
2635
+ if (!disposed && own === generation) keys.value = next;
2636
+ };
2637
+ (0, import_vue39.watch)(
2638
+ () => (0, import_vue39.unref)(deps),
2639
+ (next) => {
2640
+ flow = next ? (0, import_connect_appkit_core25.createSolanaSessionKeyFlow)(next) : null;
2641
+ guard.invalidate();
2642
+ void refresh().catch(() => {
2643
+ });
2644
+ },
2645
+ { immediate: true }
2646
+ );
2647
+ const unavailable = () => Promise.reject(new Error("No Solana session key manager is connected"));
2648
+ const act = (action, fallback) => {
2649
+ const current = flow;
2650
+ if (!current) return unavailable();
2651
+ return guard.run(async () => {
2652
+ try {
2653
+ return await action(current);
2654
+ } finally {
2655
+ await refresh().catch(() => {
2656
+ });
2657
+ }
2658
+ }, fallback);
2659
+ };
2660
+ return {
2661
+ keys,
2662
+ create: (scope) => act((f) => f.create(scope), "Could not create the key"),
2663
+ revoke: (id) => act((f) => f.revoke(id), "Could not revoke the key"),
2664
+ refresh,
2665
+ isPending: guard.busy,
2666
+ error: guard.error
2667
+ };
2668
+ }
2669
+
2670
+ // src/name-lookup.ts
2671
+ var import_connect_appkit_core26 = require("@naculus/connect-appkit-core");
2672
+ var import_vue40 = require("vue");
2673
+ function useNameLookup(options) {
2674
+ const guard = useActionGuard();
2675
+ const data = (0, import_vue40.shallowRef)(null);
2676
+ const loading = (0, import_vue40.shallowRef)(false);
2566
2677
  const run = () => {
2567
- const input = (0, import_vue38.toValue)(options.input).trim();
2568
- const skip = (0, import_vue38.toValue)(options.skip) ?? false;
2569
- const scope = (0, import_vue38.toValue)(options.scope);
2570
- const config = (0, import_vue38.toValue)(options.resolverConfig);
2571
- const mine = ++generation;
2678
+ const input = (0, import_vue40.toValue)(options.input).trim();
2679
+ const skip = (0, import_vue40.toValue)(options.skip) ?? false;
2680
+ const scope = (0, import_vue40.toValue)(options.scope);
2681
+ const config = (0, import_vue40.toValue)(options.resolverConfig);
2572
2682
  if (!input || skip) {
2683
+ guard.reset();
2573
2684
  data.value = null;
2574
2685
  loading.value = false;
2575
- error.value = null;
2576
2686
  return;
2577
2687
  }
2578
2688
  data.value = null;
2579
2689
  loading.value = true;
2580
- error.value = null;
2581
- Promise.resolve().then(() => options.query((0, import_connect_appkit_core24.getResolver)(config), input, scope)).then((result) => {
2582
- if (disposed || mine !== generation) return;
2583
- data.value = result;
2584
- loading.value = false;
2585
- }).catch((cause) => {
2586
- if (disposed || mine !== generation) return;
2587
- data.value = null;
2588
- error.value = cause instanceof Error ? cause : new Error(String(cause));
2589
- loading.value = false;
2690
+ void guard.run(
2691
+ async (commit) => {
2692
+ try {
2693
+ const result = await Promise.resolve().then(
2694
+ () => options.query((0, import_connect_appkit_core26.getResolver)(config), input, scope)
2695
+ );
2696
+ commit(() => {
2697
+ data.value = result;
2698
+ });
2699
+ } catch (cause) {
2700
+ commit(() => {
2701
+ data.value = null;
2702
+ });
2703
+ throw cause;
2704
+ }
2705
+ },
2706
+ "Name lookup failed",
2707
+ (cause) => cause instanceof Error ? cause : new Error(String(cause)),
2708
+ {
2709
+ onSettled: () => {
2710
+ loading.value = false;
2711
+ }
2712
+ }
2713
+ ).catch(() => {
2590
2714
  });
2591
2715
  };
2592
- (0, import_vue38.watch)(
2716
+ (0, import_vue40.watch)(
2593
2717
  () => [
2594
- (0, import_vue38.toValue)(options.input),
2595
- (0, import_vue38.toValue)(options.skip),
2596
- (0, import_vue38.toValue)(options.scope),
2597
- (0, import_vue38.toValue)(options.resolverConfig)
2718
+ (0, import_vue40.toValue)(options.input),
2719
+ (0, import_vue40.toValue)(options.skip),
2720
+ (0, import_vue40.toValue)(options.scope),
2721
+ (0, import_vue40.toValue)(options.resolverConfig)
2598
2722
  ],
2599
2723
  run,
2600
2724
  { immediate: true, flush: "sync", deep: true }
2601
2725
  );
2602
- (0, import_vue38.onScopeDispose)(() => {
2603
- disposed = true;
2604
- generation++;
2605
- });
2606
2726
  return {
2607
2727
  data,
2608
- isLoading: (0, import_vue38.computed)(() => loading.value),
2609
- error,
2728
+ isLoading: (0, import_vue40.computed)(() => loading.value),
2729
+ error: guard.error,
2610
2730
  refetch: run
2611
2731
  };
2612
2732
  }
@@ -2633,21 +2753,21 @@ function useLookupAddress(address, options) {
2633
2753
  }
2634
2754
 
2635
2755
  // src/useSolanaAccount.ts
2636
- var import_vue39 = require("vue");
2756
+ var import_vue41 = require("vue");
2637
2757
  function useSolanaAccount(accounts, connected) {
2638
- const isConnected = (0, import_vue39.computed)(() => (0, import_vue39.toValue)(connected));
2639
- const caip10 = (0, import_vue39.computed)(
2640
- () => isConnected.value ? ((0, import_vue39.toValue)(accounts) ?? []).find(
2758
+ const isConnected = (0, import_vue41.computed)(() => (0, import_vue41.toValue)(connected));
2759
+ const caip10 = (0, import_vue41.computed)(
2760
+ () => isConnected.value ? ((0, import_vue41.toValue)(accounts) ?? []).find(
2641
2761
  (account) => account.startsWith("solana:")
2642
2762
  ) ?? null : null
2643
2763
  );
2644
- const parts = (0, import_vue39.computed)(() => caip10.value?.split(":") ?? []);
2764
+ const parts = (0, import_vue41.computed)(() => caip10.value?.split(":") ?? []);
2645
2765
  return {
2646
- address: (0, import_vue39.computed)(
2766
+ address: (0, import_vue41.computed)(
2647
2767
  () => parts.value.length >= 3 ? parts.value.at(-1) ?? null : null
2648
2768
  ),
2649
2769
  caip10,
2650
- chainId: (0, import_vue39.computed)(
2770
+ chainId: (0, import_vue41.computed)(
2651
2771
  () => parts.value.length >= 3 ? parts.value.slice(0, -1).join(":") : null
2652
2772
  ),
2653
2773
  isConnected
@@ -2655,35 +2775,35 @@ function useSolanaAccount(accounts, connected) {
2655
2775
  }
2656
2776
 
2657
2777
  // src/useChain.ts
2658
- var import_connect_appkit_core25 = require("@naculus/connect-appkit-core");
2659
- var import_vue40 = require("vue");
2778
+ var import_connect_appkit_core27 = require("@naculus/connect-appkit-core");
2779
+ var import_vue42 = require("vue");
2660
2780
  function useChain(chains, chainId) {
2661
- const list = (0, import_vue40.computed)(() => (0, import_vue40.toValue)(chains) ?? []);
2662
- const id = (0, import_vue40.computed)(() => (0, import_vue40.toValue)(chainId) ?? null);
2663
- const currentChain = (0, import_vue40.computed)(() => (0, import_connect_appkit_core25.resolveChain)(list.value, id.value));
2781
+ const list = (0, import_vue42.computed)(() => (0, import_vue42.toValue)(chains) ?? []);
2782
+ const id = (0, import_vue42.computed)(() => (0, import_vue42.toValue)(chainId) ?? null);
2783
+ const currentChain = (0, import_vue42.computed)(() => (0, import_connect_appkit_core27.resolveChain)(list.value, id.value));
2664
2784
  return {
2665
2785
  currentChain,
2666
- chainInfo: (0, import_vue40.computed)(() => (0, import_connect_appkit_core25.describeChain)(list.value, id.value)),
2667
- availableChains: (0, import_vue40.computed)(() => (0, import_connect_appkit_core25.chainsForNamespace)(list.value, id.value)),
2668
- currentChainNumber: (0, import_vue40.computed)(
2669
- () => currentChain.value ? (0, import_connect_appkit_core25.chainNumber)(currentChain.value) : null
2786
+ chainInfo: (0, import_vue42.computed)(() => (0, import_connect_appkit_core27.describeChain)(list.value, id.value)),
2787
+ availableChains: (0, import_vue42.computed)(() => (0, import_connect_appkit_core27.chainsForNamespace)(list.value, id.value)),
2788
+ currentChainNumber: (0, import_vue42.computed)(
2789
+ () => currentChain.value ? (0, import_connect_appkit_core27.chainNumber)(currentChain.value) : null
2670
2790
  ),
2671
- namespace: (0, import_vue40.computed)(
2672
- () => currentChain.value ? (0, import_connect_appkit_core25.chainNamespace)(currentChain.value) : null
2791
+ namespace: (0, import_vue42.computed)(
2792
+ () => currentChain.value ? (0, import_connect_appkit_core27.chainNamespace)(currentChain.value) : null
2673
2793
  )
2674
2794
  };
2675
2795
  }
2676
2796
 
2677
2797
  // src/usePassphraseGate.ts
2678
- var import_vue41 = require("vue");
2798
+ var import_vue43 = require("vue");
2679
2799
  function usePassphraseGate(gate) {
2680
- const request = (0, import_vue41.shallowRef)(gate.getSnapshot());
2800
+ const request = (0, import_vue43.shallowRef)(gate.getSnapshot());
2681
2801
  const unsubscribe = gate.subscribe(() => {
2682
2802
  request.value = gate.getSnapshot();
2683
2803
  });
2684
- (0, import_vue41.onScopeDispose)(unsubscribe);
2804
+ (0, import_vue43.onScopeDispose)(unsubscribe);
2685
2805
  return {
2686
- request: (0, import_vue41.readonly)(request),
2806
+ request: (0, import_vue43.readonly)(request),
2687
2807
  submit: (passphrase) => gate.submit(passphrase),
2688
2808
  cancel: (reason) => gate.cancel(reason),
2689
2809
  forget: (reason) => gate.forget(reason)
@@ -2692,54 +2812,61 @@ function usePassphraseGate(gate) {
2692
2812
 
2693
2813
  // src/useSolanaBalance.ts
2694
2814
  var import_connect_core17 = require("@naculus/connect-core");
2695
- var import_vue42 = require("vue");
2815
+ var import_vue44 = require("vue");
2696
2816
  function useSolanaBalance(address, rpcUrl) {
2697
- const balance = (0, import_vue42.shallowRef)(null);
2698
- const isFetching = (0, import_vue42.ref)(false);
2699
- const error = (0, import_vue42.shallowRef)(null);
2700
- let generation = 0;
2701
- let disposed = false;
2817
+ const guard = useActionGuard();
2818
+ const balance = (0, import_vue44.shallowRef)(null);
2819
+ const isFetching = (0, import_vue44.ref)(false);
2702
2820
  const refetch = async () => {
2703
- const addr = (0, import_vue42.toValue)(address);
2704
- const url = (0, import_vue42.toValue)(rpcUrl);
2821
+ const addr = (0, import_vue44.toValue)(address);
2822
+ const url = (0, import_vue44.toValue)(rpcUrl);
2705
2823
  if (!addr || !url) {
2824
+ guard.invalidate();
2825
+ isFetching.value = false;
2706
2826
  balance.value = null;
2707
2827
  return;
2708
2828
  }
2709
- const own = ++generation;
2710
2829
  isFetching.value = true;
2711
- error.value = null;
2712
- try {
2713
- const next = await (0, import_connect_core17.getSolanaBalance)(url, addr);
2714
- if (disposed || own !== generation) return;
2715
- balance.value = next;
2716
- } catch (err) {
2717
- if (disposed || own !== generation) return;
2718
- balance.value = null;
2719
- error.value = err instanceof Error ? err : new Error("Balance read failed");
2720
- } finally {
2721
- if (!disposed && own === generation) isFetching.value = false;
2722
- }
2830
+ await guard.run(
2831
+ async (commit) => {
2832
+ try {
2833
+ const next = await (0, import_connect_core17.getSolanaBalance)(url, addr);
2834
+ commit(() => {
2835
+ balance.value = next;
2836
+ });
2837
+ } catch (err) {
2838
+ commit(() => {
2839
+ balance.value = null;
2840
+ });
2841
+ throw err;
2842
+ }
2843
+ },
2844
+ "Balance read failed",
2845
+ void 0,
2846
+ {
2847
+ onSettled: () => {
2848
+ isFetching.value = false;
2849
+ }
2850
+ }
2851
+ ).catch(() => {
2852
+ });
2723
2853
  };
2724
- (0, import_vue42.watchEffect)(() => {
2725
- (0, import_vue42.toValue)(address);
2726
- (0, import_vue42.toValue)(rpcUrl);
2854
+ (0, import_vue44.watchEffect)(() => {
2855
+ (0, import_vue44.toValue)(address);
2856
+ (0, import_vue44.toValue)(rpcUrl);
2727
2857
  void refetch();
2728
2858
  });
2729
- (0, import_vue42.onScopeDispose)(() => {
2730
- disposed = true;
2731
- });
2732
- return { balance, isFetching, error, refetch };
2859
+ return { balance, isFetching, error: guard.error, refetch };
2733
2860
  }
2734
2861
 
2735
2862
  // src/useLastTx.ts
2736
- var import_vue43 = require("vue");
2863
+ var import_vue45 = require("vue");
2737
2864
  function useLastTx(monitor) {
2738
- const lastTx = (0, import_vue43.shallowRef)(null);
2739
- const lastConfirmedTx = (0, import_vue43.shallowRef)(null);
2740
- const lastFailedTx = (0, import_vue43.shallowRef)(null);
2741
- (0, import_vue43.watch)(
2742
- () => (0, import_vue43.toValue)(monitor),
2865
+ const lastTx = (0, import_vue45.shallowRef)(null);
2866
+ const lastConfirmedTx = (0, import_vue45.shallowRef)(null);
2867
+ const lastFailedTx = (0, import_vue45.shallowRef)(null);
2868
+ (0, import_vue45.watch)(
2869
+ () => (0, import_vue45.toValue)(monitor),
2743
2870
  (activeMonitor, _previous, onCleanup) => {
2744
2871
  if (!activeMonitor) return;
2745
2872
  const recordLatest = (entry) => {
@@ -2777,38 +2904,42 @@ function useLastTx(monitor) {
2777
2904
  }
2778
2905
 
2779
2906
  // src/useTxHistory.ts
2780
- var import_vue44 = require("vue");
2907
+ var import_vue46 = require("vue");
2781
2908
  function useTxHistory(address, chainId, monitor) {
2782
- const entries = (0, import_vue44.shallowRef)([]);
2783
- const isLoading = (0, import_vue44.shallowRef)(false);
2784
- const error = (0, import_vue44.shallowRef)(null);
2785
- let generation = 0;
2909
+ const guard = useActionGuard();
2910
+ const entries = (0, import_vue46.shallowRef)([]);
2911
+ const isLoading = (0, import_vue46.shallowRef)(false);
2786
2912
  const refresh = async () => {
2787
- const mine = ++generation;
2788
- const activeMonitor = (0, import_vue44.toValue)(monitor);
2913
+ const activeMonitor = (0, import_vue46.toValue)(monitor);
2789
2914
  if (!activeMonitor) {
2915
+ guard.reset();
2790
2916
  entries.value = [];
2791
2917
  isLoading.value = false;
2792
- error.value = null;
2793
2918
  return;
2794
2919
  }
2795
2920
  isLoading.value = true;
2796
- error.value = null;
2797
- try {
2798
- const result = await activeMonitor.getTxHistory(
2799
- (0, import_vue44.toValue)(address) ?? void 0,
2800
- (0, import_vue44.toValue)(chainId) ?? void 0
2801
- );
2802
- if (mine === generation) entries.value = result;
2803
- } catch (err) {
2804
- if (mine !== generation) return;
2805
- error.value = err instanceof Error ? err : new Error("Failed to load transaction history");
2806
- } finally {
2807
- if (mine === generation) isLoading.value = false;
2808
- }
2921
+ await guard.run(
2922
+ async (commit) => {
2923
+ const result = await activeMonitor.getTxHistory(
2924
+ (0, import_vue46.toValue)(address) ?? void 0,
2925
+ (0, import_vue46.toValue)(chainId) ?? void 0
2926
+ );
2927
+ commit(() => {
2928
+ entries.value = result;
2929
+ });
2930
+ },
2931
+ "Failed to load transaction history",
2932
+ void 0,
2933
+ {
2934
+ onSettled: () => {
2935
+ isLoading.value = false;
2936
+ }
2937
+ }
2938
+ ).catch(() => {
2939
+ });
2809
2940
  };
2810
- (0, import_vue44.watch)(
2811
- [() => (0, import_vue44.toValue)(monitor), () => (0, import_vue44.toValue)(address), () => (0, import_vue44.toValue)(chainId)],
2941
+ (0, import_vue46.watch)(
2942
+ [() => (0, import_vue46.toValue)(monitor), () => (0, import_vue46.toValue)(address), () => (0, import_vue46.toValue)(chainId)],
2812
2943
  ([activeMonitor], _previous, onCleanup) => {
2813
2944
  if (!activeMonitor) {
2814
2945
  void refresh();
@@ -2826,9 +2957,9 @@ function useTxHistory(address, chainId, monitor) {
2826
2957
  return {
2827
2958
  entries,
2828
2959
  isLoading,
2829
- error,
2960
+ error: guard.error,
2830
2961
  refresh,
2831
- summary: (0, import_vue44.computed)(() => ({
2962
+ summary: (0, import_vue46.computed)(() => ({
2832
2963
  pending: entries.value.filter((item) => item.status === "pending").length,
2833
2964
  confirmed: entries.value.filter((item) => item.status === "confirmed").length,
2834
2965
  failed: entries.value.filter((item) => item.status === "failed").length
@@ -2837,17 +2968,17 @@ function useTxHistory(address, chainId, monitor) {
2837
2968
  }
2838
2969
 
2839
2970
  // src/useTxMonitor.ts
2840
- var import_vue45 = require("vue");
2971
+ var import_vue47 = require("vue");
2841
2972
  function useTxMonitor(hash, chainId, monitor) {
2842
- const entry = (0, import_vue45.shallowRef)(null);
2843
- const isLoading = (0, import_vue45.shallowRef)(false);
2844
- const isWatching = (0, import_vue45.shallowRef)(false);
2845
- const error = (0, import_vue45.shallowRef)(null);
2973
+ const entry = (0, import_vue47.shallowRef)(null);
2974
+ const isLoading = (0, import_vue47.shallowRef)(false);
2975
+ const isWatching = (0, import_vue47.shallowRef)(false);
2976
+ const error = (0, import_vue47.shallowRef)(null);
2846
2977
  let generation = 0;
2847
2978
  const refresh = async () => {
2848
- const activeMonitor = (0, import_vue45.toValue)(monitor);
2849
- const activeHash = (0, import_vue45.toValue)(hash);
2850
- const activeChainId = (0, import_vue45.toValue)(chainId);
2979
+ const activeMonitor = (0, import_vue47.toValue)(monitor);
2980
+ const activeHash = (0, import_vue47.toValue)(hash);
2981
+ const activeChainId = (0, import_vue47.toValue)(chainId);
2851
2982
  if (!activeMonitor || !activeHash) return;
2852
2983
  isLoading.value = true;
2853
2984
  error.value = null;
@@ -2865,15 +2996,15 @@ function useTxMonitor(hash, chainId, monitor) {
2865
2996
  }
2866
2997
  };
2867
2998
  const stopWatching = () => {
2868
- const activeMonitor = (0, import_vue45.toValue)(monitor);
2869
- const activeHash = (0, import_vue45.toValue)(hash);
2870
- const activeChainId = (0, import_vue45.toValue)(chainId);
2999
+ const activeMonitor = (0, import_vue47.toValue)(monitor);
3000
+ const activeHash = (0, import_vue47.toValue)(hash);
3001
+ const activeChainId = (0, import_vue47.toValue)(chainId);
2871
3002
  if (!activeMonitor || !activeHash) return;
2872
3003
  activeMonitor.stopWatching(activeHash, activeChainId ?? void 0);
2873
3004
  isWatching.value = false;
2874
3005
  };
2875
- (0, import_vue45.watch)(
2876
- [() => (0, import_vue45.toValue)(monitor), () => (0, import_vue45.toValue)(hash), () => (0, import_vue45.toValue)(chainId)],
3006
+ (0, import_vue47.watch)(
3007
+ [() => (0, import_vue47.toValue)(monitor), () => (0, import_vue47.toValue)(hash), () => (0, import_vue47.toValue)(chainId)],
2877
3008
  ([activeMonitor, activeHash, activeChainId], _previous, onCleanup) => {
2878
3009
  const mine = ++generation;
2879
3010
  if (!activeMonitor || !activeHash || !activeChainId) {
@@ -2913,7 +3044,7 @@ function useTxMonitor(hash, chainId, monitor) {
2913
3044
  );
2914
3045
  return {
2915
3046
  entry,
2916
- status: (0, import_vue45.computed)(() => entry.value?.status ?? "idle"),
3047
+ status: (0, import_vue47.computed)(() => entry.value?.status ?? "idle"),
2917
3048
  isLoading,
2918
3049
  isWatching,
2919
3050
  error,
@@ -2923,71 +3054,80 @@ function useTxMonitor(hash, chainId, monitor) {
2923
3054
  }
2924
3055
 
2925
3056
  // src/useCapabilities.ts
2926
- var import_connect_appkit_core26 = require("@naculus/connect-appkit-core");
2927
- var import_vue46 = require("vue");
3057
+ var import_connect_appkit_core28 = require("@naculus/connect-appkit-core");
3058
+ var import_vue48 = require("vue");
2928
3059
  function useCapabilities(client, session, chainId) {
2929
- const capabilities = (0, import_vue46.shallowRef)(
3060
+ const guard = useActionGuard();
3061
+ const capabilities = (0, import_vue48.shallowRef)(
2930
3062
  null
2931
3063
  );
2932
- const isFetching = (0, import_vue46.shallowRef)(false);
2933
- const error = (0, import_vue46.shallowRef)(null);
2934
- let generation = 0;
3064
+ const isFetching = (0, import_vue48.shallowRef)(false);
2935
3065
  const refetch = async () => {
2936
- const mine = ++generation;
2937
- const activeClient = (0, import_vue46.toValue)(client);
2938
- const activeSession = (0, import_vue46.toValue)(session);
3066
+ const activeClient = (0, import_vue48.toValue)(client);
3067
+ const activeSession = (0, import_vue48.toValue)(session);
2939
3068
  if (!activeClient?.getCapabilities || !activeSession) {
3069
+ guard.reset();
2940
3070
  capabilities.value = null;
2941
3071
  isFetching.value = false;
2942
- error.value = null;
2943
3072
  return;
2944
3073
  }
2945
3074
  isFetching.value = true;
2946
- error.value = null;
2947
- try {
2948
- const raw = await activeClient.getCapabilities(activeSession);
2949
- if (mine !== generation) return;
2950
- capabilities.value = (0, import_connect_appkit_core26.normalizeCapabilities)(raw);
2951
- } catch (err) {
2952
- if (mine !== generation) return;
2953
- capabilities.value = null;
2954
- error.value = err instanceof Error ? err : new Error("Capability query failed");
2955
- } finally {
2956
- if (mine === generation) isFetching.value = false;
2957
- }
3075
+ await guard.run(
3076
+ async (commit) => {
3077
+ try {
3078
+ const raw = await activeClient.getCapabilities(activeSession);
3079
+ commit(() => {
3080
+ capabilities.value = (0, import_connect_appkit_core28.normalizeCapabilities)(raw);
3081
+ });
3082
+ } catch (err) {
3083
+ commit(() => {
3084
+ capabilities.value = null;
3085
+ });
3086
+ throw err;
3087
+ }
3088
+ },
3089
+ "Capability query failed",
3090
+ void 0,
3091
+ {
3092
+ onSettled: () => {
3093
+ isFetching.value = false;
3094
+ }
3095
+ }
3096
+ ).catch(() => {
3097
+ });
2958
3098
  };
2959
- (0, import_vue46.watchEffect)(() => {
2960
- void (0, import_vue46.toValue)(client);
2961
- void (0, import_vue46.toValue)(session);
3099
+ (0, import_vue48.watchEffect)(() => {
3100
+ void (0, import_vue48.toValue)(client);
3101
+ void (0, import_vue48.toValue)(session);
2962
3102
  void refetch();
2963
3103
  });
2964
3104
  return {
2965
3105
  capabilities,
2966
- current: (0, import_vue46.computed)(
2967
- () => (0, import_connect_appkit_core26.selectChainCapabilities)(capabilities.value, (0, import_vue46.toValue)(chainId))
3106
+ current: (0, import_vue48.computed)(
3107
+ () => (0, import_connect_appkit_core28.selectChainCapabilities)(capabilities.value, (0, import_vue48.toValue)(chainId))
2968
3108
  ),
2969
- atomic: (0, import_vue46.computed)(
2970
- () => (0, import_connect_appkit_core26.atomicSupportFor)(capabilities.value, (0, import_vue46.toValue)(chainId))
3109
+ atomic: (0, import_vue48.computed)(
3110
+ () => (0, import_connect_appkit_core28.atomicSupportFor)(capabilities.value, (0, import_vue48.toValue)(chainId))
2971
3111
  ),
2972
3112
  isFetching,
2973
- error,
3113
+ error: guard.error,
2974
3114
  refetch
2975
3115
  };
2976
3116
  }
2977
3117
 
2978
3118
  // src/useSolanaRoles.ts
2979
- var import_connect_appkit_core27 = require("@naculus/connect-appkit-core");
2980
- var import_vue47 = require("vue");
3119
+ var import_connect_appkit_core29 = require("@naculus/connect-appkit-core");
3120
+ var import_vue49 = require("vue");
2981
3121
  function useSolanaRoles(connector, session) {
2982
- const state = (0, import_vue47.computed)(
2983
- () => (0, import_connect_appkit_core27.readSolanaRoles)((0, import_vue47.toValue)(connector), (0, import_vue47.toValue)(session))
3122
+ const state = (0, import_vue49.computed)(
3123
+ () => (0, import_connect_appkit_core29.readSolanaRoles)((0, import_vue49.toValue)(connector), (0, import_vue49.toValue)(session))
2984
3124
  );
2985
3125
  return {
2986
- roles: (0, import_vue47.computed)(() => state.value.roles),
2987
- absence: (0, import_vue47.computed)(() => state.value.absence),
2988
- identity: (0, import_vue47.computed)(() => state.value.roles?.identity ?? null),
2989
- signer: (0, import_vue47.computed)(() => state.value.roles?.signer ?? null),
2990
- payer: (0, import_vue47.computed)(() => state.value.roles?.payer ?? null)
3126
+ roles: (0, import_vue49.computed)(() => state.value.roles),
3127
+ absence: (0, import_vue49.computed)(() => state.value.absence),
3128
+ identity: (0, import_vue49.computed)(() => state.value.roles?.identity ?? null),
3129
+ signer: (0, import_vue49.computed)(() => state.value.roles?.signer ?? null),
3130
+ payer: (0, import_vue49.computed)(() => state.value.roles?.payer ?? null)
2991
3131
  };
2992
3132
  }
2993
3133
  // Annotate the CommonJS export names for ESM import in node:
@@ -3042,6 +3182,7 @@ function useSolanaRoles(connector, session) {
3042
3182
  useLookupAddress,
3043
3183
  useNotification,
3044
3184
  usePassphraseGate,
3185
+ usePaymentFetch,
3045
3186
  useResolveName,
3046
3187
  useRevokeSession,
3047
3188
  useRouteQuote,
@@ -3062,6 +3203,7 @@ function useSolanaRoles(connector, session) {
3062
3203
  useSolanaAccount,
3063
3204
  useSolanaBalance,
3064
3205
  useSolanaRoles,
3206
+ useSolanaSessionKey,
3065
3207
  useSolanaTransaction,
3066
3208
  useSwitchChain,
3067
3209
  useTokenBalance,