@solana/connector 0.0.0 → 0.1.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 +1460 -0
- package/dist/chunk-5ZUVZZWU.mjs +180 -0
- package/dist/chunk-5ZUVZZWU.mjs.map +1 -0
- package/dist/chunk-6PBQ5CXV.mjs +635 -0
- package/dist/chunk-6PBQ5CXV.mjs.map +1 -0
- package/dist/chunk-D4JGBIP7.js +314 -0
- package/dist/chunk-D4JGBIP7.js.map +1 -0
- package/dist/chunk-EGYXJT54.mjs +298 -0
- package/dist/chunk-EGYXJT54.mjs.map +1 -0
- package/dist/chunk-P4ZLJI4L.js +706 -0
- package/dist/chunk-P4ZLJI4L.js.map +1 -0
- package/dist/chunk-P5A3XNFF.js +2482 -0
- package/dist/chunk-P5A3XNFF.js.map +1 -0
- package/dist/chunk-SMUUAKC3.js +186 -0
- package/dist/chunk-SMUUAKC3.js.map +1 -0
- package/dist/chunk-TAAXHAV2.mjs +2419 -0
- package/dist/chunk-TAAXHAV2.mjs.map +1 -0
- package/dist/compat.d.mts +47 -0
- package/dist/compat.d.ts +47 -0
- package/dist/compat.js +98 -0
- package/dist/compat.js.map +1 -0
- package/dist/compat.mjs +94 -0
- package/dist/compat.mjs.map +1 -0
- package/dist/headless.d.mts +515 -0
- package/dist/headless.d.ts +515 -0
- package/dist/headless.js +445 -0
- package/dist/headless.js.map +1 -0
- package/dist/headless.mjs +4 -0
- package/dist/headless.mjs.map +1 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +502 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react.d.mts +496 -0
- package/dist/react.d.ts +496 -0
- package/dist/react.js +65 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +4 -0
- package/dist/react.mjs.map +1 -0
- package/dist/transaction-signer-D3csM_Mf.d.mts +199 -0
- package/dist/transaction-signer-D3csM_Mf.d.ts +199 -0
- package/dist/wallet-standard-shim-C1tisl9S.d.ts +926 -0
- package/dist/wallet-standard-shim-Cg0GVGwu.d.mts +926 -0
- package/package.json +93 -10
- package/index.js +0 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { Wallet, WalletAccount } from '@wallet-standard/base';
|
|
2
|
+
import { SolanaClusterId, SolanaCluster } from '@wallet-ui/core';
|
|
3
|
+
import { Signature, Address, TransactionMessage } from 'gill';
|
|
4
|
+
import { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Transaction and signer-related types
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Union type for all supported Solana transaction formats
|
|
12
|
+
* Supports both legacy (@solana/web3.js) and modern (gill) transaction types
|
|
13
|
+
*/
|
|
14
|
+
type SolanaTransaction = Transaction | VersionedTransaction | TransactionMessage | Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* Transaction status during its lifecycle
|
|
17
|
+
*/
|
|
18
|
+
type TransactionActivityStatus = 'pending' | 'confirmed' | 'failed';
|
|
19
|
+
/**
|
|
20
|
+
* Methods used to send/sign transactions
|
|
21
|
+
*/
|
|
22
|
+
type TransactionMethod = 'signTransaction' | 'signAllTransactions' | 'signAndSendTransaction' | 'signAndSendTransactions' | 'sendTransaction' | 'sendRawTransaction';
|
|
23
|
+
/**
|
|
24
|
+
* Transaction metadata for additional context
|
|
25
|
+
*/
|
|
26
|
+
interface TransactionMetadata {
|
|
27
|
+
/** Transaction size in bytes */
|
|
28
|
+
size?: number;
|
|
29
|
+
/** Compute units requested */
|
|
30
|
+
computeUnits?: number;
|
|
31
|
+
/** Priority fee in lamports */
|
|
32
|
+
priorityFee?: number;
|
|
33
|
+
/** Number of signatures required */
|
|
34
|
+
numSignatures?: number;
|
|
35
|
+
/** Whether preflight was skipped */
|
|
36
|
+
skipPreflight?: boolean;
|
|
37
|
+
/** Custom metadata fields */
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for creating a transaction signer
|
|
42
|
+
*/
|
|
43
|
+
interface TransactionSignerConfig {
|
|
44
|
+
/** The Wallet Standard wallet instance */
|
|
45
|
+
wallet: Wallet;
|
|
46
|
+
/** The specific account to sign with */
|
|
47
|
+
account: WalletAccount;
|
|
48
|
+
/** Optional cluster/network context for chain-specific operations */
|
|
49
|
+
cluster?: SolanaCluster;
|
|
50
|
+
/** Optional event emitter for transaction lifecycle events */
|
|
51
|
+
eventEmitter?: {
|
|
52
|
+
emit: (event: unknown) => void;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Result of a signed transaction operation
|
|
57
|
+
*/
|
|
58
|
+
interface SignedTransaction {
|
|
59
|
+
/** The transaction signature/hash */
|
|
60
|
+
signature: string;
|
|
61
|
+
/** The signed transaction data */
|
|
62
|
+
transaction: SolanaTransaction;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Capabilities that a transaction signer supports
|
|
66
|
+
* Useful for conditionally enabling/disabling UI features
|
|
67
|
+
*/
|
|
68
|
+
interface TransactionSignerCapabilities {
|
|
69
|
+
/** Can sign transactions without sending */
|
|
70
|
+
canSign: boolean;
|
|
71
|
+
/** Can sign and send transactions in one operation */
|
|
72
|
+
canSend: boolean;
|
|
73
|
+
/** Can sign arbitrary messages */
|
|
74
|
+
canSignMessage: boolean;
|
|
75
|
+
/** Can sign multiple transactions at once */
|
|
76
|
+
supportsBatchSigning: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Transaction activity record for debugging and monitoring
|
|
80
|
+
*/
|
|
81
|
+
interface TransactionActivity {
|
|
82
|
+
/** Transaction signature */
|
|
83
|
+
signature: Signature;
|
|
84
|
+
/** When the transaction was sent */
|
|
85
|
+
timestamp: string;
|
|
86
|
+
/** Transaction status */
|
|
87
|
+
status: TransactionActivityStatus;
|
|
88
|
+
/** Error message if failed */
|
|
89
|
+
error?: string;
|
|
90
|
+
/** Cluster where transaction was sent */
|
|
91
|
+
cluster: SolanaClusterId;
|
|
92
|
+
/** Fee payer address */
|
|
93
|
+
feePayer?: Address;
|
|
94
|
+
/** Method used (signAndSendTransaction, sendTransaction, etc) */
|
|
95
|
+
method: TransactionMethod;
|
|
96
|
+
/** Additional metadata */
|
|
97
|
+
metadata?: TransactionMetadata;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @solana/connector - Unified Error System
|
|
102
|
+
*/
|
|
103
|
+
declare abstract class ConnectorError extends Error {
|
|
104
|
+
abstract readonly code: string;
|
|
105
|
+
abstract readonly recoverable: boolean;
|
|
106
|
+
readonly context?: Record<string, unknown>;
|
|
107
|
+
readonly originalError?: Error;
|
|
108
|
+
readonly timestamp: string;
|
|
109
|
+
constructor(message: string, context?: Record<string, unknown>, originalError?: Error);
|
|
110
|
+
toJSON(): Record<string, unknown>;
|
|
111
|
+
}
|
|
112
|
+
declare class ConnectionError extends ConnectorError {
|
|
113
|
+
readonly code: ConnectionErrorCode;
|
|
114
|
+
readonly recoverable = true;
|
|
115
|
+
constructor(code: ConnectionErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
|
|
116
|
+
}
|
|
117
|
+
type ConnectionErrorCode = 'WALLET_NOT_CONNECTED' | 'WALLET_NOT_FOUND' | 'CONNECTION_FAILED' | 'CONNECTION_REJECTED' | 'DISCONNECTION_FAILED' | 'ACCOUNT_NOT_AVAILABLE' | 'RECONNECTION_FAILED';
|
|
118
|
+
declare class ValidationError extends ConnectorError {
|
|
119
|
+
readonly code: ValidationErrorCode;
|
|
120
|
+
readonly recoverable = false;
|
|
121
|
+
constructor(code: ValidationErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
|
|
122
|
+
}
|
|
123
|
+
type ValidationErrorCode = 'INVALID_TRANSACTION' | 'INVALID_MESSAGE' | 'INVALID_ADDRESS' | 'INVALID_SIGNATURE' | 'INVALID_FORMAT' | 'UNSUPPORTED_FORMAT' | 'VALIDATION_FAILED';
|
|
124
|
+
declare class ConfigurationError extends ConnectorError {
|
|
125
|
+
readonly code: ConfigurationErrorCode;
|
|
126
|
+
readonly recoverable = false;
|
|
127
|
+
constructor(code: ConfigurationErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
|
|
128
|
+
}
|
|
129
|
+
type ConfigurationErrorCode = 'MISSING_PROVIDER' | 'INVALID_CLUSTER' | 'CLUSTER_NOT_FOUND' | 'INVALID_CONFIG' | 'INITIALIZATION_FAILED';
|
|
130
|
+
declare class NetworkError extends ConnectorError {
|
|
131
|
+
readonly code: NetworkErrorCode;
|
|
132
|
+
readonly recoverable = true;
|
|
133
|
+
constructor(code: NetworkErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
|
|
134
|
+
}
|
|
135
|
+
type NetworkErrorCode = 'RPC_ERROR' | 'NETWORK_TIMEOUT' | 'NETWORK_UNAVAILABLE' | 'TRANSACTION_SIMULATION_FAILED';
|
|
136
|
+
declare class TransactionError extends ConnectorError {
|
|
137
|
+
readonly code: TransactionErrorCode;
|
|
138
|
+
readonly recoverable: boolean;
|
|
139
|
+
constructor(code: TransactionErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
|
|
140
|
+
}
|
|
141
|
+
type TransactionErrorCode = 'SIGNING_FAILED' | 'SEND_FAILED' | 'FEATURE_NOT_SUPPORTED' | 'USER_REJECTED' | 'SIMULATION_FAILED' | 'INVALID_TRANSACTION' | 'TRANSACTION_EXPIRED';
|
|
142
|
+
declare function isConnectorError(error: unknown): error is ConnectorError;
|
|
143
|
+
declare function isConnectionError(error: unknown): error is ConnectionError;
|
|
144
|
+
declare function isValidationError(error: unknown): error is ValidationError;
|
|
145
|
+
declare function isConfigurationError(error: unknown): error is ConfigurationError;
|
|
146
|
+
declare function isNetworkError(error: unknown): error is NetworkError;
|
|
147
|
+
declare function isTransactionError(error: unknown): error is TransactionError;
|
|
148
|
+
declare const Errors: {
|
|
149
|
+
readonly walletNotConnected: (context?: Record<string, unknown>) => ConnectionError;
|
|
150
|
+
readonly walletNotFound: (walletName?: string) => ConnectionError;
|
|
151
|
+
readonly connectionFailed: (originalError?: Error) => ConnectionError;
|
|
152
|
+
readonly accountNotAvailable: (address?: string) => ConnectionError;
|
|
153
|
+
readonly invalidTransaction: (reason: string, context?: Record<string, unknown>) => ValidationError;
|
|
154
|
+
readonly invalidFormat: (expectedFormat: string, actualFormat?: string) => ValidationError;
|
|
155
|
+
readonly unsupportedFormat: (format: string) => ValidationError;
|
|
156
|
+
readonly missingProvider: (hookName: string) => ConfigurationError;
|
|
157
|
+
readonly clusterNotFound: (clusterId: string, availableClusters: string[]) => ConfigurationError;
|
|
158
|
+
readonly rpcError: (message: string, originalError?: Error) => NetworkError;
|
|
159
|
+
readonly networkTimeout: () => NetworkError;
|
|
160
|
+
readonly signingFailed: (originalError?: Error) => TransactionError;
|
|
161
|
+
readonly featureNotSupported: (feature: string) => TransactionError;
|
|
162
|
+
readonly userRejected: (operation: string) => TransactionError;
|
|
163
|
+
};
|
|
164
|
+
declare function toConnectorError(error: unknown, defaultMessage?: string): ConnectorError;
|
|
165
|
+
declare function getUserFriendlyMessage(error: unknown): string;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Transaction signing abstraction layer
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
interface TransactionSigner {
|
|
172
|
+
/** The wallet address that will sign transactions */
|
|
173
|
+
readonly address: string;
|
|
174
|
+
signTransaction(transaction: SolanaTransaction): Promise<SolanaTransaction>;
|
|
175
|
+
signAllTransactions(transactions: SolanaTransaction[]): Promise<SolanaTransaction[]>;
|
|
176
|
+
signAndSendTransaction(transaction: SolanaTransaction, options?: {
|
|
177
|
+
skipPreflight?: boolean;
|
|
178
|
+
maxRetries?: number;
|
|
179
|
+
}): Promise<string>;
|
|
180
|
+
signAndSendTransactions(transactions: SolanaTransaction[], options?: {
|
|
181
|
+
skipPreflight?: boolean;
|
|
182
|
+
maxRetries?: number;
|
|
183
|
+
}): Promise<string[]>;
|
|
184
|
+
signMessage?(message: Uint8Array): Promise<Uint8Array>;
|
|
185
|
+
getCapabilities(): TransactionSignerCapabilities;
|
|
186
|
+
}
|
|
187
|
+
declare function createTransactionSigner(config: TransactionSignerConfig): TransactionSigner | null;
|
|
188
|
+
/**
|
|
189
|
+
* @deprecated Use TransactionError from '../errors' instead
|
|
190
|
+
*/
|
|
191
|
+
declare class TransactionSignerError extends TransactionError {
|
|
192
|
+
constructor(message: string, code: 'WALLET_NOT_CONNECTED' | 'FEATURE_NOT_SUPPORTED' | 'SIGNING_FAILED' | 'SEND_FAILED', originalError?: Error);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* @deprecated Use isTransactionError from '../errors' instead
|
|
196
|
+
*/
|
|
197
|
+
declare function isTransactionSignerError(error: unknown): error is TransactionSignerError;
|
|
198
|
+
|
|
199
|
+
export { ConnectorError as C, Errors as E, NetworkError as N, type SolanaTransaction as S, type TransactionSignerConfig as T, ValidationError as V, type SignedTransaction as a, type TransactionSignerCapabilities as b, type TransactionActivity as c, type TransactionActivityStatus as d, type TransactionMethod as e, type TransactionMetadata as f, createTransactionSigner as g, TransactionSignerError as h, isTransactionSignerError as i, type TransactionSigner as j, ConnectionError as k, ConfigurationError as l, TransactionError as m, isConnectorError as n, isConnectionError as o, isValidationError as p, isConfigurationError as q, isNetworkError as r, isTransactionError as s, toConnectorError as t, getUserFriendlyMessage as u, type ConnectionErrorCode as v, type ValidationErrorCode as w, type ConfigurationErrorCode as x, type NetworkErrorCode as y, type TransactionErrorCode as z };
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { Wallet, WalletAccount } from '@wallet-standard/base';
|
|
2
|
+
import { SolanaClusterId, SolanaCluster } from '@wallet-ui/core';
|
|
3
|
+
import { Signature, Address, TransactionMessage } from 'gill';
|
|
4
|
+
import { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Transaction and signer-related types
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Union type for all supported Solana transaction formats
|
|
12
|
+
* Supports both legacy (@solana/web3.js) and modern (gill) transaction types
|
|
13
|
+
*/
|
|
14
|
+
type SolanaTransaction = Transaction | VersionedTransaction | TransactionMessage | Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* Transaction status during its lifecycle
|
|
17
|
+
*/
|
|
18
|
+
type TransactionActivityStatus = 'pending' | 'confirmed' | 'failed';
|
|
19
|
+
/**
|
|
20
|
+
* Methods used to send/sign transactions
|
|
21
|
+
*/
|
|
22
|
+
type TransactionMethod = 'signTransaction' | 'signAllTransactions' | 'signAndSendTransaction' | 'signAndSendTransactions' | 'sendTransaction' | 'sendRawTransaction';
|
|
23
|
+
/**
|
|
24
|
+
* Transaction metadata for additional context
|
|
25
|
+
*/
|
|
26
|
+
interface TransactionMetadata {
|
|
27
|
+
/** Transaction size in bytes */
|
|
28
|
+
size?: number;
|
|
29
|
+
/** Compute units requested */
|
|
30
|
+
computeUnits?: number;
|
|
31
|
+
/** Priority fee in lamports */
|
|
32
|
+
priorityFee?: number;
|
|
33
|
+
/** Number of signatures required */
|
|
34
|
+
numSignatures?: number;
|
|
35
|
+
/** Whether preflight was skipped */
|
|
36
|
+
skipPreflight?: boolean;
|
|
37
|
+
/** Custom metadata fields */
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for creating a transaction signer
|
|
42
|
+
*/
|
|
43
|
+
interface TransactionSignerConfig {
|
|
44
|
+
/** The Wallet Standard wallet instance */
|
|
45
|
+
wallet: Wallet;
|
|
46
|
+
/** The specific account to sign with */
|
|
47
|
+
account: WalletAccount;
|
|
48
|
+
/** Optional cluster/network context for chain-specific operations */
|
|
49
|
+
cluster?: SolanaCluster;
|
|
50
|
+
/** Optional event emitter for transaction lifecycle events */
|
|
51
|
+
eventEmitter?: {
|
|
52
|
+
emit: (event: unknown) => void;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Result of a signed transaction operation
|
|
57
|
+
*/
|
|
58
|
+
interface SignedTransaction {
|
|
59
|
+
/** The transaction signature/hash */
|
|
60
|
+
signature: string;
|
|
61
|
+
/** The signed transaction data */
|
|
62
|
+
transaction: SolanaTransaction;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Capabilities that a transaction signer supports
|
|
66
|
+
* Useful for conditionally enabling/disabling UI features
|
|
67
|
+
*/
|
|
68
|
+
interface TransactionSignerCapabilities {
|
|
69
|
+
/** Can sign transactions without sending */
|
|
70
|
+
canSign: boolean;
|
|
71
|
+
/** Can sign and send transactions in one operation */
|
|
72
|
+
canSend: boolean;
|
|
73
|
+
/** Can sign arbitrary messages */
|
|
74
|
+
canSignMessage: boolean;
|
|
75
|
+
/** Can sign multiple transactions at once */
|
|
76
|
+
supportsBatchSigning: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Transaction activity record for debugging and monitoring
|
|
80
|
+
*/
|
|
81
|
+
interface TransactionActivity {
|
|
82
|
+
/** Transaction signature */
|
|
83
|
+
signature: Signature;
|
|
84
|
+
/** When the transaction was sent */
|
|
85
|
+
timestamp: string;
|
|
86
|
+
/** Transaction status */
|
|
87
|
+
status: TransactionActivityStatus;
|
|
88
|
+
/** Error message if failed */
|
|
89
|
+
error?: string;
|
|
90
|
+
/** Cluster where transaction was sent */
|
|
91
|
+
cluster: SolanaClusterId;
|
|
92
|
+
/** Fee payer address */
|
|
93
|
+
feePayer?: Address;
|
|
94
|
+
/** Method used (signAndSendTransaction, sendTransaction, etc) */
|
|
95
|
+
method: TransactionMethod;
|
|
96
|
+
/** Additional metadata */
|
|
97
|
+
metadata?: TransactionMetadata;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @solana/connector - Unified Error System
|
|
102
|
+
*/
|
|
103
|
+
declare abstract class ConnectorError extends Error {
|
|
104
|
+
abstract readonly code: string;
|
|
105
|
+
abstract readonly recoverable: boolean;
|
|
106
|
+
readonly context?: Record<string, unknown>;
|
|
107
|
+
readonly originalError?: Error;
|
|
108
|
+
readonly timestamp: string;
|
|
109
|
+
constructor(message: string, context?: Record<string, unknown>, originalError?: Error);
|
|
110
|
+
toJSON(): Record<string, unknown>;
|
|
111
|
+
}
|
|
112
|
+
declare class ConnectionError extends ConnectorError {
|
|
113
|
+
readonly code: ConnectionErrorCode;
|
|
114
|
+
readonly recoverable = true;
|
|
115
|
+
constructor(code: ConnectionErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
|
|
116
|
+
}
|
|
117
|
+
type ConnectionErrorCode = 'WALLET_NOT_CONNECTED' | 'WALLET_NOT_FOUND' | 'CONNECTION_FAILED' | 'CONNECTION_REJECTED' | 'DISCONNECTION_FAILED' | 'ACCOUNT_NOT_AVAILABLE' | 'RECONNECTION_FAILED';
|
|
118
|
+
declare class ValidationError extends ConnectorError {
|
|
119
|
+
readonly code: ValidationErrorCode;
|
|
120
|
+
readonly recoverable = false;
|
|
121
|
+
constructor(code: ValidationErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
|
|
122
|
+
}
|
|
123
|
+
type ValidationErrorCode = 'INVALID_TRANSACTION' | 'INVALID_MESSAGE' | 'INVALID_ADDRESS' | 'INVALID_SIGNATURE' | 'INVALID_FORMAT' | 'UNSUPPORTED_FORMAT' | 'VALIDATION_FAILED';
|
|
124
|
+
declare class ConfigurationError extends ConnectorError {
|
|
125
|
+
readonly code: ConfigurationErrorCode;
|
|
126
|
+
readonly recoverable = false;
|
|
127
|
+
constructor(code: ConfigurationErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
|
|
128
|
+
}
|
|
129
|
+
type ConfigurationErrorCode = 'MISSING_PROVIDER' | 'INVALID_CLUSTER' | 'CLUSTER_NOT_FOUND' | 'INVALID_CONFIG' | 'INITIALIZATION_FAILED';
|
|
130
|
+
declare class NetworkError extends ConnectorError {
|
|
131
|
+
readonly code: NetworkErrorCode;
|
|
132
|
+
readonly recoverable = true;
|
|
133
|
+
constructor(code: NetworkErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
|
|
134
|
+
}
|
|
135
|
+
type NetworkErrorCode = 'RPC_ERROR' | 'NETWORK_TIMEOUT' | 'NETWORK_UNAVAILABLE' | 'TRANSACTION_SIMULATION_FAILED';
|
|
136
|
+
declare class TransactionError extends ConnectorError {
|
|
137
|
+
readonly code: TransactionErrorCode;
|
|
138
|
+
readonly recoverable: boolean;
|
|
139
|
+
constructor(code: TransactionErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
|
|
140
|
+
}
|
|
141
|
+
type TransactionErrorCode = 'SIGNING_FAILED' | 'SEND_FAILED' | 'FEATURE_NOT_SUPPORTED' | 'USER_REJECTED' | 'SIMULATION_FAILED' | 'INVALID_TRANSACTION' | 'TRANSACTION_EXPIRED';
|
|
142
|
+
declare function isConnectorError(error: unknown): error is ConnectorError;
|
|
143
|
+
declare function isConnectionError(error: unknown): error is ConnectionError;
|
|
144
|
+
declare function isValidationError(error: unknown): error is ValidationError;
|
|
145
|
+
declare function isConfigurationError(error: unknown): error is ConfigurationError;
|
|
146
|
+
declare function isNetworkError(error: unknown): error is NetworkError;
|
|
147
|
+
declare function isTransactionError(error: unknown): error is TransactionError;
|
|
148
|
+
declare const Errors: {
|
|
149
|
+
readonly walletNotConnected: (context?: Record<string, unknown>) => ConnectionError;
|
|
150
|
+
readonly walletNotFound: (walletName?: string) => ConnectionError;
|
|
151
|
+
readonly connectionFailed: (originalError?: Error) => ConnectionError;
|
|
152
|
+
readonly accountNotAvailable: (address?: string) => ConnectionError;
|
|
153
|
+
readonly invalidTransaction: (reason: string, context?: Record<string, unknown>) => ValidationError;
|
|
154
|
+
readonly invalidFormat: (expectedFormat: string, actualFormat?: string) => ValidationError;
|
|
155
|
+
readonly unsupportedFormat: (format: string) => ValidationError;
|
|
156
|
+
readonly missingProvider: (hookName: string) => ConfigurationError;
|
|
157
|
+
readonly clusterNotFound: (clusterId: string, availableClusters: string[]) => ConfigurationError;
|
|
158
|
+
readonly rpcError: (message: string, originalError?: Error) => NetworkError;
|
|
159
|
+
readonly networkTimeout: () => NetworkError;
|
|
160
|
+
readonly signingFailed: (originalError?: Error) => TransactionError;
|
|
161
|
+
readonly featureNotSupported: (feature: string) => TransactionError;
|
|
162
|
+
readonly userRejected: (operation: string) => TransactionError;
|
|
163
|
+
};
|
|
164
|
+
declare function toConnectorError(error: unknown, defaultMessage?: string): ConnectorError;
|
|
165
|
+
declare function getUserFriendlyMessage(error: unknown): string;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Transaction signing abstraction layer
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
interface TransactionSigner {
|
|
172
|
+
/** The wallet address that will sign transactions */
|
|
173
|
+
readonly address: string;
|
|
174
|
+
signTransaction(transaction: SolanaTransaction): Promise<SolanaTransaction>;
|
|
175
|
+
signAllTransactions(transactions: SolanaTransaction[]): Promise<SolanaTransaction[]>;
|
|
176
|
+
signAndSendTransaction(transaction: SolanaTransaction, options?: {
|
|
177
|
+
skipPreflight?: boolean;
|
|
178
|
+
maxRetries?: number;
|
|
179
|
+
}): Promise<string>;
|
|
180
|
+
signAndSendTransactions(transactions: SolanaTransaction[], options?: {
|
|
181
|
+
skipPreflight?: boolean;
|
|
182
|
+
maxRetries?: number;
|
|
183
|
+
}): Promise<string[]>;
|
|
184
|
+
signMessage?(message: Uint8Array): Promise<Uint8Array>;
|
|
185
|
+
getCapabilities(): TransactionSignerCapabilities;
|
|
186
|
+
}
|
|
187
|
+
declare function createTransactionSigner(config: TransactionSignerConfig): TransactionSigner | null;
|
|
188
|
+
/**
|
|
189
|
+
* @deprecated Use TransactionError from '../errors' instead
|
|
190
|
+
*/
|
|
191
|
+
declare class TransactionSignerError extends TransactionError {
|
|
192
|
+
constructor(message: string, code: 'WALLET_NOT_CONNECTED' | 'FEATURE_NOT_SUPPORTED' | 'SIGNING_FAILED' | 'SEND_FAILED', originalError?: Error);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* @deprecated Use isTransactionError from '../errors' instead
|
|
196
|
+
*/
|
|
197
|
+
declare function isTransactionSignerError(error: unknown): error is TransactionSignerError;
|
|
198
|
+
|
|
199
|
+
export { ConnectorError as C, Errors as E, NetworkError as N, type SolanaTransaction as S, type TransactionSignerConfig as T, ValidationError as V, type SignedTransaction as a, type TransactionSignerCapabilities as b, type TransactionActivity as c, type TransactionActivityStatus as d, type TransactionMethod as e, type TransactionMetadata as f, createTransactionSigner as g, TransactionSignerError as h, isTransactionSignerError as i, type TransactionSigner as j, ConnectionError as k, ConfigurationError as l, TransactionError as m, isConnectorError as n, isConnectionError as o, isValidationError as p, isConfigurationError as q, isNetworkError as r, isTransactionError as s, toConnectorError as t, getUserFriendlyMessage as u, type ConnectionErrorCode as v, type ValidationErrorCode as w, type ConfigurationErrorCode as x, type NetworkErrorCode as y, type TransactionErrorCode as z };
|