@bithomp/xrpl-api 3.1.9 → 3.1.11
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
CHANGED
|
@@ -29,7 +29,7 @@ declare class Connection extends EventEmitter {
|
|
|
29
29
|
private client?;
|
|
30
30
|
readonly url: string;
|
|
31
31
|
readonly type?: string;
|
|
32
|
-
|
|
32
|
+
types: string[];
|
|
33
33
|
latency: LatencyInfo[];
|
|
34
34
|
readonly logger?: any;
|
|
35
35
|
readonly timeout?: number;
|
|
@@ -59,6 +59,7 @@ declare class Connection extends EventEmitter {
|
|
|
59
59
|
private reconnect;
|
|
60
60
|
private removeClient;
|
|
61
61
|
private setupEmitter;
|
|
62
|
+
private updateTypes;
|
|
62
63
|
private updateSubscriptions;
|
|
63
64
|
private subscribe;
|
|
64
65
|
private unsubscribe;
|
package/lib/connection.js
CHANGED
|
@@ -18,6 +18,7 @@ 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.types = [];
|
|
21
22
|
this.latency = [];
|
|
22
23
|
this.onlineSince = null;
|
|
23
24
|
this.serverInfo = {};
|
|
@@ -26,12 +27,7 @@ class Connection extends events_1.EventEmitter {
|
|
|
26
27
|
this.shutdown = false;
|
|
27
28
|
this.url = url;
|
|
28
29
|
this.type = type;
|
|
29
|
-
|
|
30
|
-
this.types = this.type.split(",").map((v) => v.trim());
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
this.types = [];
|
|
34
|
-
}
|
|
30
|
+
this.updateTypes();
|
|
35
31
|
this.client = null;
|
|
36
32
|
this.logger = options.logger;
|
|
37
33
|
this.timeout = options.timeout;
|
|
@@ -59,7 +55,6 @@ class Connection extends events_1.EventEmitter {
|
|
|
59
55
|
});
|
|
60
56
|
await this.removeClient();
|
|
61
57
|
this.client = new xrpl_1.Client(this.url, (0, common_1.removeUndefined)({ timeout: this.timeout, connectionTimeout: this.connectionTimeout }));
|
|
62
|
-
this.client.apiVersion = this.apiVersion;
|
|
63
58
|
this.setupEmitter();
|
|
64
59
|
await this.client.connection.connect();
|
|
65
60
|
await this.updateServerInfo();
|
|
@@ -89,7 +84,7 @@ class Connection extends events_1.EventEmitter {
|
|
|
89
84
|
return this.updateSubscriptions(request);
|
|
90
85
|
}
|
|
91
86
|
const waitTime = (0, utils_1.getTimestamp)() + RECONNECT_TIMEOUT;
|
|
92
|
-
while (
|
|
87
|
+
while (!this.client || !this.isConnected()) {
|
|
93
88
|
await (0, utils_1.sleep)(100);
|
|
94
89
|
if (this.shutdown) {
|
|
95
90
|
return { error: "shutdownConnection", error_message: "Connection is shutdown.", status: "error" };
|
|
@@ -201,6 +196,8 @@ class Connection extends events_1.EventEmitter {
|
|
|
201
196
|
try {
|
|
202
197
|
await this.removeClient();
|
|
203
198
|
await (0, utils_1.sleep)(RECONNECT_TIMEOUT);
|
|
199
|
+
this.updateTypes();
|
|
200
|
+
this.serverInfoUpdating = false;
|
|
204
201
|
await this.connect();
|
|
205
202
|
}
|
|
206
203
|
catch (e) {
|
|
@@ -292,6 +289,14 @@ class Connection extends events_1.EventEmitter {
|
|
|
292
289
|
this.emit("path_find", path);
|
|
293
290
|
});
|
|
294
291
|
}
|
|
292
|
+
updateTypes() {
|
|
293
|
+
if (typeof this.type === "string") {
|
|
294
|
+
this.types = this.type.split(",").map((v) => v.trim());
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
this.types = [];
|
|
298
|
+
}
|
|
299
|
+
}
|
|
295
300
|
async updateSubscriptions(request) {
|
|
296
301
|
if (request.command === "subscribe") {
|
|
297
302
|
const addStreams = [];
|
package/lib/ledger/vl.js
CHANGED
|
@@ -26,7 +26,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.createVL = createVL;
|
|
27
27
|
exports.createVLBlob = createVLBlob;
|
|
28
28
|
exports.getVLBlobValidatorsManifest = getVLBlobValidatorsManifest;
|
|
29
|
+
const ripple_address_codec_1 = require("ripple-address-codec");
|
|
29
30
|
const Client = __importStar(require("../client"));
|
|
31
|
+
const utils_1 = require("../parse/utils");
|
|
30
32
|
const vl_1 = require("../models/vl");
|
|
31
33
|
const manifest_1 = require("../models/manifest");
|
|
32
34
|
const ledger_1 = require("../models/ledger");
|
|
@@ -101,9 +103,11 @@ async function getVLBlobValidatorsManifest(validatorsPublicKeys) {
|
|
|
101
103
|
}));
|
|
102
104
|
const validators = validatorsManifests.map((info) => {
|
|
103
105
|
const validationPublicKey = info.requested;
|
|
106
|
+
const publicKeyBuffer = (0, ripple_address_codec_1.decodeNodePublic)(validationPublicKey);
|
|
107
|
+
const publicKey = (0, utils_1.bytesToHex)(publicKeyBuffer.buffer);
|
|
104
108
|
const manifest = info.manifest;
|
|
105
109
|
return {
|
|
106
|
-
validation_public_key:
|
|
110
|
+
validation_public_key: publicKey,
|
|
107
111
|
manifest,
|
|
108
112
|
};
|
|
109
113
|
});
|
|
@@ -43,7 +43,7 @@ function parsePayment(tx) {
|
|
|
43
43
|
assert.ok(tx.TransactionType === "Payment");
|
|
44
44
|
const source = {
|
|
45
45
|
address: tx.Account,
|
|
46
|
-
maxAmount: (0, utils_1.removeGenericCounterparty)((0, amount_1.default)(tx.SendMax || tx.Amount), tx.Account),
|
|
46
|
+
maxAmount: (0, utils_1.removeGenericCounterparty)((0, amount_1.default)(tx.SendMax || tx.DeliverMax || tx.Amount), tx.Account),
|
|
47
47
|
tag: tx.SourceTag,
|
|
48
48
|
};
|
|
49
49
|
const destination = {
|
package/lib/parse/transaction.js
CHANGED
|
@@ -158,6 +158,7 @@ function parseTransaction(tx, includeRawTransaction, nativeCurrency, definitions
|
|
|
158
158
|
type: type,
|
|
159
159
|
address: (0, account_1.parseAccount)(tx.Account),
|
|
160
160
|
sequence: tx.Sequence,
|
|
161
|
+
ticketSequence: tx.TicketSequence,
|
|
161
162
|
id: tx.hash,
|
|
162
163
|
ctid: tx.ctid,
|
|
163
164
|
specification: (0, common_1.removeUndefined)(specification),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bithomp/xrpl-api",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.11",
|
|
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",
|
|
@@ -64,19 +64,19 @@
|
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/chai": "^4.3.19",
|
|
66
66
|
"@types/chai-as-promised": "^7.1.8",
|
|
67
|
-
"@types/lodash": "^4.17.
|
|
68
|
-
"@types/mocha": "^10.0.
|
|
67
|
+
"@types/lodash": "^4.17.10",
|
|
68
|
+
"@types/mocha": "^10.0.9",
|
|
69
69
|
"@types/nconf": "^0.10.7",
|
|
70
70
|
"@types/node": "^20.14.15",
|
|
71
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
72
|
-
"@typescript-eslint/parser": "^8.
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "^8.9.0",
|
|
72
|
+
"@typescript-eslint/parser": "^8.9.0",
|
|
73
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
77
|
"eslint-plugin-chai-friendly": "^1.0.1",
|
|
78
|
-
"eslint-plugin-import": "^2.
|
|
79
|
-
"eslint-plugin-n": "^17.
|
|
78
|
+
"eslint-plugin-import": "^2.31.0",
|
|
79
|
+
"eslint-plugin-n": "^17.11.1",
|
|
80
80
|
"eslint-plugin-promise": "^7.1.0",
|
|
81
81
|
"mocha": "^10.7.3",
|
|
82
82
|
"nconf": "^0.12.1",
|