@drift-labs/sdk 0.1.36-master.0 → 0.1.36-master.3

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.
@@ -41,8 +41,13 @@ class PollingClearingHouseAccountSubscriber {
41
41
  });
42
42
  yield this.updateAccountsToPoll();
43
43
  yield this.addToAccountLoader();
44
- yield this.fetch();
45
- const subscriptionSucceeded = this.didSubscriptionSucceed();
44
+ let subscriptionSucceeded = false;
45
+ let retries = 0;
46
+ while (!subscriptionSucceeded && retries < 5) {
47
+ yield this.fetch();
48
+ subscriptionSucceeded = this.didSubscriptionSucceed();
49
+ retries++;
50
+ }
46
51
  if (subscriptionSucceeded) {
47
52
  this.eventEmitter.emit('update');
48
53
  }
@@ -162,6 +167,9 @@ class PollingClearingHouseAccountSubscriber {
162
167
  // @ts-ignore
163
168
  this.eventEmitter.emit(accountToPoll.eventType, account);
164
169
  this.eventEmitter.emit('update');
170
+ if (!this.isSubscribed) {
171
+ this.isSubscribed = this.didSubscriptionSucceed();
172
+ }
165
173
  });
166
174
  }
167
175
  this.errorCallbackId = this.accountLoader.addErrorCallbacks((error) => {
@@ -23,4 +23,5 @@ export declare class PollingOracleSubscriber implements OracleSubscriber {
23
23
  unsubscribe(): Promise<void>;
24
24
  assertIsSubscribed(): void;
25
25
  getOraclePriceData(): OraclePriceData;
26
+ didSubscriptionSucceed(): boolean;
26
27
  }
@@ -26,10 +26,18 @@ class PollingOracleSubscriber {
26
26
  return true;
27
27
  }
28
28
  this.addToAccountLoader();
29
- yield this.fetch();
30
- this.eventEmitter.emit('update');
31
- this.isSubscribed = true;
32
- return true;
29
+ let subscriptionSucceeded = false;
30
+ let retries = 0;
31
+ while (!subscriptionSucceeded && retries < 5) {
32
+ yield this.fetch();
33
+ subscriptionSucceeded = this.didSubscriptionSucceed();
34
+ retries++;
35
+ }
36
+ if (subscriptionSucceeded) {
37
+ this.eventEmitter.emit('update');
38
+ }
39
+ this.isSubscribed = subscriptionSucceeded;
40
+ return subscriptionSucceeded;
33
41
  });
34
42
  }
35
43
  addToAccountLoader() {
@@ -75,5 +83,8 @@ class PollingOracleSubscriber {
75
83
  this.assertIsSubscribed();
76
84
  return this.oraclePriceData;
77
85
  }
86
+ didSubscriptionSucceed() {
87
+ return !!this.oraclePriceData;
88
+ }
78
89
  }
79
90
  exports.PollingOracleSubscriber = PollingOracleSubscriber;
@@ -22,4 +22,5 @@ export declare class PollingTokenAccountSubscriber implements TokenAccountSubscr
22
22
  unsubscribe(): Promise<void>;
23
23
  assertIsSubscribed(): void;
24
24
  getTokenAccount(): AccountInfo;
25
+ didSubscriptionSucceed(): boolean;
25
26
  }
@@ -26,10 +26,18 @@ class PollingTokenAccountSubscriber {
26
26
  return true;
27
27
  }
28
28
  this.addToAccountLoader();
29
- yield this.fetch();
30
- this.eventEmitter.emit('update');
31
- this.isSubscribed = true;
32
- return true;
29
+ let subscriptionSucceeded = false;
30
+ let retries = 0;
31
+ while (!subscriptionSucceeded && retries < 5) {
32
+ yield this.fetch();
33
+ subscriptionSucceeded = this.didSubscriptionSucceed();
34
+ retries++;
35
+ }
36
+ if (subscriptionSucceeded) {
37
+ this.eventEmitter.emit('update');
38
+ }
39
+ this.isSubscribed = subscriptionSucceeded;
40
+ return subscriptionSucceeded;
33
41
  });
34
42
  }
35
43
  addToAccountLoader() {
@@ -75,5 +83,8 @@ class PollingTokenAccountSubscriber {
75
83
  this.assertIsSubscribed();
76
84
  return this.tokenAccount;
77
85
  }
86
+ didSubscriptionSucceed() {
87
+ return !!this.tokenAccount;
88
+ }
78
89
  }
79
90
  exports.PollingTokenAccountSubscriber = PollingTokenAccountSubscriber;
@@ -30,8 +30,13 @@ class PollingUserAccountSubscriber {
30
30
  return true;
31
31
  }
32
32
  yield this.addToAccountLoader();
33
- yield this.fetchIfUnloaded();
34
- const subscriptionSucceeded = this.didSubscriptionSucceed();
33
+ let subscriptionSucceeded = false;
34
+ let retries = 0;
35
+ while (!subscriptionSucceeded && retries < 5) {
36
+ yield this.fetchIfUnloaded();
37
+ subscriptionSucceeded = this.didSubscriptionSucceed();
38
+ retries++;
39
+ }
35
40
  if (subscriptionSucceeded) {
36
41
  this.eventEmitter.emit('update');
37
42
  }