@naculus/connect-appkit-vue 0.5.0 → 0.7.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 +297 -125
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -3
- package/dist/index.d.ts +21 -3
- package/dist/index.js +230 -54
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -78,6 +78,7 @@ __export(index_exports, {
|
|
|
78
78
|
useExecuteRoute: () => useExecuteRoute,
|
|
79
79
|
useLastTx: () => useLastTx,
|
|
80
80
|
useLookupAddress: () => useLookupAddress,
|
|
81
|
+
useMppSession: () => useMppSession,
|
|
81
82
|
useNotification: () => useNotification,
|
|
82
83
|
usePassphraseGate: () => usePassphraseGate,
|
|
83
84
|
usePaymentFetch: () => usePaymentFetch,
|
|
@@ -341,9 +342,19 @@ function useNotification(options = {}) {
|
|
|
341
342
|
() => notifications.value.filter((item) => !item.read).length
|
|
342
343
|
);
|
|
343
344
|
let disposed = false;
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
let pending = [];
|
|
346
|
+
const settle = (saved) => {
|
|
347
|
+
const queued = pending ?? [];
|
|
348
|
+
pending = null;
|
|
349
|
+
if (disposed) return;
|
|
350
|
+
if (queued.length === 0) {
|
|
351
|
+
if (saved) settings.value = saved;
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
settings.value = (0, import_connect_appkit_core.replayNotificationSettings)(saved, queued);
|
|
355
|
+
(0, import_connect_appkit_core.saveNotificationSettings)(storage, settings.value);
|
|
356
|
+
};
|
|
357
|
+
void (0, import_connect_appkit_core.loadNotificationSettings)(storage).then(settle, () => settle(null));
|
|
347
358
|
channel.onNotification = (item) => {
|
|
348
359
|
if (!disposed) notifications.value = [...notifications.value, item];
|
|
349
360
|
};
|
|
@@ -354,10 +365,15 @@ function useNotification(options = {}) {
|
|
|
354
365
|
disposed = true;
|
|
355
366
|
channel.onNotification = void 0;
|
|
356
367
|
});
|
|
357
|
-
const
|
|
358
|
-
|
|
368
|
+
const applySettings = (compute) => {
|
|
369
|
+
pending?.push(compute);
|
|
370
|
+
settings.value = (0, import_connect_appkit_core.updateNotificationSettings)(
|
|
371
|
+
settings.value,
|
|
372
|
+
compute(settings.value)
|
|
373
|
+
);
|
|
359
374
|
(0, import_connect_appkit_core.saveNotificationSettings)(storage, settings.value);
|
|
360
375
|
};
|
|
376
|
+
const updateSettings = (update) => applySettings(() => update);
|
|
361
377
|
return {
|
|
362
378
|
notifications,
|
|
363
379
|
unreadCount,
|
|
@@ -387,8 +403,8 @@ function useNotification(options = {}) {
|
|
|
387
403
|
},
|
|
388
404
|
updateSettings,
|
|
389
405
|
setChannels: (channels) => updateSettings((0, import_connect_appkit_core.channelsUpdate)(channels)),
|
|
390
|
-
muteChain: (chainId) =>
|
|
391
|
-
unmuteChain: (chainId) =>
|
|
406
|
+
muteChain: (chainId) => applySettings((current) => (0, import_connect_appkit_core.mutedChainSettings)(current, chainId, true)),
|
|
407
|
+
unmuteChain: (chainId) => applySettings((current) => (0, import_connect_appkit_core.mutedChainSettings)(current, chainId, false))
|
|
392
408
|
};
|
|
393
409
|
}
|
|
394
410
|
|
|
@@ -2617,16 +2633,143 @@ function usePaymentFetch(pay) {
|
|
|
2617
2633
|
};
|
|
2618
2634
|
}
|
|
2619
2635
|
|
|
2620
|
-
// src/
|
|
2636
|
+
// src/useMppSession.ts
|
|
2621
2637
|
var import_connect_appkit_core25 = require("@naculus/connect-appkit-core");
|
|
2622
2638
|
var import_vue39 = require("vue");
|
|
2639
|
+
function useMppSession(session) {
|
|
2640
|
+
const current = () => (0, import_vue39.unref)(session);
|
|
2641
|
+
const pending = (0, import_vue39.shallowRef)(current().meter.pending);
|
|
2642
|
+
const channel = (0, import_vue39.shallowRef)(
|
|
2643
|
+
(0, import_connect_appkit_core25.readCurrentMppSessionChannel)(current())
|
|
2644
|
+
);
|
|
2645
|
+
const lastReceipt = (0, import_vue39.shallowRef)(null);
|
|
2646
|
+
const recoveryChannelId = (0, import_vue39.shallowRef)(null);
|
|
2647
|
+
const isPending = (0, import_vue39.shallowRef)(false);
|
|
2648
|
+
const error = (0, import_vue39.shallowRef)(null);
|
|
2649
|
+
let active = 0;
|
|
2650
|
+
let generation = 0;
|
|
2651
|
+
let epoch = 0;
|
|
2652
|
+
let disposed = false;
|
|
2653
|
+
(0, import_vue39.watch)(
|
|
2654
|
+
() => (0, import_vue39.unref)(session),
|
|
2655
|
+
(value) => {
|
|
2656
|
+
generation++;
|
|
2657
|
+
epoch++;
|
|
2658
|
+
active = 0;
|
|
2659
|
+
isPending.value = false;
|
|
2660
|
+
pending.value = value.meter.pending;
|
|
2661
|
+
channel.value = (0, import_connect_appkit_core25.readCurrentMppSessionChannel)(value);
|
|
2662
|
+
lastReceipt.value = null;
|
|
2663
|
+
recoveryChannelId.value = null;
|
|
2664
|
+
error.value = null;
|
|
2665
|
+
},
|
|
2666
|
+
{ flush: "sync" }
|
|
2667
|
+
);
|
|
2668
|
+
(0, import_vue39.onScopeDispose)(() => {
|
|
2669
|
+
disposed = true;
|
|
2670
|
+
generation++;
|
|
2671
|
+
epoch++;
|
|
2672
|
+
});
|
|
2673
|
+
const run = (operation, publish, clearsRecovery = false) => {
|
|
2674
|
+
const own = ++generation;
|
|
2675
|
+
const ownEpoch = epoch;
|
|
2676
|
+
const invokedSession = current();
|
|
2677
|
+
active++;
|
|
2678
|
+
isPending.value = true;
|
|
2679
|
+
error.value = null;
|
|
2680
|
+
return operation(invokedSession).then((result) => {
|
|
2681
|
+
if (!disposed && ownEpoch === epoch) {
|
|
2682
|
+
publish?.(result);
|
|
2683
|
+
const currentChannel = (0, import_connect_appkit_core25.readCurrentMppSessionChannel)(invokedSession);
|
|
2684
|
+
channel.value = currentChannel;
|
|
2685
|
+
pending.value = invokedSession.meter.pending;
|
|
2686
|
+
if (clearsRecovery || !currentChannel) {
|
|
2687
|
+
recoveryChannelId.value = null;
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
return result;
|
|
2691
|
+
}).catch((cause) => {
|
|
2692
|
+
const normalized = cause instanceof Error ? cause : new Error("MPP session operation failed");
|
|
2693
|
+
if (!disposed && ownEpoch === epoch) {
|
|
2694
|
+
const currentChannel = (0, import_connect_appkit_core25.readCurrentMppSessionChannel)(invokedSession);
|
|
2695
|
+
channel.value = currentChannel;
|
|
2696
|
+
pending.value = invokedSession.meter.pending;
|
|
2697
|
+
const recovery = (0, import_connect_appkit_core25.readMppRecoveryChannelId)(cause);
|
|
2698
|
+
if (recovery) recoveryChannelId.value = recovery;
|
|
2699
|
+
else if (!currentChannel) recoveryChannelId.value = null;
|
|
2700
|
+
if (own === generation) error.value = normalized;
|
|
2701
|
+
}
|
|
2702
|
+
throw normalized;
|
|
2703
|
+
}).finally(() => {
|
|
2704
|
+
if (ownEpoch === epoch) {
|
|
2705
|
+
active--;
|
|
2706
|
+
if (!disposed) isPending.value = active > 0;
|
|
2707
|
+
}
|
|
2708
|
+
});
|
|
2709
|
+
};
|
|
2710
|
+
const fetch = (input, init) => run(
|
|
2711
|
+
(value) => value(input, init),
|
|
2712
|
+
(result) => {
|
|
2713
|
+
const receipt = (0, import_connect_appkit_core25.readMppSessionReceipt)(result.receipt);
|
|
2714
|
+
if (receipt) lastReceipt.value = receipt;
|
|
2715
|
+
}
|
|
2716
|
+
);
|
|
2717
|
+
const close = () => run(
|
|
2718
|
+
(value) => value.close(),
|
|
2719
|
+
(result) => {
|
|
2720
|
+
const receipt = (0, import_connect_appkit_core25.readMppSessionReceipt)(result.receipt);
|
|
2721
|
+
if (receipt) lastReceipt.value = receipt;
|
|
2722
|
+
},
|
|
2723
|
+
true
|
|
2724
|
+
);
|
|
2725
|
+
const forceClose = () => run((value) => value.forceClose(), void 0, true);
|
|
2726
|
+
const add = (units) => {
|
|
2727
|
+
try {
|
|
2728
|
+
current().meter.add(units);
|
|
2729
|
+
pending.value = current().meter.pending;
|
|
2730
|
+
error.value = null;
|
|
2731
|
+
} catch (cause) {
|
|
2732
|
+
const normalized = cause instanceof Error ? cause : new Error("MPP session operation failed");
|
|
2733
|
+
error.value = normalized;
|
|
2734
|
+
recoveryChannelId.value = (0, import_connect_appkit_core25.readMppRecoveryChannelId)(cause);
|
|
2735
|
+
throw normalized;
|
|
2736
|
+
}
|
|
2737
|
+
};
|
|
2738
|
+
return {
|
|
2739
|
+
fetch,
|
|
2740
|
+
meter: { add },
|
|
2741
|
+
pending,
|
|
2742
|
+
channel,
|
|
2743
|
+
lastReceipt,
|
|
2744
|
+
recoveryChannelId,
|
|
2745
|
+
isPending,
|
|
2746
|
+
error,
|
|
2747
|
+
close,
|
|
2748
|
+
forceClose,
|
|
2749
|
+
reset: () => {
|
|
2750
|
+
generation++;
|
|
2751
|
+
epoch++;
|
|
2752
|
+
active = 0;
|
|
2753
|
+
isPending.value = false;
|
|
2754
|
+
pending.value = current().meter.pending;
|
|
2755
|
+
channel.value = (0, import_connect_appkit_core25.readCurrentMppSessionChannel)(current());
|
|
2756
|
+
lastReceipt.value = null;
|
|
2757
|
+
recoveryChannelId.value = null;
|
|
2758
|
+
error.value = null;
|
|
2759
|
+
}
|
|
2760
|
+
};
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
// src/useSolanaSessionKey.ts
|
|
2764
|
+
var import_connect_appkit_core26 = require("@naculus/connect-appkit-core");
|
|
2765
|
+
var import_vue40 = require("vue");
|
|
2623
2766
|
function useSolanaSessionKey(deps) {
|
|
2624
2767
|
const guard = useActionGuard();
|
|
2625
|
-
const keys = (0,
|
|
2768
|
+
const keys = (0, import_vue40.shallowRef)([]);
|
|
2626
2769
|
let flow = null;
|
|
2627
2770
|
let generation = 0;
|
|
2628
2771
|
let disposed = false;
|
|
2629
|
-
(0,
|
|
2772
|
+
(0, import_vue40.onScopeDispose)(() => {
|
|
2630
2773
|
disposed = true;
|
|
2631
2774
|
});
|
|
2632
2775
|
const refresh = async () => {
|
|
@@ -2634,10 +2777,10 @@ function useSolanaSessionKey(deps) {
|
|
|
2634
2777
|
const next = flow ? await flow.list() : [];
|
|
2635
2778
|
if (!disposed && own === generation) keys.value = next;
|
|
2636
2779
|
};
|
|
2637
|
-
(0,
|
|
2638
|
-
() => (0,
|
|
2780
|
+
(0, import_vue40.watch)(
|
|
2781
|
+
() => (0, import_vue40.unref)(deps),
|
|
2639
2782
|
(next) => {
|
|
2640
|
-
flow = next ? (0,
|
|
2783
|
+
flow = next ? (0, import_connect_appkit_core26.createSolanaSessionKeyFlow)(next) : null;
|
|
2641
2784
|
guard.invalidate();
|
|
2642
2785
|
void refresh().catch(() => {
|
|
2643
2786
|
});
|
|
@@ -2668,17 +2811,17 @@ function useSolanaSessionKey(deps) {
|
|
|
2668
2811
|
}
|
|
2669
2812
|
|
|
2670
2813
|
// src/name-lookup.ts
|
|
2671
|
-
var
|
|
2672
|
-
var
|
|
2814
|
+
var import_connect_appkit_core27 = require("@naculus/connect-appkit-core");
|
|
2815
|
+
var import_vue41 = require("vue");
|
|
2673
2816
|
function useNameLookup(options) {
|
|
2674
2817
|
const guard = useActionGuard();
|
|
2675
|
-
const data = (0,
|
|
2676
|
-
const loading = (0,
|
|
2818
|
+
const data = (0, import_vue41.shallowRef)(null);
|
|
2819
|
+
const loading = (0, import_vue41.shallowRef)(false);
|
|
2677
2820
|
const run = () => {
|
|
2678
|
-
const input = (0,
|
|
2679
|
-
const skip = (0,
|
|
2680
|
-
const scope = (0,
|
|
2681
|
-
const config = (0,
|
|
2821
|
+
const input = (0, import_vue41.toValue)(options.input).trim();
|
|
2822
|
+
const skip = (0, import_vue41.toValue)(options.skip) ?? false;
|
|
2823
|
+
const scope = (0, import_vue41.toValue)(options.scope);
|
|
2824
|
+
const config = (0, import_vue41.toValue)(options.resolverConfig);
|
|
2682
2825
|
if (!input || skip) {
|
|
2683
2826
|
guard.reset();
|
|
2684
2827
|
data.value = null;
|
|
@@ -2691,7 +2834,7 @@ function useNameLookup(options) {
|
|
|
2691
2834
|
async (commit) => {
|
|
2692
2835
|
try {
|
|
2693
2836
|
const result = await Promise.resolve().then(
|
|
2694
|
-
() => options.query((0,
|
|
2837
|
+
() => options.query((0, import_connect_appkit_core27.getResolver)(config), input, scope)
|
|
2695
2838
|
);
|
|
2696
2839
|
commit(() => {
|
|
2697
2840
|
data.value = result;
|
|
@@ -2713,19 +2856,19 @@ function useNameLookup(options) {
|
|
|
2713
2856
|
).catch(() => {
|
|
2714
2857
|
});
|
|
2715
2858
|
};
|
|
2716
|
-
(0,
|
|
2859
|
+
(0, import_vue41.watch)(
|
|
2717
2860
|
() => [
|
|
2718
|
-
(0,
|
|
2719
|
-
(0,
|
|
2720
|
-
(0,
|
|
2721
|
-
(0,
|
|
2861
|
+
(0, import_vue41.toValue)(options.input),
|
|
2862
|
+
(0, import_vue41.toValue)(options.skip),
|
|
2863
|
+
(0, import_vue41.toValue)(options.scope),
|
|
2864
|
+
(0, import_vue41.toValue)(options.resolverConfig)
|
|
2722
2865
|
],
|
|
2723
2866
|
run,
|
|
2724
2867
|
{ immediate: true, flush: "sync", deep: true }
|
|
2725
2868
|
);
|
|
2726
2869
|
return {
|
|
2727
2870
|
data,
|
|
2728
|
-
isLoading: (0,
|
|
2871
|
+
isLoading: (0, import_vue41.computed)(() => loading.value),
|
|
2729
2872
|
error: guard.error,
|
|
2730
2873
|
refetch: run
|
|
2731
2874
|
};
|
|
@@ -2753,21 +2896,21 @@ function useLookupAddress(address, options) {
|
|
|
2753
2896
|
}
|
|
2754
2897
|
|
|
2755
2898
|
// src/useSolanaAccount.ts
|
|
2756
|
-
var
|
|
2899
|
+
var import_vue42 = require("vue");
|
|
2757
2900
|
function useSolanaAccount(accounts, connected) {
|
|
2758
|
-
const isConnected = (0,
|
|
2759
|
-
const caip10 = (0,
|
|
2760
|
-
() => isConnected.value ? ((0,
|
|
2901
|
+
const isConnected = (0, import_vue42.computed)(() => (0, import_vue42.toValue)(connected));
|
|
2902
|
+
const caip10 = (0, import_vue42.computed)(
|
|
2903
|
+
() => isConnected.value ? ((0, import_vue42.toValue)(accounts) ?? []).find(
|
|
2761
2904
|
(account) => account.startsWith("solana:")
|
|
2762
2905
|
) ?? null : null
|
|
2763
2906
|
);
|
|
2764
|
-
const parts = (0,
|
|
2907
|
+
const parts = (0, import_vue42.computed)(() => caip10.value?.split(":") ?? []);
|
|
2765
2908
|
return {
|
|
2766
|
-
address: (0,
|
|
2909
|
+
address: (0, import_vue42.computed)(
|
|
2767
2910
|
() => parts.value.length >= 3 ? parts.value.at(-1) ?? null : null
|
|
2768
2911
|
),
|
|
2769
2912
|
caip10,
|
|
2770
|
-
chainId: (0,
|
|
2913
|
+
chainId: (0, import_vue42.computed)(
|
|
2771
2914
|
() => parts.value.length >= 3 ? parts.value.slice(0, -1).join(":") : null
|
|
2772
2915
|
),
|
|
2773
2916
|
isConnected
|
|
@@ -2775,35 +2918,35 @@ function useSolanaAccount(accounts, connected) {
|
|
|
2775
2918
|
}
|
|
2776
2919
|
|
|
2777
2920
|
// src/useChain.ts
|
|
2778
|
-
var
|
|
2779
|
-
var
|
|
2921
|
+
var import_connect_appkit_core28 = require("@naculus/connect-appkit-core");
|
|
2922
|
+
var import_vue43 = require("vue");
|
|
2780
2923
|
function useChain(chains, chainId) {
|
|
2781
|
-
const list = (0,
|
|
2782
|
-
const id = (0,
|
|
2783
|
-
const currentChain = (0,
|
|
2924
|
+
const list = (0, import_vue43.computed)(() => (0, import_vue43.toValue)(chains) ?? []);
|
|
2925
|
+
const id = (0, import_vue43.computed)(() => (0, import_vue43.toValue)(chainId) ?? null);
|
|
2926
|
+
const currentChain = (0, import_vue43.computed)(() => (0, import_connect_appkit_core28.resolveChain)(list.value, id.value));
|
|
2784
2927
|
return {
|
|
2785
2928
|
currentChain,
|
|
2786
|
-
chainInfo: (0,
|
|
2787
|
-
availableChains: (0,
|
|
2788
|
-
currentChainNumber: (0,
|
|
2789
|
-
() => currentChain.value ? (0,
|
|
2929
|
+
chainInfo: (0, import_vue43.computed)(() => (0, import_connect_appkit_core28.describeChain)(list.value, id.value)),
|
|
2930
|
+
availableChains: (0, import_vue43.computed)(() => (0, import_connect_appkit_core28.chainsForNamespace)(list.value, id.value)),
|
|
2931
|
+
currentChainNumber: (0, import_vue43.computed)(
|
|
2932
|
+
() => currentChain.value ? (0, import_connect_appkit_core28.chainNumber)(currentChain.value) : null
|
|
2790
2933
|
),
|
|
2791
|
-
namespace: (0,
|
|
2792
|
-
() => currentChain.value ? (0,
|
|
2934
|
+
namespace: (0, import_vue43.computed)(
|
|
2935
|
+
() => currentChain.value ? (0, import_connect_appkit_core28.chainNamespace)(currentChain.value) : null
|
|
2793
2936
|
)
|
|
2794
2937
|
};
|
|
2795
2938
|
}
|
|
2796
2939
|
|
|
2797
2940
|
// src/usePassphraseGate.ts
|
|
2798
|
-
var
|
|
2941
|
+
var import_vue44 = require("vue");
|
|
2799
2942
|
function usePassphraseGate(gate) {
|
|
2800
|
-
const request = (0,
|
|
2943
|
+
const request = (0, import_vue44.shallowRef)(gate.getSnapshot());
|
|
2801
2944
|
const unsubscribe = gate.subscribe(() => {
|
|
2802
2945
|
request.value = gate.getSnapshot();
|
|
2803
2946
|
});
|
|
2804
|
-
(0,
|
|
2947
|
+
(0, import_vue44.onScopeDispose)(unsubscribe);
|
|
2805
2948
|
return {
|
|
2806
|
-
request: (0,
|
|
2949
|
+
request: (0, import_vue44.readonly)(request),
|
|
2807
2950
|
submit: (passphrase) => gate.submit(passphrase),
|
|
2808
2951
|
cancel: (reason) => gate.cancel(reason),
|
|
2809
2952
|
forget: (reason) => gate.forget(reason)
|
|
@@ -2812,14 +2955,14 @@ function usePassphraseGate(gate) {
|
|
|
2812
2955
|
|
|
2813
2956
|
// src/useSolanaBalance.ts
|
|
2814
2957
|
var import_connect_core17 = require("@naculus/connect-core");
|
|
2815
|
-
var
|
|
2958
|
+
var import_vue45 = require("vue");
|
|
2816
2959
|
function useSolanaBalance(address, rpcUrl) {
|
|
2817
2960
|
const guard = useActionGuard();
|
|
2818
|
-
const balance = (0,
|
|
2819
|
-
const isFetching = (0,
|
|
2961
|
+
const balance = (0, import_vue45.shallowRef)(null);
|
|
2962
|
+
const isFetching = (0, import_vue45.ref)(false);
|
|
2820
2963
|
const refetch = async () => {
|
|
2821
|
-
const addr = (0,
|
|
2822
|
-
const url = (0,
|
|
2964
|
+
const addr = (0, import_vue45.toValue)(address);
|
|
2965
|
+
const url = (0, import_vue45.toValue)(rpcUrl);
|
|
2823
2966
|
if (!addr || !url) {
|
|
2824
2967
|
guard.invalidate();
|
|
2825
2968
|
isFetching.value = false;
|
|
@@ -2851,22 +2994,22 @@ function useSolanaBalance(address, rpcUrl) {
|
|
|
2851
2994
|
).catch(() => {
|
|
2852
2995
|
});
|
|
2853
2996
|
};
|
|
2854
|
-
(0,
|
|
2855
|
-
(0,
|
|
2856
|
-
(0,
|
|
2997
|
+
(0, import_vue45.watchEffect)(() => {
|
|
2998
|
+
(0, import_vue45.toValue)(address);
|
|
2999
|
+
(0, import_vue45.toValue)(rpcUrl);
|
|
2857
3000
|
void refetch();
|
|
2858
3001
|
});
|
|
2859
3002
|
return { balance, isFetching, error: guard.error, refetch };
|
|
2860
3003
|
}
|
|
2861
3004
|
|
|
2862
3005
|
// src/useLastTx.ts
|
|
2863
|
-
var
|
|
3006
|
+
var import_vue46 = require("vue");
|
|
2864
3007
|
function useLastTx(monitor) {
|
|
2865
|
-
const lastTx = (0,
|
|
2866
|
-
const lastConfirmedTx = (0,
|
|
2867
|
-
const lastFailedTx = (0,
|
|
2868
|
-
(0,
|
|
2869
|
-
() => (0,
|
|
3008
|
+
const lastTx = (0, import_vue46.shallowRef)(null);
|
|
3009
|
+
const lastConfirmedTx = (0, import_vue46.shallowRef)(null);
|
|
3010
|
+
const lastFailedTx = (0, import_vue46.shallowRef)(null);
|
|
3011
|
+
(0, import_vue46.watch)(
|
|
3012
|
+
() => (0, import_vue46.toValue)(monitor),
|
|
2870
3013
|
(activeMonitor, _previous, onCleanup) => {
|
|
2871
3014
|
if (!activeMonitor) return;
|
|
2872
3015
|
const recordLatest = (entry) => {
|
|
@@ -2904,13 +3047,13 @@ function useLastTx(monitor) {
|
|
|
2904
3047
|
}
|
|
2905
3048
|
|
|
2906
3049
|
// src/useTxHistory.ts
|
|
2907
|
-
var
|
|
3050
|
+
var import_vue47 = require("vue");
|
|
2908
3051
|
function useTxHistory(address, chainId, monitor) {
|
|
2909
3052
|
const guard = useActionGuard();
|
|
2910
|
-
const entries = (0,
|
|
2911
|
-
const isLoading = (0,
|
|
3053
|
+
const entries = (0, import_vue47.shallowRef)([]);
|
|
3054
|
+
const isLoading = (0, import_vue47.shallowRef)(false);
|
|
2912
3055
|
const refresh = async () => {
|
|
2913
|
-
const activeMonitor = (0,
|
|
3056
|
+
const activeMonitor = (0, import_vue47.toValue)(monitor);
|
|
2914
3057
|
if (!activeMonitor) {
|
|
2915
3058
|
guard.reset();
|
|
2916
3059
|
entries.value = [];
|
|
@@ -2921,8 +3064,8 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
2921
3064
|
await guard.run(
|
|
2922
3065
|
async (commit) => {
|
|
2923
3066
|
const result = await activeMonitor.getTxHistory(
|
|
2924
|
-
(0,
|
|
2925
|
-
(0,
|
|
3067
|
+
(0, import_vue47.toValue)(address) ?? void 0,
|
|
3068
|
+
(0, import_vue47.toValue)(chainId) ?? void 0
|
|
2926
3069
|
);
|
|
2927
3070
|
commit(() => {
|
|
2928
3071
|
entries.value = result;
|
|
@@ -2938,8 +3081,8 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
2938
3081
|
).catch(() => {
|
|
2939
3082
|
});
|
|
2940
3083
|
};
|
|
2941
|
-
(0,
|
|
2942
|
-
[() => (0,
|
|
3084
|
+
(0, import_vue47.watch)(
|
|
3085
|
+
[() => (0, import_vue47.toValue)(monitor), () => (0, import_vue47.toValue)(address), () => (0, import_vue47.toValue)(chainId)],
|
|
2943
3086
|
([activeMonitor], _previous, onCleanup) => {
|
|
2944
3087
|
if (!activeMonitor) {
|
|
2945
3088
|
void refresh();
|
|
@@ -2959,7 +3102,7 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
2959
3102
|
isLoading,
|
|
2960
3103
|
error: guard.error,
|
|
2961
3104
|
refresh,
|
|
2962
|
-
summary: (0,
|
|
3105
|
+
summary: (0, import_vue47.computed)(() => ({
|
|
2963
3106
|
pending: entries.value.filter((item) => item.status === "pending").length,
|
|
2964
3107
|
confirmed: entries.value.filter((item) => item.status === "confirmed").length,
|
|
2965
3108
|
failed: entries.value.filter((item) => item.status === "failed").length
|
|
@@ -2968,45 +3111,74 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
2968
3111
|
}
|
|
2969
3112
|
|
|
2970
3113
|
// src/useTxMonitor.ts
|
|
2971
|
-
var
|
|
3114
|
+
var import_vue48 = require("vue");
|
|
2972
3115
|
function useTxMonitor(hash, chainId, monitor) {
|
|
2973
|
-
const entry = (0,
|
|
2974
|
-
const isLoading = (0,
|
|
2975
|
-
const isWatching = (0,
|
|
2976
|
-
const
|
|
3116
|
+
const entry = (0, import_vue48.shallowRef)(null);
|
|
3117
|
+
const isLoading = (0, import_vue48.shallowRef)(false);
|
|
3118
|
+
const isWatching = (0, import_vue48.shallowRef)(false);
|
|
3119
|
+
const guard = useActionGuard();
|
|
3120
|
+
const error = guard.error;
|
|
2977
3121
|
let generation = 0;
|
|
3122
|
+
let refreshed = [];
|
|
3123
|
+
const currentInputs = () => [
|
|
3124
|
+
(0, import_vue48.toValue)(monitor),
|
|
3125
|
+
(0, import_vue48.toValue)(hash),
|
|
3126
|
+
(0, import_vue48.toValue)(chainId)
|
|
3127
|
+
];
|
|
3128
|
+
const sameInputs = (a, b) => a.every((value, i) => Object.is(value, b[i]));
|
|
2978
3129
|
const refresh = async () => {
|
|
2979
|
-
const activeMonitor = (0,
|
|
2980
|
-
const activeHash = (0,
|
|
2981
|
-
const activeChainId = (0,
|
|
3130
|
+
const activeMonitor = (0, import_vue48.toValue)(monitor);
|
|
3131
|
+
const activeHash = (0, import_vue48.toValue)(hash);
|
|
3132
|
+
const activeChainId = (0, import_vue48.toValue)(chainId);
|
|
2982
3133
|
if (!activeMonitor || !activeHash) return;
|
|
3134
|
+
const started = [activeMonitor, activeHash, activeChainId];
|
|
3135
|
+
refreshed = started;
|
|
2983
3136
|
isLoading.value = true;
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
3137
|
+
await guard.run(
|
|
3138
|
+
async (commit) => {
|
|
3139
|
+
try {
|
|
3140
|
+
await activeMonitor.refreshTx(
|
|
3141
|
+
activeHash,
|
|
3142
|
+
activeChainId ?? void 0
|
|
3143
|
+
);
|
|
3144
|
+
} catch (err) {
|
|
3145
|
+
if (!sameInputs(started, currentInputs())) return;
|
|
3146
|
+
throw err;
|
|
3147
|
+
}
|
|
3148
|
+
if (!sameInputs(started, currentInputs())) return;
|
|
3149
|
+
const current = activeMonitor.getTxStatus(
|
|
3150
|
+
activeHash,
|
|
3151
|
+
activeChainId ?? void 0
|
|
3152
|
+
);
|
|
3153
|
+
commit(() => {
|
|
3154
|
+
entry.value = current ?? null;
|
|
3155
|
+
});
|
|
3156
|
+
},
|
|
3157
|
+
"Failed to refresh transaction",
|
|
3158
|
+
void 0,
|
|
3159
|
+
{
|
|
3160
|
+
onSettled: () => {
|
|
3161
|
+
isLoading.value = false;
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3164
|
+
).catch(() => {
|
|
3165
|
+
});
|
|
2997
3166
|
};
|
|
2998
3167
|
const stopWatching = () => {
|
|
2999
|
-
const activeMonitor = (0,
|
|
3000
|
-
const activeHash = (0,
|
|
3001
|
-
const activeChainId = (0,
|
|
3168
|
+
const activeMonitor = (0, import_vue48.toValue)(monitor);
|
|
3169
|
+
const activeHash = (0, import_vue48.toValue)(hash);
|
|
3170
|
+
const activeChainId = (0, import_vue48.toValue)(chainId);
|
|
3002
3171
|
if (!activeMonitor || !activeHash) return;
|
|
3003
3172
|
activeMonitor.stopWatching(activeHash, activeChainId ?? void 0);
|
|
3004
3173
|
isWatching.value = false;
|
|
3005
3174
|
};
|
|
3006
|
-
(0,
|
|
3007
|
-
[() => (0,
|
|
3175
|
+
(0, import_vue48.watch)(
|
|
3176
|
+
[() => (0, import_vue48.toValue)(monitor), () => (0, import_vue48.toValue)(hash), () => (0, import_vue48.toValue)(chainId)],
|
|
3008
3177
|
([activeMonitor, activeHash, activeChainId], _previous, onCleanup) => {
|
|
3009
3178
|
const mine = ++generation;
|
|
3179
|
+
if (!sameInputs([activeMonitor, activeHash, activeChainId], refreshed)) {
|
|
3180
|
+
guard.invalidate();
|
|
3181
|
+
}
|
|
3010
3182
|
if (!activeMonitor || !activeHash || !activeChainId) {
|
|
3011
3183
|
entry.value = null;
|
|
3012
3184
|
isLoading.value = false;
|
|
@@ -3028,8 +3200,7 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
3028
3200
|
isWatching.value = true;
|
|
3029
3201
|
isLoading.value = true;
|
|
3030
3202
|
error.value = null;
|
|
3031
|
-
|
|
3032
|
-
if (current) entry.value = current;
|
|
3203
|
+
entry.value = activeMonitor.getTxStatus(activeHash, activeChainId) ?? null;
|
|
3033
3204
|
activeMonitor.watchTx(activeHash, activeChainId, {}).then((initial) => {
|
|
3034
3205
|
if (cancelled || mine !== generation) return;
|
|
3035
3206
|
entry.value = initial;
|
|
@@ -3044,7 +3215,7 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
3044
3215
|
);
|
|
3045
3216
|
return {
|
|
3046
3217
|
entry,
|
|
3047
|
-
status: (0,
|
|
3218
|
+
status: (0, import_vue48.computed)(() => entry.value?.status ?? "idle"),
|
|
3048
3219
|
isLoading,
|
|
3049
3220
|
isWatching,
|
|
3050
3221
|
error,
|
|
@@ -3054,17 +3225,17 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
3054
3225
|
}
|
|
3055
3226
|
|
|
3056
3227
|
// src/useCapabilities.ts
|
|
3057
|
-
var
|
|
3058
|
-
var
|
|
3228
|
+
var import_connect_appkit_core29 = require("@naculus/connect-appkit-core");
|
|
3229
|
+
var import_vue49 = require("vue");
|
|
3059
3230
|
function useCapabilities(client, session, chainId) {
|
|
3060
3231
|
const guard = useActionGuard();
|
|
3061
|
-
const capabilities = (0,
|
|
3232
|
+
const capabilities = (0, import_vue49.shallowRef)(
|
|
3062
3233
|
null
|
|
3063
3234
|
);
|
|
3064
|
-
const isFetching = (0,
|
|
3235
|
+
const isFetching = (0, import_vue49.shallowRef)(false);
|
|
3065
3236
|
const refetch = async () => {
|
|
3066
|
-
const activeClient = (0,
|
|
3067
|
-
const activeSession = (0,
|
|
3237
|
+
const activeClient = (0, import_vue49.toValue)(client);
|
|
3238
|
+
const activeSession = (0, import_vue49.toValue)(session);
|
|
3068
3239
|
if (!activeClient?.getCapabilities || !activeSession) {
|
|
3069
3240
|
guard.reset();
|
|
3070
3241
|
capabilities.value = null;
|
|
@@ -3077,7 +3248,7 @@ function useCapabilities(client, session, chainId) {
|
|
|
3077
3248
|
try {
|
|
3078
3249
|
const raw = await activeClient.getCapabilities(activeSession);
|
|
3079
3250
|
commit(() => {
|
|
3080
|
-
capabilities.value = (0,
|
|
3251
|
+
capabilities.value = (0, import_connect_appkit_core29.normalizeCapabilities)(raw);
|
|
3081
3252
|
});
|
|
3082
3253
|
} catch (err) {
|
|
3083
3254
|
commit(() => {
|
|
@@ -3096,18 +3267,18 @@ function useCapabilities(client, session, chainId) {
|
|
|
3096
3267
|
).catch(() => {
|
|
3097
3268
|
});
|
|
3098
3269
|
};
|
|
3099
|
-
(0,
|
|
3100
|
-
void (0,
|
|
3101
|
-
void (0,
|
|
3270
|
+
(0, import_vue49.watchEffect)(() => {
|
|
3271
|
+
void (0, import_vue49.toValue)(client);
|
|
3272
|
+
void (0, import_vue49.toValue)(session);
|
|
3102
3273
|
void refetch();
|
|
3103
3274
|
});
|
|
3104
3275
|
return {
|
|
3105
3276
|
capabilities,
|
|
3106
|
-
current: (0,
|
|
3107
|
-
() => (0,
|
|
3277
|
+
current: (0, import_vue49.computed)(
|
|
3278
|
+
() => (0, import_connect_appkit_core29.selectChainCapabilities)(capabilities.value, (0, import_vue49.toValue)(chainId))
|
|
3108
3279
|
),
|
|
3109
|
-
atomic: (0,
|
|
3110
|
-
() => (0,
|
|
3280
|
+
atomic: (0, import_vue49.computed)(
|
|
3281
|
+
() => (0, import_connect_appkit_core29.atomicSupportFor)(capabilities.value, (0, import_vue49.toValue)(chainId))
|
|
3111
3282
|
),
|
|
3112
3283
|
isFetching,
|
|
3113
3284
|
error: guard.error,
|
|
@@ -3116,18 +3287,18 @@ function useCapabilities(client, session, chainId) {
|
|
|
3116
3287
|
}
|
|
3117
3288
|
|
|
3118
3289
|
// src/useSolanaRoles.ts
|
|
3119
|
-
var
|
|
3120
|
-
var
|
|
3290
|
+
var import_connect_appkit_core30 = require("@naculus/connect-appkit-core");
|
|
3291
|
+
var import_vue50 = require("vue");
|
|
3121
3292
|
function useSolanaRoles(connector, session) {
|
|
3122
|
-
const state = (0,
|
|
3123
|
-
() => (0,
|
|
3293
|
+
const state = (0, import_vue50.computed)(
|
|
3294
|
+
() => (0, import_connect_appkit_core30.readSolanaRoles)((0, import_vue50.toValue)(connector), (0, import_vue50.toValue)(session))
|
|
3124
3295
|
);
|
|
3125
3296
|
return {
|
|
3126
|
-
roles: (0,
|
|
3127
|
-
absence: (0,
|
|
3128
|
-
identity: (0,
|
|
3129
|
-
signer: (0,
|
|
3130
|
-
payer: (0,
|
|
3297
|
+
roles: (0, import_vue50.computed)(() => state.value.roles),
|
|
3298
|
+
absence: (0, import_vue50.computed)(() => state.value.absence),
|
|
3299
|
+
identity: (0, import_vue50.computed)(() => state.value.roles?.identity ?? null),
|
|
3300
|
+
signer: (0, import_vue50.computed)(() => state.value.roles?.signer ?? null),
|
|
3301
|
+
payer: (0, import_vue50.computed)(() => state.value.roles?.payer ?? null)
|
|
3131
3302
|
};
|
|
3132
3303
|
}
|
|
3133
3304
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -3180,6 +3351,7 @@ function useSolanaRoles(connector, session) {
|
|
|
3180
3351
|
useExecuteRoute,
|
|
3181
3352
|
useLastTx,
|
|
3182
3353
|
useLookupAddress,
|
|
3354
|
+
useMppSession,
|
|
3183
3355
|
useNotification,
|
|
3184
3356
|
usePassphraseGate,
|
|
3185
3357
|
usePaymentFetch,
|