@bithomp/xrpl-api 3.4.5 → 3.4.6
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 +1 -1
- package/lib/connection.js +4 -5
- package/lib/ledger/account_tx.js +9 -0
- package/package.json +1 -1
package/lib/connection.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ declare class Connection extends EventEmitter {
|
|
|
32
32
|
types: string[];
|
|
33
33
|
latency: LatencyInfo[];
|
|
34
34
|
readonly logger?: any;
|
|
35
|
-
readonly timeout
|
|
35
|
+
readonly timeout: number;
|
|
36
36
|
readonly connectionTimeout: number;
|
|
37
37
|
readonly hash?: string;
|
|
38
38
|
private onlineSince;
|
package/lib/connection.js
CHANGED
|
@@ -45,7 +45,7 @@ const common_1 = require("./common");
|
|
|
45
45
|
const utils_1 = require("./common/utils");
|
|
46
46
|
const XRPLConnection = __importStar(require("xrpl/dist/npm/client/connection"));
|
|
47
47
|
const RECONNECT_TIMEOUT = 1000 * 5;
|
|
48
|
-
const LEDGER_CLOSED_TIMEOUT = 1000 *
|
|
48
|
+
const LEDGER_CLOSED_TIMEOUT = 1000 * 20;
|
|
49
49
|
const SERVER_INFO_UPDATE_INTERVAL = 1000 * 60 * 5;
|
|
50
50
|
const AVAILABLE_LEDGER_INDEX_WINDOW = 1000;
|
|
51
51
|
exports.DEFAULT_API_VERSION = xrpl_1.RIPPLED_API_V1;
|
|
@@ -64,7 +64,7 @@ class Connection extends events_1.EventEmitter {
|
|
|
64
64
|
this.updateTypes();
|
|
65
65
|
this.client = null;
|
|
66
66
|
this.logger = options.logger;
|
|
67
|
-
this.timeout = options.timeout;
|
|
67
|
+
this.timeout = options.timeout || LEDGER_CLOSED_TIMEOUT;
|
|
68
68
|
this.connectionTimeout = options.connectionTimeout || RECONNECT_TIMEOUT;
|
|
69
69
|
this.hash = crypto_1.default.createHash("sha256").update(url).digest("hex");
|
|
70
70
|
if (typeof options.networkID === "number") {
|
|
@@ -114,7 +114,7 @@ class Connection extends events_1.EventEmitter {
|
|
|
114
114
|
async request(request, options) {
|
|
115
115
|
const result = await this._request(request, options);
|
|
116
116
|
if (result?.error === "timeout") {
|
|
117
|
-
const timeouts = this.latency.filter((info) => info.delta >= this.
|
|
117
|
+
const timeouts = this.latency.filter((info) => info.delta >= this.timeout).length;
|
|
118
118
|
if (timeouts >= 3) {
|
|
119
119
|
this.logger?.debug({
|
|
120
120
|
service: "Bithomp::XRPL::Connection",
|
|
@@ -153,7 +153,7 @@ class Connection extends events_1.EventEmitter {
|
|
|
153
153
|
return response;
|
|
154
154
|
}
|
|
155
155
|
catch (err) {
|
|
156
|
-
this.updateLatency(
|
|
156
|
+
this.updateLatency(err.name === "TimeoutError" ? this.timeout : this.connectionTimeout);
|
|
157
157
|
this.logger?.debug({
|
|
158
158
|
service: "Bithomp::XRPL::Connection",
|
|
159
159
|
function: "request",
|
|
@@ -176,7 +176,6 @@ class Connection extends events_1.EventEmitter {
|
|
|
176
176
|
return await this.request({ command: "submit", tx_blob: transaction });
|
|
177
177
|
}
|
|
178
178
|
catch (err) {
|
|
179
|
-
this.updateLatency(1000);
|
|
180
179
|
this.logger?.debug({
|
|
181
180
|
service: "Bithomp::XRPL::Connection",
|
|
182
181
|
function: "submit",
|
package/lib/ledger/account_tx.js
CHANGED
|
@@ -333,12 +333,21 @@ function counterpartyFilter(options, transaction) {
|
|
|
333
333
|
if (transaction.tx.Destination === options.counterparty) {
|
|
334
334
|
return true;
|
|
335
335
|
}
|
|
336
|
+
if (transaction.tx.Delegate === options.counterparty) {
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
336
339
|
if (transaction.tx.Amount?.issuer === options.counterparty) {
|
|
337
340
|
return true;
|
|
338
341
|
}
|
|
339
342
|
if (transaction.tx.SendMax?.issuer === options.counterparty) {
|
|
340
343
|
return true;
|
|
341
344
|
}
|
|
345
|
+
if (typeof transaction.tx.TakerGets === "object" && transaction.tx.TakerGets?.issuer === options.counterparty) {
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
if (typeof transaction.tx.TakerPays === "object" && transaction.tx.TakerPays?.issuer === options.counterparty) {
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
342
351
|
if (transaction.tx.LimitAmount?.issuer === options.counterparty) {
|
|
343
352
|
return true;
|
|
344
353
|
}
|