@@ -193,6 +193,7 @@ import { getOracleId } from './oracles/oracleId';
193193import { SignedMsgOrderParams } from './types' ;
194194import { sha256 } from '@noble/hashes/sha256' ;
195195import { getOracleConfidenceFromMMOracleData } from './oracles/utils' ;
196+ import { WebSocketDriftClientAccountSubscriberV2 } from './accounts/webSocketDriftClientAccountSubscriberV2' ;
196197
197198type RemainingAccountParams = {
198199 userAccounts : UserAccount [ ] ;
@@ -370,6 +371,7 @@ export class DriftClient {
370371 resubTimeoutMs : config . accountSubscription ?. resubTimeoutMs ,
371372 logResubMessages : config . accountSubscription ?. logResubMessages ,
372373 commitment : config . accountSubscription ?. commitment ,
374+ programUserAccountSubscriber : config . accountSubscription ?. programUserAccountSubscriber ,
373375 } ;
374376 this . userStatsAccountSubscriptionConfig = {
375377 type : 'websocket' ,
@@ -435,7 +437,7 @@ export class DriftClient {
435437 }
436438 ) ;
437439 } else {
438- this . accountSubscriber = new WebSocketDriftClientAccountSubscriber (
440+ this . accountSubscriber = new WebSocketDriftClientAccountSubscriberV2 (
439441 this . program ,
440442 config . perpMarketIndexes ?? [ ] ,
441443 config . spotMarketIndexes ?? [ ] ,
@@ -607,7 +609,7 @@ export class DriftClient {
607609 public getSpotMarketAccount (
608610 marketIndex : number
609611 ) : SpotMarketAccount | undefined {
610- return this . accountSubscriber . getSpotMarketAccountAndSlot ( marketIndex ) . data ;
612+ return this . accountSubscriber . getSpotMarketAccountAndSlot ( marketIndex ) ? .data ;
611613 }
612614
613615 /**
@@ -618,7 +620,7 @@ export class DriftClient {
618620 marketIndex : number
619621 ) : Promise < SpotMarketAccount | undefined > {
620622 await this . accountSubscriber . fetch ( ) ;
621- return this . accountSubscriber . getSpotMarketAccountAndSlot ( marketIndex ) . data ;
623+ return this . accountSubscriber . getSpotMarketAccountAndSlot ( marketIndex ) ? .data ;
622624 }
623625
624626 public getSpotMarketAccounts ( ) : SpotMarketAccount [ ] {
@@ -927,6 +929,8 @@ export class DriftClient {
927929 authority ?: PublicKey ,
928930 userAccount ?: UserAccount
929931 ) : Promise < boolean > {
932+
933+
930934 authority = authority ?? this . authority ;
931935 const userKey = this . getUserMapKey ( subAccountId , authority ) ;
932936
@@ -954,6 +958,7 @@ export class DriftClient {
954958 * Adds and subscribes to users based on params set by the constructor or by updateWallet.
955959 */
956960 public async addAndSubscribeToUsers ( authority ?: PublicKey ) : Promise < boolean > {
961+ console . log ( 'adding and subscribing to users' , this . users . size ) ;
957962 // save the rpc calls if driftclient is initialized without a real wallet
958963 if ( this . skipLoadUsers ) return true ;
959964
0 commit comments