@naculus/connect-appkit-vue 0.2.4 → 0.2.5

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
@@ -48,12 +48,33 @@ __export(index_exports, {
48
48
  AppkitTabs: () => AppkitTabs,
49
49
  AppkitToggleGroup: () => AppkitToggleGroup,
50
50
  AppkitTooltip: () => AppkitTooltip,
51
+ useAccount: () => useAccount,
51
52
  useAccounts: () => useAccounts,
53
+ useBalance: () => useBalance,
52
54
  useCapabilities: () => useCapabilities,
53
55
  useChain: () => useChain,
56
+ useCompareCosts: () => useCompareCosts,
57
+ useConnect: () => useConnect,
58
+ useDelegation: () => useDelegation,
59
+ useDisconnect: () => useDisconnect,
60
+ useExecuteRoute: () => useExecuteRoute,
61
+ useLastTx: () => useLastTx,
62
+ useLookupAddress: () => useLookupAddress,
63
+ useNotification: () => useNotification,
54
64
  usePassphraseGate: () => usePassphraseGate,
65
+ useResolveName: () => useResolveName,
66
+ useRouteQuote: () => useRouteQuote,
67
+ useSession: () => useSession,
68
+ useSolanaAccount: () => useSolanaAccount,
55
69
  useSolanaBalance: () => useSolanaBalance,
56
- useSolanaRoles: () => useSolanaRoles
70
+ useSolanaRoles: () => useSolanaRoles,
71
+ useSwitchChain: () => useSwitchChain,
72
+ useTokenBalance: () => useTokenBalance,
73
+ useTokenList: () => useTokenList,
74
+ useTokenSearch: () => useTokenSearch,
75
+ useTxHistory: () => useTxHistory,
76
+ useTxMonitor: () => useTxMonitor,
77
+ useValidateDestination: () => useValidateDestination
57
78
  });
58
79
  module.exports = __toCommonJS(index_exports);
59
80
 
@@ -268,36 +289,906 @@ function useAccounts(accounts) {
268
289
  };
269
290
  }
270
291
 
271
- // src/useChain.ts
292
+ // src/useNotification.ts
272
293
  var import_connect_appkit_core = require("@naculus/connect-appkit-core");
294
+ var import_connect_core2 = require("@naculus/connect-core");
273
295
  var import_vue2 = require("vue");
