@vue-solana/core 2.6.1 → 3.0.1
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/errors.d.mts +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +6 -11
- package/dist/ios-wallet.mjs +1 -4
- package/dist/kit.d.mts +1 -1
- package/dist/kit.d.ts +1 -1
- package/dist/kit.mjs +4 -4
- package/dist/mobile-wallet-support.d.mts +3 -0
- package/dist/mobile-wallet-support.d.ts +3 -0
- package/dist/mobile-wallet-support.mjs +5 -0
- package/dist/mobile-wallet.d.mts +2 -2
- package/dist/mobile-wallet.d.ts +2 -2
- package/dist/mobile-wallet.mjs +1 -9
- package/dist/rpc.mjs +0 -2
- package/dist/shared/{core.CDVW-ApZ.mjs → core.DJsPYgx_.mjs} +89 -36
- package/dist/shared/{core.TqudP0hB.mjs → core.DaUlAmcN.mjs} +15 -22
- package/dist/timeout.mjs +3 -0
- package/dist/wallet-standard.mjs +1 -5
- package/dist/wallet.mjs +26 -39
- package/package.json +22 -35
- package/dist/action.cjs +0 -14
- package/dist/action.d.cts +0 -28
- package/dist/address.cjs +0 -33
- package/dist/address.d.cts +0 -16
- package/dist/buffer-polyfill.cjs +0 -12
- package/dist/buffer-polyfill.d.cts +0 -7
- package/dist/clusters.cjs +0 -37
- package/dist/clusters.d.cts +0 -10
- package/dist/errors.cjs +0 -50
- package/dist/errors.d.cts +0 -17
- package/dist/index.cjs +0 -94
- package/dist/index.d.cts +0 -19
- package/dist/ios-wallet.cjs +0 -17
- package/dist/ios-wallet.d.cts +0 -62
- package/dist/kit.cjs +0 -88
- package/dist/kit.d.cts +0 -3
- package/dist/mobile-wallet.cjs +0 -69
- package/dist/mobile-wallet.d.cts +0 -20
- package/dist/rpc.cjs +0 -20
- package/dist/rpc.d.cts +0 -7
- package/dist/shared/core.C9vxHRXl.d.cts +0 -193
- package/dist/shared/core.CasnoavM.cjs +0 -323
- package/dist/shared/core.eIBHqmLq.cjs +0 -598
- package/dist/timeout.cjs +0 -32
- package/dist/timeout.d.cts +0 -4
- package/dist/token-accounts.cjs +0 -72
- package/dist/token-accounts.d.cts +0 -36
- package/dist/transaction.cjs +0 -81
- package/dist/transaction.d.cts +0 -18
- package/dist/types.cjs +0 -2
- package/dist/types.d.cts +0 -3
- package/dist/wallet-standard.cjs +0 -17
- package/dist/wallet-standard.d.cts +0 -22
- package/dist/wallet.cjs +0 -81
- 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
|
|
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 |
|
|
45
|
+
| Runtime | ESM only (modern bundlers; Node needs ESM) |
|
|
46
46
|
| TypeScript | TypeScript 5.x recommended |
|
|
47
|
-
| Solana client | `@solana/kit@^8.
|
|
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/errors.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type SolanaErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED" | "USER_REJECTED" | "INVALID_ADDRESS" | "TRANSACTION_TIMEOUT" | "RPC_FAILURE" | "STORAGE_FAILURE";
|
|
1
|
+
type SolanaErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED" | "USER_REJECTED" | "INVALID_ADDRESS" | "TRANSACTION_TIMEOUT" | "RPC_FAILURE" | "STORAGE_FAILURE" | "INVALID_INPUT" | "DECRYPTION_FAILED";
|
|
2
2
|
interface SolanaErrorOptions {
|
|
3
3
|
cause?: unknown;
|
|
4
4
|
feature?: string;
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type SolanaErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED" | "USER_REJECTED" | "INVALID_ADDRESS" | "TRANSACTION_TIMEOUT" | "RPC_FAILURE" | "STORAGE_FAILURE";
|
|
1
|
+
type SolanaErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED" | "USER_REJECTED" | "INVALID_ADDRESS" | "TRANSACTION_TIMEOUT" | "RPC_FAILURE" | "STORAGE_FAILURE" | "INVALID_INPUT" | "DECRYPTION_FAILED";
|
|
2
2
|
interface SolanaErrorOptions {
|
|
3
3
|
cause?: unknown;
|
|
4
4
|
feature?: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -5,15 +5,17 @@ export { AddressInput, MaybeAddressInput, parseAddress } from './address.mjs';
|
|
|
5
5
|
export { installSolanaBufferPolyfill } from './buffer-polyfill.mjs';
|
|
6
6
|
export { SolanaError, SolanaErrorCode, SolanaErrorOptions, createSolanaError, isSolanaError, normalizeSolanaError } from './errors.mjs';
|
|
7
7
|
export { C as ConfirmTransactionOptions, S as SendTransactionOptions, a as SolanaChain, b as SolanaClient, c as SolanaCluster, d as SolanaConfig, e as SolanaContext, f as SolanaSignInAccount, g as SolanaSignInInput, h as SolanaSignInResult, i as SolanaSignMessageResult, j as SolanaTransaction, k as SolanaWallet, l as SolanaWalletInfo, T as TransactionConfirmation, m as TransactionStatus, n as createSolanaClient } from './shared/core.C9vxHRXl.mjs';
|
|
8
|
-
export { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity, getDefaultMobileWalletAppIdentity,
|
|
8
|
+
export { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity, getDefaultMobileWalletAppIdentity, registerSolanaMobileWallet } from './mobile-wallet.mjs';
|
|
9
9
|
export { createSolanaContext } from './rpc.mjs';
|
|
10
10
|
export { TokenAccountInfo, TokenAccountsByOwnerOptions, TokenBalanceResult, getTokenAccount, getTokenAccountsByOwner, getTokenBalance } from './token-accounts.mjs';
|
|
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
|
|
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/';
|
|
19
|
+
export { isSolanaMobileWalletSupported } from './mobile-wallet-support.mjs';
|
|
18
20
|
import '@solana/kit-plugin-rpc';
|
|
19
21
|
import '@wallet-standard/base';
|
package/dist/index.d.ts
CHANGED
|
@@ -5,15 +5,17 @@ export { AddressInput, MaybeAddressInput, parseAddress } from './address.js';
|
|
|
5
5
|
export { installSolanaBufferPolyfill } from './buffer-polyfill.js';
|
|
6
6
|
export { SolanaError, SolanaErrorCode, SolanaErrorOptions, createSolanaError, isSolanaError, normalizeSolanaError } from './errors.js';
|
|
7
7
|
export { C as ConfirmTransactionOptions, S as SendTransactionOptions, a as SolanaChain, b as SolanaClient, c as SolanaCluster, d as SolanaConfig, e as SolanaContext, f as SolanaSignInAccount, g as SolanaSignInInput, h as SolanaSignInResult, i as SolanaSignMessageResult, j as SolanaTransaction, k as SolanaWallet, l as SolanaWalletInfo, T as TransactionConfirmation, m as TransactionStatus, n as createSolanaClient } from './shared/core.C9vxHRXl.js';
|
|
8
|
-
export { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity, getDefaultMobileWalletAppIdentity,
|
|
8
|
+
export { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity, getDefaultMobileWalletAppIdentity, registerSolanaMobileWallet } from './mobile-wallet.js';
|
|
9
9
|
export { createSolanaContext } from './rpc.js';
|
|
10
10
|
export { TokenAccountInfo, TokenAccountsByOwnerOptions, TokenBalanceResult, getTokenAccount, getTokenAccountsByOwner, getTokenBalance } from './token-accounts.js';
|
|
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
|
|
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/';
|
|
19
|
+
export { isSolanaMobileWalletSupported } from './mobile-wallet-support.js';
|
|
18
20
|
import '@solana/kit-plugin-rpc';
|
|
19
21
|
import '@wallet-standard/base';
|
package/dist/index.mjs
CHANGED
|
@@ -4,20 +4,15 @@ export { parseAddress } from './address.mjs';
|
|
|
4
4
|
export { installSolanaBufferPolyfill } from './buffer-polyfill.mjs';
|
|
5
5
|
export { SolanaError, createSolanaError, isSolanaError, normalizeSolanaError } from './errors.mjs';
|
|
6
6
|
export { createSolanaClient } from './kit.mjs';
|
|
7
|
-
export { getDefaultMobileWalletAppIdentity,
|
|
7
|
+
export { getDefaultMobileWalletAppIdentity, registerSolanaMobileWallet } from './mobile-wallet.mjs';
|
|
8
8
|
export { createSolanaContext } from './rpc.mjs';
|
|
9
9
|
export { getTokenAccount, getTokenAccountsByOwner, getTokenBalance } from './token-accounts.mjs';
|
|
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
|
|
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.
|
|
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.
|
|
17
|
-
|
|
18
|
-
import '@solana-mobile/wallet-standard-mobile';
|
|
19
|
-
import '@wallet-standard/features';
|
|
20
|
-
import '@solana/wallet-standard-features';
|
|
21
|
-
import 'bs58';
|
|
22
|
-
import '@wallet-standard/app';
|
|
23
|
-
import 'tweetnacl';
|
|
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.DJsPYgx_.mjs';
|
|
18
|
+
export { isSolanaMobileWalletSupported } from './mobile-wallet-support.mjs';
|
package/dist/ios-wallet.mjs
CHANGED
|
@@ -1,4 +1 @@
|
|
|
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.
|
|
2
|
-
import '@solana/kit';
|
|
3
|
-
import 'bs58';
|
|
4
|
-
import 'tweetnacl';
|
|
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.DJsPYgx_.mjs';
|
package/dist/kit.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '@solana/kit-plugin-rpc';
|
|
2
|
-
export
|
|
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
|
|
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
1
|
import { getBase64Encoder, getBase58Decoder, signBytes, createClient, extendClient, createKeyPairFromBytes, isSolanaError, SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY } from '@solana/kit';
|
|
2
|
-
export
|
|
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,7 +37,7 @@ function resolvePayerFromSecretKey(payerSecretKey) {
|
|
|
37
37
|
if (keyPairBytes.length !== 64) {
|
|
38
38
|
throw invalidError();
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const address = getBase58Decoder().decode(keyPairBytes.slice(32));
|
|
41
41
|
let privateKey;
|
|
42
42
|
const getPrivateKey = () => privateKey ??= (async () => {
|
|
43
43
|
if (!globalThis.crypto?.subtle) {
|
|
@@ -53,14 +53,14 @@ function resolvePayerFromSecretKey(payerSecretKey) {
|
|
|
53
53
|
throw cause;
|
|
54
54
|
});
|
|
55
55
|
return {
|
|
56
|
-
address
|
|
56
|
+
address,
|
|
57
57
|
async signTransactions(transactions, config) {
|
|
58
58
|
config?.abortSignal?.throwIfAborted();
|
|
59
59
|
const key = await getPrivateKey();
|
|
60
60
|
config?.abortSignal?.throwIfAborted();
|
|
61
61
|
return Promise.all(
|
|
62
62
|
transactions.map(async (transaction) => ({
|
|
63
|
-
[
|
|
63
|
+
[address]: await signBytes(key, transaction.messageBytes)
|
|
64
64
|
}))
|
|
65
65
|
);
|
|
66
66
|
}
|
package/dist/mobile-wallet.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { isSolanaMobileWalletSupported } from './mobile-wallet-support.mjs';
|
|
1
2
|
import { a as SolanaChain } from './shared/core.C9vxHRXl.mjs';
|
|
2
3
|
import '@solana/kit-plugin-rpc';
|
|
3
4
|
import '@solana/kit';
|
|
@@ -13,8 +14,7 @@ interface RegisterSolanaMobileWalletOptions {
|
|
|
13
14
|
remoteHostAuthority?: string;
|
|
14
15
|
}
|
|
15
16
|
declare function registerSolanaMobileWallet(options?: RegisterSolanaMobileWalletOptions): boolean;
|
|
16
|
-
declare function isSolanaMobileWalletSupported(): boolean;
|
|
17
17
|
declare function getDefaultMobileWalletAppIdentity(): SolanaMobileWalletAppIdentity;
|
|
18
18
|
|
|
19
|
-
export { getDefaultMobileWalletAppIdentity,
|
|
19
|
+
export { getDefaultMobileWalletAppIdentity, registerSolanaMobileWallet };
|
|
20
20
|
export type { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity };
|
package/dist/mobile-wallet.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { isSolanaMobileWalletSupported } from './mobile-wallet-support.js';
|
|
1
2
|
import { a as SolanaChain } from './shared/core.C9vxHRXl.js';
|
|
2
3
|
import '@solana/kit-plugin-rpc';
|
|
3
4
|
import '@solana/kit';
|
|
@@ -13,8 +14,7 @@ interface RegisterSolanaMobileWalletOptions {
|
|
|
13
14
|
remoteHostAuthority?: string;
|
|
14
15
|
}
|
|
15
16
|
declare function registerSolanaMobileWallet(options?: RegisterSolanaMobileWalletOptions): boolean;
|
|
16
|
-
declare function isSolanaMobileWalletSupported(): boolean;
|
|
17
17
|
declare function getDefaultMobileWalletAppIdentity(): SolanaMobileWalletAppIdentity;
|
|
18
18
|
|
|
19
|
-
export { getDefaultMobileWalletAppIdentity,
|
|
19
|
+
export { getDefaultMobileWalletAppIdentity, registerSolanaMobileWallet };
|
|
20
20
|
export type { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity };
|
package/dist/mobile-wallet.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { registerMwa, createDefaultWalletNotFoundHandler, createDefaultChainSelector, createDefaultAuthorizationCache } from '@solana-mobile/wallet-standard-mobile';
|
|
2
|
+
import { isSolanaMobileWalletSupported } from './mobile-wallet-support.mjs';
|
|
2
3
|
|
|
3
4
|
const DEFAULT_MOBILE_WALLET_CHAINS = ["solana:mainnet", "solana:devnet"];
|
|
4
5
|
const registeredMobileWalletKeys = /* @__PURE__ */ new Set();
|
|
@@ -27,15 +28,6 @@ function registerSolanaMobileWallet(options = {}) {
|
|
|
27
28
|
registeredMobileWalletKeys.add(registrationKey);
|
|
28
29
|
return true;
|
|
29
30
|
}
|
|
30
|
-
function isSolanaMobileWalletSupported() {
|
|
31
|
-
if (typeof window === "undefined" || typeof navigator === "undefined") {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
const userAgent = navigator.userAgent;
|
|
35
|
-
const isAndroid = /Android/i.test(userAgent);
|
|
36
|
-
const isChrome = /Chrome|CriOS/i.test(userAgent) && !/Edg|OPR|Firefox|FxiOS/i.test(userAgent);
|
|
37
|
-
return isAndroid && isChrome;
|
|
38
|
-
}
|
|
39
31
|
function getDefaultMobileWalletAppIdentity() {
|
|
40
32
|
if (typeof window === "undefined") {
|
|
41
33
|
return {
|
package/dist/rpc.mjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_CLUSTER, getClusterEndpoint, getWebSocketEndpoint, getClusterWebSocketEndpoint } from './clusters.mjs';
|
|
2
2
|
import { createSolanaClient } from './kit.mjs';
|
|
3
|
-
import '@solana/kit';
|
|
4
|
-
import '@solana/kit-plugin-rpc';
|
|
5
3
|
|
|
6
4
|
function createSolanaContext(config = {}) {
|
|
7
5
|
const cluster = config.cluster ?? DEFAULT_CLUSTER;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isAddress } from '@solana/kit';
|
|
2
2
|
import bs58 from 'bs58';
|
|
3
3
|
import * as naclModule from 'tweetnacl';
|
|
4
|
+
import { createSolanaError } from '../errors.mjs';
|
|
4
5
|
|
|
5
6
|
const DEFAULT_IOS_WALLET_CHAINS = [
|
|
6
7
|
"solana:mainnet",
|
|
@@ -106,25 +107,74 @@ function isObjectRecord(value) {
|
|
|
106
107
|
return typeof value === "object" && value !== null;
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
|
|
110
|
+
let cachedNacl;
|
|
111
|
+
function getNacl() {
|
|
112
|
+
return cachedNacl ??= resolveTweetNaCl();
|
|
113
|
+
}
|
|
110
114
|
function createRequestId() {
|
|
111
|
-
return bs58.encode(
|
|
115
|
+
return bs58.encode(getNacl().randomBytes(16));
|
|
112
116
|
}
|
|
113
117
|
function getSharedSecret(walletEncryptionPublicKey, dappSecretKey) {
|
|
114
118
|
if (!walletEncryptionPublicKey) {
|
|
115
|
-
throw
|
|
119
|
+
throw createSolanaError("INVALID_INPUT", "Missing iOS wallet encryption public key");
|
|
120
|
+
}
|
|
121
|
+
let walletPk;
|
|
122
|
+
let dappSk;
|
|
123
|
+
try {
|
|
124
|
+
walletPk = bs58.decode(walletEncryptionPublicKey);
|
|
125
|
+
dappSk = bs58.decode(dappSecretKey);
|
|
126
|
+
} catch (cause) {
|
|
127
|
+
throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet encryption key encoding", {
|
|
128
|
+
cause
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
if (walletPk.length !== getNacl().box.publicKeyLength) {
|
|
132
|
+
throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet encryption public key length");
|
|
133
|
+
}
|
|
134
|
+
if (dappSk.length !== getNacl().box.secretKeyLength) {
|
|
135
|
+
throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet dapp secret key length");
|
|
116
136
|
}
|
|
117
|
-
return
|
|
137
|
+
return getNacl().box.before(walletPk, dappSk);
|
|
118
138
|
}
|
|
119
139
|
function encryptPayload(payload, nonce, sharedSecret) {
|
|
120
|
-
|
|
140
|
+
if (sharedSecret.length !== getNacl().box.sharedKeyLength) {
|
|
141
|
+
throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet shared secret length");
|
|
142
|
+
}
|
|
143
|
+
if (nonce.length !== getNacl().box.nonceLength) {
|
|
144
|
+
throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet nonce length");
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
return bs58.encode(getNacl().box.after(encodeJson(payload), nonce, sharedSecret));
|
|
148
|
+
} catch (cause) {
|
|
149
|
+
throw createSolanaError("INVALID_INPUT", "Failed to encrypt iOS wallet payload", { cause });
|
|
150
|
+
}
|
|
121
151
|
}
|
|
122
152
|
function decryptPayload(data, nonce, sharedSecret) {
|
|
123
|
-
|
|
153
|
+
let decodedData;
|
|
154
|
+
let decodedNonce;
|
|
155
|
+
try {
|
|
156
|
+
decodedData = bs58.decode(data);
|
|
157
|
+
decodedNonce = bs58.decode(nonce);
|
|
158
|
+
} catch (cause) {
|
|
159
|
+
throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet callback encoding", { cause });
|
|
160
|
+
}
|
|
161
|
+
if (sharedSecret.length !== getNacl().box.sharedKeyLength) {
|
|
162
|
+
throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet shared secret length");
|
|
163
|
+
}
|
|
164
|
+
if (decodedNonce.length !== getNacl().box.nonceLength) {
|
|
165
|
+
throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet callback nonce length");
|
|
166
|
+
}
|
|
167
|
+
const decrypted = getNacl().box.open.after(decodedData, decodedNonce, sharedSecret);
|
|
124
168
|
if (!decrypted) {
|
|
125
|
-
throw
|
|
169
|
+
throw createSolanaError("DECRYPTION_FAILED", "Unable to decrypt iOS wallet callback");
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
return JSON.parse(new TextDecoder().decode(decrypted));
|
|
173
|
+
} catch (cause) {
|
|
174
|
+
throw createSolanaError("DECRYPTION_FAILED", "Unable to decode iOS wallet callback payload", {
|
|
175
|
+
cause
|
|
176
|
+
});
|
|
126
177
|
}
|
|
127
|
-
return JSON.parse(new TextDecoder().decode(decrypted));
|
|
128
178
|
}
|
|
129
179
|
function resolveTweetNaCl() {
|
|
130
180
|
const moduleDefault = naclModule.default;
|
|
@@ -212,47 +262,50 @@ function getStoredIosWalletAccount(walletId, chains) {
|
|
|
212
262
|
];
|
|
213
263
|
}
|
|
214
264
|
function getStoredSession(walletId) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
}
|
|
265
|
+
return readJson(
|
|
266
|
+
`${SESSION_PREFIX}${walletId}`,
|
|
267
|
+
(session) => isAddress(session.publicKey)
|
|
268
|
+
);
|
|
229
269
|
}
|
|
230
270
|
function storeSession(session) {
|
|
231
|
-
|
|
271
|
+
writeJson(`${SESSION_PREFIX}${session.walletId}`, session);
|
|
232
272
|
}
|
|
233
273
|
function removeStoredSession(walletId) {
|
|
234
|
-
|
|
274
|
+
removeJson(`${SESSION_PREFIX}${walletId}`);
|
|
235
275
|
}
|
|
236
276
|
function getPendingRequest() {
|
|
237
|
-
|
|
277
|
+
return readJson(PENDING_REQUEST_KEY);
|
|
278
|
+
}
|
|
279
|
+
function storePendingRequest(request) {
|
|
280
|
+
writeJson(PENDING_REQUEST_KEY, request);
|
|
281
|
+
}
|
|
282
|
+
function clearPendingRequest() {
|
|
283
|
+
removeJson(PENDING_REQUEST_KEY);
|
|
284
|
+
}
|
|
285
|
+
function isPendingRequestExpired(request) {
|
|
286
|
+
return Date.now() - request.createdAt > PENDING_REQUEST_TTL_MS;
|
|
287
|
+
}
|
|
288
|
+
function readJson(key, validate) {
|
|
289
|
+
const value = getStorage()?.getItem(key);
|
|
238
290
|
if (!value) {
|
|
239
291
|
return null;
|
|
240
292
|
}
|
|
241
293
|
try {
|
|
242
|
-
|
|
294
|
+
const parsed = JSON.parse(value);
|
|
295
|
+
if (validate && !validate(parsed)) {
|
|
296
|
+
throw new Error("Invalid stored value");
|
|
297
|
+
}
|
|
298
|
+
return parsed;
|
|
243
299
|
} catch {
|
|
244
|
-
|
|
300
|
+
getStorage()?.removeItem(key);
|
|
245
301
|
return null;
|
|
246
302
|
}
|
|
247
303
|
}
|
|
248
|
-
function
|
|
249
|
-
getStorage()?.setItem(
|
|
304
|
+
function writeJson(key, value) {
|
|
305
|
+
getStorage()?.setItem(key, JSON.stringify(value));
|
|
250
306
|
}
|
|
251
|
-
function
|
|
252
|
-
getStorage()?.removeItem(
|
|
253
|
-
}
|
|
254
|
-
function isPendingRequestExpired(request) {
|
|
255
|
-
return Date.now() - request.createdAt > PENDING_REQUEST_TTL_MS;
|
|
307
|
+
function removeJson(key) {
|
|
308
|
+
getStorage()?.removeItem(key);
|
|
256
309
|
}
|
|
257
310
|
function getStorage() {
|
|
258
311
|
if (typeof window === "undefined") {
|
|
@@ -380,7 +433,7 @@ function getPublicKeyField(payload, field) {
|
|
|
380
433
|
}
|
|
381
434
|
|
|
382
435
|
function launchConnect(definition, options) {
|
|
383
|
-
const keyPair =
|
|
436
|
+
const keyPair = getNacl().box.keyPair();
|
|
384
437
|
const pending = createPendingRequest(definition.id, "connect", keyPair, options.redirectUrl);
|
|
385
438
|
const appIdentity = options.appIdentity ?? getDefaultIosWalletAppIdentity();
|
|
386
439
|
const url = new URL(definition.connectUrl);
|
|
@@ -442,7 +495,7 @@ async function launchEncryptedWalletRequest(definition, method, options, payload
|
|
|
442
495
|
options.redirectUrl,
|
|
443
496
|
method === "signAllTransactions" && Array.isArray(payload.transactions) ? payload.transactions.length : void 0
|
|
444
497
|
);
|
|
445
|
-
const nonce =
|
|
498
|
+
const nonce = getNacl().randomBytes(getNacl().box.nonceLength);
|
|
446
499
|
const encryptedPayload = encryptPayload(
|
|
447
500
|
{ ...payload, session: session.session },
|
|
448
501
|
nonce,
|
|
@@ -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(
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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: {
|
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 {
|
package/dist/wallet-standard.mjs
CHANGED
|
@@ -1,5 +1 @@
|
|
|
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.
|
|
2
|
-
import '@wallet-standard/features';
|
|
3
|
-
import '@solana/wallet-standard-features';
|
|
4
|
-
import 'bs58';
|
|
5
|
-
import '@wallet-standard/app';
|
|
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';
|
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
|
|
20
|
+
function assertWalletFeature(wallet, features, message) {
|
|
21
21
|
assertWalletConnected(wallet);
|
|
22
|
-
if (!
|
|
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
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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 };
|