@drift-labs/sdk 2.48.0-beta.10 → 2.48.0-beta.11

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.48.0-beta.10
1
+ 2.48.0-beta.11
@@ -53,12 +53,17 @@ class PollingUserAccountSubscriber {
53
53
  }
54
54
  async fetch() {
55
55
  var _a, _b;
56
- const dataAndContext = await this.program.account.user.fetchAndContext(this.userAccountPublicKey, this.accountLoader.commitment);
57
- if (dataAndContext.context.slot > ((_b = (_a = this.user) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : 0)) {
58
- this.user = {
59
- data: dataAndContext.data,
60
- slot: dataAndContext.context.slot,
61
- };
56
+ try {
57
+ const dataAndContext = await this.program.account.user.fetchAndContext(this.userAccountPublicKey, this.accountLoader.commitment);
58
+ if (dataAndContext.context.slot > ((_b = (_a = this.user) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : 0)) {
59
+ this.user = {
60
+ data: dataAndContext.data,
61
+ slot: dataAndContext.context.slot,
62
+ };
63
+ }
64
+ }
65
+ catch (e) {
66
+ console.log(`PollingUserAccountSubscriber.fetch() UserAccount does not exist: ${e.message}`);
62
67
  }
63
68
  }
64
69
  doesAccountExist() {
@@ -53,12 +53,17 @@ class PollingUserStatsAccountSubscriber {
53
53
  }
54
54
  async fetch() {
55
55
  var _a, _b;
56
- const dataAndContext = await this.program.account.userStats.fetchAndContext(this.userStatsAccountPublicKey, this.accountLoader.commitment);
57
- if (dataAndContext.context.slot > ((_b = (_a = this.userStats) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : 0)) {
58
- this.userStats = {
59
- data: dataAndContext.data,
60
- slot: dataAndContext.context.slot,
61
- };
56
+ try {
57
+ const dataAndContext = await this.program.account.userStats.fetchAndContext(this.userStatsAccountPublicKey, this.accountLoader.commitment);
58
+ if (dataAndContext.context.slot > ((_b = (_a = this.userStats) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : 0)) {
59
+ this.userStats = {
60
+ data: dataAndContext.data,
61
+ slot: dataAndContext.context.slot,
62
+ };
63
+ }
64
+ }
65
+ catch (e) {
66
+ console.log(`PollingUserStatsAccountSubscriber.fetch() UserStatsAccount does not exist: ${e.message}`);
62
67
  }
63
68
  }
64
69
  doesAccountExist() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.48.0-beta.10",
3
+ "version": "2.48.0-beta.11",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -93,15 +93,21 @@ export class PollingUserAccountSubscriber implements UserAccountSubscriber {
93
93
  }
94
94
 
95
95
  async fetch(): Promise<void> {
96
- const dataAndContext = await this.program.account.user.fetchAndContext(
97
- this.userAccountPublicKey,
98
- this.accountLoader.commitment
99
- );
100
- if (dataAndContext.context.slot > (this.user?.slot ?? 0)) {
101
- this.user = {
102
- data: dataAndContext.data as UserAccount,
103
- slot: dataAndContext.context.slot,
104
- };
96
+ try {
97
+ const dataAndContext = await this.program.account.user.fetchAndContext(
98
+ this.userAccountPublicKey,
99
+ this.accountLoader.commitment
100
+ );
101
+ if (dataAndContext.context.slot > (this.user?.slot ?? 0)) {
102
+ this.user = {
103
+ data: dataAndContext.data as UserAccount,
104
+ slot: dataAndContext.context.slot,
105
+ };
106
+ }
107
+ } catch (e) {
108
+ console.log(
109
+ `PollingUserAccountSubscriber.fetch() UserAccount does not exist: ${e.message}`
110
+ );
105
111
  }
106
112
  }
107
113
 
@@ -97,15 +97,22 @@ export class PollingUserStatsAccountSubscriber
97
97
  }
98
98
 
99
99
  async fetch(): Promise<void> {
100
- const dataAndContext = await this.program.account.userStats.fetchAndContext(
101
- this.userStatsAccountPublicKey,
102
- this.accountLoader.commitment
103
- );
104
- if (dataAndContext.context.slot > (this.userStats?.slot ?? 0)) {
105
- this.userStats = {
106
- data: dataAndContext.data as UserStatsAccount,
107
- slot: dataAndContext.context.slot,
108
- };
100
+ try {
101
+ const dataAndContext =
102
+ await this.program.account.userStats.fetchAndContext(
103
+ this.userStatsAccountPublicKey,
104
+ this.accountLoader.commitment
105
+ );
106
+ if (dataAndContext.context.slot > (this.userStats?.slot ?? 0)) {
107
+ this.userStats = {
108
+ data: dataAndContext.data as UserStatsAccount,
109
+ slot: dataAndContext.context.slot,
110
+ };
111
+ }
112
+ } catch (e) {
113
+ console.log(
114
+ `PollingUserStatsAccountSubscriber.fetch() UserStatsAccount does not exist: ${e.message}`
115
+ );
109
116
  }
110
117
  }
111
118