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