@clonegod/ttd-sol-common 1.0.5 → 1.0.7
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/dist/index.d.ts +11 -1
- package/dist/index.js +16 -7
- package/package.json +1 -1
- package/types/index.d.ts +1 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
1
3
|
import { StandardPoolInfoType } from '@clonegod/ttd-common';
|
|
2
4
|
export declare const ONE_SOL_IN_LAMPORTS = 1000000000;
|
|
3
|
-
export declare
|
|
5
|
+
export declare enum COMMITMENT_LEVEL {
|
|
6
|
+
PROCESSED = "processed",
|
|
7
|
+
CONFIRMED = "confirmed",
|
|
8
|
+
_FINALIZED = "finalized"
|
|
9
|
+
}
|
|
10
|
+
export declare enum LOCAL_EVENT_KEYS {
|
|
11
|
+
EVENT_POOL_ACCOUNT_CAHNGE = "EVENT_POOL_ACCOUNT_CAHNGE"
|
|
12
|
+
}
|
|
13
|
+
export declare const subscribe_pool_change_by_geyser: (geyser_ws_url: string, pool_list: StandardPoolInfoType[], eventEmitter: EventEmitter) => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -12,12 +12,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.subscribe_pool_change_by_geyser = exports.ONE_SOL_IN_LAMPORTS = void 0;
|
|
16
|
-
const dist_1 = require("@clonegod/ttd-common/dist");
|
|
15
|
+
exports.subscribe_pool_change_by_geyser = exports.LOCAL_EVENT_KEYS = exports.COMMITMENT_LEVEL = exports.ONE_SOL_IN_LAMPORTS = void 0;
|
|
17
16
|
const ws_1 = __importDefault(require("ws"));
|
|
18
|
-
const
|
|
17
|
+
const dist_1 = require("@clonegod/ttd-common/dist");
|
|
19
18
|
exports.ONE_SOL_IN_LAMPORTS = 1e9;
|
|
20
|
-
|
|
19
|
+
var COMMITMENT_LEVEL;
|
|
20
|
+
(function (COMMITMENT_LEVEL) {
|
|
21
|
+
COMMITMENT_LEVEL["PROCESSED"] = "processed";
|
|
22
|
+
COMMITMENT_LEVEL["CONFIRMED"] = "confirmed";
|
|
23
|
+
COMMITMENT_LEVEL["_FINALIZED"] = "finalized";
|
|
24
|
+
})(COMMITMENT_LEVEL || (exports.COMMITMENT_LEVEL = COMMITMENT_LEVEL = {}));
|
|
25
|
+
var LOCAL_EVENT_KEYS;
|
|
26
|
+
(function (LOCAL_EVENT_KEYS) {
|
|
27
|
+
LOCAL_EVENT_KEYS["EVENT_POOL_ACCOUNT_CAHNGE"] = "EVENT_POOL_ACCOUNT_CAHNGE";
|
|
28
|
+
})(LOCAL_EVENT_KEYS || (exports.LOCAL_EVENT_KEYS = LOCAL_EVENT_KEYS = {}));
|
|
29
|
+
const subscribe_pool_change_by_geyser = (geyser_ws_url, pool_list, eventEmitter) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
30
|
if ((0, dist_1.isEmpty)(geyser_ws_url)) {
|
|
22
31
|
(0, dist_1.log_warn)(`geyser_ws_url is empty, cann't subscribe`);
|
|
23
32
|
return;
|
|
@@ -38,7 +47,7 @@ const subscribe_pool_change_by_geyser = (geyser_ws_url, pool_list, callback) =>
|
|
|
38
47
|
pool.pool_address,
|
|
39
48
|
{
|
|
40
49
|
encoding: 'jsonParsed',
|
|
41
|
-
commitment:
|
|
50
|
+
commitment: COMMITMENT_LEVEL.PROCESSED,
|
|
42
51
|
},
|
|
43
52
|
],
|
|
44
53
|
};
|
|
@@ -67,7 +76,7 @@ const subscribe_pool_change_by_geyser = (geyser_ws_url, pool_list, callback) =>
|
|
|
67
76
|
else {
|
|
68
77
|
const res_data = messageObj['params']['result']['value']['data'];
|
|
69
78
|
let data_buff = Buffer.from(res_data[0], res_data[1]);
|
|
70
|
-
|
|
79
|
+
eventEmitter.emit(LOCAL_EVENT_KEYS.EVENT_POOL_ACCOUNT_CAHNGE, data_buff);
|
|
71
80
|
}
|
|
72
81
|
}
|
|
73
82
|
catch (err) {
|
|
@@ -83,7 +92,7 @@ const subscribe_pool_change_by_geyser = (geyser_ws_url, pool_list, callback) =>
|
|
|
83
92
|
ws_client.on('close', function close() {
|
|
84
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
94
|
(0, dist_1.log_warn)(`Socket is closed. Reconnect will be attempted in few seconds`);
|
|
86
|
-
(0, exports.subscribe_pool_change_by_geyser)(geyser_ws_url, pool_list,
|
|
95
|
+
(0, exports.subscribe_pool_change_by_geyser)(geyser_ws_url, pool_list, eventEmitter);
|
|
87
96
|
});
|
|
88
97
|
});
|
|
89
98
|
});
|
package/package.json
CHANGED