@drift-labs/sdk 2.79.0-beta.1 → 2.80.0-beta.0

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.79.0-beta.1
1
+ 2.80.0-beta.0
@@ -20,6 +20,7 @@ export declare class EventSubscriber {
20
20
  private lastSeenBlockTime;
21
21
  lastSeenTxSig: string;
22
22
  constructor(connection: Connection, program: Program, options?: EventSubscriptionOptions);
23
+ private populateInitialEventListMap;
23
24
  subscribe(): Promise<boolean>;
24
25
  private handleTxLogs;
25
26
  fetchPreviousTx(fetchMax?: boolean): Promise<void>;
@@ -22,9 +22,6 @@ class EventSubscriber {
22
22
  this.address = (_a = this.options.address) !== null && _a !== void 0 ? _a : program.programId;
23
23
  this.txEventCache = new txEventCache_1.TxEventCache(this.options.maxTx);
24
24
  this.eventListMap = new Map();
25
- for (const eventType of this.options.eventTypes) {
26
- this.eventListMap.set(eventType, new eventList_1.EventList(eventType, this.options.maxEventsPerType, (0, sort_1.getSortFn)(this.options.orderBy, this.options.orderDir), this.options.orderDir));
27
- }
28
25
  this.eventEmitter = new events_1.EventEmitter();
29
26
  if (this.options.logProviderConfig.type === 'websocket') {
30
27
  this.logProvider = new webSocketLogProvider_1.WebSocketLogProvider(this.connection, this.address, this.options.commitment, this.options.logProviderConfig.resubTimeoutMs);
@@ -33,11 +30,17 @@ class EventSubscriber {
33
30
  this.logProvider = new pollingLogProvider_1.PollingLogProvider(this.connection, this.address, options.commitment, this.options.logProviderConfig.frequency, this.options.logProviderConfig.batchSize);
34
31
  }
35
32
  }
33
+ populateInitialEventListMap() {
34
+ for (const eventType of this.options.eventTypes) {
35
+ this.eventListMap.set(eventType, new eventList_1.EventList(eventType, this.options.maxEventsPerType, (0, sort_1.getSortFn)(this.options.orderBy, this.options.orderDir), this.options.orderDir));
36
+ }
37
+ }
36
38
  async subscribe() {
37
39
  try {
38
40
  if (this.logProvider.isSubscribed()) {
39
41
  return true;
40
42
  }
43
+ this.populateInitialEventListMap();
41
44
  if (this.options.logProviderConfig.type === 'websocket') {
42
45
  if (this.options.logProviderConfig.resubTimeoutMs) {
43
46
  if (this.options.logProviderConfig.maxReconnectAttempts &&
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.78.0",
2
+ "version": "2.79.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.79.0-beta.1",
3
+ "version": "2.80.0-beta.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -41,18 +41,8 @@ export class EventSubscriber {
41
41
  this.address = this.options.address ?? program.programId;
42
42
  this.txEventCache = new TxEventCache(this.options.maxTx);
43
43
  this.eventListMap = new Map<EventType, EventList<EventType>>();
44
- for (const eventType of this.options.eventTypes) {
45
- this.eventListMap.set(
46
- eventType,
47
- new EventList(
48
- eventType,
49
- this.options.maxEventsPerType,
50
- getSortFn(this.options.orderBy, this.options.orderDir),
51
- this.options.orderDir
52
- )
53
- );
54
- }
55
44
  this.eventEmitter = new EventEmitter();
45
+
56
46
  if (this.options.logProviderConfig.type === 'websocket') {
57
47
  this.logProvider = new WebSocketLogProvider(
58
48
  this.connection,
@@ -71,12 +61,28 @@ export class EventSubscriber {
71
61
  }
72
62
  }
73
63
 
64
+ private populateInitialEventListMap() {
65
+ for (const eventType of this.options.eventTypes) {
66
+ this.eventListMap.set(
67
+ eventType,
68
+ new EventList(
69
+ eventType,
70
+ this.options.maxEventsPerType,
71
+ getSortFn(this.options.orderBy, this.options.orderDir),
72
+ this.options.orderDir
73
+ )
74
+ );
75
+ }
76
+ }
77
+
74
78
  public async subscribe(): Promise<boolean> {
75
79
  try {
76
80
  if (this.logProvider.isSubscribed()) {
77
81
  return true;
78
82
  }
79
83
 
84
+ this.populateInitialEventListMap();
85
+
80
86
  if (this.options.logProviderConfig.type === 'websocket') {
81
87
  if (this.options.logProviderConfig.resubTimeoutMs) {
82
88
  if (
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.78.0",
2
+ "version": "2.79.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {