@clonegod/ttd-sol-common 1.0.7 → 1.0.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/dist/index.d.ts +2 -2
- package/dist/index.js +11 -7
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare enum COMMITMENT_LEVEL {
|
|
|
7
7
|
CONFIRMED = "confirmed",
|
|
8
8
|
_FINALIZED = "finalized"
|
|
9
9
|
}
|
|
10
|
-
export declare enum
|
|
11
|
-
|
|
10
|
+
export declare enum LOCAL_EVENT_NAME {
|
|
11
|
+
EVENT_POOL_ACCOUNT_CHANGE = "EVENT_POOL_ACCOUNT_CHANGE"
|
|
12
12
|
}
|
|
13
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,7 +12,7 @@ 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.
|
|
15
|
+
exports.subscribe_pool_change_by_geyser = exports.LOCAL_EVENT_NAME = exports.COMMITMENT_LEVEL = exports.ONE_SOL_IN_LAMPORTS = void 0;
|
|
16
16
|
const ws_1 = __importDefault(require("ws"));
|
|
17
17
|
const dist_1 = require("@clonegod/ttd-common/dist");
|
|
18
18
|
exports.ONE_SOL_IN_LAMPORTS = 1e9;
|
|
@@ -22,10 +22,10 @@ var COMMITMENT_LEVEL;
|
|
|
22
22
|
COMMITMENT_LEVEL["CONFIRMED"] = "confirmed";
|
|
23
23
|
COMMITMENT_LEVEL["_FINALIZED"] = "finalized";
|
|
24
24
|
})(COMMITMENT_LEVEL || (exports.COMMITMENT_LEVEL = COMMITMENT_LEVEL = {}));
|
|
25
|
-
var
|
|
26
|
-
(function (
|
|
27
|
-
|
|
28
|
-
})(
|
|
25
|
+
var LOCAL_EVENT_NAME;
|
|
26
|
+
(function (LOCAL_EVENT_NAME) {
|
|
27
|
+
LOCAL_EVENT_NAME["EVENT_POOL_ACCOUNT_CHANGE"] = "EVENT_POOL_ACCOUNT_CHANGE";
|
|
28
|
+
})(LOCAL_EVENT_NAME || (exports.LOCAL_EVENT_NAME = LOCAL_EVENT_NAME = {}));
|
|
29
29
|
const subscribe_pool_change_by_geyser = (geyser_ws_url, pool_list, eventEmitter) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
30
|
if ((0, dist_1.isEmpty)(geyser_ws_url)) {
|
|
31
31
|
(0, dist_1.log_warn)(`geyser_ws_url is empty, cann't subscribe`);
|
|
@@ -38,7 +38,7 @@ const subscribe_pool_change_by_geyser = (geyser_ws_url, pool_list, eventEmitter)
|
|
|
38
38
|
yield (0, dist_1.sleep)(1000);
|
|
39
39
|
var ws_client = new ws_1.default(geyser_ws_url);
|
|
40
40
|
function subscribe_account_change(ws_client, pool) {
|
|
41
|
-
(0, dist_1.log_info)(`subscribe
|
|
41
|
+
(0, dist_1.log_info)(`subscribe: ${pool.pool_name} -> ${pool.pool_address}`);
|
|
42
42
|
const request = {
|
|
43
43
|
jsonrpc: '2.0',
|
|
44
44
|
id: 420,
|
|
@@ -61,9 +61,13 @@ const subscribe_pool_change_by_geyser = (geyser_ws_url, pool_list, eventEmitter)
|
|
|
61
61
|
});
|
|
62
62
|
ws_client.on('message', function incoming(data) {
|
|
63
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
(0, dist_1.log_info)(`Received Geyser Message`);
|
|
64
65
|
let messageStr = '';
|
|
65
66
|
try {
|
|
66
67
|
messageStr = data.toString('utf8');
|
|
68
|
+
if (dist_1.LOG.trace) {
|
|
69
|
+
(0, dist_1.log_trace)(`Received msg:`, messageStr);
|
|
70
|
+
}
|
|
67
71
|
if (messageStr == '{}') {
|
|
68
72
|
(0, dist_1.log_info)(`receive empty message, something wrong! exit ...`);
|
|
69
73
|
ws_client.close();
|
|
@@ -76,7 +80,7 @@ const subscribe_pool_change_by_geyser = (geyser_ws_url, pool_list, eventEmitter)
|
|
|
76
80
|
else {
|
|
77
81
|
const res_data = messageObj['params']['result']['value']['data'];
|
|
78
82
|
let data_buff = Buffer.from(res_data[0], res_data[1]);
|
|
79
|
-
eventEmitter.emit(
|
|
83
|
+
eventEmitter.emit(LOCAL_EVENT_NAME.EVENT_POOL_ACCOUNT_CHANGE, data_buff);
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
86
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clonegod/ttd-sol-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"push": "npm run build && npm publish"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@clonegod/ttd-common": "1.0.
|
|
16
|
+
"@clonegod/ttd-common": "1.0.127"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/bn.js": "~5.1.5",
|