@clonegod/ttd-base-common 1.0.15 → 1.0.17
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.
|
@@ -4,7 +4,8 @@ export declare class BloxrouteBase {
|
|
|
4
4
|
private ws_endpoint;
|
|
5
5
|
private wsClient;
|
|
6
6
|
constructor();
|
|
7
|
+
private initWsConnection;
|
|
7
8
|
sendTransaction(signedTx: string): Promise<string>;
|
|
8
|
-
private sendTransactionByWs;
|
|
9
9
|
private sendTransactionByHttp;
|
|
10
|
+
private sendTransactionByWs;
|
|
10
11
|
}
|
|
@@ -20,6 +20,23 @@ class BloxrouteBase {
|
|
|
20
20
|
this.endpoint = process.env.BASE_BLOXROUTE_RPC_ENDPOINT || 'https://api.blxrbdn.com';
|
|
21
21
|
this.authToken = process.env.BASE_BLOXROUTE_AUTH_TOKEN || '';
|
|
22
22
|
this.ws_endpoint = process.env.BASE_BLOXROUTE_WS_ENDPOINT || 'wss://api.blxrbdn.com/ws';
|
|
23
|
+
this.initWsConnection();
|
|
24
|
+
}
|
|
25
|
+
initWsConnection() {
|
|
26
|
+
if (!this.wsClient) {
|
|
27
|
+
this.wsClient = new dist_1.WebSocketClient(this.ws_endpoint, {
|
|
28
|
+
headers: {
|
|
29
|
+
'Authorization': this.authToken || ''
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
this.wsClient.onOpen(() => {
|
|
33
|
+
(0, dist_1.log_info)('BloXroute Base ws connected:', this.ws_endpoint);
|
|
34
|
+
});
|
|
35
|
+
this.wsClient.onMessage((message) => {
|
|
36
|
+
(0, dist_1.log_info)('BloXroute Base ws message', (0, dist_1.to_json_str)(message));
|
|
37
|
+
});
|
|
38
|
+
this.wsClient.connect();
|
|
39
|
+
}
|
|
23
40
|
}
|
|
24
41
|
sendTransaction(signedTx) {
|
|
25
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -34,43 +51,6 @@ class BloxrouteBase {
|
|
|
34
51
|
return yield this.sendTransactionByHttp(signedTx);
|
|
35
52
|
});
|
|
36
53
|
}
|
|
37
|
-
sendTransactionByWs(signedTx) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
if (!this.ws_endpoint) {
|
|
40
|
-
return '';
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
if (!this.wsClient) {
|
|
44
|
-
this.wsClient = new dist_1.WebSocketClient(this.ws_endpoint, {
|
|
45
|
-
headers: {
|
|
46
|
-
'Authorization': this.authToken || ''
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
this.wsClient.onMessage((message) => {
|
|
50
|
-
console.log('BloXroute Base ws message', message);
|
|
51
|
-
});
|
|
52
|
-
this.wsClient.connect();
|
|
53
|
-
}
|
|
54
|
-
if (!this.wsClient.isConnected()) {
|
|
55
|
-
(0, dist_1.log_warn)('BloXroute Base ws is not connected!!!');
|
|
56
|
-
return '';
|
|
57
|
-
}
|
|
58
|
-
this.wsClient.send(JSON.stringify({
|
|
59
|
-
jsonrpc: "2.0",
|
|
60
|
-
id: "1",
|
|
61
|
-
method: "blxr_tx",
|
|
62
|
-
params: {
|
|
63
|
-
"transaction": signedTx,
|
|
64
|
-
"blockchain_network": "Base-Mainnet"
|
|
65
|
-
}
|
|
66
|
-
}));
|
|
67
|
-
return '';
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
(0, dist_1.log_error)('BloXroute Base sendTransactionByWs failed!!!', error);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
54
|
sendTransactionByHttp(signedTx) {
|
|
75
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
56
|
try {
|
|
@@ -92,7 +72,7 @@ class BloxrouteBase {
|
|
|
92
72
|
if (response.data.error) {
|
|
93
73
|
throw new Error(`BloXroute Base Error: ${response.data.error.code} - ${response.data.error.message}`);
|
|
94
74
|
}
|
|
95
|
-
return response.data.result.
|
|
75
|
+
return response.data.result.txHash;
|
|
96
76
|
}
|
|
97
77
|
catch (error) {
|
|
98
78
|
(0, dist_1.log_error)('BloXroute Base sendPrivateTransaction failed!!!', error);
|
|
@@ -100,5 +80,31 @@ class BloxrouteBase {
|
|
|
100
80
|
}
|
|
101
81
|
});
|
|
102
82
|
}
|
|
83
|
+
sendTransactionByWs(signedTx) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
if (!this.ws_endpoint) {
|
|
86
|
+
return '';
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
if (!this.wsClient || !this.wsClient.isConnected()) {
|
|
90
|
+
(0, dist_1.log_warn)('BloXroute Base ws is not connected!!!');
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
this.wsClient.send(JSON.stringify({
|
|
94
|
+
jsonrpc: "2.0",
|
|
95
|
+
id: "1",
|
|
96
|
+
method: "blxr_tx",
|
|
97
|
+
params: {
|
|
98
|
+
"transaction": signedTx,
|
|
99
|
+
"blockchain_network": "Base-Mainnet"
|
|
100
|
+
}
|
|
101
|
+
}));
|
|
102
|
+
return '';
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
(0, dist_1.log_error)('BloXroute Base sendTransactionByWs failed!!!', error);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
103
109
|
}
|
|
104
110
|
exports.BloxrouteBase = BloxrouteBase;
|
|
@@ -119,7 +119,7 @@ class BaseTransactionSender {
|
|
|
119
119
|
})
|
|
120
120
|
},
|
|
121
121
|
{
|
|
122
|
-
name: 'BloXroute
|
|
122
|
+
name: 'BloXroute RPC|WS',
|
|
123
123
|
enable: process.env.SEND_TX_BLOXROUTE_RPC === 'true',
|
|
124
124
|
send: () => __awaiter(this, void 0, void 0, function* () {
|
|
125
125
|
return yield this.bloxroute.sendTransaction(signedMainTx);
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
2
|
+
"name": "@clonegod/ttd-base-common",
|
|
3
|
+
"version": "1.0.17",
|
|
4
|
+
"description": "Base common library",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"clean": "rm -rf dist node_modules",
|
|
13
|
+
"build": "yarn tsc --outDir ./dist",
|
|
14
|
+
"push": "npm run build && npm publish"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@clonegod/ttd-core": "2.0.85",
|
|
18
|
+
"axios": "^1.12.0",
|
|
19
|
+
"dotenv": "^16.4.7",
|
|
20
|
+
"ethers": "^5.8.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^22.14.0",
|
|
24
|
+
"typescript": "^5.8.2"
|
|
25
|
+
},
|
|
26
|
+
"overrides": {},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
}
|
|
30
30
|
}
|