@naculus/connect-appkit-vue 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/index.cjs +588 -499
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -5
- package/dist/index.d.ts +22 -5
- package/dist/index.js +341 -248
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -60,6 +60,7 @@ __export(index_exports, {
|
|
|
60
60
|
AppkitTooltip: () => AppkitTooltip,
|
|
61
61
|
useAccount: () => useAccount,
|
|
62
62
|
useAccounts: () => useAccounts,
|
|
63
|
+
useAuthorizations: () => useAuthorizations,
|
|
63
64
|
useBalance: () => useBalance,
|
|
64
65
|
useCapabilities: () => useCapabilities,
|
|
65
66
|
useChain: () => useChain,
|
|
@@ -327,18 +328,64 @@ function useAccounts(accounts) {
|
|
|
327
328
|
};
|
|
328
329
|
}
|
|
329
330
|
|
|
330
|
-
// src/
|
|
331
|
-
var import_connect_appkit_core = require("@naculus/connect-appkit-core");
|
|
331
|
+
// src/useAuthorizations.ts
|
|
332
332
|
var import_connect_core2 = require("@naculus/connect-core");
|
|
333
333
|
var import_vue2 = require("vue");
|
|
334
|
+
function useAuthorizations({
|
|
335
|
+
managers
|
|
336
|
+
}) {
|
|
337
|
+
const entries = (0, import_vue2.shallowRef)([]);
|
|
338
|
+
const loading = (0, import_vue2.shallowRef)(false);
|
|
339
|
+
const error = (0, import_vue2.shallowRef)(null);
|
|
340
|
+
let generation = 0;
|
|
341
|
+
let disposed = false;
|
|
342
|
+
const refresh = async () => {
|
|
343
|
+
const own = ++generation;
|
|
344
|
+
loading.value = true;
|
|
345
|
+
error.value = null;
|
|
346
|
+
try {
|
|
347
|
+
const next = await (0, import_connect_core2.listAuthorizations)((0, import_vue2.unref)(managers));
|
|
348
|
+
if (!disposed && own === generation) entries.value = next;
|
|
349
|
+
} catch (cause) {
|
|
350
|
+
if (!disposed && own === generation) {
|
|
351
|
+
error.value = cause instanceof Error ? cause : new Error("Failed to list authorizations");
|
|
352
|
+
}
|
|
353
|
+
} finally {
|
|
354
|
+
if (!disposed && own === generation) loading.value = false;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
const stop = (0, import_vue2.watch)(() => (0, import_vue2.unref)(managers), refresh, { immediate: true });
|
|
358
|
+
(0, import_vue2.onScopeDispose)(() => {
|
|
359
|
+
disposed = true;
|
|
360
|
+
generation += 1;
|
|
361
|
+
stop();
|
|
362
|
+
});
|
|
363
|
+
const revoke = async (entry) => {
|
|
364
|
+
try {
|
|
365
|
+
const result = await (0, import_connect_core2.revokeListedAuthorization)((0, import_vue2.unref)(managers), entry);
|
|
366
|
+
await refresh();
|
|
367
|
+
return result;
|
|
368
|
+
} catch (cause) {
|
|
369
|
+
const normalized = cause instanceof Error ? cause : new Error("Failed to revoke authorization");
|
|
370
|
+
if (!disposed) error.value = normalized;
|
|
371
|
+
throw normalized;
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
return { entries, loading, error, refresh, revoke };
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// src/useNotification.ts
|
|
378
|
+
var import_connect_appkit_core = require("@naculus/connect-appkit-core");
|
|
379
|
+
var import_connect_core3 = require("@naculus/connect-core");
|
|
380
|
+
var import_vue3 = require("vue");
|
|
334
381
|
function useNotification(options = {}) {
|
|
335
|
-
const channel = (0,
|
|
336
|
-
const storage = (0,
|
|
337
|
-
const notifications = (0,
|
|
338
|
-
const settings = (0,
|
|
382
|
+
const channel = (0, import_vue3.unref)(options.channel) ?? new import_connect_core3.InAppChannel();
|
|
383
|
+
const storage = (0, import_vue3.unref)(options.storage) ?? (0, import_connect_appkit_core.createNotificationSettingsStorage)();
|
|
384
|
+
const notifications = (0, import_vue3.shallowRef)(channel.getHistory());
|
|
385
|
+
const settings = (0, import_vue3.shallowRef)(
|
|
339
386
|
import_connect_appkit_core.DEFAULT_NOTIFICATION_SETTINGS
|
|
340
387
|
);
|
|
341
|
-
const unreadCount = (0,
|
|
388
|
+
const unreadCount = (0, import_vue3.computed)(
|
|
342
389
|
() => notifications.value.filter((item) => !item.read).length
|
|
343
390
|
);
|
|
344
391
|
let disposed = false;
|
|
@@ -361,7 +408,7 @@ function useNotification(options = {}) {
|
|
|
361
408
|
void channel.restore().then(() => {
|
|
362
409
|
if (!disposed) notifications.value = channel.getHistory();
|
|
363
410
|
});
|
|
364
|
-
(0,
|
|
411
|
+
(0, import_vue3.onScopeDispose)(() => {
|
|
365
412
|
disposed = true;
|
|
366
413
|
channel.onNotification = void 0;
|
|
367
414
|
});
|
|
@@ -410,14 +457,14 @@ function useNotification(options = {}) {
|
|
|
410
457
|
|
|
411
458
|
// src/useSimulateTransfer.ts
|
|
412
459
|
var import_connect_appkit_core2 = require("@naculus/connect-appkit-core");
|
|
413
|
-
var
|
|
414
|
-
var
|
|
460
|
+
var import_connect_core4 = require("@naculus/connect-core");
|
|
461
|
+
var import_vue5 = require("vue");
|
|
415
462
|
|
|
416
463
|
// src/internal/action-guard.ts
|
|
417
|
-
var
|
|
464
|
+
var import_vue4 = require("vue");
|
|
418
465
|
function useActionGuard() {
|
|
419
|
-
const busy = (0,
|
|
420
|
-
const error = (0,
|
|
466
|
+
const busy = (0, import_vue4.shallowRef)(false);
|
|
467
|
+
const error = (0, import_vue4.shallowRef)(null);
|
|
421
468
|
let active = 0;
|
|
422
469
|
let generation = 0;
|
|
423
470
|
let disposed = false;
|
|
@@ -458,28 +505,28 @@ function useActionGuard() {
|
|
|
458
505
|
disposed = true;
|
|
459
506
|
generation++;
|
|
460
507
|
};
|
|
461
|
-
(0,
|
|
508
|
+
(0, import_vue4.onScopeDispose)(dispose);
|
|
462
509
|
return { busy, error, run, clearError, reset, invalidate, dispose };
|
|
463
510
|
}
|
|
464
511
|
|
|
465
512
|
// src/useSimulateTransfer.ts
|
|
466
513
|
function useSimulateTransfer(options = {}) {
|
|
467
514
|
const guard = useActionGuard();
|
|
468
|
-
const result = (0,
|
|
469
|
-
const loading = (0,
|
|
515
|
+
const result = (0, import_vue5.shallowRef)(null);
|
|
516
|
+
const loading = (0, import_vue5.shallowRef)(false);
|
|
470
517
|
let manager;
|
|
471
518
|
const simulate = async (tokenAddress, from, to, amount, callOptions) => {
|
|
472
519
|
loading.value = true;
|
|
473
520
|
return await guard.run(
|
|
474
521
|
async (commit) => {
|
|
475
|
-
const fallbackRpcUrl = (0,
|
|
522
|
+
const fallbackRpcUrl = (0, import_vue5.unref)(options.rpcUrl);
|
|
476
523
|
const endpoint = (0, import_connect_appkit_core2.resolveSimulationEndpoint)(
|
|
477
524
|
callOptions?.chainId,
|
|
478
|
-
(0,
|
|
525
|
+
(0, import_vue5.unref)(options.chainId),
|
|
479
526
|
callOptions?.rpcUrl,
|
|
480
527
|
fallbackRpcUrl
|
|
481
528
|
);
|
|
482
|
-
manager ??= new
|
|
529
|
+
manager ??= new import_connect_core4.SimulationManager({
|
|
483
530
|
enabled: true,
|
|
484
531
|
rpcUrl: fallbackRpcUrl,
|
|
485
532
|
autoSimulate: false
|
|
@@ -517,22 +564,22 @@ function useSimulateTransfer(options = {}) {
|
|
|
517
564
|
|
|
518
565
|
// src/useTransactionSimulation.ts
|
|
519
566
|
var import_connect_appkit_core3 = require("@naculus/connect-appkit-core");
|
|
520
|
-
var
|
|
567
|
+
var import_vue6 = require("vue");
|
|
521
568
|
function useTransactionSimulation(tx, options = {}) {
|
|
522
569
|
const guard = useActionGuard();
|
|
523
|
-
const result = (0,
|
|
524
|
-
const isSimulating = (0,
|
|
570
|
+
const result = (0, import_vue6.shallowRef)(void 0);
|
|
571
|
+
const isSimulating = (0, import_vue6.shallowRef)(false);
|
|
525
572
|
let timer;
|
|
526
573
|
const simulate = async () => {
|
|
527
|
-
const transaction = (0,
|
|
574
|
+
const transaction = (0, import_vue6.toValue)(tx);
|
|
528
575
|
if (transaction) isSimulating.value = true;
|
|
529
576
|
return await guard.run(
|
|
530
577
|
async (commit) => {
|
|
531
578
|
const value = await (0, import_connect_appkit_core3.simulateTransactionPreview)(transaction, {
|
|
532
|
-
chainId: (0,
|
|
533
|
-
currentChain: (0,
|
|
534
|
-
publicClient: (0,
|
|
535
|
-
evmAccount: (0,
|
|
579
|
+
chainId: (0, import_vue6.unref)(options.chainId),
|
|
580
|
+
currentChain: (0, import_vue6.unref)(options.currentChain),
|
|
581
|
+
publicClient: (0, import_vue6.unref)(options.publicClient),
|
|
582
|
+
evmAccount: (0, import_vue6.unref)(options.evmAccount)
|
|
536
583
|
});
|
|
537
584
|
commit(() => {
|
|
538
585
|
result.value = value;
|
|
@@ -549,13 +596,13 @@ function useTransactionSimulation(tx, options = {}) {
|
|
|
549
596
|
}
|
|
550
597
|
);
|
|
551
598
|
};
|
|
552
|
-
(0,
|
|
599
|
+
(0, import_vue6.watch)(
|
|
553
600
|
[
|
|
554
|
-
() => (0,
|
|
555
|
-
() => (0,
|
|
556
|
-
() => (0,
|
|
557
|
-
() => (0,
|
|
558
|
-
() => (0,
|
|
601
|
+
() => (0, import_vue6.toValue)(tx),
|
|
602
|
+
() => (0, import_vue6.unref)(options.chainId),
|
|
603
|
+
() => (0, import_vue6.unref)(options.currentChain),
|
|
604
|
+
() => (0, import_vue6.unref)(options.publicClient),
|
|
605
|
+
() => (0, import_vue6.unref)(options.evmAccount)
|
|
559
606
|
],
|
|
560
607
|
([transaction]) => {
|
|
561
608
|
guard.invalidate();
|
|
@@ -577,7 +624,7 @@ function useTransactionSimulation(tx, options = {}) {
|
|
|
577
624
|
result.value = void 0;
|
|
578
625
|
isSimulating.value = false;
|
|
579
626
|
};
|
|
580
|
-
(0,
|
|
627
|
+
(0, import_vue6.onScopeDispose)(() => {
|
|
581
628
|
if (timer) clearTimeout(timer);
|
|
582
629
|
});
|
|
583
630
|
return { result, isSimulating, error: guard.error, simulate, reset };
|
|
@@ -585,43 +632,43 @@ function useTransactionSimulation(tx, options = {}) {
|
|
|
585
632
|
|
|
586
633
|
// src/useERC20Transfer.ts
|
|
587
634
|
var import_connect_appkit_core5 = require("@naculus/connect-appkit-core");
|
|
588
|
-
var
|
|
589
|
-
var
|
|
635
|
+
var import_connect_core6 = require("@naculus/connect-core");
|
|
636
|
+
var import_vue7 = require("vue");
|
|
590
637
|
|
|
591
638
|
// src/erc20.ts
|
|
592
639
|
var import_connect_appkit_core4 = require("@naculus/connect-appkit-core");
|
|
593
|
-
var
|
|
640
|
+
var import_connect_core5 = require("@naculus/connect-core");
|
|
594
641
|
function assertErc20Context(token, chainId, account, connected) {
|
|
595
642
|
if (!connected || !account) {
|
|
596
|
-
throw new
|
|
643
|
+
throw new import_connect_core5.WalletError("wallet_unavailable", "No connected account");
|
|
597
644
|
}
|
|
598
645
|
const mismatch = (0, import_connect_appkit_core4.tokenChainMismatch)(token, chainId);
|
|
599
646
|
if (mismatch) throw mismatch;
|
|
600
647
|
const bare = (0, import_connect_appkit_core4.bareEvmAddress)(account);
|
|
601
648
|
if (!bare) {
|
|
602
|
-
throw new
|
|
649
|
+
throw new import_connect_core5.WalletError("wallet_unavailable", "No valid EVM account");
|
|
603
650
|
}
|
|
604
651
|
return bare;
|
|
605
652
|
}
|
|
606
653
|
|
|
607
654
|
// src/useERC20Transfer.ts
|
|
608
655
|
function useERC20Transfer(options) {
|
|
609
|
-
const initialToken = (0,
|
|
656
|
+
const initialToken = (0, import_vue7.toValue)(options.token);
|
|
610
657
|
const decimals = (0, import_connect_appkit_core5.createDecimalsCache)(initialToken, initialToken.decimals);
|
|
611
|
-
const isSending = (0,
|
|
612
|
-
const error = (0,
|
|
658
|
+
const isSending = (0, import_vue7.shallowRef)(false);
|
|
659
|
+
const error = (0, import_vue7.shallowRef)(null);
|
|
613
660
|
let generation = 0;
|
|
614
661
|
let disposed = false;
|
|
615
|
-
(0,
|
|
662
|
+
(0, import_vue7.watch)(
|
|
616
663
|
[
|
|
617
|
-
() => (0,
|
|
618
|
-
() => (0,
|
|
619
|
-
() => (0,
|
|
620
|
-
() => (0,
|
|
621
|
-
() => (0,
|
|
622
|
-
() => (0,
|
|
623
|
-
() => (0,
|
|
624
|
-
() => (0,
|
|
664
|
+
() => (0, import_vue7.toValue)(options.token).address,
|
|
665
|
+
() => (0, import_vue7.toValue)(options.token).chainId,
|
|
666
|
+
() => (0, import_vue7.toValue)(options.token).decimals,
|
|
667
|
+
() => (0, import_vue7.toValue)(options.account),
|
|
668
|
+
() => (0, import_vue7.toValue)(options.chainId),
|
|
669
|
+
() => (0, import_vue7.toValue)(options.connected),
|
|
670
|
+
() => (0, import_vue7.toValue)(options.publicClient),
|
|
671
|
+
() => (0, import_vue7.unref)(options.sendTransaction)
|
|
625
672
|
],
|
|
626
673
|
() => {
|
|
627
674
|
generation++;
|
|
@@ -632,20 +679,20 @@ function useERC20Transfer(options) {
|
|
|
632
679
|
);
|
|
633
680
|
const sendTransfer = async (to, amount) => {
|
|
634
681
|
const own = ++generation;
|
|
635
|
-
const token = (0,
|
|
636
|
-
const reader = (0,
|
|
682
|
+
const token = (0, import_vue7.toValue)(options.token);
|
|
683
|
+
const reader = (0, import_vue7.toValue)(options.publicClient);
|
|
637
684
|
const stillCurrent = () => !disposed && own === generation;
|
|
638
685
|
error.value = null;
|
|
639
686
|
isSending.value = true;
|
|
640
687
|
try {
|
|
641
688
|
assertErc20Context(
|
|
642
689
|
token,
|
|
643
|
-
(0,
|
|
644
|
-
(0,
|
|
645
|
-
(0,
|
|
690
|
+
(0, import_vue7.toValue)(options.chainId),
|
|
691
|
+
(0, import_vue7.toValue)(options.account),
|
|
692
|
+
(0, import_vue7.toValue)(options.connected)
|
|
646
693
|
);
|
|
647
694
|
if (!reader) {
|
|
648
|
-
throw new
|
|
695
|
+
throw new import_connect_core6.WalletError(
|
|
649
696
|
"wallet_unavailable",
|
|
650
697
|
"No public client available"
|
|
651
698
|
);
|
|
@@ -655,20 +702,20 @@ function useERC20Transfer(options) {
|
|
|
655
702
|
precision = Number(
|
|
656
703
|
await reader.readContract({
|
|
657
704
|
address: token.address,
|
|
658
|
-
abi:
|
|
705
|
+
abi: import_connect_core6.ERC20_MIN_ABI,
|
|
659
706
|
functionName: "decimals"
|
|
660
707
|
})
|
|
661
708
|
);
|
|
662
709
|
if (!stillCurrent()) {
|
|
663
|
-
throw new
|
|
710
|
+
throw new import_connect_core6.WalletError(
|
|
664
711
|
"session_inactive",
|
|
665
712
|
"Wallet or token context changed. Retry the transfer."
|
|
666
713
|
);
|
|
667
714
|
}
|
|
668
715
|
(0, import_connect_appkit_core5.writeDecimals)(decimals, token, precision);
|
|
669
716
|
}
|
|
670
|
-
const data = (0, import_connect_appkit_core5.encodeErc20Transfer)(to, (0,
|
|
671
|
-
return await (0,
|
|
717
|
+
const data = (0, import_connect_appkit_core5.encodeErc20Transfer)(to, (0, import_connect_core6.parseUnits)(amount, precision));
|
|
718
|
+
return await (0, import_vue7.unref)(options.sendTransaction)({
|
|
672
719
|
to: token.address,
|
|
673
720
|
data,
|
|
674
721
|
value: "0"
|
|
@@ -681,7 +728,7 @@ function useERC20Transfer(options) {
|
|
|
681
728
|
if (stillCurrent()) isSending.value = false;
|
|
682
729
|
}
|
|
683
730
|
};
|
|
684
|
-
(0,
|
|
731
|
+
(0, import_vue7.onScopeDispose)(() => {
|
|
685
732
|
disposed = true;
|
|
686
733
|
generation++;
|
|
687
734
|
});
|
|
@@ -690,30 +737,30 @@ function useERC20Transfer(options) {
|
|
|
690
737
|
|
|
691
738
|
// src/useERC20Approve.ts
|
|
692
739
|
var import_connect_appkit_core6 = require("@naculus/connect-appkit-core");
|
|
693
|
-
var
|
|
694
|
-
var
|
|
740
|
+
var import_connect_core7 = require("@naculus/connect-core");
|
|
741
|
+
var import_vue8 = require("vue");
|
|
695
742
|
var MAX_UINT256 = (1n << 256n) - 1n;
|
|
696
743
|
function useERC20Approve(options) {
|
|
697
|
-
const initialToken = (0,
|
|
744
|
+
const initialToken = (0, import_vue8.toValue)(options.token);
|
|
698
745
|
const decimals = (0, import_connect_appkit_core6.createDecimalsCache)(initialToken, initialToken.decimals);
|
|
699
|
-
const allowanceRaw = (0,
|
|
700
|
-
const isApproving = (0,
|
|
701
|
-
const isFetchingAllowance = (0,
|
|
702
|
-
const error = (0,
|
|
746
|
+
const allowanceRaw = (0, import_vue8.shallowRef)(null);
|
|
747
|
+
const isApproving = (0, import_vue8.shallowRef)(false);
|
|
748
|
+
const isFetchingAllowance = (0, import_vue8.shallowRef)(false);
|
|
749
|
+
const error = (0, import_vue8.shallowRef)(null);
|
|
703
750
|
let generation = 0;
|
|
704
751
|
let allowanceGeneration = 0;
|
|
705
752
|
let disposed = false;
|
|
706
|
-
(0,
|
|
753
|
+
(0, import_vue8.watch)(
|
|
707
754
|
[
|
|
708
|
-
() => (0,
|
|
709
|
-
() => (0,
|
|
710
|
-
() => (0,
|
|
711
|
-
() => (0,
|
|
712
|
-
() => (0,
|
|
713
|
-
() => (0,
|
|
714
|
-
() => (0,
|
|
715
|
-
() => (0,
|
|
716
|
-
() => (0,
|
|
755
|
+
() => (0, import_vue8.toValue)(options.token).address,
|
|
756
|
+
() => (0, import_vue8.toValue)(options.token).chainId,
|
|
757
|
+
() => (0, import_vue8.toValue)(options.token).decimals,
|
|
758
|
+
() => (0, import_vue8.toValue)(options.spender),
|
|
759
|
+
() => (0, import_vue8.toValue)(options.account),
|
|
760
|
+
() => (0, import_vue8.toValue)(options.chainId),
|
|
761
|
+
() => (0, import_vue8.toValue)(options.connected),
|
|
762
|
+
() => (0, import_vue8.toValue)(options.publicClient),
|
|
763
|
+
() => (0, import_vue8.unref)(options.sendTransaction)
|
|
717
764
|
],
|
|
718
765
|
() => {
|
|
719
766
|
generation++;
|
|
@@ -726,17 +773,17 @@ function useERC20Approve(options) {
|
|
|
726
773
|
{ flush: "sync" }
|
|
727
774
|
);
|
|
728
775
|
const context = () => {
|
|
729
|
-
const token = (0,
|
|
776
|
+
const token = (0, import_vue8.toValue)(options.token);
|
|
730
777
|
const account = assertErc20Context(
|
|
731
778
|
token,
|
|
732
|
-
(0,
|
|
733
|
-
(0,
|
|
734
|
-
(0,
|
|
779
|
+
(0, import_vue8.toValue)(options.chainId),
|
|
780
|
+
(0, import_vue8.toValue)(options.account),
|
|
781
|
+
(0, import_vue8.toValue)(options.connected)
|
|
735
782
|
);
|
|
736
|
-
const reader = (0,
|
|
783
|
+
const reader = (0, import_vue8.toValue)(options.publicClient);
|
|
737
784
|
if (!reader)
|
|
738
|
-
throw new
|
|
739
|
-
return { token, account, reader, spender: (0,
|
|
785
|
+
throw new import_connect_core7.WalletError("wallet_unavailable", "No public client");
|
|
786
|
+
return { token, account, reader, spender: (0, import_vue8.toValue)(options.spender) };
|
|
740
787
|
};
|
|
741
788
|
const readPrecision = async () => {
|
|
742
789
|
const { token, reader } = context();
|
|
@@ -745,7 +792,7 @@ function useERC20Approve(options) {
|
|
|
745
792
|
precision = Number(
|
|
746
793
|
await reader.readContract({
|
|
747
794
|
address: token.address,
|
|
748
|
-
abi:
|
|
795
|
+
abi: import_connect_core7.ERC20_MIN_ABI,
|
|
749
796
|
functionName: "decimals"
|
|
750
797
|
})
|
|
751
798
|
);
|
|
@@ -763,7 +810,7 @@ function useERC20Approve(options) {
|
|
|
763
810
|
const raw = BigInt(
|
|
764
811
|
await reader.readContract({
|
|
765
812
|
address: token.address,
|
|
766
|
-
abi:
|
|
813
|
+
abi: import_connect_core7.ERC20_MIN_ABI,
|
|
767
814
|
functionName: "allowance",
|
|
768
815
|
args: [account, spender]
|
|
769
816
|
})
|
|
@@ -787,7 +834,7 @@ function useERC20Approve(options) {
|
|
|
787
834
|
isApproving.value = true;
|
|
788
835
|
try {
|
|
789
836
|
const { token, spender } = context();
|
|
790
|
-
const hash = await (0,
|
|
837
|
+
const hash = await (0, import_vue8.unref)(options.sendTransaction)({
|
|
791
838
|
to: token.address,
|
|
792
839
|
data: (0, import_connect_appkit_core6.encodeErc20Approve)(spender, rawAmount),
|
|
793
840
|
value: "0"
|
|
@@ -808,12 +855,12 @@ function useERC20Approve(options) {
|
|
|
808
855
|
try {
|
|
809
856
|
const precision = await readPrecision();
|
|
810
857
|
if (contextGeneration !== generation || disposed) {
|
|
811
|
-
throw new
|
|
858
|
+
throw new import_connect_core7.WalletError(
|
|
812
859
|
"session_inactive",
|
|
813
860
|
"Wallet or token context changed. Retry the approval."
|
|
814
861
|
);
|
|
815
862
|
}
|
|
816
|
-
rawAmount = (0,
|
|
863
|
+
rawAmount = (0, import_connect_core7.parseUnits)(amount, precision);
|
|
817
864
|
} catch (cause) {
|
|
818
865
|
const normalized = cause instanceof Error ? cause : new Error("Approve failed");
|
|
819
866
|
if (!disposed && contextGeneration === generation)
|
|
@@ -826,15 +873,15 @@ function useERC20Approve(options) {
|
|
|
826
873
|
const hasAllowance = async (required) => {
|
|
827
874
|
const raw = allowanceRaw.value ?? await refetchAllowance();
|
|
828
875
|
if (raw === null) return false;
|
|
829
|
-
return raw >= (0,
|
|
876
|
+
return raw >= (0, import_connect_core7.parseUnits)(required, await readPrecision());
|
|
830
877
|
};
|
|
831
|
-
const allowance = (0,
|
|
878
|
+
const allowance = (0, import_vue8.computed)(() => {
|
|
832
879
|
if (allowanceRaw.value === null) return null;
|
|
833
|
-
const token = (0,
|
|
880
|
+
const token = (0, import_vue8.toValue)(options.token);
|
|
834
881
|
const precision = (0, import_connect_appkit_core6.readDecimals)(decimals, token, token.decimals);
|
|
835
|
-
return precision === void 0 ? null : (0,
|
|
882
|
+
return precision === void 0 ? null : (0, import_connect_core7.formatUnits)(allowanceRaw.value, precision);
|
|
836
883
|
});
|
|
837
|
-
(0,
|
|
884
|
+
(0, import_vue8.onScopeDispose)(() => {
|
|
838
885
|
disposed = true;
|
|
839
886
|
generation++;
|
|
840
887
|
allowanceGeneration++;
|
|
@@ -854,20 +901,20 @@ function useERC20Approve(options) {
|
|
|
854
901
|
|
|
855
902
|
// src/useERC20TransferSimulation.ts
|
|
856
903
|
var import_connect_appkit_core7 = require("@naculus/connect-appkit-core");
|
|
857
|
-
var
|
|
858
|
-
var
|
|
904
|
+
var import_connect_core8 = require("@naculus/connect-core");
|
|
905
|
+
var import_vue9 = require("vue");
|
|
859
906
|
function useERC20TransferSimulation(options) {
|
|
860
|
-
const transaction = (0,
|
|
861
|
-
const token = (0,
|
|
862
|
-
if (!(0,
|
|
907
|
+
const transaction = (0, import_vue9.computed)(() => {
|
|
908
|
+
const token = (0, import_vue9.toValue)(options.token);
|
|
909
|
+
if (!(0, import_vue9.toValue)(options.connected) || !(0, import_vue9.toValue)(options.evmAccount))
|
|
863
910
|
return void 0;
|
|
864
911
|
try {
|
|
865
912
|
if (token.decimals === void 0) return void 0;
|
|
866
913
|
return {
|
|
867
914
|
to: token.address,
|
|
868
915
|
data: (0, import_connect_appkit_core7.encodeErc20Transfer)(
|
|
869
|
-
(0,
|
|
870
|
-
(0,
|
|
916
|
+
(0, import_vue9.toValue)(options.to),
|
|
917
|
+
(0, import_connect_core8.parseUnits)((0, import_vue9.toValue)(options.amount), token.decimals)
|
|
871
918
|
),
|
|
872
919
|
value: "0"
|
|
873
920
|
};
|
|
@@ -875,10 +922,10 @@ function useERC20TransferSimulation(options) {
|
|
|
875
922
|
return void 0;
|
|
876
923
|
}
|
|
877
924
|
});
|
|
878
|
-
const chainId = (0,
|
|
879
|
-
const token = (0,
|
|
925
|
+
const chainId = (0, import_vue9.computed)(() => {
|
|
926
|
+
const token = (0, import_vue9.toValue)(options.token);
|
|
880
927
|
if (token.chainId !== void 0) return token.chainId;
|
|
881
|
-
const currentChain = (0,
|
|
928
|
+
const currentChain = (0, import_vue9.toValue)(options.currentChain);
|
|
882
929
|
return currentChain ? (0, import_connect_appkit_core7.chainNumber)(currentChain) ?? void 0 : void 0;
|
|
883
930
|
});
|
|
884
931
|
const simulation = useTransactionSimulation(transaction, {
|
|
@@ -888,39 +935,39 @@ function useERC20TransferSimulation(options) {
|
|
|
888
935
|
evmAccount: options.evmAccount
|
|
889
936
|
});
|
|
890
937
|
return {
|
|
891
|
-
result: (0,
|
|
938
|
+
result: (0, import_vue9.computed)(
|
|
892
939
|
() => transaction.value ? simulation.result.value : void 0
|
|
893
940
|
),
|
|
894
|
-
isSimulating: (0,
|
|
941
|
+
isSimulating: (0, import_vue9.computed)(
|
|
895
942
|
() => !!transaction.value && simulation.isSimulating.value
|
|
896
943
|
),
|
|
897
|
-
error: (0,
|
|
944
|
+
error: (0, import_vue9.computed)(() => transaction.value ? simulation.error.value : null),
|
|
898
945
|
reSimulate: simulation.simulate,
|
|
899
946
|
reset: simulation.reset
|
|
900
947
|
};
|
|
901
948
|
}
|
|
902
949
|
|
|
903
950
|
// src/useAccount.ts
|
|
904
|
-
var
|
|
951
|
+
var import_vue10 = require("vue");
|
|
905
952
|
function useAccount(accounts, connected) {
|
|
906
953
|
const parsed = useAccounts(accounts);
|
|
907
|
-
const isConnected = (0,
|
|
908
|
-
const accountList = (0,
|
|
954
|
+
const isConnected = (0, import_vue10.computed)(() => (0, import_vue10.toValue)(connected));
|
|
955
|
+
const accountList = (0, import_vue10.computed)(() => (0, import_vue10.toValue)(accounts) ?? []);
|
|
909
956
|
return {
|
|
910
|
-
accounts: (0,
|
|
957
|
+
accounts: (0, import_vue10.computed)(
|
|
911
958
|
() => isConnected.value && accountList.value.length > 0 ? parsed.accounts.value : null
|
|
912
959
|
),
|
|
913
|
-
evmAccount: (0,
|
|
960
|
+
evmAccount: (0, import_vue10.computed)(
|
|
914
961
|
() => isConnected.value ? parsed.evmAccount.value : null
|
|
915
962
|
),
|
|
916
|
-
primaryAccount: (0,
|
|
963
|
+
primaryAccount: (0, import_vue10.computed)(() => accountList.value[0] ?? null),
|
|
917
964
|
isConnected,
|
|
918
|
-
count: (0,
|
|
965
|
+
count: (0, import_vue10.computed)(() => accountList.value.length)
|
|
919
966
|
};
|
|
920
967
|
}
|
|
921
968
|
|
|
922
969
|
// src/useSession.ts
|
|
923
|
-
var
|
|
970
|
+
var import_vue11 = require("vue");
|
|
924
971
|
function readSession(manager) {
|
|
925
972
|
const bundle = manager?.getActiveBundle();
|
|
926
973
|
if (!bundle) {
|
|
@@ -939,9 +986,9 @@ function readSession(manager) {
|
|
|
939
986
|
};
|
|
940
987
|
}
|
|
941
988
|
function useSession(manager) {
|
|
942
|
-
const snapshot = (0,
|
|
943
|
-
(0,
|
|
944
|
-
() => (0,
|
|
989
|
+
const snapshot = (0, import_vue11.shallowRef)(readSession((0, import_vue11.toValue)(manager)));
|
|
990
|
+
(0, import_vue11.watch)(
|
|
991
|
+
() => (0, import_vue11.toValue)(manager),
|
|
945
992
|
(current, _previous, onCleanup) => {
|
|
946
993
|
const update = () => {
|
|
947
994
|
snapshot.value = readSession(current);
|
|
@@ -964,29 +1011,29 @@ function useSession(manager) {
|
|
|
964
1011
|
{ immediate: true }
|
|
965
1012
|
);
|
|
966
1013
|
return {
|
|
967
|
-
session: (0,
|
|
968
|
-
chainSessions: (0,
|
|
969
|
-
activeChainId: (0,
|
|
970
|
-
isConnected: (0,
|
|
971
|
-
connectorId: (0,
|
|
1014
|
+
session: (0, import_vue11.computed)(() => snapshot.value.session),
|
|
1015
|
+
chainSessions: (0, import_vue11.computed)(() => snapshot.value.chainSessions),
|
|
1016
|
+
activeChainId: (0, import_vue11.computed)(() => snapshot.value.activeChainId),
|
|
1017
|
+
isConnected: (0, import_vue11.computed)(() => snapshot.value.session !== null),
|
|
1018
|
+
connectorId: (0, import_vue11.computed)(() => snapshot.value.connectorId)
|
|
972
1019
|
};
|
|
973
1020
|
}
|
|
974
1021
|
|
|
975
1022
|
// src/useConnect.ts
|
|
976
|
-
var
|
|
977
|
-
var
|
|
1023
|
+
var import_connect_core9 = require("@naculus/connect-core");
|
|
1024
|
+
var import_vue12 = require("vue");
|
|
978
1025
|
function useConnect(action, status) {
|
|
979
1026
|
const guard = useActionGuard();
|
|
980
1027
|
let inFlight = null;
|
|
981
1028
|
const connect = () => {
|
|
982
1029
|
if (inFlight) return inFlight;
|
|
983
|
-
const invoke = (0,
|
|
1030
|
+
const invoke = (0, import_vue12.unref)(action);
|
|
984
1031
|
const pending = guard.run(
|
|
985
1032
|
() => Promise.resolve().then(() => invoke()),
|
|
986
1033
|
"Connection failed",
|
|
987
1034
|
(cause) => {
|
|
988
1035
|
const message = cause instanceof Error ? cause.message : "Connection failed";
|
|
989
|
-
return cause instanceof
|
|
1036
|
+
return cause instanceof import_connect_core9.WalletError ? cause : new Error(message);
|
|
990
1037
|
}
|
|
991
1038
|
).catch(() => {
|
|
992
1039
|
}).finally(() => {
|
|
@@ -997,22 +1044,22 @@ function useConnect(action, status) {
|
|
|
997
1044
|
};
|
|
998
1045
|
return {
|
|
999
1046
|
connect,
|
|
1000
|
-
isConnecting: (0,
|
|
1001
|
-
() => guard.busy.value || (0,
|
|
1047
|
+
isConnecting: (0, import_vue12.computed)(
|
|
1048
|
+
() => guard.busy.value || (0, import_vue12.toValue)(status) === "connecting"
|
|
1002
1049
|
),
|
|
1003
1050
|
error: guard.error
|
|
1004
1051
|
};
|
|
1005
1052
|
}
|
|
1006
1053
|
|
|
1007
1054
|
// src/useDisconnect.ts
|
|
1008
|
-
var
|
|
1055
|
+
var import_vue13 = require("vue");
|
|
1009
1056
|
function useDisconnect(action, status) {
|
|
1010
1057
|
const guard = useActionGuard();
|
|
1011
1058
|
let inFlight = null;
|
|
1012
1059
|
const disconnect = () => {
|
|
1013
1060
|
if (inFlight) return inFlight;
|
|
1014
|
-
if ((0,
|
|
1015
|
-
const invoke = (0,
|
|
1061
|
+
if ((0, import_vue13.toValue)(status) === "disconnected") return Promise.resolve();
|
|
1062
|
+
const invoke = (0, import_vue13.unref)(action);
|
|
1016
1063
|
const pending = guard.run(() => Promise.resolve().then(() => invoke()), "Disconnect failed").catch(() => {
|
|
1017
1064
|
}).finally(() => {
|
|
1018
1065
|
if (inFlight === pending) inFlight = null;
|
|
@@ -1033,11 +1080,11 @@ function useDisconnect(action, status) {
|
|
|
1033
1080
|
|
|
1034
1081
|
// src/useSwitchChain.ts
|
|
1035
1082
|
var import_connect_appkit_core8 = require("@naculus/connect-appkit-core");
|
|
1036
|
-
var
|
|
1083
|
+
var import_vue14 = require("vue");
|
|
1037
1084
|
function useSwitchChain(action, chainId) {
|
|
1038
1085
|
const guard = useActionGuard();
|
|
1039
1086
|
const switchChain = (targetChainId) => {
|
|
1040
|
-
const invoke = (0,
|
|
1087
|
+
const invoke = (0, import_vue14.unref)(action);
|
|
1041
1088
|
return guard.run(async () => {
|
|
1042
1089
|
try {
|
|
1043
1090
|
await invoke(targetChainId);
|
|
@@ -1049,18 +1096,18 @@ function useSwitchChain(action, chainId) {
|
|
|
1049
1096
|
return {
|
|
1050
1097
|
switchChain,
|
|
1051
1098
|
isSwitching: guard.busy,
|
|
1052
|
-
currentChainId: (0,
|
|
1099
|
+
currentChainId: (0, import_vue14.computed)(() => (0, import_vue14.toValue)(chainId) ?? null),
|
|
1053
1100
|
error: guard.error,
|
|
1054
1101
|
clearError: guard.clearError
|
|
1055
1102
|
};
|
|
1056
1103
|
}
|
|
1057
1104
|
|
|
1058
1105
|
// src/useSignMessage.ts
|
|
1059
|
-
var
|
|
1106
|
+
var import_vue15 = require("vue");
|
|
1060
1107
|
function useSignMessage(action) {
|
|
1061
1108
|
const guard = useActionGuard();
|
|
1062
1109
|
const signMessage = (message) => {
|
|
1063
|
-
const invoke = (0,
|
|
1110
|
+
const invoke = (0, import_vue15.unref)(action);
|
|
1064
1111
|
return guard.run(() => invoke(message), "Signing failed");
|
|
1065
1112
|
};
|
|
1066
1113
|
return {
|
|
@@ -1072,12 +1119,12 @@ function useSignMessage(action) {
|
|
|
1072
1119
|
}
|
|
1073
1120
|
|
|
1074
1121
|
// src/useSendTransaction.ts
|
|
1075
|
-
var
|
|
1122
|
+
var import_vue16 = require("vue");
|
|
1076
1123
|
function useSendTransaction(action) {
|
|
1077
1124
|
const guard = useActionGuard();
|
|
1078
|
-
const status = (0,
|
|
1125
|
+
const status = (0, import_vue16.shallowRef)("idle");
|
|
1079
1126
|
const sendTransaction = (transaction) => {
|
|
1080
|
-
const invoke = (0,
|
|
1127
|
+
const invoke = (0, import_vue16.unref)(action);
|
|
1081
1128
|
status.value = "awaiting_approval";
|
|
1082
1129
|
return guard.run(async (commit) => {
|
|
1083
1130
|
const hash = await invoke(transaction);
|
|
@@ -1099,20 +1146,20 @@ function useSendTransaction(action) {
|
|
|
1099
1146
|
status,
|
|
1100
1147
|
error: guard.error,
|
|
1101
1148
|
reset,
|
|
1102
|
-
isSending: (0,
|
|
1149
|
+
isSending: (0, import_vue16.computed)(() => status.value === "awaiting_approval")
|
|
1103
1150
|
};
|
|
1104
1151
|
}
|
|
1105
1152
|
|
|
1106
1153
|
// src/useSolanaTransaction.ts
|
|
1107
|
-
var
|
|
1154
|
+
var import_vue17 = require("vue");
|
|
1108
1155
|
function useSolanaTransaction(options) {
|
|
1109
1156
|
const guard = useActionGuard();
|
|
1110
|
-
const isSigning = (0,
|
|
1111
|
-
const isSending = (0,
|
|
1157
|
+
const isSigning = (0, import_vue17.shallowRef)(false);
|
|
1158
|
+
const isSending = (0, import_vue17.shallowRef)(false);
|
|
1112
1159
|
let signing = 0;
|
|
1113
1160
|
let sending = 0;
|
|
1114
1161
|
const signTransaction = (transaction) => {
|
|
1115
|
-
const invoke = (0,
|
|
1162
|
+
const invoke = (0, import_vue17.unref)(options.signTransaction);
|
|
1116
1163
|
signing++;
|
|
1117
1164
|
isSigning.value = true;
|
|
1118
1165
|
return guard.run(() => invoke(transaction), "Signing failed").finally(() => {
|
|
@@ -1121,7 +1168,7 @@ function useSolanaTransaction(options) {
|
|
|
1121
1168
|
});
|
|
1122
1169
|
};
|
|
1123
1170
|
const sendTransaction = (transaction) => {
|
|
1124
|
-
const invoke = (0,
|
|
1171
|
+
const invoke = (0, import_vue17.unref)(options.sendTransaction);
|
|
1125
1172
|
sending++;
|
|
1126
1173
|
isSending.value = true;
|
|
1127
1174
|
return guard.run(() => invoke(transaction), "Send failed").finally(() => {
|
|
@@ -1129,7 +1176,7 @@ function useSolanaTransaction(options) {
|
|
|
1129
1176
|
isSending.value = sending > 0;
|
|
1130
1177
|
});
|
|
1131
1178
|
};
|
|
1132
|
-
const getStatus = (signature) => (0,
|
|
1179
|
+
const getStatus = (signature) => (0, import_vue17.unref)(options.getStatus)(signature);
|
|
1133
1180
|
return {
|
|
1134
1181
|
signTransaction,
|
|
1135
1182
|
sendTransaction,
|
|
@@ -1142,12 +1189,12 @@ function useSolanaTransaction(options) {
|
|
|
1142
1189
|
}
|
|
1143
1190
|
|
|
1144
1191
|
// src/useSignInWithX.ts
|
|
1145
|
-
var
|
|
1192
|
+
var import_vue18 = require("vue");
|
|
1146
1193
|
function useSignInWithX(action) {
|
|
1147
1194
|
const guard = useActionGuard();
|
|
1148
|
-
const result = (0,
|
|
1195
|
+
const result = (0, import_vue18.shallowRef)(null);
|
|
1149
1196
|
const signIn = (options) => {
|
|
1150
|
-
const invoke = (0,
|
|
1197
|
+
const invoke = (0, import_vue18.unref)(action);
|
|
1151
1198
|
return guard.run(async (commit) => {
|
|
1152
1199
|
const next = await invoke(options);
|
|
1153
1200
|
commit(() => {
|
|
@@ -1176,48 +1223,48 @@ function useSignInWithEthereum(action) {
|
|
|
1176
1223
|
}
|
|
1177
1224
|
|
|
1178
1225
|
// src/useExecuteCalls.ts
|
|
1179
|
-
var
|
|
1226
|
+
var import_vue19 = require("vue");
|
|
1180
1227
|
function useExecuteCalls(options) {
|
|
1181
1228
|
const guard = useActionGuard();
|
|
1182
|
-
const preview = (callCount, atomicity) => (0,
|
|
1229
|
+
const preview = (callCount, atomicity) => (0, import_vue19.unref)(options.preview)(callCount, atomicity);
|
|
1183
1230
|
const execute = (calls, atomicity) => {
|
|
1184
|
-
const invoke = (0,
|
|
1231
|
+
const invoke = (0, import_vue19.unref)(options.execute);
|
|
1185
1232
|
return guard.run(() => invoke(calls, atomicity), "Execution failed");
|
|
1186
1233
|
};
|
|
1187
1234
|
const reset = () => {
|
|
1188
1235
|
guard.reset();
|
|
1189
|
-
(0,
|
|
1236
|
+
(0, import_vue19.unref)(options.reset)();
|
|
1190
1237
|
};
|
|
1191
1238
|
return {
|
|
1192
1239
|
preview,
|
|
1193
1240
|
execute,
|
|
1194
1241
|
isExecuting: guard.busy,
|
|
1195
1242
|
error: guard.error,
|
|
1196
|
-
lastRoute: (0,
|
|
1243
|
+
lastRoute: (0, import_vue19.computed)(() => (0, import_vue19.toValue)(options.lastRoute)),
|
|
1197
1244
|
reset
|
|
1198
1245
|
};
|
|
1199
1246
|
}
|
|
1200
1247
|
|
|
1201
1248
|
// src/useDelegationPolicy.ts
|
|
1202
1249
|
var import_connect_appkit_core10 = require("@naculus/connect-appkit-core");
|
|
1203
|
-
var
|
|
1250
|
+
var import_vue21 = require("vue");
|
|
1204
1251
|
|
|
1205
1252
|
// src/useSessionKeys.ts
|
|
1206
1253
|
var import_connect_appkit_core9 = require("@naculus/connect-appkit-core");
|
|
1207
|
-
var
|
|
1254
|
+
var import_vue20 = require("vue");
|
|
1208
1255
|
function resolveManager(config, options) {
|
|
1209
1256
|
return options.manager ?? (0, import_connect_appkit_core9.getSharedSessionKeyManager)(config);
|
|
1210
1257
|
}
|
|
1211
1258
|
function useSessionKeys(connected, config, options = {}) {
|
|
1212
1259
|
const manager = resolveManager(config, options);
|
|
1213
|
-
const sessions = (0,
|
|
1214
|
-
const loading = (0,
|
|
1215
|
-
const error = (0,
|
|
1260
|
+
const sessions = (0, import_vue20.shallowRef)([]);
|
|
1261
|
+
const loading = (0, import_vue20.shallowRef)(false);
|
|
1262
|
+
const error = (0, import_vue20.shallowRef)(null);
|
|
1216
1263
|
let generation = 0;
|
|
1217
1264
|
let disposed = false;
|
|
1218
1265
|
const refresh = async () => {
|
|
1219
1266
|
const own = ++generation;
|
|
1220
|
-
if (!(0,
|
|
1267
|
+
if (!(0, import_vue20.toValue)(connected)) {
|
|
1221
1268
|
sessions.value = [];
|
|
1222
1269
|
return;
|
|
1223
1270
|
}
|
|
@@ -1234,20 +1281,20 @@ function useSessionKeys(connected, config, options = {}) {
|
|
|
1234
1281
|
if (!disposed && own === generation) loading.value = false;
|
|
1235
1282
|
}
|
|
1236
1283
|
};
|
|
1237
|
-
(0,
|
|
1238
|
-
() => (0,
|
|
1284
|
+
(0, import_vue20.watch)(
|
|
1285
|
+
() => (0, import_vue20.toValue)(connected),
|
|
1239
1286
|
() => {
|
|
1240
1287
|
void refresh();
|
|
1241
1288
|
},
|
|
1242
1289
|
{ immediate: true }
|
|
1243
1290
|
);
|
|
1244
|
-
(0,
|
|
1291
|
+
(0, import_vue20.onScopeDispose)(() => {
|
|
1245
1292
|
disposed = true;
|
|
1246
1293
|
generation++;
|
|
1247
1294
|
});
|
|
1248
1295
|
return {
|
|
1249
1296
|
sessions,
|
|
1250
|
-
activeSessions: (0,
|
|
1297
|
+
activeSessions: (0, import_vue20.computed)(
|
|
1251
1298
|
() => sessions.value.filter((s) => s.status === "active")
|
|
1252
1299
|
),
|
|
1253
1300
|
loading,
|
|
@@ -1262,7 +1309,7 @@ function useSessionKeys(connected, config, options = {}) {
|
|
|
1262
1309
|
function useCreateSessionKey(config, options = {}) {
|
|
1263
1310
|
const manager = resolveManager(config, options);
|
|
1264
1311
|
const guard = useActionGuard();
|
|
1265
|
-
const lastCreated = (0,
|
|
1312
|
+
const lastCreated = (0, import_vue20.shallowRef)(null);
|
|
1266
1313
|
return {
|
|
1267
1314
|
createSessionKey: (scope, signerAddress) => guard.run(async () => {
|
|
1268
1315
|
const info = await manager.createSessionKey(scope, signerAddress);
|
|
@@ -1313,31 +1360,31 @@ function useDelegationPolicy(options) {
|
|
|
1313
1360
|
manager
|
|
1314
1361
|
});
|
|
1315
1362
|
const guard = useActionGuard();
|
|
1316
|
-
const verifiedIds = (0,
|
|
1317
|
-
const isVerifying = (0,
|
|
1318
|
-
const verifyError = (0,
|
|
1363
|
+
const verifiedIds = (0, import_vue21.shallowRef)(/* @__PURE__ */ new Set());
|
|
1364
|
+
const isVerifying = (0, import_vue21.shallowRef)(false);
|
|
1365
|
+
const verifyError = (0, import_vue21.shallowRef)(null);
|
|
1319
1366
|
let verifyGeneration = 0;
|
|
1320
1367
|
let disposed = false;
|
|
1321
1368
|
const origin = options.origin ?? (typeof window !== "undefined" ? window.location.origin : "unknown");
|
|
1322
1369
|
const flow = (0, import_connect_appkit_core10.createDelegationPolicyFlow)({
|
|
1323
1370
|
manager,
|
|
1324
1371
|
origin,
|
|
1325
|
-
signer: () => (0, import_connect_appkit_core10.bareEvmAddress)((0,
|
|
1326
|
-
signMessage: (message) => (0,
|
|
1327
|
-
verifySignature: (input) => (0,
|
|
1328
|
-
previewExecution: (callCount, atomicity) => (0,
|
|
1372
|
+
signer: () => (0, import_connect_appkit_core10.bareEvmAddress)((0, import_vue21.toValue)(options.account)),
|
|
1373
|
+
signMessage: (message) => (0, import_vue21.unref)(options.signMessage)(message),
|
|
1374
|
+
verifySignature: (input) => (0, import_vue21.unref)(options.verifySignature)(input),
|
|
1375
|
+
previewExecution: (callCount, atomicity) => (0, import_vue21.unref)(options.previewExecution)(callCount, atomicity),
|
|
1329
1376
|
sponsorship: options.sponsorship,
|
|
1330
1377
|
adapter: options.adapter,
|
|
1331
|
-
signTypedData: options.signTypedData ? (typedData) => (0,
|
|
1378
|
+
signTypedData: options.signTypedData ? (typedData) => (0, import_vue21.unref)(
|
|
1332
1379
|
options.signTypedData
|
|
1333
1380
|
)(typedData) : void 0,
|
|
1334
|
-
chainId: () => (0,
|
|
1335
|
-
delegation: () => (0,
|
|
1381
|
+
chainId: () => (0, import_vue21.toValue)(options.chainId) ?? null,
|
|
1382
|
+
delegation: () => (0, import_vue21.toValue)(options.delegation),
|
|
1336
1383
|
encryptionKeyConfigured: Boolean(options.managerConfig?.encryptionKey),
|
|
1337
1384
|
storageAvailable: () => sessionKeys.storageAvailable,
|
|
1338
1385
|
refresh: sessionKeys.refresh
|
|
1339
1386
|
});
|
|
1340
|
-
(0,
|
|
1387
|
+
(0, import_vue21.watch)(
|
|
1341
1388
|
() => sessionKeys.sessions.value,
|
|
1342
1389
|
(sessions) => {
|
|
1343
1390
|
const own = ++verifyGeneration;
|
|
@@ -1367,21 +1414,21 @@ function useDelegationPolicy(options) {
|
|
|
1367
1414
|
},
|
|
1368
1415
|
{ immediate: true }
|
|
1369
1416
|
);
|
|
1370
|
-
(0,
|
|
1417
|
+
(0, import_vue21.onScopeDispose)(() => {
|
|
1371
1418
|
disposed = true;
|
|
1372
1419
|
verifyGeneration++;
|
|
1373
1420
|
});
|
|
1374
1421
|
return {
|
|
1375
1422
|
policies: sessionKeys.sessions,
|
|
1376
|
-
activePolicies: (0,
|
|
1423
|
+
activePolicies: (0, import_vue21.computed)(
|
|
1377
1424
|
() => sessionKeys.activeSessions.value.filter(
|
|
1378
1425
|
(p) => verifiedIds.value.has(p.id)
|
|
1379
1426
|
)
|
|
1380
1427
|
),
|
|
1381
1428
|
storageAvailable: sessionKeys.storageAvailable,
|
|
1382
|
-
loading: (0,
|
|
1429
|
+
loading: (0, import_vue21.computed)(() => sessionKeys.loading.value || isVerifying.value),
|
|
1383
1430
|
isBusy: guard.busy,
|
|
1384
|
-
error: (0,
|
|
1431
|
+
error: (0, import_vue21.computed)(
|
|
1385
1432
|
() => guard.error.value ?? verifyError.value ?? sessionKeys.error.value
|
|
1386
1433
|
),
|
|
1387
1434
|
createPolicy: (scope) => guard.run(() => flow.createPolicy(scope), "Policy creation failed"),
|
|
@@ -1403,28 +1450,28 @@ function useDelegationPolicy(options) {
|
|
|
1403
1450
|
|
|
1404
1451
|
// src/useSmartAccount.ts
|
|
1405
1452
|
var import_connect_appkit_core11 = require("@naculus/connect-appkit-core");
|
|
1406
|
-
var
|
|
1407
|
-
var
|
|
1453
|
+
var import_connect_core10 = require("@naculus/connect-core");
|
|
1454
|
+
var import_vue22 = require("vue");
|
|
1408
1455
|
function useSmartAccount(options) {
|
|
1409
|
-
const address = (0,
|
|
1410
|
-
const isDeployed = (0,
|
|
1411
|
-
const accountInfo = (0,
|
|
1456
|
+
const address = (0, import_vue22.shallowRef)(null);
|
|
1457
|
+
const isDeployed = (0, import_vue22.shallowRef)(false);
|
|
1458
|
+
const accountInfo = (0, import_vue22.shallowRef)(null);
|
|
1412
1459
|
const guard = useActionGuard();
|
|
1413
|
-
const managerRef = (0,
|
|
1460
|
+
const managerRef = (0, import_vue22.shallowRef)(null);
|
|
1414
1461
|
let generation = 0;
|
|
1415
1462
|
let inFlight = false;
|
|
1416
1463
|
let disposed = false;
|
|
1417
|
-
const chainId = (0,
|
|
1464
|
+
const chainId = (0, import_vue22.computed)(
|
|
1418
1465
|
() => (0, import_connect_appkit_core11.resolveEvmChainId)(
|
|
1419
|
-
(0,
|
|
1420
|
-
(0,
|
|
1466
|
+
(0, import_vue22.toValue)(options.chainId),
|
|
1467
|
+
(0, import_vue22.toValue)(options.connectedChainId)
|
|
1421
1468
|
)
|
|
1422
1469
|
);
|
|
1423
|
-
(0,
|
|
1470
|
+
(0, import_vue22.watch)(
|
|
1424
1471
|
[
|
|
1425
|
-
() => (0,
|
|
1426
|
-
() => (0,
|
|
1427
|
-
() => (0,
|
|
1472
|
+
() => (0, import_vue22.toValue)(options.manager),
|
|
1473
|
+
() => (0, import_vue22.toValue)(options.rpcUrl),
|
|
1474
|
+
() => (0, import_vue22.toValue)(options.bundlerUrl),
|
|
1428
1475
|
() => chainId.value
|
|
1429
1476
|
],
|
|
1430
1477
|
([supplied, rpcUrl, bundlerUrl, chain]) => {
|
|
@@ -1449,8 +1496,8 @@ function useSmartAccount(options) {
|
|
|
1449
1496
|
},
|
|
1450
1497
|
{ immediate: true }
|
|
1451
1498
|
);
|
|
1452
|
-
const config = (0,
|
|
1453
|
-
const owner = (0, import_connect_appkit_core11.bareEvmAddress)((0,
|
|
1499
|
+
const config = (0, import_vue22.computed)(() => {
|
|
1500
|
+
const owner = (0, import_connect_appkit_core11.bareEvmAddress)((0, import_vue22.toValue)(options.account));
|
|
1454
1501
|
const chain = chainId.value;
|
|
1455
1502
|
if (!owner || !chain || !managerRef.value) return null;
|
|
1456
1503
|
return (0, import_connect_appkit_core11.buildSmartAccountConfig)(owner, chain, {
|
|
@@ -1500,9 +1547,9 @@ function useSmartAccount(options) {
|
|
|
1500
1547
|
return info;
|
|
1501
1548
|
}, "Failed to create smart account");
|
|
1502
1549
|
const deployWallet = () => operate(async (manager, cfg, commit) => {
|
|
1503
|
-
const send = (0,
|
|
1550
|
+
const send = (0, import_vue22.unref)(options.sendTransaction);
|
|
1504
1551
|
if (!send) {
|
|
1505
|
-
throw new
|
|
1552
|
+
throw new import_connect_core10.WalletError(
|
|
1506
1553
|
"wallet_unavailable",
|
|
1507
1554
|
"deployWallet needs the connected wallet's sendTransaction"
|
|
1508
1555
|
);
|
|
@@ -1530,7 +1577,7 @@ function useSmartAccount(options) {
|
|
|
1530
1577
|
});
|
|
1531
1578
|
return addr;
|
|
1532
1579
|
}, "Failed to get smart account address");
|
|
1533
|
-
(0,
|
|
1580
|
+
(0, import_vue22.onScopeDispose)(() => {
|
|
1534
1581
|
disposed = true;
|
|
1535
1582
|
generation++;
|
|
1536
1583
|
});
|
|
@@ -1549,14 +1596,14 @@ function useSmartAccount(options) {
|
|
|
1549
1596
|
|
|
1550
1597
|
// src/useSendUserOperation.ts
|
|
1551
1598
|
var import_connect_appkit_core12 = require("@naculus/connect-appkit-core");
|
|
1552
|
-
var
|
|
1553
|
-
var
|
|
1599
|
+
var import_connect_core11 = require("@naculus/connect-core");
|
|
1600
|
+
var import_vue23 = require("vue");
|
|
1554
1601
|
function useSendUserOperation(options) {
|
|
1555
|
-
const userOpHash = (0,
|
|
1556
|
-
const receipt = (0,
|
|
1557
|
-
const isPending = (0,
|
|
1558
|
-
const isEstimating = (0,
|
|
1559
|
-
const error = (0,
|
|
1602
|
+
const userOpHash = (0, import_vue23.shallowRef)(null);
|
|
1603
|
+
const receipt = (0, import_vue23.shallowRef)(null);
|
|
1604
|
+
const isPending = (0, import_vue23.shallowRef)(false);
|
|
1605
|
+
const isEstimating = (0, import_vue23.shallowRef)(false);
|
|
1606
|
+
const error = (0, import_vue23.shallowRef)(null);
|
|
1560
1607
|
let requestId = 0;
|
|
1561
1608
|
let inFlight = false;
|
|
1562
1609
|
let disposed = false;
|
|
@@ -1565,8 +1612,8 @@ function useSendUserOperation(options) {
|
|
|
1565
1612
|
return null;
|
|
1566
1613
|
};
|
|
1567
1614
|
const sendUserOp = async (calls, opts) => {
|
|
1568
|
-
const rpcUrl = (0,
|
|
1569
|
-
const bundlerUrl = (0,
|
|
1615
|
+
const rpcUrl = (0, import_vue23.toValue)(options.rpcUrl);
|
|
1616
|
+
const bundlerUrl = (0, import_vue23.toValue)(options.bundlerUrl);
|
|
1570
1617
|
if (!rpcUrl) return fail(new Error("RPC URL not configured"));
|
|
1571
1618
|
if (!bundlerUrl) return fail(new Error("Bundler URL not configured"));
|
|
1572
1619
|
if (!calls.length) return fail(new Error("At least one call is required"));
|
|
@@ -1574,23 +1621,23 @@ function useSendUserOperation(options) {
|
|
|
1574
1621
|
return fail(new Error("A UserOperation is already in progress"));
|
|
1575
1622
|
}
|
|
1576
1623
|
const owner = (0, import_connect_appkit_core12.bareEvmAddress)(
|
|
1577
|
-
(0,
|
|
1624
|
+
(0, import_vue23.toValue)(options.owner) ?? (0, import_vue23.toValue)(options.account)
|
|
1578
1625
|
);
|
|
1579
1626
|
if (!owner) {
|
|
1580
1627
|
return fail(
|
|
1581
|
-
new
|
|
1628
|
+
new import_connect_core11.WalletError("wallet_unavailable", "No EVM account found")
|
|
1582
1629
|
);
|
|
1583
1630
|
}
|
|
1584
1631
|
let targetChainId;
|
|
1585
1632
|
try {
|
|
1586
1633
|
targetChainId = (0, import_connect_appkit_core12.resolveUserOpChain)(
|
|
1587
|
-
(0,
|
|
1588
|
-
(0,
|
|
1634
|
+
(0, import_vue23.toValue)(options.chainId),
|
|
1635
|
+
(0, import_vue23.toValue)(options.connectedChainId)
|
|
1589
1636
|
);
|
|
1590
1637
|
} catch (chainError) {
|
|
1591
1638
|
return fail(chainError);
|
|
1592
1639
|
}
|
|
1593
|
-
const signer = (0,
|
|
1640
|
+
const signer = (0, import_vue23.unref)(options.signer);
|
|
1594
1641
|
const own = ++requestId;
|
|
1595
1642
|
inFlight = true;
|
|
1596
1643
|
isPending.value = true;
|
|
@@ -1641,7 +1688,7 @@ function useSendUserOperation(options) {
|
|
|
1641
1688
|
isEstimating.value = false;
|
|
1642
1689
|
error.value = null;
|
|
1643
1690
|
};
|
|
1644
|
-
(0,
|
|
1691
|
+
(0, import_vue23.onScopeDispose)(() => {
|
|
1645
1692
|
disposed = true;
|
|
1646
1693
|
requestId++;
|
|
1647
1694
|
});
|
|
@@ -1658,15 +1705,15 @@ function useSendUserOperation(options) {
|
|
|
1658
1705
|
|
|
1659
1706
|
// src/useUserOpStatus.ts
|
|
1660
1707
|
var import_connect_appkit_core13 = require("@naculus/connect-appkit-core");
|
|
1661
|
-
var
|
|
1708
|
+
var import_vue24 = require("vue");
|
|
1662
1709
|
function useUserOpStatus(options) {
|
|
1663
|
-
const status = (0,
|
|
1664
|
-
const receipt = (0,
|
|
1665
|
-
const userOpHash = (0,
|
|
1666
|
-
const error = (0,
|
|
1667
|
-
const isPolling = (0,
|
|
1668
|
-
const elapsedMs = (0,
|
|
1669
|
-
const attempts = (0,
|
|
1710
|
+
const status = (0, import_vue24.shallowRef)("idle");
|
|
1711
|
+
const receipt = (0, import_vue24.shallowRef)(null);
|
|
1712
|
+
const userOpHash = (0, import_vue24.shallowRef)(null);
|
|
1713
|
+
const error = (0, import_vue24.shallowRef)(null);
|
|
1714
|
+
const isPolling = (0, import_vue24.shallowRef)(false);
|
|
1715
|
+
const elapsedMs = (0, import_vue24.shallowRef)(0);
|
|
1716
|
+
const attempts = (0, import_vue24.shallowRef)(0);
|
|
1670
1717
|
const pollInterval = options.pollInterval ?? 2e3;
|
|
1671
1718
|
const maxRetries = options.maxRetries ?? 30;
|
|
1672
1719
|
let generation = 0;
|
|
@@ -1687,7 +1734,7 @@ function useUserOpStatus(options) {
|
|
|
1687
1734
|
clearTimers();
|
|
1688
1735
|
};
|
|
1689
1736
|
const poll = async (hash, own) => {
|
|
1690
|
-
const bundlerUrl = (0,
|
|
1737
|
+
const bundlerUrl = (0, import_vue24.toValue)(options.bundlerUrl);
|
|
1691
1738
|
if (!bundlerUrl || own !== generation) return;
|
|
1692
1739
|
const attempt = ++attempts.value;
|
|
1693
1740
|
const abort = new AbortController();
|
|
@@ -1744,7 +1791,7 @@ function useUserOpStatus(options) {
|
|
|
1744
1791
|
error.value = null;
|
|
1745
1792
|
attempts.value = 0;
|
|
1746
1793
|
elapsedMs.value = 0;
|
|
1747
|
-
if (!(0,
|
|
1794
|
+
if (!(0, import_vue24.toValue)(options.bundlerUrl)) {
|
|
1748
1795
|
finish("not_found", new Error("Bundler URL not configured"));
|
|
1749
1796
|
return;
|
|
1750
1797
|
}
|
|
@@ -1772,7 +1819,7 @@ function useUserOpStatus(options) {
|
|
|
1772
1819
|
attempts.value = 0;
|
|
1773
1820
|
elapsedMs.value = 0;
|
|
1774
1821
|
};
|
|
1775
|
-
(0,
|
|
1822
|
+
(0, import_vue24.onScopeDispose)(stop);
|
|
1776
1823
|
return {
|
|
1777
1824
|
status,
|
|
1778
1825
|
receipt,
|
|
@@ -1788,17 +1835,17 @@ function useUserOpStatus(options) {
|
|
|
1788
1835
|
}
|
|
1789
1836
|
|
|
1790
1837
|
// src/useSendCalls.ts
|
|
1791
|
-
var
|
|
1838
|
+
var import_vue25 = require("vue");
|
|
1792
1839
|
function useSendCalls(options) {
|
|
1793
|
-
const status = (0,
|
|
1794
|
-
const error = (0,
|
|
1795
|
-
const batchHash = (0,
|
|
1796
|
-
const callsStatus = (0,
|
|
1840
|
+
const status = (0, import_vue25.shallowRef)("idle");
|
|
1841
|
+
const error = (0, import_vue25.shallowRef)(null);
|
|
1842
|
+
const batchHash = (0, import_vue25.shallowRef)(null);
|
|
1843
|
+
const callsStatus = (0, import_vue25.shallowRef)(null);
|
|
1797
1844
|
let sendGeneration = 0;
|
|
1798
1845
|
let statusGeneration = 0;
|
|
1799
1846
|
let disposed = false;
|
|
1800
1847
|
const sendCalls = async (calls, input) => {
|
|
1801
|
-
const invoke = (0,
|
|
1848
|
+
const invoke = (0, import_vue25.unref)(options.sendCalls);
|
|
1802
1849
|
const own = ++sendGeneration;
|
|
1803
1850
|
status.value = "awaiting_approval";
|
|
1804
1851
|
error.value = null;
|
|
@@ -1820,13 +1867,13 @@ function useSendCalls(options) {
|
|
|
1820
1867
|
}
|
|
1821
1868
|
};
|
|
1822
1869
|
const getCallsStatus = async (hash) => {
|
|
1823
|
-
const invoke = (0,
|
|
1870
|
+
const invoke = (0, import_vue25.unref)(options.getCallsStatus);
|
|
1824
1871
|
const own = ++statusGeneration;
|
|
1825
1872
|
const result = await invoke(hash);
|
|
1826
1873
|
if (!disposed && own === statusGeneration) callsStatus.value = result;
|
|
1827
1874
|
return result;
|
|
1828
1875
|
};
|
|
1829
|
-
const showCallsStatus = (hash) => (0,
|
|
1876
|
+
const showCallsStatus = (hash) => (0, import_vue25.unref)(options.showCallsStatus)(hash);
|
|
1830
1877
|
const reset = () => {
|
|
1831
1878
|
sendGeneration++;
|
|
1832
1879
|
statusGeneration++;
|
|
@@ -1835,7 +1882,7 @@ function useSendCalls(options) {
|
|
|
1835
1882
|
batchHash.value = null;
|
|
1836
1883
|
callsStatus.value = null;
|
|
1837
1884
|
};
|
|
1838
|
-
(0,
|
|
1885
|
+
(0, import_vue25.onScopeDispose)(() => {
|
|
1839
1886
|
disposed = true;
|
|
1840
1887
|
sendGeneration++;
|
|
1841
1888
|
statusGeneration++;
|
|
@@ -1848,38 +1895,38 @@ function useSendCalls(options) {
|
|
|
1848
1895
|
error,
|
|
1849
1896
|
batchHash,
|
|
1850
1897
|
callsStatus,
|
|
1851
|
-
execution: (0,
|
|
1852
|
-
isSending: (0,
|
|
1898
|
+
execution: (0, import_vue25.computed)(() => (0, import_vue25.toValue)(options.execution) ?? null),
|
|
1899
|
+
isSending: (0, import_vue25.computed)(() => status.value === "awaiting_approval"),
|
|
1853
1900
|
reset
|
|
1854
1901
|
};
|
|
1855
1902
|
}
|
|
1856
1903
|
|
|
1857
1904
|
// src/useEmbeddedWallet.ts
|
|
1858
|
-
var
|
|
1905
|
+
var import_vue26 = require("vue");
|
|
1859
1906
|
function useEmbeddedWallet(options) {
|
|
1860
1907
|
const guard = useActionGuard();
|
|
1861
1908
|
const run = (action) => guard.run(action, "Embedded wallet action failed");
|
|
1862
|
-
const wallet = (0,
|
|
1909
|
+
const wallet = (0, import_vue26.computed)(() => (0, import_vue26.toValue)(options.wallet));
|
|
1863
1910
|
return {
|
|
1864
1911
|
wallet,
|
|
1865
|
-
hasWallet: (0,
|
|
1866
|
-
address: (0,
|
|
1867
|
-
accounts: (0,
|
|
1868
|
-
activeNamespace: (0,
|
|
1869
|
-
backupPending: (0,
|
|
1870
|
-
storageSecurityLevel: (0,
|
|
1871
|
-
securityReport: (0,
|
|
1872
|
-
connectEmbedded: () => run(() => (0,
|
|
1873
|
-
restoreWallet: () => run(() => (0,
|
|
1874
|
-
generateWallet: () => run(() => (0,
|
|
1875
|
-
importFromMnemonic: (value) => run(() => (0,
|
|
1876
|
-
importFromPrivateKey: (value) => run(() => (0,
|
|
1877
|
-
wipe: () => run(() => (0,
|
|
1878
|
-
setActiveNamespace: (value) => (0,
|
|
1879
|
-
backfillAccounts: () => run(() => (0,
|
|
1880
|
-
getSeedPhrase: () => (0,
|
|
1881
|
-
getPrivateKey: () => (0,
|
|
1882
|
-
confirmBackup: () => (0,
|
|
1912
|
+
hasWallet: (0, import_vue26.computed)(() => wallet.value !== null),
|
|
1913
|
+
address: (0, import_vue26.computed)(() => wallet.value?.address ?? null),
|
|
1914
|
+
accounts: (0, import_vue26.computed)(() => wallet.value?.accounts ?? []),
|
|
1915
|
+
activeNamespace: (0, import_vue26.computed)(() => wallet.value?.activeNamespace ?? null),
|
|
1916
|
+
backupPending: (0, import_vue26.computed)(() => (0, import_vue26.toValue)(options.backupPending)),
|
|
1917
|
+
storageSecurityLevel: (0, import_vue26.computed)(() => (0, import_vue26.toValue)(options.storageSecurityLevel)),
|
|
1918
|
+
securityReport: (0, import_vue26.computed)(() => (0, import_vue26.toValue)(options.securityReport)),
|
|
1919
|
+
connectEmbedded: () => run(() => (0, import_vue26.unref)(options.connectEmbedded)()),
|
|
1920
|
+
restoreWallet: () => run(() => (0, import_vue26.unref)(options.restoreWallet)()),
|
|
1921
|
+
generateWallet: () => run(() => (0, import_vue26.unref)(options.generateWallet)()),
|
|
1922
|
+
importFromMnemonic: (value) => run(() => (0, import_vue26.unref)(options.importFromMnemonic)(value)),
|
|
1923
|
+
importFromPrivateKey: (value) => run(() => (0, import_vue26.unref)(options.importFromPrivateKey)(value)),
|
|
1924
|
+
wipe: () => run(() => (0, import_vue26.unref)(options.wipe)()),
|
|
1925
|
+
setActiveNamespace: (value) => (0, import_vue26.unref)(options.setActiveNamespace)(value),
|
|
1926
|
+
backfillAccounts: () => run(() => (0, import_vue26.unref)(options.backfillAccounts)()),
|
|
1927
|
+
getSeedPhrase: () => (0, import_vue26.unref)(options.getSeedPhrase)(),
|
|
1928
|
+
getPrivateKey: () => (0, import_vue26.unref)(options.getPrivateKey)(),
|
|
1929
|
+
confirmBackup: () => (0, import_vue26.unref)(options.confirmBackup)(),
|
|
1883
1930
|
isBusy: guard.busy,
|
|
1884
1931
|
error: guard.error,
|
|
1885
1932
|
clearError: guard.clearError
|
|
@@ -1898,43 +1945,43 @@ function useSIWxLogin(action) {
|
|
|
1898
1945
|
}
|
|
1899
1946
|
|
|
1900
1947
|
// src/useSIWxSession.ts
|
|
1901
|
-
var
|
|
1948
|
+
var import_vue27 = require("vue");
|
|
1902
1949
|
function useSIWxSession(options) {
|
|
1903
1950
|
const guard = useActionGuard();
|
|
1904
1951
|
return {
|
|
1905
|
-
session: (0,
|
|
1906
|
-
isAuthenticated: (0,
|
|
1907
|
-
() => (0,
|
|
1952
|
+
session: (0, import_vue27.computed)(() => (0, import_vue27.toValue)(options.session)),
|
|
1953
|
+
isAuthenticated: (0, import_vue27.computed)(
|
|
1954
|
+
() => (0, import_vue27.toValue)(options.session) !== null && !(0, import_vue27.toValue)(options.isExpired)
|
|
1908
1955
|
),
|
|
1909
|
-
isRestoring: (0,
|
|
1956
|
+
isRestoring: (0, import_vue27.computed)(() => (0, import_vue27.toValue)(options.isRestoring)),
|
|
1910
1957
|
isSigningIn: guard.busy,
|
|
1911
|
-
isExpired: (0,
|
|
1912
|
-
timeUntilExpiry: (0,
|
|
1913
|
-
signIn: (input) => guard.run(() => (0,
|
|
1958
|
+
isExpired: (0, import_vue27.computed)(() => (0, import_vue27.toValue)(options.isExpired)),
|
|
1959
|
+
timeUntilExpiry: (0, import_vue27.computed)(() => (0, import_vue27.toValue)(options.timeUntilExpiry)),
|
|
1960
|
+
signIn: (input) => guard.run(() => (0, import_vue27.unref)(options.signIn)(input), "SIWX sign-in failed"),
|
|
1914
1961
|
signOut: async () => {
|
|
1915
|
-
await (0,
|
|
1962
|
+
await (0, import_vue27.unref)(options.signOut)();
|
|
1916
1963
|
guard.clearError();
|
|
1917
1964
|
},
|
|
1918
|
-
refresh: () => guard.run(() => (0,
|
|
1965
|
+
refresh: () => guard.run(() => (0, import_vue27.unref)(options.refresh)(), "Session refresh failed"),
|
|
1919
1966
|
error: guard.error,
|
|
1920
1967
|
clearError: guard.clearError
|
|
1921
1968
|
};
|
|
1922
1969
|
}
|
|
1923
1970
|
|
|
1924
1971
|
// src/useSiwxAuthSession.ts
|
|
1925
|
-
var
|
|
1972
|
+
var import_vue28 = require("vue");
|
|
1926
1973
|
function useSiwxAuthSession(options) {
|
|
1927
1974
|
const guard = useActionGuard();
|
|
1928
|
-
const signIn = (input) => guard.run(() => (0,
|
|
1975
|
+
const signIn = (input) => guard.run(() => (0, import_vue28.unref)(options.signIn)(input), "SIWX sign-in failed");
|
|
1929
1976
|
const signOut = async () => {
|
|
1930
1977
|
guard.reset();
|
|
1931
|
-
await (0,
|
|
1978
|
+
await (0, import_vue28.unref)(options.signOut)();
|
|
1932
1979
|
guard.clearError();
|
|
1933
1980
|
};
|
|
1934
|
-
const siwxResult = (0,
|
|
1981
|
+
const siwxResult = (0, import_vue28.computed)(() => (0, import_vue28.toValue)(options.result));
|
|
1935
1982
|
return {
|
|
1936
|
-
isSignedIn: (0,
|
|
1937
|
-
isRestoring: (0,
|
|
1983
|
+
isSignedIn: (0, import_vue28.computed)(() => siwxResult.value !== null),
|
|
1984
|
+
isRestoring: (0, import_vue28.computed)(() => (0, import_vue28.toValue)(options.isRestoring)),
|
|
1938
1985
|
siwxResult,
|
|
1939
1986
|
isSigningIn: guard.busy,
|
|
1940
1987
|
error: guard.error,
|
|
@@ -1946,16 +1993,16 @@ function useSiwxAuthSession(options) {
|
|
|
1946
1993
|
|
|
1947
1994
|
// src/useBalance.ts
|
|
1948
1995
|
var import_connect_appkit_core14 = require("@naculus/connect-appkit-core");
|
|
1949
|
-
var
|
|
1950
|
-
var
|
|
1996
|
+
var import_connect_core12 = require("@naculus/connect-core");
|
|
1997
|
+
var import_vue29 = require("vue");
|
|
1951
1998
|
function useBalance(account, client, options = {}) {
|
|
1952
1999
|
const guard = useActionGuard();
|
|
1953
|
-
const balance = (0,
|
|
1954
|
-
const isFetching = (0,
|
|
2000
|
+
const balance = (0, import_vue29.shallowRef)(null);
|
|
2001
|
+
const isFetching = (0, import_vue29.shallowRef)(false);
|
|
1955
2002
|
let timer = null;
|
|
1956
2003
|
const refetch = async () => {
|
|
1957
|
-
const reader = (0,
|
|
1958
|
-
const address = (0, import_connect_appkit_core14.bareEvmAddress)((0,
|
|
2004
|
+
const reader = (0, import_vue29.toValue)(client);
|
|
2005
|
+
const address = (0, import_connect_appkit_core14.bareEvmAddress)((0, import_vue29.toValue)(account));
|
|
1959
2006
|
if (!reader || !address) {
|
|
1960
2007
|
guard.reset();
|
|
1961
2008
|
balance.value = null;
|
|
@@ -1991,11 +2038,11 @@ function useBalance(account, client, options = {}) {
|
|
|
1991
2038
|
if (timer) clearInterval(timer);
|
|
1992
2039
|
timer = null;
|
|
1993
2040
|
};
|
|
1994
|
-
(0,
|
|
2041
|
+
(0, import_vue29.watch)(
|
|
1995
2042
|
[
|
|
1996
|
-
() => (0,
|
|
1997
|
-
() => (0,
|
|
1998
|
-
() => (0,
|
|
2043
|
+
() => (0, import_vue29.toValue)(account),
|
|
2044
|
+
() => (0, import_vue29.toValue)(client),
|
|
2045
|
+
() => (0, import_vue29.toValue)(options.refreshInterval) ?? 0
|
|
1999
2046
|
],
|
|
2000
2047
|
([, , interval]) => {
|
|
2001
2048
|
stopTimer();
|
|
@@ -2004,13 +2051,13 @@ function useBalance(account, client, options = {}) {
|
|
|
2004
2051
|
},
|
|
2005
2052
|
{ immediate: true }
|
|
2006
2053
|
);
|
|
2007
|
-
(0,
|
|
2054
|
+
(0, import_vue29.onScopeDispose)(stopTimer);
|
|
2008
2055
|
return {
|
|
2009
2056
|
balance,
|
|
2010
|
-
formatted: (0,
|
|
2011
|
-
() => balance.value === null ? null : (0,
|
|
2057
|
+
formatted: (0, import_vue29.computed)(
|
|
2058
|
+
() => balance.value === null ? null : (0, import_connect_core12.formatUnits)(BigInt(balance.value), (0, import_vue29.toValue)(options.decimals) ?? 18)
|
|
2012
2059
|
),
|
|
2013
|
-
symbol: (0,
|
|
2060
|
+
symbol: (0, import_vue29.computed)(() => (0, import_vue29.toValue)(options.symbol) ?? null),
|
|
2014
2061
|
isFetching,
|
|
2015
2062
|
error: guard.error,
|
|
2016
2063
|
refetch
|
|
@@ -2019,11 +2066,11 @@ function useBalance(account, client, options = {}) {
|
|
|
2019
2066
|
|
|
2020
2067
|
// src/useRouteQuote.ts
|
|
2021
2068
|
var import_connect_appkit_core15 = require("@naculus/connect-appkit-core");
|
|
2022
|
-
var
|
|
2069
|
+
var import_vue30 = require("vue");
|
|
2023
2070
|
function useRouteQuote(input, getQuotes, options = {}) {
|
|
2024
2071
|
const guard = useActionGuard();
|
|
2025
|
-
const quotes = (0,
|
|
2026
|
-
const loading = (0,
|
|
2072
|
+
const quotes = (0, import_vue30.shallowRef)([]);
|
|
2073
|
+
const loading = (0, import_vue30.shallowRef)(false);
|
|
2027
2074
|
let timer = null;
|
|
2028
2075
|
const clearTimer = () => {
|
|
2029
2076
|
if (timer) clearTimeout(timer);
|
|
@@ -2036,7 +2083,7 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
2036
2083
|
quotes.value = [];
|
|
2037
2084
|
return null;
|
|
2038
2085
|
}
|
|
2039
|
-
const fn = (0,
|
|
2086
|
+
const fn = (0, import_vue30.unref)(getQuotes);
|
|
2040
2087
|
if (!fn) {
|
|
2041
2088
|
guard.invalidate();
|
|
2042
2089
|
loading.value = false;
|
|
@@ -2045,7 +2092,7 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
2045
2092
|
return fn;
|
|
2046
2093
|
};
|
|
2047
2094
|
const fetchQuotes = async () => {
|
|
2048
|
-
const current = (0,
|
|
2095
|
+
const current = (0, import_vue30.toValue)(input);
|
|
2049
2096
|
const fn = requestable(current);
|
|
2050
2097
|
if (!fn) return;
|
|
2051
2098
|
loading.value = true;
|
|
@@ -2080,19 +2127,19 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
2080
2127
|
).catch(() => {
|
|
2081
2128
|
});
|
|
2082
2129
|
};
|
|
2083
|
-
(0,
|
|
2130
|
+
(0, import_vue30.watch)(
|
|
2084
2131
|
[
|
|
2085
|
-
() => (0,
|
|
2086
|
-
() => (0,
|
|
2087
|
-
() => (0,
|
|
2088
|
-
() => (0,
|
|
2089
|
-
() => (0,
|
|
2090
|
-
() => (0,
|
|
2132
|
+
() => (0, import_vue30.toValue)(input).fromChain,
|
|
2133
|
+
() => (0, import_vue30.toValue)(input).toChain,
|
|
2134
|
+
() => (0, import_vue30.toValue)(input).fromToken,
|
|
2135
|
+
() => (0, import_vue30.toValue)(input).toToken,
|
|
2136
|
+
() => (0, import_vue30.toValue)(input).amount,
|
|
2137
|
+
() => (0, import_vue30.unref)(getQuotes)
|
|
2091
2138
|
],
|
|
2092
2139
|
() => {
|
|
2093
2140
|
clearTimer();
|
|
2094
2141
|
guard.invalidate();
|
|
2095
|
-
if (!requestable((0,
|
|
2142
|
+
if (!requestable((0, import_vue30.toValue)(input))) return;
|
|
2096
2143
|
timer = setTimeout(() => {
|
|
2097
2144
|
timer = null;
|
|
2098
2145
|
void fetchQuotes();
|
|
@@ -2100,7 +2147,7 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
2100
2147
|
},
|
|
2101
2148
|
{ immediate: true }
|
|
2102
2149
|
);
|
|
2103
|
-
(0,
|
|
2150
|
+
(0, import_vue30.onScopeDispose)(clearTimer);
|
|
2104
2151
|
return {
|
|
2105
2152
|
quotes,
|
|
2106
2153
|
loading,
|
|
@@ -2117,14 +2164,14 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
2117
2164
|
|
|
2118
2165
|
// src/useCompareCosts.ts
|
|
2119
2166
|
var import_connect_appkit_core16 = require("@naculus/connect-appkit-core");
|
|
2120
|
-
var
|
|
2167
|
+
var import_vue31 = require("vue");
|
|
2121
2168
|
function useCompareCosts(input, compareCosts) {
|
|
2122
2169
|
const guard = useActionGuard();
|
|
2123
|
-
const comparisons = (0,
|
|
2124
|
-
const loading = (0,
|
|
2170
|
+
const comparisons = (0, import_vue31.shallowRef)([]);
|
|
2171
|
+
const loading = (0, import_vue31.shallowRef)(false);
|
|
2125
2172
|
const fetchComparisons = async () => {
|
|
2126
|
-
const { operation, chains, options } = (0,
|
|
2127
|
-
const fn = (0,
|
|
2173
|
+
const { operation, chains, options } = (0, import_vue31.toValue)(input);
|
|
2174
|
+
const fn = (0, import_vue31.unref)(compareCosts);
|
|
2128
2175
|
if (!chains || chains.length === 0) {
|
|
2129
2176
|
guard.invalidate();
|
|
2130
2177
|
loading.value = false;
|
|
@@ -2161,8 +2208,8 @@ function useCompareCosts(input, compareCosts) {
|
|
|
2161
2208
|
).catch(() => {
|
|
2162
2209
|
});
|
|
2163
2210
|
};
|
|
2164
|
-
(0,
|
|
2165
|
-
[() => (0, import_connect_appkit_core16.compareCostsKey)((0,
|
|
2211
|
+
(0, import_vue31.watch)(
|
|
2212
|
+
[() => (0, import_connect_appkit_core16.compareCostsKey)((0, import_vue31.toValue)(input)), () => (0, import_vue31.unref)(compareCosts)],
|
|
2166
2213
|
() => {
|
|
2167
2214
|
void fetchComparisons();
|
|
2168
2215
|
},
|
|
@@ -2178,15 +2225,15 @@ function useCompareCosts(input, compareCosts) {
|
|
|
2178
2225
|
|
|
2179
2226
|
// src/useExecuteRoute.ts
|
|
2180
2227
|
var import_connect_appkit_core17 = require("@naculus/connect-appkit-core");
|
|
2181
|
-
var
|
|
2228
|
+
var import_vue32 = require("vue");
|
|
2182
2229
|
function useExecuteRoute(executeRoute) {
|
|
2183
|
-
const executing = (0,
|
|
2184
|
-
const result = (0,
|
|
2185
|
-
const error = (0,
|
|
2230
|
+
const executing = (0, import_vue32.shallowRef)(false);
|
|
2231
|
+
const result = (0, import_vue32.shallowRef)(null);
|
|
2232
|
+
const error = (0, import_vue32.shallowRef)(null);
|
|
2186
2233
|
let inFlight = false;
|
|
2187
2234
|
let disposed = false;
|
|
2188
2235
|
const execute = async (quote, recipient, options) => {
|
|
2189
|
-
const fn = (0,
|
|
2236
|
+
const fn = (0, import_vue32.unref)(executeRoute);
|
|
2190
2237
|
if (!fn) {
|
|
2191
2238
|
error.value = {
|
|
2192
2239
|
code: "no_executor",
|
|
@@ -2224,7 +2271,7 @@ function useExecuteRoute(executeRoute) {
|
|
|
2224
2271
|
if (!disposed) executing.value = false;
|
|
2225
2272
|
}
|
|
2226
2273
|
};
|
|
2227
|
-
(0,
|
|
2274
|
+
(0, import_vue32.onScopeDispose)(() => {
|
|
2228
2275
|
disposed = true;
|
|
2229
2276
|
});
|
|
2230
2277
|
return {
|
|
@@ -2242,18 +2289,18 @@ function useExecuteRoute(executeRoute) {
|
|
|
2242
2289
|
|
|
2243
2290
|
// src/useTokenList.ts
|
|
2244
2291
|
var import_connect_appkit_core18 = require("@naculus/connect-appkit-core");
|
|
2245
|
-
var
|
|
2246
|
-
var
|
|
2292
|
+
var import_connect_core13 = require("@naculus/connect-core");
|
|
2293
|
+
var import_vue33 = require("vue");
|
|
2247
2294
|
function useTokenList(chainId, options = {}) {
|
|
2248
2295
|
const config = {};
|
|
2249
2296
|
if (options.sources) config.sources = options.sources;
|
|
2250
|
-
const manager = options.manager ?? new
|
|
2297
|
+
const manager = options.manager ?? new import_connect_core13.TokenListManager(config);
|
|
2251
2298
|
const guard = useActionGuard();
|
|
2252
|
-
const tokens = (0,
|
|
2253
|
-
const isLoading = (0,
|
|
2254
|
-
const isLoaded = (0,
|
|
2299
|
+
const tokens = (0, import_vue33.shallowRef)([]);
|
|
2300
|
+
const isLoading = (0, import_vue33.shallowRef)(options.autoLoad !== false);
|
|
2301
|
+
const isLoaded = (0, import_vue33.shallowRef)(false);
|
|
2255
2302
|
const select = () => {
|
|
2256
|
-
const id = (0,
|
|
2303
|
+
const id = (0, import_vue33.toValue)(chainId);
|
|
2257
2304
|
const numeric = id ? (0, import_connect_appkit_core18.eip155ChainIdToNumber)(id) : void 0;
|
|
2258
2305
|
return manager.getTokens(
|
|
2259
2306
|
numeric !== void 0 ? { chainId: numeric } : void 0
|
|
@@ -2279,8 +2326,8 @@ function useTokenList(chainId, options = {}) {
|
|
|
2279
2326
|
).catch(() => {
|
|
2280
2327
|
});
|
|
2281
2328
|
};
|
|
2282
|
-
(0,
|
|
2283
|
-
() => (0,
|
|
2329
|
+
(0, import_vue33.watch)(
|
|
2330
|
+
() => (0, import_vue33.toValue)(chainId),
|
|
2284
2331
|
() => {
|
|
2285
2332
|
if (options.autoLoad !== false) void run(() => manager.load());
|
|
2286
2333
|
},
|
|
@@ -2297,29 +2344,29 @@ function useTokenList(chainId, options = {}) {
|
|
|
2297
2344
|
|
|
2298
2345
|
// src/useTokenSearch.ts
|
|
2299
2346
|
var import_connect_appkit_core19 = require("@naculus/connect-appkit-core");
|
|
2300
|
-
var
|
|
2301
|
-
var
|
|
2347
|
+
var import_connect_core14 = require("@naculus/connect-core");
|
|
2348
|
+
var import_vue34 = require("vue");
|
|
2302
2349
|
var DEBOUNCE_MS = 300;
|
|
2303
2350
|
var EMPTY = { exact: [], fuzzy: [], hasMore: false };
|
|
2304
2351
|
var sharedManager = null;
|
|
2305
2352
|
function getSharedManager() {
|
|
2306
2353
|
if (!sharedManager) {
|
|
2307
|
-
sharedManager = new
|
|
2354
|
+
sharedManager = new import_connect_core14.TokenListManager();
|
|
2308
2355
|
sharedManager.load().catch(() => {
|
|
2309
2356
|
});
|
|
2310
2357
|
}
|
|
2311
2358
|
return sharedManager;
|
|
2312
2359
|
}
|
|
2313
2360
|
function useTokenSearch(query, chainId, options = {}) {
|
|
2314
|
-
const results = (0,
|
|
2315
|
-
const isSearching = (0,
|
|
2361
|
+
const results = (0, import_vue34.shallowRef)(EMPTY);
|
|
2362
|
+
const isSearching = (0, import_vue34.shallowRef)(false);
|
|
2316
2363
|
let timer = null;
|
|
2317
2364
|
const clear = () => {
|
|
2318
2365
|
if (timer) clearTimeout(timer);
|
|
2319
2366
|
timer = null;
|
|
2320
2367
|
};
|
|
2321
|
-
(0,
|
|
2322
|
-
[() => ((0,
|
|
2368
|
+
(0, import_vue34.watch)(
|
|
2369
|
+
[() => ((0, import_vue34.toValue)(query) ?? "").trim(), () => (0, import_vue34.toValue)(chainId)],
|
|
2323
2370
|
([q, id]) => {
|
|
2324
2371
|
clear();
|
|
2325
2372
|
if (!q) {
|
|
@@ -2341,35 +2388,35 @@ function useTokenSearch(query, chainId, options = {}) {
|
|
|
2341
2388
|
},
|
|
2342
2389
|
{ immediate: true }
|
|
2343
2390
|
);
|
|
2344
|
-
(0,
|
|
2391
|
+
(0, import_vue34.onScopeDispose)(clear);
|
|
2345
2392
|
return { results, isSearching };
|
|
2346
2393
|
}
|
|
2347
2394
|
|
|
2348
2395
|
// src/useValidateDestination.ts
|
|
2349
2396
|
var import_connect_appkit_core20 = require("@naculus/connect-appkit-core");
|
|
2350
|
-
var
|
|
2397
|
+
var import_vue35 = require("vue");
|
|
2351
2398
|
function useValidateDestination(address) {
|
|
2352
2399
|
return {
|
|
2353
|
-
validation: (0,
|
|
2400
|
+
validation: (0, import_vue35.computed)(() => (0, import_connect_appkit_core20.validateDestination)((0, import_vue35.toValue)(address) ?? ""))
|
|
2354
2401
|
};
|
|
2355
2402
|
}
|
|
2356
2403
|
|
|
2357
2404
|
// src/useTokenBalance.ts
|
|
2358
2405
|
var import_connect_appkit_core21 = require("@naculus/connect-appkit-core");
|
|
2359
|
-
var
|
|
2360
|
-
var
|
|
2406
|
+
var import_connect_core15 = require("@naculus/connect-core");
|
|
2407
|
+
var import_vue36 = require("vue");
|
|
2361
2408
|
function tokensKey(tokens) {
|
|
2362
2409
|
return tokens.map((t) => `${t.address.toLowerCase()}|${t.decimals}|${t.symbol}`).join(",");
|
|
2363
2410
|
}
|
|
2364
2411
|
function useTokenBalance(account, client, tokens, options = {}) {
|
|
2365
2412
|
const guard = useActionGuard();
|
|
2366
|
-
const tokenBalances = (0,
|
|
2367
|
-
const isFetching = (0,
|
|
2413
|
+
const tokenBalances = (0, import_vue36.shallowRef)([]);
|
|
2414
|
+
const isFetching = (0, import_vue36.shallowRef)(false);
|
|
2368
2415
|
let timer = null;
|
|
2369
2416
|
const refetch = async () => {
|
|
2370
|
-
const reader = (0,
|
|
2371
|
-
const address = (0, import_connect_appkit_core21.bareEvmAddress)((0,
|
|
2372
|
-
const list = (0,
|
|
2417
|
+
const reader = (0, import_vue36.toValue)(client);
|
|
2418
|
+
const address = (0, import_connect_appkit_core21.bareEvmAddress)((0, import_vue36.toValue)(account));
|
|
2419
|
+
const list = (0, import_vue36.toValue)(tokens) ?? [];
|
|
2373
2420
|
if (!reader || !address || list.length === 0) {
|
|
2374
2421
|
guard.reset();
|
|
2375
2422
|
tokenBalances.value = [];
|
|
@@ -2385,7 +2432,7 @@ function useTokenBalance(account, client, tokens, options = {}) {
|
|
|
2385
2432
|
try {
|
|
2386
2433
|
const raw = await reader.readContract({
|
|
2387
2434
|
address: token.address,
|
|
2388
|
-
abi:
|
|
2435
|
+
abi: import_connect_core15.ERC20_MIN_ABI,
|
|
2389
2436
|
functionName: "balanceOf",
|
|
2390
2437
|
args: [address]
|
|
2391
2438
|
});
|
|
@@ -2393,7 +2440,7 @@ function useTokenBalance(account, client, tokens, options = {}) {
|
|
|
2393
2440
|
return {
|
|
2394
2441
|
...token,
|
|
2395
2442
|
balance: value.toString(),
|
|
2396
|
-
formatted: (0,
|
|
2443
|
+
formatted: (0, import_connect_core15.formatUnits)(value, token.decimals)
|
|
2397
2444
|
};
|
|
2398
2445
|
} catch {
|
|
2399
2446
|
return { ...token, balance: null, formatted: null };
|
|
@@ -2424,12 +2471,12 @@ function useTokenBalance(account, client, tokens, options = {}) {
|
|
|
2424
2471
|
if (timer) clearInterval(timer);
|
|
2425
2472
|
timer = null;
|
|
2426
2473
|
};
|
|
2427
|
-
(0,
|
|
2474
|
+
(0, import_vue36.watch)(
|
|
2428
2475
|
[
|
|
2429
|
-
() => (0,
|
|
2430
|
-
() => (0,
|
|
2431
|
-
() => tokensKey((0,
|
|
2432
|
-
() => (0,
|
|
2476
|
+
() => (0, import_vue36.toValue)(account),
|
|
2477
|
+
() => (0, import_vue36.toValue)(client),
|
|
2478
|
+
() => tokensKey((0, import_vue36.toValue)(tokens) ?? []),
|
|
2479
|
+
() => (0, import_vue36.toValue)(options.refreshInterval) ?? 0
|
|
2433
2480
|
],
|
|
2434
2481
|
([, , , interval]) => {
|
|
2435
2482
|
stopTimer();
|
|
@@ -2438,7 +2485,7 @@ function useTokenBalance(account, client, tokens, options = {}) {
|
|
|
2438
2485
|
},
|
|
2439
2486
|
{ immediate: true }
|
|
2440
2487
|
);
|
|
2441
|
-
(0,
|
|
2488
|
+
(0, import_vue36.onScopeDispose)(stopTimer);
|
|
2442
2489
|
return {
|
|
2443
2490
|
tokenBalances,
|
|
2444
2491
|
isFetching,
|
|
@@ -2452,12 +2499,12 @@ function useTokenBalance(account, client, tokens, options = {}) {
|
|
|
2452
2499
|
|
|
2453
2500
|
// src/useDelegate.ts
|
|
2454
2501
|
var import_connect_appkit_core22 = require("@naculus/connect-appkit-core");
|
|
2455
|
-
var
|
|
2456
|
-
var
|
|
2502
|
+
var import_connect_core16 = require("@naculus/connect-core");
|
|
2503
|
+
var import_vue37 = require("vue");
|
|
2457
2504
|
function useDelegate(options) {
|
|
2458
|
-
const result = (0,
|
|
2459
|
-
const isPending = (0,
|
|
2460
|
-
const error = (0,
|
|
2505
|
+
const result = (0, import_vue37.shallowRef)(null);
|
|
2506
|
+
const isPending = (0, import_vue37.shallowRef)(false);
|
|
2507
|
+
const error = (0, import_vue37.shallowRef)(null);
|
|
2461
2508
|
let requestId = 0;
|
|
2462
2509
|
let inFlight = false;
|
|
2463
2510
|
let disposed = false;
|
|
@@ -2467,31 +2514,31 @@ function useDelegate(options) {
|
|
|
2467
2514
|
};
|
|
2468
2515
|
const run = async (target, allowlist) => {
|
|
2469
2516
|
if (inFlight) return fail(new Error("A delegation is already in progress"));
|
|
2470
|
-
const session = (0,
|
|
2471
|
-
const account = (0, import_connect_appkit_core22.bareEvmAddress)((0,
|
|
2472
|
-
const chainId = (0,
|
|
2517
|
+
const session = (0, import_vue37.toValue)(options.session);
|
|
2518
|
+
const account = (0, import_connect_appkit_core22.bareEvmAddress)((0, import_vue37.toValue)(options.account));
|
|
2519
|
+
const chainId = (0, import_vue37.toValue)(options.chainId);
|
|
2473
2520
|
if (!session || !account || !chainId) {
|
|
2474
2521
|
return fail(
|
|
2475
|
-
new
|
|
2522
|
+
new import_connect_core16.WalletError("wallet_unavailable", "No connected EVM account")
|
|
2476
2523
|
);
|
|
2477
2524
|
}
|
|
2478
|
-
const reader = (0,
|
|
2479
|
-
if (!reader || reader.chain?.id !== (0,
|
|
2525
|
+
const reader = (0, import_vue37.toValue)(options.client);
|
|
2526
|
+
if (!reader || reader.chain?.id !== (0, import_connect_core16.eip155Reference)(chainId)) {
|
|
2480
2527
|
return fail(
|
|
2481
|
-
new
|
|
2528
|
+
new import_connect_core16.WalletError(
|
|
2482
2529
|
"chain_mismatch",
|
|
2483
2530
|
`No RPC client for ${chainId}; refusing to read the nonce elsewhere.`
|
|
2484
2531
|
)
|
|
2485
2532
|
);
|
|
2486
2533
|
}
|
|
2487
|
-
const connector = (0,
|
|
2534
|
+
const connector = (0, import_vue37.toValue)(options.connector) ?? {};
|
|
2488
2535
|
const own = ++requestId;
|
|
2489
2536
|
inFlight = true;
|
|
2490
2537
|
isPending.value = true;
|
|
2491
2538
|
error.value = null;
|
|
2492
2539
|
result.value = null;
|
|
2493
2540
|
try {
|
|
2494
|
-
const sent = await (0,
|
|
2541
|
+
const sent = await (0, import_connect_core16.delegateAccount)({
|
|
2495
2542
|
connector,
|
|
2496
2543
|
session,
|
|
2497
2544
|
account,
|
|
@@ -2519,22 +2566,22 @@ function useDelegate(options) {
|
|
|
2519
2566
|
isPending.value = false;
|
|
2520
2567
|
error.value = null;
|
|
2521
2568
|
};
|
|
2522
|
-
(0,
|
|
2569
|
+
(0, import_vue37.watch)(
|
|
2523
2570
|
[
|
|
2524
|
-
() => (0,
|
|
2525
|
-
() => (0,
|
|
2526
|
-
() => (0,
|
|
2571
|
+
() => (0, import_vue37.toValue)(options.session),
|
|
2572
|
+
() => (0, import_vue37.toValue)(options.account),
|
|
2573
|
+
() => (0, import_vue37.toValue)(options.chainId)
|
|
2527
2574
|
],
|
|
2528
2575
|
reset,
|
|
2529
2576
|
{ flush: "sync" }
|
|
2530
2577
|
);
|
|
2531
|
-
(0,
|
|
2578
|
+
(0, import_vue37.onScopeDispose)(() => {
|
|
2532
2579
|
disposed = true;
|
|
2533
2580
|
requestId++;
|
|
2534
2581
|
});
|
|
2535
2582
|
return {
|
|
2536
|
-
delegate: (target) => run(target, (0,
|
|
2537
|
-
revoke: () => run(
|
|
2583
|
+
delegate: (target) => run(target, (0, import_vue37.toValue)(options.allowlist)),
|
|
2584
|
+
revoke: () => run(import_connect_core16.REVOKE_DELEGATE, []),
|
|
2538
2585
|
result,
|
|
2539
2586
|
isPending,
|
|
2540
2587
|
error,
|
|
@@ -2544,16 +2591,16 @@ function useDelegate(options) {
|
|
|
2544
2591
|
|
|
2545
2592
|
// src/useDelegation.ts
|
|
2546
2593
|
var import_connect_appkit_core23 = require("@naculus/connect-appkit-core");
|
|
2547
|
-
var
|
|
2548
|
-
var
|
|
2594
|
+
var import_connect_core17 = require("@naculus/connect-core");
|
|
2595
|
+
var import_vue38 = require("vue");
|
|
2549
2596
|
function useDelegation(account, client, chainId) {
|
|
2550
2597
|
const guard = useActionGuard();
|
|
2551
|
-
const status = (0,
|
|
2552
|
-
const isFetching = (0,
|
|
2598
|
+
const status = (0, import_vue38.shallowRef)(import_connect_core17.UNKNOWN_DELEGATION);
|
|
2599
|
+
const isFetching = (0, import_vue38.shallowRef)(false);
|
|
2553
2600
|
const refetch = async () => {
|
|
2554
|
-
const reader = (0,
|
|
2555
|
-
const address = (0, import_connect_appkit_core23.bareEvmAddress)((0,
|
|
2556
|
-
status.value =
|
|
2601
|
+
const reader = (0, import_vue38.toValue)(client);
|
|
2602
|
+
const address = (0, import_connect_appkit_core23.bareEvmAddress)((0, import_vue38.toValue)(account));
|
|
2603
|
+
status.value = import_connect_core17.UNKNOWN_DELEGATION;
|
|
2557
2604
|
if (!reader || !address) {
|
|
2558
2605
|
guard.reset();
|
|
2559
2606
|
isFetching.value = false;
|
|
@@ -2565,11 +2612,11 @@ function useDelegation(account, client, chainId) {
|
|
|
2565
2612
|
try {
|
|
2566
2613
|
const code = await reader.getCode({ address });
|
|
2567
2614
|
commit(() => {
|
|
2568
|
-
status.value = (0,
|
|
2615
|
+
status.value = (0, import_connect_core17.readDelegation)(code ?? "0x");
|
|
2569
2616
|
});
|
|
2570
2617
|
} catch (cause) {
|
|
2571
2618
|
commit(() => {
|
|
2572
|
-
status.value =
|
|
2619
|
+
status.value = import_connect_core17.UNKNOWN_DELEGATION;
|
|
2573
2620
|
});
|
|
2574
2621
|
throw cause;
|
|
2575
2622
|
}
|
|
@@ -2584,16 +2631,16 @@ function useDelegation(account, client, chainId) {
|
|
|
2584
2631
|
).catch(() => {
|
|
2585
2632
|
});
|
|
2586
2633
|
};
|
|
2587
|
-
(0,
|
|
2588
|
-
[() => (0,
|
|
2634
|
+
(0, import_vue38.watch)(
|
|
2635
|
+
[() => (0, import_vue38.toValue)(account), () => (0, import_vue38.toValue)(client), () => (0, import_vue38.toValue)(chainId)],
|
|
2589
2636
|
() => {
|
|
2590
2637
|
void refetch();
|
|
2591
2638
|
},
|
|
2592
2639
|
{ immediate: true, flush: "sync" }
|
|
2593
2640
|
);
|
|
2594
2641
|
return {
|
|
2595
|
-
delegated: (0,
|
|
2596
|
-
delegate: (0,
|
|
2642
|
+
delegated: (0, import_vue38.computed)(() => status.value.delegated),
|
|
2643
|
+
delegate: (0, import_vue38.computed)(() => status.value.delegate),
|
|
2597
2644
|
isFetching,
|
|
2598
2645
|
error: guard.error,
|
|
2599
2646
|
refetch
|
|
@@ -2602,21 +2649,61 @@ function useDelegation(account, client, chainId) {
|
|
|
2602
2649
|
|
|
2603
2650
|
// src/usePaymentFetch.ts
|
|
2604
2651
|
var import_connect_appkit_core24 = require("@naculus/connect-appkit-core");
|
|
2605
|
-
var
|
|
2606
|
-
function usePaymentFetch(pay) {
|
|
2652
|
+
var import_vue39 = require("vue");
|
|
2653
|
+
function usePaymentFetch(pay, options = {}) {
|
|
2607
2654
|
const guard = useActionGuard();
|
|
2608
|
-
const lastPayment = (0,
|
|
2655
|
+
const lastPayment = (0, import_vue39.shallowRef)(null);
|
|
2609
2656
|
let epoch = 0;
|
|
2610
|
-
|
|
2657
|
+
let verification = 0;
|
|
2658
|
+
(0, import_vue39.onScopeDispose)(() => {
|
|
2611
2659
|
epoch++;
|
|
2660
|
+
verification++;
|
|
2612
2661
|
});
|
|
2613
2662
|
const payFetch = (input, init) => {
|
|
2614
|
-
const invoke = (0,
|
|
2663
|
+
const invoke = (0, import_vue39.unref)(pay);
|
|
2615
2664
|
const own = epoch;
|
|
2616
2665
|
return guard.run(async () => {
|
|
2617
2666
|
const result = await invoke(input, init);
|
|
2618
|
-
|
|
2619
|
-
if (payment && own === epoch)
|
|
2667
|
+
let payment = (0, import_connect_appkit_core24.describePayment)(input, result);
|
|
2668
|
+
if (payment && own === epoch) {
|
|
2669
|
+
const verify = options.verify;
|
|
2670
|
+
if (!verify) {
|
|
2671
|
+
lastPayment.value = payment;
|
|
2672
|
+
} else {
|
|
2673
|
+
payment = (0, import_connect_appkit_core24.applySettlementVerification)(payment, { status: "pending" });
|
|
2674
|
+
lastPayment.value = payment;
|
|
2675
|
+
const verificationOwn = ++verification;
|
|
2676
|
+
const retry = options.verifyRetry ?? import_connect_appkit_core24.DEFAULT_VERIFY_RETRY;
|
|
2677
|
+
void Promise.resolve().then(async () => {
|
|
2678
|
+
let outcome = { status: "pending" };
|
|
2679
|
+
for (let attempt = 0; attempt < retry.attempts; attempt += 1) {
|
|
2680
|
+
if (attempt > 0) {
|
|
2681
|
+
await new Promise(
|
|
2682
|
+
(resolve) => setTimeout(resolve, retry.delayMs)
|
|
2683
|
+
);
|
|
2684
|
+
}
|
|
2685
|
+
if (own !== epoch || verificationOwn !== verification) return;
|
|
2686
|
+
try {
|
|
2687
|
+
outcome = await verify(result);
|
|
2688
|
+
} catch (cause) {
|
|
2689
|
+
outcome = {
|
|
2690
|
+
status: "unavailable",
|
|
2691
|
+
reason: cause instanceof Error ? cause.message : "Settlement verification failed"
|
|
2692
|
+
};
|
|
2693
|
+
}
|
|
2694
|
+
if (outcome.status !== "pending") break;
|
|
2695
|
+
}
|
|
2696
|
+
if (own === epoch && verificationOwn === verification) {
|
|
2697
|
+
const current = lastPayment.value;
|
|
2698
|
+
if (current)
|
|
2699
|
+
lastPayment.value = (0, import_connect_appkit_core24.applySettlementVerification)(
|
|
2700
|
+
current,
|
|
2701
|
+
outcome
|
|
2702
|
+
);
|
|
2703
|
+
}
|
|
2704
|
+
});
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2620
2707
|
return result;
|
|
2621
2708
|
}, "Paid request failed");
|
|
2622
2709
|
};
|
|
@@ -2627,6 +2714,7 @@ function usePaymentFetch(pay) {
|
|
|
2627
2714
|
error: guard.error,
|
|
2628
2715
|
reset: () => {
|
|
2629
2716
|
epoch++;
|
|
2717
|
+
verification++;
|
|
2630
2718
|
guard.reset();
|
|
2631
2719
|
lastPayment.value = null;
|
|
2632
2720
|
}
|
|
@@ -2635,23 +2723,23 @@ function usePaymentFetch(pay) {
|
|
|
2635
2723
|
|
|
2636
2724
|
// src/useMppSession.ts
|
|
2637
2725
|
var import_connect_appkit_core25 = require("@naculus/connect-appkit-core");
|
|
2638
|
-
var
|
|
2726
|
+
var import_vue40 = require("vue");
|
|
2639
2727
|
function useMppSession(session) {
|
|
2640
|
-
const current = () => (0,
|
|
2641
|
-
const pending = (0,
|
|
2642
|
-
const channel = (0,
|
|
2728
|
+
const current = () => (0, import_vue40.unref)(session);
|
|
2729
|
+
const pending = (0, import_vue40.shallowRef)(current().meter.pending);
|
|
2730
|
+
const channel = (0, import_vue40.shallowRef)(
|
|
2643
2731
|
(0, import_connect_appkit_core25.readCurrentMppSessionChannel)(current())
|
|
2644
2732
|
);
|
|
2645
|
-
const lastReceipt = (0,
|
|
2646
|
-
const recoveryChannelId = (0,
|
|
2647
|
-
const isPending = (0,
|
|
2648
|
-
const error = (0,
|
|
2733
|
+
const lastReceipt = (0, import_vue40.shallowRef)(null);
|
|
2734
|
+
const recoveryChannelId = (0, import_vue40.shallowRef)(null);
|
|
2735
|
+
const isPending = (0, import_vue40.shallowRef)(false);
|
|
2736
|
+
const error = (0, import_vue40.shallowRef)(null);
|
|
2649
2737
|
let active = 0;
|
|
2650
2738
|
let generation = 0;
|
|
2651
2739
|
let epoch = 0;
|
|
2652
2740
|
let disposed = false;
|
|
2653
|
-
(0,
|
|
2654
|
-
() => (0,
|
|
2741
|
+
(0, import_vue40.watch)(
|
|
2742
|
+
() => (0, import_vue40.unref)(session),
|
|
2655
2743
|
(value) => {
|
|
2656
2744
|
generation++;
|
|
2657
2745
|
epoch++;
|
|
@@ -2665,7 +2753,7 @@ function useMppSession(session) {
|
|
|
2665
2753
|
},
|
|
2666
2754
|
{ flush: "sync" }
|
|
2667
2755
|
);
|
|
2668
|
-
(0,
|
|
2756
|
+
(0, import_vue40.onScopeDispose)(() => {
|
|
2669
2757
|
disposed = true;
|
|
2670
2758
|
generation++;
|
|
2671
2759
|
epoch++;
|
|
@@ -2762,14 +2850,14 @@ function useMppSession(session) {
|
|
|
2762
2850
|
|
|
2763
2851
|
// src/useSolanaSessionKey.ts
|
|
2764
2852
|
var import_connect_appkit_core26 = require("@naculus/connect-appkit-core");
|
|
2765
|
-
var
|
|
2853
|
+
var import_vue41 = require("vue");
|
|
2766
2854
|
function useSolanaSessionKey(deps) {
|
|
2767
2855
|
const guard = useActionGuard();
|
|
2768
|
-
const keys = (0,
|
|
2856
|
+
const keys = (0, import_vue41.shallowRef)([]);
|
|
2769
2857
|
let flow = null;
|
|
2770
2858
|
let generation = 0;
|
|
2771
2859
|
let disposed = false;
|
|
2772
|
-
(0,
|
|
2860
|
+
(0, import_vue41.onScopeDispose)(() => {
|
|
2773
2861
|
disposed = true;
|
|
2774
2862
|
});
|
|
2775
2863
|
const refresh = async () => {
|
|
@@ -2777,8 +2865,8 @@ function useSolanaSessionKey(deps) {
|
|
|
2777
2865
|
const next = flow ? await flow.list() : [];
|
|
2778
2866
|
if (!disposed && own === generation) keys.value = next;
|
|
2779
2867
|
};
|
|
2780
|
-
(0,
|
|
2781
|
-
() => (0,
|
|
2868
|
+
(0, import_vue41.watch)(
|
|
2869
|
+
() => (0, import_vue41.unref)(deps),
|
|
2782
2870
|
(next) => {
|
|
2783
2871
|
flow = next ? (0, import_connect_appkit_core26.createSolanaSessionKeyFlow)(next) : null;
|
|
2784
2872
|
guard.invalidate();
|
|
@@ -2812,16 +2900,16 @@ function useSolanaSessionKey(deps) {
|
|
|
2812
2900
|
|
|
2813
2901
|
// src/name-lookup.ts
|
|
2814
2902
|
var import_connect_appkit_core27 = require("@naculus/connect-appkit-core");
|
|
2815
|
-
var
|
|
2903
|
+
var import_vue42 = require("vue");
|
|
2816
2904
|
function useNameLookup(options) {
|
|
2817
2905
|
const guard = useActionGuard();
|
|
2818
|
-
const data = (0,
|
|
2819
|
-
const loading = (0,
|
|
2906
|
+
const data = (0, import_vue42.shallowRef)(null);
|
|
2907
|
+
const loading = (0, import_vue42.shallowRef)(false);
|
|
2820
2908
|
const run = () => {
|
|
2821
|
-
const input = (0,
|
|
2822
|
-
const skip = (0,
|
|
2823
|
-
const scope = (0,
|
|
2824
|
-
const config = (0,
|
|
2909
|
+
const input = (0, import_vue42.toValue)(options.input).trim();
|
|
2910
|
+
const skip = (0, import_vue42.toValue)(options.skip) ?? false;
|
|
2911
|
+
const scope = (0, import_vue42.toValue)(options.scope);
|
|
2912
|
+
const config = (0, import_vue42.toValue)(options.resolverConfig);
|
|
2825
2913
|
if (!input || skip) {
|
|
2826
2914
|
guard.reset();
|
|
2827
2915
|
data.value = null;
|
|
@@ -2856,19 +2944,19 @@ function useNameLookup(options) {
|
|
|
2856
2944
|
).catch(() => {
|
|
2857
2945
|
});
|
|
2858
2946
|
};
|
|
2859
|
-
(0,
|
|
2947
|
+
(0, import_vue42.watch)(
|
|
2860
2948
|
() => [
|
|
2861
|
-
(0,
|
|
2862
|
-
(0,
|
|
2863
|
-
(0,
|
|
2864
|
-
(0,
|
|
2949
|
+
(0, import_vue42.toValue)(options.input),
|
|
2950
|
+
(0, import_vue42.toValue)(options.skip),
|
|
2951
|
+
(0, import_vue42.toValue)(options.scope),
|
|
2952
|
+
(0, import_vue42.toValue)(options.resolverConfig)
|
|
2865
2953
|
],
|
|
2866
2954
|
run,
|
|
2867
2955
|
{ immediate: true, flush: "sync", deep: true }
|
|
2868
2956
|
);
|
|
2869
2957
|
return {
|
|
2870
2958
|
data,
|
|
2871
|
-
isLoading: (0,
|
|
2959
|
+
isLoading: (0, import_vue42.computed)(() => loading.value),
|
|
2872
2960
|
error: guard.error,
|
|
2873
2961
|
refetch: run
|
|
2874
2962
|
};
|
|
@@ -2896,21 +2984,21 @@ function useLookupAddress(address, options) {
|
|
|
2896
2984
|
}
|
|
2897
2985
|
|
|
2898
2986
|
// src/useSolanaAccount.ts
|
|
2899
|
-
var
|
|
2987
|
+
var import_vue43 = require("vue");
|
|
2900
2988
|
function useSolanaAccount(accounts, connected) {
|
|
2901
|
-
const isConnected = (0,
|
|
2902
|
-
const caip10 = (0,
|
|
2903
|
-
() => isConnected.value ? ((0,
|
|
2989
|
+
const isConnected = (0, import_vue43.computed)(() => (0, import_vue43.toValue)(connected));
|
|
2990
|
+
const caip10 = (0, import_vue43.computed)(
|
|
2991
|
+
() => isConnected.value ? ((0, import_vue43.toValue)(accounts) ?? []).find(
|
|
2904
2992
|
(account) => account.startsWith("solana:")
|
|
2905
2993
|
) ?? null : null
|
|
2906
2994
|
);
|
|
2907
|
-
const parts = (0,
|
|
2995
|
+
const parts = (0, import_vue43.computed)(() => caip10.value?.split(":") ?? []);
|
|
2908
2996
|
return {
|
|
2909
|
-
address: (0,
|
|
2997
|
+
address: (0, import_vue43.computed)(
|
|
2910
2998
|
() => parts.value.length >= 3 ? parts.value.at(-1) ?? null : null
|
|
2911
2999
|
),
|
|
2912
3000
|
caip10,
|
|
2913
|
-
chainId: (0,
|
|
3001
|
+
chainId: (0, import_vue43.computed)(
|
|
2914
3002
|
() => parts.value.length >= 3 ? parts.value.slice(0, -1).join(":") : null
|
|
2915
3003
|
),
|
|
2916
3004
|
isConnected
|
|
@@ -2919,34 +3007,34 @@ function useSolanaAccount(accounts, connected) {
|
|
|
2919
3007
|
|
|
2920
3008
|
// src/useChain.ts
|
|
2921
3009
|
var import_connect_appkit_core28 = require("@naculus/connect-appkit-core");
|
|
2922
|
-
var
|
|
3010
|
+
var import_vue44 = require("vue");
|
|
2923
3011
|
function useChain(chains, chainId) {
|
|
2924
|
-
const list = (0,
|
|
2925
|
-
const id = (0,
|
|
2926
|
-
const currentChain = (0,
|
|
3012
|
+
const list = (0, import_vue44.computed)(() => (0, import_vue44.toValue)(chains) ?? []);
|
|
3013
|
+
const id = (0, import_vue44.computed)(() => (0, import_vue44.toValue)(chainId) ?? null);
|
|
3014
|
+
const currentChain = (0, import_vue44.computed)(() => (0, import_connect_appkit_core28.resolveChain)(list.value, id.value));
|
|
2927
3015
|
return {
|
|
2928
3016
|
currentChain,
|
|
2929
|
-
chainInfo: (0,
|
|
2930
|
-
availableChains: (0,
|
|
2931
|
-
currentChainNumber: (0,
|
|
3017
|
+
chainInfo: (0, import_vue44.computed)(() => (0, import_connect_appkit_core28.describeChain)(list.value, id.value)),
|
|
3018
|
+
availableChains: (0, import_vue44.computed)(() => (0, import_connect_appkit_core28.chainsForNamespace)(list.value, id.value)),
|
|
3019
|
+
currentChainNumber: (0, import_vue44.computed)(
|
|
2932
3020
|
() => currentChain.value ? (0, import_connect_appkit_core28.chainNumber)(currentChain.value) : null
|
|
2933
3021
|
),
|
|
2934
|
-
namespace: (0,
|
|
3022
|
+
namespace: (0, import_vue44.computed)(
|
|
2935
3023
|
() => currentChain.value ? (0, import_connect_appkit_core28.chainNamespace)(currentChain.value) : null
|
|
2936
3024
|
)
|
|
2937
3025
|
};
|
|
2938
3026
|
}
|
|
2939
3027
|
|
|
2940
3028
|
// src/usePassphraseGate.ts
|
|
2941
|
-
var
|
|
3029
|
+
var import_vue45 = require("vue");
|
|
2942
3030
|
function usePassphraseGate(gate) {
|
|
2943
|
-
const request = (0,
|
|
3031
|
+
const request = (0, import_vue45.shallowRef)(gate.getSnapshot());
|
|
2944
3032
|
const unsubscribe = gate.subscribe(() => {
|
|
2945
3033
|
request.value = gate.getSnapshot();
|
|
2946
3034
|
});
|
|
2947
|
-
(0,
|
|
3035
|
+
(0, import_vue45.onScopeDispose)(unsubscribe);
|
|
2948
3036
|
return {
|
|
2949
|
-
request: (0,
|
|
3037
|
+
request: (0, import_vue45.readonly)(request),
|
|
2950
3038
|
submit: (passphrase) => gate.submit(passphrase),
|
|
2951
3039
|
cancel: (reason) => gate.cancel(reason),
|
|
2952
3040
|
forget: (reason) => gate.forget(reason)
|
|
@@ -2954,15 +3042,15 @@ function usePassphraseGate(gate) {
|
|
|
2954
3042
|
}
|
|
2955
3043
|
|
|
2956
3044
|
// src/useSolanaBalance.ts
|
|
2957
|
-
var
|
|
2958
|
-
var
|
|
3045
|
+
var import_connect_core18 = require("@naculus/connect-core");
|
|
3046
|
+
var import_vue46 = require("vue");
|
|
2959
3047
|
function useSolanaBalance(address, rpcUrl) {
|
|
2960
3048
|
const guard = useActionGuard();
|
|
2961
|
-
const balance = (0,
|
|
2962
|
-
const isFetching = (0,
|
|
3049
|
+
const balance = (0, import_vue46.shallowRef)(null);
|
|
3050
|
+
const isFetching = (0, import_vue46.ref)(false);
|
|
2963
3051
|
const refetch = async () => {
|
|
2964
|
-
const addr = (0,
|
|
2965
|
-
const url = (0,
|
|
3052
|
+
const addr = (0, import_vue46.toValue)(address);
|
|
3053
|
+
const url = (0, import_vue46.toValue)(rpcUrl);
|
|
2966
3054
|
if (!addr || !url) {
|
|
2967
3055
|
guard.invalidate();
|
|
2968
3056
|
isFetching.value = false;
|
|
@@ -2973,7 +3061,7 @@ function useSolanaBalance(address, rpcUrl) {
|
|
|
2973
3061
|
await guard.run(
|
|
2974
3062
|
async (commit) => {
|
|
2975
3063
|
try {
|
|
2976
|
-
const next = await (0,
|
|
3064
|
+
const next = await (0, import_connect_core18.getSolanaBalance)(url, addr);
|
|
2977
3065
|
commit(() => {
|
|
2978
3066
|
balance.value = next;
|
|
2979
3067
|
});
|
|
@@ -2994,22 +3082,22 @@ function useSolanaBalance(address, rpcUrl) {
|
|
|
2994
3082
|
).catch(() => {
|
|
2995
3083
|
});
|
|
2996
3084
|
};
|
|
2997
|
-
(0,
|
|
2998
|
-
(0,
|
|
2999
|
-
(0,
|
|
3085
|
+
(0, import_vue46.watchEffect)(() => {
|
|
3086
|
+
(0, import_vue46.toValue)(address);
|
|
3087
|
+
(0, import_vue46.toValue)(rpcUrl);
|
|
3000
3088
|
void refetch();
|
|
3001
3089
|
});
|
|
3002
3090
|
return { balance, isFetching, error: guard.error, refetch };
|
|
3003
3091
|
}
|
|
3004
3092
|
|
|
3005
3093
|
// src/useLastTx.ts
|
|
3006
|
-
var
|
|
3094
|
+
var import_vue47 = require("vue");
|
|
3007
3095
|
function useLastTx(monitor) {
|
|
3008
|
-
const lastTx = (0,
|
|
3009
|
-
const lastConfirmedTx = (0,
|
|
3010
|
-
const lastFailedTx = (0,
|
|
3011
|
-
(0,
|
|
3012
|
-
() => (0,
|
|
3096
|
+
const lastTx = (0, import_vue47.shallowRef)(null);
|
|
3097
|
+
const lastConfirmedTx = (0, import_vue47.shallowRef)(null);
|
|
3098
|
+
const lastFailedTx = (0, import_vue47.shallowRef)(null);
|
|
3099
|
+
(0, import_vue47.watch)(
|
|
3100
|
+
() => (0, import_vue47.toValue)(monitor),
|
|
3013
3101
|
(activeMonitor, _previous, onCleanup) => {
|
|
3014
3102
|
if (!activeMonitor) return;
|
|
3015
3103
|
const recordLatest = (entry) => {
|
|
@@ -3047,13 +3135,13 @@ function useLastTx(monitor) {
|
|
|
3047
3135
|
}
|
|
3048
3136
|
|
|
3049
3137
|
// src/useTxHistory.ts
|
|
3050
|
-
var
|
|
3138
|
+
var import_vue48 = require("vue");
|
|
3051
3139
|
function useTxHistory(address, chainId, monitor) {
|
|
3052
3140
|
const guard = useActionGuard();
|
|
3053
|
-
const entries = (0,
|
|
3054
|
-
const isLoading = (0,
|
|
3141
|
+
const entries = (0, import_vue48.shallowRef)([]);
|
|
3142
|
+
const isLoading = (0, import_vue48.shallowRef)(false);
|
|
3055
3143
|
const refresh = async () => {
|
|
3056
|
-
const activeMonitor = (0,
|
|
3144
|
+
const activeMonitor = (0, import_vue48.toValue)(monitor);
|
|
3057
3145
|
if (!activeMonitor) {
|
|
3058
3146
|
guard.reset();
|
|
3059
3147
|
entries.value = [];
|
|
@@ -3064,8 +3152,8 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
3064
3152
|
await guard.run(
|
|
3065
3153
|
async (commit) => {
|
|
3066
3154
|
const result = await activeMonitor.getTxHistory(
|
|
3067
|
-
(0,
|
|
3068
|
-
(0,
|
|
3155
|
+
(0, import_vue48.toValue)(address) ?? void 0,
|
|
3156
|
+
(0, import_vue48.toValue)(chainId) ?? void 0
|
|
3069
3157
|
);
|
|
3070
3158
|
commit(() => {
|
|
3071
3159
|
entries.value = result;
|
|
@@ -3081,8 +3169,8 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
3081
3169
|
).catch(() => {
|
|
3082
3170
|
});
|
|
3083
3171
|
};
|
|
3084
|
-
(0,
|
|
3085
|
-
[() => (0,
|
|
3172
|
+
(0, import_vue48.watch)(
|
|
3173
|
+
[() => (0, import_vue48.toValue)(monitor), () => (0, import_vue48.toValue)(address), () => (0, import_vue48.toValue)(chainId)],
|
|
3086
3174
|
([activeMonitor], _previous, onCleanup) => {
|
|
3087
3175
|
if (!activeMonitor) {
|
|
3088
3176
|
void refresh();
|
|
@@ -3102,7 +3190,7 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
3102
3190
|
isLoading,
|
|
3103
3191
|
error: guard.error,
|
|
3104
3192
|
refresh,
|
|
3105
|
-
summary: (0,
|
|
3193
|
+
summary: (0, import_vue48.computed)(() => ({
|
|
3106
3194
|
pending: entries.value.filter((item) => item.status === "pending").length,
|
|
3107
3195
|
confirmed: entries.value.filter((item) => item.status === "confirmed").length,
|
|
3108
3196
|
failed: entries.value.filter((item) => item.status === "failed").length
|
|
@@ -3111,25 +3199,25 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
3111
3199
|
}
|
|
3112
3200
|
|
|
3113
3201
|
// src/useTxMonitor.ts
|
|
3114
|
-
var
|
|
3202
|
+
var import_vue49 = require("vue");
|
|
3115
3203
|
function useTxMonitor(hash, chainId, monitor) {
|
|
3116
|
-
const entry = (0,
|
|
3117
|
-
const isLoading = (0,
|
|
3118
|
-
const isWatching = (0,
|
|
3204
|
+
const entry = (0, import_vue49.shallowRef)(null);
|
|
3205
|
+
const isLoading = (0, import_vue49.shallowRef)(false);
|
|
3206
|
+
const isWatching = (0, import_vue49.shallowRef)(false);
|
|
3119
3207
|
const guard = useActionGuard();
|
|
3120
3208
|
const error = guard.error;
|
|
3121
3209
|
let generation = 0;
|
|
3122
3210
|
let refreshed = [];
|
|
3123
3211
|
const currentInputs = () => [
|
|
3124
|
-
(0,
|
|
3125
|
-
(0,
|
|
3126
|
-
(0,
|
|
3212
|
+
(0, import_vue49.toValue)(monitor),
|
|
3213
|
+
(0, import_vue49.toValue)(hash),
|
|
3214
|
+
(0, import_vue49.toValue)(chainId)
|
|
3127
3215
|
];
|
|
3128
3216
|
const sameInputs = (a, b) => a.every((value, i) => Object.is(value, b[i]));
|
|
3129
3217
|
const refresh = async () => {
|
|
3130
|
-
const activeMonitor = (0,
|
|
3131
|
-
const activeHash = (0,
|
|
3132
|
-
const activeChainId = (0,
|
|
3218
|
+
const activeMonitor = (0, import_vue49.toValue)(monitor);
|
|
3219
|
+
const activeHash = (0, import_vue49.toValue)(hash);
|
|
3220
|
+
const activeChainId = (0, import_vue49.toValue)(chainId);
|
|
3133
3221
|
if (!activeMonitor || !activeHash) return;
|
|
3134
3222
|
const started = [activeMonitor, activeHash, activeChainId];
|
|
3135
3223
|
refreshed = started;
|
|
@@ -3165,15 +3253,15 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
3165
3253
|
});
|
|
3166
3254
|
};
|
|
3167
3255
|
const stopWatching = () => {
|
|
3168
|
-
const activeMonitor = (0,
|
|
3169
|
-
const activeHash = (0,
|
|
3170
|
-
const activeChainId = (0,
|
|
3256
|
+
const activeMonitor = (0, import_vue49.toValue)(monitor);
|
|
3257
|
+
const activeHash = (0, import_vue49.toValue)(hash);
|
|
3258
|
+
const activeChainId = (0, import_vue49.toValue)(chainId);
|
|
3171
3259
|
if (!activeMonitor || !activeHash) return;
|
|
3172
3260
|
activeMonitor.stopWatching(activeHash, activeChainId ?? void 0);
|
|
3173
3261
|
isWatching.value = false;
|
|
3174
3262
|
};
|
|
3175
|
-
(0,
|
|
3176
|
-
[() => (0,
|
|
3263
|
+
(0, import_vue49.watch)(
|
|
3264
|
+
[() => (0, import_vue49.toValue)(monitor), () => (0, import_vue49.toValue)(hash), () => (0, import_vue49.toValue)(chainId)],
|
|
3177
3265
|
([activeMonitor, activeHash, activeChainId], _previous, onCleanup) => {
|
|
3178
3266
|
const mine = ++generation;
|
|
3179
3267
|
if (!sameInputs([activeMonitor, activeHash, activeChainId], refreshed)) {
|
|
@@ -3215,7 +3303,7 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
3215
3303
|
);
|
|
3216
3304
|
return {
|
|
3217
3305
|
entry,
|
|
3218
|
-
status: (0,
|
|
3306
|
+
status: (0, import_vue49.computed)(() => entry.value?.status ?? "idle"),
|
|
3219
3307
|
isLoading,
|
|
3220
3308
|
isWatching,
|
|
3221
3309
|
error,
|
|
@@ -3226,16 +3314,16 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
3226
3314
|
|
|
3227
3315
|
// src/useCapabilities.ts
|
|
3228
3316
|
var import_connect_appkit_core29 = require("@naculus/connect-appkit-core");
|
|
3229
|
-
var
|
|
3317
|
+
var import_vue50 = require("vue");
|
|
3230
3318
|
function useCapabilities(client, session, chainId) {
|
|
3231
3319
|
const guard = useActionGuard();
|
|
3232
|
-
const capabilities = (0,
|
|
3320
|
+
const capabilities = (0, import_vue50.shallowRef)(
|
|
3233
3321
|
null
|
|
3234
3322
|
);
|
|
3235
|
-
const isFetching = (0,
|
|
3323
|
+
const isFetching = (0, import_vue50.shallowRef)(false);
|
|
3236
3324
|
const refetch = async () => {
|
|
3237
|
-
const activeClient = (0,
|
|
3238
|
-
const activeSession = (0,
|
|
3325
|
+
const activeClient = (0, import_vue50.toValue)(client);
|
|
3326
|
+
const activeSession = (0, import_vue50.toValue)(session);
|
|
3239
3327
|
if (!activeClient?.getCapabilities || !activeSession) {
|
|
3240
3328
|
guard.reset();
|
|
3241
3329
|
capabilities.value = null;
|
|
@@ -3267,18 +3355,18 @@ function useCapabilities(client, session, chainId) {
|
|
|
3267
3355
|
).catch(() => {
|
|
3268
3356
|
});
|
|
3269
3357
|
};
|
|
3270
|
-
(0,
|
|
3271
|
-
void (0,
|
|
3272
|
-
void (0,
|
|
3358
|
+
(0, import_vue50.watchEffect)(() => {
|
|
3359
|
+
void (0, import_vue50.toValue)(client);
|
|
3360
|
+
void (0, import_vue50.toValue)(session);
|
|
3273
3361
|
void refetch();
|
|
3274
3362
|
});
|
|
3275
3363
|
return {
|
|
3276
3364
|
capabilities,
|
|
3277
|
-
current: (0,
|
|
3278
|
-
() => (0, import_connect_appkit_core29.selectChainCapabilities)(capabilities.value, (0,
|
|
3365
|
+
current: (0, import_vue50.computed)(
|
|
3366
|
+
() => (0, import_connect_appkit_core29.selectChainCapabilities)(capabilities.value, (0, import_vue50.toValue)(chainId))
|
|
3279
3367
|
),
|
|
3280
|
-
atomic: (0,
|
|
3281
|
-
() => (0, import_connect_appkit_core29.atomicSupportFor)(capabilities.value, (0,
|
|
3368
|
+
atomic: (0, import_vue50.computed)(
|
|
3369
|
+
() => (0, import_connect_appkit_core29.atomicSupportFor)(capabilities.value, (0, import_vue50.toValue)(chainId))
|
|
3282
3370
|
),
|
|
3283
3371
|
isFetching,
|
|
3284
3372
|
error: guard.error,
|
|
@@ -3288,17 +3376,17 @@ function useCapabilities(client, session, chainId) {
|
|
|
3288
3376
|
|
|
3289
3377
|
// src/useSolanaRoles.ts
|
|
3290
3378
|
var import_connect_appkit_core30 = require("@naculus/connect-appkit-core");
|
|
3291
|
-
var
|
|
3379
|
+
var import_vue51 = require("vue");
|
|
3292
3380
|
function useSolanaRoles(connector, session) {
|
|
3293
|
-
const state = (0,
|
|
3294
|
-
() => (0, import_connect_appkit_core30.readSolanaRoles)((0,
|
|
3381
|
+
const state = (0, import_vue51.computed)(
|
|
3382
|
+
() => (0, import_connect_appkit_core30.readSolanaRoles)((0, import_vue51.toValue)(connector), (0, import_vue51.toValue)(session))
|
|
3295
3383
|
);
|
|
3296
3384
|
return {
|
|
3297
|
-
roles: (0,
|
|
3298
|
-
absence: (0,
|
|
3299
|
-
identity: (0,
|
|
3300
|
-
signer: (0,
|
|
3301
|
-
payer: (0,
|
|
3385
|
+
roles: (0, import_vue51.computed)(() => state.value.roles),
|
|
3386
|
+
absence: (0, import_vue51.computed)(() => state.value.absence),
|
|
3387
|
+
identity: (0, import_vue51.computed)(() => state.value.roles?.identity ?? null),
|
|
3388
|
+
signer: (0, import_vue51.computed)(() => state.value.roles?.signer ?? null),
|
|
3389
|
+
payer: (0, import_vue51.computed)(() => state.value.roles?.payer ?? null)
|
|
3302
3390
|
};
|
|
3303
3391
|
}
|
|
3304
3392
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -3333,6 +3421,7 @@ function useSolanaRoles(connector, session) {
|
|
|
3333
3421
|
AppkitTooltip,
|
|
3334
3422
|
useAccount,
|
|
3335
3423
|
useAccounts,
|
|
3424
|
+
useAuthorizations,
|
|
3336
3425
|
useBalance,
|
|
3337
3426
|
useCapabilities,
|
|
3338
3427
|
useChain,
|