@bithomp/xrpl-api 3.1.1 → 3.1.3
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/lib/connection.d.ts +2 -0
- package/lib/connection.js +10 -1
- package/lib/ledger/account_tx.js +8 -2
- package/package.json +14 -14
package/lib/connection.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ declare class Connection extends EventEmitter {
|
|
|
35
35
|
readonly timeout?: number;
|
|
36
36
|
readonly connectionTimeout: number;
|
|
37
37
|
readonly hash?: string;
|
|
38
|
+
private onlineSince;
|
|
38
39
|
private networkID?;
|
|
39
40
|
private apiVersion;
|
|
40
41
|
private serverInfoUpdating;
|
|
@@ -50,6 +51,7 @@ declare class Connection extends EventEmitter {
|
|
|
50
51
|
request(request: Request, options?: any): Promise<Response | any>;
|
|
51
52
|
submit(transaction: string): Promise<Response | any>;
|
|
52
53
|
isConnected(): boolean;
|
|
54
|
+
getOnlinePeriodMs(): number | null;
|
|
53
55
|
getLatencyMs(): number;
|
|
54
56
|
getNetworkID(): number | undefined;
|
|
55
57
|
isLedgerIndexAvailable(ledgerIndex: any): boolean;
|
package/lib/connection.js
CHANGED
|
@@ -18,6 +18,8 @@ exports.DEFAULT_API_VERSION = xrpl_1.RIPPLED_API_V1;
|
|
|
18
18
|
class Connection extends events_1.EventEmitter {
|
|
19
19
|
constructor(url, type, options = {}) {
|
|
20
20
|
super();
|
|
21
|
+
this.latency = [];
|
|
22
|
+
this.onlineSince = null;
|
|
21
23
|
this.serverInfo = {};
|
|
22
24
|
this.shutdown = false;
|
|
23
25
|
this.connectionTimer = null;
|
|
@@ -30,7 +32,6 @@ class Connection extends events_1.EventEmitter {
|
|
|
30
32
|
else {
|
|
31
33
|
this.types = [];
|
|
32
34
|
}
|
|
33
|
-
this.latency = [];
|
|
34
35
|
this.client = null;
|
|
35
36
|
this.logger = options.logger;
|
|
36
37
|
this.timeout = options.timeout;
|
|
@@ -138,6 +139,12 @@ class Connection extends events_1.EventEmitter {
|
|
|
138
139
|
}
|
|
139
140
|
return this.client.isConnected();
|
|
140
141
|
}
|
|
142
|
+
getOnlinePeriodMs() {
|
|
143
|
+
if (this.isConnected()) {
|
|
144
|
+
return this.onlineSince ? new Date().getTime() - this.onlineSince : 0;
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
141
148
|
getLatencyMs() {
|
|
142
149
|
return this.latency.map((info) => info.delta).reduce((a, b) => a + b, 0) / this.latency.length || 0;
|
|
143
150
|
}
|
|
@@ -219,6 +226,7 @@ class Connection extends events_1.EventEmitter {
|
|
|
219
226
|
url: this.url,
|
|
220
227
|
});
|
|
221
228
|
this.emit("connected");
|
|
229
|
+
this.onlineSince = new Date().getTime();
|
|
222
230
|
});
|
|
223
231
|
this.client.on("disconnected", (code) => {
|
|
224
232
|
this.logger?.debug({
|
|
@@ -227,6 +235,7 @@ class Connection extends events_1.EventEmitter {
|
|
|
227
235
|
code,
|
|
228
236
|
url: this.url,
|
|
229
237
|
});
|
|
238
|
+
this.onlineSince = 0;
|
|
230
239
|
this.serverInfo = null;
|
|
231
240
|
this.streamsSubscribed = false;
|
|
232
241
|
this.emit("disconnected", code);
|
package/lib/ledger/account_tx.js
CHANGED
|
@@ -188,10 +188,16 @@ async function applyStartTxOptions(options) {
|
|
|
188
188
|
meta: accountTransaction.meta,
|
|
189
189
|
};
|
|
190
190
|
if (options.forward === true) {
|
|
191
|
-
|
|
191
|
+
const ledgerIndex = options.startTx.tx.ledger_index;
|
|
192
|
+
if (options.ledgerIndexMin === undefined || ledgerIndex > options.ledgerIndexMin) {
|
|
193
|
+
options.ledgerIndexMin = ledgerIndex;
|
|
194
|
+
}
|
|
192
195
|
}
|
|
193
196
|
else {
|
|
194
|
-
|
|
197
|
+
const ledgerIndex = options.startTx.tx.ledger_index;
|
|
198
|
+
if (options.ledgerIndexMax === undefined || ledgerIndex < options.ledgerIndexMax) {
|
|
199
|
+
options.ledgerIndexMax = ledgerIndex;
|
|
200
|
+
}
|
|
195
201
|
}
|
|
196
202
|
}
|
|
197
203
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bithomp/xrpl-api",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "A Bithomp JavaScript/TypeScript library for interacting with the XRP Ledger",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -52,35 +52,35 @@
|
|
|
52
52
|
"lib/**/*"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"axios": "^1.7.
|
|
55
|
+
"axios": "^1.7.4",
|
|
56
56
|
"base-x": "^5.0.0",
|
|
57
57
|
"bignumber.js": "^9.1.2",
|
|
58
|
-
"elliptic": "^6.5.
|
|
58
|
+
"elliptic": "^6.5.7",
|
|
59
59
|
"lodash": "^4.17.21",
|
|
60
60
|
"ripple-address-codec": "^5.0.0",
|
|
61
61
|
"ripple-binary-codec": "^2.1.0",
|
|
62
62
|
"xrpl": "^4.0.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@types/chai": "^4.3.
|
|
65
|
+
"@types/chai": "^4.3.17",
|
|
66
66
|
"@types/chai-as-promised": "^7.1.8",
|
|
67
67
|
"@types/lodash": "^4.17.7",
|
|
68
68
|
"@types/mocha": "^10.0.7",
|
|
69
|
-
"@types/nconf": "^0.10.
|
|
70
|
-
"@types/node": "^20.14.
|
|
71
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
72
|
-
"@typescript-eslint/parser": "^
|
|
73
|
-
"chai": "^4.
|
|
69
|
+
"@types/nconf": "^0.10.7",
|
|
70
|
+
"@types/node": "^20.14.15",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "^8.1.0",
|
|
72
|
+
"@typescript-eslint/parser": "^8.1.0",
|
|
73
|
+
"chai": "^4.5.0",
|
|
74
74
|
"chai-as-promised": "^7.1.2",
|
|
75
75
|
"eslint": "^8.57.0",
|
|
76
76
|
"eslint-config-prettier": "^9.1.0",
|
|
77
|
-
"eslint-plugin-chai-friendly": "^1.0.
|
|
77
|
+
"eslint-plugin-chai-friendly": "^1.0.1",
|
|
78
78
|
"eslint-plugin-import": "^2.29.1",
|
|
79
|
-
"eslint-plugin-n": "^17.
|
|
80
|
-
"eslint-plugin-promise": "^
|
|
81
|
-
"mocha": "^10.7.
|
|
79
|
+
"eslint-plugin-n": "^17.10.2",
|
|
80
|
+
"eslint-plugin-promise": "^7.1.0",
|
|
81
|
+
"mocha": "^10.7.3",
|
|
82
82
|
"nconf": "^0.12.1",
|
|
83
|
-
"ts-jest": "^29.2.
|
|
83
|
+
"ts-jest": "^29.2.4",
|
|
84
84
|
"ts-node": "^10.9.2",
|
|
85
85
|
"typescript": "^5.4.5"
|
|
86
86
|
}
|