@vue-solana/core 2.6.0 → 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.
Files changed (49) hide show
  1. package/README.md +6 -4
  2. package/dist/index.d.mts +2 -1
  3. package/dist/index.d.ts +2 -1
  4. package/dist/index.mjs +4 -3
  5. package/dist/ios-wallet.mjs +1 -1
  6. package/dist/kit.d.mts +1 -1
  7. package/dist/kit.d.ts +1 -1
  8. package/dist/kit.mjs +17 -9
  9. package/dist/shared/{core.TqudP0hB.mjs → core.DaUlAmcN.mjs} +15 -22
  10. package/dist/shared/{core.CDVW-ApZ.mjs → core.DuQGQqnc.mjs} +29 -26
  11. package/dist/timeout.mjs +3 -0
  12. package/dist/wallet-standard.mjs +1 -1
  13. package/dist/wallet.mjs +26 -39
  14. package/package.json +18 -35
  15. package/dist/action.cjs +0 -14
  16. package/dist/action.d.cts +0 -28
  17. package/dist/address.cjs +0 -33
  18. package/dist/address.d.cts +0 -16
  19. package/dist/buffer-polyfill.cjs +0 -12
  20. package/dist/buffer-polyfill.d.cts +0 -7
  21. package/dist/clusters.cjs +0 -37
  22. package/dist/clusters.d.cts +0 -10
  23. package/dist/errors.cjs +0 -50
  24. package/dist/errors.d.cts +0 -17
  25. package/dist/index.cjs +0 -94
  26. package/dist/index.d.cts +0 -19
  27. package/dist/ios-wallet.cjs +0 -17
  28. package/dist/ios-wallet.d.cts +0 -62
  29. package/dist/kit.cjs +0 -80
  30. package/dist/kit.d.cts +0 -3
  31. package/dist/mobile-wallet.cjs +0 -69
  32. package/dist/mobile-wallet.d.cts +0 -20
  33. package/dist/rpc.cjs +0 -20
  34. package/dist/rpc.d.cts +0 -7
  35. package/dist/shared/core.C9vxHRXl.d.cts +0 -193
  36. package/dist/shared/core.CasnoavM.cjs +0 -323
  37. package/dist/shared/core.eIBHqmLq.cjs +0 -598
  38. package/dist/timeout.cjs +0 -32
  39. package/dist/timeout.d.cts +0 -4
  40. package/dist/token-accounts.cjs +0 -72
  41. package/dist/token-accounts.d.cts +0 -36
  42. package/dist/transaction.cjs +0 -81
  43. package/dist/transaction.d.cts +0 -18
  44. package/dist/types.cjs +0 -2
  45. package/dist/types.d.cts +0 -3
  46. package/dist/wallet-standard.cjs +0 -17
  47. package/dist/wallet-standard.d.cts +0 -22
  48. package/dist/wallet.cjs +0 -81
  49. package/dist/wallet.d.cts +0 -25
package/README.md CHANGED
@@ -9,7 +9,7 @@ Framework-agnostic Solana primitives for Vue Solana libraries and apps that want
9
9
 
10
10
  Use this package directly when you want Kit RPC client helpers, shared wallet types, Android Mobile Wallet Adapter registration helpers, message signing support, token account reads, and transaction helpers without installing the Vue plugin.
11
11
 
12
- `@vue-solana/core` builds on `@solana/kit`. It exposes `createSolanaClient()` and re-exports Kit primitives (`address`, `lamports`, and the `Address`, `Commitment`, `Lamports`, `Rpc`, `Signature`, and `SolanaRpcApi` types) from `@vue-solana/core/kit`. The legacy `@solana/web3-compat` surface and the `web3` subpaths were removed in v2.0.0; transactions flow through the packages as raw `Uint8Array` wire bytes.
12
+ `@vue-solana/core` builds on `@solana/kit`. It exposes `createSolanaClient()` and re-exports all of `@solana/kit` from `@vue-solana/core/kit`. The legacy `@solana/web3-compat` surface and the `web3` subpaths were removed in v2.0.0; transactions flow through the packages as raw `Uint8Array` wire bytes.
13
13
 
14
14
  Official Solana docs:
15
15
 
@@ -42,11 +42,13 @@ Full Vue Solana docs:
42
42
 
43
43
  | Requirement | Supported |
44
44
  | ------------- | ----------------------------------------------------------------- |
45
- | Runtime | Modern ESM or CommonJS bundlers |
45
+ | Runtime | ESM only (modern bundlers; Node needs ESM) |
46
46
  | TypeScript | TypeScript 5.x recommended |
47
- | Solana client | `@solana/kit@^8.3.0` (and `@solana/kit-plugin-rpc`) |
47
+ | Solana client | `@solana/kit@^8.4.0` (and `@solana/kit-plugin-rpc`) |
48
48
  | Clusters | `mainnet` (alias `mainnet-beta`), `devnet`, `testnet`, `localnet` |
49
49
 
