@vue-solana/vue 2.6.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +36 -47
- package/dist/shared/vue.1Qwco2kv.mjs +33 -0
- package/dist/shared/vue.BFSboXMB.mjs +17 -0
- package/dist/shared/vue.BGGixph-.d.mts +5 -0
- package/dist/shared/vue.BGGixph-.d.ts +5 -0
- package/dist/shared/{vue.CbJFnho-.mjs → vue.BNJTXSnQ.mjs} +17 -70
- package/dist/shared/{vue.BINkrA8h.mjs → vue.BwBqla_n.mjs} +16 -26
- package/dist/shared/vue.BxtOHzY_.mjs +27 -0
- package/dist/shared/vue.C1JbUTpJ.mjs +66 -0
- package/dist/shared/vue.C9OOmvkD.mjs +36 -0
- package/dist/shared/vue.CGv0ip3w.mjs +52 -0
- package/dist/shared/vue.CaAgH2Xt.mjs +51 -0
- package/dist/shared/{vue.Dyi1OCI1.mjs → vue.CjSw0Hh1.mjs} +3 -9
- package/dist/shared/vue.CsFY1mfz.mjs +29 -0
- package/dist/shared/vue.CvenSbZZ.mjs +27 -0
- package/dist/shared/{vue.BDNOyiGZ.mjs → vue.D5pqR5Fa.mjs} +9 -12
- package/dist/shared/vue.DNKD6jqM.mjs +22 -0
- package/dist/shared/vue.DlihC5GG.mjs +38 -0
- package/dist/shared/vue.XlfH_nkc.mjs +32 -0
- package/dist/shared/vue.hG_FieA3.mjs +37 -0
- package/dist/shared/vue.o98pAmDg.mjs +40 -0
- package/dist/swr.mjs +22 -76
- package/dist/useAccountInfo.d.mts +4 -4
- package/dist/useAccountInfo.d.ts +4 -4
- package/dist/useAccountInfo.mjs +5 -4
- package/dist/useBalance.d.mts +4 -4
- package/dist/useBalance.d.ts +4 -4
- package/dist/useBalance.mjs +5 -4
- package/dist/usePlanTransaction.d.mts +12 -13
- package/dist/usePlanTransaction.d.ts +12 -13
- package/dist/usePlanTransaction.mjs +2 -1
- package/dist/usePlanTransactions.d.mts +2 -1
- package/dist/usePlanTransactions.d.ts +2 -1
- package/dist/usePlanTransactions.mjs +2 -1
- package/dist/useProgramAccounts.d.mts +5 -15
- package/dist/useProgramAccounts.d.ts +5 -15
- package/dist/useProgramAccounts.mjs +5 -4
- package/dist/useSendTransaction.d.mts +11 -12
- package/dist/useSendTransaction.d.ts +11 -12
- package/dist/useSendTransaction.mjs +2 -1
- package/dist/useSendTransactions.d.mts +2 -1
- package/dist/useSendTransactions.d.ts +2 -1
- package/dist/useSendTransactions.mjs +2 -1
- package/dist/useSignAndSendTransaction.d.mts +1 -1
- package/dist/useSignAndSendTransaction.d.ts +1 -1
- package/dist/useSignAndSendTransaction.mjs +3 -2
- package/dist/useSignAndSendTransactions.d.mts +2 -2
- package/dist/useSignAndSendTransactions.d.ts +2 -2
- package/dist/useSignAndSendTransactions.mjs +2 -1
- package/dist/useSignIn.d.mts +4 -4
- package/dist/useSignIn.d.ts +4 -4
- package/dist/useSignIn.mjs +3 -2
- package/dist/useSignMessage.d.mts +4 -4
- package/dist/useSignMessage.d.ts +4 -4
- package/dist/useSignMessage.mjs +3 -2
- package/dist/useSignTransactions.d.mts +4 -4
- package/dist/useSignTransactions.d.ts +4 -4
- package/dist/useSignTransactions.mjs +3 -2
- package/dist/useSubscription.mjs +1 -1
- package/dist/useTokenAccounts.d.mts +4 -4
- package/dist/useTokenAccounts.d.ts +4 -4
- package/dist/useTokenAccounts.mjs +5 -4
- package/dist/useTokenBalance.d.mts +9 -7
- package/dist/useTokenBalance.d.ts +9 -7
- package/dist/useTokenBalance.mjs +4 -3
- package/dist/useTrackedData.mjs +1 -1
- package/dist/useTransactionConfirmation.d.mts +4 -4
- package/dist/useTransactionConfirmation.d.ts +4 -4
- package/dist/useTransactionConfirmation.mjs +3 -2
- package/package.json +38 -75
- package/dist/buffer-polyfill.cjs +0 -8
- package/dist/buffer-polyfill.d.cts +0 -2
- package/dist/index.cjs +0 -452
- package/dist/index.d.cts +0 -62
- package/dist/kit.cjs +0 -16
- package/dist/kit.d.cts +0 -1
- package/dist/shared/vue.4C5kX4fE.cjs +0 -36
- package/dist/shared/vue.9TPxZPMf.cjs +0 -59
- package/dist/shared/vue.B4eMoJT2.cjs +0 -36
- package/dist/shared/vue.B6ainw2G.cjs +0 -63
- package/dist/shared/vue.BD6Gm1nl.mjs +0 -74
- package/dist/shared/vue.BGxz4dru.cjs +0 -98
- package/dist/shared/vue.BIxphCAq.cjs +0 -10
- package/dist/shared/vue.BOpgWr43.mjs +0 -70
- package/dist/shared/vue.BQRpjwKl.mjs +0 -80
- package/dist/shared/vue.BVaMoz9y.cjs +0 -9
- package/dist/shared/vue.Bk5xjlUx.cjs +0 -61
- package/dist/shared/vue.Bwd1sGAM.cjs +0 -72
- package/dist/shared/vue.ByxbBC3y.mjs +0 -57
- package/dist/shared/vue.C13umiQi.mjs +0 -85
- package/dist/shared/vue.CIs8QhCw.cjs +0 -132
- package/dist/shared/vue.CMohL_Cz.mjs +0 -58
- package/dist/shared/vue.CWZSMVnB.cjs +0 -84
- package/dist/shared/vue.Co5rj-I6.mjs +0 -118
- package/dist/shared/vue.CoaIWGPT.cjs +0 -38
- package/dist/shared/vue.CrkK_T15.cjs +0 -86
- package/dist/shared/vue.D-qi8PSL.cjs +0 -82
- package/dist/shared/vue.D3Y0PWbF.mjs +0 -71
- package/dist/shared/vue.D5U1yLG3.mjs +0 -83
- package/dist/shared/vue.DAg5wC1G.cjs +0 -76
- package/dist/shared/vue.DAthhH4D.mjs +0 -118
- package/dist/shared/vue.DDbVk0Zh.cjs +0 -180
- package/dist/shared/vue.DE3emjSF.cjs +0 -48
- package/dist/shared/vue.DEHxNvUX.cjs +0 -7
- package/dist/shared/vue.DFaMJLAQ.cjs +0 -60
- package/dist/shared/vue.DKoM8jIV.cjs +0 -121
- package/dist/shared/vue.DKyQ7J67.cjs +0 -15
- package/dist/shared/vue.DL3z5PxP.d.cts +0 -21
- package/dist/shared/vue.DNxOpDXz.cjs +0 -12
- package/dist/shared/vue.Di7yjJ-R.cjs +0 -87
- package/dist/shared/vue.Dn3KLJZH.cjs +0 -121
- package/dist/shared/vue.DxM45azl.cjs +0 -173
- package/dist/shared/vue.E_npPFoV.cjs +0 -67
- package/dist/shared/vue.FiMmnMHr.cjs +0 -20
- package/dist/shared/vue.JUWqu6kD.mjs +0 -61
- package/dist/shared/vue.Sbbm9JSu.cjs +0 -74
- package/dist/shared/vue.ZuUCEEab.cjs +0 -103
- package/dist/shared/vue.l3UCdN7z.cjs +0 -111
- package/dist/shared/vue.ldvmk9NM.cjs +0 -45
- package/dist/swr.cjs +0 -136
- package/dist/swr.d.cts +0 -41
- package/dist/useAccountInfo.cjs +0 -15
- package/dist/useAccountInfo.d.cts +0 -24
- package/dist/useAction.cjs +0 -9
- package/dist/useAction.d.cts +0 -45
- package/dist/useAirdrop.cjs +0 -14
- package/dist/useAirdrop.d.cts +0 -27
- package/dist/useBalance.cjs +0 -14
- package/dist/useBalance.d.cts +0 -15
- package/dist/useClientCapability.cjs +0 -12
- package/dist/useClientCapability.d.cts +0 -39
- package/dist/useConnection.cjs +0 -11
- package/dist/useConnection.d.cts +0 -46
- package/dist/useIdentity.cjs +0 -12
- package/dist/useIdentity.d.cts +0 -3
- package/dist/usePayer.cjs +0 -13
- package/dist/usePayer.d.cts +0 -18
- package/dist/usePlanTransaction.cjs +0 -14
- package/dist/usePlanTransaction.d.cts +0 -45
- package/dist/usePlanTransactions.cjs +0 -13
- package/dist/usePlanTransactions.d.cts +0 -4
- package/dist/useProgramAccounts.cjs +0 -15
- package/dist/useProgramAccounts.d.cts +0 -55
- package/dist/useRequest.cjs +0 -11
- package/dist/useRequest.d.cts +0 -73
- package/dist/useRpc.cjs +0 -10
- package/dist/useRpc.d.cts +0 -55
- package/dist/useSelectedWalletAccount.cjs +0 -13
- package/dist/useSelectedWalletAccount.d.cts +0 -117
- package/dist/useSendTransaction.cjs +0 -14
- package/dist/useSendTransaction.d.cts +0 -51
- package/dist/useSendTransactions.cjs +0 -13
- package/dist/useSendTransactions.d.cts +0 -4
- package/dist/useSignAndSendTransaction.cjs +0 -18
- package/dist/useSignAndSendTransaction.d.cts +0 -40
- package/dist/useSignAndSendTransactions.cjs +0 -15
- package/dist/useSignAndSendTransactions.d.cts +0 -35
- package/dist/useSignIn.cjs +0 -13
- package/dist/useSignIn.d.cts +0 -23
- package/dist/useSignMessage.cjs +0 -13
- package/dist/useSignMessage.d.cts +0 -236
- package/dist/useSignTransactions.cjs +0 -13
- package/dist/useSignTransactions.d.cts +0 -24
- package/dist/useSignatureStatus.cjs +0 -14
- package/dist/useSignatureStatus.d.cts +0 -26
- package/dist/useSolana.cjs +0 -10
- package/dist/useSolana.d.cts +0 -9
- package/dist/useSolanaClient.cjs +0 -10
- package/dist/useSolanaClient.d.cts +0 -45
- package/dist/useSubscription.cjs +0 -9
- package/dist/useSubscription.d.cts +0 -70
- package/dist/useTokenAccounts.cjs +0 -15
- package/dist/useTokenAccounts.d.cts +0 -19
- package/dist/useTokenBalance.cjs +0 -15
- package/dist/useTokenBalance.d.cts +0 -15
- package/dist/useTrackedData.cjs +0 -10
- package/dist/useTrackedData.d.cts +0 -98
- package/dist/useTransaction.cjs +0 -11
- package/dist/useTransaction.d.cts +0 -27
- package/dist/useTransactionConfirmation.cjs +0 -15
- package/dist/useTransactionConfirmation.d.cts +0 -38
- package/dist/useWallet.cjs +0 -12
- package/dist/useWallet.d.cts +0 -31
- package/dist/useWallets.cjs +0 -10
- package/dist/useWallets.d.cts +0 -11
package/README.md
CHANGED
|
@@ -55,6 +55,8 @@ pnpm add @vue-solana/vue
|
|
|
55
55
|
npm install @vue-solana/vue
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
Since v3.0.0 this package is ESM only. There is no `require` export condition and no top-level `main`, so `require("@vue-solana/vue")` fails with `No "exports" main defined`. Vite apps are unaffected; pin to `@vue-solana/vue@^2` if you must stay on CommonJS.
|
|
59
|
+
|
|
58
60
|
## Plugin Setup
|
|
59
61
|
|
|
60
62
|
```ts
|
|
@@ -196,7 +198,7 @@ const { balance, loading, error, refresh } = useBalance(address);
|
|
|
196
198
|
`useAirdrop()` sends SOL to an account on devnet, testnet, or a local validator. The default Vue client includes the RPC and airdrop capabilities; a custom client can install them with `createClient().use(solanaRpc({ ... })).use(rpcAirdrop())` from `@solana/kit-plugin-rpc`.
|
|
197
199
|
|
|
198
200
|
```ts
|
|
199
|
-
import { lamports } from "@solana/kit";
|
|
201
|
+
import { lamports } from "@vue-solana/vue/kit";
|
|
200
202
|
import { useAirdrop } from "@vue-solana/vue/useAirdrop";
|
|
201
203
|
|
|
202
204
|
const { data, status, error, dispatch } = useAirdrop();
|
|
@@ -344,10 +346,10 @@ await confirmation.confirm(signature);
|
|
|
344
346
|
|
|
345
347
|
### Wallet Request Inputs and Returns
|
|
346
348
|
|
|
347
|
-
Wallet signing flows accept transaction input as raw `Uint8Array` wire bytes that conform to the Solana transaction schema. Build them with `@solana/kit` (or decode them from a base64/base58 RPC response); base64 strings, transaction objects, and instruction lists are not accepted here.
|
|
349
|
+
Wallet signing flows accept transaction input as raw `Uint8Array` wire bytes that conform to the Solana transaction schema. Build them with the Kit helpers from `@vue-solana/vue/kit` (or decode them from a base64/base58 RPC response); base64 strings, transaction objects, and instruction lists are not accepted here.
|
|
348
350
|
|
|
349
351
|
```ts
|
|
350
|
-
import { compileTransaction, getTransactionEncoder } from "@solana/kit";
|
|
352
|
+
import { compileTransaction, getTransactionEncoder } from "@vue-solana/vue/kit";
|
|
351
353
|
|
|
352
354
|
const transaction: Uint8Array = getTransactionEncoder().encode(compileTransaction(message));
|
|
353
355
|
await execute(transaction);
|
|
@@ -673,7 +675,7 @@ Other direct subpaths:
|
|
|
673
675
|
- Public Solana RPC endpoints are useful for development, but production apps should use dedicated RPC infrastructure.
|
|
674
676
|
- Broad `useProgramAccounts()` scans can be expensive or blocked on public RPC nodes. Prefer narrow filters and `dataSlice`.
|
|
675
677
|
- Use `mainnet` for Solana mainnet. This is Solana's official mainnet cluster name; the legacy `mainnet-beta` spelling is still accepted and redirects to the same endpoint.
|
|
676
|
-
- v2.0.0 removed `@solana/web3-compat` and the `web3` subpaths. Build transaction messages with `@solana/kit` and pass raw `Uint8Array` wire bytes to wallet flows. See the [Kit Migration guide](https://vue-solana-docs.vercel.app/guides/kit-migration) for migrating from v1.
|
|
678
|
+
- v2.0.0 removed `@solana/web3-compat` and the `web3` subpaths. Build transaction messages with `@vue-solana/vue/kit` and pass raw `Uint8Array` wire bytes to wallet flows. See the [Kit Migration guide](https://vue-solana-docs.vercel.app/guides/kit-migration) for migrating from v1.
|
|
677
679
|
- Desktop native app wallets are planned but not implemented yet.
|
|
678
680
|
|
|
679
681
|
## Status
|
package/dist/index.d.mts
CHANGED
|
@@ -33,11 +33,13 @@ import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
|
|
|
33
33
|
import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
|
|
34
34
|
import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
|
|
35
35
|
export * from '@vue-solana/core/types';
|
|
36
|
+
export { TransactionStatus } from '@vue-solana/core/types';
|
|
36
37
|
import { App } from 'vue';
|
|
38
|
+
export { SolanaError, SolanaErrorCode, isSolanaError } from '@vue-solana/core/errors';
|
|
37
39
|
export * from '@vue-solana/core/kit';
|
|
38
|
-
import '@vue-solana/core/errors';
|
|
39
40
|
import '@solana/kit-plugin-rpc';
|
|
40
41
|
import '@solana/kit';
|
|
42
|
+
import './shared/vue.BGGixph-.mjs';
|
|
41
43
|
import '@vue-solana/core/token-accounts';
|
|
42
44
|
|
|
43
45
|
interface VueSolanaPluginOptions extends SolanaConfig {
|
package/dist/index.d.ts
CHANGED
|
@@ -33,11 +33,13 @@ import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
|
|
|
33
33
|
import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
|
|
34
34
|
import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
|
|
35
35
|
export * from '@vue-solana/core/types';
|
|
36
|
+
export { TransactionStatus } from '@vue-solana/core/types';
|
|
36
37
|
import { App } from 'vue';
|
|
38
|
+
export { SolanaError, SolanaErrorCode, isSolanaError } from '@vue-solana/core/errors';
|
|
37
39
|
export * from '@vue-solana/core/kit';
|
|
38
|
-
import '@vue-solana/core/errors';
|
|
39
40
|
import '@solana/kit-plugin-rpc';
|
|
40
41
|
import '@solana/kit';
|
|
42
|
+
import './shared/vue.BGGixph-.js';
|
|
41
43
|
import '@vue-solana/core/token-accounts';
|
|
42
44
|
|
|
43
45
|
interface VueSolanaPluginOptions extends SolanaConfig {
|
package/dist/index.mjs
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
export { u as useAccountInfo } from './shared/vue.
|
|
1
|
+
export { u as useAccountInfo } from './shared/vue.CvenSbZZ.mjs';
|
|
2
2
|
export { u as useAction } from './shared/vue.DYk0Xfr3.mjs';
|
|
3
3
|
export { u as useAirdrop } from './shared/vue.DDQxNX5q.mjs';
|
|
4
|
-
export { u as useBalance } from './shared/vue.
|
|
4
|
+
export { u as useBalance } from './shared/vue.BFSboXMB.mjs';
|
|
5
5
|
export { M as MissingClientCapabilityError, u as useClientCapability } from './shared/vue.B9uRpSDJ.mjs';
|
|
6
6
|
export { u as useConnection } from './shared/vue.CpkwC8Th.mjs';
|
|
7
|
-
export { u as usePlanTransaction, a as usePlanTransactions } from './shared/vue.
|
|
8
|
-
export { u as useProgramAccounts } from './shared/vue.
|
|
7
|
+
export { u as usePlanTransaction, a as usePlanTransactions } from './shared/vue.CsFY1mfz.mjs';
|
|
8
|
+
export { u as useProgramAccounts } from './shared/vue.1Qwco2kv.mjs';
|
|
9
9
|
export { u as useIdentity, a as usePayer } from './shared/vue.B-xtuLtD.mjs';
|
|
10
10
|
export { u as useRequest } from './shared/vue.B8VvC8d2.mjs';
|
|
11
11
|
export { u as useRpc } from './shared/vue.BsGwt78R.mjs';
|
|
12
12
|
export { S as SelectedWalletAccountProvider, c as createSelectedWalletAccountContext, p as provideSelectedWalletAccount, s as selectedWalletAccountInjectionKey, u as useSelectedWalletAccount } from './shared/vue.BngCaeXJ.mjs';
|
|
13
|
-
export { u as useSendTransaction, a as useSendTransactions } from './shared/vue.
|
|
14
|
-
export { u as useSignMessage } from './shared/vue.
|
|
15
|
-
export { u as useSignAndSendTransaction } from './shared/vue.
|
|
16
|
-
export { u as useSignTransactions } from './shared/vue.
|
|
17
|
-
export { P as PartialSignAndSendError, u as useSignAndSendTransactions } from './shared/vue.
|
|
13
|
+
export { u as useSendTransaction, a as useSendTransactions } from './shared/vue.BxtOHzY_.mjs';
|
|
14
|
+
export { u as useSignMessage } from './shared/vue.o98pAmDg.mjs';
|
|
15
|
+
export { u as useSignAndSendTransaction } from './shared/vue.CjSw0Hh1.mjs';
|
|
16
|
+
export { u as useSignTransactions } from './shared/vue.hG_FieA3.mjs';
|
|
17
|
+
export { P as PartialSignAndSendError, u as useSignAndSendTransactions } from './shared/vue.C1JbUTpJ.mjs';
|
|
18
18
|
export { u as useSignatureStatus } from './shared/vue.CXB4NEMA.mjs';
|
|
19
|
-
export { u as useSignIn } from './shared/vue.
|
|
19
|
+
export { u as useSignIn } from './shared/vue.C9OOmvkD.mjs';
|
|
20
20
|
export { t as tryUseSolana, u as useSolana } from './shared/vue.CQh3AUE8.mjs';
|
|
21
21
|
export { u as useSolanaClient } from './shared/vue.Mxc8w6Qk.mjs';
|
|
22
|
-
export { u as useSubscription } from './shared/vue.
|
|
23
|
-
export { u as useTokenAccounts } from './shared/vue.
|
|
24
|
-
export { u as useTokenBalance } from './shared/vue.
|
|
25
|
-
export { u as useTrackedData } from './shared/vue.
|
|
22
|
+
export { u as useSubscription } from './shared/vue.D5pqR5Fa.mjs';
|
|
23
|
+
export { u as useTokenAccounts } from './shared/vue.DNKD6jqM.mjs';
|
|
24
|
+
export { u as useTokenBalance } from './shared/vue.XlfH_nkc.mjs';
|
|
25
|
+
export { u as useTrackedData } from './shared/vue.BNJTXSnQ.mjs';
|
|
26
26
|
export { u as useTransaction } from './shared/vue.5euWd6-V.mjs';
|
|
27
|
-
export { g as getConfirmedTransactionStatus, u as useTransactionConfirmation } from './shared/vue.
|
|
27
|
+
export { g as getConfirmedTransactionStatus, u as useTransactionConfirmation } from './shared/vue.CaAgH2Xt.mjs';
|
|
28
28
|
export { u as useWallet } from './shared/vue.D218Ow7t.mjs';
|
|
29
29
|
export { u as useWallets } from './shared/vue.C_4qJDiF.mjs';
|
|
30
30
|
import { s as solanaInjectionKey } from './shared/vue.D_P5SqqD.mjs';
|
|
31
31
|
import { createSolanaError, normalizeSolanaError } from '@vue-solana/core/errors';
|
|
32
|
+
export { SolanaError, isSolanaError } from '@vue-solana/core/errors';
|
|
32
33
|
import { createSolanaContext } from '@vue-solana/core/rpc';
|
|
33
34
|
import { withTimeout } from '@vue-solana/core/timeout';
|
|
34
35
|
import { getRegisteredSolanaWallets, getSolanaChain, adaptSolanaStandardWallet, subscribeSolanaWallets } from '@vue-solana/core/wallet-standard';
|
|
@@ -36,10 +37,13 @@ import { shallowRef, ref, triggerRef } from 'vue';
|
|
|
36
37
|
import { handleSolanaIosWalletCallback, getSolanaIosWallets, isSolanaIosWalletInfo, adaptSolanaIosWallet } from '@vue-solana/core/ios-wallet';
|
|
37
38
|
export * from '@vue-solana/core/types';
|
|
38
39
|
export * from '@vue-solana/core/kit';
|
|
40
|
+
import './shared/vue.BwBqla_n.mjs';
|
|
39
41
|
import '@vue-solana/core/address';
|
|
40
42
|
import './shared/vue.Bfu1dCKe.mjs';
|
|
41
43
|
import '@vue-solana/core/action';
|
|
44
|
+
import './shared/vue.CGv0ip3w.mjs';
|
|
42
45
|
import '@vue-solana/core/wallet';
|
|
46
|
+
import './shared/vue.DlihC5GG.mjs';
|
|
43
47
|
import '@vue-solana/core/transaction';
|
|
44
48
|
import 'bs58';
|
|
45
49
|
import '@vue-solana/core/token-accounts';
|
|
@@ -142,38 +146,23 @@ function createSolanaWalletRegistry(options) {
|
|
|
142
146
|
chain: getSolanaChain(options.cluster),
|
|
143
147
|
onChange: options.onWalletChange
|
|
144
148
|
});
|
|
145
|
-
const cachedAdapter = {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
await Promise.all(
|
|
163
|
-
Array.from(getCachedWallets()).map(
|
|
164
|
-
(otherWallet) => otherWallet !== cachedAdapter && otherWallet.connected ? otherWallet.disconnect() : void 0
|
|
165
|
-
)
|
|
166
|
-
);
|
|
167
|
-
},
|
|
168
|
-
disconnect: () => adaptedWallet.disconnect(),
|
|
169
|
-
signMessage: adaptedWallet.signMessage?.bind(adaptedWallet),
|
|
170
|
-
signTransaction: adaptedWallet.signTransaction?.bind(adaptedWallet),
|
|
171
|
-
signAllTransactions: adaptedWallet.signAllTransactions?.bind(adaptedWallet),
|
|
172
|
-
signAndSendTransaction: adaptedWallet.signAndSendTransaction?.bind(adaptedWallet),
|
|
173
|
-
signIn: adaptedWallet.signIn?.bind(adaptedWallet),
|
|
174
|
-
signTransactions: adaptedWallet.signTransactions?.bind(adaptedWallet),
|
|
175
|
-
signAndSendTransactions: adaptedWallet.signAndSendTransactions?.bind(adaptedWallet)
|
|
176
|
-
};
|
|
149
|
+
const cachedAdapter = new Proxy(adaptedWallet, {
|
|
150
|
+
get(target, property) {
|
|
151
|
+
if (property === "connect") {
|
|
152
|
+
return connectAndDisconnectOthers;
|
|
153
|
+
}
|
|
154
|
+
const value = Reflect.get(target, property);
|
|
155
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
async function connectAndDisconnectOthers() {
|
|
159
|
+
await adaptedWallet.connect();
|
|
160
|
+
await Promise.all(
|
|
161
|
+
Array.from(getCachedWallets()).map(
|
|
162
|
+
(otherWallet) => otherWallet !== cachedAdapter && otherWallet.connected ? otherWallet.disconnect() : void 0
|
|
163
|
+
)
|
|
164
|
+
);
|
|
165
|
+
}
|
|
177
166
|
adaptedWallets.set(walletInfo.wallet, cachedAdapter);
|
|
178
167
|
return cachedAdapter;
|
|
179
168
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
2
|
+
import { u as useAddressRead } from './vue.BwBqla_n.mjs';
|
|
3
|
+
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
4
|
+
import { d as decodeBase64 } from './vue.Bfu1dCKe.mjs';
|
|
5
|
+
|
|
6
|
+
function useProgramAccounts(programId, options = {}) {
|
|
7
|
+
const empty = [];
|
|
8
|
+
const solana = tryUseSolana();
|
|
9
|
+
const client = solana?.client ?? useConnection();
|
|
10
|
+
const { data: accounts, ...rest } = useAddressRead(
|
|
11
|
+
[programId],
|
|
12
|
+
async (key) => (await client.rpc.getProgramAccounts(key, {
|
|
13
|
+
encoding: "base64",
|
|
14
|
+
commitment: options.commitment,
|
|
15
|
+
dataSlice: options.dataSlice,
|
|
16
|
+
filters: options.filters
|
|
17
|
+
}).send()).value,
|
|
18
|
+
(response) => response.map(({ pubkey, account }) => ({
|
|
19
|
+
pubkey,
|
|
20
|
+
account: {
|
|
21
|
+
executable: account.executable,
|
|
22
|
+
lamports: Number(account.lamports),
|
|
23
|
+
owner: account.owner,
|
|
24
|
+
space: Number(account.space),
|
|
25
|
+
data: decodeBase64(account.data[0])
|
|
26
|
+
}
|
|
27
|
+
})),
|
|
28
|
+
empty
|
|
29
|
+
);
|
|
30
|
+
return { accounts, ...rest };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { useProgramAccounts as u };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
2
|
+
import { u as useAddressRead } from './vue.BwBqla_n.mjs';
|
|
3
|
+
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
4
|
+
|
|
5
|
+
function useBalance(address, commitment) {
|
|
6
|
+
const solana = tryUseSolana();
|
|
7
|
+
const client = solana?.client ?? useConnection();
|
|
8
|
+
const { data: balance, ...rest } = useAddressRead(
|
|
9
|
+
[address],
|
|
10
|
+
async (key) => (await client.rpc.getBalance(key, commitment ? { commitment } : void 0).send()).value,
|
|
11
|
+
Number,
|
|
12
|
+
null
|
|
13
|
+
);
|
|
14
|
+
return { balance, ...rest };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { useBalance as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createReactiveActionStore, getAbortablePromise, createReactiveStoreWithInitialValueAndSlotTracking } from '@vue-solana/core/kit';
|
|
2
2
|
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
3
3
|
import { shallowRef, watch, unref, onMounted, getCurrentInstance, onScopeDispose, computed } from 'vue';
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ function useTrackedData(source, options = {}) {
|
|
|
9
9
|
const data = shallowRef(void 0);
|
|
10
10
|
const error = shallowRef(null);
|
|
11
11
|
const status = shallowRef("loading");
|
|
12
|
-
|
|
12
|
+
let disposeActive;
|
|
13
13
|
let connectionCount = 0;
|
|
14
14
|
let disposed = false;
|
|
15
15
|
let activeStore;
|
|
@@ -22,8 +22,8 @@ function useTrackedData(source, options = {}) {
|
|
|
22
22
|
error.value = normalizeSolanaError(state.error, "RPC_FAILURE");
|
|
23
23
|
status.value = "error";
|
|
24
24
|
options.onError?.(state.error);
|
|
25
|
-
} else if (state.status === "loading") {
|
|
26
|
-
status.value =
|
|
25
|
+
} else if (state.status === "loading" && data.value === void 0) {
|
|
26
|
+
status.value = "loading";
|
|
27
27
|
} else if (state.status === "idle") {
|
|
28
28
|
error.value = null;
|
|
29
29
|
}
|
|
@@ -32,74 +32,25 @@ function useTrackedData(source, options = {}) {
|
|
|
32
32
|
if (disposed) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
+
disconnect();
|
|
35
36
|
let rpcRequest = unref(source.rpcRequest);
|
|
36
37
|
const rpcSubscriptionRequest = unref(source.rpcSubscriptionRequest);
|
|
37
38
|
if (!rpcRequest || !rpcSubscriptionRequest) {
|
|
38
|
-
disconnect();
|
|
39
39
|
data.value = void 0;
|
|
40
40
|
error.value = null;
|
|
41
41
|
status.value = "disabled";
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
if (!isActionSource(rpcRequest) && isSendSource(rpcRequest)) {
|
|
45
|
-
let runSend = function(abortSignal) {
|
|
46
|
-
controller?.abort();
|
|
47
|
-
controller = new AbortController();
|
|
48
|
-
const composed = abortSignal ? AbortSignal.any([controller.signal, abortSignal]) : controller.signal;
|
|
49
|
-
settle({ data: void 0, error: void 0, status: "running" });
|
|
50
|
-
const pending = Promise.resolve(sendSource.send({ abortSignal: composed }));
|
|
51
|
-
pending.then((response) => {
|
|
52
|
-
settle({ data: response, error: void 0, status: "success" });
|
|
53
|
-
}).catch((cause) => {
|
|
54
|
-
settle({ data: void 0, error: cause, status: "error" });
|
|
55
|
-
});
|
|
56
|
-
return getAbortablePromise(pending, composed);
|
|
57
|
-
};
|
|
58
45
|
const sendSource = rpcRequest;
|
|
59
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
60
|
-
let sendState = {
|
|
61
|
-
data: void 0,
|
|
62
|
-
error: void 0,
|
|
63
|
-
status: "idle"
|
|
64
|
-
};
|
|
65
|
-
let controller;
|
|
66
|
-
const emit = () => {
|
|
67
|
-
listeners.forEach((listener) => {
|
|
68
|
-
listener();
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
const settle = (next) => {
|
|
72
|
-
sendState = next;
|
|
73
|
-
emit();
|
|
74
|
-
};
|
|
75
46
|
rpcRequest = {
|
|
76
|
-
reactiveStore: () => (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
reset() {
|
|
84
|
-
controller?.abort();
|
|
85
|
-
settle({ data: void 0, error: void 0, status: "idle" });
|
|
86
|
-
},
|
|
87
|
-
subscribe(listener) {
|
|
88
|
-
listeners.add(listener);
|
|
89
|
-
return () => {
|
|
90
|
-
listeners.delete(listener);
|
|
91
|
-
};
|
|
92
|
-
},
|
|
93
|
-
withSignal(signal) {
|
|
94
|
-
return {
|
|
95
|
-
dispatch: () => {
|
|
96
|
-
void runSend(signal).catch(() => {
|
|
97
|
-
});
|
|
98
|
-
},
|
|
99
|
-
dispatchAsync: () => runSend(signal)
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
})
|
|
47
|
+
reactiveStore: () => createReactiveActionStore(
|
|
48
|
+
(abortSignal) => (
|
|
49
|
+
// Race the send against the signal so a reconnection or teardown
|
|
50
|
+
// abort fails the attempt even if the source ignores it.
|
|
51
|
+
getAbortablePromise(sendSource.send({ abortSignal }), abortSignal)
|
|
52
|
+
)
|
|
53
|
+
)
|
|
103
54
|
};
|
|
104
55
|
}
|
|
105
56
|
connectionCount += 1;
|
|
@@ -113,11 +64,9 @@ function useTrackedData(source, options = {}) {
|
|
|
113
64
|
});
|
|
114
65
|
activeStore = store;
|
|
115
66
|
applyState(store.getState());
|
|
116
|
-
|
|
117
|
-
store.
|
|
118
|
-
|
|
119
|
-
})
|
|
120
|
-
);
|
|
67
|
+
disposeActive = store.subscribe(() => {
|
|
68
|
+
applyState(store.getState());
|
|
69
|
+
});
|
|
121
70
|
if (callerSignal?.aborted) {
|
|
122
71
|
applyState({ data: store.getState().data, error: callerSignal.reason, status: "error" });
|
|
123
72
|
return;
|
|
@@ -129,10 +78,8 @@ function useTrackedData(source, options = {}) {
|
|
|
129
78
|
}
|
|
130
79
|
}
|
|
131
80
|
function disconnect() {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
});
|
|
135
|
-
disposables.length = 0;
|
|
81
|
+
disposeActive?.();
|
|
82
|
+
disposeActive = void 0;
|
|
136
83
|
if (activeStore) {
|
|
137
84
|
activeStore.reset();
|
|
138
85
|
activeStore = void 0;
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import { parseAddress } from '@vue-solana/core/address';
|
|
2
2
|
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
3
|
-
import { shallowRef, onMounted, watch, toValue } from 'vue';
|
|
4
|
-
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
5
|
-
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
3
|
+
import { shallowRef, onMounted, onScopeDispose, watch, toValue } from 'vue';
|
|
6
4
|
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
const client = solana?.client ?? useConnection();
|
|
10
|
-
const balance = shallowRef(null);
|
|
5
|
+
function useAddressRead(addresses, read, select, empty) {
|
|
6
|
+
const data = shallowRef(empty);
|
|
11
7
|
const loading = shallowRef(false);
|
|
12
8
|
const error = shallowRef(null);
|
|
13
9
|
let refreshId = 0;
|
|
14
10
|
async function refresh() {
|
|
15
11
|
const requestId = ++refreshId;
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
|
|
12
|
+
const values = addresses.map((address) => toValue(address));
|
|
13
|
+
if (values.some((value) => !value)) {
|
|
14
|
+
data.value = empty;
|
|
19
15
|
loading.value = false;
|
|
20
16
|
error.value = null;
|
|
21
17
|
return null;
|
|
@@ -23,19 +19,15 @@ function useBalance(address, commitment) {
|
|
|
23
19
|
loading.value = true;
|
|
24
20
|
error.value = null;
|
|
25
21
|
try {
|
|
26
|
-
const
|
|
27
|
-
if (!parsedAddress) {
|
|
28
|
-
balance.value = null;
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
const { value: lamports } = await client.rpc.getBalance(parsedAddress, commitment ? { commitment } : void 0).send();
|
|
22
|
+
const next = select(await read(...values.map((value) => parseAddress(value))));
|
|
32
23
|
if (requestId === refreshId) {
|
|
33
|
-
|
|
24
|
+
data.value = next;
|
|
34
25
|
}
|
|
35
|
-
return
|
|
26
|
+
return next;
|
|
36
27
|
} catch (cause) {
|
|
37
28
|
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
38
29
|
if (requestId === refreshId) {
|
|
30
|
+
data.value = empty;
|
|
39
31
|
error.value = normalizedError;
|
|
40
32
|
}
|
|
41
33
|
throw normalizedError;
|
|
@@ -48,18 +40,16 @@ function useBalance(address, commitment) {
|
|
|
48
40
|
onMounted(() => {
|
|
49
41
|
void refresh().catch(() => void 0);
|
|
50
42
|
});
|
|
43
|
+
onScopeDispose(() => {
|
|
44
|
+
refreshId += 1;
|
|
45
|
+
});
|
|
51
46
|
watch(
|
|
52
|
-
() => toValue(address),
|
|
47
|
+
() => addresses.map((address) => toValue(address)),
|
|
53
48
|
() => {
|
|
54
49
|
void refresh().catch(() => void 0);
|
|
55
50
|
}
|
|
56
51
|
);
|
|
57
|
-
return {
|
|
58
|
-
balance,
|
|
59
|
-
loading,
|
|
60
|
-
error,
|
|
61
|
-
refresh
|
|
62
|
-
};
|
|
52
|
+
return { data, loading, error, refresh };
|
|
63
53
|
}
|
|
64
54
|
|
|
65
|
-
export {
|
|
55
|
+
export { useAddressRead as u };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { u as useClientAction } from './vue.CGv0ip3w.mjs';
|
|
2
|
+
|
|
3
|
+
const SENDING_PROVIDER_HINT = "Use a client created by `createSolanaClient({ payer })` \u2014 or any client with a `payer` signer. Kit reads `client.payer` when it plans a transaction from an instruction plan.";
|
|
4
|
+
const SEND_STATUSES = {
|
|
5
|
+
error: "error",
|
|
6
|
+
idle: "idle",
|
|
7
|
+
success: "sent",
|
|
8
|
+
working: "sending"
|
|
9
|
+
};
|
|
10
|
+
function useSendTransaction() {
|
|
11
|
+
return useClientAction({
|
|
12
|
+
capability: "sendTransaction",
|
|
13
|
+
hookName: "useSendTransaction",
|
|
14
|
+
providerHint: SENDING_PROVIDER_HINT,
|
|
15
|
+
statuses: SEND_STATUSES
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function useSendTransactions() {
|
|
19
|
+
return useClientAction({
|
|
20
|
+
capability: "sendTransactions",
|
|
21
|
+
hookName: "useSendTransactions",
|
|
22
|
+
providerHint: SENDING_PROVIDER_HINT,
|
|
23
|
+
statuses: SEND_STATUSES
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { useSendTransactions as a, useSendTransaction as u };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { SolanaError, normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { withSolanaTimeout } from '@vue-solana/core/timeout';
|
|
3
|
+
import { createNoWalletSelectedError, assertWalletCanSignAndSendTransactions } from '@vue-solana/core/wallet';
|
|
4
|
+
import { shallowRef } from 'vue';
|
|
5
|
+
import { u as useExecution } from './vue.DlihC5GG.mjs';
|
|
6
|
+
import { u as useWallet } from './vue.D218Ow7t.mjs';
|
|
7
|
+
|
|
8
|
+
const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
|
|
9
|
+
class PartialSignAndSendError extends SolanaError {
|
|
10
|
+
constructor(cause, signatures) {
|
|
11
|
+
super(cause.code, cause.message, { cause: cause.cause, feature: cause.feature });
|
|
12
|
+
this.signatures = signatures;
|
|
13
|
+
this.name = "PartialSignAndSendError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function useSignAndSendTransactions() {
|
|
17
|
+
const { wallet } = useWallet();
|
|
18
|
+
const signatures = shallowRef(null);
|
|
19
|
+
const { status, loading, error, execute } = useExecution("sending");
|
|
20
|
+
function send(transactions, options) {
|
|
21
|
+
signatures.value = null;
|
|
22
|
+
return execute(
|
|
23
|
+
async () => {
|
|
24
|
+
const activeWallet = wallet.value;
|
|
25
|
+
if (!activeWallet) {
|
|
26
|
+
throw createNoWalletSelectedError();
|
|
27
|
+
}
|
|
28
|
+
assertWalletCanSignAndSendTransactions(activeWallet);
|
|
29
|
+
const sendSingularSequentially = async () => {
|
|
30
|
+
const collected = [];
|
|
31
|
+
for (const transaction of transactions) {
|
|
32
|
+
try {
|
|
33
|
+
const result = await activeWallet.signAndSendTransaction(transaction, options);
|
|
34
|
+
collected.push(result.signature);
|
|
35
|
+
} catch (cause) {
|
|
36
|
+
throw new PartialSignAndSendError(
|
|
37
|
+
normalizeSolanaError(cause, "RPC_FAILURE"),
|
|
38
|
+
collected
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return collected;
|
|
43
|
+
};
|
|
44
|
+
const send2 = withSolanaTimeout(
|
|
45
|
+
activeWallet.signAndSendTransactions ? activeWallet.signAndSendTransactions(transactions, options) : sendSingularSequentially(),
|
|
46
|
+
SIGN_AND_SEND_TIMEOUT_MS,
|
|
47
|
+
"Wallet transaction did not return a result. Check your wallet or explorer for the final status."
|
|
48
|
+
);
|
|
49
|
+
return await send2;
|
|
50
|
+
},
|
|
51
|
+
(result) => {
|
|
52
|
+
signatures.value = result;
|
|
53
|
+
return "sent";
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
signatures,
|
|
59
|
+
status,
|
|
60
|
+
loading,
|
|
61
|
+
error,
|
|
62
|
+
execute: send
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { PartialSignAndSendError as P, useSignAndSendTransactions as u };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createNoWalletSelectedError, assertWalletCanSignIn } from '@vue-solana/core/wallet';
|
|
2
|
+
import { shallowRef } from 'vue';
|
|
3
|
+
import { u as useExecution } from './vue.DlihC5GG.mjs';
|
|
4
|
+
import { u as useWallet } from './vue.D218Ow7t.mjs';
|
|
5
|
+
|
|
6
|
+
function useSignIn() {
|
|
7
|
+
const { wallet } = useWallet();
|
|
8
|
+
const signInResult = shallowRef(null);
|
|
9
|
+
const { status, loading, error, execute } = useExecution("signing-in");
|
|
10
|
+
function signIn(input) {
|
|
11
|
+
signInResult.value = null;
|
|
12
|
+
return execute(
|
|
13
|
+
async () => {
|
|
14
|
+
const activeWallet = wallet.value;
|
|
15
|
+
if (!activeWallet) {
|
|
16
|
+
throw createNoWalletSelectedError();
|
|
17
|
+
}
|
|
18
|
+
assertWalletCanSignIn(activeWallet);
|
|
19
|
+
return activeWallet.signIn(input);
|
|
20
|
+
},
|
|
21
|
+
(result) => {
|
|
22
|
+
signInResult.value = result;
|
|
23
|
+
return "signed-in";
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
signInResult,
|
|
29
|
+
status,
|
|
30
|
+
loading,
|
|
31
|
+
error,
|
|
32
|
+
signIn
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { useSignIn as u };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { shallowRef, computed, ref, onScopeDispose } from 'vue';
|
|
3
|
+
import { u as useClientCapability, M as MissingClientCapabilityError } from './vue.B9uRpSDJ.mjs';
|
|
4
|
+
import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
|
|
5
|
+
|
|
6
|
+
function useClientAction(config) {
|
|
7
|
+
const { capability, hookName, providerHint, statuses } = config;
|
|
8
|
+
useClientCapability([capability, "payer"], { hookName, providerHint });
|
|
9
|
+
const { client } = useSolanaClient();
|
|
10
|
+
const data = shallowRef(null);
|
|
11
|
+
const status = shallowRef(statuses.idle);
|
|
12
|
+
const loading = computed(() => status.value === statuses.working);
|
|
13
|
+
const error = ref(null);
|
|
14
|
+
let executionId = 0;
|
|
15
|
+
let abortController;
|
|
16
|
+
onScopeDispose(() => {
|
|
17
|
+
abortController?.abort();
|
|
18
|
+
executionId++;
|
|
19
|
+
});
|
|
20
|
+
async function execute(input, options = {}) {
|
|
21
|
+
const method = client?.[capability];
|
|
22
|
+
if (typeof method !== "function") {
|
|
23
|
+
throw new MissingClientCapabilityError(hookName, [capability], providerHint);
|
|
24
|
+
}
|
|
25
|
+
abortController?.abort();
|
|
26
|
+
const controller = new AbortController();
|
|
27
|
+
abortController = controller;
|
|
28
|
+
const currentExecutionId = ++executionId;
|
|
29
|
+
status.value = statuses.working;
|
|
30
|
+
error.value = null;
|
|
31
|
+
data.value = null;
|
|
32
|
+
try {
|
|
33
|
+
const abortSignal = options.abortSignal ? AbortSignal.any([controller.signal, options.abortSignal]) : controller.signal;
|
|
34
|
+
const result = await method(input, { abortSignal });
|
|
35
|
+
if (currentExecutionId === executionId) {
|
|
36
|
+
data.value = result;
|
|
37
|
+
status.value = statuses.success;
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
} catch (cause) {
|
|
41
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
42
|
+
if (currentExecutionId === executionId) {
|
|
43
|
+
error.value = normalizedError;
|
|
44
|
+
status.value = statuses.error;
|
|
45
|
+
}
|
|
46
|
+
throw normalizedError;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return { data, status, loading, error, execute };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { useClientAction as u };
|