@drift-labs/sdk 2.82.0-beta.7 → 2.82.0-beta.8
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/VERSION +1 -1
- package/lib/tx/baseTxSender.js +3 -2
- package/lib/tx/types.d.ts +5 -0
- package/lib/tx/types.js +12 -1
- package/package.json +1 -1
- package/src/tx/baseTxSender.ts +8 -4
- package/src/tx/types.ts +12 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.82.0-beta.
|
|
1
|
+
2.82.0-beta.8
|
package/lib/tx/baseTxSender.js
CHANGED
|
@@ -10,6 +10,7 @@ const anchor_1 = require("@coral-xyz/anchor");
|
|
|
10
10
|
const assert_1 = __importDefault(require("assert"));
|
|
11
11
|
const bs58_1 = __importDefault(require("bs58"));
|
|
12
12
|
const DEFAULT_TIMEOUT = 35000;
|
|
13
|
+
const NOT_CONFIRMED_ERROR_CODE = -1001;
|
|
13
14
|
class BaseTxSender {
|
|
14
15
|
constructor({ connection, wallet, opts = anchor_1.AnchorProvider.defaultOptions(), timeout = DEFAULT_TIMEOUT, additionalConnections = new Array(), confirmationStrategy = types_1.ConfirmationStrategy.Combo, additionalTxSenderCallbacks, }) {
|
|
15
16
|
this.timeoutCount = 0;
|
|
@@ -181,7 +182,7 @@ class BaseTxSender {
|
|
|
181
182
|
}
|
|
182
183
|
this.timeoutCount += 1;
|
|
183
184
|
const duration = (Date.now() - start) / 1000;
|
|
184
|
-
throw new
|
|
185
|
+
throw new types_1.TxSendError(`Transaction was not confirmed in ${duration.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${signature} using the Solana Explorer or CLI tools.`, NOT_CONFIRMED_ERROR_CODE);
|
|
185
186
|
}
|
|
186
187
|
return response;
|
|
187
188
|
}
|
|
@@ -203,7 +204,7 @@ class BaseTxSender {
|
|
|
203
204
|
// Transaction not confirmed within 30 seconds
|
|
204
205
|
this.timeoutCount += 1;
|
|
205
206
|
const duration = (Date.now() - start) / 1000;
|
|
206
|
-
throw new
|
|
207
|
+
throw new types_1.TxSendError(`Transaction was not confirmed in ${duration.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${signature} using the Solana Explorer or CLI tools.`, NOT_CONFIRMED_ERROR_CODE);
|
|
207
208
|
}
|
|
208
209
|
async confirmTransaction(signature, commitment) {
|
|
209
210
|
if (this.confirmationStrategy === types_1.ConfirmationStrategy.WebSocket ||
|
package/lib/tx/types.d.ts
CHANGED
|
@@ -22,3 +22,8 @@ export interface TxSender {
|
|
|
22
22
|
simulateTransaction(tx: VersionedTransaction): Promise<boolean>;
|
|
23
23
|
getTimeoutCount(): number;
|
|
24
24
|
}
|
|
25
|
+
export declare class TxSendError extends Error {
|
|
26
|
+
message: string;
|
|
27
|
+
code: number;
|
|
28
|
+
constructor(message: string, code: number);
|
|
29
|
+
}
|
package/lib/tx/types.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConfirmationStrategy = void 0;
|
|
3
|
+
exports.TxSendError = exports.ConfirmationStrategy = void 0;
|
|
4
4
|
var ConfirmationStrategy;
|
|
5
5
|
(function (ConfirmationStrategy) {
|
|
6
6
|
ConfirmationStrategy["WebSocket"] = "websocket";
|
|
7
7
|
ConfirmationStrategy["Polling"] = "polling";
|
|
8
8
|
ConfirmationStrategy["Combo"] = "combo";
|
|
9
9
|
})(ConfirmationStrategy = exports.ConfirmationStrategy || (exports.ConfirmationStrategy = {}));
|
|
10
|
+
class TxSendError extends Error {
|
|
11
|
+
constructor(message, code) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.message = message;
|
|
14
|
+
this.code = code;
|
|
15
|
+
if (Error.captureStackTrace) {
|
|
16
|
+
Error.captureStackTrace(this, TxSendError);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.TxSendError = TxSendError;
|
package/package.json
CHANGED
package/src/tx/baseTxSender.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
ConfirmationStrategy,
|
|
3
3
|
ExtraConfirmationOptions,
|
|
4
4
|
TxSender,
|
|
5
|
+
TxSendError,
|
|
5
6
|
TxSigAndSlot,
|
|
6
7
|
} from './types';
|
|
7
8
|
import {
|
|
@@ -25,6 +26,7 @@ import bs58 from 'bs58';
|
|
|
25
26
|
import { IWallet } from '../types';
|
|
26
27
|
|
|
27
28
|
const DEFAULT_TIMEOUT = 35000;
|
|
29
|
+
const NOT_CONFIRMED_ERROR_CODE = -1001;
|
|
28
30
|
|
|
29
31
|
export abstract class BaseTxSender implements TxSender {
|
|
30
32
|
connection: Connection;
|
|
@@ -282,10 +284,11 @@ export abstract class BaseTxSender implements TxSender {
|
|
|
282
284
|
}
|
|
283
285
|
this.timeoutCount += 1;
|
|
284
286
|
const duration = (Date.now() - start) / 1000;
|
|
285
|
-
throw new
|
|
287
|
+
throw new TxSendError(
|
|
286
288
|
`Transaction was not confirmed in ${duration.toFixed(
|
|
287
289
|
2
|
|
288
|
-
)} seconds. It is unknown if it succeeded or failed. Check signature ${signature} using the Solana Explorer or CLI tools
|
|
290
|
+
)} seconds. It is unknown if it succeeded or failed. Check signature ${signature} using the Solana Explorer or CLI tools.`,
|
|
291
|
+
NOT_CONFIRMED_ERROR_CODE
|
|
289
292
|
);
|
|
290
293
|
}
|
|
291
294
|
|
|
@@ -317,10 +320,11 @@ export abstract class BaseTxSender implements TxSender {
|
|
|
317
320
|
// Transaction not confirmed within 30 seconds
|
|
318
321
|
this.timeoutCount += 1;
|
|
319
322
|
const duration = (Date.now() - start) / 1000;
|
|
320
|
-
throw new
|
|
323
|
+
throw new TxSendError(
|
|
321
324
|
`Transaction was not confirmed in ${duration.toFixed(
|
|
322
325
|
2
|
|
323
|
-
)} seconds. It is unknown if it succeeded or failed. Check signature ${signature} using the Solana Explorer or CLI tools
|
|
326
|
+
)} seconds. It is unknown if it succeeded or failed. Check signature ${signature} using the Solana Explorer or CLI tools.`,
|
|
327
|
+
NOT_CONFIRMED_ERROR_CODE
|
|
324
328
|
);
|
|
325
329
|
}
|
|
326
330
|
|
package/src/tx/types.ts
CHANGED
|
@@ -60,3 +60,15 @@ export interface TxSender {
|
|
|
60
60
|
|
|
61
61
|
getTimeoutCount(): number;
|
|
62
62
|
}
|
|
63
|
+
|
|
64
|
+
export class TxSendError extends Error {
|
|
65
|
+
constructor(
|
|
66
|
+
public message: string,
|
|
67
|
+
public code: number
|
|
68
|
+
) {
|
|
69
|
+
super(message);
|
|
70
|
+
if (Error.captureStackTrace) {
|
|
71
|
+
Error.captureStackTrace(this, TxSendError);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|