@vue-solana/core 0.6.0 → 0.7.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 +56 -44
- 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 +9 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +3 -1
- 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/wallet.cjs +15 -8
- package/dist/wallet.d.cts +9 -5
- package/dist/wallet.d.mts +9 -5
- package/dist/wallet.d.ts +9 -5
- package/dist/wallet.mjs +15 -9
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# @vue-solana/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@vue-solana/core)
|
|
4
|
+
[](https://www.npmjs.com/package/@vue-solana/core)
|
|
5
|
+
[](https://github.com/vue-solana/vue-solana/blob/main/LICENSE)
|
|
6
|
+
[](https://vue-solana-docs.vercel.app/packages/core)
|
|
7
|
+
|
|
8
|
+
Framework-agnostic Solana primitives for Vue Solana libraries and apps that want shared RPC, wallet, and transaction helpers without installing a Vue plugin.
|
|
4
9
|
|
|
5
10
|
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
11
|
|
|
@@ -20,6 +25,27 @@ Full Vue Solana docs:
|
|
|
20
25
|
- [Agent Skill](https://vue-solana-docs.vercel.app/agent-skill)
|
|
21
26
|
- [Troubleshooting](https://vue-solana-docs.vercel.app/troubleshooting)
|
|
22
27
|
|
|
28
|
+
## Features
|
|
29
|
+
|
|
30
|
+
- Cluster-aware RPC connection helpers with HTTP and WebSocket endpoint defaults.
|
|
31
|
+
- Shared `SolanaConfig`, `SolanaContext`, and `SolanaWallet` types for framework integrations.
|
|
32
|
+
- Wallet capability assertions for connection, message signing, and transaction signing flows.
|
|
33
|
+
- Browser Wallet Standard adaptation primitives.
|
|
34
|
+
- Android Mobile Wallet Adapter registration helpers.
|
|
35
|
+
- iOS browser wallet link helpers for supported wallets.
|
|
36
|
+
- Transaction submission and confirmation helpers.
|
|
37
|
+
|
|
38
|
+
## Compatibility
|
|
39
|
+
|
|
40
|
+
| Requirement | Supported |
|
|
41
|
+
| ------------- | ----------------------------------------------- |
|
|
42
|
+
| Runtime | Modern ESM or CommonJS bundlers |
|
|
43
|
+
| TypeScript | TypeScript 5.x recommended |
|
|
44
|
+
| Solana client | `@solana/web3-compat@^0.0.21` |
|
|
45
|
+
| Clusters | `mainnet-beta`, `devnet`, `testnet`, `localnet` |
|
|
46
|
+
|
|
47
|
+
This package intentionally keeps raw Solana primitives in `@solana/web3-compat`. Import `Connection`, `PublicKey`, `Transaction`, and `VersionedTransaction` from Solana packages; import Vue Solana configuration, wallet interfaces, and helpers from `@vue-solana/core`.
|
|
48
|
+
|
|
23
49
|
## Install
|
|
24
50
|
|
|
25
51
|
```sh
|
|
@@ -66,6 +92,14 @@ const config: SolanaConfig = {
|
|
|
66
92
|
};
|
|
67
93
|
```
|
|
68
94
|
|
|
95
|
+
| Option | Type | Default | Description |
|
|
96
|
+
| ------------- | ------------------------------------------------------- | ----------------------------- | --------------------------------------------------------------------------------------- |
|
|
97
|
+
| `cluster` | `"mainnet-beta" \| "devnet" \| "testnet" \| "localnet"` | `"devnet"` | Solana cluster used when `endpoint` is omitted. |
|
|
98
|
+
| `endpoint` | `string` | Public endpoint for `cluster` | HTTP RPC endpoint. Use a dedicated RPC provider for production apps. |
|
|
99
|
+
| `wsEndpoint` | `string` | Derived from `endpoint` | WebSocket RPC endpoint. |
|
|
100
|
+
| `commitment` | Solana commitment | Solana client default | Default commitment for created connections. |
|
|
101
|
+
| `autoConnect` | `boolean` | `false` | Consumed by Vue/Nuxt integrations to reconnect a previously selected discovered wallet. |
|
|
102
|
+
|
|
69
103
|
Supported clusters are `mainnet-beta`, `testnet`, `devnet`, and `localnet`. If `endpoint` is omitted, the package uses the public Solana RPC endpoint for the selected cluster. If `wsEndpoint` is omitted, it is derived from the RPC endpoint.
|
|
70
104
|
|
|
71
105
|
`autoConnect` is consumed by the Vue plugin and Nuxt module. It defaults to `false`; when set to `true`, Vue Solana reconnects only a previously selected wallet identity that is discovered again on the client.
|
|
@@ -92,19 +126,21 @@ Direct subpaths:
|
|
|
92
126
|
- `@vue-solana/core/wallet`
|
|
93
127
|
- `@vue-solana/core/wallet-standard`
|
|
94
128
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
129
|
+
| API | Description |
|
|
130
|
+
| ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
131
|
+
| `DEFAULT_CLUSTER` | Default cluster, currently `devnet`. |
|
|
132
|
+
| `parsePublicKey(value)` | Parses a `PublicKey`, address string, ref-like `{ value }`, getter, `null`, or `undefined` into a `PublicKey \| null`. |
|
|
133
|
+
| `createSolanaConnection(config?)` | Creates a Solana `Connection`. |
|
|
134
|
+
| `createSolanaContext(config?)` | Creates `{ cluster, endpoint, wsEndpoint, connection }`. |
|
|
135
|
+
| `getClusterEndpoint(cluster?)` | Returns the HTTP RPC endpoint for a cluster. |
|
|
136
|
+
| `getClusterWebSocketEndpoint(cluster?)` | Returns the WebSocket endpoint for a cluster. |
|
|
137
|
+
| `getWebSocketEndpoint(endpoint)` | Converts `http`/`https` RPC URLs to `ws`/`wss` URLs. |
|
|
138
|
+
| `isWalletConnected(wallet)` | Checks whether a wallet is connected and has a public key. |
|
|
139
|
+
| `assertWalletConnected(wallet)` | Throws if the wallet is not connected. |
|
|
140
|
+
| `assertWalletCanSignMessage(wallet)` | Throws if the wallet is disconnected or cannot sign messages. |
|
|
141
|
+
| `assertWalletCanSign(wallet)` | Throws if the wallet cannot sign transactions. |
|
|
142
|
+
| `signAndSendTransaction(connection, wallet, transaction, options?)` | Signs and sends a transaction using a configured wallet. Android MWA wallets prefer `signTransaction` plus app-side RPC submission when available. |
|
|
143
|
+
| `confirmTransactionSignature(connection, signature, options?)` | Waits for a submitted signature to reach a requested commitment. Defaults to `confirmed` and a 60 second timeout. |
|
|
108
144
|
|
|
109
145
|
## Wallet Interface
|
|
110
146
|
|
|
@@ -153,37 +189,13 @@ npx skills add vue-solana/vue-solana --skill vue-solana
|
|
|
153
189
|
|
|
154
190
|
Docs: [Vue Solana Agent Skill](https://vue-solana-docs.vercel.app/agent-skill)
|
|
155
191
|
|
|
156
|
-
##
|
|
157
|
-
|
|
158
|
-
`@solana/web3-compat@0.0.21` currently has broken TypeScript metadata. Runtime imports still use the real package, but TypeScript consumers may need a local declaration shim.
|
|
159
|
-
|
|
160
|
-
If TypeScript cannot resolve `@solana/web3-compat`, add `types/web3-compat.d.ts` to your app:
|
|
161
|
-
|
|
162
|
-
```ts
|
|
163
|
-
declare module "@solana/web3-compat" {
|
|
164
|
-
export type {
|
|
165
|
-
AccountInfo,
|
|
166
|
-
Commitment,
|
|
167
|
-
RpcResponseAndContext,
|
|
168
|
-
SendOptions,
|
|
169
|
-
SignatureResult,
|
|
170
|
-
SignatureStatus,
|
|
171
|
-
TransactionSignature,
|
|
172
|
-
} from "@solana/web3.js";
|
|
173
|
-
export {
|
|
174
|
-
Connection,
|
|
175
|
-
Keypair,
|
|
176
|
-
PublicKey,
|
|
177
|
-
SystemProgram,
|
|
178
|
-
Transaction,
|
|
179
|
-
TransactionInstruction,
|
|
180
|
-
VersionedTransaction,
|
|
181
|
-
} from "@solana/web3.js";
|
|
182
|
-
}
|
|
183
|
-
```
|
|
192
|
+
## Caveats
|
|
184
193
|
|
|
185
|
-
|
|
194
|
+
- Public Solana RPC endpoints are useful for development, but production apps should use dedicated RPC infrastructure.
|
|
195
|
+
- Use `mainnet-beta` for Solana mainnet. `mainnet` is intentionally not accepted as a cluster alias.
|
|
196
|
+
- `@solana/web3-compat@0.0.21` currently has broken TypeScript package metadata. Runtime imports still use the real package, but TypeScript consumers may need a local declaration shim. See [Troubleshooting](https://vue-solana-docs.vercel.app/troubleshooting) for the workaround.
|
|
197
|
+
- Desktop native app wallets are planned but not implemented yet.
|
|
186
198
|
|
|
187
199
|
## Status
|
|
188
200
|
|
|
189
|
-
This package
|
|
201
|
+
This package provides RPC helpers, browser extension wallet primitives, Android mobile wallet registration, message signing, and transaction helpers.
|
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,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
const clusters = require('./clusters.cjs');
|
|
4
4
|
const address = require('./address.cjs');
|
|
5
|
+
const errors = require('./errors.cjs');
|
|
5
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
12
|
const discovery = require('./shared/core.DX2frf65.cjs');
|
|
11
13
|
require('@solana/web3-compat');
|
|
@@ -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,10 +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;
|
|
41
49
|
exports.SolanaWalletError = wallet.SolanaWalletError;
|
|
42
50
|
exports.assertWalletCanSign = wallet.assertWalletCanSign;
|
|
43
51
|
exports.assertWalletCanSignMessage = wallet.assertWalletCanSignMessage;
|
|
44
52
|
exports.assertWalletConnected = wallet.assertWalletConnected;
|
|
53
|
+
exports.createNoWalletSelectedError = wallet.createNoWalletSelectedError;
|
|
45
54
|
exports.isWalletConnected = wallet.isWalletConnected;
|
|
46
55
|
exports.SOLANA_CHAINS = discovery.SOLANA_CHAINS;
|
|
47
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';
|
|
8
|
+
export { withSolanaTimeout, withTimeout } from './timeout.cjs';
|
|
7
9
|
export { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaSignMessageResult, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation } from './types.cjs';
|
|
8
|
-
export { SolanaWalletError, SolanaWalletErrorCode, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected } from './wallet.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';
|
|
8
|
+
export { withSolanaTimeout, withTimeout } from './timeout.mjs';
|
|
7
9
|
export { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaSignMessageResult, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation } from './types.mjs';
|
|
8
|
-
export { SolanaWalletError, SolanaWalletErrorCode, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected } from './wallet.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';
|
|
8
|
+
export { withSolanaTimeout, withTimeout } from './timeout.js';
|
|
7
9
|
export { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaSignMessageResult, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation } from './types.js';
|
|
8
|
-
export { SolanaWalletError, SolanaWalletErrorCode, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected } from './wallet.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,10 +1,12 @@
|
|
|
1
1
|
export { DEFAULT_CLUSTER, getClusterEndpoint, getClusterWebSocketEndpoint, getWebSocketEndpoint } from './clusters.mjs';
|
|
2
2
|
export { parsePublicKey } from './address.mjs';
|
|
3
|
+
export { SolanaError, createSolanaError, isSolanaError, normalizeSolanaError } from './errors.mjs';
|
|
3
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 { withSolanaTimeout, withTimeout } from './timeout.mjs';
|
|
9
|
+
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, createNoWalletSelectedError, isWalletConnected } from './wallet.mjs';
|
|
8
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';
|
package/dist/timeout.cjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const errors = require('./errors.cjs');
|
|
4
|
+
|
|
5
|
+
function withTimeout(promise, timeoutMs, createError) {
|
|
6
|
+
if (timeoutMs === void 0) {
|
|
7
|
+
return promise;
|
|
8
|
+
}
|
|
9
|
+
let timeoutId;
|
|
10
|
+
return Promise.race([
|
|
11
|
+
promise,
|
|
12
|
+
new Promise((_, reject) => {
|
|
13
|
+
timeoutId = setTimeout(() => {
|
|
14
|
+
try {
|
|
15
|
+
reject(createError());
|
|
16
|
+
} catch (error) {
|
|
17
|
+
reject(error);
|
|
18
|
+
}
|
|
19
|
+
}, timeoutMs);
|
|
20
|
+
})
|
|
21
|
+
]).finally(() => {
|
|
22
|
+
if (timeoutId) {
|
|
23
|
+
clearTimeout(timeoutId);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function withSolanaTimeout(promise, timeoutMs, message) {
|
|
28
|
+
return withTimeout(promise, timeoutMs, () => errors.createSolanaError("TRANSACTION_TIMEOUT", message));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.withSolanaTimeout = withSolanaTimeout;
|
|
32
|
+
exports.withTimeout = withTimeout;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number | undefined, createError: () => unknown): Promise<T>;
|
|
2
|
+
declare function withSolanaTimeout<T>(promise: Promise<T>, timeoutMs: number | undefined, message: string): Promise<T>;
|
|
3
|
+
|
|
4
|
+
export { withSolanaTimeout, withTimeout };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number | undefined, createError: () => unknown): Promise<T>;
|
|
2
|
+
declare function withSolanaTimeout<T>(promise: Promise<T>, timeoutMs: number | undefined, message: string): Promise<T>;
|
|
3
|
+
|
|
4
|
+
export { withSolanaTimeout, withTimeout };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number | undefined, createError: () => unknown): Promise<T>;
|
|
2
|
+
declare function withSolanaTimeout<T>(promise: Promise<T>, timeoutMs: number | undefined, message: string): Promise<T>;
|
|
3
|
+
|
|
4
|
+
export { withSolanaTimeout, withTimeout };
|
package/dist/timeout.mjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createSolanaError } from './errors.mjs';
|
|
2
|
+
|
|
3
|
+
function withTimeout(promise, timeoutMs, createError) {
|
|
4
|
+
if (timeoutMs === void 0) {
|
|
5
|
+
return promise;
|
|
6
|
+
}
|
|
7
|
+
let timeoutId;
|
|
8
|
+
return Promise.race([
|
|
9
|
+
promise,
|
|
10
|
+
new Promise((_, reject) => {
|
|
11
|
+
timeoutId = setTimeout(() => {
|
|
12
|
+
try {
|
|
13
|
+
reject(createError());
|
|
14
|
+
} catch (error) {
|
|
15
|
+
reject(error);
|
|
16
|
+
}
|
|
17
|
+
}, timeoutMs);
|
|
18
|
+
})
|
|
19
|
+
]).finally(() => {
|
|
20
|
+
if (timeoutId) {
|
|
21
|
+
clearTimeout(timeoutId);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function withSolanaTimeout(promise, timeoutMs, message) {
|
|
26
|
+
return withTimeout(promise, timeoutMs, () => createSolanaError("TRANSACTION_TIMEOUT", message));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { withSolanaTimeout, withTimeout };
|
package/dist/transaction.cjs
CHANGED
|
@@ -1,32 +1,47 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const errors = require('./errors.cjs');
|
|
4
|
+
const timeout = require('./timeout.cjs');
|
|
3
5
|
const wallet = require('./wallet.cjs');
|
|
4
6
|
|
|
5
7
|
const DEFAULT_CONFIRMATION_COMMITMENT = "confirmed";
|
|
6
8
|
const DEFAULT_CONFIRMATION_TIMEOUT_MS = 6e4;
|
|
7
9
|
async function signAndSendTransaction(connection, wallet$1, transaction, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
try {
|
|
11
|
+
wallet.assertWalletConnected(wallet$1);
|
|
12
|
+
if (isMobileWalletAdapterWallet(wallet$1) && wallet$1.signTransaction) {
|
|
13
|
+
wallet.assertWalletCanSign(wallet$1);
|
|
14
|
+
return await signAndSendRawTransaction(connection, wallet$1, transaction, options);
|
|
15
|
+
}
|
|
16
|
+
if (wallet$1.signAndSendTransaction) {
|
|
17
|
+
const result = await wallet$1.signAndSendTransaction(transaction, options);
|
|
18
|
+
return result.signature;
|
|
19
|
+
}
|
|
10
20
|
wallet.assertWalletCanSign(wallet$1);
|
|
11
|
-
return signAndSendRawTransaction(connection, wallet$1, transaction, options);
|
|
21
|
+
return await signAndSendRawTransaction(connection, wallet$1, transaction, options);
|
|
22
|
+
} catch (cause) {
|
|
23
|
+
throw errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
12
24
|
}
|
|
13
|
-
if (wallet$1.signAndSendTransaction) {
|
|
14
|
-
const result = await wallet$1.signAndSendTransaction(transaction, options);
|
|
15
|
-
return result.signature;
|
|
16
|
-
}
|
|
17
|
-
wallet.assertWalletCanSign(wallet$1);
|
|
18
|
-
return signAndSendRawTransaction(connection, wallet$1, transaction, options);
|
|
19
25
|
}
|
|
20
26
|
async function confirmTransactionSignature(connection, signature, options = {}) {
|
|
21
27
|
const commitment = options.commitment ?? DEFAULT_CONFIRMATION_COMMITMENT;
|
|
22
28
|
const confirmation = connection.confirmTransaction(signature, commitment);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
let result;
|
|
30
|
+
try {
|
|
31
|
+
result = await timeout.withSolanaTimeout(
|
|
32
|
+
confirmation,
|
|
33
|
+
options.timeoutMs ?? DEFAULT_CONFIRMATION_TIMEOUT_MS,
|
|
34
|
+
`Timed out waiting for transaction ${signature} to reach ${commitment} commitment.`
|
|
35
|
+
);
|
|
36
|
+
} catch (cause) {
|
|
37
|
+
throw errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
38
|
+
}
|
|
28
39
|
if (result.value.err) {
|
|
29
|
-
throw
|
|
40
|
+
throw errors.createSolanaError(
|
|
41
|
+
"RPC_FAILURE",
|
|
42
|
+
`Transaction ${signature} failed to reach ${commitment} commitment.`,
|
|
43
|
+
{ cause: result.value.err }
|
|
44
|
+
);
|
|
30
45
|
}
|
|
31
46
|
return {
|
|
32
47
|
signature,
|
|
@@ -42,21 +57,6 @@ async function signAndSendRawTransaction(connection, wallet, transaction, option
|
|
|
42
57
|
function isMobileWalletAdapterWallet(wallet) {
|
|
43
58
|
return wallet.source === "mobile-wallet-adapter";
|
|
44
59
|
}
|
|
45
|
-
async function withTransactionTimeout(promise, timeoutMs, message) {
|
|
46
|
-
let timeoutId;
|
|
47
|
-
try {
|
|
48
|
-
const timeout = new Promise((_, reject) => {
|
|
49
|
-
timeoutId = setTimeout(() => {
|
|
50
|
-
reject(new Error(message));
|
|
51
|
-
}, timeoutMs);
|
|
52
|
-
});
|
|
53
|
-
return await Promise.race([promise, timeout]);
|
|
54
|
-
} finally {
|
|
55
|
-
if (timeoutId) {
|
|
56
|
-
clearTimeout(timeoutId);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
60
|
|
|
61
61
|
exports.confirmTransactionSignature = confirmTransactionSignature;
|
|
62
62
|
exports.signAndSendTransaction = signAndSendTransaction;
|
package/dist/transaction.mjs
CHANGED
|
@@ -1,30 +1,45 @@
|
|
|
1
|
+
import { normalizeSolanaError, createSolanaError } from './errors.mjs';
|
|
2
|
+
import { withSolanaTimeout } from './timeout.mjs';
|
|
1
3
|
import { assertWalletConnected, assertWalletCanSign } from './wallet.mjs';
|
|
2
4
|
|
|
3
5
|
const DEFAULT_CONFIRMATION_COMMITMENT = "confirmed";
|
|
4
6
|
const DEFAULT_CONFIRMATION_TIMEOUT_MS = 6e4;
|
|
5
7
|
async function signAndSendTransaction(connection, wallet, transaction, options) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
try {
|
|
9
|
+
assertWalletConnected(wallet);
|
|
10
|
+
if (isMobileWalletAdapterWallet(wallet) && wallet.signTransaction) {
|
|
11
|
+
assertWalletCanSign(wallet);
|
|
12
|
+
return await signAndSendRawTransaction(connection, wallet, transaction, options);
|
|
13
|
+
}
|
|
14
|
+
if (wallet.signAndSendTransaction) {
|
|
15
|
+
const result = await wallet.signAndSendTransaction(transaction, options);
|
|
16
|
+
return result.signature;
|
|
17
|
+
}
|
|
8
18
|
assertWalletCanSign(wallet);
|
|
9
|
-
return signAndSendRawTransaction(connection, wallet, transaction, options);
|
|
19
|
+
return await signAndSendRawTransaction(connection, wallet, transaction, options);
|
|
20
|
+
} catch (cause) {
|
|
21
|
+
throw normalizeSolanaError(cause, "RPC_FAILURE");
|
|
10
22
|
}
|
|
11
|
-
if (wallet.signAndSendTransaction) {
|
|
12
|
-
const result = await wallet.signAndSendTransaction(transaction, options);
|
|
13
|
-
return result.signature;
|
|
14
|
-
}
|
|
15
|
-
assertWalletCanSign(wallet);
|
|
16
|
-
return signAndSendRawTransaction(connection, wallet, transaction, options);
|
|
17
23
|
}
|
|
18
24
|
async function confirmTransactionSignature(connection, signature, options = {}) {
|
|
19
25
|
const commitment = options.commitment ?? DEFAULT_CONFIRMATION_COMMITMENT;
|
|
20
26
|
const confirmation = connection.confirmTransaction(signature, commitment);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
let result;
|
|
28
|
+
try {
|
|
29
|
+
result = await withSolanaTimeout(
|
|
30
|
+
confirmation,
|
|
31
|
+
options.timeoutMs ?? DEFAULT_CONFIRMATION_TIMEOUT_MS,
|
|
32
|
+
`Timed out waiting for transaction ${signature} to reach ${commitment} commitment.`
|
|
33
|
+
);
|
|
34
|
+
} catch (cause) {
|
|
35
|
+
throw normalizeSolanaError(cause, "RPC_FAILURE");
|
|
36
|
+
}
|
|
26
37
|
if (result.value.err) {
|
|
27
|
-
throw
|
|
38
|
+
throw createSolanaError(
|
|
39
|
+
"RPC_FAILURE",
|
|
40
|
+
`Transaction ${signature} failed to reach ${commitment} commitment.`,
|
|
41
|
+
{ cause: result.value.err }
|
|
42
|
+
);
|
|
28
43
|
}
|
|
29
44
|
return {
|
|
30
45
|
signature,
|
|
@@ -40,20 +55,5 @@ async function signAndSendRawTransaction(connection, wallet, transaction, option
|
|
|
40
55
|
function isMobileWalletAdapterWallet(wallet) {
|
|
41
56
|
return wallet.source === "mobile-wallet-adapter";
|
|
42
57
|
}
|
|
43
|
-
async function withTransactionTimeout(promise, timeoutMs, message) {
|
|
44
|
-
let timeoutId;
|
|
45
|
-
try {
|
|
46
|
-
const timeout = new Promise((_, reject) => {
|
|
47
|
-
timeoutId = setTimeout(() => {
|
|
48
|
-
reject(new Error(message));
|
|
49
|
-
}, timeoutMs);
|
|
50
|
-
});
|
|
51
|
-
return await Promise.race([promise, timeout]);
|
|
52
|
-
} finally {
|
|
53
|
-
if (timeoutId) {
|
|
54
|
-
clearTimeout(timeoutId);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
58
|
|
|
59
59
|
export { confirmTransactionSignature, signAndSendTransaction };
|
package/dist/wallet.cjs
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const errors = require('./errors.cjs');
|
|
4
|
+
|
|
5
|
+
class SolanaWalletError extends errors.SolanaError {
|
|
6
|
+
constructor(code, message, options = {}) {
|
|
7
|
+
super(code, message, options);
|
|
7
8
|
this.name = "SolanaWalletError";
|
|
8
9
|
}
|
|
9
10
|
}
|
|
11
|
+
function createNoWalletSelectedError(cause) {
|
|
12
|
+
return new SolanaWalletError("NO_WALLET_SELECTED", "No Solana wallet is selected", { cause });
|
|
13
|
+
}
|
|
10
14
|
function isWalletConnected(wallet) {
|
|
11
15
|
return Boolean(wallet?.connected && wallet.publicKey);
|
|
12
16
|
}
|
|
@@ -19,8 +23,9 @@ function assertWalletCanSign(wallet) {
|
|
|
19
23
|
assertWalletConnected(wallet);
|
|
20
24
|
if (!wallet.signTransaction) {
|
|
21
25
|
throw new SolanaWalletError(
|
|
22
|
-
"
|
|
23
|
-
"Solana wallet does not support signTransaction"
|
|
26
|
+
"WALLET_FEATURE_UNSUPPORTED",
|
|
27
|
+
"Solana wallet does not support signTransaction",
|
|
28
|
+
{ feature: "signTransaction" }
|
|
24
29
|
);
|
|
25
30
|
}
|
|
26
31
|
}
|
|
@@ -28,8 +33,9 @@ function assertWalletCanSignMessage(wallet) {
|
|
|
28
33
|
assertWalletConnected(wallet);
|
|
29
34
|
if (!wallet.signMessage) {
|
|
30
35
|
throw new SolanaWalletError(
|
|
31
|
-
"
|
|
32
|
-
"Solana wallet does not support signMessage"
|
|
36
|
+
"WALLET_FEATURE_UNSUPPORTED",
|
|
37
|
+
"Solana wallet does not support signMessage",
|
|
38
|
+
{ feature: "signMessage" }
|
|
33
39
|
);
|
|
34
40
|
}
|
|
35
41
|
}
|
|
@@ -38,4 +44,5 @@ exports.SolanaWalletError = SolanaWalletError;
|
|
|
38
44
|
exports.assertWalletCanSign = assertWalletCanSign;
|
|
39
45
|
exports.assertWalletCanSignMessage = assertWalletCanSignMessage;
|
|
40
46
|
exports.assertWalletConnected = assertWalletConnected;
|
|
47
|
+
exports.createNoWalletSelectedError = createNoWalletSelectedError;
|
|
41
48
|
exports.isWalletConnected = isWalletConnected;
|
package/dist/wallet.d.cts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { SolanaWallet } from './types.cjs';
|
|
2
|
+
import { SolanaError } from './errors.cjs';
|
|
2
3
|
import '@solana/web3-compat';
|
|
3
4
|
|
|
4
|
-
type SolanaWalletErrorCode = "
|
|
5
|
-
declare class SolanaWalletError extends
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type SolanaWalletErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED";
|
|
6
|
+
declare class SolanaWalletError extends SolanaError {
|
|
7
|
+
constructor(code: SolanaWalletErrorCode, message: string, options?: {
|
|
8
|
+
cause?: unknown;
|
|
9
|
+
feature?: string;
|
|
10
|
+
});
|
|
8
11
|
}
|
|
12
|
+
declare function createNoWalletSelectedError(cause?: unknown): SolanaWalletError;
|
|
9
13
|
declare function isWalletConnected(wallet: Pick<SolanaWallet, "connected" | "publicKey"> | null | undefined): boolean;
|
|
10
14
|
declare function assertWalletConnected(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & {
|
|
11
15
|
publicKey: NonNullable<SolanaWallet["publicKey"]>;
|
|
@@ -13,5 +17,5 @@ declare function assertWalletConnected(wallet: SolanaWallet | null | undefined):
|
|
|
13
17
|
declare function assertWalletCanSign(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signTransaction">>;
|
|
14
18
|
declare function assertWalletCanSignMessage(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signMessage">>;
|
|
15
19
|
|
|
16
|
-
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected };
|
|
20
|
+
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, createNoWalletSelectedError, isWalletConnected };
|
|
17
21
|
export type { SolanaWalletErrorCode };
|
package/dist/wallet.d.mts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { SolanaWallet } from './types.mjs';
|
|
2
|
+
import { SolanaError } from './errors.mjs';
|
|
2
3
|
import '@solana/web3-compat';
|
|
3
4
|
|
|
4
|
-
type SolanaWalletErrorCode = "
|
|
5
|
-
declare class SolanaWalletError extends
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type SolanaWalletErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED";
|
|
6
|
+
declare class SolanaWalletError extends SolanaError {
|
|
7
|
+
constructor(code: SolanaWalletErrorCode, message: string, options?: {
|
|
8
|
+
cause?: unknown;
|
|
9
|
+
feature?: string;
|
|
10
|
+
});
|
|
8
11
|
}
|
|
12
|
+
declare function createNoWalletSelectedError(cause?: unknown): SolanaWalletError;
|
|
9
13
|
declare function isWalletConnected(wallet: Pick<SolanaWallet, "connected" | "publicKey"> | null | undefined): boolean;
|
|
10
14
|
declare function assertWalletConnected(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & {
|
|
11
15
|
publicKey: NonNullable<SolanaWallet["publicKey"]>;
|
|
@@ -13,5 +17,5 @@ declare function assertWalletConnected(wallet: SolanaWallet | null | undefined):
|
|
|
13
17
|
declare function assertWalletCanSign(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signTransaction">>;
|
|
14
18
|
declare function assertWalletCanSignMessage(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signMessage">>;
|
|
15
19
|
|
|
16
|
-
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected };
|
|
20
|
+
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, createNoWalletSelectedError, isWalletConnected };
|
|
17
21
|
export type { SolanaWalletErrorCode };
|
package/dist/wallet.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { SolanaWallet } from './types.js';
|
|
2
|
+
import { SolanaError } from './errors.js';
|
|
2
3
|
import '@solana/web3-compat';
|
|
3
4
|
|
|
4
|
-
type SolanaWalletErrorCode = "
|
|
5
|
-
declare class SolanaWalletError extends
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type SolanaWalletErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED";
|
|
6
|
+
declare class SolanaWalletError extends SolanaError {
|
|
7
|
+
constructor(code: SolanaWalletErrorCode, message: string, options?: {
|
|
8
|
+
cause?: unknown;
|
|
9
|
+
feature?: string;
|
|
10
|
+
});
|
|
8
11
|
}
|
|
12
|
+
declare function createNoWalletSelectedError(cause?: unknown): SolanaWalletError;
|
|
9
13
|
declare function isWalletConnected(wallet: Pick<SolanaWallet, "connected" | "publicKey"> | null | undefined): boolean;
|
|
10
14
|
declare function assertWalletConnected(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & {
|
|
11
15
|
publicKey: NonNullable<SolanaWallet["publicKey"]>;
|
|
@@ -13,5 +17,5 @@ declare function assertWalletConnected(wallet: SolanaWallet | null | undefined):
|
|
|
13
17
|
declare function assertWalletCanSign(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signTransaction">>;
|
|
14
18
|
declare function assertWalletCanSignMessage(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signMessage">>;
|
|
15
19
|
|
|
16
|
-
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected };
|
|
20
|
+
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, createNoWalletSelectedError, isWalletConnected };
|
|
17
21
|
export type { SolanaWalletErrorCode };
|
package/dist/wallet.mjs
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { SolanaError } from './errors.mjs';
|
|
2
|
+
|
|
3
|
+
class SolanaWalletError extends SolanaError {
|
|
4
|
+
constructor(code, message, options = {}) {
|
|
5
|
+
super(code, message, options);
|
|
5
6
|
this.name = "SolanaWalletError";
|
|
6
7
|
}
|
|
7
8
|
}
|
|
9
|
+
function createNoWalletSelectedError(cause) {
|
|
10
|
+
return new SolanaWalletError("NO_WALLET_SELECTED", "No Solana wallet is selected", { cause });
|
|
11
|
+
}
|
|
8
12
|
function isWalletConnected(wallet) {
|
|
9
13
|
return Boolean(wallet?.connected && wallet.publicKey);
|
|
10
14
|
}
|
|
@@ -17,8 +21,9 @@ function assertWalletCanSign(wallet) {
|
|
|
17
21
|
assertWalletConnected(wallet);
|
|
18
22
|
if (!wallet.signTransaction) {
|
|
19
23
|
throw new SolanaWalletError(
|
|
20
|
-
"
|
|
21
|
-
"Solana wallet does not support signTransaction"
|
|
24
|
+
"WALLET_FEATURE_UNSUPPORTED",
|
|
25
|
+
"Solana wallet does not support signTransaction",
|
|
26
|
+
{ feature: "signTransaction" }
|
|
22
27
|
);
|
|
23
28
|
}
|
|
24
29
|
}
|
|
@@ -26,10 +31,11 @@ function assertWalletCanSignMessage(wallet) {
|
|
|
26
31
|
assertWalletConnected(wallet);
|
|
27
32
|
if (!wallet.signMessage) {
|
|
28
33
|
throw new SolanaWalletError(
|
|
29
|
-
"
|
|
30
|
-
"Solana wallet does not support signMessage"
|
|
34
|
+
"WALLET_FEATURE_UNSUPPORTED",
|
|
35
|
+
"Solana wallet does not support signMessage",
|
|
36
|
+
{ feature: "signMessage" }
|
|
31
37
|
);
|
|
32
38
|
}
|
|
33
39
|
}
|
|
34
40
|
|
|
35
|
-
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected };
|
|
41
|
+
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, createNoWalletSelectedError, isWalletConnected };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-solana/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Framework-agnostic primitives for Vue Solana libraries.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -45,6 +45,11 @@
|
|
|
45
45
|
"import": "./dist/clusters.mjs",
|
|
46
46
|
"require": "./dist/clusters.cjs"
|
|
47
47
|
},
|
|
48
|
+
"./errors": {
|
|
49
|
+
"types": "./dist/errors.d.ts",
|
|
50
|
+
"import": "./dist/errors.mjs",
|
|
51
|
+
"require": "./dist/errors.cjs"
|
|
52
|
+
},
|
|
48
53
|
"./ios-wallet": {
|
|
49
54
|
"types": "./dist/ios-wallet.d.ts",
|
|
50
55
|
"import": "./dist/ios-wallet.mjs",
|
|
@@ -60,6 +65,11 @@
|
|
|
60
65
|
"import": "./dist/rpc.mjs",
|
|
61
66
|
"require": "./dist/rpc.cjs"
|
|
62
67
|
},
|
|
68
|
+
"./timeout": {
|
|
69
|
+
"types": "./dist/timeout.d.ts",
|
|
70
|
+
"import": "./dist/timeout.mjs",
|
|
71
|
+
"require": "./dist/timeout.cjs"
|
|
72
|
+
},
|
|
63
73
|
"./transaction": {
|
|
64
74
|
"types": "./dist/transaction.d.ts",
|
|
65
75
|
"import": "./dist/transaction.mjs",
|