@bithomp/xrpl-api 3.2.28 → 3.3.2
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.js +50 -16
- package/lib/ledger/account_info.js +5 -3
- package/lib/ledger/account_lines.js +5 -3
- package/lib/ledger/account_namespace.js +5 -3
- package/lib/ledger/account_nfts.js +17 -12
- package/lib/ledger/account_objects.js +8 -6
- package/lib/ledger/account_offers.js +9 -6
- package/lib/ledger/account_tx.js +4 -3
- package/lib/ledger/amm_info.js +9 -6
- package/lib/ledger/book_offers.js +5 -3
- package/lib/ledger/gateway_balances.js +9 -6
- package/lib/ledger/ledger.js +5 -3
- package/lib/ledger/ledger_entry.js +4 -3
- package/lib/ledger/manifest.js +5 -3
- package/lib/ledger/nft_info.js +5 -3
- package/lib/ledger/server_definitions.js +5 -3
- package/lib/ledger/server_info.js +5 -3
- package/lib/ledger/transaction.js +4 -3
- package/lib/models/account_object.js +15 -8
- package/lib/models/amm_info.d.ts +1 -0
- package/lib/models/amm_info.js +4 -0
- package/lib/models/base_model.d.ts +1 -0
- package/package.json +9 -9
package/lib/connection.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -10,6 +43,7 @@ const xrpl_1 = require("xrpl");
|
|
|
10
43
|
const ledger_1 = require("./models/ledger");
|
|
11
44
|
const common_1 = require("./common");
|
|
12
45
|
const utils_1 = require("./common/utils");
|
|
46
|
+
const XRPLConnection = __importStar(require("xrpl/dist/npm/client/connection"));
|
|
13
47
|
const RECONNECT_TIMEOUT = 1000 * 5;
|
|
14
48
|
const LEDGER_CLOSED_TIMEOUT = 1000 * 15;
|
|
15
49
|
const SERVER_INFO_UPDATE_INTERVAL = 1000 * 60 * 5;
|
|
@@ -54,9 +88,9 @@ class Connection extends events_1.EventEmitter {
|
|
|
54
88
|
shutdown: this.shutdown,
|
|
55
89
|
});
|
|
56
90
|
await this.removeClient();
|
|
57
|
-
this.client = new
|
|
91
|
+
this.client = new XRPLConnection.Connection(this.url, (0, common_1.removeUndefined)({ timeout: this.timeout, connectionTimeout: this.connectionTimeout }));
|
|
58
92
|
this.setupEmitter();
|
|
59
|
-
await this.client.
|
|
93
|
+
await this.client.connect();
|
|
60
94
|
await this.updateServerInfo();
|
|
61
95
|
await this.subscribe();
|
|
62
96
|
}
|
|
@@ -97,7 +131,7 @@ class Connection extends events_1.EventEmitter {
|
|
|
97
131
|
if (this.apiVersion && !request.hasOwnProperty("api_version") && exports.DEFAULT_API_VERSION !== this.apiVersion) {
|
|
98
132
|
request.api_version = this.apiVersion;
|
|
99
133
|
}
|
|
100
|
-
const response = await this.client.
|
|
134
|
+
const response = await this.client.request(request);
|
|
101
135
|
this.updateLatency((0, utils_1.getTimestamp)() - startTimestamp);
|
|
102
136
|
this.connectionValidation();
|
|
103
137
|
return response;
|
|
@@ -145,7 +179,7 @@ class Connection extends events_1.EventEmitter {
|
|
|
145
179
|
if (!this.client) {
|
|
146
180
|
return false;
|
|
147
181
|
}
|
|
148
|
-
return this.client.
|
|
182
|
+
return this.client.isConnected();
|
|
149
183
|
}
|
|
150
184
|
getOnlinePeriodMs() {
|
|
151
185
|
if (this.isConnected()) {
|
|
@@ -218,8 +252,8 @@ class Connection extends events_1.EventEmitter {
|
|
|
218
252
|
async removeClient() {
|
|
219
253
|
try {
|
|
220
254
|
if (this.client) {
|
|
221
|
-
await this.client.
|
|
222
|
-
this.client.
|
|
255
|
+
await this.client.disconnect();
|
|
256
|
+
this.client.removeAllListeners();
|
|
223
257
|
this.client = undefined;
|
|
224
258
|
}
|
|
225
259
|
}
|
|
@@ -230,7 +264,7 @@ class Connection extends events_1.EventEmitter {
|
|
|
230
264
|
if (!this.client) {
|
|
231
265
|
return;
|
|
232
266
|
}
|
|
233
|
-
this.client.
|
|
267
|
+
this.client.on("connected", () => {
|
|
234
268
|
this.logger?.debug({
|
|
235
269
|
service: "Bithomp::XRPL::Connection",
|
|
236
270
|
emit: "connected",
|
|
@@ -239,7 +273,7 @@ class Connection extends events_1.EventEmitter {
|
|
|
239
273
|
this.emit("connected");
|
|
240
274
|
this.onlineSince = (0, utils_1.getTimestamp)();
|
|
241
275
|
});
|
|
242
|
-
this.client.
|
|
276
|
+
this.client.on("disconnected", (code) => {
|
|
243
277
|
this.logger?.debug({
|
|
244
278
|
service: "Bithomp::XRPL::Connection",
|
|
245
279
|
emit: "disconnected",
|
|
@@ -251,7 +285,7 @@ class Connection extends events_1.EventEmitter {
|
|
|
251
285
|
this.streamsSubscribed = false;
|
|
252
286
|
this.emit("disconnected", code);
|
|
253
287
|
});
|
|
254
|
-
this.client.
|
|
288
|
+
this.client.on("error", (source, message, error) => {
|
|
255
289
|
try {
|
|
256
290
|
this.logger?.error({
|
|
257
291
|
service: "Bithomp::XRPL::Connection",
|
|
@@ -272,26 +306,26 @@ class Connection extends events_1.EventEmitter {
|
|
|
272
306
|
}
|
|
273
307
|
this.connectionValidation();
|
|
274
308
|
});
|
|
275
|
-
this.client.
|
|
309
|
+
this.client.on("ledgerClosed", (ledgerStream) => {
|
|
276
310
|
this.onLedgerClosed(ledgerStream);
|
|
277
311
|
this.emit("ledgerClosed", ledgerStream);
|
|
278
312
|
});
|
|
279
|
-
this.client.
|
|
313
|
+
this.client.on("transaction", (transactionStream) => {
|
|
280
314
|
this.emit("transaction", transactionStream);
|
|
281
315
|
});
|
|
282
|
-
this.client.
|
|
316
|
+
this.client.on("validationReceived", (validation) => {
|
|
283
317
|
this.emit("validationReceived", validation);
|
|
284
318
|
});
|
|
285
|
-
this.client.
|
|
319
|
+
this.client.on("manifestReceived", (manifest) => {
|
|
286
320
|
this.emit("manifestReceived", manifest);
|
|
287
321
|
});
|
|
288
|
-
this.client.
|
|
322
|
+
this.client.on("peerStatusChange", (status) => {
|
|
289
323
|
this.emit("peerStatusChange", status);
|
|
290
324
|
});
|
|
291
|
-
this.client.
|
|
325
|
+
this.client.on("consensusPhase", (consensus) => {
|
|
292
326
|
this.emit("consensusPhase", consensus);
|
|
293
327
|
});
|
|
294
|
-
this.client.
|
|
328
|
+
this.client.on("path_find", (path) => {
|
|
295
329
|
this.emit("path_find", path);
|
|
296
330
|
});
|
|
297
331
|
}
|
|
@@ -38,6 +38,7 @@ exports.getAccountInfoData = getAccountInfoData;
|
|
|
38
38
|
exports.isActivated = isActivated;
|
|
39
39
|
const Client = __importStar(require("../client"));
|
|
40
40
|
const account_info_1 = require("../parse/ledger/account-info");
|
|
41
|
+
const common_1 = require("../common");
|
|
41
42
|
async function getAccountInfo(account, options = {}) {
|
|
42
43
|
const connection = options.connection || Client.findConnection();
|
|
43
44
|
if (!connection) {
|
|
@@ -57,15 +58,16 @@ async function getAccountInfo(account, options = {}) {
|
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
if (response.error) {
|
|
60
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
61
|
-
return {
|
|
61
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
62
|
+
return (0, common_1.removeUndefined)({
|
|
62
63
|
account,
|
|
63
64
|
error,
|
|
64
65
|
error_code,
|
|
65
66
|
error_message,
|
|
67
|
+
error_exception,
|
|
66
68
|
status,
|
|
67
69
|
validated,
|
|
68
|
-
};
|
|
70
|
+
});
|
|
69
71
|
}
|
|
70
72
|
const result = response.result;
|
|
71
73
|
if (!result) {
|
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.getAccountLines = getAccountLines;
|
|
37
37
|
const Client = __importStar(require("../client"));
|
|
38
38
|
const utils_1 = require("../common/utils");
|
|
39
|
+
const common_1 = require("../common");
|
|
39
40
|
async function getAccountLines(account, options = {}) {
|
|
40
41
|
const { hash, marker } = (0, utils_1.parseMarker)(options.marker);
|
|
41
42
|
options.marker = marker;
|
|
@@ -58,15 +59,16 @@ async function getAccountLines(account, options = {}) {
|
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
if (response.error) {
|
|
61
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
62
|
-
return {
|
|
62
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
63
|
+
return (0, common_1.removeUndefined)({
|
|
63
64
|
account,
|
|
64
65
|
error,
|
|
65
66
|
error_code,
|
|
66
67
|
error_message,
|
|
68
|
+
error_exception,
|
|
67
69
|
status,
|
|
68
70
|
validated,
|
|
69
|
-
};
|
|
71
|
+
});
|
|
70
72
|
}
|
|
71
73
|
const result = response.result;
|
|
72
74
|
if (options.currency || options.issuer) {
|
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.getAccountNamespace = getAccountNamespace;
|
|
37
37
|
const Client = __importStar(require("../client"));
|
|
38
|
+
const common_1 = require("../common");
|
|
38
39
|
async function getAccountNamespace(account, namespaceId, options = {}) {
|
|
39
40
|
const connection = Client.findConnection();
|
|
40
41
|
if (!connection) {
|
|
@@ -54,16 +55,17 @@ async function getAccountNamespace(account, namespaceId, options = {}) {
|
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
if (response.error) {
|
|
57
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
58
|
-
return {
|
|
58
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
59
|
+
return (0, common_1.removeUndefined)({
|
|
59
60
|
account,
|
|
60
61
|
namespace_id: namespaceId,
|
|
61
62
|
error,
|
|
62
63
|
error_code,
|
|
63
64
|
error_message,
|
|
65
|
+
error_exception,
|
|
64
66
|
status,
|
|
65
67
|
validated,
|
|
66
|
-
};
|
|
68
|
+
});
|
|
67
69
|
}
|
|
68
70
|
const result = response.result;
|
|
69
71
|
return result;
|
|
@@ -40,6 +40,7 @@ exports.getAccountNftBuyOffers = getAccountNftBuyOffers;
|
|
|
40
40
|
const Client = __importStar(require("../client"));
|
|
41
41
|
const account_nfts_1 = require("../models/account_nfts");
|
|
42
42
|
const utils_1 = require("../common/utils");
|
|
43
|
+
const common_1 = require("../common");
|
|
43
44
|
async function getAccountNfts(account, options = {}) {
|
|
44
45
|
const { hash, marker } = (0, utils_1.parseMarker)(options.marker);
|
|
45
46
|
options.marker = marker;
|
|
@@ -61,15 +62,16 @@ async function getAccountNfts(account, options = {}) {
|
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
if (response.error) {
|
|
64
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
65
|
-
return {
|
|
65
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
66
|
+
return (0, common_1.removeUndefined)({
|
|
66
67
|
account,
|
|
67
68
|
error,
|
|
68
69
|
error_code,
|
|
69
70
|
error_message,
|
|
71
|
+
error_exception,
|
|
70
72
|
status,
|
|
71
73
|
validated,
|
|
72
|
-
};
|
|
74
|
+
});
|
|
73
75
|
}
|
|
74
76
|
const result = response?.result;
|
|
75
77
|
if (!result) {
|
|
@@ -119,15 +121,16 @@ async function findAccountNfts(account, options = { timeout: 15000 }) {
|
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
123
|
if (response.error) {
|
|
122
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
123
|
-
return {
|
|
124
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
125
|
+
return (0, common_1.removeUndefined)({
|
|
124
126
|
account,
|
|
125
127
|
error,
|
|
126
128
|
error_code,
|
|
127
129
|
error_message,
|
|
130
|
+
error_exception,
|
|
128
131
|
status,
|
|
129
132
|
validated,
|
|
130
|
-
};
|
|
133
|
+
});
|
|
131
134
|
}
|
|
132
135
|
response.account_nfts = accountNfts;
|
|
133
136
|
return response;
|
|
@@ -150,15 +153,16 @@ async function getAccountNftSellOffers(nftID, options = {}) {
|
|
|
150
153
|
};
|
|
151
154
|
}
|
|
152
155
|
if (response.error) {
|
|
153
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
154
|
-
return {
|
|
156
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
157
|
+
return (0, common_1.removeUndefined)({
|
|
155
158
|
nft_id: nftID,
|
|
156
159
|
error,
|
|
157
160
|
error_code,
|
|
158
161
|
error_message,
|
|
162
|
+
error_exception,
|
|
159
163
|
status,
|
|
160
164
|
validated,
|
|
161
|
-
};
|
|
165
|
+
});
|
|
162
166
|
}
|
|
163
167
|
return response?.result;
|
|
164
168
|
}
|
|
@@ -180,15 +184,16 @@ async function getAccountNftBuyOffers(nftID, options = {}) {
|
|
|
180
184
|
};
|
|
181
185
|
}
|
|
182
186
|
if (response.error) {
|
|
183
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
184
|
-
return {
|
|
187
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
188
|
+
return (0, common_1.removeUndefined)({
|
|
185
189
|
nft_id: nftID,
|
|
186
190
|
error,
|
|
187
191
|
error_code,
|
|
188
192
|
error_message,
|
|
193
|
+
error_exception,
|
|
189
194
|
status,
|
|
190
195
|
validated,
|
|
191
|
-
};
|
|
196
|
+
});
|
|
192
197
|
}
|
|
193
198
|
return response?.result;
|
|
194
199
|
}
|
|
@@ -70,15 +70,16 @@ async function getAccountObjects(account, options = {}) {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
if (response.error) {
|
|
73
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
74
|
-
return {
|
|
73
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
74
|
+
return (0, utils_1.removeUndefined)({
|
|
75
75
|
account,
|
|
76
76
|
error,
|
|
77
77
|
error_code,
|
|
78
78
|
error_message,
|
|
79
|
+
error_exception,
|
|
79
80
|
status,
|
|
80
81
|
validated,
|
|
81
|
-
};
|
|
82
|
+
});
|
|
82
83
|
}
|
|
83
84
|
const result = response.result;
|
|
84
85
|
const newMarker = (0, utils_1.createMarker)(connection.hash, result.marker);
|
|
@@ -128,15 +129,16 @@ async function getAccountAllObjects(account, options = {}) {
|
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
if (response.error) {
|
|
131
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
132
|
-
return {
|
|
132
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
133
|
+
return (0, utils_1.removeUndefined)({
|
|
133
134
|
account,
|
|
134
135
|
error,
|
|
135
136
|
error_code,
|
|
136
137
|
error_message,
|
|
138
|
+
error_exception,
|
|
137
139
|
status,
|
|
138
140
|
validated,
|
|
139
|
-
};
|
|
141
|
+
});
|
|
140
142
|
}
|
|
141
143
|
response.account_objects = accountObjects;
|
|
142
144
|
if (!options.hasOwnProperty("limit") || options.limit === undefined) {
|
|
@@ -42,6 +42,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
42
42
|
const Client = __importStar(require("../client"));
|
|
43
43
|
const utils_1 = require("../common/utils");
|
|
44
44
|
const account_order_1 = require("../parse/ledger/account-order");
|
|
45
|
+
const common_1 = require("../common");
|
|
45
46
|
const OFFERS_LIMIT_MAX = 400;
|
|
46
47
|
async function getAccountOffers(account, options = {}) {
|
|
47
48
|
const formatted = options.legacy === true || options.formatted === true;
|
|
@@ -66,15 +67,16 @@ async function getAccountOffers(account, options = {}) {
|
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
if (response.error) {
|
|
69
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
70
|
-
return {
|
|
70
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
71
|
+
return (0, common_1.removeUndefined)({
|
|
71
72
|
account,
|
|
72
73
|
error,
|
|
73
74
|
error_code,
|
|
74
75
|
error_message,
|
|
76
|
+
error_exception,
|
|
75
77
|
status,
|
|
76
78
|
validated,
|
|
77
|
-
};
|
|
79
|
+
});
|
|
78
80
|
}
|
|
79
81
|
const result = response.result;
|
|
80
82
|
const newMarker = (0, utils_1.createMarker)(connection.hash, result.marker);
|
|
@@ -118,15 +120,16 @@ async function getAccountAllOffers(account, options = {}) {
|
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
122
|
if (response.error) {
|
|
121
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
122
|
-
return {
|
|
123
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
124
|
+
return (0, common_1.removeUndefined)({
|
|
123
125
|
account,
|
|
124
126
|
error,
|
|
125
127
|
error_code,
|
|
126
128
|
error_message,
|
|
129
|
+
error_exception,
|
|
127
130
|
status,
|
|
128
131
|
validated,
|
|
129
|
-
};
|
|
132
|
+
});
|
|
130
133
|
}
|
|
131
134
|
response.offers = accountOffers;
|
|
132
135
|
return response;
|
package/lib/ledger/account_tx.js
CHANGED
|
@@ -76,15 +76,16 @@ async function getTransactions(account, options = { limit: DEFAULT_LIMIT }) {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
if (response.error) {
|
|
79
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
80
|
-
return {
|
|
79
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
80
|
+
return (0, utils_1.removeUndefined)({
|
|
81
81
|
account,
|
|
82
82
|
error,
|
|
83
83
|
error_code,
|
|
84
84
|
error_message,
|
|
85
|
+
error_exception,
|
|
85
86
|
status,
|
|
86
87
|
validated,
|
|
87
|
-
};
|
|
88
|
+
});
|
|
88
89
|
}
|
|
89
90
|
const result = response?.result;
|
|
90
91
|
if (!result) {
|
package/lib/ledger/amm_info.js
CHANGED
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.getAmmInfo = getAmmInfo;
|
|
37
37
|
exports.getAmmInfoByAssets = getAmmInfoByAssets;
|
|
38
38
|
const Client = __importStar(require("../client"));
|
|
39
|
+
const utils_1 = require("../common/utils");
|
|
39
40
|
async function getAmmInfo(ammAccount, options = {}) {
|
|
40
41
|
const connection = options.connection || Client.findConnection(options.type, options.url, true);
|
|
41
42
|
if (!connection) {
|
|
@@ -61,14 +62,15 @@ async function getAmmInfo(ammAccount, options = {}) {
|
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
if (response.error) {
|
|
64
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
65
|
-
return {
|
|
65
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
66
|
+
return (0, utils_1.removeUndefined)({
|
|
66
67
|
error,
|
|
67
68
|
error_code,
|
|
68
69
|
error_message,
|
|
70
|
+
error_exception,
|
|
69
71
|
status,
|
|
70
72
|
validated,
|
|
71
|
-
};
|
|
73
|
+
});
|
|
72
74
|
}
|
|
73
75
|
return response?.result;
|
|
74
76
|
}
|
|
@@ -98,14 +100,15 @@ async function getAmmInfoByAssets(asset, asset2, options = {}) {
|
|
|
98
100
|
};
|
|
99
101
|
}
|
|
100
102
|
if (response.error) {
|
|
101
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
102
|
-
return {
|
|
103
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
104
|
+
return (0, utils_1.removeUndefined)({
|
|
103
105
|
error,
|
|
104
106
|
error_code,
|
|
105
107
|
error_message,
|
|
108
|
+
error_exception,
|
|
106
109
|
status,
|
|
107
110
|
validated,
|
|
108
|
-
};
|
|
111
|
+
});
|
|
109
112
|
}
|
|
110
113
|
return response?.result;
|
|
111
114
|
}
|
|
@@ -38,6 +38,7 @@ exports.getOrderbook = getOrderbook;
|
|
|
38
38
|
const Client = __importStar(require("../client"));
|
|
39
39
|
const book_offers_1 = require("../models/book_offers");
|
|
40
40
|
const utils_1 = require("../common/utils");
|
|
41
|
+
const common_1 = require("../common");
|
|
41
42
|
async function getBookOffers(taker, takerGets, takerPays, options = {}) {
|
|
42
43
|
const { hash, marker } = (0, utils_1.parseMarker)(options.marker);
|
|
43
44
|
options.marker = marker;
|
|
@@ -62,15 +63,16 @@ async function getBookOffers(taker, takerGets, takerPays, options = {}) {
|
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
65
|
if (response.error) {
|
|
65
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
66
|
-
return {
|
|
66
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
67
|
+
return (0, common_1.removeUndefined)({
|
|
67
68
|
taker,
|
|
68
69
|
error,
|
|
69
70
|
error_code,
|
|
70
71
|
error_message,
|
|
72
|
+
error_exception,
|
|
71
73
|
status,
|
|
72
74
|
validated,
|
|
73
|
-
};
|
|
75
|
+
});
|
|
74
76
|
}
|
|
75
77
|
const result = response.result;
|
|
76
78
|
const newMarker = (0, utils_1.createMarker)(connection.hash, result.marker);
|
|
@@ -42,6 +42,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
42
42
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
43
43
|
const Client = __importStar(require("../client"));
|
|
44
44
|
const gateway_balances_1 = require("../parse/ledger/gateway-balances");
|
|
45
|
+
const utils_1 = require("../common/utils");
|
|
45
46
|
async function getBalanceSheet(account, options = {}) {
|
|
46
47
|
const formatted = options.formatted === true;
|
|
47
48
|
const connection = Client.findConnection("gateway_balances");
|
|
@@ -63,15 +64,16 @@ async function getBalanceSheet(account, options = {}) {
|
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
66
|
if (response.error) {
|
|
66
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
67
|
-
return {
|
|
67
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
68
|
+
return (0, utils_1.removeUndefined)({
|
|
68
69
|
account,
|
|
69
70
|
error,
|
|
70
71
|
error_code,
|
|
71
72
|
error_message,
|
|
73
|
+
error_exception,
|
|
72
74
|
status,
|
|
73
75
|
validated,
|
|
74
|
-
};
|
|
76
|
+
});
|
|
75
77
|
}
|
|
76
78
|
const result = response.result;
|
|
77
79
|
if (formatted) {
|
|
@@ -82,15 +84,16 @@ async function getBalanceSheet(account, options = {}) {
|
|
|
82
84
|
async function getAccountObligations(account) {
|
|
83
85
|
const response = (await getBalanceSheet(account));
|
|
84
86
|
if (response.error) {
|
|
85
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
86
|
-
return {
|
|
87
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
88
|
+
return (0, utils_1.removeUndefined)({
|
|
87
89
|
account,
|
|
88
90
|
error,
|
|
89
91
|
error_code,
|
|
90
92
|
error_message,
|
|
93
|
+
error_exception,
|
|
91
94
|
status,
|
|
92
95
|
validated,
|
|
93
|
-
};
|
|
96
|
+
});
|
|
94
97
|
}
|
|
95
98
|
const obligations = response.obligations;
|
|
96
99
|
const obligationsLines = [];
|
package/lib/ledger/ledger.js
CHANGED
|
@@ -37,6 +37,7 @@ exports.getLedger = getLedger;
|
|
|
37
37
|
exports.getLedgerIndex = getLedgerIndex;
|
|
38
38
|
const Client = __importStar(require("../client"));
|
|
39
39
|
const ledger_1 = require("../parse/ledger/ledger");
|
|
40
|
+
const utils_1 = require("../common/utils");
|
|
40
41
|
async function getLedger(options = {}) {
|
|
41
42
|
const formatted = options.legacy === true || options.formatted === true;
|
|
42
43
|
const connection = options.connection || Client.findConnection("history");
|
|
@@ -57,14 +58,15 @@ async function getLedger(options = {}) {
|
|
|
57
58
|
expand: !!options.expand,
|
|
58
59
|
});
|
|
59
60
|
if (response.error) {
|
|
60
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
61
|
-
return {
|
|
61
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
62
|
+
return (0, utils_1.removeUndefined)({
|
|
62
63
|
error,
|
|
63
64
|
error_code,
|
|
64
65
|
error_message,
|
|
66
|
+
error_exception,
|
|
65
67
|
status,
|
|
66
68
|
validated,
|
|
67
|
-
};
|
|
69
|
+
});
|
|
68
70
|
}
|
|
69
71
|
const result = response?.result;
|
|
70
72
|
if (!result) {
|
|
@@ -62,15 +62,16 @@ async function getLedgerEntry(ledgerEntry, options = {}) {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
if (response.error) {
|
|
65
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
66
|
-
return {
|
|
65
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
66
|
+
return (0, common_1.removeUndefined)({
|
|
67
67
|
ledger_entry: ledgerEntry,
|
|
68
68
|
error,
|
|
69
69
|
error_code,
|
|
70
70
|
error_message,
|
|
71
|
+
error_exception,
|
|
71
72
|
status,
|
|
72
73
|
validated,
|
|
73
|
-
};
|
|
74
|
+
});
|
|
74
75
|
}
|
|
75
76
|
return response?.result;
|
|
76
77
|
}
|
package/lib/ledger/manifest.js
CHANGED
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.getManifest = getManifest;
|
|
37
37
|
const Client = __importStar(require("../client"));
|
|
38
|
+
const utils_1 = require("../common/utils");
|
|
38
39
|
async function getManifest(publicKey, options = {}) {
|
|
39
40
|
const connection = options.connection || Client.findConnection("manifest");
|
|
40
41
|
if (!connection) {
|
|
@@ -52,14 +53,15 @@ async function getManifest(publicKey, options = {}) {
|
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
55
|
if (response.error) {
|
|
55
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
56
|
-
return {
|
|
56
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
57
|
+
return (0, utils_1.removeUndefined)({
|
|
57
58
|
error,
|
|
58
59
|
error_code,
|
|
59
60
|
error_message,
|
|
61
|
+
error_exception,
|
|
60
62
|
status,
|
|
61
63
|
validated,
|
|
62
|
-
};
|
|
64
|
+
});
|
|
63
65
|
}
|
|
64
66
|
return response?.result;
|
|
65
67
|
}
|
package/lib/ledger/nft_info.js
CHANGED
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.getNftInfo = getNftInfo;
|
|
37
37
|
const Client = __importStar(require("../client"));
|
|
38
|
+
const utils_1 = require("../common/utils");
|
|
38
39
|
async function getNftInfo(nft_id, _options = {}) {
|
|
39
40
|
const connection = Client.findConnection("clio", undefined, true);
|
|
40
41
|
if (!connection) {
|
|
@@ -52,14 +53,15 @@ async function getNftInfo(nft_id, _options = {}) {
|
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
55
|
if (response.error) {
|
|
55
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
56
|
-
return {
|
|
56
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
57
|
+
return (0, utils_1.removeUndefined)({
|
|
57
58
|
error,
|
|
58
59
|
error_code,
|
|
59
60
|
error_message,
|
|
61
|
+
error_exception,
|
|
60
62
|
status,
|
|
61
63
|
validated,
|
|
62
|
-
};
|
|
64
|
+
});
|
|
63
65
|
}
|
|
64
66
|
return response?.result;
|
|
65
67
|
}
|
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.getServerDefinitions = getServerDefinitions;
|
|
37
37
|
const Client = __importStar(require("../client"));
|
|
38
|
+
const utils_1 = require("../common/utils");
|
|
38
39
|
async function getServerDefinitions(options = {}) {
|
|
39
40
|
const connection = options.connection || Client.findConnection();
|
|
40
41
|
if (!connection) {
|
|
@@ -50,14 +51,15 @@ async function getServerDefinitions(options = {}) {
|
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
53
|
if (response.error) {
|
|
53
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
54
|
-
return {
|
|
54
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
55
|
+
return (0, utils_1.removeUndefined)({
|
|
55
56
|
error,
|
|
56
57
|
error_code,
|
|
57
58
|
error_message,
|
|
59
|
+
error_exception,
|
|
58
60
|
status,
|
|
59
61
|
validated,
|
|
60
|
-
};
|
|
62
|
+
});
|
|
61
63
|
}
|
|
62
64
|
return response?.result;
|
|
63
65
|
}
|
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.getServerInfo = getServerInfo;
|
|
37
37
|
const Client = __importStar(require("../client"));
|
|
38
|
+
const utils_1 = require("../common/utils");
|
|
38
39
|
async function getServerInfo(options = {}) {
|
|
39
40
|
const connection = options.connection || Client.findConnection(options.type, options.url, true);
|
|
40
41
|
if (!connection) {
|
|
@@ -50,14 +51,15 @@ async function getServerInfo(options = {}) {
|
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
53
|
if (response.error) {
|
|
53
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
54
|
-
return {
|
|
54
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
55
|
+
return (0, utils_1.removeUndefined)({
|
|
55
56
|
error,
|
|
56
57
|
error_code,
|
|
57
58
|
error_message,
|
|
59
|
+
error_exception,
|
|
58
60
|
status,
|
|
59
61
|
validated,
|
|
60
|
-
};
|
|
62
|
+
});
|
|
61
63
|
}
|
|
62
64
|
return response?.result;
|
|
63
65
|
}
|
|
@@ -74,15 +74,16 @@ async function getTransaction(transaction, options = {}) {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
if (response.error) {
|
|
77
|
-
const { error, error_code, error_message, status, validated } = response;
|
|
78
|
-
return {
|
|
77
|
+
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
78
|
+
return (0, utils_1.removeUndefined)({
|
|
79
79
|
transaction,
|
|
80
80
|
error,
|
|
81
81
|
error_code,
|
|
82
82
|
error_message,
|
|
83
|
+
error_exception,
|
|
83
84
|
status,
|
|
84
85
|
validated,
|
|
85
|
-
};
|
|
86
|
+
});
|
|
86
87
|
}
|
|
87
88
|
const result = response?.result;
|
|
88
89
|
if (typeof result === "object") {
|
|
@@ -46,17 +46,22 @@ function isNegativeBalance(balance) {
|
|
|
46
46
|
return balance !== "0" && balance[0] === "-";
|
|
47
47
|
}
|
|
48
48
|
const RippleStateToTrustLine = (ledgerEntry, account) => {
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
49
|
+
const viewLowest = ledgerEntry.LowLimit.issuer === account;
|
|
50
|
+
const flags = ledgerEntry.Flags;
|
|
51
|
+
const self = viewLowest ? ledgerEntry.LowLimit : ledgerEntry.HighLimit;
|
|
52
|
+
const counterparty = viewLowest ? ledgerEntry.HighLimit : ledgerEntry.LowLimit;
|
|
53
|
+
const { lsfLowNoRipple, lsfHighNoRipple, lsfLowAuth, lsfHighAuth } = RippleStateFlags;
|
|
54
|
+
const no_ripple = (flags & (viewLowest ? lsfLowNoRipple : lsfHighNoRipple)) !== 0;
|
|
55
|
+
const no_ripple_peer = (flags & (viewLowest ? lsfHighNoRipple : lsfLowNoRipple)) !== 0;
|
|
56
|
+
const authorized = (flags & (viewLowest ? lsfLowAuth : lsfHighAuth)) !== 0;
|
|
57
|
+
const peer_authorized = (flags & (viewLowest ? lsfHighAuth : lsfLowAuth)) !== 0;
|
|
56
58
|
const balance = ledgerEntry.HighLimit.issuer === account && ledgerEntry.Balance.value.startsWith("-")
|
|
57
59
|
? ledgerEntry.Balance.value.slice(1)
|
|
58
60
|
: ledgerEntry.Balance.value;
|
|
59
|
-
|
|
61
|
+
let lockedBalance = ledgerEntry.LockedBalance?.value;
|
|
62
|
+
if (lockedBalance && lockedBalance.startsWith("-")) {
|
|
63
|
+
lockedBalance = lockedBalance.slice(1);
|
|
64
|
+
}
|
|
60
65
|
let lockCount = undefined;
|
|
61
66
|
if (lockedBalance) {
|
|
62
67
|
lockCount = ledgerEntry.LockCount;
|
|
@@ -71,6 +76,8 @@ const RippleStateToTrustLine = (ledgerEntry, account) => {
|
|
|
71
76
|
locked_balance: lockedBalance,
|
|
72
77
|
no_ripple,
|
|
73
78
|
no_ripple_peer,
|
|
79
|
+
authorized,
|
|
80
|
+
peer_authorized,
|
|
74
81
|
});
|
|
75
82
|
};
|
|
76
83
|
function accountObjectsToNFTOffers(accountObjects) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AMM_LP_TOKEN_REGEX: RegExp;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bithomp/xrpl-api",
|
|
3
|
-
"version": "3.2
|
|
3
|
+
"version": "3.3.2",
|
|
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",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"elliptic": "^6.6.1",
|
|
59
59
|
"lodash": "^4.17.21",
|
|
60
60
|
"ripple-address-codec": "5.0.0",
|
|
61
|
-
"ripple-binary-codec": "
|
|
61
|
+
"ripple-binary-codec": "2.3.0",
|
|
62
62
|
"ripple-keypairs": "2.0.0",
|
|
63
63
|
"xrpl": "4.2.5"
|
|
64
64
|
},
|
|
@@ -70,19 +70,19 @@
|
|
|
70
70
|
"@types/mocha": "^10.0.10",
|
|
71
71
|
"@types/nconf": "^0.10.7",
|
|
72
72
|
"@types/node": "^22.15.21",
|
|
73
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
74
|
-
"@typescript-eslint/parser": "^8.
|
|
73
|
+
"@typescript-eslint/eslint-plugin": "^8.34.0",
|
|
74
|
+
"@typescript-eslint/parser": "^8.34.0",
|
|
75
75
|
"chai": "^4.5.0",
|
|
76
76
|
"chai-as-promised": "^7.1.2",
|
|
77
|
-
"eslint": "^9.
|
|
77
|
+
"eslint": "^9.28.0",
|
|
78
78
|
"eslint-config-prettier": "^10.1.5",
|
|
79
|
-
"eslint-plugin-chai-friendly": "^1.0
|
|
79
|
+
"eslint-plugin-chai-friendly": "^1.1.0",
|
|
80
80
|
"eslint-plugin-import": "^2.31.0",
|
|
81
|
-
"eslint-plugin-n": "^17.
|
|
81
|
+
"eslint-plugin-n": "^17.20.0",
|
|
82
82
|
"eslint-plugin-promise": "^7.2.1",
|
|
83
|
-
"mocha": "^11.
|
|
83
|
+
"mocha": "^11.6.0",
|
|
84
84
|
"nconf": "^0.13.0",
|
|
85
|
-
"ts-jest": "^29.
|
|
85
|
+
"ts-jest": "^29.4.0",
|
|
86
86
|
"ts-node": "^10.9.2",
|
|
87
87
|
"typescript": "^5.8.3"
|
|
88
88
|
}
|