50
+ Since v3.0.0 this package is ESM only: there is no `require` export condition and no top-level `main`, so `require("@vue-solana/core")` fails with `No "exports" main defined`. Pin to `@vue-solana/core@^2` if you must stay on CommonJS.
51
+
50
52
  This package no longer depends on `@solana/web3-compat`. It depends on `@solana/kit` and `@solana/kit-plugin-rpc`, so apps do not need to install either directly for normal Vue Solana usage.
51
53
 
52
54
  ## Install
@@ -226,7 +228,7 @@ Docs: [Vue Solana Agent Skill](https://vue-solana-docs.vercel.app/agent-skill)
226
228
 
227
229
  - Public Solana RPC endpoints are useful for development, but production apps should use dedicated RPC infrastructure.
228
230
  - 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.
229
- - Transactions are raw wire bytes. Build transaction messages with `@solana/kit` (`createTransactionMessage()`, `compileTransaction()`) and serialize them before passing them to wallet flows.
231
+ - Transactions are raw wire bytes. Build transaction messages with `@vue-solana/core/kit` (`createTransactionMessage()`, `compileTransaction()`) and serialize them before passing them to wallet flows.
230
232
  - v2.0.0 removed `@solana/web3-compat` and the `web3` subpaths. See the [Kit Migration guide](https://vue-solana-docs.vercel.app/guides/kit-migration) for migrating from v1.
231
233
  - Desktop native app wallets are planned but not implemented yet.
232
234
 
package/dist/index.d.mts CHANGED
@@ -11,7 +11,8 @@ export { TokenAccountInfo, TokenAccountsByOwnerOptions, TokenBalanceResult, getT
11
11
  export { confirmTransactionSignature, signAndSendTransaction } from './transaction.mjs';
12
12
  export { withSolanaTimeout, withTimeout } from './timeout.mjs';
13
13
  export { SolanaWalletError, SolanaWalletErrorCode, assertWalletCanSign, assertWalletCanSignAndSendTransactions, assertWalletCanSignIn, assertWalletCanSignMessage, assertWalletCanSignTransactions, assertWalletConnected, createNoWalletSelectedError, isWalletConnected } from './wallet.mjs';
14
- export { AccountRole, Address, ClientWithIdentity, ClientWithPayer, ClientWithSubscribeToIdentity, ClientWithSubscribeToPayer, ClientWithTransactionPlanning, ClientWithTransactionSending, Commitment, CreateReactiveStoreWithInitialValueAndSlotTrackingConfig, Instruction, InstructionPlanInput, Lamports, ReactiveActionSource, ReactiveActionState, ReactiveActionStatus, ReactiveActionStore, ReactiveState, ReactiveStreamSource, ReactiveStreamStore, Rpc, Signature, SingleTransactionPlan, SolanaRpcApi, SolanaRpcResponse, SuccessfulSingleTransactionPlanResult, TransactionMessage, TransactionPlan, TransactionPlanInput, TransactionPlanResult, TransactionSigner, address, appendTransactionMessageInstruction, compileTransaction, createReactiveActionStore, createReactiveStoreWithInitialValueAndSlotTracking, createTransactionMessage, extendClient, generateKeyPairSigner, getAbortablePromise, getTransactionEncoder, isAbortError, isAddress, lamports, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, summarizeTransactionPlanResult } from '@solana/kit';
14
+ export * from '@solana/kit';
15
+ export { isAbortError } from '@solana/kit';
15
16
  export { AdaptSolanaIosWalletOptions, GetSolanaIosWalletsOptions, IosWalletCallbackResult, IosWalletInfo, IosWalletMethod, SolanaIosWalletAppIdentity, adaptSolanaIosWallet, getDefaultIosWalletAppIdentity, getDefaultIosWalletRedirectUrl, getSolanaIosWallets, handleSolanaIosWalletCallback, isIosBrowser, isSolanaIosBrowserWalletSupported, isSolanaIosWalletInfo } from './ios-wallet.mjs';
16
17
  export { AdaptSolanaWalletOptions, SOLANA_CHAINS, SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, adaptSolanaStandardWallet, getRegisteredSolanaWallets, getSolanaChain, isSolanaStandardWallet, subscribeSolanaWallets } from './wallet-standard.mjs';
17
18
  export { Buffer } from 'buffer/';
package/dist/index.d.ts CHANGED
@@ -11,7 +11,8 @@ export { TokenAccountInfo, TokenAccountsByOwnerOptions, TokenBalanceResult, getT
11
11
  export { confirmTransactionSignature, signAndSendTransaction } from './transaction.js';
12
12
  export { withSolanaTimeout, withTimeout } from './timeout.js';
13
13
  export { SolanaWalletError, SolanaWalletErrorCode, assertWalletCanSign, assertWalletCanSignAndSendTransactions, assertWalletCanSignIn, assertWalletCanSignMessage, assertWalletCanSignTransactions, assertWalletConnected, createNoWalletSelectedError, isWalletConnected } from './wallet.js';
14
- export { AccountRole, Address, ClientWithIdentity, ClientWithPayer, ClientWithSubscribeToIdentity, ClientWithSubscribeToPayer, ClientWithTransactionPlanning, ClientWithTransactionSending, Commitment, CreateReactiveStoreWithInitialValueAndSlotTrackingConfig, Instruction, InstructionPlanInput, Lamports, ReactiveActionSource, ReactiveActionState, ReactiveActionStatus, ReactiveActionStore, ReactiveState, ReactiveStreamSource, ReactiveStreamStore, Rpc, Signature, SingleTransactionPlan, SolanaRpcApi, SolanaRpcResponse, SuccessfulSingleTransactionPlanResult, TransactionMessage, TransactionPlan, TransactionPlanInput, TransactionPlanResult, TransactionSigner, address, appendTransactionMessageInstruction, compileTransaction, createReactiveActionStore, createReactiveStoreWithInitialValueAndSlotTracking, createTransactionMessage, extendClient, generateKeyPairSigner, getAbortablePromise, getTransactionEncoder, isAbortError, isAddress, lamports, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, summarizeTransactionPlanResult } from '@solana/kit';
14
+ export * from '@solana/kit';
15
+ export { isAbortError } from '@solana/kit';
15
16
  export { AdaptSolanaIosWalletOptions, GetSolanaIosWalletsOptions, IosWalletCallbackResult, IosWalletInfo, IosWalletMethod, SolanaIosWalletAppIdentity, adaptSolanaIosWallet, getDefaultIosWalletAppIdentity, getDefaultIosWalletRedirectUrl, getSolanaIosWallets, handleSolanaIosWalletCallback, isIosBrowser, isSolanaIosBrowserWalletSupported, isSolanaIosWalletInfo } from './ios-wallet.js';
16
17
  export { AdaptSolanaWalletOptions, SOLANA_CHAINS, SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, adaptSolanaStandardWallet, getRegisteredSolanaWallets, getSolanaChain, isSolanaStandardWallet, subscribeSolanaWallets } from './wallet-standard.js';
17
18
  export { Buffer } from 'buffer/';
package/dist/index.mjs CHANGED
@@ -10,10 +10,11 @@ export { getTokenAccount, getTokenAccountsByOwner, getTokenBalance } from './tok
10
10
  export { confirmTransactionSignature, signAndSendTransaction } from './transaction.mjs';
11
11
  export { withSolanaTimeout, withTimeout } from './timeout.mjs';
12
12
  export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignAndSendTransactions, assertWalletCanSignIn, assertWalletCanSignMessage, assertWalletCanSignTransactions, assertWalletConnected, createNoWalletSelectedError, isWalletConnected } from './wallet.mjs';
13
- export { AccountRole, address, appendTransactionMessageInstruction, compileTransaction, createReactiveActionStore, createReactiveStoreWithInitialValueAndSlotTracking, createTransactionMessage, extendClient, generateKeyPairSigner, getAbortablePromise, getTransactionEncoder, isAbortError, isAddress, lamports, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, summarizeTransactionPlanResult } from '@solana/kit';
13
+ export * from '@solana/kit';
14
+ export { isAbortError } from '@solana/kit';
14
15
  export { Buffer } from 'buffer/';
15
- export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.TqudP0hB.mjs';
16
- export { a as adaptSolanaIosWallet, g as getDefaultIosWalletAppIdentity, b as getDefaultIosWalletRedirectUrl, c as getSolanaIosWallets, h as handleSolanaIosWalletCallback, i as isIosBrowser, d as isSolanaIosBrowserWalletSupported, e as isSolanaIosWalletInfo } from './shared/core.CDVW-ApZ.mjs';
16
+ export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.DaUlAmcN.mjs';
17
+ export { a as adaptSolanaIosWallet, g as getDefaultIosWalletAppIdentity, b as getDefaultIosWalletRedirectUrl, c as getSolanaIosWallets, h as handleSolanaIosWalletCallback, i as isIosBrowser, d as isSolanaIosBrowserWalletSupported, e as isSolanaIosWalletInfo } from './shared/core.DuQGQqnc.mjs';
17
18
  import '@solana/kit-plugin-rpc';
18
19
  import '@solana-mobile/wallet-standard-mobile';
19
20
  import '@wallet-standard/features';
@@ -1,4 +1,4 @@
1
- export { a as adaptSolanaIosWallet, g as getDefaultIosWalletAppIdentity, b as getDefaultIosWalletRedirectUrl, c as getSolanaIosWallets, h as handleSolanaIosWalletCallback, i as isIosBrowser, d as isSolanaIosBrowserWalletSupported, e as isSolanaIosWalletInfo } from './shared/core.CDVW-ApZ.mjs';
1
+ export { a as adaptSolanaIosWallet, g as getDefaultIosWalletAppIdentity, b as getDefaultIosWalletRedirectUrl, c as getSolanaIosWallets, h as handleSolanaIosWalletCallback, i as isIosBrowser, d as isSolanaIosBrowserWalletSupported, e as isSolanaIosWalletInfo } from './shared/core.DuQGQqnc.mjs';
2
2
  import '@solana/kit';
3
3
  import 'bs58';
4
4
  import 'tweetnacl';
package/dist/kit.d.mts CHANGED
@@ -1,3 +1,3 @@
1
1
  import '@solana/kit-plugin-rpc';
2
- export { AccountRole, Address, ClientWithIdentity, ClientWithPayer, ClientWithSubscribeToIdentity, ClientWithSubscribeToPayer, ClientWithTransactionPlanning, ClientWithTransactionSending, Commitment, CreateReactiveStoreWithInitialValueAndSlotTrackingConfig, Instruction, InstructionPlanInput, Lamports, ReactiveActionSource, ReactiveActionState, ReactiveActionStatus, ReactiveActionStore, ReactiveState, ReactiveStreamSource, ReactiveStreamStore, Rpc, Signature, SingleTransactionPlan, SolanaRpcApi, SolanaRpcResponse, SuccessfulSingleTransactionPlanResult, TransactionMessage, TransactionPlan, TransactionPlanInput, TransactionPlanResult, TransactionSigner, address, appendTransactionMessageInstruction, compileTransaction, createReactiveActionStore, createReactiveStoreWithInitialValueAndSlotTracking, createTransactionMessage, extendClient, generateKeyPairSigner, getAbortablePromise, getTransactionEncoder, isAbortError, isAddress, lamports, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, summarizeTransactionPlanResult } from '@solana/kit';
2
+ export * from '@solana/kit';
3
3
  export { b as SolanaClient, n as createSolanaClient } from './shared/core.C9vxHRXl.mjs';
package/dist/kit.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import '@solana/kit-plugin-rpc';
2
- export { AccountRole, Address, ClientWithIdentity, ClientWithPayer, ClientWithSubscribeToIdentity, ClientWithSubscribeToPayer, ClientWithTransactionPlanning, ClientWithTransactionSending, Commitment, CreateReactiveStoreWithInitialValueAndSlotTrackingConfig, Instruction, InstructionPlanInput, Lamports, ReactiveActionSource, ReactiveActionState, ReactiveActionStatus, ReactiveActionStore, ReactiveState, ReactiveStreamSource, ReactiveStreamStore, Rpc, Signature, SingleTransactionPlan, SolanaRpcApi, SolanaRpcResponse, SuccessfulSingleTransactionPlanResult, TransactionMessage, TransactionPlan, TransactionPlanInput, TransactionPlanResult, TransactionSigner, address, appendTransactionMessageInstruction, compileTransaction, createReactiveActionStore, createReactiveStoreWithInitialValueAndSlotTracking, createTransactionMessage, extendClient, generateKeyPairSigner, getAbortablePromise, getTransactionEncoder, isAbortError, isAddress, lamports, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, summarizeTransactionPlanResult } from '@solana/kit';
2
+ export * from '@solana/kit';
3
3
  export { b as SolanaClient, n as createSolanaClient } from './shared/core.C9vxHRXl.js';
package/dist/kit.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { getBase64Encoder, getBase58Decoder, signBytes, createClient, extendClient, createKeyPairFromBytes } from '@solana/kit';
2
- export { AccountRole, address, appendTransactionMessageInstruction, compileTransaction, createReactiveActionStore, createReactiveStoreWithInitialValueAndSlotTracking, createTransactionMessage, extendClient, generateKeyPairSigner, getAbortablePromise, getTransactionEncoder, isAbortError, isAddress, lamports, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, summarizeTransactionPlanResult } from '@solana/kit';
1
+ import { getBase64Encoder, getBase58Decoder, signBytes, createClient, extendClient, createKeyPairFromBytes, isSolanaError, SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY } from '@solana/kit';
2
+ export * from '@solana/kit';
3
3
  import { solanaRpc, rpcAirdrop } from '@solana/kit-plugin-rpc';
4
4
  import { DEFAULT_CLUSTER, getClusterEndpoint, getWebSocketEndpoint, getClusterWebSocketEndpoint } from './clusters.mjs';
5
5
 
@@ -37,22 +37,30 @@ function resolvePayerFromSecretKey(payerSecretKey) {
37
37
  if (keyPairBytes.length !== 64) {
38
38
  throw invalidError();
39
39
  }
40
- const address2 = getBase58Decoder().decode(keyPairBytes.slice(32));
40
+ const address = getBase58Decoder().decode(keyPairBytes.slice(32));
41
41
  let privateKey;
42
- const getPrivateKey = () => privateKey ??= createKeyPairFromBytes(keyPairBytes).then(
43
- (keyPair) => keyPair.privateKey,
44
- () => {
42
+ const getPrivateKey = () => privateKey ??= (async () => {
43
+ if (!globalThis.crypto?.subtle) {
44
+ throw new Error(
45
+ "`payerSecretKey` signing needs WebCrypto, which browsers only expose in a secure context (https, or http on localhost)."
46
+ );
47
+ }
48
+ return (await createKeyPairFromBytes(keyPairBytes)).privateKey;
49
+ })().catch((cause) => {
50
+ if (isSolanaError(cause, SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY)) {
45
51
  throw invalidError();
46
52
  }
47
- );
53
+ throw cause;
54
+ });
48
55
  return {
49
- address: address2,
56
+ address,
50
57
  async signTransactions(transactions, config) {
51
58
  config?.abortSignal?.throwIfAborted();
52
59
  const key = await getPrivateKey();
60
+ config?.abortSignal?.throwIfAborted();
53
61
  return Promise.all(
54
62
  transactions.map(async (transaction) => ({
55
- [address2]: await signBytes(key, transaction.messageBytes)
63
+ [address]: await signBytes(key, transaction.messageBytes)
56
64
  }))
57
65
  );
58
66
  }
@@ -104,7 +104,9 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
104
104
  }
105
105
  },
106
106
  signIn: hasSignIn(wallet) ? async (input) => {
107
- const [result] = await wallet.features[SolanaSignIn].signIn(...input ? [input] : []);
107
+ const [result] = await wallet.features[SolanaSignIn].signIn(
108
+ input ?? getDefaultSignInInput(getActiveAccount(account))
109
+ );
108
110
  if (!result) {
109
111
  throw new Error("Solana wallet did not return a sign-in result");
110
112
  }
@@ -133,27 +135,12 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
133
135
  }
134
136
  return result.signedTransaction;
135
137
  } : void 0,
136
- signAllTransactions: hasSignTransaction(wallet) ? async (transactions) => {
137
- const activeAccount = getActiveAccount(account);
138
- const results = await wallet.features[SolanaSignTransaction].signTransaction(
139
- ...transactions.map((transaction) => ({
140
- account: activeAccount,
141
- transaction: new Uint8Array(transaction),
142
- chain: options.chain
143
- }))
144
- );
145
- if (results.length !== transactions.length) {
146
- throw new Error(
147
- `Solana wallet returned ${results.length} signed transactions for ${transactions.length} requested transactions`
148
- );
149
- }
150
- return results.map((result) => {
151
- if (!result) {
152
- throw new Error("Solana wallet did not return a signed transaction");
153
- }
154
- return result.signedTransaction;
155
- });
156
- } : void 0,
138
+ signAllTransactions: hasSignTransaction(wallet) ? async (transactions) => signAllThroughFeature(
139
+ wallet,
140
+ () => getActiveAccount(account),
141
+ transactions,
142
+ options.chain
143
+ ) : void 0,
157
144
  signTransactions: hasSignTransaction(wallet) ? async (transactions) => signAllThroughFeature(
158
145
  wallet,
159
146
  () => getActiveAccount(account),
@@ -218,6 +205,12 @@ async function signAllThroughFeature(wallet, getAccount, transactions, chain) {
218
205
  return result.signedTransaction;
219
206
  });
220
207
  }
208
+ function getDefaultSignInInput(account) {
209
+ return {
210
+ domain: typeof location === "undefined" ? "" : location.host,
211
+ address: account.address
212
+ };
213
+ }
221
214
  function toSolanaSignInResult(result) {
222
215
  return {
223
216
  account: {
@@ -212,47 +212,50 @@ function getStoredIosWalletAccount(walletId, chains) {
212
212
  ];
213
213
  }
214
214
  function getStoredSession(walletId) {
215
- const value = getStorage()?.getItem(`${SESSION_PREFIX}${walletId}`);
216
- if (!value) {
217
- return null;
218
- }
219
- try {
220
- const session = JSON.parse(value);
221
- if (!isAddress(session.publicKey)) {
222
- throw new Error("Invalid stored public key");
223
- }
224
- return session;
225
- } catch {
226
- removeStoredSession(walletId);
227
- return null;
228
- }
215
+ return readJson(
216
+ `${SESSION_PREFIX}${walletId}`,
217
+ (session) => isAddress(session.publicKey)
218
+ );
229
219
  }
230
220
  function storeSession(session) {
231
- getStorage()?.setItem(`${SESSION_PREFIX}${session.walletId}`, JSON.stringify(session));
221
+ writeJson(`${SESSION_PREFIX}${session.walletId}`, session);
232
222
  }
233
223
  function removeStoredSession(walletId) {
234
- getStorage()?.removeItem(`${SESSION_PREFIX}${walletId}`);
224
+ removeJson(`${SESSION_PREFIX}${walletId}`);
235
225
  }
236
226
  function getPendingRequest() {
237
- const value = getStorage()?.getItem(PENDING_REQUEST_KEY);
227
+ return readJson(PENDING_REQUEST_KEY);
228
+ }
229
+ function storePendingRequest(request) {
230
+ writeJson(PENDING_REQUEST_KEY, request);
231
+ }
232
+ function clearPendingRequest() {
233
+ removeJson(PENDING_REQUEST_KEY);
234
+ }
235
+ function isPendingRequestExpired(request) {
236
+ return Date.now() - request.createdAt > PENDING_REQUEST_TTL_MS;
237
+ }
238
+ function readJson(key, validate) {
239
+ const value = getStorage()?.getItem(key);
238
240
  if (!value) {
239
241
  return null;
240
242
  }
241
243
  try {
242
- return JSON.parse(value);
244
+ const parsed = JSON.parse(value);
245
+ if (validate && !validate(parsed)) {
246
+ throw new Error("Invalid stored value");
247
+ }
248
+ return parsed;
243
249
  } catch {
244
- clearPendingRequest();
250
+ getStorage()?.removeItem(key);
245
251
  return null;
246
252
  }
247
253
  }
248
- function storePendingRequest(request) {
249
- getStorage()?.setItem(PENDING_REQUEST_KEY, JSON.stringify(request));
250
- }
251
- function clearPendingRequest() {
252
- getStorage()?.removeItem(PENDING_REQUEST_KEY);
254
+ function writeJson(key, value) {
255
+ getStorage()?.setItem(key, JSON.stringify(value));
253
256
  }
254
- function isPendingRequestExpired(request) {
255
- return Date.now() - request.createdAt > PENDING_REQUEST_TTL_MS;
257
+ function removeJson(key) {
258
+ getStorage()?.removeItem(key);
256
259
  }
257
260
  function getStorage() {
258
261
  if (typeof window === "undefined") {
package/dist/timeout.mjs CHANGED
@@ -7,6 +7,9 @@ function withTimeout(promise, timeoutMs, createError) {
7
7
  let timeoutId;
8
8
  return Promise.race([
9
9
  promise,
10
+ // ponytail: the try/catch looks redundant but is not. `createError()` runs
11
+ // in the `setTimeout` callback, not the executor body, so a throwing
12
+ // factory would be an uncaught exception rather than a rejection.
10
13
  new Promise((_, reject) => {
11
14
  timeoutId = setTimeout(() => {
12
15
  try {
@@ -1,4 +1,4 @@
1
- export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.TqudP0hB.mjs';
1
+ export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.DaUlAmcN.mjs';
2
2
  import '@wallet-standard/features';
3
3
  import '@solana/wallet-standard-features';
4
4
  import 'bs58';
package/dist/wallet.mjs CHANGED
@@ -17,55 +17,42 @@ function assertWalletConnected(wallet) {
17
17
  throw new SolanaWalletError("WALLET_NOT_CONNECTED", "Solana wallet is not connected");
18
18
  }
19
19
  }
20
- function assertWalletCanSign(wallet) {
20
+ function assertWalletFeature(wallet, features, message) {
21
21
  assertWalletConnected(wallet);
22
- if (!wallet.signTransaction) {
23
- throw new SolanaWalletError(
24
- "WALLET_FEATURE_UNSUPPORTED",
25
- "Solana wallet does not support signTransaction",
26
- { feature: "signTransaction" }
27
- );
22
+ if (!features.some((feature) => wallet[feature])) {
23
+ throw new SolanaWalletError("WALLET_FEATURE_UNSUPPORTED", message, { feature: features[0] });
28
24
  }
29
25
  }
26
+ function assertWalletCanSign(wallet) {
27
+ assertWalletFeature(
28
+ wallet,
29
+ ["signTransaction"],
30
+ "Solana wallet does not support signTransaction"
31
+ );
32
+ }
30
33
  function assertWalletCanSignMessage(wallet) {
31
- assertWalletConnected(wallet);
32
- if (!wallet.signMessage) {
33
- throw new SolanaWalletError(
34
- "WALLET_FEATURE_UNSUPPORTED",
35
- "Solana wallet does not support signMessage",
36
- { feature: "signMessage" }
37
- );
38
- }
34
+ assertWalletFeature(wallet, ["signMessage"], "Solana wallet does not support signMessage");
39
35
  }
40
36
  function assertWalletCanSignIn(wallet) {
41
- assertWalletConnected(wallet);
42
- if (!wallet.signIn) {
43
- throw new SolanaWalletError(
44
- "WALLET_FEATURE_UNSUPPORTED",
45
- "Solana wallet does not support signIn (Sign In With Solana)",
46
- { feature: "signIn" }
47
- );
48
- }
37
+ assertWalletFeature(
38
+ wallet,
39
+ ["signIn"],
40
+ "Solana wallet does not support signIn (Sign In With Solana)"
41
+ );
49
42
  }
50
43
  function assertWalletCanSignTransactions(wallet) {
51
- assertWalletConnected(wallet);
52
- if (!wallet.signTransactions && !wallet.signAllTransactions) {
53
- throw new SolanaWalletError(
54
- "WALLET_FEATURE_UNSUPPORTED",
55
- "Solana wallet does not support signTransactions",
56
- { feature: "signTransactions" }
57
- );
58
- }
44
+ assertWalletFeature(
45
+ wallet,
46
+ ["signTransactions", "signAllTransactions"],
47
+ "Solana wallet does not support signTransactions"
48
+ );
59
49
  }
60
50
  function assertWalletCanSignAndSendTransactions(wallet) {
61
- assertWalletConnected(wallet);
62
- if (!wallet.signAndSendTransactions && !wallet.signAndSendTransaction) {
63
- throw new SolanaWalletError(
64
- "WALLET_FEATURE_UNSUPPORTED",
65
- "Solana wallet does not support signAndSendTransactions",
66
- { feature: "signAndSendTransactions" }
67
- );
68
- }
51
+ assertWalletFeature(
52
+ wallet,
53
+ ["signAndSendTransactions", "signAndSendTransaction"],
54
+ "Solana wallet does not support signAndSendTransactions"
55
+ );
69
56
  }
70
57
 
71
58
  export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignAndSendTransactions, assertWalletCanSignIn, assertWalletCanSignMessage, assertWalletCanSignTransactions, assertWalletConnected, createNoWalletSelectedError, isWalletConnected };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-solana/core",
3
- "version": "2.6.0",
3
+ "version": "3.0.0",
4
4
  "description": "Framework-agnostic primitives for Vue Solana libraries.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -22,89 +22,72 @@
22
22
  },
23
23
  "type": "module",
24
24
  "sideEffects": false,
25
- "main": "./dist/index.cjs",
26
25
  "module": "./dist/index.mjs",
27
26
  "types": "./dist/index.d.ts",
28
27
  "exports": {
29
28
  ".": {
30
29
  "types": "./dist/index.d.ts",
31
- "import": "./dist/index.mjs",
32
- "require": "./dist/index.cjs"
30
+ "import": "./dist/index.mjs"
33
31
  },
34
32
  "./address": {
35
33
  "types": "./dist/address.d.ts",
36
- "import": "./dist/address.mjs",
37
- "require": "./dist/address.cjs"
34
+ "import": "./dist/address.mjs"
38
35
  },
39
36
  "./action": {
40
37
  "types": "./dist/action.d.ts",
41
- "import": "./dist/action.mjs",
42
- "require": "./dist/action.cjs"
38
+ "import": "./dist/action.mjs"
43
39
  },
44
40
  "./buffer-polyfill": {
45
41
  "types": "./dist/buffer-polyfill.d.ts",
46
- "import": "./dist/buffer-polyfill.mjs",
47
- "require": "./dist/buffer-polyfill.cjs"
42
+ "import": "./dist/buffer-polyfill.mjs"
48
43
  },
49
44
  "./types": {
50
45
  "types": "./dist/types.d.ts",
51
- "import": "./dist/types.mjs",
52
- "require": "./dist/types.cjs"
46
+ "import": "./dist/types.mjs"
53
47
  },
54
48
  "./clusters": {
55
49
  "types": "./dist/clusters.d.ts",
56
- "import": "./dist/clusters.mjs",
57
- "require": "./dist/clusters.cjs"
50
+ "import": "./dist/clusters.mjs"
58
51
  },
59
52
  "./errors": {
60
53
  "types": "./dist/errors.d.ts",
61
- "import": "./dist/errors.mjs",
62
- "require": "./dist/errors.cjs"
54
+ "import": "./dist/errors.mjs"
63
55
  },
64
56
  "./ios-wallet": {
65
57
  "types": "./dist/ios-wallet.d.ts",
66
- "import": "./dist/ios-wallet.mjs",
67
- "require": "./dist/ios-wallet.cjs"
58
+ "import": "./dist/ios-wallet.mjs"
68
59
  },
69
60
  "./kit": {
70
61
  "types": "./dist/kit.d.ts",
71
- "import": "./dist/kit.mjs",
72
- "require": "./dist/kit.cjs"
62
+ "import": "./dist/kit.mjs"
73
63
  },
74
64
  "./mobile-wallet": {
75
65
  "types": "./dist/mobile-wallet.d.ts",
76
- "import": "./dist/mobile-wallet.mjs",
77
- "require": "./dist/mobile-wallet.cjs"
66
+ "import": "./dist/mobile-wallet.mjs"
78
67
  },
79
68
  "./rpc": {
80
69
  "types": "./dist/rpc.d.ts",
81
- "import": "./dist/rpc.mjs",
82
- "require": "./dist/rpc.cjs"
70
+ "import": "./dist/rpc.mjs"
83
71
  },
84
72
  "./timeout": {
85
73
  "types": "./dist/timeout.d.ts",
86
- "import": "./dist/timeout.mjs",
87
- "require": "./dist/timeout.cjs"
74
+ "import": "./dist/timeout.mjs"
88
75
  },
89
76
  "./transaction": {
90
77
  "types": "./dist/transaction.d.ts",
91
- "import": "./dist/transaction.mjs",
92
- "require": "./dist/transaction.cjs"
78
+ "import": "./dist/transaction.mjs"
93
79
  },
94
80
  "./wallet": {
95
81
  "types": "./dist/wallet.d.ts",
96
- "import": "./dist/wallet.mjs",
97
- "require": "./dist/wallet.cjs"
82
+ "import": "./dist/wallet.mjs"
98
83
  },
99
84
  "./wallet-standard": {
100
85
  "types": "./dist/wallet-standard.d.ts",
101
- "import": "./dist/wallet-standard.mjs",
102
- "require": "./dist/wallet-standard.cjs"
86
+ "import": "./dist/wallet-standard.mjs"
103
87
  },
104
88
  "./token-accounts": {
105
89
  "types": "./dist/token-accounts.d.ts",
106
- "import": "./dist/token-accounts.mjs",
107
- "require": "./dist/token-accounts.cjs"
90
+ "import": "./dist/token-accounts.mjs"
108
91
  }
109
92
  },
110
93
  "files": [
@@ -116,7 +99,7 @@
116
99
  },
117
100
  "dependencies": {
118
101
  "@solana-mobile/wallet-standard-mobile": "^0.5.3",
119
- "@solana/kit": "^8.3.0",
102
+ "@solana/kit": "^8.4.0",
120
103
  "@solana/kit-plugin-rpc": "^0.19.0",
121
104
  "@solana/wallet-standard-features": "^1.3.0",
122
105
  "@wallet-standard/app": "^1.1.1",
package/dist/action.cjs DELETED
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- const kit = require('@solana/kit');
4
-
5
- function createSolanaActionStore(fn) {
6
- return kit.createReactiveActionStore(fn);
7
- }
8
- function isSolanaActionAborted(error) {
9
- return kit.isAbortError(error);
10
- }
11
-
12
- exports.isAbortError = kit.isAbortError;
13
- exports.createSolanaActionStore = createSolanaActionStore;
14
- exports.isSolanaActionAborted = isSolanaActionAborted;
package/dist/action.d.cts DELETED
@@ -1,28 +0,0 @@
1
- import { ReactiveActionState, ReactiveActionStore } from '@solana/kit';
2
- export { isAbortError } from '@solana/kit';
3
-
4
- /**
5
- * Framework-agnostic action state machine for Solana async work.
6
- *
7
- * Wraps an async function receiving a fresh `AbortSignal` per call and exposes a
8
- * `{ getState, subscribe, dispatch, reset, withSignal }` store that UI frameworks
9
- * can bridge into reactive state (Vue composables, React hooks, etc.).
10
- *
11
- * - Each `dispatch` aborts the previous in-flight call (fresh signal per dispatch).
12
- * - Superseded calls reject with an abort error; real failures surface on state.
13
- * - `withSignal` composes a caller-provided cancellation source per dispatch
14
- * (per-attempt timeouts, shared kill switches).
15
- *
16
- * @see `createReactiveActionStore` from `@solana/kit`, which this wraps.
17
- */
18
- type SolanaActionStore<TArgs extends readonly unknown[], TResult> = ReactiveActionStore<TArgs, TResult>;
19
- declare function createSolanaActionStore<TArgs extends readonly unknown[], TResult>(fn: (signal: AbortSignal, ...args: TArgs) => Promise<TResult>): SolanaActionStore<TArgs, TResult>;
20
- /**
21
- * Snapshot shape bridged into reactive state by framework composables.
22
- */
23
- type SolanaActionState<TResult> = ReactiveActionState<TResult>;
24
-
25
- declare function isSolanaActionAborted(error: unknown): boolean;
26
-
27
- export { createSolanaActionStore, isSolanaActionAborted };
28
- export type { SolanaActionState, SolanaActionStore };
package/dist/address.cjs DELETED
@@ -1,33 +0,0 @@
1
- 'use strict';
2
-
3
- const kit = require('@solana/kit');
4
- const errors = require('./errors.cjs');
5
-
6
- function parseAddress(value) {
7
- const input = toAddressInput(value);
8
- if (!input) {
9
- return null;
10
- }
11
- if (kit.isAddress(input)) {
12
- return input;
13
- }
14
- try {
15
- return kit.address(input);
16
- } catch (cause) {
17
- throw errors.createSolanaError("INVALID_ADDRESS", "Invalid Solana address", { cause });
18
- }
19
- }
20
- function toAddressInput(value) {
21
- if (!value) {
22
- return null;
23
- }
24
- if (typeof value === "function") {
25
- return value();
26
- }
27
- if (typeof value === "string") {
28
- return value;
29
- }
30
- return value.value;
31
- }
32
-
33
- exports.parseAddress = parseAddress;
@@ -1,16 +0,0 @@
1
- import { Address } from '@solana/kit';
2
-
3
- type AddressInput = Address | string | null | undefined;
4
- type MaybeAddressInput = AddressInput | {
5
- value: AddressInput;
6
- } | (() => AddressInput);
7
- /**
8
- * Parse a Solana address from a Kit `Address`, string, ref, or getter.
9
- *
10
- * Valid strings are returned as `Address`; invalid input throws a
11
- * `SolanaError` with code `INVALID_ADDRESS`.
12
- */
13
- declare function parseAddress(value: MaybeAddressInput): Address | null;
14
-
15
- export { parseAddress };
16
- export type { AddressInput, MaybeAddressInput };
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- const _ = require('buffer/');
4
-
5
- function installSolanaBufferPolyfill() {
6
- const globalScope = globalThis;
7
- globalScope.Buffer ??= _.Buffer;
8
- return globalScope.Buffer;
9
- }
10
-
11
- exports.Buffer = _.Buffer;
12
- exports.installSolanaBufferPolyfill = installSolanaBufferPolyfill;
@@ -1,7 +0,0 @@
1
- /// <reference path="../types/buffer.d.ts" />
2
- import { Buffer } from 'buffer/';
3
- export { Buffer } from 'buffer/';
4
-
5
- declare function installSolanaBufferPolyfill(): typeof Buffer;
6
-
7
- export { installSolanaBufferPolyfill };