@drift-labs/sdk 2.82.0-beta.7 → 2.82.0-beta.9

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 CHANGED
@@ -1 +1 @@
1
- 2.82.0-beta.7
1
+ 2.82.0-beta.9
@@ -542,9 +542,9 @@ exports.MainnetPerpMarkets = [
542
542
  symbol: 'KMNO-PERP',
543
543
  baseAssetSymbol: 'KMNO',
544
544
  marketIndex: 28,
545
- oracle: new web3_js_1.PublicKey('sDAQaZQJQ4RXAxH3x526mbEXyQZT15ktkL84d7hmk7M'),
545
+ oracle: new web3_js_1.PublicKey('6ynsvjkE2UoiRScbDx7ZxbBsyn7wyvg5P1vENvhtkG1C'),
546
546
  launchTs: 1712240681000,
547
- oracleSource: __1.OracleSource.Prelaunch,
547
+ oracleSource: __1.OracleSource.SWITCHBOARD,
548
548
  },
549
549
  {
550
550
  fullName: 'Tensor',
@@ -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 Error(`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.`);
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 Error(`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.`);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.82.0-beta.7",
3
+ "version": "2.82.0-beta.9",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -553,9 +553,9 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
553
553
  symbol: 'KMNO-PERP',
554
554
  baseAssetSymbol: 'KMNO',
555
555
  marketIndex: 28,
556
- oracle: new PublicKey('sDAQaZQJQ4RXAxH3x526mbEXyQZT15ktkL84d7hmk7M'),
556
+ oracle: new PublicKey('6ynsvjkE2UoiRScbDx7ZxbBsyn7wyvg5P1vENvhtkG1C'),
557
557
  launchTs: 1712240681000,
558
- oracleSource: OracleSource.Prelaunch,
558
+ oracleSource: OracleSource.SWITCHBOARD,
559
559
  },
560
560
  {
561
561
  fullName: 'Tensor',
@@ -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 Error(
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 Error(
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
+ }