@drift-labs/sdk 2.95.0-beta.20 → 2.95.0-beta.21

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.95.0-beta.20
1
+ 2.95.0-beta.21
@@ -100,13 +100,15 @@ class WebSocketDriftClientAccountSubscriber {
100
100
  }));
101
101
  }
102
102
  const oracleAccountInfos = await connection.getMultipleAccountsInfo(this.oracleInfos.map((oracleInfo) => oracleInfo.publicKey));
103
- this.initialOraclePriceData = new Map(this.oracleInfos
104
- .filter((_, i) => !!oracleAccountInfos[i])
105
- .map((oracleInfo, i) => {
103
+ this.initialOraclePriceData = new Map(this.oracleInfos.reduce((result, oracleInfo, i) => {
104
+ if (!oracleAccountInfos[i]) {
105
+ return result;
106
+ }
106
107
  const oracleClient = this.oracleClientCache.get(oracleInfo.source, connection, this.program);
107
108
  const oraclePriceData = oracleClient.getOraclePriceDataFromBuffer(oracleAccountInfos[i].data);
108
- return [oracleInfo.publicKey.toString(), oraclePriceData];
109
- }));
109
+ result.push([oracleInfo.publicKey.toString(), oraclePriceData]);
110
+ return result;
111
+ }, []));
110
112
  }
111
113
  removeInitialData() {
112
114
  this.initialPerpMarketAccountData = new Map();
@@ -223,7 +225,7 @@ class WebSocketDriftClientAccountSubscriber {
223
225
  const perpMarkets = this.getMarketAccountsAndSlots();
224
226
  const addOraclePromises = [];
225
227
  for (const perpMarket of perpMarkets) {
226
- if (!perpMarket) {
228
+ if (!perpMarket || !perpMarket.data) {
227
229
  continue;
228
230
  }
229
231
  const perpMarketAccount = perpMarket.data;
@@ -244,7 +246,7 @@ class WebSocketDriftClientAccountSubscriber {
244
246
  const spotMarkets = this.getSpotMarketAccountsAndSlots();
245
247
  const addOraclePromises = [];
246
248
  for (const spotMarket of spotMarkets) {
247
- if (!spotMarket) {
249
+ if (!spotMarket || !spotMarket.data) {
248
250
  continue;
249
251
  }
250
252
  const spotMarketAccount = spotMarket.data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.95.0-beta.20",
3
+ "version": "2.95.0-beta.21",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -210,19 +210,24 @@ export class WebSocketDriftClientAccountSubscriber
210
210
  this.oracleInfos.map((oracleInfo) => oracleInfo.publicKey)
211
211
  );
212
212
  this.initialOraclePriceData = new Map(
213
- this.oracleInfos
214
- .filter((_, i) => !!oracleAccountInfos[i])
215
- .map((oracleInfo, i) => {
216
- const oracleClient = this.oracleClientCache.get(
217
- oracleInfo.source,
218
- connection,
219
- this.program
220
- );
221
- const oraclePriceData = oracleClient.getOraclePriceDataFromBuffer(
222
- oracleAccountInfos[i].data
223
- );
224
- return [oracleInfo.publicKey.toString(), oraclePriceData];
225
- })
213
+ this.oracleInfos.reduce((result, oracleInfo, i) => {
214
+ if (!oracleAccountInfos[i]) {
215
+ return result;
216
+ }
217
+
218
+ const oracleClient = this.oracleClientCache.get(
219
+ oracleInfo.source,
220
+ connection,
221
+ this.program
222
+ );
223
+
224
+ const oraclePriceData = oracleClient.getOraclePriceDataFromBuffer(
225
+ oracleAccountInfos[i].data
226
+ );
227
+
228
+ result.push([oracleInfo.publicKey.toString(), oraclePriceData]);
229
+ return result;
230
+ }, [])
226
231
  );
227
232
  }
228
233
 
@@ -431,7 +436,7 @@ export class WebSocketDriftClientAccountSubscriber
431
436
  const perpMarkets = this.getMarketAccountsAndSlots();
432
437
  const addOraclePromises = [];
433
438
  for (const perpMarket of perpMarkets) {
434
- if (!perpMarket) {
439
+ if (!perpMarket || !perpMarket.data) {
435
440
  continue;
436
441
  }
437
442
  const perpMarketAccount = perpMarket.data;
@@ -455,7 +460,7 @@ export class WebSocketDriftClientAccountSubscriber
455
460
  const spotMarkets = this.getSpotMarketAccountsAndSlots();
456
461
  const addOraclePromises = [];
457
462
  for (const spotMarket of spotMarkets) {
458
- if (!spotMarket) {
463
+ if (!spotMarket || !spotMarket.data) {
459
464
  continue;
460
465
  }
461
466
  const spotMarketAccount = spotMarket.data;