@@ -194,6 +194,7 @@ import { getOracleId } from './oracles/oracleId';
194194import { SignedMsgOrderParams } from './types' ;
195195import { sha256 } from '@noble/hashes/sha256' ;
196196import { getOracleConfidenceFromMMOracleData } from './oracles/utils' ;
197+ import { WebSocketDriftClientAccountSubscriberV2 } from './accounts/webSocketDriftClientAccountSubscriberV2' ;
197198
198199type RemainingAccountParams = {
199200 userAccounts : UserAccount [ ] ;
@@ -371,6 +372,7 @@ export class DriftClient {
371372 resubTimeoutMs : config . accountSubscription ?. resubTimeoutMs ,
372373 logResubMessages : config . accountSubscription ?. logResubMessages ,
373374 commitment : config . accountSubscription ?. commitment ,
375+ programUserAccountSubscriber : config . accountSubscription ?. programUserAccountSubscriber ,
374376 } ;
375377 this . userStatsAccountSubscriptionConfig = {
376378 type : 'websocket' ,
@@ -436,7 +438,7 @@ export class DriftClient {
436438 }
437439 ) ;
438440 } else {
439- this . accountSubscriber = new WebSocketDriftClientAccountSubscriber (
441+ this . accountSubscriber = new WebSocketDriftClientAccountSubscriberV2 (
440442 this . program ,
441443 config . perpMarketIndexes ?? [ ] ,
442444 config . spotMarketIndexes ?? [ ] ,
@@ -610,7 +612,7 @@ export class DriftClient {
610612 public getSpotMarketAccount (
611613 marketIndex : number
612614 ) : SpotMarketAccount | undefined {
613- return this . accountSubscriber . getSpotMarketAccountAndSlot ( marketIndex ) . data ;
615+ return this . accountSubscriber . getSpotMarketAccountAndSlot ( marketIndex ) ? .data ;
614616 }
615617
616618 /**
@@ -621,7 +623,7 @@ export class DriftClient {
621623 marketIndex : number
622624 ) : Promise < SpotMarketAccount | undefined > {
623625 await this . accountSubscriber . fetch ( ) ;
624- return this . accountSubscriber . getSpotMarketAccountAndSlot ( marketIndex ) . data ;
626+ return this . accountSubscriber . getSpotMarketAccountAndSlot ( marketIndex ) ? .data ;
625627 }
626628
627629 public getSpotMarketAccounts ( ) : SpotMarketAccount [ ] {
@@ -930,6 +932,8 @@ export class DriftClient {
930932 authority ?: PublicKey ,
931933 userAccount ?: UserAccount
932934 ) : Promise < boolean > {
935+
936+
933937 authority = authority ?? this . authority ;
934938 const userKey = this . getUserMapKey ( subAccountId , authority ) ;
935939
@@ -957,6 +961,7 @@ export class DriftClient {
957961 * Adds and subscribes to users based on params set by the constructor or by updateWallet.
958962 */
959963 public async addAndSubscribeToUsers ( authority ?: PublicKey ) : Promise < boolean > {
964+ console . log ( 'adding and subscribing to users' , this . users . size ) ;
960965 // save the rpc calls if driftclient is initialized without a real wallet
961966 if ( this . skipLoadUsers ) return true ;
962967
0 commit comments