xrpl-client
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -206,3 +206,6 @@ "use strict"; | ||
// Got response on a command, process accordingly | ||
const matchingCall = this.pendingCalls.filter((call) => { | ||
const matchingCall = [ | ||
...this.pendingCalls, | ||
...this.subscriptions, | ||
].filter((call) => { | ||
var _a; | ||
@@ -213,5 +216,6 @@ return call.id === ((_a = messageJson === null || messageJson === void 0 ? void 0 : messageJson.id) === null || _a === void 0 ? void 0 : _a._WsClient); | ||
const internalServerInfoCall = String(((_d = (_c = (_b = matchingCall[0]) === null || _b === void 0 ? void 0 : _b.request) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d._Request) || "").split("@")[0] === "_WsClient_Internal_ServerInfo"; | ||
matchingCall[0].promiseCallables.resolve(Object.assign(messageJson, { | ||
Object.assign(messageJson, { | ||
id: (_e = messageJson === null || messageJson === void 0 ? void 0 : messageJson.id) === null || _e === void 0 ? void 0 : _e._Request, | ||
})); | ||
}); | ||
matchingCall[0].promiseCallables.resolve((messageJson === null || messageJson === void 0 ? void 0 : messageJson.result) || messageJson); | ||
this.pendingCalls.splice(this.pendingCalls.indexOf(matchingCall[0]), 1); | ||
@@ -250,2 +254,3 @@ if (!internalServerInfoCall) { | ||
try { | ||
// log(call.request); | ||
this.connection.send(JSON.stringify(call.request)); | ||
@@ -331,10 +336,14 @@ } | ||
return new Promise((resolve, reject) => { | ||
if (this.getState().online) { | ||
const state = this.getState(); | ||
if (state.online && | ||
state.secLastContact && | ||
state.secLastContact < 10 && | ||
state.ledger.last) { | ||
// We're good | ||
resolve(this); | ||
} | ||
else { | ||
this.on("state", (state) => { | ||
if (state.online) { | ||
resolve(this); | ||
} | ||
this.on("ledger", () => { | ||
// Let's wait to make sure we're really connected | ||
resolve(this); | ||
}); | ||
@@ -341,0 +350,0 @@ } |
{ | ||
"name": "xrpl-client", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Connect to the XRP Ledger using websockets", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -10,3 +10,3 @@ # XRPL WebSocket Client [![npm version](https://badge.fury.io/js/xrpl-client.svg)](https://www.npmjs.com/xrpl-client) [![GitHub Actions NodeJS status](https://github.com/XRPL-Labs/xrpl-client/workflows/NodeJS/badge.svg?branch=main)](https://github.com/XRPL-Labs/xrpl-client/actions) [![CDNJS Browserified](https://img.shields.io/badge/cdnjs-browserified-blue)](https://cdn.jsdelivr.net/gh/XRPL-Labs/xrpl-client@main/dist/browser.js) [![CDNJS Browserified Minified](https://img.shields.io/badge/cdnjs-minified-orange)](https://cdn.jsdelivr.net/gh/XRPL-Labs/xrpl-client@main/dist/browser.min.js) | ||
- `send({ command: "..."})` » `Promise<CallResponse | AnyJson>` » Send a `comand` to the connected XRPL node. | ||
- `ready()` » `Promise<void>` » fires when you're connected. You can fire commands before that, they will be buffered. | ||
- `ready()` » `Promise<self>` » fires when you're fully connected. While the `state` event (and `getState()` method) only return the WebSocket online state, `ready()` will only return (async) if the first ledger data has been received and the last ledger index is known. | ||
- `getState()` » `ConnectionState` » Get the connection, connectivity & server state (e.g. fees, reserves). | ||
@@ -13,0 +13,0 @@ - close() » `void` » Fully close the entire object (can't be used again). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30614
571