@drift-labs/sdk 2.157.0-beta.0 → 2.157.0-beta.1
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/laserProgramAccountSubscriber.d.ts +1 -0
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +14 -6
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +1 -0
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.js +14 -6
- package/lib/node/isomorphic/grpc.d.ts +13 -4
- package/lib/node/isomorphic/grpc.js +74 -5
- package/lib/node/isomorphic/grpc.node.d.ts +13 -4
- package/lib/node/isomorphic/grpc.node.d.ts.map +1 -1
- package/lib/node/isomorphic/grpc.node.js +74 -5
- package/package.json +4 -2
- package/src/accounts/laserProgramAccountSubscriber.ts +21 -7
- package/src/isomorphic/grpc.node.ts +98 -16
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.157.0-beta.
|
|
1
|
+
2.157.0-beta.1
|
|
@@ -10,6 +10,7 @@ export declare class LaserstreamProgramAccountSubscriber<T> extends WebSocketPro
|
|
|
10
10
|
private commitmentLevel;
|
|
11
11
|
listenerId?: number;
|
|
12
12
|
private readonly laserConfig;
|
|
13
|
+
private readonly laserCommitmentLevel;
|
|
13
14
|
private constructor();
|
|
14
15
|
static create<U>(grpcConfigs: GrpcConfigs, subscriptionName: string, accountDiscriminator: string, program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => U, options?: {
|
|
15
16
|
filters: MemcmpFilter[];
|
|
@@ -29,26 +29,32 @@ const Buffer = __importStar(require("buffer"));
|
|
|
29
29
|
const webSocketProgramAccountSubscriber_1 = require("./webSocketProgramAccountSubscriber");
|
|
30
30
|
const grpc_1 = require("../isomorphic/grpc");
|
|
31
31
|
class LaserstreamProgramAccountSubscriber extends webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber {
|
|
32
|
-
constructor(laserConfig, commitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = { filters: [] }, resubOpts) {
|
|
32
|
+
constructor(laserConfig, commitmentLevel, laserCommitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = { filters: [] }, resubOpts) {
|
|
33
33
|
super(subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
|
|
34
34
|
this.laserConfig = laserConfig;
|
|
35
|
+
this.laserCommitmentLevel = laserCommitmentLevel;
|
|
35
36
|
this.commitmentLevel = this.toLaserCommitment(commitmentLevel);
|
|
36
37
|
}
|
|
37
38
|
static async create(grpcConfigs, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = {
|
|
38
39
|
filters: [],
|
|
39
40
|
}, resubOpts) {
|
|
40
41
|
var _a;
|
|
42
|
+
// Load enums from the optional helius-laserstream module
|
|
43
|
+
const [compressionAlgorithms, laserCommitmentLevel] = await Promise.all([
|
|
44
|
+
(0, grpc_1.getLaserCompressionAlgorithms)(),
|
|
45
|
+
(0, grpc_1.getLaserCommitmentLevel)(),
|
|
46
|
+
]);
|
|
41
47
|
const laserConfig = {
|
|
42
48
|
apiKey: grpcConfigs.token,
|
|
43
49
|
endpoint: grpcConfigs.endpoint,
|
|
44
50
|
maxReconnectAttempts: grpcConfigs.enableReconnect ? 10 : 0,
|
|
45
51
|
channelOptions: {
|
|
46
|
-
'grpc.default_compression_algorithm':
|
|
52
|
+
'grpc.default_compression_algorithm': compressionAlgorithms.zstd,
|
|
47
53
|
'grpc.max_receive_message_length': 1000000000,
|
|
48
54
|
},
|
|
49
55
|
};
|
|
50
56
|
const commitmentLevel = (_a = grpcConfigs.commitmentLevel) !== null && _a !== void 0 ? _a : grpc_1.CommitmentLevel.CONFIRMED;
|
|
51
|
-
return new LaserstreamProgramAccountSubscriber(laserConfig, commitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
|
|
57
|
+
return new LaserstreamProgramAccountSubscriber(laserConfig, commitmentLevel, laserCommitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
|
|
52
58
|
}
|
|
53
59
|
async subscribe(onChange) {
|
|
54
60
|
var _a;
|
|
@@ -81,7 +87,9 @@ class LaserstreamProgramAccountSubscriber extends webSocketProgramAccountSubscri
|
|
|
81
87
|
transactionsStatus: {},
|
|
82
88
|
};
|
|
83
89
|
try {
|
|
84
|
-
|
|
90
|
+
// Dynamically load LaserSubscribe from the optional helius-laserstream module
|
|
91
|
+
const laserSubscribe = await (0, grpc_1.getLaserSubscribe)();
|
|
92
|
+
const stream = await laserSubscribe(this.laserConfig, request, async (update) => {
|
|
85
93
|
var _a;
|
|
86
94
|
if (update.account) {
|
|
87
95
|
const slot = Number(update.account.slot);
|
|
@@ -146,9 +154,9 @@ class LaserstreamProgramAccountSubscriber extends webSocketProgramAccountSubscri
|
|
|
146
154
|
toLaserCommitment(level) {
|
|
147
155
|
var _a, _b;
|
|
148
156
|
if (typeof level === 'string') {
|
|
149
|
-
return ((_a =
|
|
157
|
+
return ((_a = this.laserCommitmentLevel[level.toUpperCase()]) !== null && _a !== void 0 ? _a : this.laserCommitmentLevel.CONFIRMED);
|
|
150
158
|
}
|
|
151
|
-
return (_b = level) !== null && _b !== void 0 ? _b :
|
|
159
|
+
return (_b = level) !== null && _b !== void 0 ? _b : this.laserCommitmentLevel.CONFIRMED;
|
|
152
160
|
}
|
|
153
161
|
}
|
|
154
162
|
exports.LaserstreamProgramAccountSubscriber = LaserstreamProgramAccountSubscriber;
|
|
@@ -10,6 +10,7 @@ export declare class LaserstreamProgramAccountSubscriber<T> extends WebSocketPro
|
|
|
10
10
|
private commitmentLevel;
|
|
11
11
|
listenerId?: number;
|
|
12
12
|
private readonly laserConfig;
|
|
13
|
+
private readonly laserCommitmentLevel;
|
|
13
14
|
private constructor();
|
|
14
15
|
static create<U>(grpcConfigs: GrpcConfigs, subscriptionName: string, accountDiscriminator: string, program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => U, options?: {
|
|
15
16
|
filters: MemcmpFilter[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"laserProgramAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/accounts/laserProgramAccountSubscriber.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,OAAO,EACN,oBAAoB,
|
|
1
|
+
{"version":3,"file":"laserProgramAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/accounts/laserProgramAccountSubscriber.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,OAAO,EACN,oBAAoB,EAQpB,MAAM,oBAAoB,CAAC;AAE5B,KAAK,eAAe,GACnB,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;AAElE,qBAAa,mCAAmC,CAC/C,CAAC,CACA,SAAQ,iCAAiC,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,MAAM,CAMD;IAEb,OAAO,CAAC,eAAe,CAAkB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE3B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;IAChD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA8B;IAEnE,OAAO;WAwBa,MAAM,CAAC,CAAC,EAC3B,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,MAAM,EACxB,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,CAAC,EACtD,OAAO,GAAE;QAAE,OAAO,EAAE,YAAY,EAAE,CAAA;KAEjC,EACD,SAAS,CAAC,EAAE,SAAS,GACnB,OAAO,CAAC,mCAAmC,CAAC,CAAC,CAAC,CAAC;IAiC5C,SAAS,CACd,QAAQ,EAAE,CACT,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,KACV,IAAI,GACP,OAAO,CAAC,IAAI,CAAC;IAsFH,WAAW,CAAC,OAAO,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBjD,iBAAiB,CACvB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAChC,eAAe;CASlB"}
|
|
@@ -29,26 +29,32 @@ const Buffer = __importStar(require("buffer"));
|
|
|
29
29
|
const webSocketProgramAccountSubscriber_1 = require("./webSocketProgramAccountSubscriber");
|
|
30
30
|
const grpc_1 = require("../isomorphic/grpc");
|
|
31
31
|
class LaserstreamProgramAccountSubscriber extends webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber {
|
|
32
|
-
constructor(laserConfig, commitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = { filters: [] }, resubOpts) {
|
|
32
|
+
constructor(laserConfig, commitmentLevel, laserCommitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = { filters: [] }, resubOpts) {
|
|
33
33
|
super(subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
|
|
34
34
|
this.laserConfig = laserConfig;
|
|
35
|
+
this.laserCommitmentLevel = laserCommitmentLevel;
|
|
35
36
|
this.commitmentLevel = this.toLaserCommitment(commitmentLevel);
|
|
36
37
|
}
|
|
37
38
|
static async create(grpcConfigs, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = {
|
|
38
39
|
filters: [],
|
|
39
40
|
}, resubOpts) {
|
|
40
41
|
var _a;
|
|
42
|
+
// Load enums from the optional helius-laserstream module
|
|
43
|
+
const [compressionAlgorithms, laserCommitmentLevel] = await Promise.all([
|
|
44
|
+
(0, grpc_1.getLaserCompressionAlgorithms)(),
|
|
45
|
+
(0, grpc_1.getLaserCommitmentLevel)(),
|
|
46
|
+
]);
|
|
41
47
|
const laserConfig = {
|
|
42
48
|
apiKey: grpcConfigs.token,
|
|
43
49
|
endpoint: grpcConfigs.endpoint,
|
|
44
50
|
maxReconnectAttempts: grpcConfigs.enableReconnect ? 10 : 0,
|
|
45
51
|
channelOptions: {
|
|
46
|
-
'grpc.default_compression_algorithm':
|
|
52
|
+
'grpc.default_compression_algorithm': compressionAlgorithms.zstd,
|
|
47
53
|
'grpc.max_receive_message_length': 1000000000,
|
|
48
54
|
},
|
|
49
55
|
};
|
|
50
56
|
const commitmentLevel = (_a = grpcConfigs.commitmentLevel) !== null && _a !== void 0 ? _a : grpc_1.CommitmentLevel.CONFIRMED;
|
|
51
|
-
return new LaserstreamProgramAccountSubscriber(laserConfig, commitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
|
|
57
|
+
return new LaserstreamProgramAccountSubscriber(laserConfig, commitmentLevel, laserCommitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
|
|
52
58
|
}
|
|
53
59
|
async subscribe(onChange) {
|
|
54
60
|
var _a;
|
|
@@ -81,7 +87,9 @@ class LaserstreamProgramAccountSubscriber extends webSocketProgramAccountSubscri
|
|
|
81
87
|
transactionsStatus: {},
|
|
82
88
|
};
|
|
83
89
|
try {
|
|
84
|
-
|
|
90
|
+
// Dynamically load LaserSubscribe from the optional helius-laserstream module
|
|
91
|
+
const laserSubscribe = await (0, grpc_1.getLaserSubscribe)();
|
|
92
|
+
const stream = await laserSubscribe(this.laserConfig, request, async (update) => {
|
|
85
93
|
var _a;
|
|
86
94
|
if (update.account) {
|
|
87
95
|
const slot = Number(update.account.slot);
|
|
@@ -146,9 +154,9 @@ class LaserstreamProgramAccountSubscriber extends webSocketProgramAccountSubscri
|
|
|
146
154
|
toLaserCommitment(level) {
|
|
147
155
|
var _a, _b;
|
|
148
156
|
if (typeof level === 'string') {
|
|
149
|
-
return ((_a =
|
|
157
|
+
return ((_a = this.laserCommitmentLevel[level.toUpperCase()]) !== null && _a !== void 0 ? _a : this.laserCommitmentLevel.CONFIRMED);
|
|
150
158
|
}
|
|
151
|
-
return (_b = level) !== null && _b !== void 0 ? _b :
|
|
159
|
+
return (_b = level) !== null && _b !== void 0 ? _b : this.laserCommitmentLevel.CONFIRMED;
|
|
152
160
|
}
|
|
153
161
|
}
|
|
154
162
|
exports.LaserstreamProgramAccountSubscriber = LaserstreamProgramAccountSubscriber;
|
|
@@ -2,9 +2,18 @@ import type Client from '@triton-one/yellowstone-grpc';
|
|
|
2
2
|
import type { SubscribeRequest, SubscribeUpdate } from '@triton-one/yellowstone-grpc';
|
|
3
3
|
import { CommitmentLevel } from '@triton-one/yellowstone-grpc';
|
|
4
4
|
import type { ClientDuplexStream, ChannelOptions } from '@grpc/grpc-js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export type { LaserstreamConfig, SubscribeRequest as LaserSubscribeRequest, SubscribeUpdate as LaserSubscribeUpdate, } from 'helius-laserstream';
|
|
6
|
+
export declare const LaserCommitmentLevel: {
|
|
7
|
+
readonly PROCESSED: 0;
|
|
8
|
+
readonly CONFIRMED: 1;
|
|
9
|
+
readonly FINALIZED: 2;
|
|
10
|
+
};
|
|
11
|
+
export declare const CompressionAlgorithms: typeof import("helius-laserstream").CompressionAlgorithms;
|
|
12
|
+
export declare function getLaserSubscribe(): Promise<typeof import('helius-laserstream').subscribe>;
|
|
13
|
+
export declare function getLaserCommitmentLevel(): Promise<typeof import('helius-laserstream').CommitmentLevel>;
|
|
14
|
+
export declare function getLaserCompressionAlgorithms(): Promise<typeof import('helius-laserstream').CompressionAlgorithms>;
|
|
15
|
+
export declare function LaserSubscribe(...args: Parameters<typeof import('helius-laserstream').subscribe>): ReturnType<typeof import('helius-laserstream').subscribe>;
|
|
16
|
+
export { CommitmentLevel, Client };
|
|
17
|
+
export type { ClientDuplexStream, ChannelOptions, SubscribeRequest, SubscribeUpdate, };
|
|
9
18
|
export declare function createClient(...args: ConstructorParameters<typeof Client>): Promise<Client>;
|
|
10
19
|
//# sourceMappingURL=grpc.node.d.ts.map
|
|
@@ -23,13 +23,82 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createClient = exports.
|
|
26
|
+
exports.createClient = exports.CommitmentLevel = exports.LaserSubscribe = exports.getLaserCompressionAlgorithms = exports.getLaserCommitmentLevel = exports.getLaserSubscribe = exports.CompressionAlgorithms = exports.LaserCommitmentLevel = void 0;
|
|
27
27
|
const yellowstone_grpc_1 = require("@triton-one/yellowstone-grpc");
|
|
28
28
|
Object.defineProperty(exports, "CommitmentLevel", { enumerable: true, get: function () { return yellowstone_grpc_1.CommitmentLevel; } });
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
// Lazy-loaded module reference for helius-laserstream
|
|
30
|
+
let laserStreamModule = null;
|
|
31
|
+
let laserStreamLoadError = null;
|
|
32
|
+
// Try to load helius-laserstream (it's an optional dependency that may not be available on all platforms)
|
|
33
|
+
async function loadLaserStream() {
|
|
34
|
+
if (laserStreamModule) {
|
|
35
|
+
return laserStreamModule;
|
|
36
|
+
}
|
|
37
|
+
if (laserStreamLoadError) {
|
|
38
|
+
throw laserStreamLoadError;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
laserStreamModule = await Promise.resolve().then(() => __importStar(require('helius-laserstream')));
|
|
42
|
+
return laserStreamModule;
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
laserStreamLoadError = new Error(`helius-laserstream is not available on this platform. ` +
|
|
46
|
+
`LaserStream functionality requires Linux or macOS. ` +
|
|
47
|
+
`Original error: ${err instanceof Error ? err.message : String(err)}`);
|
|
48
|
+
throw laserStreamLoadError;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Lazy getters for LaserStream exports - these throw helpful errors if the module isn't available
|
|
52
|
+
exports.LaserCommitmentLevel = new Proxy({}, {
|
|
53
|
+
get(_target, prop) {
|
|
54
|
+
// Return placeholder values for type checking - actual usage should go through getLaserCommitmentLevel()
|
|
55
|
+
const values = {
|
|
56
|
+
PROCESSED: 0,
|
|
57
|
+
CONFIRMED: 1,
|
|
58
|
+
FINALIZED: 2,
|
|
59
|
+
};
|
|
60
|
+
return values[prop];
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
exports.CompressionAlgorithms = new Proxy({}, {
|
|
64
|
+
get(_target, prop) {
|
|
65
|
+
const values = {
|
|
66
|
+
identity: 0,
|
|
67
|
+
deflate: 1,
|
|
68
|
+
gzip: 2,
|
|
69
|
+
zstd: 3,
|
|
70
|
+
};
|
|
71
|
+
return values[prop];
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
// Async function to get the actual LaserSubscribe function
|
|
75
|
+
async function getLaserSubscribe() {
|
|
76
|
+
const module = await loadLaserStream();
|
|
77
|
+
return module.subscribe;
|
|
78
|
+
}
|
|
79
|
+
exports.getLaserSubscribe = getLaserSubscribe;
|
|
80
|
+
// Async function to get actual LaserCommitmentLevel
|
|
81
|
+
async function getLaserCommitmentLevel() {
|
|
82
|
+
const module = await loadLaserStream();
|
|
83
|
+
return module.CommitmentLevel;
|
|
84
|
+
}
|
|
85
|
+
exports.getLaserCommitmentLevel = getLaserCommitmentLevel;
|
|
86
|
+
// Async function to get actual CompressionAlgorithms
|
|
87
|
+
async function getLaserCompressionAlgorithms() {
|
|
88
|
+
const module = await loadLaserStream();
|
|
89
|
+
return module.CompressionAlgorithms;
|
|
90
|
+
}
|
|
91
|
+
exports.getLaserCompressionAlgorithms = getLaserCompressionAlgorithms;
|
|
92
|
+
let laserSubscribeWarned = false;
|
|
93
|
+
// Backwards-compatible wrapper that lazy-loads the module and warns once.
|
|
94
|
+
function LaserSubscribe(...args) {
|
|
95
|
+
if (!laserSubscribeWarned) {
|
|
96
|
+
laserSubscribeWarned = true;
|
|
97
|
+
console.warn('LaserSubscribe is deprecated. Use getLaserSubscribe() for optional helius-laserstream support.');
|
|
98
|
+
}
|
|
99
|
+
return getLaserSubscribe().then((subscribe) => subscribe(...args));
|
|
100
|
+
}
|
|
101
|
+
exports.LaserSubscribe = LaserSubscribe;
|
|
33
102
|
// Export a function to create a new Client instance
|
|
34
103
|
async function createClient(...args) {
|
|
35
104
|
const { default: Client_ } = await Promise.resolve().then(() => __importStar(require('@triton-one/yellowstone-grpc')));
|
|
@@ -2,9 +2,18 @@ import type Client from '@triton-one/yellowstone-grpc';
|
|
|
2
2
|
import type { SubscribeRequest, SubscribeUpdate } from '@triton-one/yellowstone-grpc';
|
|
3
3
|
import { CommitmentLevel } from '@triton-one/yellowstone-grpc';
|
|
4
4
|
import type { ClientDuplexStream, ChannelOptions } from '@grpc/grpc-js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export type { LaserstreamConfig, SubscribeRequest as LaserSubscribeRequest, SubscribeUpdate as LaserSubscribeUpdate, } from 'helius-laserstream';
|
|
6
|
+
export declare const LaserCommitmentLevel: {
|
|
7
|
+
readonly PROCESSED: 0;
|
|
8
|
+
readonly CONFIRMED: 1;
|
|
9
|
+
readonly FINALIZED: 2;
|
|
10
|
+
};
|
|
11
|
+
export declare const CompressionAlgorithms: typeof import("helius-laserstream").CompressionAlgorithms;
|
|
12
|
+
export declare function getLaserSubscribe(): Promise<typeof import('helius-laserstream').subscribe>;
|
|
13
|
+
export declare function getLaserCommitmentLevel(): Promise<typeof import('helius-laserstream').CommitmentLevel>;
|
|
14
|
+
export declare function getLaserCompressionAlgorithms(): Promise<typeof import('helius-laserstream').CompressionAlgorithms>;
|
|
15
|
+
export declare function LaserSubscribe(...args: Parameters<typeof import('helius-laserstream').subscribe>): ReturnType<typeof import('helius-laserstream').subscribe>;
|
|
16
|
+
export { CommitmentLevel, Client };
|
|
17
|
+
export type { ClientDuplexStream, ChannelOptions, SubscribeRequest, SubscribeUpdate, };
|
|
9
18
|
export declare function createClient(...args: ConstructorParameters<typeof Client>): Promise<Client>;
|
|
10
19
|
//# sourceMappingURL=grpc.node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc.node.d.ts","sourceRoot":"","sources":["../../../src/isomorphic/grpc.node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,8BAA8B,CAAC;AACvD,OAAO,KAAK,EACX,gBAAgB,EAChB,eAAe,EACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"grpc.node.d.ts","sourceRoot":"","sources":["../../../src/isomorphic/grpc.node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,8BAA8B,CAAC;AACvD,OAAO,KAAK,EACX,gBAAgB,EAChB,eAAe,EACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGxE,YAAY,EACX,iBAAiB,EACjB,gBAAgB,IAAI,qBAAqB,EACzC,eAAe,IAAI,oBAAoB,GACvC,MAAM,oBAAoB,CAAC;AA4B5B,eAAO,MAAM,oBAAoB;;;;CAahC,CAAC;AAEF,eAAO,MAAM,qBAAqB,2DAajC,CAAC;AAGF,wBAAsB,iBAAiB,IAAI,OAAO,CACjD,cAAc,oBAAoB,EAAE,SAAS,CAC7C,CAGA;AAGD,wBAAsB,uBAAuB,IAAI,OAAO,CACvD,cAAc,oBAAoB,EAAE,eAAe,CACnD,CAGA;AAGD,wBAAsB,6BAA6B,IAAI,OAAO,CAC7D,cAAc,oBAAoB,EAAE,qBAAqB,CACzD,CAGA;AAKD,wBAAgB,cAAc,CAC7B,GAAG,IAAI,EAAE,UAAU,CAAC,cAAc,oBAAoB,EAAE,SAAS,CAAC,GAChE,UAAU,CAAC,cAAc,oBAAoB,EAAE,SAAS,CAAC,CAQ3D;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC;AACnC,YAAY,EACX,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,eAAe,GACf,CAAC;AAGF,wBAAsB,YAAY,CACjC,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,MAAM,CAAC,GAC3C,OAAO,CAAC,MAAM,CAAC,CAGjB"}
|
|
@@ -23,13 +23,82 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createClient = exports.
|
|
26
|
+
exports.createClient = exports.CommitmentLevel = exports.LaserSubscribe = exports.getLaserCompressionAlgorithms = exports.getLaserCommitmentLevel = exports.getLaserSubscribe = exports.CompressionAlgorithms = exports.LaserCommitmentLevel = void 0;
|
|
27
27
|
const yellowstone_grpc_1 = require("@triton-one/yellowstone-grpc");
|
|
28
28
|
Object.defineProperty(exports, "CommitmentLevel", { enumerable: true, get: function () { return yellowstone_grpc_1.CommitmentLevel; } });
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
// Lazy-loaded module reference for helius-laserstream
|
|
30
|
+
let laserStreamModule = null;
|
|
31
|
+
let laserStreamLoadError = null;
|
|
32
|
+
// Try to load helius-laserstream (it's an optional dependency that may not be available on all platforms)
|
|
33
|
+
async function loadLaserStream() {
|
|
34
|
+
if (laserStreamModule) {
|
|
35
|
+
return laserStreamModule;
|
|
36
|
+
}
|
|
37
|
+
if (laserStreamLoadError) {
|
|
38
|
+
throw laserStreamLoadError;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
laserStreamModule = await Promise.resolve().then(() => __importStar(require('helius-laserstream')));
|
|
42
|
+
return laserStreamModule;
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
laserStreamLoadError = new Error(`helius-laserstream is not available on this platform. ` +
|
|
46
|
+
`LaserStream functionality requires Linux or macOS. ` +
|
|
47
|
+
`Original error: ${err instanceof Error ? err.message : String(err)}`);
|
|
48
|
+
throw laserStreamLoadError;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Lazy getters for LaserStream exports - these throw helpful errors if the module isn't available
|
|
52
|
+
exports.LaserCommitmentLevel = new Proxy({}, {
|
|
53
|
+
get(_target, prop) {
|
|
54
|
+
// Return placeholder values for type checking - actual usage should go through getLaserCommitmentLevel()
|
|
55
|
+
const values = {
|
|
56
|
+
PROCESSED: 0,
|
|
57
|
+
CONFIRMED: 1,
|
|
58
|
+
FINALIZED: 2,
|
|
59
|
+
};
|
|
60
|
+
return values[prop];
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
exports.CompressionAlgorithms = new Proxy({}, {
|
|
64
|
+
get(_target, prop) {
|
|
65
|
+
const values = {
|
|
66
|
+
identity: 0,
|
|
67
|
+
deflate: 1,
|
|
68
|
+
gzip: 2,
|
|
69
|
+
zstd: 3,
|
|
70
|
+
};
|
|
71
|
+
return values[prop];
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
// Async function to get the actual LaserSubscribe function
|
|
75
|
+
async function getLaserSubscribe() {
|
|
76
|
+
const module = await loadLaserStream();
|
|
77
|
+
return module.subscribe;
|
|
78
|
+
}
|
|
79
|
+
exports.getLaserSubscribe = getLaserSubscribe;
|
|
80
|
+
// Async function to get actual LaserCommitmentLevel
|
|
81
|
+
async function getLaserCommitmentLevel() {
|
|
82
|
+
const module = await loadLaserStream();
|
|
83
|
+
return module.CommitmentLevel;
|
|
84
|
+
}
|
|
85
|
+
exports.getLaserCommitmentLevel = getLaserCommitmentLevel;
|
|
86
|
+
// Async function to get actual CompressionAlgorithms
|
|
87
|
+
async function getLaserCompressionAlgorithms() {
|
|
88
|
+
const module = await loadLaserStream();
|
|
89
|
+
return module.CompressionAlgorithms;
|
|
90
|
+
}
|
|
91
|
+
exports.getLaserCompressionAlgorithms = getLaserCompressionAlgorithms;
|
|
92
|
+
let laserSubscribeWarned = false;
|
|
93
|
+
// Backwards-compatible wrapper that lazy-loads the module and warns once.
|
|
94
|
+
function LaserSubscribe(...args) {
|
|
95
|
+
if (!laserSubscribeWarned) {
|
|
96
|
+
laserSubscribeWarned = true;
|
|
97
|
+
console.warn('LaserSubscribe is deprecated. Use getLaserSubscribe() for optional helius-laserstream support.');
|
|
98
|
+
}
|
|
99
|
+
return getLaserSubscribe().then((subscribe) => subscribe(...args));
|
|
100
|
+
}
|
|
101
|
+
exports.LaserSubscribe = LaserSubscribe;
|
|
33
102
|
// Export a function to create a new Client instance
|
|
34
103
|
async function createClient(...args) {
|
|
35
104
|
const { default: Client_ } = await Promise.resolve().then(() => __importStar(require('@triton-one/yellowstone-grpc')));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drift-labs/sdk",
|
|
3
|
-
"version": "2.157.0-beta.
|
|
3
|
+
"version": "2.157.0-beta.1",
|
|
4
4
|
"main": "lib/node/index.js",
|
|
5
5
|
"types": "lib/node/index.d.ts",
|
|
6
6
|
"module": "./lib/browser/index.js",
|
|
@@ -59,7 +59,6 @@
|
|
|
59
59
|
"@triton-one/yellowstone-grpc": "1.4.1",
|
|
60
60
|
"anchor-bankrun": "0.3.0",
|
|
61
61
|
"gill": "^0.10.2",
|
|
62
|
-
"helius-laserstream": "0.1.8",
|
|
63
62
|
"nanoid": "3.3.4",
|
|
64
63
|
"node-cache": "5.1.2",
|
|
65
64
|
"solana-bankrun": "0.3.1",
|
|
@@ -71,6 +70,9 @@
|
|
|
71
70
|
"zod": "4.0.17",
|
|
72
71
|
"zstddec": "0.1.0"
|
|
73
72
|
},
|
|
73
|
+
"optionalDependencies": {
|
|
74
|
+
"helius-laserstream": "0.1.8"
|
|
75
|
+
},
|
|
74
76
|
"devDependencies": {
|
|
75
77
|
"@types/big.js": "6.2.2",
|
|
76
78
|
"@types/bn.js": "5.1.6",
|
|
@@ -6,12 +6,13 @@ import { WebSocketProgramAccountSubscriber } from './webSocketProgramAccountSubs
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
LaserCommitmentLevel,
|
|
9
|
-
LaserSubscribe,
|
|
10
9
|
LaserstreamConfig,
|
|
11
10
|
LaserSubscribeRequest,
|
|
12
11
|
LaserSubscribeUpdate,
|
|
13
|
-
CompressionAlgorithms,
|
|
14
12
|
CommitmentLevel,
|
|
13
|
+
getLaserSubscribe,
|
|
14
|
+
getLaserCompressionAlgorithms,
|
|
15
|
+
getLaserCommitmentLevel,
|
|
15
16
|
} from '../isomorphic/grpc';
|
|
16
17
|
|
|
17
18
|
type LaserCommitment =
|
|
@@ -32,10 +33,12 @@ export class LaserstreamProgramAccountSubscriber<
|
|
|
32
33
|
public listenerId?: number;
|
|
33
34
|
|
|
34
35
|
private readonly laserConfig: LaserstreamConfig;
|
|
36
|
+
private readonly laserCommitmentLevel: typeof LaserCommitmentLevel;
|
|
35
37
|
|
|
36
38
|
private constructor(
|
|
37
39
|
laserConfig: LaserstreamConfig,
|
|
38
40
|
commitmentLevel: CommitmentLevel,
|
|
41
|
+
laserCommitmentLevel: typeof LaserCommitmentLevel,
|
|
39
42
|
subscriptionName: string,
|
|
40
43
|
accountDiscriminator: string,
|
|
41
44
|
program: Program,
|
|
@@ -52,6 +55,7 @@ export class LaserstreamProgramAccountSubscriber<
|
|
|
52
55
|
resubOpts
|
|
53
56
|
);
|
|
54
57
|
this.laserConfig = laserConfig;
|
|
58
|
+
this.laserCommitmentLevel = laserCommitmentLevel;
|
|
55
59
|
this.commitmentLevel = this.toLaserCommitment(commitmentLevel);
|
|
56
60
|
}
|
|
57
61
|
|
|
@@ -66,12 +70,18 @@ export class LaserstreamProgramAccountSubscriber<
|
|
|
66
70
|
},
|
|
67
71
|
resubOpts?: ResubOpts
|
|
68
72
|
): Promise<LaserstreamProgramAccountSubscriber<U>> {
|
|
73
|
+
// Load enums from the optional helius-laserstream module
|
|
74
|
+
const [compressionAlgorithms, laserCommitmentLevel] = await Promise.all([
|
|
75
|
+
getLaserCompressionAlgorithms(),
|
|
76
|
+
getLaserCommitmentLevel(),
|
|
77
|
+
]);
|
|
78
|
+
|
|
69
79
|
const laserConfig: LaserstreamConfig = {
|
|
70
80
|
apiKey: grpcConfigs.token,
|
|
71
81
|
endpoint: grpcConfigs.endpoint,
|
|
72
82
|
maxReconnectAttempts: grpcConfigs.enableReconnect ? 10 : 0,
|
|
73
83
|
channelOptions: {
|
|
74
|
-
'grpc.default_compression_algorithm':
|
|
84
|
+
'grpc.default_compression_algorithm': compressionAlgorithms.zstd,
|
|
75
85
|
'grpc.max_receive_message_length': 1_000_000_000,
|
|
76
86
|
},
|
|
77
87
|
};
|
|
@@ -82,6 +92,7 @@ export class LaserstreamProgramAccountSubscriber<
|
|
|
82
92
|
return new LaserstreamProgramAccountSubscriber<U>(
|
|
83
93
|
laserConfig,
|
|
84
94
|
commitmentLevel,
|
|
95
|
+
laserCommitmentLevel,
|
|
85
96
|
subscriptionName,
|
|
86
97
|
accountDiscriminator,
|
|
87
98
|
program,
|
|
@@ -131,7 +142,10 @@ export class LaserstreamProgramAccountSubscriber<
|
|
|
131
142
|
};
|
|
132
143
|
|
|
133
144
|
try {
|
|
134
|
-
|
|
145
|
+
// Dynamically load LaserSubscribe from the optional helius-laserstream module
|
|
146
|
+
const laserSubscribe = await getLaserSubscribe();
|
|
147
|
+
|
|
148
|
+
const stream = await laserSubscribe(
|
|
135
149
|
this.laserConfig,
|
|
136
150
|
request,
|
|
137
151
|
async (update: LaserSubscribeUpdate) => {
|
|
@@ -206,10 +220,10 @@ export class LaserstreamProgramAccountSubscriber<
|
|
|
206
220
|
): LaserCommitment {
|
|
207
221
|
if (typeof level === 'string') {
|
|
208
222
|
return (
|
|
209
|
-
(
|
|
210
|
-
|
|
223
|
+
(this.laserCommitmentLevel as any)[level.toUpperCase()] ??
|
|
224
|
+
this.laserCommitmentLevel.CONFIRMED
|
|
211
225
|
);
|
|
212
226
|
}
|
|
213
|
-
return (level as LaserCommitment) ??
|
|
227
|
+
return (level as LaserCommitment) ?? this.laserCommitmentLevel.CONFIRMED;
|
|
214
228
|
}
|
|
215
229
|
}
|
|
@@ -6,32 +6,114 @@ import type {
|
|
|
6
6
|
import { CommitmentLevel } from '@triton-one/yellowstone-grpc';
|
|
7
7
|
import type { ClientDuplexStream, ChannelOptions } from '@grpc/grpc-js';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
subscribe as LaserSubscribe,
|
|
12
|
-
CompressionAlgorithms,
|
|
13
|
-
} from 'helius-laserstream';
|
|
14
|
-
import type {
|
|
9
|
+
// Re-export types for helius-laserstream (these are type-only imports so they don't cause runtime errors)
|
|
10
|
+
export type {
|
|
15
11
|
LaserstreamConfig,
|
|
16
12
|
SubscribeRequest as LaserSubscribeRequest,
|
|
17
13
|
SubscribeUpdate as LaserSubscribeUpdate,
|
|
18
14
|
} from 'helius-laserstream';
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
// Lazy-loaded module reference for helius-laserstream
|
|
17
|
+
let laserStreamModule: typeof import('helius-laserstream') | null = null;
|
|
18
|
+
let laserStreamLoadError: Error | null = null;
|
|
19
|
+
|
|
20
|
+
// Try to load helius-laserstream (it's an optional dependency that may not be available on all platforms)
|
|
21
|
+
async function loadLaserStream(): Promise<typeof import('helius-laserstream')> {
|
|
22
|
+
if (laserStreamModule) {
|
|
23
|
+
return laserStreamModule;
|
|
24
|
+
}
|
|
25
|
+
if (laserStreamLoadError) {
|
|
26
|
+
throw laserStreamLoadError;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
laserStreamModule = await import('helius-laserstream');
|
|
30
|
+
return laserStreamModule;
|
|
31
|
+
} catch (err) {
|
|
32
|
+
laserStreamLoadError = new Error(
|
|
33
|
+
`helius-laserstream is not available on this platform. ` +
|
|
34
|
+
`LaserStream functionality requires Linux or macOS. ` +
|
|
35
|
+
`Original error: ${err instanceof Error ? err.message : String(err)}`
|
|
36
|
+
);
|
|
37
|
+
throw laserStreamLoadError;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Lazy getters for LaserStream exports - these throw helpful errors if the module isn't available
|
|
42
|
+
export const LaserCommitmentLevel = new Proxy(
|
|
43
|
+
{} as typeof import('helius-laserstream').CommitmentLevel,
|
|
44
|
+
{
|
|
45
|
+
get(_target, prop) {
|
|
46
|
+
// Return placeholder values for type checking - actual usage should go through getLaserCommitmentLevel()
|
|
47
|
+
const values: Record<string, number> = {
|
|
48
|
+
PROCESSED: 0,
|
|
49
|
+
CONFIRMED: 1,
|
|
50
|
+
FINALIZED: 2,
|
|
51
|
+
};
|
|
52
|
+
return values[prop as string];
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
export const CompressionAlgorithms = new Proxy(
|
|
58
|
+
{} as typeof import('helius-laserstream').CompressionAlgorithms,
|
|
59
|
+
{
|
|
60
|
+
get(_target, prop) {
|
|
61
|
+
const values: Record<string, number> = {
|
|
62
|
+
identity: 0,
|
|
63
|
+
deflate: 1,
|
|
64
|
+
gzip: 2,
|
|
65
|
+
zstd: 3,
|
|
66
|
+
};
|
|
67
|
+
return values[prop as string];
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// Async function to get the actual LaserSubscribe function
|
|
73
|
+
export async function getLaserSubscribe(): Promise<
|
|
74
|
+
typeof import('helius-laserstream').subscribe
|
|
75
|
+
> {
|
|
76
|
+
const module = await loadLaserStream();
|
|
77
|
+
return module.subscribe;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Async function to get actual LaserCommitmentLevel
|
|
81
|
+
export async function getLaserCommitmentLevel(): Promise<
|
|
82
|
+
typeof import('helius-laserstream').CommitmentLevel
|
|
83
|
+
> {
|
|
84
|
+
const module = await loadLaserStream();
|
|
85
|
+
return module.CommitmentLevel;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Async function to get actual CompressionAlgorithms
|
|
89
|
+
export async function getLaserCompressionAlgorithms(): Promise<
|
|
90
|
+
typeof import('helius-laserstream').CompressionAlgorithms
|
|
91
|
+
> {
|
|
92
|
+
const module = await loadLaserStream();
|
|
93
|
+
return module.CompressionAlgorithms;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let laserSubscribeWarned = false;
|
|
97
|
+
|
|
98
|
+
// Backwards-compatible wrapper that lazy-loads the module and warns once.
|
|
99
|
+
export function LaserSubscribe(
|
|
100
|
+
...args: Parameters<typeof import('helius-laserstream').subscribe>
|
|
101
|
+
): ReturnType<typeof import('helius-laserstream').subscribe> {
|
|
102
|
+
if (!laserSubscribeWarned) {
|
|
103
|
+
laserSubscribeWarned = true;
|
|
104
|
+
console.warn(
|
|
105
|
+
'LaserSubscribe is deprecated. Use getLaserSubscribe() for optional helius-laserstream support.'
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
return getLaserSubscribe().then((subscribe) => subscribe(...args));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { CommitmentLevel, Client };
|
|
27
112
|
export type {
|
|
28
113
|
ClientDuplexStream,
|
|
29
114
|
ChannelOptions,
|
|
30
115
|
SubscribeRequest,
|
|
31
116
|
SubscribeUpdate,
|
|
32
|
-
LaserstreamConfig,
|
|
33
|
-
LaserSubscribeRequest,
|
|
34
|
-
LaserSubscribeUpdate,
|
|
35
117
|
};
|
|
36
118
|
|
|
37
119
|
// Export a function to create a new Client instance
|