@drift-labs/sdk 2.131.0-beta.8 → 2.131.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 +1 -1
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +1 -0
- package/lib/browser/accounts/webSocketAccountSubscriberV2.js +22 -17
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +1 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriberV2.js +22 -17
- package/package.json +1 -1
- package/src/accounts/webSocketAccountSubscriberV2.ts +22 -17
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.131.0-beta.
|
|
1
|
+
2.131.0-beta.9
|
|
@@ -23,6 +23,7 @@ export declare class WebSocketAccountSubscriberV2<T> implements AccountSubscribe
|
|
|
23
23
|
private rpcSubscriptions;
|
|
24
24
|
private abortController?;
|
|
25
25
|
constructor(accountName: string, program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => T, resubOpts?: ResubOpts, commitment?: Commitment);
|
|
26
|
+
private handleNotificationLoop;
|
|
26
27
|
subscribe(onChange: (data: T) => void): Promise<void>;
|
|
27
28
|
setData(data: T, slot?: number): void;
|
|
28
29
|
protected setTimeout(): void;
|
|
@@ -35,8 +35,22 @@ class WebSocketAccountSubscriberV2 {
|
|
|
35
35
|
this.rpc = rpc;
|
|
36
36
|
this.rpcSubscriptions = rpcSubscriptions;
|
|
37
37
|
}
|
|
38
|
+
async handleNotificationLoop(subscription) {
|
|
39
|
+
var _a;
|
|
40
|
+
for await (const notification of subscription) {
|
|
41
|
+
if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs) {
|
|
42
|
+
this.receivingData = true;
|
|
43
|
+
clearTimeout(this.timeoutId);
|
|
44
|
+
this.handleRpcResponse(notification.context, notification.value);
|
|
45
|
+
this.setTimeout();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.handleRpcResponse(notification.context, notification.value);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
38
52
|
async subscribe(onChange) {
|
|
39
|
-
var _a, _b
|
|
53
|
+
var _a, _b;
|
|
40
54
|
if (this.listenerId != null || this.isUnsubscribing) {
|
|
41
55
|
if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.logResubMessages) {
|
|
42
56
|
console.log(`[${this.logAccountName}] Subscribe returning early - listenerId=${this.listenerId}, isUnsubscribing=${this.isUnsubscribing}`);
|
|
@@ -50,6 +64,11 @@ class WebSocketAccountSubscriberV2 {
|
|
|
50
64
|
// Create abort controller for proper cleanup
|
|
51
65
|
const abortController = new AbortController();
|
|
52
66
|
this.abortController = abortController;
|
|
67
|
+
this.listenerId = Math.random(); // Unique ID for logging purposes
|
|
68
|
+
if ((_b = this.resubOpts) === null || _b === void 0 ? void 0 : _b.resubTimeoutMs) {
|
|
69
|
+
this.receivingData = true;
|
|
70
|
+
this.setTimeout();
|
|
71
|
+
}
|
|
53
72
|
// Subscribe to account changes using gill's rpcSubscriptions
|
|
54
73
|
const pubkey = this.accountPublicKey.toBase58();
|
|
55
74
|
if ((0, gill_1.isAddress)(pubkey)) {
|
|
@@ -61,22 +80,8 @@ class WebSocketAccountSubscriberV2 {
|
|
|
61
80
|
.subscribe({
|
|
62
81
|
abortSignal: abortController.signal,
|
|
63
82
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this.receivingData = true;
|
|
67
|
-
clearTimeout(this.timeoutId);
|
|
68
|
-
this.handleRpcResponse(notification.context, notification.value);
|
|
69
|
-
this.setTimeout();
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
this.handleRpcResponse(notification.context, notification.value);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
this.listenerId = Math.random(); // Unique ID for logging purposes
|
|
77
|
-
if ((_c = this.resubOpts) === null || _c === void 0 ? void 0 : _c.resubTimeoutMs) {
|
|
78
|
-
this.receivingData = true;
|
|
79
|
-
this.setTimeout();
|
|
83
|
+
// Start notification loop without awaiting
|
|
84
|
+
this.handleNotificationLoop(subscription);
|
|
80
85
|
}
|
|
81
86
|
}
|
|
82
87
|
setData(data, slot) {
|
|
@@ -23,6 +23,7 @@ export declare class WebSocketAccountSubscriberV2<T> implements AccountSubscribe
|
|
|
23
23
|
private rpcSubscriptions;
|
|
24
24
|
private abortController?;
|
|
25
25
|
constructor(accountName: string, program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => T, resubOpts?: ResubOpts, commitment?: Commitment);
|
|
26
|
+
private handleNotificationLoop;
|
|
26
27
|
subscribe(onChange: (data: T) => void): Promise<void>;
|
|
27
28
|
setData(data: T, slot?: number): void;
|
|
28
29
|
protected setTimeout(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webSocketAccountSubscriberV2.d.ts","sourceRoot":"","sources":["../../../src/accounts/webSocketAccountSubscriberV2.ts"],"names":[],"mappings":";;AAAA,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,aAAa,EACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAkB,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EACN,eAAe,EACf,gCAAgC,EAChC,gCAAgC,EAIhC,KAAK,UAAU,EACf,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,qBAAa,4BAA4B,CAAC,CAAC,CAAE,YAAW,iBAAiB,CAAC,CAAC,CAAC;IAC3E,WAAW,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAC7B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,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;IAW/B,WAAW,CAAC,OAAO,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAmB3C"}
|
|
@@ -35,8 +35,22 @@ class WebSocketAccountSubscriberV2 {
|
|
|
35
35
|
this.rpc = rpc;
|
|
36
36
|
this.rpcSubscriptions = rpcSubscriptions;
|
|
37
37
|
}
|
|
38
|
+
async handleNotificationLoop(subscription) {
|
|
39
|
+
var _a;
|
|
40
|
+
for await (const notification of subscription) {
|
|
41
|
+
if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs) {
|
|
42
|
+
this.receivingData = true;
|
|
43
|
+
clearTimeout(this.timeoutId);
|
|
44
|
+
this.handleRpcResponse(notification.context, notification.value);
|
|
45
|
+
this.setTimeout();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.handleRpcResponse(notification.context, notification.value);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
38
52
|
async subscribe(onChange) {
|
|
39
|
-
var _a, _b
|
|
53
|
+
var _a, _b;
|
|
40
54
|
if (this.listenerId != null || this.isUnsubscribing) {
|
|
41
55
|
if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.logResubMessages) {
|
|
42
56
|
console.log(`[${this.logAccountName}] Subscribe returning early - listenerId=${this.listenerId}, isUnsubscribing=${this.isUnsubscribing}`);
|
|
@@ -50,6 +64,11 @@ class WebSocketAccountSubscriberV2 {
|
|
|
50
64
|
// Create abort controller for proper cleanup
|
|
51
65
|
const abortController = new AbortController();
|
|
52
66
|
this.abortController = abortController;
|
|
67
|
+
this.listenerId = Math.random(); // Unique ID for logging purposes
|
|
68
|
+
if ((_b = this.resubOpts) === null || _b === void 0 ? void 0 : _b.resubTimeoutMs) {
|
|
69
|
+
this.receivingData = true;
|
|
70
|
+
this.setTimeout();
|
|
71
|
+
}
|
|
53
72
|
// Subscribe to account changes using gill's rpcSubscriptions
|
|
54
73
|
const pubkey = this.accountPublicKey.toBase58();
|
|
55
74
|
if ((0, gill_1.isAddress)(pubkey)) {
|
|
@@ -61,22 +80,8 @@ class WebSocketAccountSubscriberV2 {
|
|
|
61
80
|
.subscribe({
|
|
62
81
|
abortSignal: abortController.signal,
|
|
63
82
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this.receivingData = true;
|
|
67
|
-
clearTimeout(this.timeoutId);
|
|
68
|
-
this.handleRpcResponse(notification.context, notification.value);
|
|
69
|
-
this.setTimeout();
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
this.handleRpcResponse(notification.context, notification.value);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
this.listenerId = Math.random(); // Unique ID for logging purposes
|
|
77
|
-
if ((_c = this.resubOpts) === null || _c === void 0 ? void 0 : _c.resubTimeoutMs) {
|
|
78
|
-
this.receivingData = true;
|
|
79
|
-
this.setTimeout();
|
|
83
|
+
// Start notification loop without awaiting
|
|
84
|
+
this.handleNotificationLoop(subscription);
|
|
80
85
|
}
|
|
81
86
|
}
|
|
82
87
|
setData(data, slot) {
|
package/package.json
CHANGED
|
@@ -90,6 +90,19 @@ export class WebSocketAccountSubscriberV2<T> implements AccountSubscriber<T> {
|
|
|
90
90
|
this.rpcSubscriptions = rpcSubscriptions;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
private async handleNotificationLoop(subscription: AsyncIterable<any>) {
|
|
94
|
+
for await (const notification of subscription) {
|
|
95
|
+
if (this.resubOpts?.resubTimeoutMs) {
|
|
96
|
+
this.receivingData = true;
|
|
97
|
+
clearTimeout(this.timeoutId);
|
|
98
|
+
this.handleRpcResponse(notification.context, notification.value);
|
|
99
|
+
this.setTimeout();
|
|
100
|
+
} else {
|
|
101
|
+
this.handleRpcResponse(notification.context, notification.value);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
93
106
|
async subscribe(onChange: (data: T) => void): Promise<void> {
|
|
94
107
|
if (this.listenerId != null || this.isUnsubscribing) {
|
|
95
108
|
if (this.resubOpts?.logResubMessages) {
|
|
@@ -109,6 +122,13 @@ export class WebSocketAccountSubscriberV2<T> implements AccountSubscriber<T> {
|
|
|
109
122
|
const abortController = new AbortController();
|
|
110
123
|
this.abortController = abortController;
|
|
111
124
|
|
|
125
|
+
this.listenerId = Math.random(); // Unique ID for logging purposes
|
|
126
|
+
|
|
127
|
+
if (this.resubOpts?.resubTimeoutMs) {
|
|
128
|
+
this.receivingData = true;
|
|
129
|
+
this.setTimeout();
|
|
130
|
+
}
|
|
131
|
+
|
|
112
132
|
// Subscribe to account changes using gill's rpcSubscriptions
|
|
113
133
|
const pubkey = this.accountPublicKey.toBase58();
|
|
114
134
|
if (isAddress(pubkey)) {
|
|
@@ -121,23 +141,8 @@ export class WebSocketAccountSubscriberV2<T> implements AccountSubscriber<T> {
|
|
|
121
141
|
abortSignal: abortController.signal,
|
|
122
142
|
});
|
|
123
143
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
this.receivingData = true;
|
|
127
|
-
clearTimeout(this.timeoutId);
|
|
128
|
-
this.handleRpcResponse(notification.context, notification.value);
|
|
129
|
-
this.setTimeout();
|
|
130
|
-
} else {
|
|
131
|
-
this.handleRpcResponse(notification.context, notification.value);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
this.listenerId = Math.random(); // Unique ID for logging purposes
|
|
137
|
-
|
|
138
|
-
if (this.resubOpts?.resubTimeoutMs) {
|
|
139
|
-
this.receivingData = true;
|
|
140
|
-
this.setTimeout();
|
|
144
|
+
// Start notification loop without awaiting
|
|
145
|
+
this.handleNotificationLoop(subscription);
|
|
141
146
|
}
|
|
142
147
|
}
|
|
143
148
|
|