@drift-labs/sdk 2.95.0-beta.18 → 2.95.0-beta.19

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.18
1
+ 2.95.0-beta.19
@@ -82,7 +82,9 @@ class WebSocketDriftClientAccountSubscriber {
82
82
  if (!this.initialPerpMarketAccountData) {
83
83
  const perpMarketPublicKeys = this.perpMarketIndexes.map((marketIndex) => (0, pda_1.getPerpMarketPublicKeySync)(this.program.programId, marketIndex));
84
84
  const perpMarketAccountInfos = await connection.getMultipleAccountsInfo(perpMarketPublicKeys);
85
- this.initialPerpMarketAccountData = new Map(perpMarketAccountInfos.map((accountInfo) => {
85
+ this.initialPerpMarketAccountData = new Map(perpMarketAccountInfos
86
+ .filter((accountInfo) => !!accountInfo.data)
87
+ .map((accountInfo) => {
86
88
  const perpMarket = this.program.coder.accounts.decode('PerpMarket', accountInfo.data);
87
89
  return [perpMarket.marketIndex, perpMarket];
88
90
  }));
@@ -90,13 +92,17 @@ class WebSocketDriftClientAccountSubscriber {
90
92
  if (!this.initialSpotMarketAccountData) {
91
93
  const spotMarketPublicKeys = this.spotMarketIndexes.map((marketIndex) => (0, pda_1.getSpotMarketPublicKeySync)(this.program.programId, marketIndex));
92
94
  const spotMarketAccountInfos = await connection.getMultipleAccountsInfo(spotMarketPublicKeys);
93
- this.initialSpotMarketAccountData = new Map(spotMarketAccountInfos.map((accountInfo) => {
95
+ this.initialSpotMarketAccountData = new Map(spotMarketAccountInfos
96
+ .filter((accountInfo) => !!accountInfo.data)
97
+ .map((accountInfo) => {
94
98
  const spotMarket = this.program.coder.accounts.decode('SpotMarket', accountInfo.data);
95
99
  return [spotMarket.marketIndex, spotMarket];
96
100
  }));
97
101
  }
98
102
  const oracleAccountInfos = await connection.getMultipleAccountsInfo(this.oracleInfos.map((oracleInfo) => oracleInfo.publicKey));
99
- this.initialOraclePriceData = new Map(this.oracleInfos.map((oracleInfo, i) => {
103
+ this.initialOraclePriceData = new Map(this.oracleInfos
104
+ .filter((_, i) => !!oracleAccountInfos[i])
105
+ .map((oracleInfo, i) => {
100
106
  const oracleClient = this.oracleClientCache.get(oracleInfo.source, connection, this.program);
101
107
  const oraclePriceData = oracleClient.getOraclePriceDataFromBuffer(oracleAccountInfos[i].data);
102
108
  return [oracleInfo.publicKey.toString(), oraclePriceData];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.95.0-beta.18",
3
+ "version": "2.95.0-beta.19",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -174,13 +174,15 @@ export class WebSocketDriftClientAccountSubscriber
174
174
  perpMarketPublicKeys
175
175
  );
176
176
  this.initialPerpMarketAccountData = new Map(
177
- perpMarketAccountInfos.map((accountInfo) => {
178
- const perpMarket = this.program.coder.accounts.decode(
179
- 'PerpMarket',
180
- accountInfo.data
181
- );
182
- return [perpMarket.marketIndex, perpMarket];
183
- })
177
+ perpMarketAccountInfos
178
+ .filter((accountInfo) => !!accountInfo.data)
179
+ .map((accountInfo) => {
180
+ const perpMarket = this.program.coder.accounts.decode(
181
+ 'PerpMarket',
182
+ accountInfo.data
183
+ );
184
+ return [perpMarket.marketIndex, perpMarket];
185
+ })
184
186
  );
185
187
  }
186
188
 
@@ -192,13 +194,15 @@ export class WebSocketDriftClientAccountSubscriber
192
194
  spotMarketPublicKeys
193
195
  );
194
196
  this.initialSpotMarketAccountData = new Map(
195
- spotMarketAccountInfos.map((accountInfo) => {
196
- const spotMarket = this.program.coder.accounts.decode(
197
- 'SpotMarket',
198
- accountInfo.data
199
- );
200
- return [spotMarket.marketIndex, spotMarket];
201
- })
197
+ spotMarketAccountInfos
198
+ .filter((accountInfo) => !!accountInfo.data)
199
+ .map((accountInfo) => {
200
+ const spotMarket = this.program.coder.accounts.decode(
201
+ 'SpotMarket',
202
+ accountInfo.data
203
+ );
204
+ return [spotMarket.marketIndex, spotMarket];
205
+ })
202
206
  );
203
207
  }
204
208
 
@@ -206,17 +210,19 @@ export class WebSocketDriftClientAccountSubscriber
206
210
  this.oracleInfos.map((oracleInfo) => oracleInfo.publicKey)
207
211
  );
208
212
  this.initialOraclePriceData = new Map(
209
- this.oracleInfos.map((oracleInfo, i) => {
210
- const oracleClient = this.oracleClientCache.get(
211
- oracleInfo.source,
212
- connection,
213
- this.program
214
- );
215
- const oraclePriceData = oracleClient.getOraclePriceDataFromBuffer(
216
- oracleAccountInfos[i].data
217
- );
218
- return [oracleInfo.publicKey.toString(), oraclePriceData];
219
- })
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
+ })
220
226
  );
221
227
  }
222
228