@naculus/connect-appkit-vue 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -4
- package/dist/index.cjs +1828 -308
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +637 -4
- package/dist/index.d.ts +637 -4
- package/dist/index.js +1830 -282
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -55,25 +65,50 @@ __export(index_exports, {
|
|
|
55
65
|
useChain: () => useChain,
|
|
56
66
|
useCompareCosts: () => useCompareCosts,
|
|
57
67
|
useConnect: () => useConnect,
|
|
68
|
+
useCreateSessionKey: () => useCreateSessionKey,
|
|
69
|
+
useDelegate: () => useDelegate,
|
|
58
70
|
useDelegation: () => useDelegation,
|
|
71
|
+
useDelegationPolicy: () => useDelegationPolicy,
|
|
59
72
|
useDisconnect: () => useDisconnect,
|
|
73
|
+
useERC20Approve: () => useERC20Approve,
|
|
74
|
+
useERC20Transfer: () => useERC20Transfer,
|
|
75
|
+
useERC20TransferSimulation: () => useERC20TransferSimulation,
|
|
76
|
+
useEmbeddedWallet: () => useEmbeddedWallet,
|
|
77
|
+
useExecuteCalls: () => useExecuteCalls,
|
|
60
78
|
useExecuteRoute: () => useExecuteRoute,
|
|
61
79
|
useLastTx: () => useLastTx,
|
|
62
80
|
useLookupAddress: () => useLookupAddress,
|
|
63
81
|
useNotification: () => useNotification,
|
|
64
82
|
usePassphraseGate: () => usePassphraseGate,
|
|
65
83
|
useResolveName: () => useResolveName,
|
|
84
|
+
useRevokeSession: () => useRevokeSession,
|
|
66
85
|
useRouteQuote: () => useRouteQuote,
|
|
86
|
+
useSIWxLogin: () => useSIWxLogin,
|
|
87
|
+
useSIWxSession: () => useSIWxSession,
|
|
88
|
+
useSendCalls: () => useSendCalls,
|
|
89
|
+
useSendTransaction: () => useSendTransaction,
|
|
90
|
+
useSendUserOperation: () => useSendUserOperation,
|
|
91
|
+
useSendWithSession: () => useSendWithSession,
|
|
67
92
|
useSession: () => useSession,
|
|
93
|
+
useSessionKeys: () => useSessionKeys,
|
|
94
|
+
useSignInWithEthereum: () => useSignInWithEthereum,
|
|
95
|
+
useSignInWithX: () => useSignInWithX,
|
|
96
|
+
useSignMessage: () => useSignMessage,
|
|
97
|
+
useSimulateTransfer: () => useSimulateTransfer,
|
|
98
|
+
useSiwxAuthSession: () => useSiwxAuthSession,
|
|
99
|
+
useSmartAccount: () => useSmartAccount,
|
|
68
100
|
useSolanaAccount: () => useSolanaAccount,
|
|
69
101
|
useSolanaBalance: () => useSolanaBalance,
|
|
70
102
|
useSolanaRoles: () => useSolanaRoles,
|
|
103
|
+
useSolanaTransaction: () => useSolanaTransaction,
|
|
71
104
|
useSwitchChain: () => useSwitchChain,
|
|
72
105
|
useTokenBalance: () => useTokenBalance,
|
|
73
106
|
useTokenList: () => useTokenList,
|
|
74
107
|
useTokenSearch: () => useTokenSearch,
|
|
108
|
+
useTransactionSimulation: () => useTransactionSimulation,
|
|
75
109
|
useTxHistory: () => useTxHistory,
|
|
76
110
|
useTxMonitor: () => useTxMonitor,
|
|
111
|
+
useUserOpStatus: () => useUserOpStatus,
|
|
77
112
|
useValidateDestination: () => useValidateDestination
|
|
78
113
|
});
|
|
79
114
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -355,27 +390,473 @@ function useNotification(options = {}) {
|
|
|
355
390
|
};
|
|
356
391
|
}
|
|
357
392
|
|
|
358
|
-
// src/
|
|
393
|
+
// src/useSimulateTransfer.ts
|
|
394
|
+
var import_connect_appkit_core2 = require("@naculus/connect-appkit-core");
|
|
395
|
+
var import_connect_core3 = require("@naculus/connect-core");
|
|
359
396
|
var import_vue3 = require("vue");
|
|
397
|
+
function useSimulateTransfer(options = {}) {
|
|
398
|
+
const result = (0, import_vue3.shallowRef)(null);
|
|
399
|
+
const loading = (0, import_vue3.shallowRef)(false);
|
|
400
|
+
const error = (0, import_vue3.shallowRef)(null);
|
|
401
|
+
let manager;
|
|
402
|
+
let generation = 0;
|
|
403
|
+
let disposed = false;
|
|
404
|
+
const simulate = async (tokenAddress, from, to, amount, callOptions) => {
|
|
405
|
+
const own = ++generation;
|
|
406
|
+
loading.value = true;
|
|
407
|
+
error.value = null;
|
|
408
|
+
try {
|
|
409
|
+
const fallbackRpcUrl = (0, import_vue3.unref)(options.rpcUrl);
|
|
410
|
+
const endpoint = (0, import_connect_appkit_core2.resolveSimulationEndpoint)(
|
|
411
|
+
callOptions?.chainId,
|
|
412
|
+
(0, import_vue3.unref)(options.chainId),
|
|
413
|
+
callOptions?.rpcUrl,
|
|
414
|
+
fallbackRpcUrl
|
|
415
|
+
);
|
|
416
|
+
manager ??= new import_connect_core3.SimulationManager({
|
|
417
|
+
enabled: true,
|
|
418
|
+
rpcUrl: fallbackRpcUrl,
|
|
419
|
+
autoSimulate: false
|
|
420
|
+
});
|
|
421
|
+
const value = await manager.simulateERC20Transfer(
|
|
422
|
+
tokenAddress,
|
|
423
|
+
from,
|
|
424
|
+
to,
|
|
425
|
+
amount,
|
|
426
|
+
endpoint.chainId,
|
|
427
|
+
callOptions?.decimals,
|
|
428
|
+
endpoint.rpcUrl
|
|
429
|
+
);
|
|
430
|
+
if (!disposed && own === generation) result.value = value;
|
|
431
|
+
return value;
|
|
432
|
+
} catch (cause) {
|
|
433
|
+
const normalized = cause instanceof Error ? cause : new Error(String(cause));
|
|
434
|
+
if (!disposed && own === generation) error.value = normalized;
|
|
435
|
+
throw normalized;
|
|
436
|
+
} finally {
|
|
437
|
+
if (!disposed && own === generation) loading.value = false;
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
const reset = () => {
|
|
441
|
+
generation++;
|
|
442
|
+
result.value = null;
|
|
443
|
+
error.value = null;
|
|
444
|
+
loading.value = false;
|
|
445
|
+
};
|
|
446
|
+
(0, import_vue3.onScopeDispose)(() => {
|
|
447
|
+
disposed = true;
|
|
448
|
+
generation++;
|
|
449
|
+
});
|
|
450
|
+
return { result, loading, error, simulate, reset };
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// src/useTransactionSimulation.ts
|
|
454
|
+
var import_connect_appkit_core3 = require("@naculus/connect-appkit-core");
|
|
455
|
+
var import_vue4 = require("vue");
|
|
456
|
+
function useTransactionSimulation(tx, options = {}) {
|
|
457
|
+
const result = (0, import_vue4.shallowRef)(void 0);
|
|
458
|
+
const isSimulating = (0, import_vue4.shallowRef)(false);
|
|
459
|
+
const error = (0, import_vue4.shallowRef)(null);
|
|
460
|
+
let timer;
|
|
461
|
+
let generation = 0;
|
|
462
|
+
let disposed = false;
|
|
463
|
+
const simulate = async () => {
|
|
464
|
+
const own = ++generation;
|
|
465
|
+
const transaction = (0, import_vue4.toValue)(tx);
|
|
466
|
+
if (transaction) {
|
|
467
|
+
isSimulating.value = true;
|
|
468
|
+
error.value = null;
|
|
469
|
+
}
|
|
470
|
+
try {
|
|
471
|
+
const value = await (0, import_connect_appkit_core3.simulateTransactionPreview)(transaction, {
|
|
472
|
+
chainId: (0, import_vue4.unref)(options.chainId),
|
|
473
|
+
currentChain: (0, import_vue4.unref)(options.currentChain),
|
|
474
|
+
publicClient: (0, import_vue4.unref)(options.publicClient),
|
|
475
|
+
evmAccount: (0, import_vue4.unref)(options.evmAccount)
|
|
476
|
+
});
|
|
477
|
+
if (!disposed && own === generation) result.value = value;
|
|
478
|
+
return value;
|
|
479
|
+
} catch (cause) {
|
|
480
|
+
const normalized = cause instanceof Error ? cause : new Error("Simulation failed");
|
|
481
|
+
if (!disposed && own === generation) error.value = normalized;
|
|
482
|
+
throw normalized;
|
|
483
|
+
} finally {
|
|
484
|
+
if (transaction && !disposed && own === generation)
|
|
485
|
+
isSimulating.value = false;
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
(0, import_vue4.watch)(
|
|
489
|
+
[
|
|
490
|
+
() => (0, import_vue4.toValue)(tx),
|
|
491
|
+
() => (0, import_vue4.unref)(options.chainId),
|
|
492
|
+
() => (0, import_vue4.unref)(options.currentChain),
|
|
493
|
+
() => (0, import_vue4.unref)(options.publicClient),
|
|
494
|
+
() => (0, import_vue4.unref)(options.evmAccount)
|
|
495
|
+
],
|
|
496
|
+
([transaction]) => {
|
|
497
|
+
generation++;
|
|
498
|
+
if (timer) clearTimeout(timer);
|
|
499
|
+
if (!transaction) return;
|
|
500
|
+
timer = setTimeout(() => {
|
|
501
|
+
timer = void 0;
|
|
502
|
+
void simulate().catch(() => {
|
|
503
|
+
});
|
|
504
|
+
}, 300);
|
|
505
|
+
},
|
|
506
|
+
{ immediate: true }
|
|
507
|
+
);
|
|
508
|
+
const reset = () => {
|
|
509
|
+
generation++;
|
|
510
|
+
result.value = void 0;
|
|
511
|
+
error.value = null;
|
|
512
|
+
isSimulating.value = false;
|
|
513
|
+
};
|
|
514
|
+
(0, import_vue4.onScopeDispose)(() => {
|
|
515
|
+
disposed = true;
|
|
516
|
+
generation++;
|
|
517
|
+
if (timer) clearTimeout(timer);
|
|
518
|
+
});
|
|
519
|
+
return { result, isSimulating, error, simulate, reset };
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// src/useERC20Transfer.ts
|
|
523
|
+
var import_connect_appkit_core5 = require("@naculus/connect-appkit-core");
|
|
524
|
+
var import_connect_core5 = require("@naculus/connect-core");
|
|
525
|
+
var import_vue5 = require("vue");
|
|
526
|
+
|
|
527
|
+
// src/erc20.ts
|
|
528
|
+
var import_connect_appkit_core4 = require("@naculus/connect-appkit-core");
|
|
529
|
+
var import_connect_core4 = require("@naculus/connect-core");
|
|
530
|
+
function assertErc20Context(token, chainId, account, connected) {
|
|
531
|
+
if (!connected || !account) {
|
|
532
|
+
throw new import_connect_core4.WalletError("wallet_unavailable", "No connected account");
|
|
533
|
+
}
|
|
534
|
+
const mismatch = (0, import_connect_appkit_core4.tokenChainMismatch)(token, chainId);
|
|
535
|
+
if (mismatch) throw mismatch;
|
|
536
|
+
const bare = (0, import_connect_appkit_core4.bareEvmAddress)(account);
|
|
537
|
+
if (!bare) {
|
|
538
|
+
throw new import_connect_core4.WalletError("wallet_unavailable", "No valid EVM account");
|
|
539
|
+
}
|
|
540
|
+
return bare;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// src/useERC20Transfer.ts
|
|
544
|
+
function useERC20Transfer(options) {
|
|
545
|
+
const initialToken = (0, import_vue5.toValue)(options.token);
|
|
546
|
+
const decimals = (0, import_connect_appkit_core5.createDecimalsCache)(initialToken, initialToken.decimals);
|
|
547
|
+
const isSending = (0, import_vue5.shallowRef)(false);
|
|
548
|
+
const error = (0, import_vue5.shallowRef)(null);
|
|
549
|
+
let generation = 0;
|
|
550
|
+
let disposed = false;
|
|
551
|
+
(0, import_vue5.watch)(
|
|
552
|
+
[
|
|
553
|
+
() => (0, import_vue5.toValue)(options.token).address,
|
|
554
|
+
() => (0, import_vue5.toValue)(options.token).chainId,
|
|
555
|
+
() => (0, import_vue5.toValue)(options.token).decimals,
|
|
556
|
+
() => (0, import_vue5.toValue)(options.account),
|
|
557
|
+
() => (0, import_vue5.toValue)(options.chainId),
|
|
558
|
+
() => (0, import_vue5.toValue)(options.connected),
|
|
559
|
+
() => (0, import_vue5.toValue)(options.publicClient),
|
|
560
|
+
() => (0, import_vue5.unref)(options.sendTransaction)
|
|
561
|
+
],
|
|
562
|
+
() => {
|
|
563
|
+
generation++;
|
|
564
|
+
isSending.value = false;
|
|
565
|
+
error.value = null;
|
|
566
|
+
},
|
|
567
|
+
{ flush: "sync" }
|
|
568
|
+
);
|
|
569
|
+
const sendTransfer = async (to, amount) => {
|
|
570
|
+
const own = ++generation;
|
|
571
|
+
const token = (0, import_vue5.toValue)(options.token);
|
|
572
|
+
const reader = (0, import_vue5.toValue)(options.publicClient);
|
|
573
|
+
const stillCurrent = () => !disposed && own === generation;
|
|
574
|
+
error.value = null;
|
|
575
|
+
isSending.value = true;
|
|
576
|
+
try {
|
|
577
|
+
assertErc20Context(
|
|
578
|
+
token,
|
|
579
|
+
(0, import_vue5.toValue)(options.chainId),
|
|
580
|
+
(0, import_vue5.toValue)(options.account),
|
|
581
|
+
(0, import_vue5.toValue)(options.connected)
|
|
582
|
+
);
|
|
583
|
+
if (!reader) {
|
|
584
|
+
throw new import_connect_core5.WalletError(
|
|
585
|
+
"wallet_unavailable",
|
|
586
|
+
"No public client available"
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
let precision = (0, import_connect_appkit_core5.readDecimals)(decimals, token, token.decimals);
|
|
590
|
+
if (precision === void 0) {
|
|
591
|
+
precision = Number(
|
|
592
|
+
await reader.readContract({
|
|
593
|
+
address: token.address,
|
|
594
|
+
abi: import_connect_core5.ERC20_MIN_ABI,
|
|
595
|
+
functionName: "decimals"
|
|
596
|
+
})
|
|
597
|
+
);
|
|
598
|
+
if (!stillCurrent()) {
|
|
599
|
+
throw new import_connect_core5.WalletError(
|
|
600
|
+
"session_inactive",
|
|
601
|
+
"Wallet or token context changed. Retry the transfer."
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
(0, import_connect_appkit_core5.writeDecimals)(decimals, token, precision);
|
|
605
|
+
}
|
|
606
|
+
const data = (0, import_connect_appkit_core5.encodeErc20Transfer)(to, (0, import_connect_core5.parseUnits)(amount, precision));
|
|
607
|
+
return await (0, import_vue5.unref)(options.sendTransaction)({
|
|
608
|
+
to: token.address,
|
|
609
|
+
data,
|
|
610
|
+
value: "0"
|
|
611
|
+
});
|
|
612
|
+
} catch (cause) {
|
|
613
|
+
const normalized = cause instanceof Error ? cause : new Error("Transfer failed");
|
|
614
|
+
if (stillCurrent()) error.value = normalized;
|
|
615
|
+
throw normalized;
|
|
616
|
+
} finally {
|
|
617
|
+
if (stillCurrent()) isSending.value = false;
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
(0, import_vue5.onScopeDispose)(() => {
|
|
621
|
+
disposed = true;
|
|
622
|
+
generation++;
|
|
623
|
+
});
|
|
624
|
+
return { sendTransfer, isSending, error };
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// src/useERC20Approve.ts
|
|
628
|
+
var import_connect_appkit_core6 = require("@naculus/connect-appkit-core");
|
|
629
|
+
var import_connect_core6 = require("@naculus/connect-core");
|
|
630
|
+
var import_vue6 = require("vue");
|
|
631
|
+
var MAX_UINT256 = (1n << 256n) - 1n;
|
|
632
|
+
function useERC20Approve(options) {
|
|
633
|
+
const initialToken = (0, import_vue6.toValue)(options.token);
|
|
634
|
+
const decimals = (0, import_connect_appkit_core6.createDecimalsCache)(initialToken, initialToken.decimals);
|
|
635
|
+
const allowanceRaw = (0, import_vue6.shallowRef)(null);
|
|
636
|
+
const isApproving = (0, import_vue6.shallowRef)(false);
|
|
637
|
+
const isFetchingAllowance = (0, import_vue6.shallowRef)(false);
|
|
638
|
+
const error = (0, import_vue6.shallowRef)(null);
|
|
639
|
+
let generation = 0;
|
|
640
|
+
let allowanceGeneration = 0;
|
|
641
|
+
let disposed = false;
|
|
642
|
+
(0, import_vue6.watch)(
|
|
643
|
+
[
|
|
644
|
+
() => (0, import_vue6.toValue)(options.token).address,
|
|
645
|
+
() => (0, import_vue6.toValue)(options.token).chainId,
|
|
646
|
+
() => (0, import_vue6.toValue)(options.token).decimals,
|
|
647
|
+
() => (0, import_vue6.toValue)(options.spender),
|
|
648
|
+
() => (0, import_vue6.toValue)(options.account),
|
|
649
|
+
() => (0, import_vue6.toValue)(options.chainId),
|
|
650
|
+
() => (0, import_vue6.toValue)(options.connected),
|
|
651
|
+
() => (0, import_vue6.toValue)(options.publicClient),
|
|
652
|
+
() => (0, import_vue6.unref)(options.sendTransaction)
|
|
653
|
+
],
|
|
654
|
+
() => {
|
|
655
|
+
generation++;
|
|
656
|
+
allowanceGeneration++;
|
|
657
|
+
allowanceRaw.value = null;
|
|
658
|
+
isApproving.value = false;
|
|
659
|
+
isFetchingAllowance.value = false;
|
|
660
|
+
error.value = null;
|
|
661
|
+
},
|
|
662
|
+
{ flush: "sync" }
|
|
663
|
+
);
|
|
664
|
+
const context = () => {
|
|
665
|
+
const token = (0, import_vue6.toValue)(options.token);
|
|
666
|
+
const account = assertErc20Context(
|
|
667
|
+
token,
|
|
668
|
+
(0, import_vue6.toValue)(options.chainId),
|
|
669
|
+
(0, import_vue6.toValue)(options.account),
|
|
670
|
+
(0, import_vue6.toValue)(options.connected)
|
|
671
|
+
);
|
|
672
|
+
const reader = (0, import_vue6.toValue)(options.publicClient);
|
|
673
|
+
if (!reader)
|
|
674
|
+
throw new import_connect_core6.WalletError("wallet_unavailable", "No public client");
|
|
675
|
+
return { token, account, reader, spender: (0, import_vue6.toValue)(options.spender) };
|
|
676
|
+
};
|
|
677
|
+
const readPrecision = async () => {
|
|
678
|
+
const { token, reader } = context();
|
|
679
|
+
let precision = (0, import_connect_appkit_core6.readDecimals)(decimals, token, token.decimals);
|
|
680
|
+
if (precision === void 0) {
|
|
681
|
+
precision = Number(
|
|
682
|
+
await reader.readContract({
|
|
683
|
+
address: token.address,
|
|
684
|
+
abi: import_connect_core6.ERC20_MIN_ABI,
|
|
685
|
+
functionName: "decimals"
|
|
686
|
+
})
|
|
687
|
+
);
|
|
688
|
+
(0, import_connect_appkit_core6.writeDecimals)(decimals, token, precision);
|
|
689
|
+
}
|
|
690
|
+
return precision;
|
|
691
|
+
};
|
|
692
|
+
const refetchAllowance = async () => {
|
|
693
|
+
const own = ++allowanceGeneration;
|
|
694
|
+
allowanceRaw.value = null;
|
|
695
|
+
error.value = null;
|
|
696
|
+
isFetchingAllowance.value = true;
|
|
697
|
+
try {
|
|
698
|
+
const { token, account, reader, spender } = context();
|
|
699
|
+
const raw = BigInt(
|
|
700
|
+
await reader.readContract({
|
|
701
|
+
address: token.address,
|
|
702
|
+
abi: import_connect_core6.ERC20_MIN_ABI,
|
|
703
|
+
functionName: "allowance",
|
|
704
|
+
args: [account, spender]
|
|
705
|
+
})
|
|
706
|
+
);
|
|
707
|
+
if (disposed || own !== allowanceGeneration) return null;
|
|
708
|
+
allowanceRaw.value = raw;
|
|
709
|
+
return raw;
|
|
710
|
+
} catch (cause) {
|
|
711
|
+
if (!disposed && own === allowanceGeneration) {
|
|
712
|
+
error.value = cause instanceof Error ? cause : new Error("Failed to fetch allowance");
|
|
713
|
+
}
|
|
714
|
+
return null;
|
|
715
|
+
} finally {
|
|
716
|
+
if (!disposed && own === allowanceGeneration)
|
|
717
|
+
isFetchingAllowance.value = false;
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
const doApprove = async (rawAmount) => {
|
|
721
|
+
const own = ++generation;
|
|
722
|
+
error.value = null;
|
|
723
|
+
isApproving.value = true;
|
|
724
|
+
try {
|
|
725
|
+
const { token, spender } = context();
|
|
726
|
+
const hash = await (0, import_vue6.unref)(options.sendTransaction)({
|
|
727
|
+
to: token.address,
|
|
728
|
+
data: (0, import_connect_appkit_core6.encodeErc20Approve)(spender, rawAmount),
|
|
729
|
+
value: "0"
|
|
730
|
+
});
|
|
731
|
+
if (!disposed && own === generation) void refetchAllowance();
|
|
732
|
+
return hash;
|
|
733
|
+
} catch (cause) {
|
|
734
|
+
const normalized = cause instanceof Error ? cause : new Error("Approve failed");
|
|
735
|
+
if (!disposed && own === generation) error.value = normalized;
|
|
736
|
+
throw normalized;
|
|
737
|
+
} finally {
|
|
738
|
+
if (!disposed && own === generation) isApproving.value = false;
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
const approve = async (amount) => {
|
|
742
|
+
const contextGeneration = generation;
|
|
743
|
+
let rawAmount;
|
|
744
|
+
try {
|
|
745
|
+
const precision = await readPrecision();
|
|
746
|
+
if (contextGeneration !== generation || disposed) {
|
|
747
|
+
throw new import_connect_core6.WalletError(
|
|
748
|
+
"session_inactive",
|
|
749
|
+
"Wallet or token context changed. Retry the approval."
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
rawAmount = (0, import_connect_core6.parseUnits)(amount, precision);
|
|
753
|
+
} catch (cause) {
|
|
754
|
+
const normalized = cause instanceof Error ? cause : new Error("Approve failed");
|
|
755
|
+
if (!disposed && contextGeneration === generation)
|
|
756
|
+
error.value = normalized;
|
|
757
|
+
throw normalized;
|
|
758
|
+
}
|
|
759
|
+
return doApprove(rawAmount);
|
|
760
|
+
};
|
|
761
|
+
const approveMax = () => doApprove(MAX_UINT256);
|
|
762
|
+
const hasAllowance = async (required) => {
|
|
763
|
+
const raw = allowanceRaw.value ?? await refetchAllowance();
|
|
764
|
+
if (raw === null) return false;
|
|
765
|
+
return raw >= (0, import_connect_core6.parseUnits)(required, await readPrecision());
|
|
766
|
+
};
|
|
767
|
+
const allowance = (0, import_vue6.computed)(() => {
|
|
768
|
+
if (allowanceRaw.value === null) return null;
|
|
769
|
+
const token = (0, import_vue6.toValue)(options.token);
|
|
770
|
+
const precision = (0, import_connect_appkit_core6.readDecimals)(decimals, token, token.decimals);
|
|
771
|
+
return precision === void 0 ? null : (0, import_connect_core6.formatUnits)(allowanceRaw.value, precision);
|
|
772
|
+
});
|
|
773
|
+
(0, import_vue6.onScopeDispose)(() => {
|
|
774
|
+
disposed = true;
|
|
775
|
+
generation++;
|
|
776
|
+
allowanceGeneration++;
|
|
777
|
+
});
|
|
778
|
+
return {
|
|
779
|
+
approve,
|
|
780
|
+
approveMax,
|
|
781
|
+
allowanceRaw,
|
|
782
|
+
allowance,
|
|
783
|
+
hasAllowance,
|
|
784
|
+
isApproving,
|
|
785
|
+
isFetchingAllowance,
|
|
786
|
+
error,
|
|
787
|
+
refetchAllowance
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
// src/useERC20TransferSimulation.ts
|
|
792
|
+
var import_connect_appkit_core7 = require("@naculus/connect-appkit-core");
|
|
793
|
+
var import_connect_core7 = require("@naculus/connect-core");
|
|
794
|
+
var import_vue7 = require("vue");
|
|
795
|
+
function useERC20TransferSimulation(options) {
|
|
796
|
+
const transaction = (0, import_vue7.computed)(() => {
|
|
797
|
+
const token = (0, import_vue7.toValue)(options.token);
|
|
798
|
+
if (!(0, import_vue7.toValue)(options.connected) || !(0, import_vue7.toValue)(options.evmAccount))
|
|
799
|
+
return void 0;
|
|
800
|
+
try {
|
|
801
|
+
if (token.decimals === void 0) return void 0;
|
|
802
|
+
return {
|
|
803
|
+
to: token.address,
|
|
804
|
+
data: (0, import_connect_appkit_core7.encodeErc20Transfer)(
|
|
805
|
+
(0, import_vue7.toValue)(options.to),
|
|
806
|
+
(0, import_connect_core7.parseUnits)((0, import_vue7.toValue)(options.amount), token.decimals)
|
|
807
|
+
),
|
|
808
|
+
value: "0"
|
|
809
|
+
};
|
|
810
|
+
} catch {
|
|
811
|
+
return void 0;
|
|
812
|
+
}
|
|
813
|
+
});
|
|
814
|
+
const chainId = (0, import_vue7.computed)(() => {
|
|
815
|
+
const token = (0, import_vue7.toValue)(options.token);
|
|
816
|
+
if (token.chainId !== void 0) return token.chainId;
|
|
817
|
+
const currentChain = (0, import_vue7.toValue)(options.currentChain);
|
|
818
|
+
return currentChain ? (0, import_connect_appkit_core7.chainNumber)(currentChain) ?? void 0 : void 0;
|
|
819
|
+
});
|
|
820
|
+
const simulation = useTransactionSimulation(transaction, {
|
|
821
|
+
chainId,
|
|
822
|
+
currentChain: options.currentChain,
|
|
823
|
+
publicClient: options.publicClient,
|
|
824
|
+
evmAccount: options.evmAccount
|
|
825
|
+
});
|
|
826
|
+
return {
|
|
827
|
+
result: (0, import_vue7.computed)(
|
|
828
|
+
() => transaction.value ? simulation.result.value : void 0
|
|
829
|
+
),
|
|
830
|
+
isSimulating: (0, import_vue7.computed)(
|
|
831
|
+
() => !!transaction.value && simulation.isSimulating.value
|
|
832
|
+
),
|
|
833
|
+
error: (0, import_vue7.computed)(() => transaction.value ? simulation.error.value : null),
|
|
834
|
+
reSimulate: simulation.simulate,
|
|
835
|
+
reset: simulation.reset
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
// src/useAccount.ts
|
|
840
|
+
var import_vue8 = require("vue");
|
|
360
841
|
function useAccount(accounts, connected) {
|
|
361
842
|
const parsed = useAccounts(accounts);
|
|
362
|
-
const isConnected = (0,
|
|
363
|
-
const accountList = (0,
|
|
843
|
+
const isConnected = (0, import_vue8.computed)(() => (0, import_vue8.toValue)(connected));
|
|
844
|
+
const accountList = (0, import_vue8.computed)(() => (0, import_vue8.toValue)(accounts) ?? []);
|
|
364
845
|
return {
|
|
365
|
-
accounts: (0,
|
|
846
|
+
accounts: (0, import_vue8.computed)(
|
|
366
847
|
() => isConnected.value && accountList.value.length > 0 ? parsed.accounts.value : null
|
|
367
848
|
),
|
|
368
|
-
evmAccount: (0,
|
|
849
|
+
evmAccount: (0, import_vue8.computed)(
|
|
369
850
|
() => isConnected.value ? parsed.evmAccount.value : null
|
|
370
851
|
),
|
|
371
|
-
primaryAccount: (0,
|
|
852
|
+
primaryAccount: (0, import_vue8.computed)(() => accountList.value[0] ?? null),
|
|
372
853
|
isConnected,
|
|
373
|
-
count: (0,
|
|
854
|
+
count: (0, import_vue8.computed)(() => accountList.value.length)
|
|
374
855
|
};
|
|
375
856
|
}
|
|
376
857
|
|
|
377
858
|
// src/useSession.ts
|
|
378
|
-
var
|
|
859
|
+
var import_vue9 = require("vue");
|
|
379
860
|
function readSession(manager) {
|
|
380
861
|
const bundle = manager?.getActiveBundle();
|
|
381
862
|
if (!bundle) {
|
|
@@ -394,9 +875,9 @@ function readSession(manager) {
|
|
|
394
875
|
};
|
|
395
876
|
}
|
|
396
877
|
function useSession(manager) {
|
|
397
|
-
const snapshot = (0,
|
|
398
|
-
(0,
|
|
399
|
-
() => (0,
|
|
878
|
+
const snapshot = (0, import_vue9.shallowRef)(readSession((0, import_vue9.toValue)(manager)));
|
|
879
|
+
(0, import_vue9.watch)(
|
|
880
|
+
() => (0, import_vue9.toValue)(manager),
|
|
400
881
|
(current, _previous, onCleanup) => {
|
|
401
882
|
const update = () => {
|
|
402
883
|
snapshot.value = readSession(current);
|
|
@@ -406,145 +887,1067 @@ function useSession(manager) {
|
|
|
406
887
|
current.on("sessionConnected", update);
|
|
407
888
|
current.on("sessionDisconnected", update);
|
|
408
889
|
current.on("chainChanged", update);
|
|
890
|
+
current.on("sessionScopeChanged", update);
|
|
891
|
+
current.on("sessionRevoked", update);
|
|
409
892
|
onCleanup(() => {
|
|
410
893
|
current.off("sessionConnected", update);
|
|
411
894
|
current.off("sessionDisconnected", update);
|
|
412
895
|
current.off("chainChanged", update);
|
|
896
|
+
current.off("sessionScopeChanged", update);
|
|
897
|
+
current.off("sessionRevoked", update);
|
|
898
|
+
});
|
|
899
|
+
},
|
|
900
|
+
{ immediate: true }
|
|
901
|
+
);
|
|
902
|
+
return {
|
|
903
|
+
session: (0, import_vue9.computed)(() => snapshot.value.session),
|
|
904
|
+
chainSessions: (0, import_vue9.computed)(() => snapshot.value.chainSessions),
|
|
905
|
+
activeChainId: (0, import_vue9.computed)(() => snapshot.value.activeChainId),
|
|
906
|
+
isConnected: (0, import_vue9.computed)(() => snapshot.value.session !== null),
|
|
907
|
+
connectorId: (0, import_vue9.computed)(() => snapshot.value.connectorId)
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
// src/useConnect.ts
|
|
912
|
+
var import_connect_core8 = require("@naculus/connect-core");
|
|
913
|
+
var import_vue11 = require("vue");
|
|
914
|
+
|
|
915
|
+
// src/internal/action-guard.ts
|
|
916
|
+
var import_vue10 = require("vue");
|
|
917
|
+
function useActionGuard() {
|
|
918
|
+
const busy = (0, import_vue10.shallowRef)(false);
|
|
919
|
+
const error = (0, import_vue10.shallowRef)(null);
|
|
920
|
+
let active = 0;
|
|
921
|
+
let generation = 0;
|
|
922
|
+
let disposed = false;
|
|
923
|
+
const run = async (action, fallbackMessage, normalizeError) => {
|
|
924
|
+
const own = ++generation;
|
|
925
|
+
const commit = (write) => {
|
|
926
|
+
if (!disposed && own === generation) write();
|
|
927
|
+
};
|
|
928
|
+
active++;
|
|
929
|
+
busy.value = true;
|
|
930
|
+
error.value = null;
|
|
931
|
+
try {
|
|
932
|
+
return await action(commit);
|
|
933
|
+
} catch (cause) {
|
|
934
|
+
const normalized = normalizeError ? normalizeError(cause) : cause instanceof Error ? cause : new Error(fallbackMessage);
|
|
935
|
+
if (!disposed && own === generation) error.value = normalized;
|
|
936
|
+
throw normalized;
|
|
937
|
+
} finally {
|
|
938
|
+
active--;
|
|
939
|
+
if (!disposed) busy.value = active > 0;
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
const reset = () => {
|
|
943
|
+
generation++;
|
|
944
|
+
error.value = null;
|
|
945
|
+
};
|
|
946
|
+
const clearError = () => {
|
|
947
|
+
error.value = null;
|
|
948
|
+
};
|
|
949
|
+
const dispose = () => {
|
|
950
|
+
disposed = true;
|
|
951
|
+
generation++;
|
|
952
|
+
};
|
|
953
|
+
(0, import_vue10.onScopeDispose)(dispose);
|
|
954
|
+
return { busy, error, run, clearError, reset, dispose };
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
// src/useConnect.ts
|
|
958
|
+
function useConnect(action, status) {
|
|
959
|
+
const guard = useActionGuard();
|
|
960
|
+
let inFlight = null;
|
|
961
|
+
const connect = () => {
|
|
962
|
+
if (inFlight) return inFlight;
|
|
963
|
+
const invoke = (0, import_vue11.unref)(action);
|
|
964
|
+
const pending = guard.run(
|
|
965
|
+
() => Promise.resolve().then(() => invoke()),
|
|
966
|
+
"Connection failed",
|
|
967
|
+
(cause) => {
|
|
968
|
+
const message = cause instanceof Error ? cause.message : "Connection failed";
|
|
969
|
+
return cause instanceof import_connect_core8.WalletError ? cause : new Error(message);
|
|
970
|
+
}
|
|
971
|
+
).catch(() => {
|
|
972
|
+
}).finally(() => {
|
|
973
|
+
if (inFlight === pending) inFlight = null;
|
|
974
|
+
});
|
|
975
|
+
inFlight = pending;
|
|
976
|
+
return pending;
|
|
977
|
+
};
|
|
978
|
+
return {
|
|
979
|
+
connect,
|
|
980
|
+
isConnecting: (0, import_vue11.computed)(
|
|
981
|
+
() => guard.busy.value || (0, import_vue11.toValue)(status) === "connecting"
|
|
982
|
+
),
|
|
983
|
+
error: guard.error
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
// src/useDisconnect.ts
|
|
988
|
+
var import_vue12 = require("vue");
|
|
989
|
+
function useDisconnect(action, status) {
|
|
990
|
+
const guard = useActionGuard();
|
|
991
|
+
let inFlight = null;
|
|
992
|
+
const disconnect = () => {
|
|
993
|
+
if (inFlight) return inFlight;
|
|
994
|
+
if ((0, import_vue12.toValue)(status) === "disconnected") return Promise.resolve();
|
|
995
|
+
const invoke = (0, import_vue12.unref)(action);
|
|
996
|
+
const pending = guard.run(() => Promise.resolve().then(() => invoke()), "Disconnect failed").catch(() => {
|
|
997
|
+
}).finally(() => {
|
|
998
|
+
if (inFlight === pending) inFlight = null;
|
|
999
|
+
});
|
|
1000
|
+
inFlight = pending;
|
|
1001
|
+
return pending;
|
|
1002
|
+
};
|
|
1003
|
+
const cleanup = () => {
|
|
1004
|
+
guard.dispose();
|
|
1005
|
+
};
|
|
1006
|
+
return {
|
|
1007
|
+
disconnect,
|
|
1008
|
+
isDisconnecting: guard.busy,
|
|
1009
|
+
error: guard.error,
|
|
1010
|
+
cleanup
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
// src/useSwitchChain.ts
|
|
1015
|
+
var import_connect_appkit_core8 = require("@naculus/connect-appkit-core");
|
|
1016
|
+
var import_vue13 = require("vue");
|
|
1017
|
+
function useSwitchChain(action, chainId) {
|
|
1018
|
+
const guard = useActionGuard();
|
|
1019
|
+
const switchChain = (targetChainId) => {
|
|
1020
|
+
const invoke = (0, import_vue13.unref)(action);
|
|
1021
|
+
return guard.run(async () => {
|
|
1022
|
+
try {
|
|
1023
|
+
await invoke(targetChainId);
|
|
1024
|
+
} catch (cause) {
|
|
1025
|
+
throw (0, import_connect_appkit_core8.toChainSwitchError)(cause);
|
|
1026
|
+
}
|
|
1027
|
+
}, "Failed to switch chain");
|
|
1028
|
+
};
|
|
1029
|
+
return {
|
|
1030
|
+
switchChain,
|
|
1031
|
+
isSwitching: guard.busy,
|
|
1032
|
+
currentChainId: (0, import_vue13.computed)(() => (0, import_vue13.toValue)(chainId) ?? null),
|
|
1033
|
+
error: guard.error,
|
|
1034
|
+
clearError: guard.clearError
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
// src/useSignMessage.ts
|
|
1039
|
+
var import_vue14 = require("vue");
|
|
1040
|
+
function useSignMessage(action) {
|
|
1041
|
+
const guard = useActionGuard();
|
|
1042
|
+
const signMessage = (message) => {
|
|
1043
|
+
const invoke = (0, import_vue14.unref)(action);
|
|
1044
|
+
return guard.run(() => invoke(message), "Signing failed");
|
|
1045
|
+
};
|
|
1046
|
+
return {
|
|
1047
|
+
signMessage,
|
|
1048
|
+
isSigning: guard.busy,
|
|
1049
|
+
error: guard.error,
|
|
1050
|
+
reset: guard.reset
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
// src/useSendTransaction.ts
|
|
1055
|
+
var import_vue15 = require("vue");
|
|
1056
|
+
function useSendTransaction(action) {
|
|
1057
|
+
const guard = useActionGuard();
|
|
1058
|
+
const status = (0, import_vue15.shallowRef)("idle");
|
|
1059
|
+
const sendTransaction = (transaction) => {
|
|
1060
|
+
const invoke = (0, import_vue15.unref)(action);
|
|
1061
|
+
status.value = "awaiting_approval";
|
|
1062
|
+
return guard.run(async (commit) => {
|
|
1063
|
+
const hash = await invoke(transaction);
|
|
1064
|
+
commit(() => {
|
|
1065
|
+
status.value = "submitted";
|
|
1066
|
+
});
|
|
1067
|
+
return hash;
|
|
1068
|
+
}, "Transaction failed").catch((cause) => {
|
|
1069
|
+
if (guard.error.value === cause) status.value = "failed";
|
|
1070
|
+
throw cause;
|
|
1071
|
+
});
|
|
1072
|
+
};
|
|
1073
|
+
const reset = () => {
|
|
1074
|
+
guard.reset();
|
|
1075
|
+
status.value = "idle";
|
|
1076
|
+
};
|
|
1077
|
+
return {
|
|
1078
|
+
sendTransaction,
|
|
1079
|
+
status,
|
|
1080
|
+
error: guard.error,
|
|
1081
|
+
reset,
|
|
1082
|
+
isSending: (0, import_vue15.computed)(() => status.value === "awaiting_approval")
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
// src/useSolanaTransaction.ts
|
|
1087
|
+
var import_vue16 = require("vue");
|
|
1088
|
+
function useSolanaTransaction(options) {
|
|
1089
|
+
const guard = useActionGuard();
|
|
1090
|
+
const isSigning = (0, import_vue16.shallowRef)(false);
|
|
1091
|
+
const isSending = (0, import_vue16.shallowRef)(false);
|
|
1092
|
+
let signing = 0;
|
|
1093
|
+
let sending = 0;
|
|
1094
|
+
const signTransaction = (transaction) => {
|
|
1095
|
+
const invoke = (0, import_vue16.unref)(options.signTransaction);
|
|
1096
|
+
signing++;
|
|
1097
|
+
isSigning.value = true;
|
|
1098
|
+
return guard.run(() => invoke(transaction), "Signing failed").finally(() => {
|
|
1099
|
+
signing--;
|
|
1100
|
+
isSigning.value = signing > 0;
|
|
1101
|
+
});
|
|
1102
|
+
};
|
|
1103
|
+
const sendTransaction = (transaction) => {
|
|
1104
|
+
const invoke = (0, import_vue16.unref)(options.sendTransaction);
|
|
1105
|
+
sending++;
|
|
1106
|
+
isSending.value = true;
|
|
1107
|
+
return guard.run(() => invoke(transaction), "Send failed").finally(() => {
|
|
1108
|
+
sending--;
|
|
1109
|
+
isSending.value = sending > 0;
|
|
1110
|
+
});
|
|
1111
|
+
};
|
|
1112
|
+
const getStatus = (signature) => (0, import_vue16.unref)(options.getStatus)(signature);
|
|
1113
|
+
return {
|
|
1114
|
+
signTransaction,
|
|
1115
|
+
sendTransaction,
|
|
1116
|
+
getStatus,
|
|
1117
|
+
isSigning,
|
|
1118
|
+
isSending,
|
|
1119
|
+
error: guard.error,
|
|
1120
|
+
reset: guard.reset
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
// src/useSignInWithX.ts
|
|
1125
|
+
var import_vue17 = require("vue");
|
|
1126
|
+
function useSignInWithX(action) {
|
|
1127
|
+
const isSigningIn = (0, import_vue17.shallowRef)(false);
|
|
1128
|
+
const result = (0, import_vue17.shallowRef)(null);
|
|
1129
|
+
const error = (0, import_vue17.shallowRef)(null);
|
|
1130
|
+
let generation = 0;
|
|
1131
|
+
let active = 0;
|
|
1132
|
+
let disposed = false;
|
|
1133
|
+
const signIn = async (options) => {
|
|
1134
|
+
const invoke = (0, import_vue17.unref)(action);
|
|
1135
|
+
const own = ++generation;
|
|
1136
|
+
active++;
|
|
1137
|
+
isSigningIn.value = true;
|
|
1138
|
+
error.value = null;
|
|
1139
|
+
try {
|
|
1140
|
+
const next = await invoke(options);
|
|
1141
|
+
if (!disposed && own === generation) result.value = next;
|
|
1142
|
+
return next;
|
|
1143
|
+
} catch (cause) {
|
|
1144
|
+
const normalized = cause instanceof Error ? cause : new Error("SIWX sign-in failed");
|
|
1145
|
+
if (!disposed && own === generation) error.value = normalized;
|
|
1146
|
+
throw normalized;
|
|
1147
|
+
} finally {
|
|
1148
|
+
active--;
|
|
1149
|
+
if (!disposed) isSigningIn.value = active > 0;
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
const clearError = () => {
|
|
1153
|
+
error.value = null;
|
|
1154
|
+
};
|
|
1155
|
+
const reset = () => {
|
|
1156
|
+
generation++;
|
|
1157
|
+
result.value = null;
|
|
1158
|
+
error.value = null;
|
|
1159
|
+
};
|
|
1160
|
+
(0, import_vue17.onScopeDispose)(() => {
|
|
1161
|
+
disposed = true;
|
|
1162
|
+
generation++;
|
|
1163
|
+
});
|
|
1164
|
+
return { signIn, isSigningIn, result, error, clearError, reset };
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
// src/useSignInWithEthereum.ts
|
|
1168
|
+
function useSignInWithEthereum(action) {
|
|
1169
|
+
return useSignInWithX(action);
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
// src/useExecuteCalls.ts
|
|
1173
|
+
var import_vue18 = require("vue");
|
|
1174
|
+
function useExecuteCalls(options) {
|
|
1175
|
+
const guard = useActionGuard();
|
|
1176
|
+
const preview = (callCount, atomicity) => (0, import_vue18.unref)(options.preview)(callCount, atomicity);
|
|
1177
|
+
const execute = (calls, atomicity) => {
|
|
1178
|
+
const invoke = (0, import_vue18.unref)(options.execute);
|
|
1179
|
+
return guard.run(() => invoke(calls, atomicity), "Execution failed");
|
|
1180
|
+
};
|
|
1181
|
+
const reset = () => {
|
|
1182
|
+
guard.reset();
|
|
1183
|
+
(0, import_vue18.unref)(options.reset)();
|
|
1184
|
+
};
|
|
1185
|
+
return {
|
|
1186
|
+
preview,
|
|
1187
|
+
execute,
|
|
1188
|
+
isExecuting: guard.busy,
|
|
1189
|
+
error: guard.error,
|
|
1190
|
+
lastRoute: (0, import_vue18.computed)(() => (0, import_vue18.toValue)(options.lastRoute)),
|
|
1191
|
+
reset
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
// src/useDelegationPolicy.ts
|
|
1196
|
+
var import_connect_appkit_core10 = require("@naculus/connect-appkit-core");
|
|
1197
|
+
var import_vue20 = require("vue");
|
|
1198
|
+
|
|
1199
|
+
// src/useSessionKeys.ts
|
|
1200
|
+
var import_connect_appkit_core9 = require("@naculus/connect-appkit-core");
|
|
1201
|
+
var import_vue19 = require("vue");
|
|
1202
|
+
function resolveManager(config, options) {
|
|
1203
|
+
return options.manager ?? (0, import_connect_appkit_core9.getSharedSessionKeyManager)(config);
|
|
1204
|
+
}
|
|
1205
|
+
function useSessionKeys(connected, config, options = {}) {
|
|
1206
|
+
const manager = resolveManager(config, options);
|
|
1207
|
+
const sessions = (0, import_vue19.shallowRef)([]);
|
|
1208
|
+
const loading = (0, import_vue19.shallowRef)(false);
|
|
1209
|
+
const error = (0, import_vue19.shallowRef)(null);
|
|
1210
|
+
let generation = 0;
|
|
1211
|
+
let disposed = false;
|
|
1212
|
+
const refresh = async () => {
|
|
1213
|
+
const own = ++generation;
|
|
1214
|
+
if (!(0, import_vue19.toValue)(connected)) {
|
|
1215
|
+
sessions.value = [];
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
loading.value = true;
|
|
1219
|
+
error.value = null;
|
|
1220
|
+
try {
|
|
1221
|
+
const keys = await manager.listSessions();
|
|
1222
|
+
if (!disposed && own === generation) sessions.value = keys;
|
|
1223
|
+
} catch (cause) {
|
|
1224
|
+
if (!disposed && own === generation) {
|
|
1225
|
+
error.value = cause instanceof Error ? cause : new Error("Failed to load session keys");
|
|
1226
|
+
}
|
|
1227
|
+
} finally {
|
|
1228
|
+
if (!disposed && own === generation) loading.value = false;
|
|
1229
|
+
}
|
|
1230
|
+
};
|
|
1231
|
+
(0, import_vue19.watch)(
|
|
1232
|
+
() => (0, import_vue19.toValue)(connected),
|
|
1233
|
+
() => {
|
|
1234
|
+
void refresh();
|
|
1235
|
+
},
|
|
1236
|
+
{ immediate: true }
|
|
1237
|
+
);
|
|
1238
|
+
(0, import_vue19.onScopeDispose)(() => {
|
|
1239
|
+
disposed = true;
|
|
1240
|
+
generation++;
|
|
1241
|
+
});
|
|
1242
|
+
return {
|
|
1243
|
+
sessions,
|
|
1244
|
+
activeSessions: (0, import_vue19.computed)(
|
|
1245
|
+
() => sessions.value.filter((s) => s.status === "active")
|
|
1246
|
+
),
|
|
1247
|
+
loading,
|
|
1248
|
+
error,
|
|
1249
|
+
refresh,
|
|
1250
|
+
clearError: () => {
|
|
1251
|
+
error.value = null;
|
|
1252
|
+
},
|
|
1253
|
+
storageAvailable: manager.isStorageAvailable()
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
function useCreateSessionKey(config, options = {}) {
|
|
1257
|
+
const manager = resolveManager(config, options);
|
|
1258
|
+
const guard = useActionGuard();
|
|
1259
|
+
const lastCreated = (0, import_vue19.shallowRef)(null);
|
|
1260
|
+
return {
|
|
1261
|
+
createSessionKey: (scope, signerAddress) => guard.run(async () => {
|
|
1262
|
+
const info = await manager.createSessionKey(scope, signerAddress);
|
|
1263
|
+
lastCreated.value = info;
|
|
1264
|
+
return info;
|
|
1265
|
+
}, "Failed to create session key"),
|
|
1266
|
+
lastCreated,
|
|
1267
|
+
isCreating: guard.busy,
|
|
1268
|
+
error: guard.error,
|
|
1269
|
+
clearError: guard.reset
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
function useRevokeSession(config, options = {}) {
|
|
1273
|
+
const manager = resolveManager(config, options);
|
|
1274
|
+
const guard = useActionGuard();
|
|
1275
|
+
return {
|
|
1276
|
+
revokeSession: (sessionId) => guard.run(
|
|
1277
|
+
() => manager.revokeSession(sessionId),
|
|
1278
|
+
"Failed to revoke session key"
|
|
1279
|
+
),
|
|
1280
|
+
isRevoking: guard.busy,
|
|
1281
|
+
error: guard.error,
|
|
1282
|
+
clearError: guard.reset
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
function useSendWithSession(config, options = {}) {
|
|
1286
|
+
const manager = resolveManager(config, options);
|
|
1287
|
+
const guard = useActionGuard();
|
|
1288
|
+
return {
|
|
1289
|
+
signWithSession: (sessionId, messageHash, tx) => guard.run(
|
|
1290
|
+
() => manager.signWithSessionKey(sessionId, messageHash, tx),
|
|
1291
|
+
"Failed to sign with session key"
|
|
1292
|
+
),
|
|
1293
|
+
checkScope: (sessionId, tx) => guard.run(
|
|
1294
|
+
() => manager.checkSessionScope(sessionId, tx),
|
|
1295
|
+
"Failed to check session scope"
|
|
1296
|
+
),
|
|
1297
|
+
isBusy: guard.busy,
|
|
1298
|
+
error: guard.error,
|
|
1299
|
+
clearError: guard.reset
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
// src/useDelegationPolicy.ts
|
|
1304
|
+
function useDelegationPolicy(options) {
|
|
1305
|
+
const manager = options.manager ?? (0, import_connect_appkit_core10.getSharedSessionKeyManager)(options.managerConfig);
|
|
1306
|
+
const sessionKeys = useSessionKeys(options.connected, options.managerConfig, {
|
|
1307
|
+
manager
|
|
1308
|
+
});
|
|
1309
|
+
const guard = useActionGuard();
|
|
1310
|
+
const verifiedIds = (0, import_vue20.shallowRef)(/* @__PURE__ */ new Set());
|
|
1311
|
+
const isVerifying = (0, import_vue20.shallowRef)(false);
|
|
1312
|
+
const verifyError = (0, import_vue20.shallowRef)(null);
|
|
1313
|
+
let verifyGeneration = 0;
|
|
1314
|
+
let disposed = false;
|
|
1315
|
+
const origin = options.origin ?? (typeof window !== "undefined" ? window.location.origin : "unknown");
|
|
1316
|
+
const flow = (0, import_connect_appkit_core10.createDelegationPolicyFlow)({
|
|
1317
|
+
manager,
|
|
1318
|
+
origin,
|
|
1319
|
+
signer: () => (0, import_connect_appkit_core10.bareEvmAddress)((0, import_vue20.toValue)(options.account)),
|
|
1320
|
+
signMessage: (message) => (0, import_vue20.unref)(options.signMessage)(message),
|
|
1321
|
+
verifySignature: (input) => (0, import_vue20.unref)(options.verifySignature)(input),
|
|
1322
|
+
previewExecution: (callCount, atomicity) => (0, import_vue20.unref)(options.previewExecution)(callCount, atomicity),
|
|
1323
|
+
sponsorship: options.sponsorship,
|
|
1324
|
+
adapter: options.adapter,
|
|
1325
|
+
delegation: () => (0, import_vue20.toValue)(options.delegation),
|
|
1326
|
+
encryptionKeyConfigured: Boolean(options.managerConfig?.encryptionKey),
|
|
1327
|
+
storageAvailable: () => sessionKeys.storageAvailable,
|
|
1328
|
+
refresh: sessionKeys.refresh
|
|
1329
|
+
});
|
|
1330
|
+
(0, import_vue20.watch)(
|
|
1331
|
+
() => sessionKeys.sessions.value,
|
|
1332
|
+
(sessions) => {
|
|
1333
|
+
const own = ++verifyGeneration;
|
|
1334
|
+
const candidates = sessions.filter(import_connect_appkit_core10.isVerifiablePolicy);
|
|
1335
|
+
if (candidates.length === 0) {
|
|
1336
|
+
verifiedIds.value = /* @__PURE__ */ new Set();
|
|
1337
|
+
isVerifying.value = false;
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
isVerifying.value = true;
|
|
1341
|
+
void Promise.all(
|
|
1342
|
+
candidates.map(
|
|
1343
|
+
async (policy) => [policy.id, await flow.verifyStoredPolicy(policy)]
|
|
1344
|
+
)
|
|
1345
|
+
).then((results) => {
|
|
1346
|
+
if (disposed || own !== verifyGeneration) return;
|
|
1347
|
+
verifiedIds.value = new Set(
|
|
1348
|
+
results.filter(([, ok]) => ok).map(([id]) => id)
|
|
1349
|
+
);
|
|
1350
|
+
}).catch((cause) => {
|
|
1351
|
+
if (disposed || own !== verifyGeneration) return;
|
|
1352
|
+
verifiedIds.value = /* @__PURE__ */ new Set();
|
|
1353
|
+
verifyError.value = cause instanceof Error ? cause : new Error("Policy verification failed");
|
|
1354
|
+
}).finally(() => {
|
|
1355
|
+
if (!disposed && own === verifyGeneration) isVerifying.value = false;
|
|
413
1356
|
});
|
|
414
1357
|
},
|
|
415
1358
|
{ immediate: true }
|
|
416
1359
|
);
|
|
1360
|
+
(0, import_vue20.onScopeDispose)(() => {
|
|
1361
|
+
disposed = true;
|
|
1362
|
+
verifyGeneration++;
|
|
1363
|
+
});
|
|
417
1364
|
return {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
1365
|
+
policies: sessionKeys.sessions,
|
|
1366
|
+
activePolicies: (0, import_vue20.computed)(
|
|
1367
|
+
() => sessionKeys.activeSessions.value.filter(
|
|
1368
|
+
(p) => verifiedIds.value.has(p.id)
|
|
1369
|
+
)
|
|
1370
|
+
),
|
|
1371
|
+
storageAvailable: sessionKeys.storageAvailable,
|
|
1372
|
+
loading: (0, import_vue20.computed)(() => sessionKeys.loading.value || isVerifying.value),
|
|
1373
|
+
isBusy: guard.busy,
|
|
1374
|
+
error: (0, import_vue20.computed)(
|
|
1375
|
+
() => guard.error.value ?? verifyError.value ?? sessionKeys.error.value
|
|
1376
|
+
),
|
|
1377
|
+
createPolicy: (scope) => guard.run(() => flow.createPolicy(scope), "Policy creation failed"),
|
|
1378
|
+
revokePolicy: (policyId) => guard.run(() => flow.revokePolicy(policyId), "Policy revocation failed"),
|
|
1379
|
+
previewPolicyExecution: flow.previewPolicyExecution,
|
|
1380
|
+
signPolicyDigest: flow.signPolicyDigest,
|
|
1381
|
+
executePolicy: (policyId, tx) => guard.run(
|
|
1382
|
+
() => flow.executePolicy(policyId, tx),
|
|
1383
|
+
"Policy execution failed"
|
|
1384
|
+
),
|
|
1385
|
+
refresh: sessionKeys.refresh,
|
|
1386
|
+
clearError: () => {
|
|
1387
|
+
guard.reset();
|
|
1388
|
+
verifyError.value = null;
|
|
1389
|
+
sessionKeys.clearError();
|
|
1390
|
+
}
|
|
423
1391
|
};
|
|
424
1392
|
}
|
|
425
1393
|
|
|
426
|
-
// src/
|
|
427
|
-
var
|
|
428
|
-
var
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
const
|
|
1394
|
+
// src/useSmartAccount.ts
|
|
1395
|
+
var import_connect_appkit_core11 = require("@naculus/connect-appkit-core");
|
|
1396
|
+
var import_connect_core9 = require("@naculus/connect-core");
|
|
1397
|
+
var import_vue21 = require("vue");
|
|
1398
|
+
function useSmartAccount(options) {
|
|
1399
|
+
const address = (0, import_vue21.shallowRef)(null);
|
|
1400
|
+
const isDeployed = (0, import_vue21.shallowRef)(false);
|
|
1401
|
+
const accountInfo = (0, import_vue21.shallowRef)(null);
|
|
1402
|
+
const guard = useActionGuard();
|
|
1403
|
+
const managerRef = (0, import_vue21.shallowRef)(null);
|
|
1404
|
+
let generation = 0;
|
|
1405
|
+
let inFlight = false;
|
|
432
1406
|
let disposed = false;
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
1407
|
+
const chainId = (0, import_vue21.computed)(
|
|
1408
|
+
() => (0, import_connect_appkit_core11.resolveEvmChainId)(
|
|
1409
|
+
(0, import_vue21.toValue)(options.chainId),
|
|
1410
|
+
(0, import_vue21.toValue)(options.connectedChainId)
|
|
1411
|
+
)
|
|
1412
|
+
);
|
|
1413
|
+
(0, import_vue21.watch)(
|
|
1414
|
+
[
|
|
1415
|
+
() => (0, import_vue21.toValue)(options.manager),
|
|
1416
|
+
() => (0, import_vue21.toValue)(options.rpcUrl),
|
|
1417
|
+
() => (0, import_vue21.toValue)(options.bundlerUrl),
|
|
1418
|
+
() => chainId.value
|
|
1419
|
+
],
|
|
1420
|
+
([supplied, rpcUrl, bundlerUrl, chain]) => {
|
|
1421
|
+
const own = ++generation;
|
|
1422
|
+
managerRef.value = null;
|
|
1423
|
+
if (supplied) {
|
|
1424
|
+
managerRef.value = supplied;
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
if (!rpcUrl || !chain) return;
|
|
1428
|
+
import("@naculus/connect-core").then(({ SmartAccountManager }) => {
|
|
1429
|
+
if (disposed || own !== generation) return;
|
|
1430
|
+
managerRef.value = new SmartAccountManager({
|
|
1431
|
+
rpcUrl,
|
|
1432
|
+
chainId: chain,
|
|
1433
|
+
bundlerClient: { url: bundlerUrl ?? "" }
|
|
1434
|
+
});
|
|
1435
|
+
}).catch((cause) => {
|
|
1436
|
+
if (disposed || own !== generation) return;
|
|
1437
|
+
guard.error.value = cause instanceof Error ? cause : new Error("Failed to load account-abstraction module");
|
|
1438
|
+
});
|
|
1439
|
+
},
|
|
1440
|
+
{ immediate: true }
|
|
1441
|
+
);
|
|
1442
|
+
const config = (0, import_vue21.computed)(() => {
|
|
1443
|
+
const owner = (0, import_connect_appkit_core11.bareEvmAddress)((0, import_vue21.toValue)(options.account));
|
|
1444
|
+
const chain = chainId.value;
|
|
1445
|
+
if (!owner || !chain || !managerRef.value) return null;
|
|
1446
|
+
return (0, import_connect_appkit_core11.buildSmartAccountConfig)(owner, chain, {
|
|
1447
|
+
accountType: options.accountType,
|
|
1448
|
+
entryPoint: options.entryPoint,
|
|
1449
|
+
salt: options.salt
|
|
446
1450
|
});
|
|
447
|
-
|
|
448
|
-
|
|
1451
|
+
});
|
|
1452
|
+
const apply = (info) => {
|
|
1453
|
+
address.value = info.address;
|
|
1454
|
+
isDeployed.value = info.isDeployed;
|
|
1455
|
+
accountInfo.value = info;
|
|
449
1456
|
};
|
|
450
|
-
(
|
|
1457
|
+
const operate = async (action, fallback) => {
|
|
1458
|
+
const cfg = config.value;
|
|
1459
|
+
const manager = managerRef.value;
|
|
1460
|
+
if (!cfg || !manager) {
|
|
1461
|
+
guard.error.value = new Error("Smart account not configured");
|
|
1462
|
+
return null;
|
|
1463
|
+
}
|
|
1464
|
+
if (inFlight) {
|
|
1465
|
+
guard.error.value = new Error(
|
|
1466
|
+
"Smart account operation already in progress"
|
|
1467
|
+
);
|
|
1468
|
+
return null;
|
|
1469
|
+
}
|
|
1470
|
+
inFlight = true;
|
|
1471
|
+
const own = generation;
|
|
1472
|
+
const current = () => !disposed && own === generation;
|
|
1473
|
+
const commit = (write) => {
|
|
1474
|
+
if (current()) write();
|
|
1475
|
+
};
|
|
1476
|
+
try {
|
|
1477
|
+
return await guard.run(async () => {
|
|
1478
|
+
const result = await action(manager, cfg, commit);
|
|
1479
|
+
return current() ? result : null;
|
|
1480
|
+
}, fallback);
|
|
1481
|
+
} catch {
|
|
1482
|
+
return null;
|
|
1483
|
+
} finally {
|
|
1484
|
+
inFlight = false;
|
|
1485
|
+
}
|
|
1486
|
+
};
|
|
1487
|
+
const createWallet = () => operate(async (manager, cfg, commit) => {
|
|
1488
|
+
const info = await manager.createAccount(cfg);
|
|
1489
|
+
commit(() => apply(info));
|
|
1490
|
+
return info;
|
|
1491
|
+
}, "Failed to create smart account");
|
|
1492
|
+
const deployWallet = () => operate(async (manager, cfg, commit) => {
|
|
1493
|
+
const send = (0, import_vue21.unref)(options.sendTransaction);
|
|
1494
|
+
if (!send) {
|
|
1495
|
+
throw new import_connect_core9.WalletError(
|
|
1496
|
+
"wallet_unavailable",
|
|
1497
|
+
"deployWallet needs the connected wallet's sendTransaction"
|
|
1498
|
+
);
|
|
1499
|
+
}
|
|
1500
|
+
const before = await manager.createAccount(cfg);
|
|
1501
|
+
if (before.isDeployed) {
|
|
1502
|
+
commit(() => apply(before));
|
|
1503
|
+
return before.address;
|
|
1504
|
+
}
|
|
1505
|
+
const deployTx = await manager.getDeployCallData(cfg);
|
|
1506
|
+
const hash = await send({
|
|
1507
|
+
to: deployTx.to,
|
|
1508
|
+
data: deployTx.data,
|
|
1509
|
+
value: deployTx.value.toString(),
|
|
1510
|
+
chainId: cfg.chainId
|
|
1511
|
+
});
|
|
1512
|
+
const after = await manager.createAccount(cfg);
|
|
1513
|
+
commit(() => apply(after));
|
|
1514
|
+
return hash;
|
|
1515
|
+
}, "Failed to deploy smart account");
|
|
1516
|
+
const getAddress = () => operate(async (manager, cfg, commit) => {
|
|
1517
|
+
const addr = await manager.getAccountAddress(cfg);
|
|
1518
|
+
commit(() => {
|
|
1519
|
+
address.value = addr;
|
|
1520
|
+
});
|
|
1521
|
+
return addr;
|
|
1522
|
+
}, "Failed to get smart account address");
|
|
1523
|
+
(0, import_vue21.onScopeDispose)(() => {
|
|
451
1524
|
disposed = true;
|
|
1525
|
+
generation++;
|
|
452
1526
|
});
|
|
453
1527
|
return {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
error
|
|
1528
|
+
address,
|
|
1529
|
+
isDeployed,
|
|
1530
|
+
accountInfo,
|
|
1531
|
+
isLoading: guard.busy,
|
|
1532
|
+
error: guard.error,
|
|
1533
|
+
config,
|
|
1534
|
+
createWallet,
|
|
1535
|
+
deployWallet,
|
|
1536
|
+
getAddress
|
|
459
1537
|
};
|
|
460
1538
|
}
|
|
461
1539
|
|
|
462
|
-
// src/
|
|
463
|
-
var
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
1540
|
+
// src/useSendUserOperation.ts
|
|
1541
|
+
var import_connect_appkit_core12 = require("@naculus/connect-appkit-core");
|
|
1542
|
+
var import_connect_core10 = require("@naculus/connect-core");
|
|
1543
|
+
var import_vue22 = require("vue");
|
|
1544
|
+
function useSendUserOperation(options) {
|
|
1545
|
+
const userOpHash = (0, import_vue22.shallowRef)(null);
|
|
1546
|
+
const receipt = (0, import_vue22.shallowRef)(null);
|
|
1547
|
+
const isPending = (0, import_vue22.shallowRef)(false);
|
|
1548
|
+
const isEstimating = (0, import_vue22.shallowRef)(false);
|
|
1549
|
+
const error = (0, import_vue22.shallowRef)(null);
|
|
1550
|
+
let requestId = 0;
|
|
1551
|
+
let inFlight = false;
|
|
467
1552
|
let disposed = false;
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
1553
|
+
const fail = (cause) => {
|
|
1554
|
+
error.value = cause;
|
|
1555
|
+
return null;
|
|
1556
|
+
};
|
|
1557
|
+
const sendUserOp = async (calls, opts) => {
|
|
1558
|
+
const rpcUrl = (0, import_vue22.toValue)(options.rpcUrl);
|
|
1559
|
+
const bundlerUrl = (0, import_vue22.toValue)(options.bundlerUrl);
|
|
1560
|
+
if (!rpcUrl) return fail(new Error("RPC URL not configured"));
|
|
1561
|
+
if (!bundlerUrl) return fail(new Error("Bundler URL not configured"));
|
|
1562
|
+
if (!calls.length) return fail(new Error("At least one call is required"));
|
|
1563
|
+
if (inFlight) {
|
|
1564
|
+
return fail(new Error("A UserOperation is already in progress"));
|
|
1565
|
+
}
|
|
1566
|
+
const owner = (0, import_connect_appkit_core12.bareEvmAddress)(
|
|
1567
|
+
(0, import_vue22.toValue)(options.owner) ?? (0, import_vue22.toValue)(options.account)
|
|
1568
|
+
);
|
|
1569
|
+
if (!owner) {
|
|
1570
|
+
return fail(
|
|
1571
|
+
new import_connect_core10.WalletError("wallet_unavailable", "No EVM account found")
|
|
1572
|
+
);
|
|
1573
|
+
}
|
|
1574
|
+
let targetChainId;
|
|
1575
|
+
try {
|
|
1576
|
+
targetChainId = (0, import_connect_appkit_core12.resolveUserOpChain)(
|
|
1577
|
+
(0, import_vue22.toValue)(options.chainId),
|
|
1578
|
+
(0, import_vue22.toValue)(options.connectedChainId)
|
|
1579
|
+
);
|
|
1580
|
+
} catch (chainError) {
|
|
1581
|
+
return fail(chainError);
|
|
1582
|
+
}
|
|
1583
|
+
const signer = (0, import_vue22.unref)(options.signer);
|
|
1584
|
+
const own = ++requestId;
|
|
1585
|
+
inFlight = true;
|
|
1586
|
+
isPending.value = true;
|
|
1587
|
+
isEstimating.value = true;
|
|
474
1588
|
error.value = null;
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
1589
|
+
userOpHash.value = null;
|
|
1590
|
+
receipt.value = null;
|
|
1591
|
+
try {
|
|
1592
|
+
const { SmartAccountManager } = await import("@naculus/connect-core");
|
|
1593
|
+
const manager = new SmartAccountManager({
|
|
1594
|
+
rpcUrl,
|
|
1595
|
+
bundlerClient: { url: bundlerUrl },
|
|
1596
|
+
chainId: targetChainId,
|
|
1597
|
+
signer,
|
|
1598
|
+
signerMode: options.signerMode ?? "eip191"
|
|
1599
|
+
});
|
|
1600
|
+
const config = (0, import_connect_appkit_core12.buildSmartAccountConfig)(owner, targetChainId, {
|
|
1601
|
+
accountType: options.accountType,
|
|
1602
|
+
entryPoint: options.entryPoint,
|
|
1603
|
+
salt: options.salt
|
|
1604
|
+
});
|
|
1605
|
+
const response = await manager.sendUserOperation(config, calls, opts);
|
|
1606
|
+
if (disposed || own !== requestId) return null;
|
|
1607
|
+
isEstimating.value = false;
|
|
1608
|
+
userOpHash.value = response.userOpHash;
|
|
1609
|
+
void manager.getUserOperationReceipt(response.userOpHash).then((next) => {
|
|
1610
|
+
if (!disposed && own === requestId) receipt.value = next;
|
|
1611
|
+
}).catch(() => void 0);
|
|
1612
|
+
return response;
|
|
1613
|
+
} catch (cause) {
|
|
1614
|
+
if (disposed || own !== requestId) return null;
|
|
1615
|
+
return fail(
|
|
1616
|
+
cause instanceof Error ? cause : new Error("Failed to send UserOperation")
|
|
1617
|
+
);
|
|
1618
|
+
} finally {
|
|
1619
|
+
inFlight = false;
|
|
1620
|
+
if (!disposed && own === requestId) {
|
|
1621
|
+
isPending.value = false;
|
|
1622
|
+
isEstimating.value = false;
|
|
478
1623
|
}
|
|
479
|
-
}
|
|
480
|
-
if (inFlight === pending) inFlight = null;
|
|
481
|
-
if (!disposed) isDisconnecting.value = false;
|
|
482
|
-
});
|
|
483
|
-
inFlight = pending;
|
|
484
|
-
return pending;
|
|
1624
|
+
}
|
|
485
1625
|
};
|
|
486
|
-
const
|
|
1626
|
+
const reset = () => {
|
|
1627
|
+
requestId++;
|
|
1628
|
+
userOpHash.value = null;
|
|
1629
|
+
receipt.value = null;
|
|
1630
|
+
isPending.value = false;
|
|
1631
|
+
isEstimating.value = false;
|
|
1632
|
+
error.value = null;
|
|
1633
|
+
};
|
|
1634
|
+
(0, import_vue22.onScopeDispose)(() => {
|
|
487
1635
|
disposed = true;
|
|
1636
|
+
requestId++;
|
|
1637
|
+
});
|
|
1638
|
+
return {
|
|
1639
|
+
sendUserOp,
|
|
1640
|
+
userOpHash,
|
|
1641
|
+
receipt,
|
|
1642
|
+
isPending,
|
|
1643
|
+
isEstimating,
|
|
1644
|
+
error,
|
|
1645
|
+
reset
|
|
488
1646
|
};
|
|
489
|
-
(0, import_vue6.onScopeDispose)(cleanup);
|
|
490
|
-
return { disconnect, isDisconnecting, error, cleanup };
|
|
491
1647
|
}
|
|
492
1648
|
|
|
493
|
-
// src/
|
|
494
|
-
var
|
|
495
|
-
var
|
|
496
|
-
function
|
|
497
|
-
const
|
|
498
|
-
const
|
|
1649
|
+
// src/useUserOpStatus.ts
|
|
1650
|
+
var import_connect_appkit_core13 = require("@naculus/connect-appkit-core");
|
|
1651
|
+
var import_vue23 = require("vue");
|
|
1652
|
+
function useUserOpStatus(options) {
|
|
1653
|
+
const status = (0, import_vue23.shallowRef)("idle");
|
|
1654
|
+
const receipt = (0, import_vue23.shallowRef)(null);
|
|
1655
|
+
const userOpHash = (0, import_vue23.shallowRef)(null);
|
|
1656
|
+
const error = (0, import_vue23.shallowRef)(null);
|
|
1657
|
+
const isPolling = (0, import_vue23.shallowRef)(false);
|
|
1658
|
+
const elapsedMs = (0, import_vue23.shallowRef)(0);
|
|
1659
|
+
const attempts = (0, import_vue23.shallowRef)(0);
|
|
1660
|
+
const pollInterval = options.pollInterval ?? 2e3;
|
|
1661
|
+
const maxRetries = options.maxRetries ?? 30;
|
|
499
1662
|
let generation = 0;
|
|
500
|
-
let
|
|
1663
|
+
let startedAt = 0;
|
|
1664
|
+
let ticker = null;
|
|
1665
|
+
let timer = null;
|
|
1666
|
+
let controller = null;
|
|
1667
|
+
const clearTimers = () => {
|
|
1668
|
+
if (ticker) clearInterval(ticker);
|
|
1669
|
+
if (timer) clearTimeout(timer);
|
|
1670
|
+
ticker = null;
|
|
1671
|
+
timer = null;
|
|
1672
|
+
};
|
|
1673
|
+
const finish = (next, cause) => {
|
|
1674
|
+
status.value = next;
|
|
1675
|
+
error.value = cause;
|
|
1676
|
+
isPolling.value = false;
|
|
1677
|
+
clearTimers();
|
|
1678
|
+
};
|
|
1679
|
+
const poll = async (hash, own) => {
|
|
1680
|
+
const bundlerUrl = (0, import_vue23.toValue)(options.bundlerUrl);
|
|
1681
|
+
if (!bundlerUrl || own !== generation) return;
|
|
1682
|
+
const attempt = ++attempts.value;
|
|
1683
|
+
const abort = new AbortController();
|
|
1684
|
+
controller = abort;
|
|
1685
|
+
try {
|
|
1686
|
+
const next = await (0, import_connect_appkit_core13.fetchUserOperationReceipt)(
|
|
1687
|
+
bundlerUrl,
|
|
1688
|
+
hash,
|
|
1689
|
+
abort.signal
|
|
1690
|
+
);
|
|
1691
|
+
if (own !== generation) return;
|
|
1692
|
+
if (next) {
|
|
1693
|
+
receipt.value = next;
|
|
1694
|
+
finish(next.success ? "confirmed" : "failed", null);
|
|
1695
|
+
return;
|
|
1696
|
+
}
|
|
1697
|
+
status.value = "pending";
|
|
1698
|
+
if (attempt <= maxRetries) {
|
|
1699
|
+
timer = setTimeout(() => void poll(hash, own), pollInterval);
|
|
1700
|
+
} else {
|
|
1701
|
+
finish(
|
|
1702
|
+
"not_found",
|
|
1703
|
+
new Error("UserOperation not included after maximum retries")
|
|
1704
|
+
);
|
|
1705
|
+
}
|
|
1706
|
+
} catch (cause) {
|
|
1707
|
+
if (own !== generation || abort.signal.aborted) return;
|
|
1708
|
+
const next = cause instanceof Error ? cause : new Error("Unknown bundler response failure");
|
|
1709
|
+
if (next instanceof import_connect_appkit_core13.InvalidUserOperationReceiptError) {
|
|
1710
|
+
finish("not_found", next);
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
if (attempt <= maxRetries) {
|
|
1714
|
+
timer = setTimeout(() => void poll(hash, own), pollInterval);
|
|
1715
|
+
} else {
|
|
1716
|
+
finish(
|
|
1717
|
+
"not_found",
|
|
1718
|
+
new Error(
|
|
1719
|
+
`UserOperation status unavailable after ${attempt} attempt${attempt === 1 ? "" : "s"}: ${next.message}`
|
|
1720
|
+
)
|
|
1721
|
+
);
|
|
1722
|
+
}
|
|
1723
|
+
} finally {
|
|
1724
|
+
if (controller === abort) controller = null;
|
|
1725
|
+
}
|
|
1726
|
+
};
|
|
1727
|
+
const start = (hash) => {
|
|
1728
|
+
const own = ++generation;
|
|
1729
|
+
controller?.abort();
|
|
1730
|
+
controller = null;
|
|
1731
|
+
clearTimers();
|
|
1732
|
+
userOpHash.value = hash;
|
|
1733
|
+
receipt.value = null;
|
|
1734
|
+
error.value = null;
|
|
1735
|
+
attempts.value = 0;
|
|
1736
|
+
elapsedMs.value = 0;
|
|
1737
|
+
if (!(0, import_vue23.toValue)(options.bundlerUrl)) {
|
|
1738
|
+
finish("not_found", new Error("Bundler URL not configured"));
|
|
1739
|
+
return;
|
|
1740
|
+
}
|
|
1741
|
+
status.value = "pending";
|
|
1742
|
+
isPolling.value = true;
|
|
1743
|
+
startedAt = Date.now();
|
|
1744
|
+
ticker = setInterval(() => {
|
|
1745
|
+
elapsedMs.value = Date.now() - startedAt;
|
|
1746
|
+
}, 1e3);
|
|
1747
|
+
void poll(hash, own);
|
|
1748
|
+
};
|
|
1749
|
+
const stop = () => {
|
|
1750
|
+
generation++;
|
|
1751
|
+
controller?.abort();
|
|
1752
|
+
controller = null;
|
|
1753
|
+
clearTimers();
|
|
1754
|
+
isPolling.value = false;
|
|
1755
|
+
};
|
|
1756
|
+
const reset = () => {
|
|
1757
|
+
stop();
|
|
1758
|
+
status.value = "idle";
|
|
1759
|
+
receipt.value = null;
|
|
1760
|
+
userOpHash.value = null;
|
|
1761
|
+
error.value = null;
|
|
1762
|
+
attempts.value = 0;
|
|
1763
|
+
elapsedMs.value = 0;
|
|
1764
|
+
};
|
|
1765
|
+
(0, import_vue23.onScopeDispose)(stop);
|
|
1766
|
+
return {
|
|
1767
|
+
status,
|
|
1768
|
+
receipt,
|
|
1769
|
+
userOpHash,
|
|
1770
|
+
error,
|
|
1771
|
+
isPolling,
|
|
1772
|
+
elapsedMs,
|
|
1773
|
+
attempts,
|
|
1774
|
+
start,
|
|
1775
|
+
stop,
|
|
1776
|
+
reset
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
// src/useSendCalls.ts
|
|
1781
|
+
var import_vue24 = require("vue");
|
|
1782
|
+
function useSendCalls(options) {
|
|
1783
|
+
const status = (0, import_vue24.shallowRef)("idle");
|
|
1784
|
+
const error = (0, import_vue24.shallowRef)(null);
|
|
1785
|
+
const batchHash = (0, import_vue24.shallowRef)(null);
|
|
1786
|
+
const callsStatus = (0, import_vue24.shallowRef)(null);
|
|
1787
|
+
let sendGeneration = 0;
|
|
1788
|
+
let statusGeneration = 0;
|
|
501
1789
|
let disposed = false;
|
|
502
|
-
const
|
|
503
|
-
const invoke = (0,
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
isSwitching.value = true;
|
|
1790
|
+
const sendCalls = async (calls, input) => {
|
|
1791
|
+
const invoke = (0, import_vue24.unref)(options.sendCalls);
|
|
1792
|
+
const own = ++sendGeneration;
|
|
1793
|
+
status.value = "awaiting_approval";
|
|
507
1794
|
error.value = null;
|
|
1795
|
+
batchHash.value = null;
|
|
508
1796
|
try {
|
|
509
|
-
await invoke(
|
|
1797
|
+
const hash = await invoke(calls, input);
|
|
1798
|
+
if (!disposed && own === sendGeneration) {
|
|
1799
|
+
status.value = "submitted";
|
|
1800
|
+
batchHash.value = hash;
|
|
1801
|
+
}
|
|
1802
|
+
return hash;
|
|
510
1803
|
} catch (cause) {
|
|
511
|
-
const
|
|
512
|
-
if (!disposed &&
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
1804
|
+
const normalized = cause instanceof Error ? cause : new Error("sendCalls failed");
|
|
1805
|
+
if (!disposed && own === sendGeneration) {
|
|
1806
|
+
status.value = "failed";
|
|
1807
|
+
error.value = normalized;
|
|
1808
|
+
}
|
|
1809
|
+
throw normalized;
|
|
517
1810
|
}
|
|
518
1811
|
};
|
|
519
|
-
|
|
1812
|
+
const getCallsStatus = async (hash) => {
|
|
1813
|
+
const invoke = (0, import_vue24.unref)(options.getCallsStatus);
|
|
1814
|
+
const own = ++statusGeneration;
|
|
1815
|
+
const result = await invoke(hash);
|
|
1816
|
+
if (!disposed && own === statusGeneration) callsStatus.value = result;
|
|
1817
|
+
return result;
|
|
1818
|
+
};
|
|
1819
|
+
const showCallsStatus = (hash) => (0, import_vue24.unref)(options.showCallsStatus)(hash);
|
|
1820
|
+
const reset = () => {
|
|
1821
|
+
sendGeneration++;
|
|
1822
|
+
statusGeneration++;
|
|
1823
|
+
status.value = "idle";
|
|
1824
|
+
error.value = null;
|
|
1825
|
+
batchHash.value = null;
|
|
1826
|
+
callsStatus.value = null;
|
|
1827
|
+
};
|
|
1828
|
+
(0, import_vue24.onScopeDispose)(() => {
|
|
520
1829
|
disposed = true;
|
|
521
|
-
|
|
1830
|
+
sendGeneration++;
|
|
1831
|
+
statusGeneration++;
|
|
522
1832
|
});
|
|
523
1833
|
return {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
1834
|
+
sendCalls,
|
|
1835
|
+
getCallsStatus,
|
|
1836
|
+
showCallsStatus,
|
|
1837
|
+
status,
|
|
527
1838
|
error,
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
1839
|
+
batchHash,
|
|
1840
|
+
callsStatus,
|
|
1841
|
+
execution: (0, import_vue24.computed)(() => (0, import_vue24.toValue)(options.execution) ?? null),
|
|
1842
|
+
isSending: (0, import_vue24.computed)(() => status.value === "awaiting_approval"),
|
|
1843
|
+
reset
|
|
1844
|
+
};
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
// src/useEmbeddedWallet.ts
|
|
1848
|
+
var import_vue25 = require("vue");
|
|
1849
|
+
function useEmbeddedWallet(options) {
|
|
1850
|
+
const guard = useActionGuard();
|
|
1851
|
+
const run = (action) => guard.run(action, "Embedded wallet action failed");
|
|
1852
|
+
const wallet = (0, import_vue25.computed)(() => (0, import_vue25.toValue)(options.wallet));
|
|
1853
|
+
return {
|
|
1854
|
+
wallet,
|
|
1855
|
+
hasWallet: (0, import_vue25.computed)(() => wallet.value !== null),
|
|
1856
|
+
address: (0, import_vue25.computed)(() => wallet.value?.address ?? null),
|
|
1857
|
+
accounts: (0, import_vue25.computed)(() => wallet.value?.accounts ?? []),
|
|
1858
|
+
activeNamespace: (0, import_vue25.computed)(() => wallet.value?.activeNamespace ?? null),
|
|
1859
|
+
backupPending: (0, import_vue25.computed)(() => (0, import_vue25.toValue)(options.backupPending)),
|
|
1860
|
+
storageSecurityLevel: (0, import_vue25.computed)(() => (0, import_vue25.toValue)(options.storageSecurityLevel)),
|
|
1861
|
+
securityReport: (0, import_vue25.computed)(() => (0, import_vue25.toValue)(options.securityReport)),
|
|
1862
|
+
connectEmbedded: () => run(() => (0, import_vue25.unref)(options.connectEmbedded)()),
|
|
1863
|
+
restoreWallet: () => run(() => (0, import_vue25.unref)(options.restoreWallet)()),
|
|
1864
|
+
generateWallet: () => run(() => (0, import_vue25.unref)(options.generateWallet)()),
|
|
1865
|
+
importFromMnemonic: (value) => run(() => (0, import_vue25.unref)(options.importFromMnemonic)(value)),
|
|
1866
|
+
importFromPrivateKey: (value) => run(() => (0, import_vue25.unref)(options.importFromPrivateKey)(value)),
|
|
1867
|
+
wipe: () => run(() => (0, import_vue25.unref)(options.wipe)()),
|
|
1868
|
+
setActiveNamespace: (value) => (0, import_vue25.unref)(options.setActiveNamespace)(value),
|
|
1869
|
+
backfillAccounts: () => run(() => (0, import_vue25.unref)(options.backfillAccounts)()),
|
|
1870
|
+
getSeedPhrase: () => (0, import_vue25.unref)(options.getSeedPhrase)(),
|
|
1871
|
+
getPrivateKey: () => (0, import_vue25.unref)(options.getPrivateKey)(),
|
|
1872
|
+
confirmBackup: () => (0, import_vue25.unref)(options.confirmBackup)(),
|
|
1873
|
+
isBusy: guard.busy,
|
|
1874
|
+
error: guard.error,
|
|
1875
|
+
clearError: guard.clearError
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
// src/useSIWxLogin.ts
|
|
1880
|
+
function useSIWxLogin(action) {
|
|
1881
|
+
const state = useSignInWithX(action);
|
|
1882
|
+
return {
|
|
1883
|
+
signIn: state.signIn,
|
|
1884
|
+
isSigningIn: state.isSigningIn,
|
|
1885
|
+
error: state.error,
|
|
1886
|
+
clearError: state.clearError
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
// src/useSIWxSession.ts
|
|
1891
|
+
var import_vue26 = require("vue");
|
|
1892
|
+
function useSIWxSession(options) {
|
|
1893
|
+
const guard = useActionGuard();
|
|
1894
|
+
return {
|
|
1895
|
+
session: (0, import_vue26.computed)(() => (0, import_vue26.toValue)(options.session)),
|
|
1896
|
+
isAuthenticated: (0, import_vue26.computed)(
|
|
1897
|
+
() => (0, import_vue26.toValue)(options.session) !== null && !(0, import_vue26.toValue)(options.isExpired)
|
|
1898
|
+
),
|
|
1899
|
+
isRestoring: (0, import_vue26.computed)(() => (0, import_vue26.toValue)(options.isRestoring)),
|
|
1900
|
+
isSigningIn: guard.busy,
|
|
1901
|
+
isExpired: (0, import_vue26.computed)(() => (0, import_vue26.toValue)(options.isExpired)),
|
|
1902
|
+
timeUntilExpiry: (0, import_vue26.computed)(() => (0, import_vue26.toValue)(options.timeUntilExpiry)),
|
|
1903
|
+
signIn: (input) => guard.run(() => (0, import_vue26.unref)(options.signIn)(input), "SIWX sign-in failed"),
|
|
1904
|
+
signOut: async () => {
|
|
1905
|
+
await (0, import_vue26.unref)(options.signOut)();
|
|
1906
|
+
guard.clearError();
|
|
1907
|
+
},
|
|
1908
|
+
refresh: () => guard.run(() => (0, import_vue26.unref)(options.refresh)(), "Session refresh failed"),
|
|
1909
|
+
error: guard.error,
|
|
1910
|
+
clearError: guard.clearError
|
|
1911
|
+
};
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
// src/useSiwxAuthSession.ts
|
|
1915
|
+
var import_vue27 = require("vue");
|
|
1916
|
+
function useSiwxAuthSession(options) {
|
|
1917
|
+
const guard = useActionGuard();
|
|
1918
|
+
const signIn = (input) => guard.run(() => (0, import_vue27.unref)(options.signIn)(input), "SIWX sign-in failed");
|
|
1919
|
+
const signOut = async () => {
|
|
1920
|
+
guard.reset();
|
|
1921
|
+
await (0, import_vue27.unref)(options.signOut)();
|
|
1922
|
+
guard.clearError();
|
|
1923
|
+
};
|
|
1924
|
+
const siwxResult = (0, import_vue27.computed)(() => (0, import_vue27.toValue)(options.result));
|
|
1925
|
+
return {
|
|
1926
|
+
isSignedIn: (0, import_vue27.computed)(() => siwxResult.value !== null),
|
|
1927
|
+
isRestoring: (0, import_vue27.computed)(() => (0, import_vue27.toValue)(options.isRestoring)),
|
|
1928
|
+
siwxResult,
|
|
1929
|
+
isSigningIn: guard.busy,
|
|
1930
|
+
error: guard.error,
|
|
1931
|
+
signIn,
|
|
1932
|
+
signOut,
|
|
1933
|
+
clearError: guard.clearError
|
|
531
1934
|
};
|
|
532
1935
|
}
|
|
533
1936
|
|
|
534
1937
|
// src/useBalance.ts
|
|
535
|
-
var
|
|
536
|
-
var
|
|
537
|
-
var
|
|
1938
|
+
var import_connect_appkit_core14 = require("@naculus/connect-appkit-core");
|
|
1939
|
+
var import_connect_core11 = require("@naculus/connect-core");
|
|
1940
|
+
var import_vue28 = require("vue");
|
|
538
1941
|
function useBalance(account, client, options = {}) {
|
|
539
|
-
const balance = (0,
|
|
540
|
-
const isFetching = (0,
|
|
541
|
-
const error = (0,
|
|
1942
|
+
const balance = (0, import_vue28.shallowRef)(null);
|
|
1943
|
+
const isFetching = (0, import_vue28.shallowRef)(false);
|
|
1944
|
+
const error = (0, import_vue28.shallowRef)(null);
|
|
542
1945
|
let generation = 0;
|
|
543
1946
|
let disposed = false;
|
|
544
1947
|
let timer = null;
|
|
545
1948
|
const refetch = async () => {
|
|
546
|
-
const reader = (0,
|
|
547
|
-
const address = (0,
|
|
1949
|
+
const reader = (0, import_vue28.toValue)(client);
|
|
1950
|
+
const address = (0, import_connect_appkit_core14.bareEvmAddress)((0, import_vue28.toValue)(account));
|
|
548
1951
|
const own = ++generation;
|
|
549
1952
|
if (!reader || !address) {
|
|
550
1953
|
balance.value = null;
|
|
@@ -570,11 +1973,11 @@ function useBalance(account, client, options = {}) {
|
|
|
570
1973
|
if (timer) clearInterval(timer);
|
|
571
1974
|
timer = null;
|
|
572
1975
|
};
|
|
573
|
-
(0,
|
|
1976
|
+
(0, import_vue28.watch)(
|
|
574
1977
|
[
|
|
575
|
-
() => (0,
|
|
576
|
-
() => (0,
|
|
577
|
-
() => (0,
|
|
1978
|
+
() => (0, import_vue28.toValue)(account),
|
|
1979
|
+
() => (0, import_vue28.toValue)(client),
|
|
1980
|
+
() => (0, import_vue28.toValue)(options.refreshInterval) ?? 0
|
|
578
1981
|
],
|
|
579
1982
|
([, , interval]) => {
|
|
580
1983
|
stopTimer();
|
|
@@ -583,17 +1986,17 @@ function useBalance(account, client, options = {}) {
|
|
|
583
1986
|
},
|
|
584
1987
|
{ immediate: true }
|
|
585
1988
|
);
|
|
586
|
-
(0,
|
|
1989
|
+
(0, import_vue28.onScopeDispose)(() => {
|
|
587
1990
|
disposed = true;
|
|
588
1991
|
generation++;
|
|
589
1992
|
stopTimer();
|
|
590
1993
|
});
|
|
591
1994
|
return {
|
|
592
1995
|
balance,
|
|
593
|
-
formatted: (0,
|
|
594
|
-
() => balance.value === null ? null : (0,
|
|
1996
|
+
formatted: (0, import_vue28.computed)(
|
|
1997
|
+
() => balance.value === null ? null : (0, import_connect_core11.formatUnits)(BigInt(balance.value), (0, import_vue28.toValue)(options.decimals) ?? 18)
|
|
595
1998
|
),
|
|
596
|
-
symbol: (0,
|
|
1999
|
+
symbol: (0, import_vue28.computed)(() => (0, import_vue28.toValue)(options.symbol) ?? null),
|
|
597
2000
|
isFetching,
|
|
598
2001
|
error,
|
|
599
2002
|
refetch
|
|
@@ -601,12 +2004,12 @@ function useBalance(account, client, options = {}) {
|
|
|
601
2004
|
}
|
|
602
2005
|
|
|
603
2006
|
// src/useRouteQuote.ts
|
|
604
|
-
var
|
|
605
|
-
var
|
|
2007
|
+
var import_connect_appkit_core15 = require("@naculus/connect-appkit-core");
|
|
2008
|
+
var import_vue29 = require("vue");
|
|
606
2009
|
function useRouteQuote(input, getQuotes, options = {}) {
|
|
607
|
-
const quotes = (0,
|
|
608
|
-
const loading = (0,
|
|
609
|
-
const error = (0,
|
|
2010
|
+
const quotes = (0, import_vue29.shallowRef)([]);
|
|
2011
|
+
const loading = (0, import_vue29.shallowRef)(false);
|
|
2012
|
+
const error = (0, import_vue29.shallowRef)(null);
|
|
610
2013
|
let generation = 0;
|
|
611
2014
|
let disposed = false;
|
|
612
2015
|
let timer = null;
|
|
@@ -615,10 +2018,10 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
615
2018
|
timer = null;
|
|
616
2019
|
};
|
|
617
2020
|
const fetchQuotes = async () => {
|
|
618
|
-
const current = (0,
|
|
619
|
-
const fn = (0,
|
|
2021
|
+
const current = (0, import_vue29.toValue)(input);
|
|
2022
|
+
const fn = (0, import_vue29.unref)(getQuotes);
|
|
620
2023
|
const own = ++generation;
|
|
621
|
-
if (!(0,
|
|
2024
|
+
if (!(0, import_connect_appkit_core15.isQuotableInput)(current)) {
|
|
622
2025
|
quotes.value = [];
|
|
623
2026
|
return;
|
|
624
2027
|
}
|
|
@@ -644,14 +2047,14 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
644
2047
|
if (!disposed && own === generation) loading.value = false;
|
|
645
2048
|
}
|
|
646
2049
|
};
|
|
647
|
-
(0,
|
|
2050
|
+
(0, import_vue29.watch)(
|
|
648
2051
|
[
|
|
649
|
-
() => (0,
|
|
650
|
-
() => (0,
|
|
651
|
-
() => (0,
|
|
652
|
-
() => (0,
|
|
653
|
-
() => (0,
|
|
654
|
-
() => (0,
|
|
2052
|
+
() => (0, import_vue29.toValue)(input).fromChain,
|
|
2053
|
+
() => (0, import_vue29.toValue)(input).toChain,
|
|
2054
|
+
() => (0, import_vue29.toValue)(input).fromToken,
|
|
2055
|
+
() => (0, import_vue29.toValue)(input).toToken,
|
|
2056
|
+
() => (0, import_vue29.toValue)(input).amount,
|
|
2057
|
+
() => (0, import_vue29.unref)(getQuotes)
|
|
655
2058
|
],
|
|
656
2059
|
([fromChain, toChain, fromToken, , amount]) => {
|
|
657
2060
|
clearTimer();
|
|
@@ -666,7 +2069,7 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
666
2069
|
},
|
|
667
2070
|
{ immediate: true }
|
|
668
2071
|
);
|
|
669
|
-
(0,
|
|
2072
|
+
(0, import_vue29.onScopeDispose)(() => {
|
|
670
2073
|
disposed = true;
|
|
671
2074
|
generation++;
|
|
672
2075
|
clearTimer();
|
|
@@ -687,17 +2090,17 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
687
2090
|
}
|
|
688
2091
|
|
|
689
2092
|
// src/useCompareCosts.ts
|
|
690
|
-
var
|
|
691
|
-
var
|
|
2093
|
+
var import_connect_appkit_core16 = require("@naculus/connect-appkit-core");
|
|
2094
|
+
var import_vue30 = require("vue");
|
|
692
2095
|
function useCompareCosts(input, compareCosts) {
|
|
693
|
-
const comparisons = (0,
|
|
694
|
-
const loading = (0,
|
|
695
|
-
const error = (0,
|
|
2096
|
+
const comparisons = (0, import_vue30.shallowRef)([]);
|
|
2097
|
+
const loading = (0, import_vue30.shallowRef)(false);
|
|
2098
|
+
const error = (0, import_vue30.shallowRef)(null);
|
|
696
2099
|
let generation = 0;
|
|
697
2100
|
let disposed = false;
|
|
698
2101
|
const fetchComparisons = async () => {
|
|
699
|
-
const { operation, chains, options } = (0,
|
|
700
|
-
const fn = (0,
|
|
2102
|
+
const { operation, chains, options } = (0, import_vue30.toValue)(input);
|
|
2103
|
+
const fn = (0, import_vue30.unref)(compareCosts);
|
|
701
2104
|
const own = ++generation;
|
|
702
2105
|
if (!chains || chains.length === 0) {
|
|
703
2106
|
comparisons.value = [];
|
|
@@ -718,14 +2121,14 @@ function useCompareCosts(input, compareCosts) {
|
|
|
718
2121
|
if (!disposed && own === generation) loading.value = false;
|
|
719
2122
|
}
|
|
720
2123
|
};
|
|
721
|
-
(0,
|
|
722
|
-
[() => (0,
|
|
2124
|
+
(0, import_vue30.watch)(
|
|
2125
|
+
[() => (0, import_connect_appkit_core16.compareCostsKey)((0, import_vue30.toValue)(input)), () => (0, import_vue30.unref)(compareCosts)],
|
|
723
2126
|
() => {
|
|
724
2127
|
void fetchComparisons();
|
|
725
2128
|
},
|
|
726
2129
|
{ immediate: true }
|
|
727
2130
|
);
|
|
728
|
-
(0,
|
|
2131
|
+
(0, import_vue30.onScopeDispose)(() => {
|
|
729
2132
|
disposed = true;
|
|
730
2133
|
generation++;
|
|
731
2134
|
});
|
|
@@ -733,16 +2136,16 @@ function useCompareCosts(input, compareCosts) {
|
|
|
733
2136
|
}
|
|
734
2137
|
|
|
735
2138
|
// src/useExecuteRoute.ts
|
|
736
|
-
var
|
|
737
|
-
var
|
|
2139
|
+
var import_connect_appkit_core17 = require("@naculus/connect-appkit-core");
|
|
2140
|
+
var import_vue31 = require("vue");
|
|
738
2141
|
function useExecuteRoute(executeRoute) {
|
|
739
|
-
const executing = (0,
|
|
740
|
-
const result = (0,
|
|
741
|
-
const error = (0,
|
|
2142
|
+
const executing = (0, import_vue31.shallowRef)(false);
|
|
2143
|
+
const result = (0, import_vue31.shallowRef)(null);
|
|
2144
|
+
const error = (0, import_vue31.shallowRef)(null);
|
|
742
2145
|
let inFlight = false;
|
|
743
2146
|
let disposed = false;
|
|
744
2147
|
const execute = async (quote, recipient, options) => {
|
|
745
|
-
const fn = (0,
|
|
2148
|
+
const fn = (0, import_vue31.unref)(executeRoute);
|
|
746
2149
|
if (!fn) {
|
|
747
2150
|
error.value = {
|
|
748
2151
|
code: "no_executor",
|
|
@@ -751,7 +2154,7 @@ function useExecuteRoute(executeRoute) {
|
|
|
751
2154
|
result.value = null;
|
|
752
2155
|
return null;
|
|
753
2156
|
}
|
|
754
|
-
const recipientError = (0,
|
|
2157
|
+
const recipientError = (0, import_connect_appkit_core17.validateRouteRecipient)(quote, recipient);
|
|
755
2158
|
if (recipientError) {
|
|
756
2159
|
error.value = recipientError;
|
|
757
2160
|
result.value = null;
|
|
@@ -773,14 +2176,14 @@ function useExecuteRoute(executeRoute) {
|
|
|
773
2176
|
if (!disposed) result.value = execResult;
|
|
774
2177
|
return execResult;
|
|
775
2178
|
} catch (cause) {
|
|
776
|
-
if (!disposed) error.value = (0,
|
|
2179
|
+
if (!disposed) error.value = (0, import_connect_appkit_core17.toExecuteRouteError)(cause);
|
|
777
2180
|
return null;
|
|
778
2181
|
} finally {
|
|
779
2182
|
inFlight = false;
|
|
780
2183
|
if (!disposed) executing.value = false;
|
|
781
2184
|
}
|
|
782
2185
|
};
|
|
783
|
-
(0,
|
|
2186
|
+
(0, import_vue31.onScopeDispose)(() => {
|
|
784
2187
|
disposed = true;
|
|
785
2188
|
});
|
|
786
2189
|
return {
|
|
@@ -797,22 +2200,22 @@ function useExecuteRoute(executeRoute) {
|
|
|
797
2200
|
}
|
|
798
2201
|
|
|
799
2202
|
// src/useTokenList.ts
|
|
800
|
-
var
|
|
801
|
-
var
|
|
802
|
-
var
|
|
2203
|
+
var import_connect_appkit_core18 = require("@naculus/connect-appkit-core");
|
|
2204
|
+
var import_connect_core12 = require("@naculus/connect-core");
|
|
2205
|
+
var import_vue32 = require("vue");
|
|
803
2206
|
function useTokenList(chainId, options = {}) {
|
|
804
2207
|
const config = {};
|
|
805
2208
|
if (options.sources) config.sources = options.sources;
|
|
806
|
-
const manager = options.manager ?? new
|
|
807
|
-
const tokens = (0,
|
|
808
|
-
const isLoading = (0,
|
|
809
|
-
const isLoaded = (0,
|
|
810
|
-
const error = (0,
|
|
2209
|
+
const manager = options.manager ?? new import_connect_core12.TokenListManager(config);
|
|
2210
|
+
const tokens = (0, import_vue32.shallowRef)([]);
|
|
2211
|
+
const isLoading = (0, import_vue32.shallowRef)(options.autoLoad !== false);
|
|
2212
|
+
const isLoaded = (0, import_vue32.shallowRef)(false);
|
|
2213
|
+
const error = (0, import_vue32.shallowRef)(null);
|
|
811
2214
|
let generation = 0;
|
|
812
2215
|
let disposed = false;
|
|
813
2216
|
const select = () => {
|
|
814
|
-
const id = (0,
|
|
815
|
-
const numeric = id ? (0,
|
|
2217
|
+
const id = (0, import_vue32.toValue)(chainId);
|
|
2218
|
+
const numeric = id ? (0, import_connect_appkit_core18.eip155ChainIdToNumber)(id) : void 0;
|
|
816
2219
|
return manager.getTokens(
|
|
817
2220
|
numeric !== void 0 ? { chainId: numeric } : void 0
|
|
818
2221
|
);
|
|
@@ -833,14 +2236,14 @@ function useTokenList(chainId, options = {}) {
|
|
|
833
2236
|
if (!disposed && own === generation) isLoading.value = false;
|
|
834
2237
|
}
|
|
835
2238
|
};
|
|
836
|
-
(0,
|
|
837
|
-
() => (0,
|
|
2239
|
+
(0, import_vue32.watch)(
|
|
2240
|
+
() => (0, import_vue32.toValue)(chainId),
|
|
838
2241
|
() => {
|
|
839
2242
|
if (options.autoLoad !== false) void run(() => manager.load());
|
|
840
2243
|
},
|
|
841
2244
|
{ immediate: true }
|
|
842
2245
|
);
|
|
843
|
-
(0,
|
|
2246
|
+
(0, import_vue32.onScopeDispose)(() => {
|
|
844
2247
|
disposed = true;
|
|
845
2248
|
generation++;
|
|
846
2249
|
});
|
|
@@ -854,30 +2257,30 @@ function useTokenList(chainId, options = {}) {
|
|
|
854
2257
|
}
|
|
855
2258
|
|
|
856
2259
|
// src/useTokenSearch.ts
|
|
857
|
-
var
|
|
858
|
-
var
|
|
859
|
-
var
|
|
2260
|
+
var import_connect_appkit_core19 = require("@naculus/connect-appkit-core");
|
|
2261
|
+
var import_connect_core13 = require("@naculus/connect-core");
|
|
2262
|
+
var import_vue33 = require("vue");
|
|
860
2263
|
var DEBOUNCE_MS = 300;
|
|
861
2264
|
var EMPTY = { exact: [], fuzzy: [], hasMore: false };
|
|
862
2265
|
var sharedManager = null;
|
|
863
2266
|
function getSharedManager() {
|
|
864
2267
|
if (!sharedManager) {
|
|
865
|
-
sharedManager = new
|
|
2268
|
+
sharedManager = new import_connect_core13.TokenListManager();
|
|
866
2269
|
sharedManager.load().catch(() => {
|
|
867
2270
|
});
|
|
868
2271
|
}
|
|
869
2272
|
return sharedManager;
|
|
870
2273
|
}
|
|
871
2274
|
function useTokenSearch(query, chainId, options = {}) {
|
|
872
|
-
const results = (0,
|
|
873
|
-
const isSearching = (0,
|
|
2275
|
+
const results = (0, import_vue33.shallowRef)(EMPTY);
|
|
2276
|
+
const isSearching = (0, import_vue33.shallowRef)(false);
|
|
874
2277
|
let timer = null;
|
|
875
2278
|
const clear = () => {
|
|
876
2279
|
if (timer) clearTimeout(timer);
|
|
877
2280
|
timer = null;
|
|
878
2281
|
};
|
|
879
|
-
(0,
|
|
880
|
-
[() => ((0,
|
|
2282
|
+
(0, import_vue33.watch)(
|
|
2283
|
+
[() => ((0, import_vue33.toValue)(query) ?? "").trim(), () => (0, import_vue33.toValue)(chainId)],
|
|
881
2284
|
([q, id]) => {
|
|
882
2285
|
clear();
|
|
883
2286
|
if (!q) {
|
|
@@ -889,7 +2292,7 @@ function useTokenSearch(query, chainId, options = {}) {
|
|
|
889
2292
|
timer = setTimeout(() => {
|
|
890
2293
|
timer = null;
|
|
891
2294
|
const manager = options.manager ?? getSharedManager();
|
|
892
|
-
const numeric = id ? (0,
|
|
2295
|
+
const numeric = id ? (0, import_connect_appkit_core19.eip155ChainIdToNumber)(id) : void 0;
|
|
893
2296
|
results.value = manager.search(q, {
|
|
894
2297
|
chainId: numeric,
|
|
895
2298
|
limit: options.limit ?? 20
|
|
@@ -899,37 +2302,37 @@ function useTokenSearch(query, chainId, options = {}) {
|
|
|
899
2302
|
},
|
|
900
2303
|
{ immediate: true }
|
|
901
2304
|
);
|
|
902
|
-
(0,
|
|
2305
|
+
(0, import_vue33.onScopeDispose)(clear);
|
|
903
2306
|
return { results, isSearching };
|
|
904
2307
|
}
|
|
905
2308
|
|
|
906
2309
|
// src/useValidateDestination.ts
|
|
907
|
-
var
|
|
908
|
-
var
|
|
2310
|
+
var import_connect_appkit_core20 = require("@naculus/connect-appkit-core");
|
|
2311
|
+
var import_vue34 = require("vue");
|
|
909
2312
|
function useValidateDestination(address) {
|
|
910
2313
|
return {
|
|
911
|
-
validation: (0,
|
|
2314
|
+
validation: (0, import_vue34.computed)(() => (0, import_connect_appkit_core20.validateDestination)((0, import_vue34.toValue)(address) ?? ""))
|
|
912
2315
|
};
|
|
913
2316
|
}
|
|
914
2317
|
|
|
915
2318
|
// src/useTokenBalance.ts
|
|
916
|
-
var
|
|
917
|
-
var
|
|
918
|
-
var
|
|
2319
|
+
var import_connect_appkit_core21 = require("@naculus/connect-appkit-core");
|
|
2320
|
+
var import_connect_core14 = require("@naculus/connect-core");
|
|
2321
|
+
var import_vue35 = require("vue");
|
|
919
2322
|
function tokensKey(tokens) {
|
|
920
2323
|
return tokens.map((t) => `${t.address.toLowerCase()}|${t.decimals}|${t.symbol}`).join(",");
|
|
921
2324
|
}
|
|
922
2325
|
function useTokenBalance(account, client, tokens, options = {}) {
|
|
923
|
-
const tokenBalances = (0,
|
|
924
|
-
const isFetching = (0,
|
|
925
|
-
const error = (0,
|
|
2326
|
+
const tokenBalances = (0, import_vue35.shallowRef)([]);
|
|
2327
|
+
const isFetching = (0, import_vue35.shallowRef)(false);
|
|
2328
|
+
const error = (0, import_vue35.shallowRef)(null);
|
|
926
2329
|
let generation = 0;
|
|
927
2330
|
let disposed = false;
|
|
928
2331
|
let timer = null;
|
|
929
2332
|
const refetch = async () => {
|
|
930
|
-
const reader = (0,
|
|
931
|
-
const address = (0,
|
|
932
|
-
const list = (0,
|
|
2333
|
+
const reader = (0, import_vue35.toValue)(client);
|
|
2334
|
+
const address = (0, import_connect_appkit_core21.bareEvmAddress)((0, import_vue35.toValue)(account));
|
|
2335
|
+
const list = (0, import_vue35.toValue)(tokens) ?? [];
|
|
933
2336
|
const own = ++generation;
|
|
934
2337
|
if (!reader || !address || list.length === 0) {
|
|
935
2338
|
tokenBalances.value = [];
|
|
@@ -945,7 +2348,7 @@ function useTokenBalance(account, client, tokens, options = {}) {
|
|
|
945
2348
|
try {
|
|
946
2349
|
const raw = await reader.readContract({
|
|
947
2350
|
address: token.address,
|
|
948
|
-
abi:
|
|
2351
|
+
abi: import_connect_core14.ERC20_MIN_ABI,
|
|
949
2352
|
functionName: "balanceOf",
|
|
950
2353
|
args: [address]
|
|
951
2354
|
});
|
|
@@ -953,7 +2356,7 @@ function useTokenBalance(account, client, tokens, options = {}) {
|
|
|
953
2356
|
return {
|
|
954
2357
|
...token,
|
|
955
2358
|
balance: value.toString(),
|
|
956
|
-
formatted: (0,
|
|
2359
|
+
formatted: (0, import_connect_core14.formatUnits)(value, token.decimals)
|
|
957
2360
|
};
|
|
958
2361
|
} catch {
|
|
959
2362
|
return { ...token, balance: null, formatted: null };
|
|
@@ -974,12 +2377,12 @@ function useTokenBalance(account, client, tokens, options = {}) {
|
|
|
974
2377
|
if (timer) clearInterval(timer);
|
|
975
2378
|
timer = null;
|
|
976
2379
|
};
|
|
977
|
-
(0,
|
|
2380
|
+
(0, import_vue35.watch)(
|
|
978
2381
|
[
|
|
979
|
-
() => (0,
|
|
980
|
-
() => (0,
|
|
981
|
-
() => tokensKey((0,
|
|
982
|
-
() => (0,
|
|
2382
|
+
() => (0, import_vue35.toValue)(account),
|
|
2383
|
+
() => (0, import_vue35.toValue)(client),
|
|
2384
|
+
() => tokensKey((0, import_vue35.toValue)(tokens) ?? []),
|
|
2385
|
+
() => (0, import_vue35.toValue)(options.refreshInterval) ?? 0
|
|
983
2386
|
],
|
|
984
2387
|
([, , , interval]) => {
|
|
985
2388
|
stopTimer();
|
|
@@ -988,7 +2391,7 @@ function useTokenBalance(account, client, tokens, options = {}) {
|
|
|
988
2391
|
},
|
|
989
2392
|
{ immediate: true }
|
|
990
2393
|
);
|
|
991
|
-
(0,
|
|
2394
|
+
(0, import_vue35.onScopeDispose)(() => {
|
|
992
2395
|
disposed = true;
|
|
993
2396
|
generation++;
|
|
994
2397
|
stopTimer();
|
|
@@ -1004,21 +2407,113 @@ function useTokenBalance(account, client, tokens, options = {}) {
|
|
|
1004
2407
|
};
|
|
1005
2408
|
}
|
|
1006
2409
|
|
|
2410
|
+
// src/useDelegate.ts
|
|
2411
|
+
var import_connect_appkit_core22 = require("@naculus/connect-appkit-core");
|
|
2412
|
+
var import_connect_core15 = require("@naculus/connect-core");
|
|
2413
|
+
var import_vue36 = require("vue");
|
|
2414
|
+
function useDelegate(options) {
|
|
2415
|
+
const result = (0, import_vue36.shallowRef)(null);
|
|
2416
|
+
const isPending = (0, import_vue36.shallowRef)(false);
|
|
2417
|
+
const error = (0, import_vue36.shallowRef)(null);
|
|
2418
|
+
let requestId = 0;
|
|
2419
|
+
let inFlight = false;
|
|
2420
|
+
let disposed = false;
|
|
2421
|
+
const fail = (cause) => {
|
|
2422
|
+
error.value = cause;
|
|
2423
|
+
return null;
|
|
2424
|
+
};
|
|
2425
|
+
const run = async (target, allowlist) => {
|
|
2426
|
+
if (inFlight) return fail(new Error("A delegation is already in progress"));
|
|
2427
|
+
const session = (0, import_vue36.toValue)(options.session);
|
|
2428
|
+
const account = (0, import_connect_appkit_core22.bareEvmAddress)((0, import_vue36.toValue)(options.account));
|
|
2429
|
+
const chainId = (0, import_vue36.toValue)(options.chainId);
|
|
2430
|
+
if (!session || !account || !chainId) {
|
|
2431
|
+
return fail(
|
|
2432
|
+
new import_connect_core15.WalletError("wallet_unavailable", "No connected EVM account")
|
|
2433
|
+
);
|
|
2434
|
+
}
|
|
2435
|
+
const reader = (0, import_vue36.toValue)(options.client);
|
|
2436
|
+
if (!reader || reader.chain?.id !== (0, import_connect_core15.eip155Reference)(chainId)) {
|
|
2437
|
+
return fail(
|
|
2438
|
+
new import_connect_core15.WalletError(
|
|
2439
|
+
"chain_mismatch",
|
|
2440
|
+
`No RPC client for ${chainId}; refusing to read the nonce elsewhere.`
|
|
2441
|
+
)
|
|
2442
|
+
);
|
|
2443
|
+
}
|
|
2444
|
+
const connector = (0, import_vue36.toValue)(options.connector) ?? {};
|
|
2445
|
+
const own = ++requestId;
|
|
2446
|
+
inFlight = true;
|
|
2447
|
+
isPending.value = true;
|
|
2448
|
+
error.value = null;
|
|
2449
|
+
result.value = null;
|
|
2450
|
+
try {
|
|
2451
|
+
const sent = await (0, import_connect_core15.delegateAccount)({
|
|
2452
|
+
connector,
|
|
2453
|
+
session,
|
|
2454
|
+
account,
|
|
2455
|
+
chainId,
|
|
2456
|
+
delegate: target,
|
|
2457
|
+
allowlist,
|
|
2458
|
+
getTransactionCount: (address, blockTag) => reader.getTransactionCount({ address, blockTag })
|
|
2459
|
+
});
|
|
2460
|
+
if (disposed || own !== requestId) return null;
|
|
2461
|
+
result.value = sent;
|
|
2462
|
+
return sent;
|
|
2463
|
+
} catch (cause) {
|
|
2464
|
+
if (disposed || own !== requestId) return null;
|
|
2465
|
+
return fail(
|
|
2466
|
+
cause instanceof Error ? cause : new Error("Failed to send delegation")
|
|
2467
|
+
);
|
|
2468
|
+
} finally {
|
|
2469
|
+
inFlight = false;
|
|
2470
|
+
if (!disposed && own === requestId) isPending.value = false;
|
|
2471
|
+
}
|
|
2472
|
+
};
|
|
2473
|
+
const reset = () => {
|
|
2474
|
+
requestId++;
|
|
2475
|
+
result.value = null;
|
|
2476
|
+
isPending.value = false;
|
|
2477
|
+
error.value = null;
|
|
2478
|
+
};
|
|
2479
|
+
(0, import_vue36.watch)(
|
|
2480
|
+
[
|
|
2481
|
+
() => (0, import_vue36.toValue)(options.session),
|
|
2482
|
+
() => (0, import_vue36.toValue)(options.account),
|
|
2483
|
+
() => (0, import_vue36.toValue)(options.chainId)
|
|
2484
|
+
],
|
|
2485
|
+
reset,
|
|
2486
|
+
{ flush: "sync" }
|
|
2487
|
+
);
|
|
2488
|
+
(0, import_vue36.onScopeDispose)(() => {
|
|
2489
|
+
disposed = true;
|
|
2490
|
+
requestId++;
|
|
2491
|
+
});
|
|
2492
|
+
return {
|
|
2493
|
+
delegate: (target) => run(target, (0, import_vue36.toValue)(options.allowlist)),
|
|
2494
|
+
revoke: () => run(import_connect_core15.REVOKE_DELEGATE, []),
|
|
2495
|
+
result,
|
|
2496
|
+
isPending,
|
|
2497
|
+
error,
|
|
2498
|
+
reset
|
|
2499
|
+
};
|
|
2500
|
+
}
|
|
2501
|
+
|
|
1007
2502
|
// src/useDelegation.ts
|
|
1008
|
-
var
|
|
1009
|
-
var
|
|
1010
|
-
var
|
|
2503
|
+
var import_connect_appkit_core23 = require("@naculus/connect-appkit-core");
|
|
2504
|
+
var import_connect_core16 = require("@naculus/connect-core");
|
|
2505
|
+
var import_vue37 = require("vue");
|
|
1011
2506
|
function useDelegation(account, client, chainId) {
|
|
1012
|
-
const status = (0,
|
|
1013
|
-
const isFetching = (0,
|
|
1014
|
-
const error = (0,
|
|
2507
|
+
const status = (0, import_vue37.shallowRef)(import_connect_core16.UNKNOWN_DELEGATION);
|
|
2508
|
+
const isFetching = (0, import_vue37.shallowRef)(false);
|
|
2509
|
+
const error = (0, import_vue37.shallowRef)(null);
|
|
1015
2510
|
let generation = 0;
|
|
1016
2511
|
let disposed = false;
|
|
1017
2512
|
const refetch = async () => {
|
|
1018
2513
|
const mine = ++generation;
|
|
1019
|
-
const reader = (0,
|
|
1020
|
-
const address = (0,
|
|
1021
|
-
status.value =
|
|
2514
|
+
const reader = (0, import_vue37.toValue)(client);
|
|
2515
|
+
const address = (0, import_connect_appkit_core23.bareEvmAddress)((0, import_vue37.toValue)(account));
|
|
2516
|
+
status.value = import_connect_core16.UNKNOWN_DELEGATION;
|
|
1022
2517
|
error.value = null;
|
|
1023
2518
|
if (!reader || !address) {
|
|
1024
2519
|
isFetching.value = false;
|
|
@@ -1028,31 +2523,31 @@ function useDelegation(account, client, chainId) {
|
|
|
1028
2523
|
try {
|
|
1029
2524
|
const code = await reader.getCode({ address });
|
|
1030
2525
|
if (!disposed && mine === generation) {
|
|
1031
|
-
status.value = (0,
|
|
2526
|
+
status.value = (0, import_connect_core16.readDelegation)(code ?? "0x");
|
|
1032
2527
|
}
|
|
1033
2528
|
} catch (cause) {
|
|
1034
2529
|
if (!disposed && mine === generation) {
|
|
1035
|
-
status.value =
|
|
2530
|
+
status.value = import_connect_core16.UNKNOWN_DELEGATION;
|
|
1036
2531
|
error.value = cause instanceof Error ? cause : new Error("Code read failed");
|
|
1037
2532
|
}
|
|
1038
2533
|
} finally {
|
|
1039
2534
|
if (!disposed && mine === generation) isFetching.value = false;
|
|
1040
2535
|
}
|
|
1041
2536
|
};
|
|
1042
|
-
(0,
|
|
1043
|
-
() =>
|
|
2537
|
+
(0, import_vue37.watch)(
|
|
2538
|
+
[() => (0, import_vue37.toValue)(account), () => (0, import_vue37.toValue)(client), () => (0, import_vue37.toValue)(chainId)],
|
|
1044
2539
|
() => {
|
|
1045
2540
|
void refetch();
|
|
1046
2541
|
},
|
|
1047
2542
|
{ immediate: true, flush: "sync" }
|
|
1048
2543
|
);
|
|
1049
|
-
(0,
|
|
2544
|
+
(0, import_vue37.onScopeDispose)(() => {
|
|
1050
2545
|
disposed = true;
|
|
1051
2546
|
generation++;
|
|
1052
2547
|
});
|
|
1053
2548
|
return {
|
|
1054
|
-
delegated: (0,
|
|
1055
|
-
delegate: (0,
|
|
2549
|
+
delegated: (0, import_vue37.computed)(() => status.value.delegated),
|
|
2550
|
+
delegate: (0, import_vue37.computed)(() => status.value.delegate),
|
|
1056
2551
|
isFetching,
|
|
1057
2552
|
error,
|
|
1058
2553
|
refetch
|
|
@@ -1060,19 +2555,19 @@ function useDelegation(account, client, chainId) {
|
|
|
1060
2555
|
}
|
|
1061
2556
|
|
|
1062
2557
|
// src/name-lookup.ts
|
|
1063
|
-
var
|
|
1064
|
-
var
|
|
2558
|
+
var import_connect_appkit_core24 = require("@naculus/connect-appkit-core");
|
|
2559
|
+
var import_vue38 = require("vue");
|
|
1065
2560
|
function useNameLookup(options) {
|
|
1066
|
-
const data = (0,
|
|
1067
|
-
const loading = (0,
|
|
1068
|
-
const error = (0,
|
|
2561
|
+
const data = (0, import_vue38.shallowRef)(null);
|
|
2562
|
+
const loading = (0, import_vue38.shallowRef)(false);
|
|
2563
|
+
const error = (0, import_vue38.shallowRef)(null);
|
|
1069
2564
|
let generation = 0;
|
|
1070
2565
|
let disposed = false;
|
|
1071
2566
|
const run = () => {
|
|
1072
|
-
const input = (0,
|
|
1073
|
-
const skip = (0,
|
|
1074
|
-
const scope = (0,
|
|
1075
|
-
const config = (0,
|
|
2567
|
+
const input = (0, import_vue38.toValue)(options.input).trim();
|
|
2568
|
+
const skip = (0, import_vue38.toValue)(options.skip) ?? false;
|
|
2569
|
+
const scope = (0, import_vue38.toValue)(options.scope);
|
|
2570
|
+
const config = (0, import_vue38.toValue)(options.resolverConfig);
|
|
1076
2571
|
const mine = ++generation;
|
|
1077
2572
|
if (!input || skip) {
|
|
1078
2573
|
data.value = null;
|
|
@@ -1083,7 +2578,7 @@ function useNameLookup(options) {
|
|
|
1083
2578
|
data.value = null;
|
|
1084
2579
|
loading.value = true;
|
|
1085
2580
|
error.value = null;
|
|
1086
|
-
Promise.resolve().then(() => options.query((0,
|
|
2581
|
+
Promise.resolve().then(() => options.query((0, import_connect_appkit_core24.getResolver)(config), input, scope)).then((result) => {
|
|
1087
2582
|
if (disposed || mine !== generation) return;
|
|
1088
2583
|
data.value = result;
|
|
1089
2584
|
loading.value = false;
|
|
@@ -1094,23 +2589,23 @@ function useNameLookup(options) {
|
|
|
1094
2589
|
loading.value = false;
|
|
1095
2590
|
});
|
|
1096
2591
|
};
|
|
1097
|
-
(0,
|
|
2592
|
+
(0, import_vue38.watch)(
|
|
1098
2593
|
() => [
|
|
1099
|
-
(0,
|
|
1100
|
-
(0,
|
|
1101
|
-
(0,
|
|
1102
|
-
(0,
|
|
2594
|
+
(0, import_vue38.toValue)(options.input),
|
|
2595
|
+
(0, import_vue38.toValue)(options.skip),
|
|
2596
|
+
(0, import_vue38.toValue)(options.scope),
|
|
2597
|
+
(0, import_vue38.toValue)(options.resolverConfig)
|
|
1103
2598
|
],
|
|
1104
2599
|
run,
|
|
1105
2600
|
{ immediate: true, flush: "sync", deep: true }
|
|
1106
2601
|
);
|
|
1107
|
-
(0,
|
|
2602
|
+
(0, import_vue38.onScopeDispose)(() => {
|
|
1108
2603
|
disposed = true;
|
|
1109
2604
|
generation++;
|
|
1110
2605
|
});
|
|
1111
2606
|
return {
|
|
1112
2607
|
data,
|
|
1113
|
-
isLoading: (0,
|
|
2608
|
+
isLoading: (0, import_vue38.computed)(() => loading.value),
|
|
1114
2609
|
error,
|
|
1115
2610
|
refetch: run
|
|
1116
2611
|
};
|
|
@@ -1138,21 +2633,21 @@ function useLookupAddress(address, options) {
|
|
|
1138
2633
|
}
|
|
1139
2634
|
|
|
1140
2635
|
// src/useSolanaAccount.ts
|
|
1141
|
-
var
|
|
2636
|
+
var import_vue39 = require("vue");
|
|
1142
2637
|
function useSolanaAccount(accounts, connected) {
|
|
1143
|
-
const isConnected = (0,
|
|
1144
|
-
const caip10 = (0,
|
|
1145
|
-
() => isConnected.value ? ((0,
|
|
2638
|
+
const isConnected = (0, import_vue39.computed)(() => (0, import_vue39.toValue)(connected));
|
|
2639
|
+
const caip10 = (0, import_vue39.computed)(
|
|
2640
|
+
() => isConnected.value ? ((0, import_vue39.toValue)(accounts) ?? []).find(
|
|
1146
2641
|
(account) => account.startsWith("solana:")
|
|
1147
2642
|
) ?? null : null
|
|
1148
2643
|
);
|
|
1149
|
-
const parts = (0,
|
|
2644
|
+
const parts = (0, import_vue39.computed)(() => caip10.value?.split(":") ?? []);
|
|
1150
2645
|
return {
|
|
1151
|
-
address: (0,
|
|
2646
|
+
address: (0, import_vue39.computed)(
|
|
1152
2647
|
() => parts.value.length >= 3 ? parts.value.at(-1) ?? null : null
|
|
1153
2648
|
),
|
|
1154
2649
|
caip10,
|
|
1155
|
-
chainId: (0,
|
|
2650
|
+
chainId: (0, import_vue39.computed)(
|
|
1156
2651
|
() => parts.value.length >= 3 ? parts.value.slice(0, -1).join(":") : null
|
|
1157
2652
|
),
|
|
1158
2653
|
isConnected
|
|
@@ -1160,35 +2655,35 @@ function useSolanaAccount(accounts, connected) {
|
|
|
1160
2655
|
}
|
|
1161
2656
|
|
|
1162
2657
|
// src/useChain.ts
|
|
1163
|
-
var
|
|
1164
|
-
var
|
|
2658
|
+
var import_connect_appkit_core25 = require("@naculus/connect-appkit-core");
|
|
2659
|
+
var import_vue40 = require("vue");
|
|
1165
2660
|
function useChain(chains, chainId) {
|
|
1166
|
-
const list = (0,
|
|
1167
|
-
const id = (0,
|
|
1168
|
-
const currentChain = (0,
|
|
2661
|
+
const list = (0, import_vue40.computed)(() => (0, import_vue40.toValue)(chains) ?? []);
|
|
2662
|
+
const id = (0, import_vue40.computed)(() => (0, import_vue40.toValue)(chainId) ?? null);
|
|
2663
|
+
const currentChain = (0, import_vue40.computed)(() => (0, import_connect_appkit_core25.resolveChain)(list.value, id.value));
|
|
1169
2664
|
return {
|
|
1170
2665
|
currentChain,
|
|
1171
|
-
chainInfo: (0,
|
|
1172
|
-
availableChains: (0,
|
|
1173
|
-
currentChainNumber: (0,
|
|
1174
|
-
() => currentChain.value ? (0,
|
|
2666
|
+
chainInfo: (0, import_vue40.computed)(() => (0, import_connect_appkit_core25.describeChain)(list.value, id.value)),
|
|
2667
|
+
availableChains: (0, import_vue40.computed)(() => (0, import_connect_appkit_core25.chainsForNamespace)(list.value, id.value)),
|
|
2668
|
+
currentChainNumber: (0, import_vue40.computed)(
|
|
2669
|
+
() => currentChain.value ? (0, import_connect_appkit_core25.chainNumber)(currentChain.value) : null
|
|
1175
2670
|
),
|
|
1176
|
-
namespace: (0,
|
|
1177
|
-
() => currentChain.value ? (0,
|
|
2671
|
+
namespace: (0, import_vue40.computed)(
|
|
2672
|
+
() => currentChain.value ? (0, import_connect_appkit_core25.chainNamespace)(currentChain.value) : null
|
|
1178
2673
|
)
|
|
1179
2674
|
};
|
|
1180
2675
|
}
|
|
1181
2676
|
|
|
1182
2677
|
// src/usePassphraseGate.ts
|
|
1183
|
-
var
|
|
2678
|
+
var import_vue41 = require("vue");
|
|
1184
2679
|
function usePassphraseGate(gate) {
|
|
1185
|
-
const request = (0,
|
|
2680
|
+
const request = (0, import_vue41.shallowRef)(gate.getSnapshot());
|
|
1186
2681
|
const unsubscribe = gate.subscribe(() => {
|
|
1187
2682
|
request.value = gate.getSnapshot();
|
|
1188
2683
|
});
|
|
1189
|
-
(0,
|
|
2684
|
+
(0, import_vue41.onScopeDispose)(unsubscribe);
|
|
1190
2685
|
return {
|
|
1191
|
-
request: (0,
|
|
2686
|
+
request: (0, import_vue41.readonly)(request),
|
|
1192
2687
|
submit: (passphrase) => gate.submit(passphrase),
|
|
1193
2688
|
cancel: (reason) => gate.cancel(reason),
|
|
1194
2689
|
forget: (reason) => gate.forget(reason)
|
|
@@ -1196,17 +2691,17 @@ function usePassphraseGate(gate) {
|
|
|
1196
2691
|
}
|
|
1197
2692
|
|
|
1198
2693
|
// src/useSolanaBalance.ts
|
|
1199
|
-
var
|
|
1200
|
-
var
|
|
2694
|
+
var import_connect_core17 = require("@naculus/connect-core");
|
|
2695
|
+
var import_vue42 = require("vue");
|
|
1201
2696
|
function useSolanaBalance(address, rpcUrl) {
|
|
1202
|
-
const balance = (0,
|
|
1203
|
-
const isFetching = (0,
|
|
1204
|
-
const error = (0,
|
|
2697
|
+
const balance = (0, import_vue42.shallowRef)(null);
|
|
2698
|
+
const isFetching = (0, import_vue42.ref)(false);
|
|
2699
|
+
const error = (0, import_vue42.shallowRef)(null);
|
|
1205
2700
|
let generation = 0;
|
|
1206
2701
|
let disposed = false;
|
|
1207
2702
|
const refetch = async () => {
|
|
1208
|
-
const addr = (0,
|
|
1209
|
-
const url = (0,
|
|
2703
|
+
const addr = (0, import_vue42.toValue)(address);
|
|
2704
|
+
const url = (0, import_vue42.toValue)(rpcUrl);
|
|
1210
2705
|
if (!addr || !url) {
|
|
1211
2706
|
balance.value = null;
|
|
1212
2707
|
return;
|
|
@@ -1215,7 +2710,7 @@ function useSolanaBalance(address, rpcUrl) {
|
|
|
1215
2710
|
isFetching.value = true;
|
|
1216
2711
|
error.value = null;
|
|
1217
2712
|
try {
|
|
1218
|
-
const next = await (0,
|
|
2713
|
+
const next = await (0, import_connect_core17.getSolanaBalance)(url, addr);
|
|
1219
2714
|
if (disposed || own !== generation) return;
|
|
1220
2715
|
balance.value = next;
|
|
1221
2716
|
} catch (err) {
|
|
@@ -1226,25 +2721,25 @@ function useSolanaBalance(address, rpcUrl) {
|
|
|
1226
2721
|
if (!disposed && own === generation) isFetching.value = false;
|
|
1227
2722
|
}
|
|
1228
2723
|
};
|
|
1229
|
-
(0,
|
|
1230
|
-
(0,
|
|
1231
|
-
(0,
|
|
2724
|
+
(0, import_vue42.watchEffect)(() => {
|
|
2725
|
+
(0, import_vue42.toValue)(address);
|
|
2726
|
+
(0, import_vue42.toValue)(rpcUrl);
|
|
1232
2727
|
void refetch();
|
|
1233
2728
|
});
|
|
1234
|
-
(0,
|
|
2729
|
+
(0, import_vue42.onScopeDispose)(() => {
|
|
1235
2730
|
disposed = true;
|
|
1236
2731
|
});
|
|
1237
2732
|
return { balance, isFetching, error, refetch };
|
|
1238
2733
|
}
|
|
1239
2734
|
|
|
1240
2735
|
// src/useLastTx.ts
|
|
1241
|
-
var
|
|
2736
|
+
var import_vue43 = require("vue");
|
|
1242
2737
|
function useLastTx(monitor) {
|
|
1243
|
-
const lastTx = (0,
|
|
1244
|
-
const lastConfirmedTx = (0,
|
|
1245
|
-
const lastFailedTx = (0,
|
|
1246
|
-
(0,
|
|
1247
|
-
() => (0,
|
|
2738
|
+
const lastTx = (0, import_vue43.shallowRef)(null);
|
|
2739
|
+
const lastConfirmedTx = (0, import_vue43.shallowRef)(null);
|
|
2740
|
+
const lastFailedTx = (0, import_vue43.shallowRef)(null);
|
|
2741
|
+
(0, import_vue43.watch)(
|
|
2742
|
+
() => (0, import_vue43.toValue)(monitor),
|
|
1248
2743
|
(activeMonitor, _previous, onCleanup) => {
|
|
1249
2744
|
if (!activeMonitor) return;
|
|
1250
2745
|
const recordLatest = (entry) => {
|
|
@@ -1282,15 +2777,15 @@ function useLastTx(monitor) {
|
|
|
1282
2777
|
}
|
|
1283
2778
|
|
|
1284
2779
|
// src/useTxHistory.ts
|
|
1285
|
-
var
|
|
2780
|
+
var import_vue44 = require("vue");
|
|
1286
2781
|
function useTxHistory(address, chainId, monitor) {
|
|
1287
|
-
const entries = (0,
|
|
1288
|
-
const isLoading = (0,
|
|
1289
|
-
const error = (0,
|
|
2782
|
+
const entries = (0, import_vue44.shallowRef)([]);
|
|
2783
|
+
const isLoading = (0, import_vue44.shallowRef)(false);
|
|
2784
|
+
const error = (0, import_vue44.shallowRef)(null);
|
|
1290
2785
|
let generation = 0;
|
|
1291
2786
|
const refresh = async () => {
|
|
1292
2787
|
const mine = ++generation;
|
|
1293
|
-
const activeMonitor = (0,
|
|
2788
|
+
const activeMonitor = (0, import_vue44.toValue)(monitor);
|
|
1294
2789
|
if (!activeMonitor) {
|
|
1295
2790
|
entries.value = [];
|
|
1296
2791
|
isLoading.value = false;
|
|
@@ -1301,8 +2796,8 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
1301
2796
|
error.value = null;
|
|
1302
2797
|
try {
|
|
1303
2798
|
const result = await activeMonitor.getTxHistory(
|
|
1304
|
-
(0,
|
|
1305
|
-
(0,
|
|
2799
|
+
(0, import_vue44.toValue)(address) ?? void 0,
|
|
2800
|
+
(0, import_vue44.toValue)(chainId) ?? void 0
|
|
1306
2801
|
);
|
|
1307
2802
|
if (mine === generation) entries.value = result;
|
|
1308
2803
|
} catch (err) {
|
|
@@ -1312,8 +2807,8 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
1312
2807
|
if (mine === generation) isLoading.value = false;
|
|
1313
2808
|
}
|
|
1314
2809
|
};
|
|
1315
|
-
(0,
|
|
1316
|
-
() =>
|
|
2810
|
+
(0, import_vue44.watch)(
|
|
2811
|
+
[() => (0, import_vue44.toValue)(monitor), () => (0, import_vue44.toValue)(address), () => (0, import_vue44.toValue)(chainId)],
|
|
1317
2812
|
([activeMonitor], _previous, onCleanup) => {
|
|
1318
2813
|
if (!activeMonitor) {
|
|
1319
2814
|
void refresh();
|
|
@@ -1333,7 +2828,7 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
1333
2828
|
isLoading,
|
|
1334
2829
|
error,
|
|
1335
2830
|
refresh,
|
|
1336
|
-
summary: (0,
|
|
2831
|
+
summary: (0, import_vue44.computed)(() => ({
|
|
1337
2832
|
pending: entries.value.filter((item) => item.status === "pending").length,
|
|
1338
2833
|
confirmed: entries.value.filter((item) => item.status === "confirmed").length,
|
|
1339
2834
|
failed: entries.value.filter((item) => item.status === "failed").length
|
|
@@ -1342,17 +2837,17 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
1342
2837
|
}
|
|
1343
2838
|
|
|
1344
2839
|
// src/useTxMonitor.ts
|
|
1345
|
-
var
|
|
2840
|
+
var import_vue45 = require("vue");
|
|
1346
2841
|
function useTxMonitor(hash, chainId, monitor) {
|
|
1347
|
-
const entry = (0,
|
|
1348
|
-
const isLoading = (0,
|
|
1349
|
-
const isWatching = (0,
|
|
1350
|
-
const error = (0,
|
|
2842
|
+
const entry = (0, import_vue45.shallowRef)(null);
|
|
2843
|
+
const isLoading = (0, import_vue45.shallowRef)(false);
|
|
2844
|
+
const isWatching = (0, import_vue45.shallowRef)(false);
|
|
2845
|
+
const error = (0, import_vue45.shallowRef)(null);
|
|
1351
2846
|
let generation = 0;
|
|
1352
2847
|
const refresh = async () => {
|
|
1353
|
-
const activeMonitor = (0,
|
|
1354
|
-
const activeHash = (0,
|
|
1355
|
-
const activeChainId = (0,
|
|
2848
|
+
const activeMonitor = (0, import_vue45.toValue)(monitor);
|
|
2849
|
+
const activeHash = (0, import_vue45.toValue)(hash);
|
|
2850
|
+
const activeChainId = (0, import_vue45.toValue)(chainId);
|
|
1356
2851
|
if (!activeMonitor || !activeHash) return;
|
|
1357
2852
|
isLoading.value = true;
|
|
1358
2853
|
error.value = null;
|
|
@@ -1370,15 +2865,15 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
1370
2865
|
}
|
|
1371
2866
|
};
|
|
1372
2867
|
const stopWatching = () => {
|
|
1373
|
-
const activeMonitor = (0,
|
|
1374
|
-
const activeHash = (0,
|
|
1375
|
-
const activeChainId = (0,
|
|
2868
|
+
const activeMonitor = (0, import_vue45.toValue)(monitor);
|
|
2869
|
+
const activeHash = (0, import_vue45.toValue)(hash);
|
|
2870
|
+
const activeChainId = (0, import_vue45.toValue)(chainId);
|
|
1376
2871
|
if (!activeMonitor || !activeHash) return;
|
|
1377
2872
|
activeMonitor.stopWatching(activeHash, activeChainId ?? void 0);
|
|
1378
2873
|
isWatching.value = false;
|
|
1379
2874
|
};
|
|
1380
|
-
(0,
|
|
1381
|
-
() =>
|
|
2875
|
+
(0, import_vue45.watch)(
|
|
2876
|
+
[() => (0, import_vue45.toValue)(monitor), () => (0, import_vue45.toValue)(hash), () => (0, import_vue45.toValue)(chainId)],
|
|
1382
2877
|
([activeMonitor, activeHash, activeChainId], _previous, onCleanup) => {
|
|
1383
2878
|
const mine = ++generation;
|
|
1384
2879
|
if (!activeMonitor || !activeHash || !activeChainId) {
|
|
@@ -1418,7 +2913,7 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
1418
2913
|
);
|
|
1419
2914
|
return {
|
|
1420
2915
|
entry,
|
|
1421
|
-
status: (0,
|
|
2916
|
+
status: (0, import_vue45.computed)(() => entry.value?.status ?? "idle"),
|
|
1422
2917
|
isLoading,
|
|
1423
2918
|
isWatching,
|
|
1424
2919
|
error,
|
|
@@ -1428,19 +2923,19 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
1428
2923
|
}
|
|
1429
2924
|
|
|
1430
2925
|
// src/useCapabilities.ts
|
|
1431
|
-
var
|
|
1432
|
-
var
|
|
2926
|
+
var import_connect_appkit_core26 = require("@naculus/connect-appkit-core");
|
|
2927
|
+
var import_vue46 = require("vue");
|
|
1433
2928
|
function useCapabilities(client, session, chainId) {
|
|
1434
|
-
const capabilities = (0,
|
|
2929
|
+
const capabilities = (0, import_vue46.shallowRef)(
|
|
1435
2930
|
null
|
|
1436
2931
|
);
|
|
1437
|
-
const isFetching = (0,
|
|
1438
|
-
const error = (0,
|
|
2932
|
+
const isFetching = (0, import_vue46.shallowRef)(false);
|
|
2933
|
+
const error = (0, import_vue46.shallowRef)(null);
|
|
1439
2934
|
let generation = 0;
|
|
1440
2935
|
const refetch = async () => {
|
|
1441
2936
|
const mine = ++generation;
|
|
1442
|
-
const activeClient = (0,
|
|
1443
|
-
const activeSession = (0,
|
|
2937
|
+
const activeClient = (0, import_vue46.toValue)(client);
|
|
2938
|
+
const activeSession = (0, import_vue46.toValue)(session);
|
|
1444
2939
|
if (!activeClient?.getCapabilities || !activeSession) {
|
|
1445
2940
|
capabilities.value = null;
|
|
1446
2941
|
isFetching.value = false;
|
|
@@ -1452,7 +2947,7 @@ function useCapabilities(client, session, chainId) {
|
|
|
1452
2947
|
try {
|
|
1453
2948
|
const raw = await activeClient.getCapabilities(activeSession);
|
|
1454
2949
|
if (mine !== generation) return;
|
|
1455
|
-
capabilities.value = (0,
|
|
2950
|
+
capabilities.value = (0, import_connect_appkit_core26.normalizeCapabilities)(raw);
|
|
1456
2951
|
} catch (err) {
|
|
1457
2952
|
if (mine !== generation) return;
|
|
1458
2953
|
capabilities.value = null;
|
|
@@ -1461,18 +2956,18 @@ function useCapabilities(client, session, chainId) {
|
|
|
1461
2956
|
if (mine === generation) isFetching.value = false;
|
|
1462
2957
|
}
|
|
1463
2958
|
};
|
|
1464
|
-
(0,
|
|
1465
|
-
void (0,
|
|
1466
|
-
void (0,
|
|
2959
|
+
(0, import_vue46.watchEffect)(() => {
|
|
2960
|
+
void (0, import_vue46.toValue)(client);
|
|
2961
|
+
void (0, import_vue46.toValue)(session);
|
|
1467
2962
|
void refetch();
|
|
1468
2963
|
});
|
|
1469
2964
|
return {
|
|
1470
2965
|
capabilities,
|
|
1471
|
-
current: (0,
|
|
1472
|
-
() => (0,
|
|
2966
|
+
current: (0, import_vue46.computed)(
|
|
2967
|
+
() => (0, import_connect_appkit_core26.selectChainCapabilities)(capabilities.value, (0, import_vue46.toValue)(chainId))
|
|
1473
2968
|
),
|
|
1474
|
-
atomic: (0,
|
|
1475
|
-
() => (0,
|
|
2969
|
+
atomic: (0, import_vue46.computed)(
|
|
2970
|
+
() => (0, import_connect_appkit_core26.atomicSupportFor)(capabilities.value, (0, import_vue46.toValue)(chainId))
|
|
1476
2971
|
),
|
|
1477
2972
|
isFetching,
|
|
1478
2973
|
error,
|
|
@@ -1481,18 +2976,18 @@ function useCapabilities(client, session, chainId) {
|
|
|
1481
2976
|
}
|
|
1482
2977
|
|
|
1483
2978
|
// src/useSolanaRoles.ts
|
|
1484
|
-
var
|
|
1485
|
-
var
|
|
2979
|
+
var import_connect_appkit_core27 = require("@naculus/connect-appkit-core");
|
|
2980
|
+
var import_vue47 = require("vue");
|
|
1486
2981
|
function useSolanaRoles(connector, session) {
|
|
1487
|
-
const state = (0,
|
|
1488
|
-
() => (0,
|
|
2982
|
+
const state = (0, import_vue47.computed)(
|
|
2983
|
+
() => (0, import_connect_appkit_core27.readSolanaRoles)((0, import_vue47.toValue)(connector), (0, import_vue47.toValue)(session))
|
|
1489
2984
|
);
|
|
1490
2985
|
return {
|
|
1491
|
-
roles: (0,
|
|
1492
|
-
absence: (0,
|
|
1493
|
-
identity: (0,
|
|
1494
|
-
signer: (0,
|
|
1495
|
-
payer: (0,
|
|
2986
|
+
roles: (0, import_vue47.computed)(() => state.value.roles),
|
|
2987
|
+
absence: (0, import_vue47.computed)(() => state.value.absence),
|
|
2988
|
+
identity: (0, import_vue47.computed)(() => state.value.roles?.identity ?? null),
|
|
2989
|
+
signer: (0, import_vue47.computed)(() => state.value.roles?.signer ?? null),
|
|
2990
|
+
payer: (0, import_vue47.computed)(() => state.value.roles?.payer ?? null)
|
|
1496
2991
|
};
|
|
1497
2992
|
}
|
|
1498
2993
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1532,25 +3027,50 @@ function useSolanaRoles(connector, session) {
|
|
|
1532
3027
|
useChain,
|
|
1533
3028
|
useCompareCosts,
|
|
1534
3029
|
useConnect,
|
|
3030
|
+
useCreateSessionKey,
|
|
3031
|
+
useDelegate,
|
|
1535
3032
|
useDelegation,
|
|
3033
|
+
useDelegationPolicy,
|
|
1536
3034
|
useDisconnect,
|
|
3035
|
+
useERC20Approve,
|
|
3036
|
+
useERC20Transfer,
|
|
3037
|
+
useERC20TransferSimulation,
|
|
3038
|
+
useEmbeddedWallet,
|
|
3039
|
+
useExecuteCalls,
|
|
1537
3040
|
useExecuteRoute,
|
|
1538
3041
|
useLastTx,
|
|
1539
3042
|
useLookupAddress,
|
|
1540
3043
|
useNotification,
|
|
1541
3044
|
usePassphraseGate,
|
|
1542
3045
|
useResolveName,
|
|
3046
|
+
useRevokeSession,
|
|
1543
3047
|
useRouteQuote,
|
|
3048
|
+
useSIWxLogin,
|
|
3049
|
+
useSIWxSession,
|
|
3050
|
+
useSendCalls,
|
|
3051
|
+
useSendTransaction,
|
|
3052
|
+
useSendUserOperation,
|
|
3053
|
+
useSendWithSession,
|
|
1544
3054
|
useSession,
|
|
3055
|
+
useSessionKeys,
|
|
3056
|
+
useSignInWithEthereum,
|
|
3057
|
+
useSignInWithX,
|
|
3058
|
+
useSignMessage,
|
|
3059
|
+
useSimulateTransfer,
|
|
3060
|
+
useSiwxAuthSession,
|
|
3061
|
+
useSmartAccount,
|
|
1545
3062
|
useSolanaAccount,
|
|
1546
3063
|
useSolanaBalance,
|
|
1547
3064
|
useSolanaRoles,
|
|
3065
|
+
useSolanaTransaction,
|
|
1548
3066
|
useSwitchChain,
|
|
1549
3067
|
useTokenBalance,
|
|
1550
3068
|
useTokenList,
|
|
1551
3069
|
useTokenSearch,
|
|
3070
|
+
useTransactionSimulation,
|
|
1552
3071
|
useTxHistory,
|
|
1553
3072
|
useTxMonitor,
|
|
3073
|
+
useUserOpStatus,
|
|
1554
3074
|
useValidateDestination
|
|
1555
3075
|
});
|
|
1556
3076
|
//# sourceMappingURL=index.cjs.map
|