296
+ function useNotification(options = {}) {
297
+ const channel = (0, import_vue2.unref)(options.channel) ?? new import_connect_core2.InAppChannel();
298
+ const storage = (0, import_vue2.unref)(options.storage) ?? (0, import_connect_appkit_core.createNotificationSettingsStorage)();
299
+ const notifications = (0, import_vue2.shallowRef)(channel.getHistory());
300
+ const settings = (0, import_vue2.shallowRef)(
301
+ import_connect_appkit_core.DEFAULT_NOTIFICATION_SETTINGS
302
+ );
303
+ const unreadCount = (0, import_vue2.computed)(
304
+ () => notifications.value.filter((item) => !item.read).length
305
+ );
306
+ let disposed = false;
307
+ void (0, import_connect_appkit_core.loadNotificationSettings)(storage).then((saved) => {
308
+ if (!disposed && saved) settings.value = saved;
309
+ });
310
+ channel.onNotification = (item) => {
311
+ if (!disposed) notifications.value = [...notifications.value, item];
312
+ };
313
+ void channel.restore().then(() => {
314
+ if (!disposed) notifications.value = channel.getHistory();
315
+ });
316
+ (0, import_vue2.onScopeDispose)(() => {
317
+ disposed = true;
318
+ channel.onNotification = void 0;
319
+ });
320
+ const updateSettings = (update) => {
321
+ settings.value = (0, import_connect_appkit_core.updateNotificationSettings)(settings.value, update);
322
+ (0, import_connect_appkit_core.saveNotificationSettings)(storage, settings.value);
323
+ };
324
+ return {
325
+ notifications,
326
+ unreadCount,
327
+ settings,
328
+ addNotification: (item) => (0, import_connect_appkit_core.addInAppNotification)(channel, item),
329
+ clear: () => {
330
+ channel.clear();
331
+ notifications.value = [];
332
+ },
333
+ clearOne: (id) => {
334
+ void (0, import_connect_appkit_core.clearOneInAppNotification)(channel, id).then(() => {
335
+ if (!disposed) notifications.value = channel.getHistory();
336
+ });
337
+ },
338
+ markAsRead: (id) => {
339
+ channel.markAsRead(id);
340
+ notifications.value = notifications.value.map(
341
+ (item) => item.id === id ? { ...item, read: true } : item
342
+ );
343
+ },
344
+ markAllAsRead: () => {
345
+ channel.markAllAsRead();
346
+ notifications.value = notifications.value.map((item) => ({
347
+ ...item,
348
+ read: true
349
+ }));
350
+ },
351
+ updateSettings,
352
+ setChannels: (channels) => updateSettings((0, import_connect_appkit_core.channelsUpdate)(channels)),
353
+ muteChain: (chainId) => updateSettings((0, import_connect_appkit_core.mutedChainSettings)(settings.value, chainId, true)),
354
+ unmuteChain: (chainId) => updateSettings((0, import_connect_appkit_core.mutedChainSettings)(settings.value, chainId, false))
355
+ };
356
+ }
357
+
358
+ // src/useAccount.ts
359
+ var import_vue3 = require("vue");
360
+ function useAccount(accounts, connected) {
361
+ const parsed = useAccounts(accounts);
362
+ const isConnected = (0, import_vue3.computed)(() => (0, import_vue3.toValue)(connected));
363
+ const accountList = (0, import_vue3.computed)(() => (0, import_vue3.toValue)(accounts) ?? []);
364
+ return {
365
+ accounts: (0, import_vue3.computed)(
366
+ () => isConnected.value && accountList.value.length > 0 ? parsed.accounts.value : null
367
+ ),
368
+ evmAccount: (0, import_vue3.computed)(
369
+ () => isConnected.value ? parsed.evmAccount.value : null
370
+ ),
371
+ primaryAccount: (0, import_vue3.computed)(() => accountList.value[0] ?? null),
372
+ isConnected,
373
+ count: (0, import_vue3.computed)(() => accountList.value.length)
374
+ };
375
+ }
376
+
377
+ // src/useSession.ts
378
+ var import_vue4 = require("vue");
379
+ function readSession(manager) {
380
+ const bundle = manager?.getActiveBundle();
381
+ if (!bundle) {
382
+ return {
383
+ session: null,
384
+ chainSessions: [],
385
+ activeChainId: null,
386
+ connectorId: null
387
+ };
388
+ }
389
+ return {
390
+ session: bundle.walletSession,
391
+ chainSessions: Array.from(bundle.chainSessions.values()),
392
+ activeChainId: bundle.activeChainId,
393
+ connectorId: bundle.walletSession.walletType
394
+ };
395
+ }
396
+ function useSession(manager) {
397
+ const snapshot = (0, import_vue4.shallowRef)(readSession((0, import_vue4.toValue)(manager)));
398
+ (0, import_vue4.watch)(
399
+ () => (0, import_vue4.toValue)(manager),
400
+ (current, _previous, onCleanup) => {
401
+ const update = () => {
402
+ snapshot.value = readSession(current);
403
+ };
404
+ update();
405
+ if (!current) return;
406
+ current.on("sessionConnected", update);
407
+ current.on("sessionDisconnected", update);
408
+ current.on("chainChanged", update);
409
+ onCleanup(() => {
410
+ current.off("sessionConnected", update);
411
+ current.off("sessionDisconnected", update);
412
+ current.off("chainChanged", update);
413
+ });
414
+ },
415
+ { immediate: true }
416
+ );
417
+ return {
418
+ session: (0, import_vue4.computed)(() => snapshot.value.session),
419
+ chainSessions: (0, import_vue4.computed)(() => snapshot.value.chainSessions),
420
+ activeChainId: (0, import_vue4.computed)(() => snapshot.value.activeChainId),
421
+ isConnected: (0, import_vue4.computed)(() => snapshot.value.session !== null),
422
+ connectorId: (0, import_vue4.computed)(() => snapshot.value.connectorId)
423
+ };
424
+ }
425
+
426
+ // src/useConnect.ts
427
+ var import_connect_core3 = require("@naculus/connect-core");
428
+ var import_vue5 = require("vue");
429
+ function useConnect(action, status) {
430
+ const isLoading = (0, import_vue5.shallowRef)(false);
431
+ const error = (0, import_vue5.shallowRef)(null);
432
+ let disposed = false;
433
+ let inFlight = null;
434
+ const connect = () => {
435
+ if (inFlight) return inFlight;
436
+ const invoke = (0, import_vue5.unref)(action);
437
+ isLoading.value = true;
438
+ error.value = null;
439
+ const pending = Promise.resolve().then(() => invoke()).catch((cause) => {
440
+ if (disposed) return;
441
+ const message = cause instanceof Error ? cause.message : "Connection failed";
442
+ error.value = cause instanceof import_connect_core3.WalletError ? cause : new Error(message);
443
+ }).finally(() => {
444
+ if (inFlight === pending) inFlight = null;
445
+ if (!disposed) isLoading.value = false;
446
+ });
447
+ inFlight = pending;
448
+ return pending;
449
+ };
450
+ (0, import_vue5.onScopeDispose)(() => {
451
+ disposed = true;
452
+ });
453
+ return {
454
+ connect,
455
+ isConnecting: (0, import_vue5.computed)(
456
+ () => isLoading.value || (0, import_vue5.toValue)(status) === "connecting"
457
+ ),
458
+ error
459
+ };
460
+ }
461
+
462
+ // src/useDisconnect.ts
463
+ var import_vue6 = require("vue");
464
+ function useDisconnect(action, status) {
465
+ const isDisconnecting = (0, import_vue6.shallowRef)(false);
466
+ const error = (0, import_vue6.shallowRef)(null);
467
+ let disposed = false;
468
+ let inFlight = null;
469
+ const disconnect = () => {
470
+ if (inFlight) return inFlight;
471
+ if ((0, import_vue6.toValue)(status) === "disconnected") return Promise.resolve();
472
+ const invoke = (0, import_vue6.unref)(action);
473
+ isDisconnecting.value = true;
474
+ error.value = null;
475
+ const pending = Promise.resolve().then(() => invoke()).catch((cause) => {
476
+ if (!disposed) {
477
+ error.value = cause instanceof Error ? cause : new Error("Disconnect failed");
478
+ }
479
+ }).finally(() => {
480
+ if (inFlight === pending) inFlight = null;
481
+ if (!disposed) isDisconnecting.value = false;
482
+ });
483
+ inFlight = pending;
484
+ return pending;
485
+ };
486
+ const cleanup = () => {
487
+ disposed = true;
488
+ };
489
+ (0, import_vue6.onScopeDispose)(cleanup);
490
+ return { disconnect, isDisconnecting, error, cleanup };
491
+ }
492
+
493
+ // src/useSwitchChain.ts
494
+ var import_connect_appkit_core2 = require("@naculus/connect-appkit-core");
495
+ var import_vue7 = require("vue");
496
+ function useSwitchChain(action, chainId) {
497
+ const isSwitching = (0, import_vue7.shallowRef)(false);
498
+ const error = (0, import_vue7.shallowRef)(null);
499
+ let generation = 0;
500
+ let active = 0;
501
+ let disposed = false;
502
+ const switchChain = async (targetChainId) => {
503
+ const invoke = (0, import_vue7.unref)(action);
504
+ const mine = ++generation;
505
+ active++;
506
+ isSwitching.value = true;
507
+ error.value = null;
508
+ try {
509
+ await invoke(targetChainId);
510
+ } catch (cause) {
511
+ const walletError = (0, import_connect_appkit_core2.toChainSwitchError)(cause);
512
+ if (!disposed && mine === generation) error.value = walletError;
513
+ throw walletError;
514
+ } finally {
515
+ active--;
516
+ if (!disposed) isSwitching.value = active > 0;
517
+ }
518
+ };
519
+ (0, import_vue7.onScopeDispose)(() => {
520
+ disposed = true;
521
+ generation++;
522
+ });
523
+ return {
524
+ switchChain,
525
+ isSwitching,
526
+ currentChainId: (0, import_vue7.computed)(() => (0, import_vue7.toValue)(chainId) ?? null),
527
+ error,
528
+ clearError: () => {
529
+ error.value = null;
530
+ }
531
+ };
532
+ }
533
+
534
+ // src/useBalance.ts
535
+ var import_connect_appkit_core3 = require("@naculus/connect-appkit-core");
536
+ var import_connect_core4 = require("@naculus/connect-core");
537
+ var import_vue8 = require("vue");
538
+ function useBalance(account, client, options = {}) {
539
+ const balance = (0, import_vue8.shallowRef)(null);
540
+ const isFetching = (0, import_vue8.shallowRef)(false);
541
+ const error = (0, import_vue8.shallowRef)(null);
542
+ let generation = 0;
543
+ let disposed = false;
544
+ let timer = null;
545
+ const refetch = async () => {
546
+ const reader = (0, import_vue8.toValue)(client);
547
+ const address = (0, import_connect_appkit_core3.bareEvmAddress)((0, import_vue8.toValue)(account));
548
+ const own = ++generation;
549
+ if (!reader || !address) {
550
+ balance.value = null;
551
+ error.value = null;
552
+ isFetching.value = false;
553
+ return;
554
+ }
555
+ isFetching.value = true;
556
+ error.value = null;
557
+ try {
558
+ const next = await reader.getBalance({ address });
559
+ if (disposed || own !== generation) return;
560
+ balance.value = next.toString();
561
+ } catch (cause) {
562
+ if (disposed || own !== generation) return;
563
+ balance.value = null;
564
+ error.value = cause instanceof Error ? cause : new Error("Balance read failed");
565
+ } finally {
566
+ if (!disposed && own === generation) isFetching.value = false;
567
+ }
568
+ };
569
+ const stopTimer = () => {
570
+ if (timer) clearInterval(timer);
571
+ timer = null;
572
+ };
573
+ (0, import_vue8.watch)(
574
+ [
575
+ () => (0, import_vue8.toValue)(account),
576
+ () => (0, import_vue8.toValue)(client),
577
+ () => (0, import_vue8.toValue)(options.refreshInterval) ?? 0
578
+ ],
579
+ ([, , interval]) => {
580
+ stopTimer();
581
+ void refetch();
582
+ if (interval > 0) timer = setInterval(() => void refetch(), interval);
583
+ },
584
+ { immediate: true }
585
+ );
586
+ (0, import_vue8.onScopeDispose)(() => {
587
+ disposed = true;
588
+ generation++;
589
+ stopTimer();
590
+ });
591
+ return {
592
+ balance,
593
+ formatted: (0, import_vue8.computed)(
594
+ () => balance.value === null ? null : (0, import_connect_core4.formatUnits)(BigInt(balance.value), (0, import_vue8.toValue)(options.decimals) ?? 18)
595
+ ),
596
+ symbol: (0, import_vue8.computed)(() => (0, import_vue8.toValue)(options.symbol) ?? null),
597
+ isFetching,
598
+ error,
599
+ refetch
600
+ };
601
+ }
602
+
603
+ // src/useRouteQuote.ts
604
+ var import_connect_appkit_core4 = require("@naculus/connect-appkit-core");
605
+ var import_vue9 = require("vue");
606
+ function useRouteQuote(input, getQuotes, options = {}) {
607
+ const quotes = (0, import_vue9.shallowRef)([]);
608
+ const loading = (0, import_vue9.shallowRef)(false);
609
+ const error = (0, import_vue9.shallowRef)(null);
610
+ let generation = 0;
611
+ let disposed = false;
612
+ let timer = null;
613
+ const clearTimer = () => {
614
+ if (timer) clearTimeout(timer);
615
+ timer = null;
616
+ };
617
+ const fetchQuotes = async () => {
618
+ const current = (0, import_vue9.toValue)(input);
619
+ const fn = (0, import_vue9.unref)(getQuotes);
620
+ const own = ++generation;
621
+ if (!(0, import_connect_appkit_core4.isQuotableInput)(current)) {
622
+ quotes.value = [];
623
+ return;
624
+ }
625
+ if (!fn) return;
626
+ loading.value = true;
627
+ error.value = null;
628
+ try {
629
+ const result = await fn(
630
+ current.fromChain,
631
+ current.toChain,
632
+ current.fromToken,
633
+ current.amount,
634
+ current.options,
635
+ current.toToken
636
+ );
637
+ if (disposed || own !== generation) return;
638
+ quotes.value = result;
639
+ } catch (cause) {
640
+ if (disposed || own !== generation) return;
641
+ error.value = cause instanceof Error ? cause : new Error(String(cause));
642
+ quotes.value = [];
643
+ } finally {
644
+ if (!disposed && own === generation) loading.value = false;
645
+ }
646
+ };
647
+ (0, import_vue9.watch)(
648
+ [
649
+ () => (0, import_vue9.toValue)(input).fromChain,
650
+ () => (0, import_vue9.toValue)(input).toChain,
651
+ () => (0, import_vue9.toValue)(input).fromToken,
652
+ () => (0, import_vue9.toValue)(input).toToken,
653
+ () => (0, import_vue9.toValue)(input).amount,
654
+ () => (0, import_vue9.unref)(getQuotes)
655
+ ],
656
+ ([fromChain, toChain, fromToken, , amount]) => {
657
+ clearTimer();
658
+ if (!fromChain || !toChain || !fromToken || !amount) {
659
+ quotes.value = [];
660
+ return;
661
+ }
662
+ timer = setTimeout(() => {
663
+ timer = null;
664
+ void fetchQuotes();
665
+ }, options.debounceMs ?? 300);
666
+ },
667
+ { immediate: true }
668
+ );
669
+ (0, import_vue9.onScopeDispose)(() => {
670
+ disposed = true;
671
+ generation++;
672
+ clearTimer();
673
+ });
674
+ return {
675
+ quotes,
676
+ loading,
677
+ error,
678
+ refresh: fetchQuotes,
679
+ clear: () => {
680
+ clearTimer();
681
+ generation++;
682
+ quotes.value = [];
683
+ error.value = null;
684
+ loading.value = false;
685
+ }
686
+ };
687
+ }
688
+
689
+ // src/useCompareCosts.ts
690
+ var import_connect_appkit_core5 = require("@naculus/connect-appkit-core");
691
+ var import_vue10 = require("vue");
692
+ function useCompareCosts(input, compareCosts) {
693
+ const comparisons = (0, import_vue10.shallowRef)([]);
694
+ const loading = (0, import_vue10.shallowRef)(false);
695
+ const error = (0, import_vue10.shallowRef)(null);
696
+ let generation = 0;
697
+ let disposed = false;
698
+ const fetchComparisons = async () => {
699
+ const { operation, chains, options } = (0, import_vue10.toValue)(input);
700
+ const fn = (0, import_vue10.unref)(compareCosts);
701
+ const own = ++generation;
702
+ if (!chains || chains.length === 0) {
703
+ comparisons.value = [];
704
+ return;
705
+ }
706
+ if (!fn) return;
707
+ loading.value = true;
708
+ error.value = null;
709
+ try {
710
+ const result = await fn(operation, chains, options);
711
+ if (disposed || own !== generation) return;
712
+ comparisons.value = result;
713
+ } catch (cause) {
714
+ if (disposed || own !== generation) return;
715
+ error.value = cause instanceof Error ? cause : new Error(String(cause));
716
+ comparisons.value = [];
717
+ } finally {
718
+ if (!disposed && own === generation) loading.value = false;
719
+ }
720
+ };
721
+ (0, import_vue10.watch)(
722
+ [() => (0, import_connect_appkit_core5.compareCostsKey)((0, import_vue10.toValue)(input)), () => (0, import_vue10.unref)(compareCosts)],
723
+ () => {
724
+ void fetchComparisons();
725
+ },
726
+ { immediate: true }
727
+ );
728
+ (0, import_vue10.onScopeDispose)(() => {
729
+ disposed = true;
730
+ generation++;
731
+ });
732
+ return { comparisons, loading, error, refresh: fetchComparisons };
733
+ }
734
+
735
+ // src/useExecuteRoute.ts
736
+ var import_connect_appkit_core6 = require("@naculus/connect-appkit-core");
737
+ var import_vue11 = require("vue");
738
+ function useExecuteRoute(executeRoute) {
739
+ const executing = (0, import_vue11.shallowRef)(false);
740
+ const result = (0, import_vue11.shallowRef)(null);
741
+ const error = (0, import_vue11.shallowRef)(null);
742
+ let inFlight = false;
743
+ let disposed = false;
744
+ const execute = async (quote, recipient, options) => {
745
+ const fn = (0, import_vue11.unref)(executeRoute);
746
+ if (!fn) {
747
+ error.value = {
748
+ code: "no_executor",
749
+ message: "No executeRoute function provided"
750
+ };
751
+ result.value = null;
752
+ return null;
753
+ }
754
+ const recipientError = (0, import_connect_appkit_core6.validateRouteRecipient)(quote, recipient);
755
+ if (recipientError) {
756
+ error.value = recipientError;
757
+ result.value = null;
758
+ return null;
759
+ }
760
+ if (inFlight) {
761
+ error.value = {
762
+ code: "execution_in_progress",
763
+ message: "A route execution is already in progress"
764
+ };
765
+ return null;
766
+ }
767
+ inFlight = true;
768
+ executing.value = true;
769
+ error.value = null;
770
+ result.value = null;
771
+ try {
772
+ const execResult = await fn(quote, recipient, options);
773
+ if (!disposed) result.value = execResult;
774
+ return execResult;
775
+ } catch (cause) {
776
+ if (!disposed) error.value = (0, import_connect_appkit_core6.toExecuteRouteError)(cause);
777
+ return null;
778
+ } finally {
779
+ inFlight = false;
780
+ if (!disposed) executing.value = false;
781
+ }
782
+ };
783
+ (0, import_vue11.onScopeDispose)(() => {
784
+ disposed = true;
785
+ });
786
+ return {
787
+ execute,
788
+ executing,
789
+ result,
790
+ error,
791
+ reset: () => {
792
+ result.value = null;
793
+ error.value = null;
794
+ executing.value = false;
795
+ }
796
+ };
797
+ }
798
+
799
+ // src/useTokenList.ts
800
+ var import_connect_appkit_core7 = require("@naculus/connect-appkit-core");
801
+ var import_connect_core5 = require("@naculus/connect-core");
802
+ var import_vue12 = require("vue");
803
+ function useTokenList(chainId, options = {}) {
804
+ const config = {};
805
+ if (options.sources) config.sources = options.sources;
806
+ const manager = options.manager ?? new import_connect_core5.TokenListManager(config);
807
+ const tokens = (0, import_vue12.shallowRef)([]);
808
+ const isLoading = (0, import_vue12.shallowRef)(options.autoLoad !== false);
809
+ const isLoaded = (0, import_vue12.shallowRef)(false);
810
+ const error = (0, import_vue12.shallowRef)(null);
811
+ let generation = 0;
812
+ let disposed = false;
813
+ const select = () => {
814
+ const id = (0, import_vue12.toValue)(chainId);
815
+ const numeric = id ? (0, import_connect_appkit_core7.eip155ChainIdToNumber)(id) : void 0;
816
+ return manager.getTokens(
817
+ numeric !== void 0 ? { chainId: numeric } : void 0
818
+ );
819
+ };
820
+ const run = async (op) => {
821
+ const own = ++generation;
822
+ isLoading.value = true;
823
+ error.value = null;
824
+ try {
825
+ await op();
826
+ if (disposed || own !== generation) return;
827
+ tokens.value = select();
828
+ isLoaded.value = true;
829
+ } catch (cause) {
830
+ if (disposed || own !== generation) return;
831
+ error.value = cause instanceof Error ? cause : new Error(String(cause));
832
+ } finally {
833
+ if (!disposed && own === generation) isLoading.value = false;
834
+ }
835
+ };
836
+ (0, import_vue12.watch)(
837
+ () => (0, import_vue12.toValue)(chainId),
838
+ () => {
839
+ if (options.autoLoad !== false) void run(() => manager.load());
840
+ },
841
+ { immediate: true }
842
+ );
843
+ (0, import_vue12.onScopeDispose)(() => {
844
+ disposed = true;
845
+ generation++;
846
+ });
847
+ return {
848
+ tokens,
849
+ isLoading,
850
+ isLoaded,
851
+ error,
852
+ refetch: () => run(() => manager.refresh())
853
+ };
854
+ }
855
+
856
+ // src/useTokenSearch.ts
857
+ var import_connect_appkit_core8 = require("@naculus/connect-appkit-core");
858
+ var import_connect_core6 = require("@naculus/connect-core");
859
+ var import_vue13 = require("vue");
860
+ var DEBOUNCE_MS = 300;
861
+ var EMPTY = { exact: [], fuzzy: [], hasMore: false };
862
+ var sharedManager = null;
863
+ function getSharedManager() {
864
+ if (!sharedManager) {
865
+ sharedManager = new import_connect_core6.TokenListManager();
866
+ sharedManager.load().catch(() => {
867
+ });
868
+ }
869
+ return sharedManager;
870
+ }
871
+ function useTokenSearch(query, chainId, options = {}) {
872
+ const results = (0, import_vue13.shallowRef)(EMPTY);
873
+ const isSearching = (0, import_vue13.shallowRef)(false);
874
+ let timer = null;
875
+ const clear = () => {
876
+ if (timer) clearTimeout(timer);
877
+ timer = null;
878
+ };
879
+ (0, import_vue13.watch)(
880
+ [() => ((0, import_vue13.toValue)(query) ?? "").trim(), () => (0, import_vue13.toValue)(chainId)],
881
+ ([q, id]) => {
882
+ clear();
883
+ if (!q) {
884
+ results.value = EMPTY;
885
+ isSearching.value = false;
886
+ return;
887
+ }
888
+ isSearching.value = true;
889
+ timer = setTimeout(() => {
890
+ timer = null;
891
+ const manager = options.manager ?? getSharedManager();
892
+ const numeric = id ? (0, import_connect_appkit_core8.eip155ChainIdToNumber)(id) : void 0;
893
+ results.value = manager.search(q, {
894
+ chainId: numeric,
895
+ limit: options.limit ?? 20
896
+ });
897
+ isSearching.value = false;
898
+ }, options.debounceMs ?? DEBOUNCE_MS);
899
+ },
900
+ { immediate: true }
901
+ );
902
+ (0, import_vue13.onScopeDispose)(clear);
903
+ return { results, isSearching };
904
+ }
905
+
906
+ // src/useValidateDestination.ts
907
+ var import_connect_appkit_core9 = require("@naculus/connect-appkit-core");
908
+ var import_vue14 = require("vue");
909
+ function useValidateDestination(address) {
910
+ return {
911
+ validation: (0, import_vue14.computed)(() => (0, import_connect_appkit_core9.validateDestination)((0, import_vue14.toValue)(address) ?? ""))
912
+ };
913
+ }
914
+
915
+ // src/useTokenBalance.ts
916
+ var import_connect_appkit_core10 = require("@naculus/connect-appkit-core");
917
+ var import_connect_core7 = require("@naculus/connect-core");
918
+ var import_vue15 = require("vue");
919
+ function tokensKey(tokens) {
920
+ return tokens.map((t) => `${t.address.toLowerCase()}|${t.decimals}|${t.symbol}`).join(",");
921
+ }
922
+ function useTokenBalance(account, client, tokens, options = {}) {
923
+ const tokenBalances = (0, import_vue15.shallowRef)([]);
924
+ const isFetching = (0, import_vue15.shallowRef)(false);
925
+ const error = (0, import_vue15.shallowRef)(null);
926
+ let generation = 0;
927
+ let disposed = false;
928
+ let timer = null;
929
+ const refetch = async () => {
930
+ const reader = (0, import_vue15.toValue)(client);
931
+ const address = (0, import_connect_appkit_core10.bareEvmAddress)((0, import_vue15.toValue)(account));
932
+ const list = (0, import_vue15.toValue)(tokens) ?? [];
933
+ const own = ++generation;
934
+ if (!reader || !address || list.length === 0) {
935
+ tokenBalances.value = [];
936
+ error.value = null;
937
+ isFetching.value = false;
938
+ return;
939
+ }
940
+ isFetching.value = true;
941
+ error.value = null;
942
+ try {
943
+ const results = await Promise.all(
944
+ list.map(async (token) => {
945
+ try {
946
+ const raw = await reader.readContract({
947
+ address: token.address,
948
+ abi: import_connect_core7.ERC20_MIN_ABI,
949
+ functionName: "balanceOf",
950
+ args: [address]
951
+ });
952
+ const value = BigInt(raw);
953
+ return {
954
+ ...token,
955
+ balance: value.toString(),
956
+ formatted: (0, import_connect_core7.formatUnits)(value, token.decimals)
957
+ };
958
+ } catch {
959
+ return { ...token, balance: null, formatted: null };
960
+ }
961
+ })
962
+ );
963
+ if (disposed || own !== generation) return;
964
+ tokenBalances.value = results;
965
+ } catch (cause) {
966
+ if (disposed || own !== generation) return;
967
+ tokenBalances.value = [];
968
+ error.value = cause instanceof Error ? cause : new Error("Failed to fetch token balances");
969
+ } finally {
970
+ if (!disposed && own === generation) isFetching.value = false;
971
+ }
972
+ };
973
+ const stopTimer = () => {
974
+ if (timer) clearInterval(timer);
975
+ timer = null;
976
+ };
977
+ (0, import_vue15.watch)(
978
+ [
979
+ () => (0, import_vue15.toValue)(account),
980
+ () => (0, import_vue15.toValue)(client),
981
+ () => tokensKey((0, import_vue15.toValue)(tokens) ?? []),
982
+ () => (0, import_vue15.toValue)(options.refreshInterval) ?? 0
983
+ ],
984
+ ([, , , interval]) => {
985
+ stopTimer();
986
+ void refetch();
987
+ if (interval > 0) timer = setInterval(() => void refetch(), interval);
988
+ },
989
+ { immediate: true }
990
+ );
991
+ (0, import_vue15.onScopeDispose)(() => {
992
+ disposed = true;
993
+ generation++;
994
+ stopTimer();
995
+ });
996
+ return {
997
+ tokenBalances,
998
+ isFetching,
999
+ error,
1000
+ refetch,
1001
+ getTokenBalance: (tokenAddress) => tokenBalances.value.find(
1002
+ (t) => t.address.toLowerCase() === tokenAddress.toLowerCase()
1003
+ )
1004
+ };
1005
+ }
1006
+
1007
+ // src/useDelegation.ts
1008
+ var import_connect_appkit_core11 = require("@naculus/connect-appkit-core");
1009
+ var import_connect_core8 = require("@naculus/connect-core");
1010
+ var import_vue16 = require("vue");
1011
+ function useDelegation(account, client, chainId) {
1012
+ const status = (0, import_vue16.shallowRef)(import_connect_core8.UNKNOWN_DELEGATION);
1013
+ const isFetching = (0, import_vue16.shallowRef)(false);
1014
+ const error = (0, import_vue16.shallowRef)(null);
1015
+ let generation = 0;
1016
+ let disposed = false;
1017
+ const refetch = async () => {
1018
+ const mine = ++generation;
1019
+ const reader = (0, import_vue16.toValue)(client);
1020
+ const address = (0, import_connect_appkit_core11.bareEvmAddress)((0, import_vue16.toValue)(account));
1021
+ status.value = import_connect_core8.UNKNOWN_DELEGATION;
1022
+ error.value = null;
1023
+ if (!reader || !address) {
1024
+ isFetching.value = false;
1025
+ return;
1026
+ }
1027
+ isFetching.value = true;
1028
+ try {
1029
+ const code = await reader.getCode({ address });
1030
+ if (!disposed && mine === generation) {
1031
+ status.value = (0, import_connect_core8.readDelegation)(code ?? "0x");
1032
+ }
1033
+ } catch (cause) {
1034
+ if (!disposed && mine === generation) {
1035
+ status.value = import_connect_core8.UNKNOWN_DELEGATION;
1036
+ error.value = cause instanceof Error ? cause : new Error("Code read failed");
1037
+ }
1038
+ } finally {
1039
+ if (!disposed && mine === generation) isFetching.value = false;
1040
+ }
1041
+ };
1042
+ (0, import_vue16.watch)(
1043
+ () => [(0, import_vue16.toValue)(account), (0, import_vue16.toValue)(client), (0, import_vue16.toValue)(chainId)],
1044
+ () => {
1045
+ void refetch();
1046
+ },
1047
+ { immediate: true, flush: "sync" }
1048
+ );
1049
+ (0, import_vue16.onScopeDispose)(() => {
1050
+ disposed = true;
1051
+ generation++;
1052
+ });
1053
+ return {
1054
+ delegated: (0, import_vue16.computed)(() => status.value.delegated),
1055
+ delegate: (0, import_vue16.computed)(() => status.value.delegate),
1056
+ isFetching,
1057
+ error,
1058
+ refetch
1059
+ };
1060
+ }
1061
+
1062
+ // src/name-lookup.ts
1063
+ var import_connect_appkit_core12 = require("@naculus/connect-appkit-core");
1064
+ var import_vue17 = require("vue");
1065
+ function useNameLookup(options) {
1066
+ const data = (0, import_vue17.shallowRef)(null);
1067
+ const loading = (0, import_vue17.shallowRef)(false);
1068
+ const error = (0, import_vue17.shallowRef)(null);
1069
+ let generation = 0;
1070
+ let disposed = false;
1071
+ const run = () => {
1072
+ const input = (0, import_vue17.toValue)(options.input).trim();
1073
+ const skip = (0, import_vue17.toValue)(options.skip) ?? false;
1074
+ const scope = (0, import_vue17.toValue)(options.scope);
1075
+ const config = (0, import_vue17.toValue)(options.resolverConfig);
1076
+ const mine = ++generation;
1077
+ if (!input || skip) {
1078
+ data.value = null;
1079
+ loading.value = false;
1080
+ error.value = null;
1081
+ return;
1082
+ }
1083
+ data.value = null;
1084
+ loading.value = true;
1085
+ error.value = null;
1086
+ Promise.resolve().then(() => options.query((0, import_connect_appkit_core12.getResolver)(config), input, scope)).then((result) => {
1087
+ if (disposed || mine !== generation) return;
1088
+ data.value = result;
1089
+ loading.value = false;
1090
+ }).catch((cause) => {
1091
+ if (disposed || mine !== generation) return;
1092
+ data.value = null;
1093
+ error.value = cause instanceof Error ? cause : new Error(String(cause));
1094
+ loading.value = false;
1095
+ });
1096
+ };
1097
+ (0, import_vue17.watch)(
1098
+ () => [
1099
+ (0, import_vue17.toValue)(options.input),
1100
+ (0, import_vue17.toValue)(options.skip),
1101
+ (0, import_vue17.toValue)(options.scope),
1102
+ (0, import_vue17.toValue)(options.resolverConfig)
1103
+ ],
1104
+ run,
1105
+ { immediate: true, flush: "sync", deep: true }
1106
+ );
1107
+ (0, import_vue17.onScopeDispose)(() => {
1108
+ disposed = true;
1109
+ generation++;
1110
+ });
1111
+ return {
1112
+ data,
1113
+ isLoading: (0, import_vue17.computed)(() => loading.value),
1114
+ error,
1115
+ refetch: run
1116
+ };
1117
+ }
1118
+
1119
+ // src/useResolveName.ts
1120
+ function useResolveName(name, options) {
1121
+ return useNameLookup({
1122
+ input: name,
1123
+ skip: options?.skip,
1124
+ resolverConfig: options?.resolverConfig,
1125
+ query: (resolver, input) => resolver.resolveName(input)
1126
+ });
1127
+ }
1128
+
1129
+ // src/useLookupAddress.ts
1130
+ function useLookupAddress(address, options) {
1131
+ return useNameLookup({
1132
+ input: address,
1133
+ scope: options?.chainId,
1134
+ skip: options?.skip,
1135
+ resolverConfig: options?.resolverConfig,
1136
+ query: (resolver, input, scope) => resolver.lookupAddress(input, scope)
1137
+ });
1138
+ }
1139
+
1140
+ // src/useSolanaAccount.ts
1141
+ var import_vue18 = require("vue");
1142
+ function useSolanaAccount(accounts, connected) {
1143
+ const isConnected = (0, import_vue18.computed)(() => (0, import_vue18.toValue)(connected));
1144
+ const caip10 = (0, import_vue18.computed)(
1145
+ () => isConnected.value ? ((0, import_vue18.toValue)(accounts) ?? []).find(
1146
+ (account) => account.startsWith("solana:")
1147
+ ) ?? null : null
1148
+ );
1149
+ const parts = (0, import_vue18.computed)(() => caip10.value?.split(":") ?? []);
1150
+ return {
1151
+ address: (0, import_vue18.computed)(
1152
+ () => parts.value.length >= 3 ? parts.value.at(-1) ?? null : null
1153
+ ),
1154
+ caip10,
1155
+ chainId: (0, import_vue18.computed)(
1156
+ () => parts.value.length >= 3 ? parts.value.slice(0, -1).join(":") : null
1157
+ ),
1158
+ isConnected
1159
+ };
1160
+ }
1161
+
1162
+ // src/useChain.ts
1163
+ var import_connect_appkit_core13 = require("@naculus/connect-appkit-core");
1164
+ var import_vue19 = require("vue");
274
1165
  function useChain(chains, chainId) {
275
- const list = (0, import_vue2.computed)(() => (0, import_vue2.toValue)(chains) ?? []);
276
- const id = (0, import_vue2.computed)(() => (0, import_vue2.toValue)(chainId) ?? null);
277
- const currentChain = (0, import_vue2.computed)(() => (0, import_connect_appkit_core.resolveChain)(list.value, id.value));
1166
+ const list = (0, import_vue19.computed)(() => (0, import_vue19.toValue)(chains) ?? []);
1167
+ const id = (0, import_vue19.computed)(() => (0, import_vue19.toValue)(chainId) ?? null);
1168
+ const currentChain = (0, import_vue19.computed)(() => (0, import_connect_appkit_core13.resolveChain)(list.value, id.value));
278
1169
  return {
279
1170
  currentChain,
280
- chainInfo: (0, import_vue2.computed)(() => (0, import_connect_appkit_core.describeChain)(list.value, id.value)),
281
- availableChains: (0, import_vue2.computed)(() => (0, import_connect_appkit_core.chainsForNamespace)(list.value, id.value)),
282
- currentChainNumber: (0, import_vue2.computed)(
283
- () => currentChain.value ? (0, import_connect_appkit_core.chainNumber)(currentChain.value) : null
1171
+ chainInfo: (0, import_vue19.computed)(() => (0, import_connect_appkit_core13.describeChain)(list.value, id.value)),
1172
+ availableChains: (0, import_vue19.computed)(() => (0, import_connect_appkit_core13.chainsForNamespace)(list.value, id.value)),
1173
+ currentChainNumber: (0, import_vue19.computed)(
1174
+ () => currentChain.value ? (0, import_connect_appkit_core13.chainNumber)(currentChain.value) : null
284
1175
  ),
285
- namespace: (0, import_vue2.computed)(
286
- () => currentChain.value ? (0, import_connect_appkit_core.chainNamespace)(currentChain.value) : null
1176
+ namespace: (0, import_vue19.computed)(
1177
+ () => currentChain.value ? (0, import_connect_appkit_core13.chainNamespace)(currentChain.value) : null
287
1178
  )
288
1179
  };
289
1180
  }
290
1181
 
291
1182
  // src/usePassphraseGate.ts
292
- var import_vue3 = require("vue");
1183
+ var import_vue20 = require("vue");
293
1184
  function usePassphraseGate(gate) {
294
- const request = (0, import_vue3.shallowRef)(gate.getSnapshot());
1185
+ const request = (0, import_vue20.shallowRef)(gate.getSnapshot());
295
1186
  const unsubscribe = gate.subscribe(() => {
296
1187
  request.value = gate.getSnapshot();
297
1188
  });
298
- (0, import_vue3.onScopeDispose)(unsubscribe);
1189
+ (0, import_vue20.onScopeDispose)(unsubscribe);
299
1190
  return {
300
- request: (0, import_vue3.readonly)(request),
1191
+ request: (0, import_vue20.readonly)(request),
301
1192
  submit: (passphrase) => gate.submit(passphrase),
302
1193
  cancel: (reason) => gate.cancel(reason),
303
1194
  forget: (reason) => gate.forget(reason)
@@ -305,17 +1196,17 @@ function usePassphraseGate(gate) {
305
1196
  }
306
1197
 
307
1198
  // src/useSolanaBalance.ts
308
- var import_connect_core2 = require("@naculus/connect-core");
309
- var import_vue4 = require("vue");
1199
+ var import_connect_core9 = require("@naculus/connect-core");
1200
+ var import_vue21 = require("vue");
310
1201
  function useSolanaBalance(address, rpcUrl) {
311
- const balance = (0, import_vue4.shallowRef)(null);
312
- const isFetching = (0, import_vue4.ref)(false);
313
- const error = (0, import_vue4.shallowRef)(null);
1202
+ const balance = (0, import_vue21.shallowRef)(null);
1203
+ const isFetching = (0, import_vue21.ref)(false);
1204
+ const error = (0, import_vue21.shallowRef)(null);
314
1205
  let generation = 0;
315
1206
  let disposed = false;
316
1207
  const refetch = async () => {
317
- const addr = (0, import_vue4.toValue)(address);
318
- const url = (0, import_vue4.toValue)(rpcUrl);
1208
+ const addr = (0, import_vue21.toValue)(address);
1209
+ const url = (0, import_vue21.toValue)(rpcUrl);
319
1210
  if (!addr || !url) {
320
1211
  balance.value = null;
321
1212
  return;
@@ -324,7 +1215,7 @@ function useSolanaBalance(address, rpcUrl) {
324
1215
  isFetching.value = true;
325
1216
  error.value = null;
326
1217
  try {
327
- const next = await (0, import_connect_core2.getSolanaBalance)(url, addr);
1218
+ const next = await (0, import_connect_core9.getSolanaBalance)(url, addr);
328
1219
  if (disposed || own !== generation) return;
329
1220
  balance.value = next;
330
1221
  } catch (err) {
@@ -335,31 +1226,221 @@ function useSolanaBalance(address, rpcUrl) {
335
1226
  if (!disposed && own === generation) isFetching.value = false;
336
1227
  }
337
1228
  };
338
- (0, import_vue4.watchEffect)(() => {
339
- (0, import_vue4.toValue)(address);
340
- (0, import_vue4.toValue)(rpcUrl);
1229
+ (0, import_vue21.watchEffect)(() => {
1230
+ (0, import_vue21.toValue)(address);
1231
+ (0, import_vue21.toValue)(rpcUrl);
341
1232
  void refetch();
342
1233
  });
343
- (0, import_vue4.onScopeDispose)(() => {
1234
+ (0, import_vue21.onScopeDispose)(() => {
344
1235
  disposed = true;
345
1236
  });
346
1237
  return { balance, isFetching, error, refetch };
347
1238
  }
348
1239
 
1240
+ // src/useLastTx.ts
1241
+ var import_vue22 = require("vue");
1242
+ function useLastTx(monitor) {
1243
+ const lastTx = (0, import_vue22.shallowRef)(null);
1244
+ const lastConfirmedTx = (0, import_vue22.shallowRef)(null);
1245
+ const lastFailedTx = (0, import_vue22.shallowRef)(null);
1246
+ (0, import_vue22.watch)(
1247
+ () => (0, import_vue22.toValue)(monitor),
1248
+ (activeMonitor, _previous, onCleanup) => {
1249
+ if (!activeMonitor) return;
1250
+ const recordLatest = (entry) => {
1251
+ if (!lastTx.value || entry.createdAt >= lastTx.value.createdAt) {
1252
+ lastTx.value = entry;
1253
+ }
1254
+ };
1255
+ const onConfirmed = (entry) => {
1256
+ lastConfirmedTx.value = entry;
1257
+ recordLatest(entry);
1258
+ };
1259
+ const onFailed = (entry) => {
1260
+ lastFailedTx.value = entry;
1261
+ recordLatest(entry);
1262
+ };
1263
+ activeMonitor.on("confirmed", onConfirmed);
1264
+ activeMonitor.on("failed", onFailed);
1265
+ onCleanup(() => {
1266
+ activeMonitor.off("confirmed", onConfirmed);
1267
+ activeMonitor.off("failed", onFailed);
1268
+ });
1269
+ },
1270
+ { immediate: true }
1271
+ );
1272
+ return {
1273
+ lastTx,
1274
+ lastConfirmedTx,
1275
+ lastFailedTx,
1276
+ clear: () => {
1277
+ lastTx.value = null;
1278
+ lastConfirmedTx.value = null;
1279
+ lastFailedTx.value = null;
1280
+ }
1281
+ };
1282
+ }
1283
+
1284
+ // src/useTxHistory.ts
1285
+ var import_vue23 = require("vue");
1286
+ function useTxHistory(address, chainId, monitor) {
1287
+ const entries = (0, import_vue23.shallowRef)([]);
1288
+ const isLoading = (0, import_vue23.shallowRef)(false);
1289
+ const error = (0, import_vue23.shallowRef)(null);
1290
+ let generation = 0;
1291
+ const refresh = async () => {
1292
+ const mine = ++generation;
1293
+ const activeMonitor = (0, import_vue23.toValue)(monitor);
1294
+ if (!activeMonitor) {
1295
+ entries.value = [];
1296
+ isLoading.value = false;
1297
+ error.value = null;
1298
+ return;
1299
+ }
1300
+ isLoading.value = true;
1301
+ error.value = null;
1302
+ try {
1303
+ const result = await activeMonitor.getTxHistory(
1304
+ (0, import_vue23.toValue)(address) ?? void 0,
1305
+ (0, import_vue23.toValue)(chainId) ?? void 0
1306
+ );
1307
+ if (mine === generation) entries.value = result;
1308
+ } catch (err) {
1309
+ if (mine !== generation) return;
1310
+ error.value = err instanceof Error ? err : new Error("Failed to load transaction history");
1311
+ } finally {
1312
+ if (mine === generation) isLoading.value = false;
1313
+ }
1314
+ };
1315
+ (0, import_vue23.watch)(
1316
+ () => [(0, import_vue23.toValue)(monitor), (0, import_vue23.toValue)(address), (0, import_vue23.toValue)(chainId)],
1317
+ ([activeMonitor], _previous, onCleanup) => {
1318
+ if (!activeMonitor) {
1319
+ void refresh();
1320
+ return;
1321
+ }
1322
+ const onStatusChange = () => {
1323
+ void refresh();
1324
+ };
1325
+ activeMonitor.on("statusChange", onStatusChange);
1326
+ onCleanup(() => activeMonitor.off("statusChange", onStatusChange));
1327
+ void refresh();
1328
+ },
1329
+ { immediate: true }
1330
+ );
1331
+ return {
1332
+ entries,
1333
+ isLoading,
1334
+ error,
1335
+ refresh,
1336
+ summary: (0, import_vue23.computed)(() => ({
1337
+ pending: entries.value.filter((item) => item.status === "pending").length,
1338
+ confirmed: entries.value.filter((item) => item.status === "confirmed").length,
1339
+ failed: entries.value.filter((item) => item.status === "failed").length
1340
+ }))
1341
+ };
1342
+ }
1343
+
1344
+ // src/useTxMonitor.ts
1345
+ var import_vue24 = require("vue");
1346
+ function useTxMonitor(hash, chainId, monitor) {
1347
+ const entry = (0, import_vue24.shallowRef)(null);
1348
+ const isLoading = (0, import_vue24.shallowRef)(false);
1349
+ const isWatching = (0, import_vue24.shallowRef)(false);
1350
+ const error = (0, import_vue24.shallowRef)(null);
1351
+ let generation = 0;
1352
+ const refresh = async () => {
1353
+ const activeMonitor = (0, import_vue24.toValue)(monitor);
1354
+ const activeHash = (0, import_vue24.toValue)(hash);
1355
+ const activeChainId = (0, import_vue24.toValue)(chainId);
1356
+ if (!activeMonitor || !activeHash) return;
1357
+ isLoading.value = true;
1358
+ error.value = null;
1359
+ try {
1360
+ await activeMonitor.refreshTx(activeHash, activeChainId ?? void 0);
1361
+ const current = activeMonitor.getTxStatus(
1362
+ activeHash,
1363
+ activeChainId ?? void 0
1364
+ );
1365
+ if (current) entry.value = current;
1366
+ } catch (err) {
1367
+ error.value = err instanceof Error ? err : new Error("Failed to refresh transaction");
1368
+ } finally {
1369
+ isLoading.value = false;
1370
+ }
1371
+ };
1372
+ const stopWatching = () => {
1373
+ const activeMonitor = (0, import_vue24.toValue)(monitor);
1374
+ const activeHash = (0, import_vue24.toValue)(hash);
1375
+ const activeChainId = (0, import_vue24.toValue)(chainId);
1376
+ if (!activeMonitor || !activeHash) return;
1377
+ activeMonitor.stopWatching(activeHash, activeChainId ?? void 0);
1378
+ isWatching.value = false;
1379
+ };
1380
+ (0, import_vue24.watch)(
1381
+ () => [(0, import_vue24.toValue)(monitor), (0, import_vue24.toValue)(hash), (0, import_vue24.toValue)(chainId)],
1382
+ ([activeMonitor, activeHash, activeChainId], _previous, onCleanup) => {
1383
+ const mine = ++generation;
1384
+ if (!activeMonitor || !activeHash || !activeChainId) {
1385
+ entry.value = null;
1386
+ isLoading.value = false;
1387
+ isWatching.value = false;
1388
+ error.value = null;
1389
+ return;
1390
+ }
1391
+ let cancelled = false;
1392
+ const onStatusChange = (updated) => {
1393
+ if (!cancelled && updated.hash === activeHash && updated.chainId === activeChainId) {
1394
+ entry.value = { ...updated };
1395
+ }
1396
+ };
1397
+ activeMonitor.on("statusChange", onStatusChange);
1398
+ onCleanup(() => {
1399
+ cancelled = true;
1400
+ activeMonitor.off("statusChange", onStatusChange);
1401
+ });
1402
+ isWatching.value = true;
1403
+ isLoading.value = true;
1404
+ error.value = null;
1405
+ const current = activeMonitor.getTxStatus(activeHash, activeChainId);
1406
+ if (current) entry.value = current;
1407
+ activeMonitor.watchTx(activeHash, activeChainId, {}).then((initial) => {
1408
+ if (cancelled || mine !== generation) return;
1409
+ entry.value = initial;
1410
+ isLoading.value = false;
1411
+ }).catch((err) => {
1412
+ if (cancelled || mine !== generation) return;
1413
+ error.value = err instanceof Error ? err : new Error("Failed to watch transaction");
1414
+ isLoading.value = false;
1415
+ });
1416
+ },
1417
+ { immediate: true }
1418
+ );
1419
+ return {
1420
+ entry,
1421
+ status: (0, import_vue24.computed)(() => entry.value?.status ?? "idle"),
1422
+ isLoading,
1423
+ isWatching,
1424
+ error,
1425
+ refresh,
1426
+ stopWatching
1427
+ };
1428
+ }
1429
+
349
1430
  // src/useCapabilities.ts
350
- var import_connect_appkit_core2 = require("@naculus/connect-appkit-core");
351
- var import_vue5 = require("vue");
1431
+ var import_connect_appkit_core14 = require("@naculus/connect-appkit-core");
1432
+ var import_vue25 = require("vue");
352
1433
  function useCapabilities(client, session, chainId) {
353
- const capabilities = (0, import_vue5.shallowRef)(
1434
+ const capabilities = (0, import_vue25.shallowRef)(
354
1435
  null
355
1436
  );
356
- const isFetching = (0, import_vue5.shallowRef)(false);
357
- const error = (0, import_vue5.shallowRef)(null);
1437
+ const isFetching = (0, import_vue25.shallowRef)(false);
1438
+ const error = (0, import_vue25.shallowRef)(null);
358
1439
  let generation = 0;
359
1440
  const refetch = async () => {
360
1441
  const mine = ++generation;
361
- const activeClient = (0, import_vue5.toValue)(client);
362
- const activeSession = (0, import_vue5.toValue)(session);
1442
+ const activeClient = (0, import_vue25.toValue)(client);
1443
+ const activeSession = (0, import_vue25.toValue)(session);
363
1444
  if (!activeClient?.getCapabilities || !activeSession) {
364
1445
  capabilities.value = null;
365
1446
  isFetching.value = false;
@@ -371,7 +1452,7 @@ function useCapabilities(client, session, chainId) {
371
1452
  try {
372
1453
  const raw = await activeClient.getCapabilities(activeSession);
373
1454
  if (mine !== generation) return;
374
- capabilities.value = (0, import_connect_appkit_core2.normalizeCapabilities)(raw);
1455
+ capabilities.value = (0, import_connect_appkit_core14.normalizeCapabilities)(raw);
375
1456
  } catch (err) {
376
1457
  if (mine !== generation) return;
377
1458
  capabilities.value = null;
@@ -380,18 +1461,18 @@ function useCapabilities(client, session, chainId) {
380
1461
  if (mine === generation) isFetching.value = false;
381
1462
  }
382
1463
  };
383
- (0, import_vue5.watchEffect)(() => {
384
- void (0, import_vue5.toValue)(client);
385
- void (0, import_vue5.toValue)(session);
1464
+ (0, import_vue25.watchEffect)(() => {
1465
+ void (0, import_vue25.toValue)(client);
1466
+ void (0, import_vue25.toValue)(session);
386
1467
  void refetch();
387
1468
  });
388
1469
  return {
389
1470
  capabilities,
390
- current: (0, import_vue5.computed)(
391
- () => (0, import_connect_appkit_core2.selectChainCapabilities)(capabilities.value, (0, import_vue5.toValue)(chainId))
1471
+ current: (0, import_vue25.computed)(
1472
+ () => (0, import_connect_appkit_core14.selectChainCapabilities)(capabilities.value, (0, import_vue25.toValue)(chainId))
392
1473
  ),
393
- atomic: (0, import_vue5.computed)(
394
- () => (0, import_connect_appkit_core2.atomicSupportFor)(capabilities.value, (0, import_vue5.toValue)(chainId))
1474
+ atomic: (0, import_vue25.computed)(
1475
+ () => (0, import_connect_appkit_core14.atomicSupportFor)(capabilities.value, (0, import_vue25.toValue)(chainId))
395
1476
  ),
396
1477
  isFetching,
397
1478
  error,
@@ -400,18 +1481,18 @@ function useCapabilities(client, session, chainId) {
400
1481
  }
401
1482
 
402
1483
  // src/useSolanaRoles.ts
403
- var import_connect_appkit_core3 = require("@naculus/connect-appkit-core");
404
- var import_vue6 = require("vue");
1484
+ var import_connect_appkit_core15 = require("@naculus/connect-appkit-core");
1485
+ var import_vue26 = require("vue");
405
1486
  function useSolanaRoles(connector, session) {
406
- const state = (0, import_vue6.computed)(
407
- () => (0, import_connect_appkit_core3.readSolanaRoles)((0, import_vue6.toValue)(connector), (0, import_vue6.toValue)(session))
1487
+ const state = (0, import_vue26.computed)(
1488
+ () => (0, import_connect_appkit_core15.readSolanaRoles)((0, import_vue26.toValue)(connector), (0, import_vue26.toValue)(session))
408
1489
  );
409
1490
  return {
410
- roles: (0, import_vue6.computed)(() => state.value.roles),
411
- absence: (0, import_vue6.computed)(() => state.value.absence),
412
- identity: (0, import_vue6.computed)(() => state.value.roles?.identity ?? null),
413
- signer: (0, import_vue6.computed)(() => state.value.roles?.signer ?? null),
414
- payer: (0, import_vue6.computed)(() => state.value.roles?.payer ?? null)
1491
+ roles: (0, import_vue26.computed)(() => state.value.roles),
1492
+ absence: (0, import_vue26.computed)(() => state.value.absence),
1493
+ identity: (0, import_vue26.computed)(() => state.value.roles?.identity ?? null),
1494
+ signer: (0, import_vue26.computed)(() => state.value.roles?.signer ?? null),
1495
+ payer: (0, import_vue26.computed)(() => state.value.roles?.payer ?? null)
415
1496
  };
416
1497
  }
417
1498
  // Annotate the CommonJS export names for ESM import in node:
@@ -444,11 +1525,32 @@ function useSolanaRoles(connector, session) {
444
1525
  AppkitTabs,
445
1526
  AppkitToggleGroup,
446
1527
  AppkitTooltip,
1528
+ useAccount,
447
1529
  useAccounts,
1530
+ useBalance,
448
1531
  useCapabilities,
449
1532
  useChain,
1533
+ useCompareCosts,
1534
+ useConnect,
1535
+ useDelegation,
1536
+ useDisconnect,
1537
+ useExecuteRoute,
1538
+ useLastTx,
1539
+ useLookupAddress,
1540
+ useNotification,
450
1541
  usePassphraseGate,
1542
+ useResolveName,
1543
+ useRouteQuote,
1544
+ useSession,
1545
+ useSolanaAccount,
451
1546
  useSolanaBalance,
452
- useSolanaRoles
1547
+ useSolanaRoles,
1548
+ useSwitchChain,
1549
+ useTokenBalance,
1550
+ useTokenList,
1551
+ useTokenSearch,
1552
+ useTxHistory,
1553
+ useTxMonitor,
1554
+ useValidateDestination
453
1555
  });
454
1556
  //# sourceMappingURL=index.cjs.map