solana-web3-on-steroids 1.0.2

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.
@@ -0,0 +1,275 @@
1
+ import { Connection, TransactionExpiredBlockheightExceededError, } from '@solana/web3.js';
2
+ import { TransactionState, DEFAULT_CONFIG } from '../types/SteroidWalletTypes.js';
3
+ /**
4
+ * Enhanced transaction handling with state management, automatic retries,
5
+ * blockhash refresh, and multi-node confirmation.
6
+ */
7
+ export class SteroidTransaction {
8
+ connection;
9
+ transactionStates = new Map();
10
+ constructor(connection) {
11
+ this.connection = connection;
12
+ }
13
+ /**
14
+ * Sends a transaction with continuous re-broadcasting and multi-node monitoring.
15
+ * Includes automatic blockhash refresh and comprehensive error handling.
16
+ */
17
+ async sendAndConfirm(transaction, options = {}) {
18
+ const mergedOptions = {
19
+ skipPreflight: false,
20
+ preflightCommitment: 'processed',
21
+ ...DEFAULT_CONFIG.TRANSACTION,
22
+ ...options,
23
+ };
24
+ const { timeoutSeconds, retryInterval, skipPreflight, preflightCommitment, confirmationCommitment, maxBlockhashAge, enableLogging, confirmationNodes, } = mergedOptions;
25
+ const stateId = this.generateStateId();
26
+ const state = {
27
+ state: TransactionState.PENDING,
28
+ attempts: 0,
29
+ startTime: Date.now(),
30
+ };
31
+ this.transactionStates.set(stateId, state);
32
+ try {
33
+ // 1. Simulation with detailed error parsing
34
+ if (!skipPreflight) {
35
+ this.updateState(stateId, TransactionState.PENDING);
36
+ await this.simulateTransaction(transaction, preflightCommitment, enableLogging);
37
+ this.updateState(stateId, TransactionState.SIMULATED);
38
+ }
39
+ // 2. Initial blockhash setup if needed
40
+ let blockhashContext;
41
+ if (this.isLegacyTransaction(transaction)) {
42
+ blockhashContext = await this.getFreshBlockhash(enableLogging);
43
+ transaction.recentBlockhash = blockhashContext.blockhash;
44
+ transaction.lastValidBlockHeight = blockhashContext.lastValidBlockHeight;
45
+ }
46
+ const rawTransaction = this.serializeTransaction(transaction);
47
+ const startTime = Date.now();
48
+ let signature = '';
49
+ let lastBlockhashRefresh = Date.now();
50
+ // 3. Send and retry loop with blockhash refresh
51
+ while (Date.now() - startTime < timeoutSeconds * 1000) {
52
+ try {
53
+ state.attempts++;
54
+ state.lastAttemptTime = Date.now();
55
+ // Check if blockhash is too old and refresh if needed
56
+ const ageSeconds = (Date.now() - lastBlockhashRefresh) / 1000;
57
+ if (ageSeconds > maxBlockhashAge && this.isLegacyTransaction(transaction)) {
58
+ this.log('info', `Blockhash age ${ageSeconds.toFixed(1)}s exceeds max ${maxBlockhashAge}s, refreshing...`, enableLogging);
59
+ blockhashContext = await this.getFreshBlockhash(enableLogging);
60
+ transaction.recentBlockhash = blockhashContext.blockhash;
61
+ transaction.lastValidBlockHeight = blockhashContext.lastValidBlockHeight;
62
+ // Re-serialize with new blockhash
63
+ // Note: This assumes the transaction is re-signed by the caller if needed
64
+ lastBlockhashRefresh = Date.now();
65
+ }
66
+ // Broadcast transaction
67
+ signature = await this.connection.sendRawTransaction(rawTransaction, {
68
+ skipPreflight: true,
69
+ maxRetries: 0, // We handle retries ourselves
70
+ });
71
+ this.updateState(stateId, TransactionState.SENT, signature);
72
+ this.log('info', `Transaction sent: ${signature} (attempt ${state.attempts})`, enableLogging);
73
+ // 4. Multi-node confirmation check
74
+ const confirmed = await this.pollForConfirmation(signature, confirmationCommitment, confirmationNodes, enableLogging);
75
+ if (confirmed) {
76
+ this.updateState(stateId, TransactionState.CONFIRMED, signature);
77
+ state.confirmedAt = Date.now();
78
+ const duration = ((state.confirmedAt - state.startTime) / 1000).toFixed(2);
79
+ this.log('info', `Transaction confirmed in ${duration}s after ${state.attempts} attempts`, enableLogging);
80
+ return signature;
81
+ }
82
+ this.log('warn', `Transaction not yet confirmed, will retry in ${retryInterval}ms...`, enableLogging);
83
+ }
84
+ catch (error) {
85
+ // Handle blockhash expiration
86
+ if (this.isBlockhashExpiredError(error)) {
87
+ this.log('warn', 'Blockhash expired or invalid, will refresh on next attempt', enableLogging);
88
+ lastBlockhashRefresh = 0; // Force refresh on next iteration
89
+ }
90
+ else {
91
+ this.log('warn', `Broadcast attempt failed: ${error.message}`, enableLogging);
92
+ }
93
+ }
94
+ await this.sleep(retryInterval);
95
+ }
96
+ // Timeout reached
97
+ const errorMsg = `Transaction not confirmed within ${timeoutSeconds}s after ${state.attempts} attempts`;
98
+ this.updateState(stateId, TransactionState.EXPIRED, signature, errorMsg);
99
+ throw new Error(`[SteroidTransaction] ${errorMsg}. Last signature: ${signature || 'none'}`);
100
+ }
101
+ catch (error) {
102
+ this.updateState(stateId, TransactionState.FAILED, state.signature, error.message);
103
+ throw error;
104
+ }
105
+ }
106
+ /**
107
+ * Simulates a transaction and provides detailed error information.
108
+ */
109
+ async simulateTransaction(transaction, commitment, enableLogging) {
110
+ try {
111
+ const simulation = await this.connection.simulateTransaction(transaction, {
112
+ commitment,
113
+ replaceRecentBlockhash: true,
114
+ });
115
+ if (simulation.value.err) {
116
+ const errorDetails = this.parseSimulationError(simulation.value);
117
+ this.log('error', `Simulation failed: ${errorDetails}`, enableLogging);
118
+ throw new Error(`[SteroidTransaction] Simulation failed: ${errorDetails}`);
119
+ }
120
+ if (simulation.value.logs) {
121
+ this.log('info', `Simulation succeeded. Logs count: ${simulation.value.logs.length}`, enableLogging);
122
+ }
123
+ }
124
+ catch (error) {
125
+ if (error.message?.includes('Simulation failed'))
126
+ throw error;
127
+ throw new Error(`[SteroidTransaction] Simulation error: ${error.message}`);
128
+ }
129
+ }
130
+ /**
131
+ * Polls multiple RPC endpoints for signature status to bypass node lag.
132
+ */
133
+ async pollForConfirmation(signature, commitment, nodesToCheck, enableLogging) {
134
+ const endpoints = this.connection.getEndpoints();
135
+ const endpointsToCheck = endpoints.slice(0, Math.min(nodesToCheck, endpoints.length));
136
+ this.log('info', `Checking confirmation across ${endpointsToCheck.length} nodes...`, enableLogging);
137
+ const checks = endpointsToCheck.map(async (url) => {
138
+ try {
139
+ const tempConn = new Connection(url, { commitment });
140
+ const status = await tempConn.getSignatureStatus(signature);
141
+ if (status.value?.err) {
142
+ throw new Error(`Transaction failed on ${url}: ${JSON.stringify(status.value.err)}`);
143
+ }
144
+ const isConfirmed = status.value?.confirmationStatus === 'confirmed' ||
145
+ status.value?.confirmationStatus === 'finalized';
146
+ if (isConfirmed && status.value) {
147
+ this.log('info', `Transaction confirmed on ${url} (${status.value.confirmationStatus})`, enableLogging);
148
+ return true;
149
+ }
150
+ return false;
151
+ }
152
+ catch (error) {
153
+ this.log('warn', `Confirmation check failed for ${url}: ${error.message}`, enableLogging);
154
+ return false;
155
+ }
156
+ });
157
+ const results = await Promise.allSettled(checks);
158
+ // Fail-fast if any node reports a definitive transaction error
159
+ for (const result of results) {
160
+ if (result.status === 'rejected' && result.reason?.message?.includes('Transaction failed')) {
161
+ throw result.reason;
162
+ }
163
+ }
164
+ return results.some((r) => r.status === 'fulfilled' && r.value === true);
165
+ }
166
+ /**
167
+ * Get fresh blockhash with retry logic.
168
+ */
169
+ async getFreshBlockhash(enableLogging) {
170
+ try {
171
+ const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash('confirmed');
172
+ this.log('info', `Fetched fresh blockhash: ${blockhash.slice(0, 8)}...`, enableLogging);
173
+ return { blockhash, lastValidBlockHeight };
174
+ }
175
+ catch (error) {
176
+ throw new Error(`[SteroidTransaction] Failed to get blockhash: ${error.message}`);
177
+ }
178
+ }
179
+ /**
180
+ * Parse simulation errors into human-readable format.
181
+ */
182
+ parseSimulationError(simulationValue) {
183
+ const logs = simulationValue.logs || [];
184
+ const errorLog = logs.find((l) => l.includes('Error:') || l.includes('failed') || l.includes('custom program error'));
185
+ if (errorLog)
186
+ return errorLog;
187
+ if (simulationValue.err) {
188
+ if (typeof simulationValue.err === 'string')
189
+ return simulationValue.err;
190
+ if (simulationValue.err.InstructionError) {
191
+ const [index, error] = simulationValue.err.InstructionError;
192
+ return `Instruction ${index} failed: ${JSON.stringify(error)}`;
193
+ }
194
+ return JSON.stringify(simulationValue.err);
195
+ }
196
+ return 'Unknown simulation error';
197
+ }
198
+ isBlockhashExpiredError(error) {
199
+ return (error instanceof TransactionExpiredBlockheightExceededError ||
200
+ error.message?.includes('block height exceeded') ||
201
+ error.message?.includes('blockhash not found'));
202
+ }
203
+ /**
204
+ * Type guard for legacy transactions.
205
+ */
206
+ isLegacyTransaction(transaction) {
207
+ return 'recentBlockhash' in transaction;
208
+ }
209
+ /**
210
+ * Serialize transaction to bytes.
211
+ */
212
+ serializeTransaction(transaction) {
213
+ if (this.isLegacyTransaction(transaction)) {
214
+ return transaction.serialize();
215
+ }
216
+ return Buffer.from(transaction.serialize());
217
+ }
218
+ generateStateId() {
219
+ return `tx_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
220
+ }
221
+ updateState(stateId, state, signature, error) {
222
+ const existing = this.transactionStates.get(stateId);
223
+ if (existing) {
224
+ existing.state = state;
225
+ if (signature)
226
+ existing.signature = signature;
227
+ if (error)
228
+ existing.error = error;
229
+ }
230
+ }
231
+ log(level, message, enabled) {
232
+ if (!enabled)
233
+ return;
234
+ const prefix = '[SteroidTransaction]';
235
+ const formattedMessage = `${prefix} ${message}`;
236
+ switch (level) {
237
+ case 'info':
238
+ console.log(formattedMessage);
239
+ break;
240
+ case 'warn':
241
+ console.warn(formattedMessage);
242
+ break;
243
+ case 'error':
244
+ console.error(formattedMessage);
245
+ break;
246
+ }
247
+ }
248
+ sleep(ms) {
249
+ return new Promise((resolve) => setTimeout(resolve, ms));
250
+ }
251
+ /**
252
+ * Get the current state of a transaction.
253
+ */
254
+ getTransactionState(stateId) {
255
+ return this.transactionStates.get(stateId);
256
+ }
257
+ /**
258
+ * Get all transaction states (useful for debugging).
259
+ */
260
+ getAllTransactionStates() {
261
+ return new Map(this.transactionStates);
262
+ }
263
+ /**
264
+ * Clear old transaction states (cleanup).
265
+ */
266
+ clearOldStates(olderThanMs = 3600000) {
267
+ const now = Date.now();
268
+ for (const [id, state] of this.transactionStates.entries()) {
269
+ if (now - state.startTime > olderThanMs) {
270
+ this.transactionStates.delete(id);
271
+ }
272
+ }
273
+ }
274
+ }
275
+ //# sourceMappingURL=SteroidTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SteroidTransaction.js","sourceRoot":"","sources":["../../src/transaction/SteroidTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAMV,0CAA0C,GAC3C,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAsB,gBAAgB,EAAwB,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAE5H;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IACrB,UAAU,CAAoB;IAC9B,iBAAiB,GAAsC,IAAI,GAAG,EAAE,CAAC;IAEzE,YAAY,UAA6B;QACvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAGD;;;OAGG;IACH,KAAK,CAAC,cAAc,CAClB,WAA+C,EAC/C,UAA8B,EAAE;QAEhC,MAAM,aAAa,GAAG;YACpB,aAAa,EAAE,KAAK;YACpB,mBAAmB,EAAE,WAAyB;YAC9C,GAAG,cAAc,CAAC,WAAW;YAC7B,GAAG,OAAO;SACX,CAAC;QAEF,MAAM,EACJ,cAAc,EACd,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,iBAAiB,GAClB,GAAG,aAAa,CAAC;QAElB,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACvC,MAAM,KAAK,GAAyB;YAClC,KAAK,EAAE,gBAAgB,CAAC,OAAO;YAC/B,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC;QACF,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAE3C,IAAI,CAAC;YACH,4CAA4C;YAC5C,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,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CAAC,GAAG,EAAE,CAAC;QACvB,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,EAAE,CAAC;YAC3D,IAAI,GAAG,GAAG,KAAK,CAAC,SAAS,GAAG,WAAW,EAAE,CAAC;gBACxC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,185 @@
1
+ import type { Connection, ConnectionConfig, Commitment, PublicKey, Transaction, VersionedTransaction, TransactionSignature, SendOptions, BlockhashWithExpiryBlockHeight, SignatureStatus } from '@solana/web3.js';
2
+ export type { Connection, ConnectionConfig, Commitment, PublicKey, Transaction, VersionedTransaction, TransactionSignature, SendOptions, BlockhashWithExpiryBlockHeight, SignatureStatus, };
3
+ export interface SteroidConnectionConfig extends ConnectionConfig {
4
+ fallbacks?: string[];
5
+ maxRetries?: number;
6
+ retryDelay?: number;
7
+ healthCheckInterval?: number;
8
+ requestTimeout?: number;
9
+ enableLogging?: boolean;
10
+ }
11
+ export interface RPCHealth {
12
+ url: string;
13
+ healthy: boolean;
14
+ lastChecked: number;
15
+ latency?: number;
16
+ }
17
+ export interface FailoverStats {
18
+ count: number;
19
+ lastTime: number;
20
+ }
21
+ export interface SteroidSendOptions extends SendOptions {
22
+ timeoutSeconds?: number;
23
+ retryInterval?: number;
24
+ confirmationCommitment?: Commitment;
25
+ maxBlockhashAge?: number;
26
+ enableLogging?: boolean;
27
+ confirmationNodes?: number;
28
+ }
29
+ export declare enum TransactionState {
30
+ PENDING = "PENDING",
31
+ SIMULATED = "SIMULATED",
32
+ SIGNED = "SIGNED",
33
+ SENT = "SENT",
34
+ CONFIRMED = "CONFIRMED",
35
+ FINALIZED = "FINALIZED",
36
+ FAILED = "FAILED",
37
+ EXPIRED = "EXPIRED"
38
+ }
39
+ export interface TransactionStateInfo {
40
+ state: TransactionState;
41
+ signature?: string;
42
+ error?: string;
43
+ attempts: number;
44
+ startTime: number;
45
+ lastAttemptTime?: number;
46
+ confirmedAt?: number;
47
+ }
48
+ export interface WalletInterface {
49
+ publicKey: PublicKey | null;
50
+ signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
51
+ signAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]>;
52
+ signMessage?(message: Uint8Array): Promise<Uint8Array>;
53
+ }
54
+ export declare enum WalletErrorType {
55
+ NOT_CONNECTED = "NOT_CONNECTED",
56
+ USER_REJECTED = "USER_REJECTED",
57
+ NETWORK_MISMATCH = "NETWORK_MISMATCH",
58
+ SIGNING_FAILED = "SIGNING_FAILED",
59
+ UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION",
60
+ UNKNOWN = "UNKNOWN"
61
+ }
62
+ export interface SteroidWalletConfig {
63
+ validateNetwork?: boolean;
64
+ expectedGenesisHash?: string;
65
+ enableLogging?: boolean;
66
+ autoRefreshBlockhash?: boolean;
67
+ maxBlockhashAge?: number;
68
+ }
69
+ export interface NetworkInfo {
70
+ genesisHash?: string;
71
+ validated: boolean;
72
+ }
73
+ /**
74
+ * Client Types
75
+ */
76
+ export interface SteroidClientConfig {
77
+ connection?: SteroidConnectionConfig;
78
+ wallet?: SteroidWalletConfig;
79
+ enableLogging?: boolean;
80
+ }
81
+ export interface ClientStats {
82
+ activeEndpoint: string;
83
+ allEndpoints: string[];
84
+ failoverStats: FailoverStats;
85
+ healthStatus: RPCHealth[];
86
+ }
87
+ /**
88
+ * Network Types
89
+ */
90
+ export type NetworkType = 'mainnet-beta' | 'devnet' | 'testnet';
91
+ /**
92
+ * Utility Types
93
+ */
94
+ export type AnyTransaction = Transaction | VersionedTransaction;
95
+ export type SignedTransaction<T extends AnyTransaction = AnyTransaction> = T;
96
+ export type TransactionResult = {
97
+ signature: TransactionSignature;
98
+ confirmedAt: number;
99
+ attempts: number;
100
+ };
101
+ export type ErrorHandler = (error: Error) => void | Promise<void>;
102
+ export type TransactionCallback = (signature: TransactionSignature, state: TransactionStateInfo) => void | Promise<void>;
103
+ /**
104
+ * Type guards
105
+ */
106
+ export declare function isLegacyTransaction(transaction: AnyTransaction): transaction is Transaction;
107
+ export declare function isVersionedTransaction(transaction: AnyTransaction): transaction is VersionedTransaction;
108
+ /**
109
+ * Helper types for improved DX
110
+ */
111
+ export type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
112
+ export type WithRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;
113
+ export type DeepPartial<T> = {
114
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
115
+ };
116
+ /**
117
+ * Event types for potential event emitter implementation
118
+ */
119
+ export interface SteroidEvents {
120
+ 'transaction:pending': {
121
+ signature?: string;
122
+ };
123
+ 'transaction:simulated': {
124
+ signature?: string;
125
+ };
126
+ 'transaction:sent': {
127
+ signature: string;
128
+ };
129
+ 'transaction:confirmed': {
130
+ signature: string;
131
+ attempts: number;
132
+ };
133
+ 'transaction:failed': {
134
+ signature?: string;
135
+ error: Error;
136
+ };
137
+ 'connection:failover': {
138
+ from: string;
139
+ to: string;
140
+ };
141
+ 'connection:health-check': {
142
+ health: RPCHealth[];
143
+ };
144
+ 'wallet:connected': {
145
+ publicKey: PublicKey;
146
+ };
147
+ 'wallet:disconnected': {};
148
+ }
149
+ /**
150
+ * Constants
151
+ */
152
+ export declare const DEFAULT_CONFIG: {
153
+ readonly CONNECTION: {
154
+ readonly maxRetries: 5;
155
+ readonly retryDelay: 500;
156
+ readonly healthCheckInterval: 30000;
157
+ readonly requestTimeout: 30000;
158
+ readonly enableLogging: false;
159
+ };
160
+ readonly TRANSACTION: {
161
+ readonly timeoutSeconds: 60;
162
+ readonly retryInterval: 2000;
163
+ readonly confirmationCommitment: Commitment;
164
+ readonly maxBlockhashAge: 60;
165
+ readonly confirmationNodes: 3;
166
+ readonly enableLogging: false;
167
+ };
168
+ readonly WALLET: {
169
+ readonly validateNetwork: true;
170
+ readonly enableLogging: false;
171
+ readonly autoRefreshBlockhash: true;
172
+ readonly maxBlockhashAge: 60;
173
+ };
174
+ };
175
+ /**
176
+ * Export type for package consumers
177
+ */
178
+ export interface SteroidWalletPackage {
179
+ SteroidClient: any;
180
+ SteroidConnection: any;
181
+ SteroidTransaction: any;
182
+ SteroidWallet: any;
183
+ WalletError: any;
184
+ createSteroidClient: any;
185
+ }
@@ -0,0 +1,56 @@
1
+ export var TransactionState;
2
+ (function (TransactionState) {
3
+ TransactionState["PENDING"] = "PENDING";
4
+ TransactionState["SIMULATED"] = "SIMULATED";
5
+ TransactionState["SIGNED"] = "SIGNED";
6
+ TransactionState["SENT"] = "SENT";
7
+ TransactionState["CONFIRMED"] = "CONFIRMED";
8
+ TransactionState["FINALIZED"] = "FINALIZED";
9
+ TransactionState["FAILED"] = "FAILED";
10
+ TransactionState["EXPIRED"] = "EXPIRED";
11
+ })(TransactionState || (TransactionState = {}));
12
+ export var WalletErrorType;
13
+ (function (WalletErrorType) {
14
+ WalletErrorType["NOT_CONNECTED"] = "NOT_CONNECTED";
15
+ WalletErrorType["USER_REJECTED"] = "USER_REJECTED";
16
+ WalletErrorType["NETWORK_MISMATCH"] = "NETWORK_MISMATCH";
17
+ WalletErrorType["SIGNING_FAILED"] = "SIGNING_FAILED";
18
+ WalletErrorType["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
19
+ WalletErrorType["UNKNOWN"] = "UNKNOWN";
20
+ })(WalletErrorType || (WalletErrorType = {}));
21
+ /**
22
+ * Type guards
23
+ */
24
+ export function isLegacyTransaction(transaction) {
25
+ return 'recentBlockhash' in transaction;
26
+ }
27
+ export function isVersionedTransaction(transaction) {
28
+ return 'version' in transaction;
29
+ }
30
+ /**
31
+ * Constants
32
+ */
33
+ export const DEFAULT_CONFIG = {
34
+ CONNECTION: {
35
+ maxRetries: 5,
36
+ retryDelay: 500,
37
+ healthCheckInterval: 30000,
38
+ requestTimeout: 30000,
39
+ enableLogging: false,
40
+ },
41
+ TRANSACTION: {
42
+ timeoutSeconds: 60,
43
+ retryInterval: 2000,
44
+ confirmationCommitment: 'confirmed',
45
+ maxBlockhashAge: 60,
46
+ confirmationNodes: 3,
47
+ enableLogging: false,
48
+ },
49
+ WALLET: {
50
+ validateNetwork: true,
51
+ enableLogging: false,
52
+ autoRefreshBlockhash: true,
53
+ maxBlockhashAge: 60,
54
+ },
55
+ };
56
+ //# sourceMappingURL=SteroidWalletTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SteroidWalletTypes.js","sourceRoot":"","sources":["../../src/types/SteroidWalletTypes.ts"],"names":[],"mappings":"AA2DA,MAAM,CAAN,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,2CAAuB,CAAA;IACvB,qCAAiB,CAAA;IACjB,iCAAa,CAAA;IACb,2CAAuB,CAAA;IACvB,2CAAuB,CAAA;IACvB,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;AACrB,CAAC,EATW,gBAAgB,KAAhB,gBAAgB,QAS3B;AAqBD,MAAM,CAAN,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,kDAA+B,CAAA;IAC/B,kDAA+B,CAAA;IAC/B,wDAAqC,CAAA;IACrC,oDAAiC,CAAA;IACjC,kEAA+C,CAAA;IAC/C,sCAAmB,CAAA;AACrB,CAAC,EAPW,eAAe,KAAf,eAAe,QAO1B;AAwDD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,WAA2B;IAE3B,OAAO,iBAAiB,IAAI,WAAW,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,WAA2B;IAE3B,OAAO,SAAS,IAAI,WAAW,CAAC;AAClC,CAAC;AA4BD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,UAAU,EAAE;QACV,UAAU,EAAE,CAAC;QACb,UAAU,EAAE,GAAG;QACf,mBAAmB,EAAE,KAAK;QAC1B,cAAc,EAAE,KAAK;QACrB,aAAa,EAAE,KAAK;KACrB;IACD,WAAW,EAAE;QACX,cAAc,EAAE,EAAE;QAClB,aAAa,EAAE,IAAI;QACnB,sBAAsB,EAAE,WAAyB;QACjD,eAAe,EAAE,EAAE;QACnB,iBAAiB,EAAE,CAAC;QACpB,aAAa,EAAE,KAAK;KACrB;IACD,MAAM,EAAE;QACN,eAAe,EAAE,IAAI;QACrB,aAAa,EAAE,KAAK;QACpB,oBAAoB,EAAE,IAAI;QAC1B,eAAe,EAAE,EAAE;KACpB;CACO,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { PublicKey, Transaction, VersionedTransaction, TransactionSignature } from '@solana/web3.js';
2
+ import { SteroidConnection } from '../connection/SteroidConnection.js';
3
+ import { WalletInterface, WalletErrorType, SteroidWalletConfig, SteroidSendOptions } from '../types/SteroidWalletTypes.js';
4
+ export declare class WalletError extends Error {
5
+ type: WalletErrorType;
6
+ originalError?: any | undefined;
7
+ constructor(type: WalletErrorType, message: string, originalError?: any | undefined);
8
+ }
9
+ /**
10
+ * SteroidWallet wraps any Solana wallet adapter and provides:
11
+ * - Normalized error handling across different wallet implementations
12
+ * - Network consistency validation
13
+ * - Automatic transaction retry and confirmation
14
+ * - Graceful degradation for missing wallet features
15
+ */
16
+ export declare class SteroidWallet {
17
+ private wallet;
18
+ private connection;
19
+ private txEngine;
20
+ private config;
21
+ private networkValidated;
22
+ private genesisHash?;
23
+ constructor(wallet: WalletInterface, connection: SteroidConnection, config?: SteroidWalletConfig);
24
+ /**
25
+ * Get the wallet's public key.
26
+ */
27
+ get publicKey(): PublicKey | null;
28
+ /**
29
+ * Signs and sends a transaction with full reliability guarantees.
30
+ * Handles blockhash refresh, retries, and multi-node confirmation.
31
+ */
32
+ signAndSend(transaction: Transaction | VersionedTransaction, options?: SteroidSendOptions): Promise<TransactionSignature>;
33
+ /**
34
+ * Sign a transaction safely with normalized error handling.
35
+ */
36
+ signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
37
+ /**
38
+ * Sign multiple transactions safely.
39
+ */
40
+ signAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]>;
41
+ /**
42
+ * Sign a message with standardized error handling.
43
+ */
44
+ signMessage(message: Uint8Array): Promise<Uint8Array>;
45
+ /**
46
+ * System-level state validation before operations.
47
+ */
48
+ private guardState;
49
+ /**
50
+ * Validates that the wallet and connection are on the same network.
51
+ */
52
+ private validateNetwork;
53
+ /**
54
+ * Ensures transaction has a fresh blockhash.
55
+ */
56
+ private ensureFreshBlockhash;
57
+ /**
58
+ * Safely sign a transaction with proper error handling.
59
+ */
60
+ private signTransactionSafe;
61
+ /**
62
+ * Normalizes different wallet errors into a consistent format.
63
+ */
64
+ private normalizeError;
65
+ /**
66
+ * Type guard for legacy transactions.
67
+ */
68
+ private isLegacyTransaction;
69
+ private log;
70
+ /**
71
+ * Get network information.
72
+ */
73
+ getNetworkInfo(): {
74
+ genesisHash?: string;
75
+ validated: boolean;
76
+ };
77
+ /**
78
+ * Force re-validation of network on next operation.
79
+ */
80
+ invalidateNetwork(): void;
81
+ /**
82
+ * Check if wallet supports message signing.
83
+ */
84
+ supportsMessageSigning(): boolean;
85
+ }