@vue-solana/core 0.5.1 → 0.7.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 -3
- package/dist/address.cjs +9 -1
- package/dist/address.mjs +9 -1
- package/dist/errors.cjs +50 -0
- package/dist/errors.d.cts +17 -0
- package/dist/errors.d.mts +17 -0
- package/dist/errors.d.ts +17 -0
- package/dist/errors.mjs +45 -0
- package/dist/index.cjs +13 -2
- package/dist/index.d.cts +4 -2
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +5 -3
- package/dist/ios-wallet.cjs +1 -1
- package/dist/ios-wallet.mjs +1 -1
- package/dist/shared/{core.DJZldB_x.cjs → core.BsekSwcZ.cjs} +87 -85
- package/dist/shared/{core.DSI7vIfT.mjs → core.Ch_Z7_17.mjs} +87 -85
- package/dist/shared/{core.D7olTUN_.mjs → core.DSMNiaHD.mjs} +23 -1
- package/dist/shared/{core.8V8PLE-S.cjs → core.DX2frf65.cjs} +22 -0
- package/dist/timeout.cjs +32 -0
- package/dist/timeout.d.cts +4 -0
- package/dist/timeout.d.mts +4 -0
- package/dist/timeout.d.ts +4 -0
- package/dist/timeout.mjs +29 -0
- package/dist/transaction.cjs +30 -30
- package/dist/transaction.mjs +30 -30
- package/dist/types.d.cts +8 -1
- package/dist/types.d.mts +8 -1
- package/dist/types.d.ts +8 -1
- package/dist/wallet-standard.cjs +1 -1
- package/dist/wallet-standard.mjs +1 -1
- package/dist/wallet.cjs +30 -2
- package/dist/wallet.d.cts +12 -1
- package/dist/wallet.d.mts +12 -1
- package/dist/wallet.d.ts +12 -1
- package/dist/wallet.mjs +28 -3
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Framework-agnostic Solana primitives used by the Vue Solana packages.
|
|
4
4
|
|
|
5
|
-
Use this package directly when you want connection helpers, shared wallet types, Android Mobile Wallet Adapter registration helpers, and transaction helpers without installing the Vue plugin.
|
|
5
|
+
Use this package directly when you want connection helpers, shared wallet types, Android Mobile Wallet Adapter registration helpers, message signing support, and transaction helpers without installing the Vue plugin.
|
|
6
6
|
|
|
7
7
|
`@vue-solana/core` does not replace `@solana/web3-compat`. Use `@solana/web3-compat` for raw Solana primitives like `Connection`, `PublicKey`, and transactions. Use `@vue-solana/core` for Vue Solana shared configuration, cluster endpoint defaults, wallet interfaces, and transaction helpers.
|
|
8
8
|
|
|
@@ -101,6 +101,7 @@ Direct subpaths:
|
|
|
101
101
|
- `getWebSocketEndpoint(endpoint)`: converts `http`/`https` RPC URLs to `ws`/`wss` URLs.
|
|
102
102
|
- `isWalletConnected(wallet)`: checks whether a wallet is connected and has a public key.
|
|
103
103
|
- `assertWalletConnected(wallet)`: throws if the wallet is not connected.
|
|
104
|
+
- `assertWalletCanSignMessage(wallet)`: throws if the wallet is disconnected or cannot sign messages.
|
|
104
105
|
- `assertWalletCanSign(wallet)`: throws if the wallet cannot sign transactions.
|
|
105
106
|
- `signAndSendTransaction(connection, wallet, transaction, options?)`: signs and sends a transaction using a configured wallet. Android Mobile Wallet Adapter wallets prefer `signTransaction` plus app-side RPC submission when available so the app can reliably return the submitted signature.
|
|
106
107
|
- `confirmTransactionSignature(connection, signature, options?)`: waits for a submitted signature to reach a requested commitment. Defaults to `confirmed` commitment and a 60 second timeout.
|
|
@@ -115,17 +116,19 @@ const wallet: SolanaWallet = {
|
|
|
115
116
|
connected: false,
|
|
116
117
|
connect: async () => {},
|
|
117
118
|
disconnect: async () => {},
|
|
119
|
+
signMessage: async (message) => ({ signedMessage: message, signature: new Uint8Array() }),
|
|
118
120
|
signTransaction: async (transaction) => transaction,
|
|
119
121
|
};
|
|
120
122
|
```
|
|
121
123
|
|
|
122
|
-
Browser extension wallets discovered through the Solana Wallet Standard are adapted into `SolanaWallet`. Android Mobile Wallet Adapter is registered through `@solana-mobile/wallet-standard-mobile` and then adapted through the same Wallet Standard adapter on supported Android Chrome clients. iOS browser wallet entries for Phantom, Solflare, and Backpack are adapted through wallet-specific universal links. You can also provide a custom object that implements `SolanaWallet` for tests or custom adapters.
|
|
124
|
+
Browser extension wallets discovered through the Solana Wallet Standard are adapted into `SolanaWallet`. Android Mobile Wallet Adapter is registered through `@solana-mobile/wallet-standard-mobile` and then adapted through the same Wallet Standard adapter on supported Android Chrome clients. iOS browser wallet entries for Phantom, Solflare, and Backpack are adapted through wallet-specific universal links. Wallet capability metadata exposes whether each wallet supports message signing, transaction signing, and sign-and-send flows. You can also provide a custom object that implements `SolanaWallet` for tests or custom adapters.
|
|
123
125
|
|
|
124
126
|
Current wallet support:
|
|
125
127
|
|
|
126
128
|
- Browser extension wallets through Wallet Standard packages.
|
|
127
129
|
- Android native mobile wallets through `@solana-mobile/wallet-standard-mobile` on Android Chrome and Chrome PWAs.
|
|
128
130
|
- iOS browser wallets for Phantom, Solflare, and Backpack through wallet-specific universal links.
|
|
131
|
+
- Message signing when the active wallet exposes `signMessage`.
|
|
129
132
|
- Manual/custom wallet objects that implement `SolanaWallet`.
|
|
130
133
|
|
|
131
134
|
Planned but not supported yet:
|
|
@@ -183,4 +186,4 @@ Make sure your `tsconfig.json` includes `types/**/*.d.ts` or another pattern tha
|
|
|
183
186
|
|
|
184
187
|
## Status
|
|
185
188
|
|
|
186
|
-
This package is early-stage. RPC helpers, browser extension wallet primitives, Android mobile wallet registration, and transaction helpers are usable.
|
|
189
|
+
This package is early-stage. RPC helpers, browser extension wallet primitives, Android mobile wallet registration, message signing, and transaction helpers are usable.
|
package/dist/address.cjs
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const web3Compat = require('@solana/web3-compat');
|
|
4
|
+
const errors = require('./errors.cjs');
|
|
4
5
|
|
|
5
6
|
function parsePublicKey(value) {
|
|
6
7
|
const publicKeyInput = toPublicKeyInput(value);
|
|
7
8
|
if (!publicKeyInput) {
|
|
8
9
|
return null;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
if (typeof publicKeyInput !== "string") {
|
|
12
|
+
return publicKeyInput;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
return new web3Compat.PublicKey(publicKeyInput);
|
|
16
|
+
} catch (cause) {
|
|
17
|
+
throw errors.createSolanaError("INVALID_ADDRESS", "Invalid Solana address", { cause });
|
|
18
|
+
}
|
|
11
19
|
}
|
|
12
20
|
function toPublicKeyInput(value) {
|
|
13
21
|
if (!value) {
|
package/dist/address.mjs
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3-compat';
|
|
2
|
+
import { createSolanaError } from './errors.mjs';
|
|
2
3
|
|
|
3
4
|
function parsePublicKey(value) {
|
|
4
5
|
const publicKeyInput = toPublicKeyInput(value);
|
|
5
6
|
if (!publicKeyInput) {
|
|
6
7
|
return null;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
if (typeof publicKeyInput !== "string") {
|
|
10
|
+
return publicKeyInput;
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
return new PublicKey(publicKeyInput);
|
|
14
|
+
} catch (cause) {
|
|
15
|
+
throw createSolanaError("INVALID_ADDRESS", "Invalid Solana address", { cause });
|
|
16
|
+
}
|
|
9
17
|
}
|
|
10
18
|
function toPublicKeyInput(value) {
|
|
11
19
|
if (!value) {
|
package/dist/errors.cjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
class SolanaError extends Error {
|
|
4
|
+
constructor(code, message, options = {}) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.name = "SolanaError";
|
|
8
|
+
this.cause = options.cause;
|
|
9
|
+
this.feature = options.feature;
|
|
10
|
+
}
|
|
11
|
+
cause;
|
|
12
|
+
feature;
|
|
13
|
+
}
|
|
14
|
+
function createSolanaError(code, message, options) {
|
|
15
|
+
return new SolanaError(code, message, options);
|
|
16
|
+
}
|
|
17
|
+
function isSolanaError(error) {
|
|
18
|
+
return error instanceof SolanaError;
|
|
19
|
+
}
|
|
20
|
+
function normalizeSolanaError(cause, fallbackCode, fallbackMessage, options = {}) {
|
|
21
|
+
if (isSolanaError(cause)) {
|
|
22
|
+
return cause;
|
|
23
|
+
}
|
|
24
|
+
const code = isUserRejectedError(cause) ? "USER_REJECTED" : fallbackCode;
|
|
25
|
+
const message = fallbackMessage ?? getErrorMessage(cause);
|
|
26
|
+
return createSolanaError(code, message, { ...options, cause });
|
|
27
|
+
}
|
|
28
|
+
function getErrorMessage(cause) {
|
|
29
|
+
if (cause instanceof Error) {
|
|
30
|
+
return cause.message;
|
|
31
|
+
}
|
|
32
|
+
return typeof cause === "string" ? cause : "An unknown Solana error occurred";
|
|
33
|
+
}
|
|
34
|
+
function isUserRejectedError(cause) {
|
|
35
|
+
if (hasErrorCode(cause) && (cause.code === 4001 || cause.code === "4001")) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
const message = getErrorMessage(cause).toLowerCase();
|
|
39
|
+
return message.includes("user rejected") || message.includes("user denied");
|
|
40
|
+
}
|
|
41
|
+
function hasErrorCode(cause) {
|
|
42
|
+
return Boolean(
|
|
43
|
+
cause && typeof cause === "object" && "code" in cause && (typeof cause.code === "number" || typeof cause.code === "string")
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.SolanaError = SolanaError;
|
|
48
|
+
exports.createSolanaError = createSolanaError;
|
|
49
|
+
exports.isSolanaError = isSolanaError;
|
|
50
|
+
exports.normalizeSolanaError = normalizeSolanaError;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type SolanaErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED" | "USER_REJECTED" | "INVALID_ADDRESS" | "TRANSACTION_TIMEOUT" | "RPC_FAILURE" | "STORAGE_FAILURE";
|
|
2
|
+
interface SolanaErrorOptions {
|
|
3
|
+
cause?: unknown;
|
|
4
|
+
feature?: string;
|
|
5
|
+
}
|
|
6
|
+
declare class SolanaError extends Error {
|
|
7
|
+
readonly code: SolanaErrorCode;
|
|
8
|
+
readonly cause?: unknown;
|
|
9
|
+
readonly feature?: string;
|
|
10
|
+
constructor(code: SolanaErrorCode, message: string, options?: SolanaErrorOptions);
|
|
11
|
+
}
|
|
12
|
+
declare function createSolanaError(code: SolanaErrorCode, message: string, options?: SolanaErrorOptions): SolanaError;
|
|
13
|
+
declare function isSolanaError(error: unknown): error is SolanaError;
|
|
14
|
+
declare function normalizeSolanaError(cause: unknown, fallbackCode: SolanaErrorCode, fallbackMessage?: string, options?: Omit<SolanaErrorOptions, "cause">): SolanaError;
|
|
15
|
+
|
|
16
|
+
export { SolanaError, createSolanaError, isSolanaError, normalizeSolanaError };
|
|
17
|
+
export type { SolanaErrorCode, SolanaErrorOptions };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type SolanaErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED" | "USER_REJECTED" | "INVALID_ADDRESS" | "TRANSACTION_TIMEOUT" | "RPC_FAILURE" | "STORAGE_FAILURE";
|
|
2
|
+
interface SolanaErrorOptions {
|
|
3
|
+
cause?: unknown;
|
|
4
|
+
feature?: string;
|
|
5
|
+
}
|
|
6
|
+
declare class SolanaError extends Error {
|
|
7
|
+
readonly code: SolanaErrorCode;
|
|
8
|
+
readonly cause?: unknown;
|
|
9
|
+
readonly feature?: string;
|
|
10
|
+
constructor(code: SolanaErrorCode, message: string, options?: SolanaErrorOptions);
|
|
11
|
+
}
|
|
12
|
+
declare function createSolanaError(code: SolanaErrorCode, message: string, options?: SolanaErrorOptions): SolanaError;
|
|
13
|
+
declare function isSolanaError(error: unknown): error is SolanaError;
|
|
14
|
+
declare function normalizeSolanaError(cause: unknown, fallbackCode: SolanaErrorCode, fallbackMessage?: string, options?: Omit<SolanaErrorOptions, "cause">): SolanaError;
|
|
15
|
+
|
|
16
|
+
export { SolanaError, createSolanaError, isSolanaError, normalizeSolanaError };
|
|
17
|
+
export type { SolanaErrorCode, SolanaErrorOptions };
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type SolanaErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED" | "USER_REJECTED" | "INVALID_ADDRESS" | "TRANSACTION_TIMEOUT" | "RPC_FAILURE" | "STORAGE_FAILURE";
|
|
2
|
+
interface SolanaErrorOptions {
|
|
3
|
+
cause?: unknown;
|
|
4
|
+
feature?: string;
|
|
5
|
+
}
|
|
6
|
+
declare class SolanaError extends Error {
|
|
7
|
+
readonly code: SolanaErrorCode;
|
|
8
|
+
readonly cause?: unknown;
|
|
9
|
+
readonly feature?: string;
|
|
10
|
+
constructor(code: SolanaErrorCode, message: string, options?: SolanaErrorOptions);
|
|
11
|
+
}
|
|
12
|
+
declare function createSolanaError(code: SolanaErrorCode, message: string, options?: SolanaErrorOptions): SolanaError;
|
|
13
|
+
declare function isSolanaError(error: unknown): error is SolanaError;
|
|
14
|
+
declare function normalizeSolanaError(cause: unknown, fallbackCode: SolanaErrorCode, fallbackMessage?: string, options?: Omit<SolanaErrorOptions, "cause">): SolanaError;
|
|
15
|
+
|
|
16
|
+
export { SolanaError, createSolanaError, isSolanaError, normalizeSolanaError };
|
|
17
|
+
export type { SolanaErrorCode, SolanaErrorOptions };
|
package/dist/errors.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
class SolanaError extends Error {
|
|
2
|
+
constructor(code, message, options = {}) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.code = code;
|
|
5
|
+
this.name = "SolanaError";
|
|
6
|
+
this.cause = options.cause;
|
|
7
|
+
this.feature = options.feature;
|
|
8
|
+
}
|
|
9
|
+
cause;
|
|
10
|
+
feature;
|
|
11
|
+
}
|
|
12
|
+
function createSolanaError(code, message, options) {
|
|
13
|
+
return new SolanaError(code, message, options);
|
|
14
|
+
}
|
|
15
|
+
function isSolanaError(error) {
|
|
16
|
+
return error instanceof SolanaError;
|
|
17
|
+
}
|
|
18
|
+
function normalizeSolanaError(cause, fallbackCode, fallbackMessage, options = {}) {
|
|
19
|
+
if (isSolanaError(cause)) {
|
|
20
|
+
return cause;
|
|
21
|
+
}
|
|
22
|
+
const code = isUserRejectedError(cause) ? "USER_REJECTED" : fallbackCode;
|
|
23
|
+
const message = fallbackMessage ?? getErrorMessage(cause);
|
|
24
|
+
return createSolanaError(code, message, { ...options, cause });
|
|
25
|
+
}
|
|
26
|
+
function getErrorMessage(cause) {
|
|
27
|
+
if (cause instanceof Error) {
|
|
28
|
+
return cause.message;
|
|
29
|
+
}
|
|
30
|
+
return typeof cause === "string" ? cause : "An unknown Solana error occurred";
|
|
31
|
+
}
|
|
32
|
+
function isUserRejectedError(cause) {
|
|
33
|
+
if (hasErrorCode(cause) && (cause.code === 4001 || cause.code === "4001")) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
const message = getErrorMessage(cause).toLowerCase();
|
|
37
|
+
return message.includes("user rejected") || message.includes("user denied");
|
|
38
|
+
}
|
|
39
|
+
function hasErrorCode(cause) {
|
|
40
|
+
return Boolean(
|
|
41
|
+
cause && typeof cause === "object" && "code" in cause && (typeof cause.code === "number" || typeof cause.code === "string")
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { SolanaError, createSolanaError, isSolanaError, normalizeSolanaError };
|
package/dist/index.cjs
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
const clusters = require('./clusters.cjs');
|
|
4
4
|
const address = require('./address.cjs');
|
|
5
|
-
const
|
|
5
|
+
const errors = require('./errors.cjs');
|
|
6
|
+
const adapter = require('./shared/core.BsekSwcZ.cjs');
|
|
6
7
|
const mobileWallet = require('./mobile-wallet.cjs');
|
|
7
8
|
const rpc = require('./rpc.cjs');
|
|
8
9
|
const transaction = require('./transaction.cjs');
|
|
10
|
+
const timeout = require('./timeout.cjs');
|
|
9
11
|
const wallet = require('./wallet.cjs');
|
|
10
|
-
const discovery = require('./shared/core.
|
|
12
|
+
const discovery = require('./shared/core.DX2frf65.cjs');
|
|
11
13
|
require('@solana/web3-compat');
|
|
12
14
|
require('bs58');
|
|
13
15
|
require('tweetnacl');
|
|
@@ -23,6 +25,10 @@ exports.getClusterEndpoint = clusters.getClusterEndpoint;
|
|
|
23
25
|
exports.getClusterWebSocketEndpoint = clusters.getClusterWebSocketEndpoint;
|
|
24
26
|
exports.getWebSocketEndpoint = clusters.getWebSocketEndpoint;
|
|
25
27
|
exports.parsePublicKey = address.parsePublicKey;
|
|
28
|
+
exports.SolanaError = errors.SolanaError;
|
|
29
|
+
exports.createSolanaError = errors.createSolanaError;
|
|
30
|
+
exports.isSolanaError = errors.isSolanaError;
|
|
31
|
+
exports.normalizeSolanaError = errors.normalizeSolanaError;
|
|
26
32
|
exports.adaptSolanaIosWallet = adapter.adaptSolanaIosWallet;
|
|
27
33
|
exports.getDefaultIosWalletAppIdentity = adapter.getDefaultIosWalletAppIdentity;
|
|
28
34
|
exports.getDefaultIosWalletRedirectUrl = adapter.getDefaultIosWalletRedirectUrl;
|
|
@@ -38,8 +44,13 @@ exports.createSolanaConnection = rpc.createSolanaConnection;
|
|
|
38
44
|
exports.createSolanaContext = rpc.createSolanaContext;
|
|
39
45
|
exports.confirmTransactionSignature = transaction.confirmTransactionSignature;
|
|
40
46
|
exports.signAndSendTransaction = transaction.signAndSendTransaction;
|
|
47
|
+
exports.withSolanaTimeout = timeout.withSolanaTimeout;
|
|
48
|
+
exports.withTimeout = timeout.withTimeout;
|
|
49
|
+
exports.SolanaWalletError = wallet.SolanaWalletError;
|
|
41
50
|
exports.assertWalletCanSign = wallet.assertWalletCanSign;
|
|
51
|
+
exports.assertWalletCanSignMessage = wallet.assertWalletCanSignMessage;
|
|
42
52
|
exports.assertWalletConnected = wallet.assertWalletConnected;
|
|
53
|
+
exports.createNoWalletSelectedError = wallet.createNoWalletSelectedError;
|
|
43
54
|
exports.isWalletConnected = wallet.isWalletConnected;
|
|
44
55
|
exports.SOLANA_CHAINS = discovery.SOLANA_CHAINS;
|
|
45
56
|
exports.SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME = discovery.SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { DEFAULT_CLUSTER, getClusterEndpoint, getClusterWebSocketEndpoint, getWebSocketEndpoint } from './clusters.cjs';
|
|
2
2
|
export { MaybePublicKeyInput, PublicKeyInput, parsePublicKey } from './address.cjs';
|
|
3
|
+
export { SolanaError, SolanaErrorCode, SolanaErrorOptions, createSolanaError, isSolanaError, normalizeSolanaError } from './errors.cjs';
|
|
3
4
|
export { AdaptSolanaIosWalletOptions, GetSolanaIosWalletsOptions, IosWalletCallbackResult, IosWalletInfo, IosWalletMethod, SolanaIosWalletAppIdentity, adaptSolanaIosWallet, getDefaultIosWalletAppIdentity, getDefaultIosWalletRedirectUrl, getSolanaIosWallets, handleSolanaIosWalletCallback, isIosBrowser, isSolanaIosBrowserWalletSupported, isSolanaIosWalletInfo } from './ios-wallet.cjs';
|
|
4
5
|
export { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity, getDefaultMobileWalletAppIdentity, isSolanaMobileWalletSupported, registerSolanaMobileWallet } from './mobile-wallet.cjs';
|
|
5
6
|
export { createSolanaConnection, createSolanaContext } from './rpc.cjs';
|
|
6
7
|
export { confirmTransactionSignature, signAndSendTransaction } from './transaction.cjs';
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
8
|
+
export { withSolanaTimeout, withTimeout } from './timeout.cjs';
|
|
9
|
+
export { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaSignMessageResult, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation } from './types.cjs';
|
|
10
|
+
export { SolanaWalletError, SolanaWalletErrorCode, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, createNoWalletSelectedError, isWalletConnected } from './wallet.cjs';
|
|
9
11
|
export { AdaptSolanaWalletOptions, SOLANA_CHAINS, SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, adaptSolanaStandardWallet, getRegisteredSolanaWallets, getSolanaChain, isSolanaStandardWallet, subscribeSolanaWallets } from './wallet-standard.cjs';
|
|
10
12
|
import '@solana/web3-compat';
|
|
11
13
|
import '@wallet-standard/base';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { DEFAULT_CLUSTER, getClusterEndpoint, getClusterWebSocketEndpoint, getWebSocketEndpoint } from './clusters.mjs';
|
|
2
2
|
export { MaybePublicKeyInput, PublicKeyInput, parsePublicKey } from './address.mjs';
|
|
3
|
+
export { SolanaError, SolanaErrorCode, SolanaErrorOptions, createSolanaError, isSolanaError, normalizeSolanaError } from './errors.mjs';
|
|
3
4
|
export { AdaptSolanaIosWalletOptions, GetSolanaIosWalletsOptions, IosWalletCallbackResult, IosWalletInfo, IosWalletMethod, SolanaIosWalletAppIdentity, adaptSolanaIosWallet, getDefaultIosWalletAppIdentity, getDefaultIosWalletRedirectUrl, getSolanaIosWallets, handleSolanaIosWalletCallback, isIosBrowser, isSolanaIosBrowserWalletSupported, isSolanaIosWalletInfo } from './ios-wallet.mjs';
|
|
4
5
|
export { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity, getDefaultMobileWalletAppIdentity, isSolanaMobileWalletSupported, registerSolanaMobileWallet } from './mobile-wallet.mjs';
|
|
5
6
|
export { createSolanaConnection, createSolanaContext } from './rpc.mjs';
|
|
6
7
|
export { confirmTransactionSignature, signAndSendTransaction } from './transaction.mjs';
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
8
|
+
export { withSolanaTimeout, withTimeout } from './timeout.mjs';
|
|
9
|
+
export { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaSignMessageResult, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation } from './types.mjs';
|
|
10
|
+
export { SolanaWalletError, SolanaWalletErrorCode, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, createNoWalletSelectedError, isWalletConnected } from './wallet.mjs';
|
|
9
11
|
export { AdaptSolanaWalletOptions, SOLANA_CHAINS, SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, adaptSolanaStandardWallet, getRegisteredSolanaWallets, getSolanaChain, isSolanaStandardWallet, subscribeSolanaWallets } from './wallet-standard.mjs';
|
|
10
12
|
import '@solana/web3-compat';
|
|
11
13
|
import '@wallet-standard/base';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { DEFAULT_CLUSTER, getClusterEndpoint, getClusterWebSocketEndpoint, getWebSocketEndpoint } from './clusters.js';
|
|
2
2
|
export { MaybePublicKeyInput, PublicKeyInput, parsePublicKey } from './address.js';
|
|
3
|
+
export { SolanaError, SolanaErrorCode, SolanaErrorOptions, createSolanaError, isSolanaError, normalizeSolanaError } from './errors.js';
|
|
3
4
|
export { AdaptSolanaIosWalletOptions, GetSolanaIosWalletsOptions, IosWalletCallbackResult, IosWalletInfo, IosWalletMethod, SolanaIosWalletAppIdentity, adaptSolanaIosWallet, getDefaultIosWalletAppIdentity, getDefaultIosWalletRedirectUrl, getSolanaIosWallets, handleSolanaIosWalletCallback, isIosBrowser, isSolanaIosBrowserWalletSupported, isSolanaIosWalletInfo } from './ios-wallet.js';
|
|
4
5
|
export { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity, getDefaultMobileWalletAppIdentity, isSolanaMobileWalletSupported, registerSolanaMobileWallet } from './mobile-wallet.js';
|
|
5
6
|
export { createSolanaConnection, createSolanaContext } from './rpc.js';
|
|
6
7
|
export { confirmTransactionSignature, signAndSendTransaction } from './transaction.js';
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
8
|
+
export { withSolanaTimeout, withTimeout } from './timeout.js';
|
|
9
|
+
export { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaSignMessageResult, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation } from './types.js';
|
|
10
|
+
export { SolanaWalletError, SolanaWalletErrorCode, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, createNoWalletSelectedError, isWalletConnected } from './wallet.js';
|
|
9
11
|
export { AdaptSolanaWalletOptions, SOLANA_CHAINS, SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, adaptSolanaStandardWallet, getRegisteredSolanaWallets, getSolanaChain, isSolanaStandardWallet, subscribeSolanaWallets } from './wallet-standard.js';
|
|
10
12
|
import '@solana/web3-compat';
|
|
11
13
|
import '@wallet-standard/base';
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { DEFAULT_CLUSTER, getClusterEndpoint, getClusterWebSocketEndpoint, getWebSocketEndpoint } from './clusters.mjs';
|
|
2
2
|
export { parsePublicKey } from './address.mjs';
|
|
3
|
-
export {
|
|
3
|
+
export { SolanaError, createSolanaError, isSolanaError, normalizeSolanaError } from './errors.mjs';
|
|
4
|
+
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.Ch_Z7_17.mjs';
|
|
4
5
|
export { getDefaultMobileWalletAppIdentity, isSolanaMobileWalletSupported, registerSolanaMobileWallet } from './mobile-wallet.mjs';
|
|
5
6
|
export { createSolanaConnection, createSolanaContext } from './rpc.mjs';
|
|
6
7
|
export { confirmTransactionSignature, signAndSendTransaction } from './transaction.mjs';
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
8
|
+
export { withSolanaTimeout, withTimeout } from './timeout.mjs';
|
|
9
|
+
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, createNoWalletSelectedError, isWalletConnected } from './wallet.mjs';
|
|
10
|
+
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.DSMNiaHD.mjs';
|
|
9
11
|
import '@solana/web3-compat';
|
|
10
12
|
import 'bs58';
|
|
11
13
|
import 'tweetnacl';
|
package/dist/ios-wallet.cjs
CHANGED
package/dist/ios-wallet.mjs
CHANGED
|
@@ -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.
|
|
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.Ch_Z7_17.mjs';
|
|
2
2
|
import '@solana/web3-compat';
|
|
3
3
|
import 'bs58';
|
|
4
4
|
import 'tweetnacl';
|
|
@@ -411,6 +411,92 @@ function deserializeTransaction(source, bytes) {
|
|
|
411
411
|
return web3Compat.VersionedTransaction.deserialize(bytes);
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
+
function launchConnect(definition, options) {
|
|
415
|
+
const keyPair = nacl.box.keyPair();
|
|
416
|
+
const pending = createPendingRequest(definition.id, "connect", keyPair, options.redirectUrl);
|
|
417
|
+
const appIdentity = options.appIdentity ?? getDefaultIosWalletAppIdentity();
|
|
418
|
+
const url = new URL(definition.connectUrl);
|
|
419
|
+
url.searchParams.set("app_url", appIdentity.uri);
|
|
420
|
+
url.searchParams.set("dapp_encryption_public_key", pending.dappEncryptionPublicKey);
|
|
421
|
+
url.searchParams.set("redirect_link", pending.redirectUrl);
|
|
422
|
+
if (options.cluster && options.cluster !== "localnet") {
|
|
423
|
+
url.searchParams.set("cluster", options.cluster);
|
|
424
|
+
}
|
|
425
|
+
storePendingRequest(pending);
|
|
426
|
+
openIosWalletUrl(url.toString());
|
|
427
|
+
}
|
|
428
|
+
async function launchSignTransaction(definition, transaction, options) {
|
|
429
|
+
const response = await launchEncryptedWalletRequest(definition, "signTransaction", options, {
|
|
430
|
+
transaction: bs58__default.encode(serializeTransaction(transaction))
|
|
431
|
+
});
|
|
432
|
+
if (!response.transaction) {
|
|
433
|
+
throw new Error("iOS wallet did not return a signed transaction");
|
|
434
|
+
}
|
|
435
|
+
return response.transaction;
|
|
436
|
+
}
|
|
437
|
+
async function launchSignAllTransactions(definition, transactions, options) {
|
|
438
|
+
const response = await launchEncryptedWalletRequest(definition, "signAllTransactions", options, {
|
|
439
|
+
transactions: transactions.map((transaction) => bs58__default.encode(serializeTransaction(transaction)))
|
|
440
|
+
});
|
|
441
|
+
if (!response.transactions) {
|
|
442
|
+
throw new Error("iOS wallet did not return signed transactions");
|
|
443
|
+
}
|
|
444
|
+
return response.transactions;
|
|
445
|
+
}
|
|
446
|
+
async function launchSignAndSendTransaction(definition, transaction, sendOptions, options) {
|
|
447
|
+
const response = await launchEncryptedWalletRequest(
|
|
448
|
+
definition,
|
|
449
|
+
"signAndSendTransaction",
|
|
450
|
+
options,
|
|
451
|
+
{
|
|
452
|
+
transaction: bs58__default.encode(serializeTransaction(transaction)),
|
|
453
|
+
sendOptions
|
|
454
|
+
}
|
|
455
|
+
);
|
|
456
|
+
if (!response.signature) {
|
|
457
|
+
throw new Error("iOS wallet did not return a transaction signature");
|
|
458
|
+
}
|
|
459
|
+
return { signature: response.signature };
|
|
460
|
+
}
|
|
461
|
+
async function launchEncryptedWalletRequest(definition, method, options, payload) {
|
|
462
|
+
const session = getStoredSession(definition.id);
|
|
463
|
+
if (!session) {
|
|
464
|
+
throw new Error("Connect the iOS wallet before signing");
|
|
465
|
+
}
|
|
466
|
+
const methodUrl = getIosWalletMethodUrl(definition, method);
|
|
467
|
+
const pending = createPendingRequest(
|
|
468
|
+
definition.id,
|
|
469
|
+
method,
|
|
470
|
+
{
|
|
471
|
+
publicKey: bs58__default.decode(session.dappEncryptionPublicKey),
|
|
472
|
+
secretKey: bs58__default.decode(session.dappEncryptionSecretKey)
|
|
473
|
+
},
|
|
474
|
+
options.redirectUrl,
|
|
475
|
+
method === "signAllTransactions" && Array.isArray(payload.transactions) ? payload.transactions.length : void 0
|
|
476
|
+
);
|
|
477
|
+
const nonce = nacl.randomBytes(nacl.box.nonceLength);
|
|
478
|
+
const encryptedPayload = encryptPayload(
|
|
479
|
+
{ ...payload, session: session.session },
|
|
480
|
+
nonce,
|
|
481
|
+
bs58__default.decode(session.sharedSecret)
|
|
482
|
+
);
|
|
483
|
+
const url = new URL(methodUrl);
|
|
484
|
+
url.searchParams.set("dapp_encryption_public_key", session.dappEncryptionPublicKey);
|
|
485
|
+
url.searchParams.set("nonce", bs58__default.encode(nonce));
|
|
486
|
+
url.searchParams.set("redirect_link", pending.redirectUrl);
|
|
487
|
+
url.searchParams.set("payload", encryptedPayload);
|
|
488
|
+
storePendingRequest(pending);
|
|
489
|
+
openIosWalletUrl(url.toString());
|
|
490
|
+
return waitForRedirect();
|
|
491
|
+
}
|
|
492
|
+
function getIosWalletMethodUrl(definition, method) {
|
|
493
|
+
const url = definition[`${method}Url`];
|
|
494
|
+
if (!url) {
|
|
495
|
+
throw new Error(`${definition.name} does not support ${method} through iOS deeplinks`);
|
|
496
|
+
}
|
|
497
|
+
return url;
|
|
498
|
+
}
|
|
499
|
+
|
|
414
500
|
function getSolanaIosWallets(options = {}) {
|
|
415
501
|
if (!isSolanaIosBrowserWalletSupported()) {
|
|
416
502
|
return [];
|
|
@@ -428,6 +514,7 @@ function getSolanaIosWallets(options = {}) {
|
|
|
428
514
|
callbackUrl,
|
|
429
515
|
capabilities: {
|
|
430
516
|
connect: true,
|
|
517
|
+
disconnect: true,
|
|
431
518
|
signTransaction: Boolean(wallet.signTransactionUrl),
|
|
432
519
|
signAllTransactions: Boolean(wallet.signAllTransactionsUrl),
|
|
433
520
|
signAndSendTransaction: Boolean(wallet.signAndSendTransactionUrl)
|
|
@@ -510,91 +597,6 @@ function adaptSolanaIosWallet(walletInfo, options = {}) {
|
|
|
510
597
|
function isSolanaIosWalletInfo(walletInfo) {
|
|
511
598
|
return walletInfo.source === "deep-link" && isIosWalletDefinition(walletInfo.wallet);
|
|
512
599
|
}
|
|
513
|
-
function launchConnect(definition, options) {
|
|
514
|
-
const keyPair = nacl.box.keyPair();
|
|
515
|
-
const pending = createPendingRequest(definition.id, "connect", keyPair, options.redirectUrl);
|
|
516
|
-
const appIdentity = options.appIdentity ?? getDefaultIosWalletAppIdentity();
|
|
517
|
-
const url = new URL(definition.connectUrl);
|
|
518
|
-
url.searchParams.set("app_url", appIdentity.uri);
|
|
519
|
-
url.searchParams.set("dapp_encryption_public_key", pending.dappEncryptionPublicKey);
|
|
520
|
-
url.searchParams.set("redirect_link", pending.redirectUrl);
|
|
521
|
-
if (options.cluster && options.cluster !== "localnet") {
|
|
522
|
-
url.searchParams.set("cluster", options.cluster);
|
|
523
|
-
}
|
|
524
|
-
storePendingRequest(pending);
|
|
525
|
-
openIosWalletUrl(url.toString());
|
|
526
|
-
}
|
|
527
|
-
async function launchSignTransaction(definition, transaction, options) {
|
|
528
|
-
const response = await launchEncryptedWalletRequest(definition, "signTransaction", options, {
|
|
529
|
-
transaction: bs58__default.encode(serializeTransaction(transaction))
|
|
530
|
-
});
|
|
531
|
-
if (!response.transaction) {
|
|
532
|
-
throw new Error("iOS wallet did not return a signed transaction");
|
|
533
|
-
}
|
|
534
|
-
return response.transaction;
|
|
535
|
-
}
|
|
536
|
-
async function launchSignAllTransactions(definition, transactions, options) {
|
|
537
|
-
const response = await launchEncryptedWalletRequest(definition, "signAllTransactions", options, {
|
|
538
|
-
transactions: transactions.map((transaction) => bs58__default.encode(serializeTransaction(transaction)))
|
|
539
|
-
});
|
|
540
|
-
if (!response.transactions) {
|
|
541
|
-
throw new Error("iOS wallet did not return signed transactions");
|
|
542
|
-
}
|
|
543
|
-
return response.transactions;
|
|
544
|
-
}
|
|
545
|
-
async function launchSignAndSendTransaction(definition, transaction, sendOptions, options) {
|
|
546
|
-
const response = await launchEncryptedWalletRequest(
|
|
547
|
-
definition,
|
|
548
|
-
"signAndSendTransaction",
|
|
549
|
-
options,
|
|
550
|
-
{
|
|
551
|
-
transaction: bs58__default.encode(serializeTransaction(transaction)),
|
|
552
|
-
sendOptions
|
|
553
|
-
}
|
|
554
|
-
);
|
|
555
|
-
if (!response.signature) {
|
|
556
|
-
throw new Error("iOS wallet did not return a transaction signature");
|
|
557
|
-
}
|
|
558
|
-
return { signature: response.signature };
|
|
559
|
-
}
|
|
560
|
-
async function launchEncryptedWalletRequest(definition, method, options, payload) {
|
|
561
|
-
const session = getStoredSession(definition.id);
|
|
562
|
-
if (!session) {
|
|
563
|
-
throw new Error("Connect the iOS wallet before signing");
|
|
564
|
-
}
|
|
565
|
-
const methodUrl = getIosWalletMethodUrl(definition, method);
|
|
566
|
-
const pending = createPendingRequest(
|
|
567
|
-
definition.id,
|
|
568
|
-
method,
|
|
569
|
-
{
|
|
570
|
-
publicKey: bs58__default.decode(session.dappEncryptionPublicKey),
|
|
571
|
-
secretKey: bs58__default.decode(session.dappEncryptionSecretKey)
|
|
572
|
-
},
|
|
573
|
-
options.redirectUrl,
|
|
574
|
-
method === "signAllTransactions" && Array.isArray(payload.transactions) ? payload.transactions.length : void 0
|
|
575
|
-
);
|
|
576
|
-
const nonce = nacl.randomBytes(nacl.box.nonceLength);
|
|
577
|
-
const encryptedPayload = encryptPayload(
|
|
578
|
-
{ ...payload, session: session.session },
|
|
579
|
-
nonce,
|
|
580
|
-
bs58__default.decode(session.sharedSecret)
|
|
581
|
-
);
|
|
582
|
-
const url = new URL(methodUrl);
|
|
583
|
-
url.searchParams.set("dapp_encryption_public_key", session.dappEncryptionPublicKey);
|
|
584
|
-
url.searchParams.set("nonce", bs58__default.encode(nonce));
|
|
585
|
-
url.searchParams.set("redirect_link", pending.redirectUrl);
|
|
586
|
-
url.searchParams.set("payload", encryptedPayload);
|
|
587
|
-
storePendingRequest(pending);
|
|
588
|
-
openIosWalletUrl(url.toString());
|
|
589
|
-
return waitForRedirect();
|
|
590
|
-
}
|
|
591
|
-
function getIosWalletMethodUrl(definition, method) {
|
|
592
|
-
const url = definition[`${method}Url`];
|
|
593
|
-
if (!url) {
|
|
594
|
-
throw new Error(`${definition.name} does not support ${method} through iOS deeplinks`);
|
|
595
|
-
}
|
|
596
|
-
return url;
|
|
597
|
-
}
|
|
598
600
|
function getIosWalletDefinition(walletInfo) {
|
|
599
601
|
if (!isIosWalletDefinition(walletInfo.wallet)) {
|
|
600
602
|
throw new Error("Solana wallet info is not an iOS wallet");
|