@drift-labs/sdk 2.85.0-beta.8 → 2.85.0-beta.9

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.85.0-beta.8
1
+ 2.85.0-beta.9
@@ -45,23 +45,30 @@ class BlockhashSubscriber {
45
45
  }
46
46
  }
47
47
  async updateBlockhash() {
48
- const [resp, lastConfirmedBlockHeight] = await Promise.all([
49
- this.connection.getLatestBlockhashAndContext({
50
- commitment: this.commitment,
51
- }),
52
- this.connection.getBlockHeight({ commitment: this.commitment }),
53
- ]);
54
- this.latestBlockHeight = lastConfirmedBlockHeight;
55
- this.latestBlockHeightContext = resp.context;
56
- // avoid caching duplicate blockhashes
57
- if (this.blockhashes.length > 0) {
58
- if (resp.value.blockhash ===
59
- this.blockhashes[this.blockhashes.length - 1].blockhash) {
60
- return;
48
+ try {
49
+ const [resp, lastConfirmedBlockHeight] = await Promise.all([
50
+ this.connection.getLatestBlockhashAndContext({
51
+ commitment: this.commitment,
52
+ }),
53
+ this.connection.getBlockHeight({ commitment: this.commitment }),
54
+ ]);
55
+ this.latestBlockHeight = lastConfirmedBlockHeight;
56
+ this.latestBlockHeightContext = resp.context;
57
+ // avoid caching duplicate blockhashes
58
+ if (this.blockhashes.length > 0) {
59
+ if (resp.value.blockhash ===
60
+ this.blockhashes[this.blockhashes.length - 1].blockhash) {
61
+ return;
62
+ }
61
63
  }
64
+ this.blockhashes.push(resp.value);
65
+ }
66
+ catch (e) {
67
+ console.error('Error updating blockhash:\n', e);
68
+ }
69
+ finally {
70
+ this.pruneBlockhashes();
62
71
  }
63
- this.blockhashes.push(resp.value);
64
- this.pruneBlockhashes();
65
72
  }
66
73
  async subscribe() {
67
74
  if (this.isSubscribed) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.85.0-beta.8",
3
+ "version": "2.85.0-beta.9",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -75,27 +75,32 @@ export class BlockhashSubscriber {
75
75
  }
76
76
 
77
77
  async updateBlockhash() {
78
- const [resp, lastConfirmedBlockHeight] = await Promise.all([
79
- this.connection.getLatestBlockhashAndContext({
80
- commitment: this.commitment,
81
- }),
82
- this.connection.getBlockHeight({ commitment: this.commitment }),
83
- ]);
84
- this.latestBlockHeight = lastConfirmedBlockHeight;
85
- this.latestBlockHeightContext = resp.context;
86
-
87
- // avoid caching duplicate blockhashes
88
- if (this.blockhashes.length > 0) {
89
- if (
90
- resp.value.blockhash ===
91
- this.blockhashes[this.blockhashes.length - 1].blockhash
92
- ) {
93
- return;
78
+ try {
79
+ const [resp, lastConfirmedBlockHeight] = await Promise.all([
80
+ this.connection.getLatestBlockhashAndContext({
81
+ commitment: this.commitment,
82
+ }),
83
+ this.connection.getBlockHeight({ commitment: this.commitment }),
84
+ ]);
85
+ this.latestBlockHeight = lastConfirmedBlockHeight;
86
+ this.latestBlockHeightContext = resp.context;
87
+
88
+ // avoid caching duplicate blockhashes
89
+ if (this.blockhashes.length > 0) {
90
+ if (
91
+ resp.value.blockhash ===
92
+ this.blockhashes[this.blockhashes.length - 1].blockhash
93
+ ) {
94
+ return;
95
+ }
94
96
  }
95
- }
96
97
 
97
- this.blockhashes.push(resp.value);
98
- this.pruneBlockhashes();
98
+ this.blockhashes.push(resp.value);
99
+ } catch (e) {
100
+ console.error('Error updating blockhash:\n', e);
101
+ } finally {
102
+ this.pruneBlockhashes();
103
+ }
99
104
  }
100
105
 
101
106
  async subscribe() {