xrpl-client
Advanced tools
Comparing version 1.0.0 to 1.0.2
@@ -19,2 +19,3 @@ /// <reference types="node" /> | ||
constructor(endpoint?: string, options?: WsClientOptions); | ||
ready(): Promise<XrplClient>; | ||
send(call: Call): Promise<CallResponse>; | ||
@@ -21,0 +22,0 @@ getState(): ConnectionState; |
@@ -22,3 +22,3 @@ "use strict"; | ||
__exportStar(require("./types"), exports); | ||
const log = debug_1.debug("xrplwsclient"); | ||
const log = debug_1.debug("xrplclient"); | ||
const logWarning = log.extend("warning"); | ||
@@ -323,4 +323,20 @@ const logMessage = log.extend("message"); | ||
this.on("reconnect", connect); | ||
// setTimeout(() => { | ||
this.connection = connect(); | ||
// }, 2000); | ||
} | ||
ready() { | ||
return new Promise((resolve, reject) => { | ||
if (this.getState().online) { | ||
resolve(this); | ||
} | ||
else { | ||
this.on("state", (state) => { | ||
if (state.online) { | ||
resolve(this); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
send(call) { | ||
@@ -327,0 +343,0 @@ assert_1.default(!this.closed, "Client in closed state"); |
{ | ||
"name": "xrpl-client", | ||
"version": "1.0.0", | ||
"version": "1.0.2", | ||
"description": "Connect to the XRP Ledger using websockets", | ||
@@ -12,8 +12,8 @@ "main": "dist/src/index.js", | ||
"watch": "tsc -w", | ||
"dev": "clear && npm run build && DEBUG=xrplwsclient* nodemon --watch dist dist/samples/sample.js", | ||
"dev": "clear && npm run build && DEBUG=xrplclient* nodemon --watch dist dist/samples/sample.js", | ||
"inspect": "clear && npm run build && node --inspect dist/samples/sample.js", | ||
"browserify": "browserify -r ./dist/src/index.js:xrpl-client -o dist/browser.js && npm run minify", | ||
"minify": "cat dist/browser.js | terser --compress --mangle > dist/browser.min.js", | ||
"test": "DEBUG=xrplwsclient:tests* jest --ci", | ||
"test-verbose": "DEBUG=xrplwsclient:tests* jest --ci --verbose", | ||
"test": "DEBUG=xrplclient:tests* jest --ci", | ||
"test-verbose": "DEBUG=xrplclient:tests* jest --ci --verbose", | ||
"lint": "eslint" | ||
@@ -45,8 +45,8 @@ }, | ||
"type": "git", | ||
"url": "git://github.com:XRPL-Labs/XrpldWsClient.git" | ||
"url": "git://github.com:XRPL-Labs/xrpl-client.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/XRPL-Labs/XrpldWsClient/issues" | ||
"url": "https://github.com/XRPL-Labs/xrpl-client/issues" | ||
}, | ||
"homepage": "https://github.com/XRPL-Labs/XrpldWsClient/#readme", | ||
"homepage": "https://github.com/XRPL-Labs/xrpl-client/#readme", | ||
"license": "MIT", | ||
@@ -53,0 +53,0 @@ "readmeFilename": "README.md", |
@@ -5,21 +5,37 @@ # 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) | ||
... | ||
Auto reconnecting, buffering, subscription remembering XRP Ledger WebSocket client. For in node & the browser. | ||
- Auto reconnecting, etc. | ||
#### Methods: | ||
- Emits: | ||
- `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. | ||
- `getState()` » `ConnectionState` » Get the connection, connectivity & server state (e.g. fees, reserves). | ||
- close() » `void` » Fully close the entire object (can't be used again). | ||
- message | ||
ledger | ||
path | ||
transaction | ||
validation | ||
- retry | ||
- close | ||
- reconnect | ||
#### Events emitted: | ||
- `state` (the state of the connection changed from online to offline or vice versa) | ||
- `message` (all messages, even if duplicate of the ones below) | ||
- `ledger` (a ledger closed) | ||
- `path` (async `path_find` response) | ||
- `transaction` | ||
- `validation` | ||
- `retry` (new connection attempt) | ||
- `close` (upstream closed the connection) | ||
- `reconnect` (reconnecting, after connected: `state`) | ||
### Syntax | ||
```javascript | ||
// Todo | ||
import { XrplClient } from "xrpl-client"; | ||
const client = new XrplClient("wss://xrplcluster.com"); | ||
// await client.ready(); | ||
const serverInfo = await client.send({ command: "server_info" }); | ||
console.log({ serverInfo }); | ||
client.on("ledger", (ledger) => { | ||
console.log("Ledger", ledger); | ||
}); | ||
``` | ||
@@ -26,0 +42,0 @@ |
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
30021
562
55