@drift-labs/sdk-browser 2.117.0-beta.6 → 2.117.0-beta.8

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.117.0-beta.6
1
+ 2.117.0-beta.8
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { Connection, TransactionSignature } from '@solana/web3.js';
3
3
  import { Program } from '@coral-xyz/anchor';
4
- import { EventSubscriptionOptions, EventType, WrappedEvents, EventMap, EventSubscriberEvents } from './types';
4
+ import { EventSubscriptionOptions, EventType, WrappedEvents, EventMap, EventSubscriberEvents, LogProviderType } from './types';
5
5
  import { EventList } from './eventList';
6
6
  import { EventEmitter } from 'events';
7
7
  import StrictEventEmitter from 'strict-event-emitter-types';
@@ -15,12 +15,13 @@ export declare class EventSubscriber {
15
15
  private awaitTxPromises;
16
16
  private awaitTxResolver;
17
17
  private logProvider;
18
- private currentProviderType;
18
+ private _currentProviderType;
19
19
  eventEmitter: StrictEventEmitter<EventEmitter, EventSubscriberEvents>;
20
20
  private lastSeenSlot;
21
21
  private lastSeenBlockTime;
22
22
  lastSeenTxSig: string;
23
23
  constructor(connection: Connection, program: Program, options?: EventSubscriptionOptions);
24
+ get currentProviderType(): LogProviderType;
24
25
  private initializeLogProvider;
25
26
  private populateInitialEventListMap;
26
27
  /**
@@ -24,17 +24,20 @@ class EventSubscriber {
24
24
  this.txEventCache = new txEventCache_1.TxEventCache(this.options.maxTx);
25
25
  this.eventListMap = new Map();
26
26
  this.eventEmitter = new events_1.EventEmitter();
27
- this.currentProviderType = this.options.logProviderConfig.type;
27
+ this._currentProviderType = this.options.logProviderConfig.type;
28
28
  this.initializeLogProvider();
29
29
  }
30
+ get currentProviderType() {
31
+ return this._currentProviderType;
32
+ }
30
33
  initializeLogProvider(subscribe = false) {
31
34
  const logProviderConfig = this.options.logProviderConfig;
32
- if (this.currentProviderType === 'websocket') {
35
+ if (this._currentProviderType === 'websocket') {
33
36
  this.logProvider = new webSocketLogProvider_1.WebSocketLogProvider(
34
37
  // @ts-ignore
35
38
  this.connection, this.address, this.options.commitment, this.options.logProviderConfig.resubTimeoutMs);
36
39
  }
37
- else if (this.currentProviderType === 'polling') {
40
+ else if (this._currentProviderType === 'polling') {
38
41
  const frequency = 'frequency' in logProviderConfig
39
42
  ? logProviderConfig.frequency
40
43
  : logProviderConfig.fallbackFrequency;
@@ -45,15 +48,15 @@ class EventSubscriber {
45
48
  // @ts-ignore
46
49
  this.connection, this.address, this.options.commitment, frequency, batchSize);
47
50
  }
48
- else if (this.currentProviderType === 'events-server') {
51
+ else if (this._currentProviderType === 'events-server') {
49
52
  this.logProvider = new eventsServerLogProvider_1.EventsServerLogProvider(logProviderConfig.url, this.options.eventTypes, this.options.address ? this.options.address.toString() : undefined);
50
53
  }
51
54
  else {
52
- throw new Error(`Invalid log provider type: ${this.currentProviderType}`);
55
+ throw new Error(`Invalid log provider type: ${this._currentProviderType}`);
53
56
  }
54
57
  if (subscribe) {
55
58
  this.logProvider.subscribe((txSig, slot, logs, mostRecentBlockTime, txSigIndex) => {
56
- this.handleTxLogs(txSig, slot, logs, mostRecentBlockTime, this.currentProviderType === 'events-server', txSigIndex);
59
+ this.handleTxLogs(txSig, slot, logs, mostRecentBlockTime, this._currentProviderType === 'events-server', txSigIndex);
57
60
  }, true);
58
61
  }
59
62
  }
@@ -70,18 +73,18 @@ class EventSubscriber {
70
73
  if (reconnectAttempts < maxReconnectAttempts) {
71
74
  return;
72
75
  }
73
- let nextProviderType = this.currentProviderType;
74
- if (this.currentProviderType === 'events-server') {
76
+ let nextProviderType = this._currentProviderType;
77
+ if (this._currentProviderType === 'events-server') {
75
78
  nextProviderType = 'websocket';
76
79
  }
77
- else if (this.currentProviderType === 'websocket') {
80
+ else if (this._currentProviderType === 'websocket') {
78
81
  nextProviderType = 'polling';
79
82
  }
80
- else if (this.currentProviderType === 'polling') {
83
+ else if (this._currentProviderType === 'polling') {
81
84
  nextProviderType = 'polling';
82
85
  }
83
- console.log(`EventSubscriber: Failing over providerType ${this.currentProviderType} to ${nextProviderType}`);
84
- this.currentProviderType = nextProviderType;
86
+ console.log(`EventSubscriber: Failing over providerType ${this._currentProviderType} to ${nextProviderType}`);
87
+ this._currentProviderType = nextProviderType;
85
88
  }
86
89
  async subscribe() {
87
90
  try {
@@ -106,7 +109,7 @@ class EventSubscriber {
106
109
  }
107
110
  }
108
111
  this.logProvider.subscribe((txSig, slot, logs, mostRecentBlockTime, txSigIndex) => {
109
- this.handleTxLogs(txSig, slot, logs, mostRecentBlockTime, this.currentProviderType === 'events-server', txSigIndex);
112
+ this.handleTxLogs(txSig, slot, logs, mostRecentBlockTime, this._currentProviderType === 'events-server', txSigIndex);
110
113
  }, true);
111
114
  return true;
112
115
  }
@@ -12913,6 +12913,11 @@
12913
12913
  "name": "oraclePrice",
12914
12914
  "type": "i64",
12915
12915
  "index": false
12916
+ },
12917
+ {
12918
+ "name": "bitFlags",
12919
+ "type": "u8",
12920
+ "index": false
12916
12921
  }
12917
12922
  ]
12918
12923
  },
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { Connection, TransactionSignature } from '@solana/web3.js';
3
3
  import { Program } from '@coral-xyz/anchor';
4
- import { EventSubscriptionOptions, EventType, WrappedEvents, EventMap, EventSubscriberEvents } from './types';
4
+ import { EventSubscriptionOptions, EventType, WrappedEvents, EventMap, EventSubscriberEvents, LogProviderType } from './types';
5
5
  import { EventList } from './eventList';
6
6
  import { EventEmitter } from 'events';
7
7
  import StrictEventEmitter from 'strict-event-emitter-types';
@@ -15,12 +15,13 @@ export declare class EventSubscriber {
15
15
  private awaitTxPromises;
16
16
  private awaitTxResolver;
17
17
  private logProvider;
18
- private currentProviderType;
18
+ private _currentProviderType;
19
19
  eventEmitter: StrictEventEmitter<EventEmitter, EventSubscriberEvents>;
20
20
  private lastSeenSlot;
21
21
  private lastSeenBlockTime;
22
22
  lastSeenTxSig: string;
23
23
  constructor(connection: Connection, program: Program, options?: EventSubscriptionOptions);
24
+ get currentProviderType(): LogProviderType;
24
25
  private initializeLogProvider;
25
26
  private populateInitialEventListMap;
26
27
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"eventSubscriber.d.ts","sourceRoot":"","sources":["../../../src/events/eventSubscriber.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAa,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAEN,wBAAwB,EACxB,SAAS,EACT,aAAa,EACb,QAAQ,EAER,qBAAqB,EAMrB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAK5D,qBAAa,eAAe;IAc1B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;IAfhB,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,eAAe,CAAoC;IAC3D,OAAO,CAAC,eAAe,CAAiC;IACxD,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,mBAAmB,CAAkB;IACtC,YAAY,EAAE,kBAAkB,CAAC,YAAY,EAAE,qBAAqB,CAAC,CAAC;IAC7E,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,iBAAiB,CAAqB;IACvC,aAAa,EAAE,MAAM,CAAC;gBAGpB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,wBAA0D;IAY5E,OAAO,CAAC,qBAAqB;IA0D7B,OAAO,CAAC,2BAA2B;IAcnC;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAuBrB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Ae,CAAoC;IAC3D,OAAO,CAAC,eAAe,CAAiC;IACxD,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,oBAAoB,CAAkB;IACvC,YAAY,EAAE,kBAAkB,CAAC,YAAY,EAAE,qBAAqB,CAAC,CAAC;IAC7E,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,iBAAiB,CAAqB;IACvC,aAAa,EAAE,MAAM,CAAC;gBAGpB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,wBAA0D;IAY5E,IAAI,mBAAmB,oBAEtB;IAED,OAAO,CAAC,qBAAqB;IA4D7B,OAAO,CAAC,2BAA2B;IAcnC;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAuBrB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAyD1C,OAAO,CAAC,YAAY;IAiDP,eAAe,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA+BlD,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAS5C,OAAO,CAAC,mBAAmB;IA0BpB,OAAO,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBnD,YAAY,CAAC,IAAI,SAAS,MAAM,QAAQ,EAC9C,SAAS,EAAE,IAAI,GACb,SAAS,CAAC,IAAI,CAAC;IAIlB;;;;;OAKG;IACI,cAAc,CAAC,IAAI,SAAS,SAAS,EAC3C,SAAS,EAAE,IAAI,GACb,QAAQ,CAAC,IAAI,CAAC,EAAE;IAIZ,aAAa,CAAC,KAAK,EAAE,oBAAoB,GAAG,aAAa,GAAG,SAAS;CAG5E"}
@@ -24,17 +24,20 @@ class EventSubscriber {
24
24
  this.txEventCache = new txEventCache_1.TxEventCache(this.options.maxTx);
25
25
  this.eventListMap = new Map();
26
26
  this.eventEmitter = new events_1.EventEmitter();
27
- this.currentProviderType = this.options.logProviderConfig.type;
27
+ this._currentProviderType = this.options.logProviderConfig.type;
28
28
  this.initializeLogProvider();
29
29
  }
30
+ get currentProviderType() {
31
+ return this._currentProviderType;
32
+ }
30
33
  initializeLogProvider(subscribe = false) {
31
34
  const logProviderConfig = this.options.logProviderConfig;
32
- if (this.currentProviderType === 'websocket') {
35
+ if (this._currentProviderType === 'websocket') {
33
36
  this.logProvider = new webSocketLogProvider_1.WebSocketLogProvider(
34
37
  // @ts-ignore
35
38
  this.connection, this.address, this.options.commitment, this.options.logProviderConfig.resubTimeoutMs);
36
39
  }
37
- else if (this.currentProviderType === 'polling') {
40
+ else if (this._currentProviderType === 'polling') {
38
41
  const frequency = 'frequency' in logProviderConfig
39
42
  ? logProviderConfig.frequency
40
43
  : logProviderConfig.fallbackFrequency;
@@ -45,15 +48,15 @@ class EventSubscriber {
45
48
  // @ts-ignore
46
49
  this.connection, this.address, this.options.commitment, frequency, batchSize);
47
50
  }
48
- else if (this.currentProviderType === 'events-server') {
51
+ else if (this._currentProviderType === 'events-server') {
49
52
  this.logProvider = new eventsServerLogProvider_1.EventsServerLogProvider(logProviderConfig.url, this.options.eventTypes, this.options.address ? this.options.address.toString() : undefined);
50
53
  }
51
54
  else {
52
- throw new Error(`Invalid log provider type: ${this.currentProviderType}`);
55
+ throw new Error(`Invalid log provider type: ${this._currentProviderType}`);
53
56
  }
54
57
  if (subscribe) {
55
58
  this.logProvider.subscribe((txSig, slot, logs, mostRecentBlockTime, txSigIndex) => {
56
- this.handleTxLogs(txSig, slot, logs, mostRecentBlockTime, this.currentProviderType === 'events-server', txSigIndex);
59
+ this.handleTxLogs(txSig, slot, logs, mostRecentBlockTime, this._currentProviderType === 'events-server', txSigIndex);
57
60
  }, true);
58
61
  }
59
62
  }
@@ -70,18 +73,18 @@ class EventSubscriber {
70
73
  if (reconnectAttempts < maxReconnectAttempts) {
71
74
  return;
72
75
  }
73
- let nextProviderType = this.currentProviderType;
74
- if (this.currentProviderType === 'events-server') {
76
+ let nextProviderType = this._currentProviderType;
77
+ if (this._currentProviderType === 'events-server') {
75
78
  nextProviderType = 'websocket';
76
79
  }
77
- else if (this.currentProviderType === 'websocket') {
80
+ else if (this._currentProviderType === 'websocket') {
78
81
  nextProviderType = 'polling';
79
82
  }
80
- else if (this.currentProviderType === 'polling') {
83
+ else if (this._currentProviderType === 'polling') {
81
84
  nextProviderType = 'polling';
82
85
  }
83
- console.log(`EventSubscriber: Failing over providerType ${this.currentProviderType} to ${nextProviderType}`);
84
- this.currentProviderType = nextProviderType;
86
+ console.log(`EventSubscriber: Failing over providerType ${this._currentProviderType} to ${nextProviderType}`);
87
+ this._currentProviderType = nextProviderType;
85
88
  }
86
89
  async subscribe() {
87
90
  try {
@@ -106,7 +109,7 @@ class EventSubscriber {
106
109
  }
107
110
  }
108
111
  this.logProvider.subscribe((txSig, slot, logs, mostRecentBlockTime, txSigIndex) => {
109
- this.handleTxLogs(txSig, slot, logs, mostRecentBlockTime, this.currentProviderType === 'events-server', txSigIndex);
112
+ this.handleTxLogs(txSig, slot, logs, mostRecentBlockTime, this._currentProviderType === 'events-server', txSigIndex);
110
113
  }, true);
111
114
  return true;
112
115
  }
@@ -12913,6 +12913,11 @@
12913
12913
  "name": "oraclePrice",
12914
12914
  "type": "i64",
12915
12915
  "index": false
12916
+ },
12917
+ {
12918
+ "name": "bitFlags",
12919
+ "type": "u8",
12920
+ "index": false
12916
12921
  }
12917
12922
  ]
12918
12923
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk-browser",
3
- "version": "2.117.0-beta.6",
3
+ "version": "2.117.0-beta.8",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "browser": "./lib/browser/index.js",
@@ -32,7 +32,7 @@ export class EventSubscriber {
32
32
  private awaitTxPromises = new Map<string, Promise<void>>();
33
33
  private awaitTxResolver = new Map<string, () => void>();
34
34
  private logProvider: LogProvider;
35
- private currentProviderType: LogProviderType;
35
+ private _currentProviderType: LogProviderType;
36
36
  public eventEmitter: StrictEventEmitter<EventEmitter, EventSubscriberEvents>;
37
37
  private lastSeenSlot: number;
38
38
  private lastSeenBlockTime: number | undefined;
@@ -49,14 +49,18 @@ export class EventSubscriber {
49
49
  this.eventListMap = new Map<EventType, EventList<EventType>>();
50
50
  this.eventEmitter = new EventEmitter();
51
51
 
52
- this.currentProviderType = this.options.logProviderConfig.type;
52
+ this._currentProviderType = this.options.logProviderConfig.type;
53
53
  this.initializeLogProvider();
54
54
  }
55
55
 
56
+ get currentProviderType() {
57
+ return this._currentProviderType;
58
+ }
59
+
56
60
  private initializeLogProvider(subscribe = false) {
57
61
  const logProviderConfig = this.options.logProviderConfig;
58
62
 
59
- if (this.currentProviderType === 'websocket') {
63
+ if (this._currentProviderType === 'websocket') {
60
64
  this.logProvider = new WebSocketLogProvider(
61
65
  // @ts-ignore
62
66
  this.connection,
@@ -66,7 +70,7 @@ export class EventSubscriber {
66
70
  this.options.logProviderConfig as WebSocketLogProviderConfig
67
71
  ).resubTimeoutMs
68
72
  );
69
- } else if (this.currentProviderType === 'polling') {
73
+ } else if (this._currentProviderType === 'polling') {
70
74
  const frequency =
71
75
  'frequency' in logProviderConfig
72
76
  ? (logProviderConfig as PollingLogProviderConfig).frequency
@@ -84,14 +88,16 @@ export class EventSubscriber {
84
88
  frequency,
85
89
  batchSize
86
90
  );
87
- } else if (this.currentProviderType === 'events-server') {
91
+ } else if (this._currentProviderType === 'events-server') {
88
92
  this.logProvider = new EventsServerLogProvider(
89
93
  (logProviderConfig as EventsServerLogProviderConfig).url,
90
94
  this.options.eventTypes,
91
95
  this.options.address ? this.options.address.toString() : undefined
92
96
  );
93
97
  } else {
94
- throw new Error(`Invalid log provider type: ${this.currentProviderType}`);
98
+ throw new Error(
99
+ `Invalid log provider type: ${this._currentProviderType}`
100
+ );
95
101
  }
96
102
 
97
103
  if (subscribe) {
@@ -102,7 +108,7 @@ export class EventSubscriber {
102
108
  slot,
103
109
  logs,
104
110
  mostRecentBlockTime,
105
- this.currentProviderType === 'events-server',
111
+ this._currentProviderType === 'events-server',
106
112
  txSigIndex
107
113
  );
108
114
  },
@@ -137,19 +143,19 @@ export class EventSubscriber {
137
143
  return;
138
144
  }
139
145
 
140
- let nextProviderType = this.currentProviderType;
141
- if (this.currentProviderType === 'events-server') {
146
+ let nextProviderType = this._currentProviderType;
147
+ if (this._currentProviderType === 'events-server') {
142
148
  nextProviderType = 'websocket';
143
- } else if (this.currentProviderType === 'websocket') {
149
+ } else if (this._currentProviderType === 'websocket') {
144
150
  nextProviderType = 'polling';
145
- } else if (this.currentProviderType === 'polling') {
151
+ } else if (this._currentProviderType === 'polling') {
146
152
  nextProviderType = 'polling';
147
153
  }
148
154
 
149
155
  console.log(
150
- `EventSubscriber: Failing over providerType ${this.currentProviderType} to ${nextProviderType}`
156
+ `EventSubscriber: Failing over providerType ${this._currentProviderType} to ${nextProviderType}`
151
157
  );
152
- this.currentProviderType = nextProviderType;
158
+ this._currentProviderType = nextProviderType;
153
159
  }
154
160
 
155
161
  public async subscribe(): Promise<boolean> {
@@ -194,7 +200,7 @@ export class EventSubscriber {
194
200
  slot,
195
201
  logs,
196
202
  mostRecentBlockTime,
197
- this.currentProviderType === 'events-server',
203
+ this._currentProviderType === 'events-server',
198
204
  txSigIndex
199
205
  );
200
206
  },
@@ -12913,6 +12913,11 @@
12913
12913
  "name": "oraclePrice",
12914
12914
  "type": "i64",
12915
12915
  "index": false
12916
+ },
12917
+ {
12918
+ "name": "bitFlags",
12919
+ "type": "u8",
12920
+ "index": false
12916
12921
  }
12917
12922
  ]
12918
12923
  },
@@ -15061,4 +15066,4 @@
15061
15066
  "metadata": {
15062
15067
  "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
15063
15068
  }
15064
- }
15069
+ }