mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-05 05:15:48 +00:00
Compare commits
80 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
418f80bf6d | ||
|
|
ec121ee62d | ||
|
|
decc395e5b | ||
|
|
8b79fe6ba1 | ||
|
|
5f0c38531c | ||
|
|
69113de552 | ||
|
|
b81c1dab35 | ||
|
|
20ed4640a7 | ||
|
|
42464b84de | ||
|
|
76780c8a8e | ||
|
|
25a2bcd3be | ||
|
|
d9a42c8669 | ||
|
|
6e0fff2ad6 | ||
|
|
4e49b6a99c | ||
|
|
10efd5eedb | ||
|
|
de293de1e6 | ||
|
|
5df32e2e6e | ||
|
|
31e012bde5 | ||
|
|
1e66f40348 | ||
|
|
9adfd404e5 | ||
|
|
d941653477 | ||
|
|
cdf9e33ad2 | ||
|
|
b7de3b0ea9 | ||
|
|
aa081a4348 | ||
|
|
e3752c9057 | ||
|
|
be1267fb14 | ||
|
|
dd30e33e8e | ||
|
|
a973266434 | ||
|
|
0ac1061d26 | ||
|
|
6938773a22 | ||
|
|
81668a8282 | ||
|
|
22a77653af | ||
|
|
6e1e2081c9 | ||
|
|
97cc99a1c0 | ||
|
|
fee832be3a | ||
|
|
e35aca7a40 | ||
|
|
53f35b5a99 | ||
|
|
44d91d8d96 | ||
|
|
14d47f62e8 | ||
|
|
be04427145 | ||
|
|
d0229d2c9d | ||
|
|
250d0763d7 | ||
|
|
3db42279e1 | ||
|
|
ba7c589545 | ||
|
|
eaf8593960 | ||
|
|
ee30927304 | ||
|
|
b58ef11e57 | ||
|
|
c726a5eab8 | ||
|
|
1e86ba0aa0 | ||
|
|
cabd4cc88d | ||
|
|
28d2fc2a3a | ||
|
|
42db44fb59 | ||
|
|
ad0165cf22 | ||
|
|
708d8c0bb5 | ||
|
|
5074441b3b | ||
|
|
a1edc0b2d5 | ||
|
|
3afdc1fca0 | ||
|
|
6b7cdfc413 | ||
|
|
95e1314eb9 | ||
|
|
ad0cc209af | ||
|
|
dd11ce480d | ||
|
|
10ace18d27 | ||
|
|
e8ca25f792 | ||
|
|
95d626f69e | ||
|
|
3fdc56ab90 | ||
|
|
bb44598e32 | ||
|
|
3c86b04fee | ||
|
|
7ee87f2625 | ||
|
|
2f03347dda | ||
|
|
bbb19dce9f | ||
|
|
c8b0035897 | ||
|
|
67d1b5278d | ||
|
|
43e444b47d | ||
|
|
f3fd468566 | ||
|
|
97d4f1f2ce | ||
|
|
fbecaf2ddc | ||
|
|
978a5bcd99 | ||
|
|
650d722609 | ||
|
|
ef1f8752d9 | ||
|
|
6fd0b3a5f1 |
@@ -8,6 +8,9 @@
|
||||
"extends": [
|
||||
"eslint:recommended"
|
||||
],
|
||||
"globals": {
|
||||
"NodeJS": true
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018,
|
||||
|
||||
50
.github/pull_request_template.md
vendored
Normal file
50
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
## High Level Overview of Change
|
||||
|
||||
<!--
|
||||
Please include a summary/list of the changes.
|
||||
If too broad, please consider splitting into multiple PRs.
|
||||
If a relevant Asana task, please link it here.
|
||||
-->
|
||||
|
||||
### Context of Change
|
||||
|
||||
<!--
|
||||
Please include the context of a change.
|
||||
If a bug fix, when was the bug introduced? What was the behavior?
|
||||
If a new feature, why was this architecture chosen? What were the alternatives?
|
||||
If a refactor, how is this better than the previous implementation?
|
||||
|
||||
If there is a design document for this feature, please link it here.
|
||||
-->
|
||||
|
||||
### Type of Change
|
||||
|
||||
<!--
|
||||
Please check relevant options, delete irrelevant ones.
|
||||
-->
|
||||
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
||||
- [ ] Refactor (non-breaking change that only restructures code)
|
||||
- [ ] Tests (You added tests for code that already exists, or your new feature included in this PR)
|
||||
- [ ] Documentation Updates
|
||||
- [ ] Release
|
||||
|
||||
## Before / After
|
||||
|
||||
<!--
|
||||
If just refactoring / back-end changes, this can be just an in-English description of the change at a technical level.
|
||||
If a UI change, screenshots should be included.
|
||||
-->
|
||||
|
||||
## Test Plan
|
||||
|
||||
<!--
|
||||
Please describe the tests that you ran to verify your changes and provide instructions so that others can reproduce.
|
||||
-->
|
||||
|
||||
<!--
|
||||
## Future Tasks
|
||||
For future tasks related to PR.
|
||||
-->
|
||||
81
.github/workflows/nodejs.yml
vendored
Normal file
81
.github/workflows/nodejs.yml
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
||||
|
||||
name: Node.js CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ develop, master ]
|
||||
pull_request:
|
||||
branches: [ develop ]
|
||||
|
||||
jobs:
|
||||
unit:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x, 14.x, 16.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: yarn install
|
||||
- run: yarn test
|
||||
- run: yarn lint
|
||||
- run: yarn build
|
||||
|
||||
integration:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x, 14.x, 16.x]
|
||||
|
||||
services:
|
||||
rippled:
|
||||
image: natenichols/rippled-standalone:latest
|
||||
ports:
|
||||
- 6006:6006
|
||||
options:
|
||||
--health-cmd="wget localhost:6006 || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: yarn install
|
||||
- run: yarn test:integration
|
||||
env:
|
||||
HOST: localhost
|
||||
PORT: ${{ job.services.rippled.ports['6006'] }}
|
||||
|
||||
browser:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [14.x] # This just needs to be compatible w/ puppeteer
|
||||
|
||||
services:
|
||||
rippled:
|
||||
image: natenichols/rippled-standalone:latest
|
||||
ports:
|
||||
- 6006:6006
|
||||
options:
|
||||
--health-cmd="wget localhost:6006 || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: yarn install
|
||||
- run: yarn test:browser
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -68,3 +68,6 @@ scripts/cache
|
||||
|
||||
# nyc (istanbul)
|
||||
.nyc_output
|
||||
|
||||
# browser tests
|
||||
test-compiled-for-web
|
||||
|
||||
@@ -20,7 +20,7 @@ Warning: Use at your own risk.
|
||||
|
||||
Exchange allowing clients to buy and sell XRP, based in Mexico.
|
||||
|
||||
## Data and visualizations
|
||||
## Explorers
|
||||
|
||||
- **[xrpintel - XRP Intelligence](https://xrpintel.com/)**
|
||||
|
||||
@@ -58,10 +58,20 @@ Warning: Use at your own risk.
|
||||
|
||||
XRP Ledger explorer, API, metrics, and analytics using a graph database that is synchronized live with the XRPL.
|
||||
|
||||
## Data monitoring
|
||||
|
||||
- **[zerptracker](https://zerptracker.com)**
|
||||
|
||||
Monitor the XRPL using powerful JSONPath expressions, and receive notifications via email, SMS, webhooks, and more.
|
||||
|
||||
- **[Utility-Scan](https://utility-scan.com)**
|
||||
|
||||
Attempts to detect RippleNet on-demand liquidity (ODL) transactions through known fiat corridors and report these transactions in real time.
|
||||
|
||||
- **[XRPL Rosetta](https://xrpl-rosetta-oepox.ondigitalocean.app)**
|
||||
|
||||
3D Globe written in three.js connected to a Node.js websocket server that is listening to exchanges and the XRPL. The visualization aims to show trading, ODL, and liquidity at exchanges, intra-exchange volume, and flows.
|
||||
|
||||
## Wallets and wallet tools
|
||||
|
||||
- **[XUMM](https://xumm.app/)**
|
||||
|
||||
106
HISTORY.md
106
HISTORY.md
@@ -2,6 +2,103 @@
|
||||
|
||||
Subscribe to [the **ripple-lib-announce** mailing list](https://groups.google.com/forum/#!forum/ripple-lib-announce) for release announcements. We recommend that ripple-lib users stay up-to-date with the latest stable release.
|
||||
|
||||
## 1.10.0 (2021-08-12)
|
||||
|
||||
* Add address generation from Devnet/Testnet faucets (#1497)
|
||||
* Fix bug with `getBalances()` ledgerVersion (#1505)
|
||||
* Include lodash in webpack build (#1500)
|
||||
* Documentation Updates:
|
||||
* Export and document AccountSetFlags (#1525)
|
||||
* Add links to example keypair derivation (#1523)
|
||||
|
||||
## 1.9.8 (2021-07-30)
|
||||
|
||||
* Export offline methods to top level of package (#1479)
|
||||
* Remove deprecated ledger fields (#1160)
|
||||
* These fields have been deprecated for many years: accepted, hash (use ledger_hash instead), seqNum (use ledger_index instead), totalCoins (use total_coins instead)
|
||||
* Docs improvements (#1251, #1420, #1463)
|
||||
* Reduce dependencies on lodash (#1467)
|
||||
* Bug fixes
|
||||
* Allow lowercase hex for memos (#1475)
|
||||
* Add type argument to Promise (#1474)
|
||||
* Fix miscommunication with ripplingDisabled in trustlines (#1481)
|
||||
* Allow X-address for issuer (#1471)
|
||||
* Dependencies
|
||||
* ws, ripple-binary-codec
|
||||
* deps-dev: typescript, @types/node, ts-node
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found below.
|
||||
```
|
||||
% shasum -a 256 build/*
|
||||
f3a0efb9f8bb618da6b10425a9b55a8492359a331a22d0ab4de7d3551870eb3d build/ripple-latest-min.js
|
||||
fc17a5572001d814ea6b81aa701fcb66882ec031c68afb769a8ea8b71c6529a6 build/ripple-latest-min.js.LICENSE.txt
|
||||
fd40457a89a14732ce261148e129cdda5aa963d9a433c57700353083faa1bffe build/ripple-latest.js
|
||||
```
|
||||
|
||||
## 1.9.7 (2021-07-14)
|
||||
|
||||
* Bug fixes
|
||||
* TypeScript: fix TrustlineTransaction type (#1458) (#1460) (thanks @mrosendin)
|
||||
* Docs
|
||||
* Update boilerplate (#1459) (thanks @mDuo13)
|
||||
* Dependencies
|
||||
* @types/node, @types/ws, @types/lodash, @types/mocha, prettier, mocha, webpack, ripple-binary-codec, ws, webpack-cli, doctoc
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found below.
|
||||
```
|
||||
% shasum -a 256 build/*
|
||||
a994422648c040076251c9a040fd494bc2ee30de23867607985b953022853afc build/ripple-latest-min.js
|
||||
fc17a5572001d814ea6b81aa701fcb66882ec031c68afb769a8ea8b71c6529a6 build/ripple-latest-min.js.LICENSE.txt
|
||||
2e22b6187ff5f9300520c29a538013067609b439181f1f2184d6a80fcfa2449c build/ripple-latest.js
|
||||
```
|
||||
|
||||
## 1.9.6 (2021-07-01)
|
||||
|
||||
* Bug fixes
|
||||
* Use 'current' ledger when preparing txs (#1429) (#999)
|
||||
* Allow multiple settings at once (#1435)
|
||||
* Dependencies
|
||||
* ripple-address-codec, prettier, mocha
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found below.
|
||||
```
|
||||
% shasum -a 256 build/*
|
||||
cac7f6f3be93efbd61dc5fd527c40f0d1baec06f2f9faa64e9eeb191cc85a710 build/ripple-latest-min.js
|
||||
fc17a5572001d814ea6b81aa701fcb66882ec031c68afb769a8ea8b71c6529a6 build/ripple-latest-min.js.LICENSE.txt
|
||||
5737483e940dca8b73768d8a1de8217c7e921a9cebaadef02d2b16867658f331 build/ripple-latest.js
|
||||
```
|
||||
|
||||
## 1.9.5 (2021-06-01)
|
||||
|
||||
* Bug fixes
|
||||
* Prevent getFee from returning NaN from Reporting Mode (#1401) (#1398)
|
||||
* Return promise inside catch block of reconnect to propagate promise (#1418) (#1113) (thanks @camposfyi)
|
||||
* Internal
|
||||
* Update mocha to use RC file config (#1417) (#1210) (thanks @camposfyi)
|
||||
* Dependencies
|
||||
* @types/ws, ws, browserslist, @types/lodash
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found below.
|
||||
```
|
||||
% shasum -a 256 build/*
|
||||
fcdc4aa1e1df7cb788b68f3d036e168aa64f9e818f441b99fef62d4571c0387d build/ripple-latest-min.js
|
||||
fc17a5572001d814ea6b81aa701fcb66882ec031c68afb769a8ea8b71c6529a6 build/ripple-latest-min.js.LICENSE.txt
|
||||
dfb7a92c4156fb3ee367254b5ea0935cda741cd3b5c36cdca695e7d89f88605e build/ripple-latest.js
|
||||
```
|
||||
|
||||
## 1.9.4 (2021-04-18)
|
||||
|
||||
* Add memos support for all transaction types for getTransactions (#1353, #1397)
|
||||
* Add Deno and React instructions (#1387)
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found below.
|
||||
```
|
||||
% shasum -a 256 build/*
|
||||
daa2b892a18037e89fea6fcf7de67624a782971956cb8df17cd765a4b0201ee9 build/ripple-latest-min.js
|
||||
fc17a5572001d814ea6b81aa701fcb66882ec031c68afb769a8ea8b71c6529a6 build/ripple-latest-min.js.LICENSE.txt
|
||||
b1d0bab54c6dbc76091610ede54a4269e73dea8cc6a9c25738d62bd7671920e4 build/ripple-latest.js
|
||||
```
|
||||
|
||||
## 1.9.3 (2021-03-16)
|
||||
|
||||
* Expose ripple-address-codec methods. These are static methods on RippleAPI, so you do not need to create a RippleAPI instance.
|
||||
@@ -53,6 +150,14 @@ Output for Example 3:
|
||||
}
|
||||
```
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found below.
|
||||
```
|
||||
% shasum -a 256 build/*
|
||||
bcc8db4e5464197151a267d9f240693794bf1eb4d26a4e0b3637f82a1d66e440 build/ripple-latest-min.js
|
||||
fc17a5572001d814ea6b81aa701fcb66882ec031c68afb769a8ea8b71c6529a6 build/ripple-latest-min.js.LICENSE.txt
|
||||
99c2825685d249c074abe7b59abaf197afce67ece7ad08ded6db67185e916dd2 build/ripple-latest.js
|
||||
```
|
||||
|
||||
## 1.9.2 (2021-03-12)
|
||||
|
||||
* Docs
|
||||
@@ -61,6 +166,7 @@ Output for Example 3:
|
||||
* Deserialization and verification of payment paths (#1382) (#1347) (#1376)
|
||||
* Dependencies
|
||||
* Bump ripple-binary-codec to 1.1.2
|
||||
* Fix edge case when constructing a value from "0", which can occur when using rippled v1.7.0
|
||||
* Bump lodash, ripple-address-codec
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found below.
|
||||
|
||||
62
README.md
62
README.md
@@ -36,7 +36,67 @@ In an existing project (with `package.json`), install `ripple-lib`:
|
||||
$ yarn add ripple-lib
|
||||
```
|
||||
|
||||
Then see the documentation:
|
||||
Then see the [documentation](#documentation).
|
||||
|
||||
### Using ripple-lib with React Native
|
||||
|
||||
If you want to use `ripple-lib` with React Native you will need to have some of the NodeJS modules available. To help with this you can use a module like [rn-nodeify](https://github.com/tradle/rn-nodeify).
|
||||
|
||||
1. Install dependencies (you can use `npm` as well):
|
||||
|
||||
```shell
|
||||
yarn add react-native-crypto
|
||||
yarn add ripple-lib
|
||||
# install peer deps
|
||||
yarn add react-native-randombytes
|
||||
# install latest rn-nodeify
|
||||
yarn add rn-nodeify@latest --dev
|
||||
```
|
||||
|
||||
2. After that, run the following command:
|
||||
|
||||
```shell
|
||||
# install node core shims and recursively hack package.json files
|
||||
# in ./node_modules to add/update the "browser"/"react-native" field with relevant mappings
|
||||
./node_modules/.bin/rn-nodeify --hack --install
|
||||
```
|
||||
|
||||
3. Enable `crypto`:
|
||||
|
||||
`rn-nodeify` will create a `shim.js` file in the project root directory.
|
||||
Open it and uncomment the line that requires the crypto module:
|
||||
|
||||
```javascript
|
||||
// If using the crypto shim, uncomment the following line to ensure
|
||||
// crypto is loaded first, so it can populate global.crypto
|
||||
require('crypto')
|
||||
```
|
||||
|
||||
4. Import `shim` in your project (it must be the first line):
|
||||
|
||||
```javascript
|
||||
import './shim'
|
||||
...
|
||||
```
|
||||
|
||||
### Using ripple-lib with Deno
|
||||
|
||||
Until official support for [Deno](https://deno.land) is added, you can use the following work-around to use `ripple-lib` with Deno:
|
||||
|
||||
```javascript
|
||||
import ripple from 'https://dev.jspm.io/npm:ripple-lib';
|
||||
|
||||
(async () => {
|
||||
const api = new (ripple as any).RippleAPI({ server: 'wss://s.altnet.rippletest.net:51233' });
|
||||
const address = 'rH8NxV12EuV...khfJ5uw9kT';
|
||||
|
||||
api.connect().then(() => {
|
||||
api.getBalances(address).then((balances: any) => {
|
||||
console.log(JSON.stringify(balances, null, 2));
|
||||
});
|
||||
});
|
||||
})();
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
|
||||
370
docs/index.md
370
docs/index.md
File diff suppressed because it is too large
Load Diff
15
docs/src/accountSetFlags.md.ejs
Normal file
15
docs/src/accountSetFlags.md.ejs
Normal file
@@ -0,0 +1,15 @@
|
||||
## accountSetFlags
|
||||
|
||||
To modify account flags, you can use an AccountSet transaction and its `SetFlag` or `ClearFlag` fields.
|
||||
|
||||
The flags are called [AccountSet flags (asf*)](https://xrpl.org/accountset.html#accountset-flags):
|
||||
|
||||
`RippleAPI.accountSetFlags.requireDestinationTag`: Require a destination tag to send transactions to this account.
|
||||
`RippleAPI.accountSetFlags.requireAuthorization`: Require authorization for users to hold balances issued by this address. Can only be enabled if the address has no trust lines connected to it.
|
||||
`RippleAPI.accountSetFlags.disallowIncomingXRP`: XRP should not be sent to this account. (Enforced by client applications, not by rippled)
|
||||
`RippleAPI.accountSetFlags.disableMasterKey`: Disallow use of the master key pair. Can only be enabled if the account has configured another way to sign transactions.
|
||||
`RippleAPI.accountSetFlags.enableTransactionIDTracking`: Track the ID of this account's most recent transaction.
|
||||
`RippleAPI.accountSetFlags.noFreeze`: Permanently give up the ability to freeze individual trust lines or disable Global Freeze. This flag can never be disabled after being enabled.
|
||||
`RippleAPI.accountSetFlags.globalFreeze`: Freeze all assets issued by this account.
|
||||
`RippleAPI.accountSetFlags.defaultRipple`: Enable [rippling](https://xrpl.org/rippling.html) on this account's trust lines by default.
|
||||
`RippleAPI.accountSetFlags.depositAuth`:Enable Deposit Authorization on this account.
|
||||
@@ -31,7 +31,7 @@ Currencies are represented as either 3-character currency codes or 40-character
|
||||
## Value
|
||||
A *value* is a quantity of a currency represented as a decimal string. Be careful: JavaScript's native number format does not have sufficient precision to represent all values. XRP has different precision from other currencies.
|
||||
|
||||
**XRP** has 6 significant digits past the decimal point. In other words, XRP cannot be divided into positive values smaller than `0.000001` (1e-6). This smallest unit is called a "drop". XRP has a maximum value of `100000000000` (1e11). Some RippleAPI methods accept XRP in order to maintain compatibility with older versions of the API. For consistency with the `rippled` APIs, we recommend formally specifying XRP values in *drops* in all API requests, and converting them to XRP for display. This is similar to Bitcoin's *satoshis* and Ethereum's *wei*. 1 XRP = 1,000,000 drops.
|
||||
**XRP** has 6 significant digits past the decimal point. In other words, XRP cannot be divided into positive values smaller than `0.000001` (1e-6). This smallest unit is called a "drop". XRP has a maximum value of `100000000000` (1e11). Some RippleAPI methods accept XRP to maintain compatibility with older versions of the API. For consistency with the `rippled` APIs, we recommend formally specifying XRP values in *drops* in all API requests, and converting them to XRP for display. This is like Bitcoin's *satoshis* and Ethereum's *wei*. 1 XRP = 1,000,000 drops.
|
||||
|
||||
**Non-XRP values** have 16 decimal digits of precision, with a maximum value of `9999999999999999e80`. The smallest positive non-XRP value is `1e-81`.
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ Use the following [boilerplate code](https://en.wikipedia.org/wiki/Boilerplate_c
|
||||
const RippleAPI = require('ripple-lib').RippleAPI;
|
||||
|
||||
const api = new RippleAPI({
|
||||
server: 'wss://s1.ripple.com' // Public rippled server hosted by Ripple, Inc.
|
||||
server: 'wss://xrplcluster.com' // Public cluster
|
||||
});
|
||||
api.on('error', (errorCode, errorMessage) => {
|
||||
console.log(errorCode + ': ' + errorMessage);
|
||||
@@ -16,7 +16,7 @@ api.on('connected', () => {
|
||||
});
|
||||
api.on('disconnected', (code) => {
|
||||
// code - [close code](https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent) sent by the server
|
||||
// will be 1000 if this was normal closure
|
||||
// the code is 1000 for a normal closure
|
||||
console.log('disconnected, code:', code);
|
||||
});
|
||||
api.connect().then(() => {
|
||||
@@ -26,9 +26,7 @@ api.connect().then(() => {
|
||||
}).catch(console.error);
|
||||
```
|
||||
|
||||
RippleAPI is designed to work in [Node.js](https://nodejs.org) version 6 or higher. Ripple recommends Node.js v10 LTS.
|
||||
|
||||
The code samples in this documentation are written with ECMAScript 6 (ES6) features, but `RippleAPI` also works with ECMAScript 5 (ES5). Regardless of whether you use ES5 or ES6, the methods that return Promises return [ES6-style promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
|
||||
[Node.js v14](https://nodejs.org/) is recommended. Other versions may work but are not frequently tested.
|
||||
|
||||
<aside class="notice">
|
||||
All the code snippets in this documentation assume that you have surrounded them with this boilerplate.
|
||||
@@ -39,7 +37,7 @@ If you omit the "catch" section, errors may not be visible.
|
||||
</aside>
|
||||
|
||||
<aside class="notice">
|
||||
The "error" event is emitted whenever an error occurs that cannot be associated with a specific request. If the listener is not registered, an exception will be thrown whenever the event is emitted.
|
||||
The API emits an "error" event whenever an error occurs that cannot be associated with a specific request. If there is no listener registered for this event, the API throws an exception whenever the event is emitted.
|
||||
</aside>
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`combine(signedTransactions: Array<string>): {signedTransaction: string, id: string}`
|
||||
|
||||
Combines signed transactions from multiple accounts for a multisignature transaction. The signed transaction must subsequently be [submitted](#submit).
|
||||
Combines signed transactions from multiple accounts for a multisignature transaction into a form that can be [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ This event is emitted when there is an error on the connection to the server tha
|
||||
The first parameter is a string indicating the error type:
|
||||
* `badMessage` - rippled returned a malformed message
|
||||
* `websocket` - the websocket library emitted an error
|
||||
* one of the error codes found in the [rippled Universal Errors](https://ripple.com/build/rippled-apis/#universal-errors).
|
||||
* one of the error codes found in the [`rippled` Universal Errors](https://xrpl.org/error-formatting.html#universal-errors).
|
||||
|
||||
The second parameter is a message explaining the error.
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ This method takes two parameters.
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns an object with two properties: `bids` and `asks`, each of which is an array of bids (buy orders) or asks (sell orders), respectively. (Note: the structures of `bids` and `asks` are identical.)
|
||||
This method returns an object with two properties: `bids` and `asks`, each of which is an array of bids (buy orders) or asks (sell orders), respectively. Both `bids` and `asks` are formatted the same way.
|
||||
|
||||
Object structure:
|
||||
|
||||
@@ -23,7 +23,7 @@ Object structure:
|
||||
|
||||
**Raw order data:** The response includes a `data` property containing the raw order data. This may include `owner_funds`, `Flags`, and other fields.
|
||||
|
||||
For details, see the rippled method [book_offers](https://ripple.com/build/rippled-apis/#book-offers).
|
||||
For details, see the `rippled` [book_offers method](https://xrpl.org/book_offers.html).
|
||||
|
||||
### Example
|
||||
|
||||
|
||||
19
docs/src/generateFaucetWallet.md.ejs
Normal file
19
docs/src/generateFaucetWallet.md.ejs
Normal file
@@ -0,0 +1,19 @@
|
||||
## generateFaucetWallet
|
||||
|
||||
`generateFaucetWallet(onTestnet = true)`
|
||||
|
||||
Calls the Testnet or Devnet faucet API in order to generate a new, random wallet with some amount of test XRP. This is for testing purposes only.
|
||||
|
||||
### Example
|
||||
|
||||
**Request**
|
||||
|
||||
Create a new wallet on the Testnet:
|
||||
|
||||
```javascript
|
||||
const wallet = await api.generateFaucetWallet()
|
||||
```
|
||||
|
||||
**Response**
|
||||
|
||||
<%- renderFixture('responses/generate-faucet-wallet.json') %>
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
Returns the estimated transaction fee for the rippled server the RippleAPI instance is connected to.
|
||||
|
||||
This will use the [feeCushion parameter](#parameters) provided to the RippleAPI constructor, or the default value of `1.2`.
|
||||
This uses the [feeCushion parameter](#parameters) provided to the RippleAPI constructor, or the default value of `1.2`.
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@ Returns open orders for the specified account. Open orders are orders that have
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns a promise that resolves with an object with the following structure (Note: the structures of `bids` and `asks` are identical):
|
||||
This method returns a promise that resolves with an object with the following structure Both `bids` and `asks` have the same format:
|
||||
|
||||
<%- renderSchema('output/get-orderbook.json') %>
|
||||
|
||||
**Raw order data:** The response includes a `data` property containing the raw order data. This may include `owner_funds`, `Flags`, and other fields.
|
||||
|
||||
For details, see the rippled method [book_offers](https://ripple.com/build/rippled-apis/#book-offers).
|
||||
For details, see the `rippled` [book_offers method](https://xrpl.org/book_offers.html).
|
||||
|
||||
### Example
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ Returns settings for the specified account. Note: For account data that is not m
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns a promise that resolves with an array of objects with the following structure (Note: all fields are optional as they will not be shown if they are set to their default value):
|
||||
This method returns a promise that resolves with an array of objects with the following structure. All fields are optional, and are omitted if they are set to their default value.
|
||||
|
||||
<%- renderSchema('output/get-settings.json') %>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ Returns `true` when there are more pages available.
|
||||
|
||||
When there are more results than contained in the response, the response includes a `marker` field. You can use this convenience method, or check for `marker` yourself.
|
||||
|
||||
See [Markers and Pagination](https://ripple.com/build/rippled-apis/#markers-and-pagination).
|
||||
See [Markers and Pagination](https://xrpl.org/markers-and-pagination.html).
|
||||
|
||||
### Return Value
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
<%- include('isValidSecret.md.ejs') %>
|
||||
<%- include('deriveKeypair.md.ejs') %>
|
||||
<%- include('deriveAddress.md.ejs') %>
|
||||
<%- include('generateFaucetWallet.md.ejs') %>
|
||||
<%- include('signPaymentChannelClaim.md.ejs') %>
|
||||
<%- include('verifyPaymentChannelClaim.md.ejs') %>
|
||||
<%- include('computeLedgerHash.md.ejs') %>
|
||||
@@ -66,5 +67,6 @@
|
||||
<%- include('iso8601ToRippleTime.md.ejs') %>
|
||||
<%- include('rippleTimeToISO8601.md.ejs') %>
|
||||
<%- include('txFlags.md.ejs') %>
|
||||
<%- include('accountSetFlags.md.ejs') %>
|
||||
<%- include('schemaValidator.md.ejs') %>
|
||||
<%- include('events.md.ejs') %>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## Offline functionality
|
||||
|
||||
RippleAPI can also function without internet connectivity. This can be useful in order to generate secrets and sign transactions from a secure, isolated machine.
|
||||
RippleAPI can also function without internet connectivity, so you can generate secrets and sign transactions from a secure, isolated machine.
|
||||
|
||||
To instantiate RippleAPI in offline mode, use the following boilerplate code:
|
||||
To instantiate RippleAPI in offline mode, use the following code:
|
||||
|
||||
```javascript
|
||||
const RippleAPI = require('ripple-lib').RippleAPI;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`parseAccountFlags(Flags: number): object`
|
||||
|
||||
Parse an `AccountRoot` object's [`Flags`](https://developers.ripple.com/accountroot.html#accountroot-flags).
|
||||
Parse an `AccountRoot` object's [`Flags`](https://xrpl.org/accountroot.html#accountroot-flags).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`prepareCheckCancel(address: string, checkCancel: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare a Check cancellation transaction. This cancels an unredeemed Check, removing it from the ledger without sending any money. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare a Check cancellation transaction. This type of transaction cancels an unredeemed Check, removing it from the ledger without sending any money. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`prepareCheckCash(address: string, checkCash: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare a Check cashing transaction. This redeems a Check to receive up to the amount authorized by the corresponding CheckCreate transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare a Check cashing transaction. This redeems a Check to receive up to the amount authorized by the corresponding CheckCreate transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`prepareCheckCreate(address: string, checkCreate: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare a Check creation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare a Check creation transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`prepareEscrowCancellation(address: string, escrowCancellation: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare an escrow cancellation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare an escrow cancellation transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`prepareEscrowCreation(address: string, escrowCreation: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare an escrow creation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare an escrow creation transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`prepareEscrowExecution(address: string, escrowExecution: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare an escrow execution transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare an escrow execution transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`prepareOrder(address: string, order: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare an order transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare an order transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`prepareOrderCancellation(address: string, orderCancellation: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare an order cancellation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare an order cancellation transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`preparePayment(address: string, payment: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare a payment transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare a payment transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`preparePaymentChannelClaim(address: string, paymentChannelClaim: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare a payment channel claim transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare a payment channel claim transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`preparePaymentChannelCreate(address: string, paymentChannelCreate: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare a payment channel creation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare a payment channel creation transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`preparePaymentChannelFund(address: string, paymentChannelFund: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare a payment channel fund transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare a payment channel fund transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`prepareSettings(address: string, settings: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare a settings transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare a settings transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`prepareTicketCreate(address: string, ticketCount: number, instructions: object): Promise<object>`
|
||||
|
||||
Prepare a ticket transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare a ticket transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
Ticket functionality requires the [TicketBatch amendment](https://github.com/ripple/xrpl-dev-portal/issues/898). As of 2020-11-24, this amendment is not activated on the Mainnet, Testnet, or Devnet.
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
`prepareTransaction(transaction: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare a transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare a transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
This method works with any of [the transaction types supported by rippled](https://developers.ripple.com/transaction-types.html).
|
||||
This method works with any of [the transaction types supported by rippled](https://xrpl.org/transaction-types.html).
|
||||
|
||||
Notably, this is the preferred method for preparing `DepositPreauth` or `AccountDelete` transactions.
|
||||
|
||||
@@ -12,8 +12,8 @@ Notably, this is the preferred method for preparing `DepositPreauth` or `Account
|
||||
|
||||
Name | Type | Description
|
||||
---- | ---- | -----------
|
||||
transaction | [transaction](https://developers.ripple.com/transaction-formats.html) | The specification (JSON) of the transaction to prepare. Set `Account` to the address of the account that is creating the transaction. You may omit auto-fillable fields like `Fee`, `Flags`, and `Sequence` to have them set automatically.
|
||||
instructions | [instructions](#transaction-instructions) | *Optional* Instructions for executing the transaction.
|
||||
transaction | [Transaction](https://xrpl.org/transaction-formats.html) | The specification (JSON) of the transaction to prepare. Set `Account` to the address of the account that is creating the transaction. You may omit auto-fillable fields like `Fee`, `Flags`, and `Sequence` to have them set automatically.
|
||||
instructions | [Instructions](#transaction-instructions) | *Optional* Instructions for executing the transaction.
|
||||
|
||||
### Return Value
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`prepareTrustline(address: string, trustline: object, instructions: object): Promise<object>`
|
||||
|
||||
Prepare a trustline transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||
Prepare a trustline transaction. The prepared transaction can then be [signed](#sign) and [submitted](#submit).
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ This method takes one parameter, an object with a `counterparty` field.
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns a new object similar to the source object, but with `issuer` instead of `counterparty`.
|
||||
This method returns a new object based on the source object, but with `issuer` instead of `counterparty`.
|
||||
|
||||
### Example
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
Returns the response from invoking the specified command, with the specified options, on the connected rippled server.
|
||||
|
||||
Refer to [rippled APIs](https://ripple.com/build/rippled-apis/) for commands and options. All XRP amounts must be specified in drops. One drop is equal to 0.000001 XRP. See [Specifying Currency Amounts](https://ripple.com/build/rippled-apis/#specifying-currency-amounts).
|
||||
Refer to [HTTP / WebSocket APIs](https://xrpl.org/rippled-api.html) for commands and options. All XRP amounts must be specified in drops. One drop is equal to 0.000001 XRP. See [Specifying Currency Amounts](https://xrpl.org/basic-data-types.html#specifying-currency-amounts).
|
||||
|
||||
Most commands return data for the `current` (in-progress, open) ledger by default. Do not rely on this. Always specify a ledger version in your request. In the example below, the 'validated' ledger is requested, which is the most recent ledger that has been validated by the whole network. See [Specifying Ledgers](https://xrpl.org/basic-data-types.html#specifying-ledgers).
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ Requests the next page of data.
|
||||
|
||||
You can use this convenience method, or include `currentResponse.marker` in `params` yourself, when using `request`.
|
||||
|
||||
See [Markers and Pagination](https://ripple.com/build/rippled-apis/#markers-and-pagination).
|
||||
See [Markers and Pagination](https://xrpl.org/markers-and-pagination.html).
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns a promise that resolves with the next page of data from rippled.
|
||||
|
||||
If the response does not have a next page, the promise will reject with `new errors.NotFoundError('response does not have a next page')`.
|
||||
If the response does not have a next page, the promise rejects with `new errors.NotFoundError('response does not have a next page')`.
|
||||
|
||||
### Example
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
# rippled APIs
|
||||
|
||||
ripple-lib relies on [rippled APIs](https://ripple.com/build/rippled-apis/) for online functionality. In addition to ripple-lib's own methods, you can also access rippled APIs through ripple-lib. Use the `request()`, `hasNextPage()`, and `requestNextPage()` methods:
|
||||
ripple-lib uses the XRP Ledger's [WebSocket API](https://xrpl.org/rippled-api.html) for online functionality. You can use ripple-lib to call these APIs directly. Use the `request()`, `hasNextPage()`, and `requestNextPage()` methods:
|
||||
|
||||
* Use `request()` to issue any `rippled` command, including `account_currencies`, `subscribe`, and `unsubscribe`. [Full list of API Methods](https://ripple.com/build/rippled-apis/#api-methods).
|
||||
* Use `hasNextPage()` to determine whether a response has more pages. This is true when the response includes a [`marker` field](https://ripple.com/build/rippled-apis/#markers-and-pagination).
|
||||
* Use `request()` to issue any `rippled` command, including `account_currencies`, `subscribe`, and `unsubscribe`. [Full list of API Methods](https://xrpl.org/public-rippled-methods.html).
|
||||
* Use `hasNextPage()` to determine whether a response has more pages. This is true when the response includes a [`marker` field](https://xrpl.org/markers-and-pagination.html).
|
||||
* Use `requestNextPage()` to request the next page of data.
|
||||
|
||||
When using rippled APIs:
|
||||
|
||||
* [Specify XRP amounts in drops](https://developers.ripple.com/basic-data-types.html#specifying-currency-amounts).
|
||||
* [Specify timestamps as the number of seconds since the "Ripple Epoch"](https://developers.ripple.com/basic-data-types.html#specifying-time).
|
||||
* [Specify XRP amounts in drops](https://xrpl.org/basic-data-types.html#specifying-currency-amounts).
|
||||
* [Specify timestamps as the number of seconds since the "Ripple Epoch"](https://xrpl.org/basic-data-types.html#specifying-time).
|
||||
* Instead of `counterparty`, use `issuer`.
|
||||
|
||||
## Listening to streams
|
||||
@@ -68,4 +68,4 @@ api.connect().then(() => {
|
||||
|
||||
The subscription ends when you unsubscribe or the WebSocket connection is closed.
|
||||
|
||||
For full details, see [rippled Subscriptions](https://ripple.com/build/rippled-apis/#subscriptions).
|
||||
For full details, see the [subscribe method](https://xrpl.org/subscribe.html).
|
||||
|
||||
@@ -6,14 +6,14 @@ Unlike the rest of the ripple-lib API, schemaValidator is a static object on Rip
|
||||
|
||||
`RippleAPI.schemaValidator.schemaValidate(schemaName: string, object: any): void`
|
||||
|
||||
This method checks an object for conformance to a specified schema. It does not return anything, but will throw a `ValidationError` if the object does not conform to the schema.
|
||||
This method checks an object for conformance to a specified schema. It does not return anything, but throws a `ValidationError` if the object does not conform to the schema.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
RippleAPI.schemaValidator.schemaValidate('sign', {
|
||||
signedTransaction: '12000322800000002400000017201B0086955368400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D874473045022100BDE09A1F6670403F341C21A77CF35BA47E45CDE974096E1AA5FC39811D8269E702203D60291B9A27F1DCABA9CF5DED307B4F23223E0B6F156991DB601DFB9C41CE1C770A726970706C652E636F6D81145E7B112523F68D2F5E879DB4EAC51C6698A69304',
|
||||
id: '02ACE87F1996E3A23690A5BB7F1774BF71CCBA68F79805831B42ABAD5913D6F4'
|
||||
signedTransaction: '12000322800000002400000017201B0086955368400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8744630440220680070A157682D9EB510E8AD58C35DC9C8346B155077D73792E88120B7A3B6B1022079537D3300C9B4D2D3D62ACCE1E66CDA893F9612CB2577ADEC8154B933765336770B6578616D706C652E636F6D81145E7B112523F68D2F5E879DB4EAC51C6698A69304',
|
||||
id: '10B54D31384A49336C36A5907E3C28227139E282D3C7F734FEA351DE446F3674'
|
||||
})
|
||||
```
|
||||
|
||||
@@ -25,7 +25,7 @@ If the object is valid (conforms to the schema), nothing is returned. Otherwise,
|
||||
|
||||
```javascript
|
||||
RippleAPI.schemaValidator.schemaValidate('sign', {
|
||||
signedTransaction: '12000322800000002400000017201B0086955368400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D874473045022100BDE09A1F6670403F341C21A77CF35BA47E45CDE974096E1AA5FC39811D8269E702203D60291B9A27F1DCABA9CF5DED307B4F23223E0B6F156991DB601DFB9C41CE1C770A726970706C652E636F6D81145E7B112523F68D2F5E879DB4EAC51C6698A69304',
|
||||
signedTransaction: '12000322800000002400000017201B0086955368400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8744630440220680070A157682D9EB510E8AD58C35DC9C8346B155077D73792E88120B7A3B6B1022079537D3300C9B4D2D3D62ACCE1E66CDA893F9612CB2577ADEC8154B933765336770B6578616D706C652E636F6D81145E7B112523F68D2F5E879DB4EAC51C6698A69304',
|
||||
id: '123'
|
||||
})
|
||||
```
|
||||
|
||||
@@ -5,9 +5,9 @@ sign(txJSON: string, secret: string, options: object): {signedTransaction: strin
|
||||
sign(txJSON: string, keypair: object, options: object): {signedTransaction: string, id: string}
|
||||
```
|
||||
|
||||
Sign a prepared transaction. The signed transaction must subsequently be [submitted](#submit).
|
||||
Sign a prepared transaction. The signed transaction can then be [submitted](#submit).
|
||||
|
||||
This method can sign any of [the transaction types supported by ripple-binary-codec](https://github.com/ripple/ripple-binary-codec/blob/cfcde79c19c359e9a0466d7bc3dc9a3aef47bb99/src/enums/definitions.json#L1637). When a new transaction type is added to the XRP Ledger, it will be unrecognized until `ripple-binary-codec` is updated. If you try to sign an unrecognized transaction type, this method throws an error similar to the following:
|
||||
This method can sign any of [the transaction types supported by ripple-binary-codec](https://github.com/ripple/ripple-binary-codec/blob/cfcde79c19c359e9a0466d7bc3dc9a3aef47bb99/src/enums/definitions.json#L1637). When a new transaction type is added to the XRP Ledger, it is unrecognized until `ripple-binary-codec` is updated. If you try to sign an unrecognized transaction type, this method throws an error like the following:
|
||||
|
||||
`Error: [TRANSACTION_TYPE] is not a valid name or ordinal for TransactionType`
|
||||
|
||||
@@ -15,7 +15,7 @@ This method can sign any of [the transaction types supported by ripple-binary-co
|
||||
|
||||
<%- renderSchema("input/sign.json") %>
|
||||
|
||||
When this method is used for multisigning, the `options` parameter is required. See the multisigning example in this section for more details.
|
||||
When this method is used for multi-signing, the `options` parameter is required. See the multi-signing example in this section for more details.
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -26,7 +26,8 @@ This method returns an object with the following structure:
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
const txJSON = '{"Flags":2147483648,"TransactionType":"AccountSet","Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","Domain":"726970706C652E636F6D","LastLedgerSequence":8820051,"Fee":"12","Sequence":23}';
|
||||
// AccountSet transaction that sets Domain to example.com:
|
||||
const txJSON = '{"Flags":2147483648,"TransactionType":"AccountSet","Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","Domain":"6578616D706C652E636F6D","LastLedgerSequence":8820051,"Fee":"12","Sequence":23}';
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV';
|
||||
const keypair = { privateKey: '00ACCD3309DB14D1A4FC9B1DAE608031F4408C85C73EE05E035B7DC8B25840107A', publicKey: '02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8' };
|
||||
return api.sign(txJSON, secret); // or: api.sign(txJSON, keypair);
|
||||
@@ -34,7 +35,20 @@ return api.sign(txJSON, secret); // or: api.sign(txJSON, keypair);
|
||||
|
||||
<%- renderFixture("responses/sign.json") %>
|
||||
|
||||
### Example (multisigning)
|
||||
### Example Keypairs
|
||||
|
||||
To learn how keypairs are derived read [here](https://xrpl.org/cryptographic-keys.html#generating-keys).
|
||||
```javascript
|
||||
// secp25519 (33 bytes)
|
||||
const privateKey = "002512BBDFDBB77510883B7DCCBEF270B86DEAC8B64AC762873D75A1BEE6298665"
|
||||
const publicKey = "0390A196799EE412284A5D80BF78C3E84CBB80E1437A0AECD9ADF94D7FEAAFA284"
|
||||
|
||||
// ed25519 (Note the 0xED prefixes a 32 byte value for a total of 33 bytes)
|
||||
const privateKey = "ED0B6CBAC838DFE7F47EA1BD0DF00EC282FDF45510C92161072CCFB84035390C4D"
|
||||
const publicKey = "ED1A7C082846CFF58FF9A892BA4BA2593151CCF1DBA59F37714CC9ED39824AF85F"
|
||||
```
|
||||
|
||||
### Example (multi-signing)
|
||||
|
||||
```javascript
|
||||
const RippleAPI = require('ripple-lib').RippleAPI;
|
||||
@@ -84,6 +98,10 @@ const multiSignPaymentTransaction = {
|
||||
Amount: '88000000'
|
||||
};
|
||||
|
||||
const multiSignPaymentInstruction = {
|
||||
signersCount: 2
|
||||
};
|
||||
|
||||
const api = new RippleAPI({
|
||||
server: 'wss://s.altnet.rippletest.net:51233'
|
||||
});
|
||||
@@ -97,7 +115,7 @@ api.connect().then(() => {
|
||||
console.log(response.resultCode, response.resultMessage);
|
||||
|
||||
// multi sign a transaction
|
||||
api.prepareTransaction(multiSignPaymentTransaction).then(prepared => {
|
||||
api.prepareTransaction(multiSignPaymentTransaction, multiSignPaymentInstruction).then(prepared => {
|
||||
console.log(prepared);
|
||||
|
||||
// Aya and Bran sign it too but with 'signAs' set to their own account
|
||||
@@ -116,8 +134,8 @@ api.connect().then(() => {
|
||||
}).catch(console.error);
|
||||
```
|
||||
|
||||
Assuming the multisigning account was setup properly, the above example will respond with `resultCode: 'tesSUCCESS'` and the hash for the transaction.
|
||||
If any of `{signAs: some_address}` options were missing the code will return a validation error as follow:
|
||||
If the multi-signing account was setup properly, the above example logs `resultCode: 'tesSUCCESS'` and the hash for the transaction. If any of `{signAs: some_address}` options were missing, the code returns a validation error such as:
|
||||
|
||||
```
|
||||
[ValidationError(txJSON is not the same for all signedTransactions)]
|
||||
```
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`signPaymentChannelClaim(channel: string, amount: string, privateKey: string): string`
|
||||
|
||||
Sign a payment channel claim. The signature can be submitted in a subsequent [PaymentChannelClaim](#preparepaymentchannelclaim) transaction.
|
||||
Sign a payment channel claim. A [PaymentChannelClaim](#preparepaymentchannelclaim) transaction can use the resulting signature to withdraw XRP from a payment channel.
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ Transaction hash: 80C5E11E1A21A626759D6CB944B33DBAAC66BD704A289C86E330B847904F5C
|
||||
|
||||
Convert a classic address and tag to an X-address.
|
||||
|
||||
If `test` is `true`, the address with start with `T` and readers of the address will know that the address is intended for use on a test network.
|
||||
If `test` is `true`, the address starts with `T` to show that the address is intended for use on a test network.
|
||||
|
||||
### Example: Encode an X-address with tag 4294967295
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ A transaction type is specified by the strings in the first column in the table
|
||||
|
||||
Type | Description
|
||||
---- | -----------
|
||||
[payment](#payment) | A `payment` transaction represents a transfer of value from one account to another. Depending on the [path](https://ripple.com/build/paths/) taken, additional exchanges of value may occur atomically to facilitate the payment.
|
||||
[payment](#payment) | A `payment` transaction represents a transfer of value from one account to another. Depending on the [path](https://xrpl.org/paths.html) taken, additional exchanges of value may occur atomically to enable the payment.
|
||||
[order](#order) | An `order` transaction creates a limit order. It defines an intent to exchange currencies, and creates an order in the XRP Ledger's order book if not completely fulfilled when placed. Orders can be partially fulfilled.
|
||||
[orderCancellation](#order-cancellation) | An `orderCancellation` transaction cancels an order in the XRP Ledger's order book.
|
||||
[trustline](#trustline) | A `trustline` transaction creates or modifies a trust line between two accounts.
|
||||
[settings](#settings) | A `settings` transaction modifies the settings of an account in the XRP Ledger.
|
||||
[escrowCreation](#escrow-creation) | An `escrowCreation` transaction creates an escrow on the ledger, which locks XRP until a cryptographic condition is met or it expires. It is like an escrow service where the XRP Ledger acts as the escrow agent.
|
||||
[escrowCancellation](#escrow-cancellation) | An `escrowCancellation` transaction unlocks the funds in an escrow and sends them back to the creator of the escrow, but it will only work after the escrow expires.
|
||||
[escrowExecution](#escrow-execution) | An `escrowExecution` transaction unlocks the funds in an escrow and sends them to the destination of the escrow, but it will only work if the cryptographic condition is provided.
|
||||
[escrowCancellation](#escrow-cancellation) | An `escrowCancellation` transaction unlocks the funds in an escrow and sends them back to the creator of the escrow, if the escrow has expired.
|
||||
[escrowExecution](#escrow-execution) | An `escrowExecution` transaction unlocks the funds in an escrow and sends them to the destination of the escrow, if the conditions for the escrow are met.
|
||||
[checkCreate](#check-create) | A `checkCreate` transaction creates a check on the ledger, which is a deferred payment that can be cashed by its intended destination.
|
||||
[checkCancel](#check-cancel) | A `checkCancel` transaction cancels an unredeemed Check, removing it from the ledger without sending any money.
|
||||
[checkCash](#check-cash) | A `checkCash` transaction redeems a Check to receive up to the amount authorized by the corresponding `checkCreate` transaction. Only the `destination` address of a Check can cash it.
|
||||
@@ -49,7 +49,7 @@ Every transaction must destroy a small amount of XRP as a cost to apply the tran
|
||||
|
||||
You can choose the size of the fee you want to pay or let a default be used. You can get an estimate of the fee required to be included in the next ledger closing with the [getFee](#getfee) method.
|
||||
|
||||
For a multi-signed transaction, ripple-lib automatically multiplies the `fee` by (1 + Number of Signatures Provided). For example, if you set `instructions.fee = '0.000020'` and `instructions.signersCount = 2`, the prepared transaction's `Fee` will be 20 drops × (1 + 2 Signatures) = 60 drops. See [Transaction Cost](https://developers.ripple.com/transaction-cost.html).
|
||||
For a multi-signed transaction, ripple-lib automatically multiplies the `fee` by (1 + Number of Signatures Provided). For example, if you set `instructions.fee = '0.000020'` and `instructions.signersCount = 2`, the prepared transaction's `Fee` is 20 drops × (1 + 2 Signatures) = 60 drops. See [Transaction Cost](https://xrpl.org/transaction-cost.html).
|
||||
|
||||
## Transaction Instructions
|
||||
|
||||
@@ -57,7 +57,7 @@ Transaction instructions indicate how to execute a transaction, complementary wi
|
||||
|
||||
<%- renderSchema("objects/instructions.json") %>
|
||||
|
||||
We recommend that you specify a `maxLedgerVersion` so that you can quickly determine that a failed transaction will never succeed in the future. It is impossible for a transaction to succeed after the XRP Ledger's consensus-validated ledger version exceeds the transaction's `maxLedgerVersion`. If you omit `maxLedgerVersion`, the "prepare\*" method automatically supplies a `maxLedgerVersion` equal to the current ledger plus 3, which it includes in the return value from the "prepare\*" method.
|
||||
We recommend that you specify a `maxLedgerVersion` so that you can quickly determine that a failed transaction can never succeed in the future. It is impossible for a transaction to succeed after the XRP Ledger's consensus-validated ledger version exceeds the transaction's `maxLedgerVersion`. If you omit `maxLedgerVersion`, the "prepare\*" method automatically supplies a `maxLedgerVersion` equal to the current ledger plus 3, which it includes in the return value from the "prepare\*" method.
|
||||
|
||||
## Transaction ID
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ Applies globally to all transactions.
|
||||
|
||||
`txFlags.Payment.NoRippleDirect`: Do not use the default path; only use specified paths. This is intended to force the transaction to take arbitrage opportunities. Most clients do not need this.
|
||||
|
||||
`txFlags.Payment.PartialPayment`: If the specified destination amount cannot be sent without spending more than the source maxAmount, reduce the received amount instead of failing outright. See [Partial Payments](https://developers.ripple.com/partial-payments.html) for more details.
|
||||
`txFlags.Payment.PartialPayment`: If the specified destination amount cannot be sent without spending more than the source maxAmount, reduce the received amount instead of failing outright. See [Partial Payments](https://xrpl.org/partial-payments.html) for more details.
|
||||
|
||||
`txFlags.Payment.LimitQuality`: Only take paths where all the conversions have an input:output ratio that is equal or better than the ratio of `destination.amount`:`source.maxAmount`. See [Limit Quality](https://developers.ripple.com/payment.html#limit-quality) for details.
|
||||
`txFlags.Payment.LimitQuality`: Only take paths where all the conversions have an input:output ratio that is equal or better than the ratio of `destination.amount`:`source.maxAmount`. See [Limit Quality](https://xrpl.org/payment.html#limit-quality) for details.
|
||||
|
||||
### OfferCreate Flags
|
||||
|
||||
@@ -38,9 +38,9 @@ Applies globally to all transactions.
|
||||
|
||||
`txFlags.TrustSet.NoRipple`: Obsolete.
|
||||
|
||||
`txFlags.TrustSet.SetNoRipple`: Blocks [rippling](https://developers.ripple.com/rippling.html) between two trustlines of the same currency, if this flag is set on both.
|
||||
`txFlags.TrustSet.SetNoRipple`: Blocks [rippling](https://xrpl.org/rippling.html) between two trustlines of the same currency, if this flag is set on both.
|
||||
|
||||
`txFlags.TrustSet.ClearNoRipple`: Clears the No-[Rippling](https://developers.ripple.com/rippling.html) flag.
|
||||
`txFlags.TrustSet.ClearNoRipple`: Clears the No-[Rippling](https://xrpl.org/rippling.html) flag.
|
||||
|
||||
`txFlags.TrustSet.SetFreeze`: Freeze the trustline. A non-XRP currency can be frozen by the exchange or gateway that issued it. XRP cannot be frozen.
|
||||
|
||||
@@ -50,7 +50,7 @@ Applies globally to all transactions.
|
||||
|
||||
You can use the `prepareSettings` method to change your account flags. This method uses AccountSet flags internally.
|
||||
|
||||
In the rippled API, Account Flags can be enabled and disabled with the SetFlag and ClearFlag parameters. See [AccountSet Flags](https://developers.ripple.com/accountset.html#accountset-flags).
|
||||
In the rippled API, Account Flags can be enabled and disabled with the SetFlag and ClearFlag parameters. See [AccountSet Flags](https://xrpl.org/accountset.html#accountset-flags).
|
||||
|
||||
The AccountSet transaction type has some transaction flags, but their use is discouraged.
|
||||
|
||||
|
||||
26
package.json
26
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ripple-lib",
|
||||
"version": "1.9.3",
|
||||
"version": "1.10.0",
|
||||
"license": "ISC",
|
||||
"description": "A TypeScript/JavaScript API for interacting with the XRP Ledger in Node.js and the browser",
|
||||
"files": [
|
||||
@@ -26,9 +26,8 @@
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"jsonschema": "1.2.2",
|
||||
"lodash": "^4.17.4",
|
||||
"lodash.isequal": "^4.5.0",
|
||||
"ripple-address-codec": "^4.1.1",
|
||||
"ripple-binary-codec": "^1.1.2",
|
||||
"ripple-binary-codec": "^1.1.3",
|
||||
"ripple-keypairs": "^1.0.3",
|
||||
"ripple-lib-transactionparser": "0.8.2",
|
||||
"ws": "^7.2.0"
|
||||
@@ -37,8 +36,8 @@
|
||||
"elliptic": "^6.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^8.2.1",
|
||||
"@types/node": "^14.0.1",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"@types/node": "^16.4.3",
|
||||
"@typescript-eslint/eslint-plugin": "^2.3.3",
|
||||
"@typescript-eslint/parser": "^2.27.0",
|
||||
"assert": "^2.0.0",
|
||||
@@ -49,14 +48,19 @@
|
||||
"ejs": "^3.0.1",
|
||||
"eslint": "^6.5.1",
|
||||
"eventemitter2": "^6.0.0",
|
||||
"https-browserify": "^1.0.0",
|
||||
"json-schema-to-markdown-table": "^0.4.0",
|
||||
"mocha": "^7",
|
||||
"mocha": "^9",
|
||||
"nyc": "^15",
|
||||
"path-browserify": "1.0.1",
|
||||
"prettier": "^2.0.5",
|
||||
"process": "^0.11.10",
|
||||
"puppeteer": "5.4.1",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"ts-node": "^9.1.1",
|
||||
"typescript": "^3.7.5",
|
||||
"stream-http": "3.1.1",
|
||||
"ts-loader": "^8.0.11",
|
||||
"ts-node": "^10.1.0",
|
||||
"typescript": "^3.9.9",
|
||||
"url": "^0.11.0",
|
||||
"webpack": "^5.6.0",
|
||||
"webpack-bundle-analyzer": "^4.1.0",
|
||||
@@ -73,8 +77,10 @@
|
||||
"doctoc": "doctoc docs/index.md --title '# RippleAPI Reference' --github --maxlevel 2",
|
||||
"docgen": "node --harmony scripts/build_docs.js",
|
||||
"prepublish": "yarn clean && yarn build",
|
||||
"test": "TS_NODE_PROJECT=src/tsconfig.json nyc mocha --exit",
|
||||
"test:watch": "TS_NODE_PROJECT=src/tsconfig.json mocha --watch --reporter dot",
|
||||
"test": "TS_NODE_PROJECT=src/tsconfig.json nyc mocha --config=test/.mocharc.json --exit",
|
||||
"test:integration": "TS_NODE_PROJECT=src/tsconfig.json nyc mocha ./test/integration/*.ts",
|
||||
"test:browser": "TS_NODE_PROJECT=src/tsconfig.json nyc mocha ./test/browser/*.ts",
|
||||
"test:watch": "TS_NODE_PROJECT=src/tsconfig.json mocha --config=test/.mocharc.json --watch --reporter dot",
|
||||
"format": "prettier --write '{src,test}/**/*.ts'",
|
||||
"lint": "eslint 'src/**/*.ts' 'test/*-test.{ts,js}'",
|
||||
"perf": "./scripts/perf_test.sh",
|
||||
|
||||
@@ -104,7 +104,7 @@ async function performPayments(payments) {
|
||||
// Most of the time we'll get 'tesSUCCESS' or (after many submissions) 'terQUEUED'
|
||||
console.log(`tx ${i} - tentative: ${result.resultCode}`)
|
||||
|
||||
const txFinalizedPromise = new Promise((resolve) => {
|
||||
const txFinalizedPromise = new Promise<void>((resolve) => {
|
||||
const ledgerClosedCallback = async (event: LedgerClosedEvent) => {
|
||||
let status
|
||||
try {
|
||||
|
||||
112
src/api.ts
112
src/api.ts
@@ -1,6 +1,7 @@
|
||||
import {EventEmitter} from 'events'
|
||||
import {
|
||||
Connection,
|
||||
constants,
|
||||
errors,
|
||||
validate,
|
||||
xrpToDrops,
|
||||
@@ -8,7 +9,7 @@ import {
|
||||
rippleTimeToISO8601,
|
||||
iso8601ToRippleTime,
|
||||
txFlags,
|
||||
ensureClassicAddress
|
||||
ensureClassicAddress,
|
||||
} from './common'
|
||||
import {
|
||||
connect,
|
||||
@@ -47,11 +48,7 @@ import prepareTicketCreate from './transaction/ticket'
|
||||
import sign from './transaction/sign'
|
||||
import combine from './transaction/combine'
|
||||
import submit from './transaction/submit'
|
||||
import {
|
||||
generateAddressAPI,
|
||||
GenerateAddressOptions,
|
||||
GeneratedAddress
|
||||
} from './offline/generate-address'
|
||||
import {generateAddress, generateXAddress} from './offline/utils'
|
||||
import {deriveKeypair, deriveAddress, deriveXAddress} from './offline/derive'
|
||||
import computeLedgerHash from './offline/ledgerhash'
|
||||
import signPaymentChannelClaim from './offline/sign-payment-channel-claim'
|
||||
@@ -89,7 +86,22 @@ import {getServerInfo, getFee} from './common/serverinfo'
|
||||
import {clamp, renameCounterpartyToIssuer} from './ledger/utils'
|
||||
import {TransactionJSON, Instructions, Prepare} from './transaction/types'
|
||||
import {ConnectionUserOptions} from './common/connection'
|
||||
import {classicAddressToXAddress, xAddressToClassicAddress, isValidXAddress, isValidClassicAddress, encodeSeed, decodeSeed, encodeAccountID, decodeAccountID, encodeNodePublic, decodeNodePublic, encodeAccountPublic, decodeAccountPublic, encodeXAddress, decodeXAddress} from 'ripple-address-codec'
|
||||
import {
|
||||
classicAddressToXAddress,
|
||||
xAddressToClassicAddress,
|
||||
isValidXAddress,
|
||||
isValidClassicAddress,
|
||||
encodeSeed,
|
||||
decodeSeed,
|
||||
encodeAccountID,
|
||||
decodeAccountID,
|
||||
encodeNodePublic,
|
||||
decodeNodePublic,
|
||||
encodeAccountPublic,
|
||||
decodeAccountPublic,
|
||||
encodeXAddress,
|
||||
decodeXAddress
|
||||
} from 'ripple-address-codec'
|
||||
import {
|
||||
computeBinaryTransactionHash,
|
||||
computeTransactionHash,
|
||||
@@ -104,6 +116,8 @@ import {
|
||||
computePaymentChannelHash
|
||||
} from './common/hashes'
|
||||
|
||||
import generateFaucetWallet from './wallet/wallet-generation'
|
||||
|
||||
export interface APIOptions extends ConnectionUserOptions {
|
||||
server?: string
|
||||
feeCushion?: number
|
||||
@@ -154,7 +168,7 @@ class RippleAPI extends EventEmitter {
|
||||
this._feeCushion = options.feeCushion || 1.2
|
||||
this._maxFeeXRP = options.maxFeeXRP || '2'
|
||||
const serverURL = options.server
|
||||
if (serverURL !== undefined) {
|
||||
if (serverURL != null) {
|
||||
this.connection = new Connection(serverURL, options)
|
||||
this.connection.on('ledgerClosed', (message) => {
|
||||
this.emit('ledger', formatLedgerClose(message))
|
||||
@@ -324,7 +338,7 @@ class RippleAPI extends EventEmitter {
|
||||
}
|
||||
// If limit is not provided, fetches all data over multiple requests.
|
||||
// NOTE: This may return much more than needed. Set limit when possible.
|
||||
const countTo: number = params.limit !== undefined ? params.limit : Infinity
|
||||
const countTo: number = params.limit != null ? params.limit : Infinity
|
||||
let count: number = 0
|
||||
let marker: string = params.marker
|
||||
let lastBatchLength: number
|
||||
@@ -352,14 +366,9 @@ class RippleAPI extends EventEmitter {
|
||||
return results
|
||||
}
|
||||
|
||||
// @deprecated Use X-addresses instead
|
||||
generateAddress(options: GenerateAddressOptions = {}): GeneratedAddress {
|
||||
return generateAddressAPI({...options, includeClassicAddress: true})
|
||||
}
|
||||
|
||||
generateXAddress(options: GenerateAddressOptions = {}): GeneratedAddress {
|
||||
return generateAddressAPI(options)
|
||||
}
|
||||
// @deprecated Use X-addresses instead & Invoke from top-level package instead
|
||||
generateAddress = generateAddress
|
||||
generateXAddress = generateXAddress // @deprecated Invoke from top-level package instead
|
||||
|
||||
connect = connect
|
||||
disconnect = disconnect
|
||||
@@ -403,11 +412,14 @@ class RippleAPI extends EventEmitter {
|
||||
|
||||
submit = submit // @deprecated Use api.request('submit', { tx_blob: signedTransaction }) instead
|
||||
|
||||
deriveKeypair = deriveKeypair
|
||||
deriveAddress = deriveAddress
|
||||
computeLedgerHash = computeLedgerHash
|
||||
signPaymentChannelClaim = signPaymentChannelClaim
|
||||
verifyPaymentChannelClaim = verifyPaymentChannelClaim
|
||||
deriveKeypair = deriveKeypair // @deprecated Invoke from top-level package instead
|
||||
deriveAddress = deriveAddress // @deprecated Invoke from top-level package instead
|
||||
computeLedgerHash = computeLedgerHash // @deprecated Invoke from top-level package instead
|
||||
signPaymentChannelClaim = signPaymentChannelClaim // @deprecated Invoke from top-level package instead
|
||||
verifyPaymentChannelClaim = verifyPaymentChannelClaim // @deprecated Invoke from top-level package instead
|
||||
|
||||
generateFaucetWallet = generateFaucetWallet
|
||||
|
||||
errors = errors
|
||||
|
||||
static deriveXAddress = deriveXAddress
|
||||
@@ -418,59 +430,71 @@ class RippleAPI extends EventEmitter {
|
||||
/**
|
||||
* Static methods to expose ripple-address-codec methods
|
||||
*/
|
||||
static classicAddressToXAddress = classicAddressToXAddress
|
||||
static xAddressToClassicAddress = xAddressToClassicAddress
|
||||
static isValidXAddress = isValidXAddress
|
||||
static isValidClassicAddress = isValidClassicAddress
|
||||
static encodeSeed = encodeSeed
|
||||
static decodeSeed = decodeSeed
|
||||
static encodeAccountID = encodeAccountID
|
||||
static decodeAccountID = decodeAccountID
|
||||
static encodeNodePublic = encodeNodePublic
|
||||
static decodeNodePublic = decodeNodePublic
|
||||
static encodeAccountPublic = encodeAccountPublic
|
||||
static decodeAccountPublic = decodeAccountPublic
|
||||
static encodeXAddress = encodeXAddress
|
||||
static decodeXAddress = decodeXAddress
|
||||
static classicAddressToXAddress = classicAddressToXAddress
|
||||
static xAddressToClassicAddress = xAddressToClassicAddress
|
||||
static isValidXAddress = isValidXAddress
|
||||
static isValidClassicAddress = isValidClassicAddress
|
||||
static encodeSeed = encodeSeed
|
||||
static decodeSeed = decodeSeed
|
||||
static encodeAccountID = encodeAccountID
|
||||
static decodeAccountID = decodeAccountID
|
||||
static encodeNodePublic = encodeNodePublic
|
||||
static decodeNodePublic = decodeNodePublic
|
||||
static encodeAccountPublic = encodeAccountPublic
|
||||
static decodeAccountPublic = decodeAccountPublic
|
||||
static encodeXAddress = encodeXAddress
|
||||
static decodeXAddress = decodeXAddress
|
||||
|
||||
/**
|
||||
* Static methods that replace functionality from the now-deprecated ripple-hashes library
|
||||
*/
|
||||
// Compute the hash of a binary transaction blob.
|
||||
// @deprecated Invoke from top-level package instead
|
||||
static computeBinaryTransactionHash = computeBinaryTransactionHash // (txBlobHex: string): string
|
||||
// Compute the hash of a transaction in txJSON format.
|
||||
// @deprecated Invoke from top-level package instead
|
||||
static computeTransactionHash = computeTransactionHash // (txJSON: any): string
|
||||
static computeBinaryTransactionSigningHash = computeBinaryTransactionSigningHash // (txBlobHex: string): string
|
||||
// @deprecated Invoke from top-level package instead
|
||||
static computeBinaryTransactionSigningHash =
|
||||
computeBinaryTransactionSigningHash // (txBlobHex: string): string
|
||||
// Compute the hash of an account, given the account's classic address (starting with `r`).
|
||||
// @deprecated Invoke from top-level package instead
|
||||
static computeAccountLedgerObjectID = computeAccountLedgerObjectID // (address: string): string
|
||||
// Compute the hash (ID) of an account's SignerList.
|
||||
// @deprecated Invoke from top-level package instead
|
||||
static computeSignerListLedgerObjectID = computeSignerListLedgerObjectID // (address: string): string
|
||||
// Compute the hash of an order, given the owner's classic address (starting with `r`) and the account sequence number of the `OfferCreate` order transaction.
|
||||
// @deprecated Invoke from top-level package instead
|
||||
static computeOrderID = computeOrderID // (address: string, sequence: number): string
|
||||
// Compute the hash of a trustline, given the two parties' classic addresses (starting with `r`) and the currency code.
|
||||
// @deprecated Invoke from top-level package instead
|
||||
static computeTrustlineHash = computeTrustlineHash // (address1: string, address2: string, currency: string): string
|
||||
// @deprecated Invoke from top-level package instead
|
||||
static computeTransactionTreeHash = computeTransactionTreeHash // (transactions: any[]): string
|
||||
// @deprecated Invoke from top-level package instead
|
||||
static computeStateTreeHash = computeStateTreeHash // (entries: any[]): string
|
||||
// Compute the hash of a ledger.
|
||||
// @deprecated Invoke from top-level package instead
|
||||
static computeLedgerHash = computeLedgerHash // (ledgerHeader): string
|
||||
// Compute the hash of an escrow, given the owner's classic address (starting with `r`) and the account sequence number of the `EscrowCreate` escrow transaction.
|
||||
// @deprecated Invoke from top-level package instead
|
||||
static computeEscrowHash = computeEscrowHash // (address, sequence): string
|
||||
// Compute the hash of a payment channel, given the owner's classic address (starting with `r`), the classic address of the destination, and the account sequence number of the `PaymentChannelCreate` payment channel transaction.
|
||||
// @deprecated Invoke from top-level package instead
|
||||
static computePaymentChannelHash = computePaymentChannelHash // (address, dstAddress, sequence): string
|
||||
|
||||
xrpToDrops = xrpToDrops
|
||||
dropsToXrp = dropsToXrp
|
||||
rippleTimeToISO8601 = rippleTimeToISO8601
|
||||
iso8601ToRippleTime = iso8601ToRippleTime
|
||||
xrpToDrops = xrpToDrops // @deprecated Invoke from top-level package instead
|
||||
dropsToXrp = dropsToXrp // @deprecated Invoke from top-level package instead
|
||||
rippleTimeToISO8601 = rippleTimeToISO8601 // @deprecated Invoke from top-level package instead
|
||||
iso8601ToRippleTime = iso8601ToRippleTime // @deprecated Invoke from top-level package instead
|
||||
txFlags = txFlags
|
||||
static accountSetFlags = constants.AccountSetFlags
|
||||
|
||||
isValidAddress = schemaValidator.isValidAddress
|
||||
isValidSecret = schemaValidator.isValidSecret
|
||||
}
|
||||
|
||||
export {
|
||||
RippleAPI
|
||||
}
|
||||
export {RippleAPI}
|
||||
|
||||
export type {
|
||||
AccountObjectsRequest,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import * as _ from 'lodash'
|
||||
import {RippleAPI, APIOptions} from './api'
|
||||
|
||||
class RippleAPIBroadcast extends RippleAPI {
|
||||
@@ -9,7 +8,7 @@ class RippleAPIBroadcast extends RippleAPI {
|
||||
super(options)
|
||||
|
||||
const apis: RippleAPI[] = servers.map(
|
||||
(server) => new RippleAPI(_.assign({}, options, {server}))
|
||||
(server) => new RippleAPI(Object.assign({}, options, {server}))
|
||||
)
|
||||
|
||||
// exposed for testing
|
||||
@@ -51,7 +50,7 @@ class RippleAPIBroadcast extends RippleAPI {
|
||||
onLedgerEvent(ledger) {
|
||||
if (
|
||||
ledger.ledgerVersion > this.ledgerVersion ||
|
||||
this.ledgerVersion === undefined
|
||||
this.ledgerVersion == null
|
||||
) {
|
||||
this.ledgerVersion = ledger.ledgerVersion
|
||||
this.emit('ledger', ledger)
|
||||
|
||||
@@ -68,7 +68,7 @@ const INTENTIONAL_DISCONNECT_CODE = 4000
|
||||
*/
|
||||
function createWebSocket(url: string, config: ConnectionOptions): WebSocket {
|
||||
const options: WebSocket.ClientOptions = {}
|
||||
if (config.proxy !== undefined) {
|
||||
if (config.proxy != null) {
|
||||
const parsedURL = parseUrl(url)
|
||||
const parsedProxyURL = parseUrl(config.proxy)
|
||||
const proxyOverrides = _.omitBy(
|
||||
@@ -81,9 +81,9 @@ function createWebSocket(url: string, config: ConnectionOptions): WebSocket {
|
||||
passphrase: config.passphrase,
|
||||
cert: config.certificate
|
||||
},
|
||||
_.isUndefined
|
||||
(value) => value == null
|
||||
)
|
||||
const proxyOptions = _.assign({}, parsedProxyURL, proxyOverrides)
|
||||
const proxyOptions = Object.assign({}, parsedProxyURL, proxyOverrides)
|
||||
let HttpsProxyAgent
|
||||
try {
|
||||
HttpsProxyAgent = require('https-proxy-agent')
|
||||
@@ -92,7 +92,7 @@ function createWebSocket(url: string, config: ConnectionOptions): WebSocket {
|
||||
}
|
||||
options.agent = new HttpsProxyAgent(proxyOptions)
|
||||
}
|
||||
if (config.authorization !== undefined) {
|
||||
if (config.authorization != null) {
|
||||
const base64 = Buffer.from(config.authorization).toString('base64')
|
||||
options.headers = {Authorization: `Basic ${base64}`}
|
||||
}
|
||||
@@ -103,9 +103,9 @@ function createWebSocket(url: string, config: ConnectionOptions): WebSocket {
|
||||
passphrase: config.passphrase,
|
||||
cert: config.certificate
|
||||
},
|
||||
_.isUndefined
|
||||
(value) => value == null
|
||||
)
|
||||
const websocketOptions = _.assign({}, options, optionsOverrides)
|
||||
const websocketOptions = Object.assign({}, options, optionsOverrides)
|
||||
const websocket = new WebSocket(url, null, websocketOptions)
|
||||
// we will have a listener for each outstanding request,
|
||||
// so we have to raise the limit (the default is 10)
|
||||
@@ -345,7 +345,7 @@ export class Connection extends EventEmitter {
|
||||
this.emit('error', 'badMessage', error.message, message)
|
||||
return
|
||||
}
|
||||
if (data.type === undefined && data.error) {
|
||||
if (data.type == null && data.error) {
|
||||
this.emit('error', data.error, data.error_message, data) // e.g. slowDown
|
||||
return
|
||||
}
|
||||
@@ -390,7 +390,7 @@ export class Connection extends EventEmitter {
|
||||
*/
|
||||
private _heartbeat = () => {
|
||||
return this.request({command: 'ping'}).catch(() => {
|
||||
this.reconnect().catch((error) => {
|
||||
return this.reconnect().catch((error) => {
|
||||
this.emit('error', 'reconnect', error.message, error)
|
||||
})
|
||||
})
|
||||
@@ -642,4 +642,13 @@ export class Connection extends EventEmitter {
|
||||
|
||||
return responsePromise
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Websocket connection URL
|
||||
*
|
||||
* @returns The Websocket connection URL
|
||||
*/
|
||||
getUrl(): string {
|
||||
return this._url
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export interface Settings {
|
||||
defaultRipple?: boolean
|
||||
}
|
||||
|
||||
const AccountFlagIndices = {
|
||||
const AccountSetFlags = {
|
||||
requireDestinationTag: txFlagIndices.AccountSet.asfRequireDest,
|
||||
requireAuthorization: txFlagIndices.AccountSet.asfRequireAuth,
|
||||
depositAuth: txFlagIndices.AccountSet.asfDepositAuth,
|
||||
@@ -96,4 +96,4 @@ const AccountFields = {
|
||||
TickSize: {name: 'tickSize', defaults: 0}
|
||||
}
|
||||
|
||||
export {AccountFields, AccountFlagIndices, AccountFlags}
|
||||
export {AccountFields, AccountSetFlags, AccountFlags}
|
||||
|
||||
@@ -54,6 +54,8 @@ class ResponseFormatError extends ConnectionError {}
|
||||
|
||||
class ValidationError extends RippleError {}
|
||||
|
||||
class XRPLFaucetError extends RippleError {}
|
||||
|
||||
class NotFoundError extends RippleError {
|
||||
constructor(message = 'Not found') {
|
||||
super(message)
|
||||
@@ -90,5 +92,6 @@ export {
|
||||
NotFoundError,
|
||||
PendingLedgerVersionError,
|
||||
MissingLedgerHistoryError,
|
||||
LedgerVersionError
|
||||
LedgerVersionError,
|
||||
XRPLFaucetError
|
||||
}
|
||||
|
||||
@@ -45,14 +45,14 @@ class RangeSet {
|
||||
|
||||
parseAndAddRanges(rangesString: string) {
|
||||
const rangeStrings = rangesString.split(',')
|
||||
_.forEach(rangeStrings, (rangeString) => {
|
||||
rangeStrings.forEach((rangeString) => {
|
||||
const range = rangeString.split('-').map(Number)
|
||||
this.addRange(range[0], range.length === 1 ? range[0] : range[1])
|
||||
})
|
||||
}
|
||||
|
||||
containsRange(start: number, end: number) {
|
||||
return _.some(this.ranges, (range) => range[0] <= start && range[1] >= end)
|
||||
return this.ranges.some((range) => range[0] <= start && range[1] >= end)
|
||||
}
|
||||
|
||||
containsValue(value: number) {
|
||||
|
||||
@@ -126,7 +126,7 @@ function loadSchemas() {
|
||||
require('./schemas/input/combine.json')
|
||||
]
|
||||
const titles = schemas.map((schema) => schema.title)
|
||||
const duplicates = _.keys(_.pickBy(_.countBy(titles), (count) => count > 1))
|
||||
const duplicates = Object.keys(_.pickBy(_.countBy(titles), (count) => count > 1))
|
||||
assert.ok(duplicates.length === 0, 'Duplicate schemas for: ' + duplicates)
|
||||
const validator = new Validator()
|
||||
// Register custom format validators that ignore undefined instances
|
||||
@@ -135,7 +135,7 @@ function loadSchemas() {
|
||||
|
||||
// This relies on "format": "xAddress" in `x-address.json`!
|
||||
validator.customFormats.xAddress = function (instance) {
|
||||
if (instance === undefined) {
|
||||
if (instance == null) {
|
||||
return true
|
||||
}
|
||||
return isValidXAddress(instance)
|
||||
@@ -143,21 +143,21 @@ function loadSchemas() {
|
||||
|
||||
// This relies on "format": "classicAddress" in `classic-address.json`!
|
||||
validator.customFormats.classicAddress = function (instance) {
|
||||
if (instance === undefined) {
|
||||
if (instance == null) {
|
||||
return true
|
||||
}
|
||||
return isValidAddress(instance)
|
||||
}
|
||||
|
||||
validator.customFormats.secret = function (instance) {
|
||||
if (instance === undefined) {
|
||||
if (instance == null) {
|
||||
return true
|
||||
}
|
||||
return isValidSecret(instance)
|
||||
}
|
||||
|
||||
// Register under the root URI '/'
|
||||
_.forEach(schemas, (schema) =>
|
||||
schemas.forEach((schema) =>
|
||||
validator.addSchema(schema, '/' + schema.title)
|
||||
)
|
||||
return validator
|
||||
@@ -168,7 +168,7 @@ const schemaValidator = loadSchemas()
|
||||
function schemaValidate(schemaName: string, object: any): void {
|
||||
// Lookup under the root URI '/'
|
||||
const schema = schemaValidator.getSchema('/' + schemaName)
|
||||
if (schema === undefined) {
|
||||
if (schema == null) {
|
||||
throw new ValidationError('no schema for ' + schemaName)
|
||||
}
|
||||
const result = schemaValidator.validate(object, schema)
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
},
|
||||
"test": {
|
||||
"type": "boolean",
|
||||
"description": "Specifies whether the address is intended for use on a test network such as Testnet or Devnet. If `true`, the address should only be used for testing, and will start with `T`. If `false`, the address should only be used on mainnet, and will start with `X`."
|
||||
"description": "Specifies whether the address is intended for use on a test network such as Testnet or Devnet. If `true`, the address should only be used for testing, and starts with `T`. If `false`, the address should only be used on Mainnet, and starts with `X`."
|
||||
},
|
||||
"includeClassicAddress": {
|
||||
"type": "boolean",
|
||||
"description": "If `true`, return the classic address, in addition to the X-address."
|
||||
"description": "If `true`, also return the classic address."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
},
|
||||
"test": {
|
||||
"type": "boolean",
|
||||
"description": "Specifies whether the address is intended for use on a test network such as Testnet or Devnet. If `true`, the address should only be used for testing, and will start with `T`. If `false`, the address should only be used on mainnet, and will start with `X`."
|
||||
"description": "Specifies whether the address is intended for use on a test network such as Testnet or Devnet. If `true`, the address should only be used for testing, and starts with `T`. If `false`, the address should only be used on Mainnet, and starts with `X`."
|
||||
},
|
||||
"includeClassicAddress": {
|
||||
"type": "boolean",
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"description": "Get the balance sheet as of this historical ledger version."
|
||||
}
|
||||
},
|
||||
"description": "Options to determine how the balances will be calculated.",
|
||||
"description": "Options to determine how the balances are calculated.",
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
},
|
||||
"includeAllData": {
|
||||
"type": "boolean",
|
||||
"description": "Include full transactions and/or state information if `includeTransactions` and/or `includeState` is set."
|
||||
"description": "Include the details of the transactions or state information if `includeTransactions` or `includeState` is set."
|
||||
},
|
||||
"includeTransactions": {
|
||||
"type": "boolean",
|
||||
"description": "Return an array of hashes for each transaction or an array of all transactions that were validated in this ledger version, depending on whether `includeAllData` is set."
|
||||
"description": "Return an array of transactions in this ledger. By default, provides the identifying hashes for each transaction. If `includeAllData` is true, include the entire transaction JSON for each transaction instead."
|
||||
},
|
||||
"includeState": {
|
||||
"type": "boolean",
|
||||
"description": "Return an array of hashes for all state data or an array of all state data in this ledger version, depending on whether `includeAllData` is set."
|
||||
"description": "Return an array of state data in this ledger. By default, provides the identifying hashes of state data. If `includeAllData` is true, return the state data in JSON form instead. **Admin required:** This is a very large amount of data."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
"description": "The XRP Ledger address of the account to get open orders for."
|
||||
},
|
||||
"options": {
|
||||
"description": "Options that determine what orders will be returned.",
|
||||
"description": "Options that determine what orders to return.",
|
||||
"properties": {
|
||||
"limit": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "At most this many orders will be returned."
|
||||
"description": "Return at most this many orders."
|
||||
},
|
||||
"ledgerVersion": {
|
||||
"$ref": "ledgerVersion",
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"properties": {
|
||||
"address": {
|
||||
"$ref": "address",
|
||||
"description": "The XRP Ledger address of the account where funds will come from."
|
||||
"description": "The XRP Ledger address of the planned sender."
|
||||
},
|
||||
"amount": {
|
||||
"$ref": "laxAmount",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"properties": {
|
||||
"id": {"$ref": "transactionHash"},
|
||||
"options": {
|
||||
"description": "Options to limit the ledger versions to search and/or to include raw transaction data.",
|
||||
"description": "Options to limit the ledger versions to search or include raw transaction data.",
|
||||
"properties": {
|
||||
"minLedgerVersion": {
|
||||
"$ref": "ledgerVersion",
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"properties": {
|
||||
"start": {
|
||||
"$ref": "hash256",
|
||||
"description": "If specified, this transaction will be the first transaction in the result. You cannot use `start` with `minLedgerVersion` or `maxLedgerVersion`. When `start` is specified, these ledger versions will be determined internally."
|
||||
"description": "If specified, start the results from this transaction. You cannot use `start` with `minLedgerVersion` or `maxLedgerVersion`. When `start` is specified, these ledger versions are determined internally."
|
||||
},
|
||||
"limit": {
|
||||
"type": "integer",
|
||||
@@ -30,11 +30,11 @@
|
||||
},
|
||||
"earliestFirst": {
|
||||
"type": "boolean",
|
||||
"description": "If true, sort transactions so that the earliest ones come first. By default, the newest transactions will come first."
|
||||
"description": "If true, sort transactions so that the earliest ones come first. By default, the newest transactions come first."
|
||||
},
|
||||
"excludeFailures": {
|
||||
"type": "boolean",
|
||||
"description": "If true, the result will omit transactions that did not succeed."
|
||||
"description": "If true, the result omits transactions that did not succeed."
|
||||
},
|
||||
"initiated": {
|
||||
"type": "boolean",
|
||||
@@ -54,7 +54,7 @@
|
||||
},
|
||||
"binary": {
|
||||
"type": "boolean",
|
||||
"description": "If true, the transactions will be sent from the server in a condensed binary format rather than JSON."
|
||||
"description": "If true, return transactions in binary format rather than JSON."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
"properties": {
|
||||
"privateKey": {
|
||||
"type": "privateKey",
|
||||
"description": "The uppercase hexadecimal representation of the secp256k1 or Ed25519 private key."
|
||||
"description": "The uppercase hexadecimal representation of the secp256k1 or Ed25519 private key. Ed25519 keys are prefixed with 0xED. You can read about how keys are derived [here](https://xrpl.org/cryptographic-keys.html)."
|
||||
},
|
||||
"publicKey": {
|
||||
"type": "publicKey",
|
||||
"description": "The uppercase hexadecimal representation of the secp256k1 or Ed25519 public key."
|
||||
"description": "The uppercase hexadecimal representation of the secp256k1 or Ed25519 public key. Ed25519 keys are prefixed with 0xED. You can read about how keys are derived [here](https://xrpl.org/cryptographic-keys.html)."
|
||||
}
|
||||
},
|
||||
"description": "The private and public key of the account that is initiating the transaction. (This field cannot be used with secret).",
|
||||
@@ -30,7 +30,7 @@
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
"description": "Options that control the type of signature that will be generated.",
|
||||
"description": "Options that control the type of signature to create.",
|
||||
"properties": {
|
||||
"signAs": {
|
||||
"$ref": "address",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"value": {
|
||||
"description": "The quantity of the currency, denoted as a string to retain floating point precision",
|
||||
"description": "The quantity of the currency, denoted as a string so that it does not lose precision",
|
||||
"$ref": "value"
|
||||
},
|
||||
"currency": {
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
"$ref": "value"
|
||||
},
|
||||
"maxFee": {
|
||||
"description": "Deprecated: Use `maxFeeXRP` in the RippleAPI constructor instead. The maximum fee to pay for this transaction. If this exceeds `maxFeeXRP`, `maxFeeXRP` will be used instead. See [Transaction Fees](#transaction-fees) for more information.",
|
||||
"description": "Deprecated: Use `maxFeeXRP` in the RippleAPI constructor instead. The maximum fee to pay for this transaction. If this exceeds `maxFeeXRP`, use `maxFeeXRP` instead. See [Transaction Fees](#transaction-fees) for more information.",
|
||||
"$ref": "value"
|
||||
},
|
||||
"maxLedgerVersion": {
|
||||
"description": "The highest ledger version that the transaction can be included in. If this option and `maxLedgerVersionOffset` are both omitted, the `maxLedgerVersion` option will default to 3 greater than the current validated ledger version (equivalent to `maxLedgerVersionOffset=3`). Use `null` to not set a maximum ledger version. If not null, this must be an integer greater than 0, or one of the following strings: 'validated', 'closed', 'current'.",
|
||||
"description": "The highest ledger version that the transaction can be included in. If this option and `maxLedgerVersionOffset` are both omitted, the default is 3 greater than the current validated ledger version (equivalent to `maxLedgerVersionOffset=3`). Use `null` to not set a maximum ledger version. If not null, this must be an integer greater than 0, or one of the following strings: 'validated', 'closed', 'current'.",
|
||||
"oneOf": [
|
||||
{"$ref": "ledgerVersion"},
|
||||
{"type": "null"}
|
||||
@@ -34,7 +34,7 @@
|
||||
"minimum": 0
|
||||
},
|
||||
"signersCount": {
|
||||
"description": "Number of signers that will be signing this transaction.",
|
||||
"description": "Number of signers that can multi-sign this transaction.",
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "issue",
|
||||
"description": "A currency-counterparty pair, or just currency if it's XRP",
|
||||
"description": "The currency code, and the counterparty if it's not XRP.",
|
||||
"allOf": [
|
||||
{"$ref": "amountbase"},
|
||||
{"not": {"required": ["value"]}}
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
"properties": {
|
||||
"defaultRipple": {
|
||||
"type": "boolean",
|
||||
"description": "Enable [rippling](https://ripple.com/build/understanding-the-noripple-flag/) on this account’s trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3))"
|
||||
"description": "Enable [rippling](https://xrpl.org/rippling.html) on this account’s trust lines by default. Currency issuers should enable this setting; most others should not."
|
||||
},
|
||||
"depositAuth": {
|
||||
"type": "boolean",
|
||||
"description": "Enable [Deposit Authorization](https://ripple.com/build/deposit-authorization/) on this account. If set, transactions cannot send value of any kind to this account unless the sender of those transactions is the account itself. (Requires the [DepositAuth amendment](https://ripple.com/build/known-amendments/#depositauth))"
|
||||
"description": "Enable [Deposit Authorization](https://xrpl.org/depositauth.html) on this account. If set, transactions cannot send value of any kind to this account unless the sender of those transactions is the account itself. (Requires the [DepositAuth amendment](https://xrpl.org/known-amendments.html#depositauth))"
|
||||
},
|
||||
"disableMasterKey": {
|
||||
"type": "boolean",
|
||||
"description": "Disallows use of the master key to sign transactions for this account. To disable the master key, you must authorize the transaction by signing it with the master key pair. You cannot use a regular key pair or a multi-signature. You can re-enable the master key pair using a regular key pair or multi-signature. See [AccountSet](https://developers.ripple.com/accountset.html)."
|
||||
"description": "Disallows use of the master key to sign transactions for this account. To disable the master key, you must authorize the transaction by signing it with the master key pair. You cannot use a regular key pair or a multi-signature. You can re-enable the master key pair using a regular key pair or multi-signature. See [AccountSet](https://xrpl.org/accountset.html)."
|
||||
},
|
||||
"disallowIncomingXRP": {
|
||||
"type": "boolean",
|
||||
@@ -67,7 +67,7 @@
|
||||
},
|
||||
"requireAuthorization": {
|
||||
"type": "boolean",
|
||||
"description": "If set, this account must individually approve other users in order for those users to hold this account’s issuances."
|
||||
"description": "If set, this account must individually give other users permission to hold this account’s issued tokens."
|
||||
},
|
||||
"requireDestinationTag": {
|
||||
"type": "boolean",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "tx-json",
|
||||
"link": "https://developers.ripple.com/transaction-formats.html",
|
||||
"link": "https://xrpl.org/transaction-formats.html",
|
||||
"description": "An object in rippled txJSON format",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"balances": {
|
||||
"type": "array",
|
||||
"items": {"$ref": "amount"},
|
||||
"description": "Amounts issued to the hotwallet accounts from the request. The keys are hot wallet addresses and the values are arrays of currency amounts they hold. The issuer (omitted from the currency amounts) is the account from the request."
|
||||
"description": "Amounts issued to the \"hotwallet\" accounts from the request. The keys are the accounts' addresses, and the values are arrays of currency amounts they hold. The issuer (omitted from the currency amounts) is the account from the request."
|
||||
},
|
||||
"assets": {
|
||||
"type": "array",
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"closeFlags": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "A bit-map of flags relating to the closing of this ledger. Currently, the ledger has only one flag defined for `closeFlags`: **sLCF_NoConsensusTime** (value 1). If this flag is enabled, it means that validators were in conflict regarding the correct close time for the ledger, but built otherwise the same ledger, so they declared consensus while \"agreeing to disagree\" on the close time. In this case, the consensus ledger contains a `closeTime` value that is 1 second after that of the previous ledger. (In this case, there is no official close time, but the actual real-world close time is probably 3-6 seconds later than the specified `closeTime`.)"
|
||||
"description": "A bit-map of flags relating to the closing of this ledger. Currently, the ledger has only one flag defined for `closeFlags`: **sLCF_NoConsensusTime** (value 1). If this flag is enabled, it means that validators disagreed on the correct close time for the ledger, but built otherwise the same ledger, so they declared consensus while \"agreeing to disagree\" on the close time. In this case, the consensus ledger contains a `closeTime` value that is 1 second after that of the previous ledger. (In this case, there is no official close time, but the actual real-world close time is probably 3-6 seconds later than the specified `closeTime`.)"
|
||||
},
|
||||
"ledgerHash": {
|
||||
"$ref": "hash256",
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
},
|
||||
"publicKey": {
|
||||
"$ref": "publicKey",
|
||||
"description": "Public key of the key pair the source will use to sign claims against this channel."
|
||||
"description": "Public key of the key pair the source uses to sign claims against this channel."
|
||||
},
|
||||
"cancelAfter": {
|
||||
"type": "string",
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
},
|
||||
"ioLatencyMs": {
|
||||
"type": "number",
|
||||
"description": "Amount of time spent waiting for I/O operations to be performed, in milliseconds. If this number is not very, very low, then the rippled server is probably having serious load issues."
|
||||
"description": "Amount of time spent waiting for I/O operations, in milliseconds. If this number is not very, very low, then the rippled server is probably having serious load issues."
|
||||
},
|
||||
"load": {
|
||||
"type": "object",
|
||||
@@ -26,7 +26,7 @@
|
||||
"properties": {
|
||||
"jobTypes": {
|
||||
"type": "array",
|
||||
"description": "*(Admin only)* Information about the rate of different types of jobs being performed by the server and how much time it spends on each.",
|
||||
"description": "*(Admin only)* Information about the rate of different types of jobs the server is doing and how much time it spends on each.",
|
||||
"items": {"type": "object"}
|
||||
},
|
||||
"threads": {
|
||||
@@ -62,7 +62,7 @@
|
||||
},
|
||||
"pubkeyNode": {
|
||||
"type": "string",
|
||||
"description": "Public key used to verify this node for internal communications; this key is automatically generated by the server the first time it starts up. (If deleted, the node can just create a new pair of keys.)"
|
||||
"description": "Public key used to verify this node for internal communications; this key is automatically generated by the server the first time it starts up."
|
||||
},
|
||||
"pubkeyValidator": {
|
||||
"type": "string",
|
||||
@@ -70,7 +70,7 @@
|
||||
},
|
||||
"serverState": {
|
||||
"type": "string",
|
||||
"description": "A string indicating to what extent the server is participating in the network. See [Possible Server States](https://developers.ripple.com/rippled-server-states.html) for more details.",
|
||||
"description": "A string indicating to what extent the server is participating in the network. See [Possible Server States](https://xrpl.org/rippled-server-states.html) for more details.",
|
||||
"enum": ["disconnected", "connected", "syncing", "tracking", "full", "validating", "proposing"]
|
||||
},
|
||||
"validatedLedger": {
|
||||
@@ -96,12 +96,12 @@
|
||||
},
|
||||
"reserveIncrementXRP": {
|
||||
"$ref": "value",
|
||||
"description": "Amount of XRP added to the account reserve for each object an account is responsible for in the ledger."
|
||||
"description": "Amount of XRP added to the account reserve for each object an account owns in the ledger."
|
||||
},
|
||||
"ledgerVersion": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "Identifying sequence number of this ledger version."
|
||||
"description": "Identifying ledger index of this ledger version."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
@@ -109,7 +109,7 @@
|
||||
},
|
||||
"validationQuorum": {
|
||||
"type": "number",
|
||||
"description": "Minimum number of trusted validations required in order to validate a ledger version. Some circumstances may cause the server to require more validations."
|
||||
"description": "Minimum number of trusted validations required to validate a ledger version. Some circumstances may cause the server to require more validations."
|
||||
}
|
||||
},
|
||||
"required": ["buildVersion", "completeLedgers", "hostID", "ioLatencyMs", "lastClose", "loadFactor", "peers", "pubkeyNode", "serverState", "validatedLedger", "validationQuorum"],
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
"properties": {
|
||||
"specification": {
|
||||
"$ref": "trustline",
|
||||
"description": "A trustline specification that would produce this trustline in its current state."
|
||||
"description": "A trust line specification that would produce this trust line in its current state."
|
||||
},
|
||||
"counterparty": {
|
||||
"properties": {
|
||||
"limit": {
|
||||
"$ref": "value",
|
||||
"description": "The maximum amount that the counterparty can be owed through the trustline."
|
||||
"description": "The maximum amount that the counterparty can be owed through the trust line."
|
||||
},
|
||||
"ripplingDisabled": {
|
||||
"type": "boolean",
|
||||
@@ -20,7 +20,7 @@
|
||||
},
|
||||
"frozen": {
|
||||
"type": "boolean",
|
||||
"description": "If true, the trustline is frozen, which means that funds can only be sent to the counterparty."
|
||||
"description": "If true, the trust line is frozen, which means that funds can only be sent directly to the counterparty."
|
||||
},
|
||||
"authorized": {
|
||||
"type": "boolean",
|
||||
@@ -35,10 +35,10 @@
|
||||
"properties": {
|
||||
"balance": {
|
||||
"$ref": "signedValue",
|
||||
"description": "The balance on the trustline, representing which party owes the other and by how much."
|
||||
"description": "The balance on the trust line, representing which party owes the other and by how much."
|
||||
}
|
||||
},
|
||||
"description": "Properties of the trustline regarding it's current state that are not part of the specification.",
|
||||
"description": "Non-settings details of the trust line's state.",
|
||||
"required": ["balance"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"properties": {
|
||||
"result": {
|
||||
"type": "string",
|
||||
"description": "Result code returned by rippled. See [Transaction Results](https://developers.ripple.com/transaction-results.html) for a complete list."
|
||||
"description": "Result code returned by rippled. See [Transaction Results](https://xrpl.org/transaction-results.html) for a complete list."
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"properties": {
|
||||
"fee": {
|
||||
"$ref": "value",
|
||||
"description": "The fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information. For multi-signed transactions, this fee will be multiplied by (N+1), where N is the number of signatures you plan to provide."
|
||||
"description": "The fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information. For multi-signed transactions, this fee is multiplied by (N+1), where N is the number of signatures you plan to provide."
|
||||
},
|
||||
"sequence": {
|
||||
"$ref": "sequence",
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
},
|
||||
"engine_result": {
|
||||
"type": "string",
|
||||
"description": "Code indicating the preliminary result of the transaction, for example `tesSUCCESS`. [List of transaction responses](https://developers.ripple.com/transaction-results.html)"
|
||||
"description": "Code indicating the preliminary result of the transaction, for example `tesSUCCESS`. [List of transaction responses](https://xrpl.org/transaction-results.html)"
|
||||
},
|
||||
"engine_result_code": {
|
||||
"type": "integer",
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
"destinationXAddress": {
|
||||
"$ref": "address",
|
||||
"description": "X-address of an account to receive any leftover XRP after deleting the sending account. Must be a funded account in the ledger, and must not be the sending account."
|
||||
}
|
||||
},
|
||||
"memos": {"$ref": "memos"}
|
||||
},
|
||||
"anyOf": [
|
||||
{
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"checkID": {
|
||||
"$ref": "hash256",
|
||||
"description": "The ID of the Check ledger object to cancel, as a 64-character hexadecimal string."
|
||||
}
|
||||
},
|
||||
"memos": {"$ref": "memos"}
|
||||
},
|
||||
"required": ["checkID"],
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
"deliverMin": {
|
||||
"$ref": "laxAmount",
|
||||
"description": "Redeem the Check for at least this amount and for as much as possible. The currency must match that of the sendMax of the corresponding CheckCreate transaction. You must provide either this field or amount."
|
||||
}
|
||||
},
|
||||
"memos": {"$ref": "memos"}
|
||||
},
|
||||
"required": ["checkID"],
|
||||
"oneOf": [
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
"invoiceID": {
|
||||
"$ref": "hash256",
|
||||
"description": "256-bit hash, as a 64-character hexadecimal string, representing a specific reason or identifier for this check."
|
||||
}
|
||||
},
|
||||
"memos": {"$ref": "memos"}
|
||||
},
|
||||
"required": ["destination", "sendMax"],
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"unauthorize": {
|
||||
"$ref": "address",
|
||||
"description": "Address of the account that can cash the check."
|
||||
}
|
||||
},
|
||||
"memos": {"$ref": "memos"}
|
||||
},
|
||||
"oneOf": [
|
||||
{"required": ["authorize"]},
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"$ref": "hash256"
|
||||
},
|
||||
"allowPartialPayment": {
|
||||
"description": "If true, this payment should proceed even if the whole amount cannot be delivered due to a lack of liquidity or a lack of funds in the source account.",
|
||||
"description": "If true, this payment can deliver less than the full amount.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"noDirectRipple": {
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
},
|
||||
"immediateOrCancel": {
|
||||
"type": "boolean",
|
||||
"description": "Treat the offer as an [Immediate or Cancel order](http://en.wikipedia.org/wiki/Immediate_or_cancel). If enabled, the offer will never become a ledger node: it only attempts to match existing offers in the ledger. This cannot be used with `fillOrKill`."
|
||||
"description": "Treat the offer as an [Immediate or Cancel order](http://en.wikipedia.org/wiki/Immediate_or_cancel). If enabled, do not create an object in the ledger that can be matched later: instead, only execute as much as can be fulfilled immediately. This cannot be used with `fillOrKill`."
|
||||
},
|
||||
"fillOrKill": {
|
||||
"type": "boolean",
|
||||
"description": "Treat the offer as a [Fill or Kill order](http://en.wikipedia.org/wiki/Fill_or_kill). Only attempt to match existing offers in the ledger, and only do so if the entire quantity can be exchanged. This cannot be used with `immediateOrCancel`."
|
||||
},
|
||||
"passive": {
|
||||
"description": "If enabled, the offer will not consume offers that exactly match it, and instead becomes an Offer node in the ledger. It will still consume offers that cross it.",
|
||||
"description": "If enabled, the offer does not consume offers that exactly match it, and instead becomes an Offer node in the ledger. It still consumes offers that cross it.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"expirationTime": {
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
"close": {
|
||||
"type": "boolean",
|
||||
"description": "Request to close the channel. If the channel has no XRP remaining or the destination address requests it, closes the channel immediately (returning unclaimed XRP to the source address). Otherwise, sets the channel to expire after settleDelay seconds have passed."
|
||||
}
|
||||
},
|
||||
"memos": {"$ref": "memos"}
|
||||
},
|
||||
"required": ["channel"],
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
"destinationTag": {
|
||||
"$ref": "tag",
|
||||
"description": "Destination tag."
|
||||
}
|
||||
},
|
||||
"memos": {"$ref": "memos"}
|
||||
},
|
||||
"required": ["amount", "destination", "settleDelay", "publicKey"],
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "New expiration for this channel. (This does not change the cancelAfter expiration, if the channel has one.) Cannot move the expiration sooner than settleDelay seconds from time of the request."
|
||||
}
|
||||
},
|
||||
"memos": {"$ref": "memos"}
|
||||
},
|
||||
"required": ["amount", "channel"],
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"$ref": "hash256"
|
||||
},
|
||||
"allowPartialPayment": {
|
||||
"description": "If true, this payment should proceed even if the whole amount cannot be delivered due to a lack of liquidity or a lack of funds in the source account.",
|
||||
"description": "If true, this payment can deliver less than the full amount.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"noDirectRipple": {
|
||||
|
||||
@@ -33,8 +33,9 @@ export type GetServerInfoResponse = {
|
||||
networkLedger?: string
|
||||
}
|
||||
|
||||
function renameKeys(object, mapping) {
|
||||
_.forEach(mapping, (to, from) => {
|
||||
function renameKeys(object: Record<string, any>, mapping: Record<string, any>) {
|
||||
Object.entries(mapping).forEach(entry => {
|
||||
const [from, to] = entry;
|
||||
object[to] = object[from]
|
||||
delete object[from]
|
||||
})
|
||||
@@ -62,15 +63,19 @@ function getServerInfo(this: RippleAPI): Promise<GetServerInfoResponse> {
|
||||
// This is a public API that can be called directly.
|
||||
// This is not used by the `prepare*` methods. See `src/transaction/utils.ts`
|
||||
async function getFee(this: RippleAPI, cushion?: number): Promise<string> {
|
||||
if (cushion === undefined) {
|
||||
if (cushion == null) {
|
||||
cushion = this._feeCushion
|
||||
}
|
||||
if (cushion === undefined) {
|
||||
if (cushion == null) {
|
||||
cushion = 1.2
|
||||
}
|
||||
|
||||
const serverInfo = (await this.request('server_info')).info
|
||||
const baseFeeXrp = new BigNumber(serverInfo.validated_ledger.base_fee_xrp)
|
||||
if (serverInfo.load_factor == null) {
|
||||
// https://github.com/ripple/rippled/issues/3812#issuecomment-816871100
|
||||
serverInfo.load_factor = 1
|
||||
}
|
||||
let fee = baseFeeXrp.times(serverInfo.load_factor).times(cushion)
|
||||
|
||||
// Cap fee to `this._maxFeeXRP`
|
||||
|
||||
@@ -10,12 +10,6 @@ export interface Ledger {
|
||||
total_coins: string
|
||||
transaction_hash: string
|
||||
transactions: string[] | object[]
|
||||
// @deprecated
|
||||
seqNum?: string
|
||||
// @deprecated
|
||||
totalCoins?: string
|
||||
// @deprecated
|
||||
hash?: string
|
||||
close_flags?: number
|
||||
parent_close_time?: number
|
||||
accountState?: any[]
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import * as _ from 'lodash'
|
||||
import BigNumber from 'bignumber.js'
|
||||
import {deriveKeypair} from 'ripple-keypairs'
|
||||
import {Amount, RippledAmount} from './types/objects'
|
||||
import {RippledAmount} from './types/objects'
|
||||
import {ValidationError} from './errors'
|
||||
import {xAddressToClassicAddress} from 'ripple-address-codec'
|
||||
|
||||
function isValidSecret(secret: string): boolean {
|
||||
try {
|
||||
@@ -105,20 +106,31 @@ function xrpToDrops(xrp: BigNumber.Value): string {
|
||||
.toString(10)
|
||||
}
|
||||
|
||||
function toRippledAmount(amount: Amount): RippledAmount {
|
||||
function toRippledAmount(amount: RippledAmount): RippledAmount {
|
||||
if (typeof amount === 'string')
|
||||
return amount;
|
||||
|
||||
if (amount.currency === 'XRP') {
|
||||
return xrpToDrops(amount.value)
|
||||
}
|
||||
if (amount.currency === 'drops') {
|
||||
return amount.value
|
||||
}
|
||||
|
||||
let issuer = amount.counterparty || amount.issuer
|
||||
let tag: number | false = false;
|
||||
|
||||
try {
|
||||
({classicAddress: issuer, tag} = xAddressToClassicAddress(issuer))
|
||||
} catch (e) { /* not an X-address */ }
|
||||
|
||||
if (tag !== false) {
|
||||
throw new ValidationError("Issuer X-address includes a tag")
|
||||
}
|
||||
|
||||
return {
|
||||
currency: amount.currency,
|
||||
issuer: amount.counterparty
|
||||
? amount.counterparty
|
||||
: amount.issuer
|
||||
? amount.issuer
|
||||
: undefined,
|
||||
issuer,
|
||||
value: amount.value
|
||||
}
|
||||
}
|
||||
@@ -127,9 +139,8 @@ function convertKeysFromSnakeCaseToCamelCase(obj: any): any {
|
||||
if (typeof obj === 'object') {
|
||||
const accumulator = Array.isArray(obj) ? [] : {}
|
||||
let newKey
|
||||
return _.reduce(
|
||||
obj,
|
||||
(result, value, key) => {
|
||||
return Object.entries(obj).reduce(
|
||||
(result, [key, value]) => {
|
||||
newKey = key
|
||||
// taking this out of function leads to error in PhantomJS
|
||||
const FINDSNAKE = /([a-zA-Z]_[a-zA-Z])/g
|
||||
@@ -146,7 +157,7 @@ function convertKeysFromSnakeCaseToCamelCase(obj: any): any {
|
||||
}
|
||||
|
||||
function removeUndefined<T extends object>(obj: T): T {
|
||||
return _.omitBy(obj, _.isUndefined) as T
|
||||
return _.omitBy(obj, value => value == null) as T
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,9 +8,9 @@ function error(text) {
|
||||
|
||||
function validateLedgerRange(options) {
|
||||
if (
|
||||
!_.isUndefined(options) &&
|
||||
!_.isUndefined(options.minLedgerVersion) &&
|
||||
!_.isUndefined(options.maxLedgerVersion)
|
||||
options != null &&
|
||||
options.minLedgerVersion != null &&
|
||||
options.maxLedgerVersion != null
|
||||
) {
|
||||
if (Number(options.minLedgerVersion) > Number(options.maxLedgerVersion)) {
|
||||
throw error('minLedgerVersion must not be greater than maxLedgerVersion')
|
||||
|
||||
@@ -4,5 +4,7 @@ export * from './transaction/types'
|
||||
|
||||
export * from './common/types/objects/ledger'
|
||||
|
||||
export * from './offline/utils';
|
||||
|
||||
// Broadcast api is experimental
|
||||
export {RippleAPIBroadcast} from './broadcast'
|
||||
|
||||
@@ -18,29 +18,38 @@ export type GetBalanceSheet = {
|
||||
}>
|
||||
}
|
||||
|
||||
function formatBalanceSheet(balanceSheet): GetBalanceSheet {
|
||||
type BalanceSheet = {
|
||||
account: string,
|
||||
assets?: Record<string, any>,
|
||||
balances?: Record<string, any>,
|
||||
obligations?: Record<string, string>,
|
||||
ledger_current_index?: number,
|
||||
validated?: boolean
|
||||
}
|
||||
|
||||
function formatBalanceSheet(balanceSheet: BalanceSheet): GetBalanceSheet {
|
||||
const result: GetBalanceSheet = {}
|
||||
|
||||
if (!_.isUndefined(balanceSheet.balances)) {
|
||||
if (balanceSheet.balances != null) {
|
||||
result.balances = []
|
||||
_.forEach(balanceSheet.balances, (balances, counterparty) => {
|
||||
_.forEach(balances, (balance) => {
|
||||
Object.entries(balanceSheet.balances).forEach(entry => {
|
||||
const [counterparty, balances] = entry;
|
||||
balances.forEach((balance) => {
|
||||
result.balances.push(Object.assign({counterparty}, balance))
|
||||
})
|
||||
})
|
||||
}
|
||||
if (!_.isUndefined(balanceSheet.assets)) {
|
||||
if (balanceSheet.assets != null) {
|
||||
result.assets = []
|
||||
_.forEach(balanceSheet.assets, (assets, counterparty) => {
|
||||
_.forEach(assets, (balance) => {
|
||||
Object.entries(balanceSheet.assets).forEach(([counterparty, assets]) => {
|
||||
assets.forEach((balance) => {
|
||||
result.assets.push(Object.assign({counterparty}, balance))
|
||||
})
|
||||
})
|
||||
}
|
||||
if (!_.isUndefined(balanceSheet.obligations)) {
|
||||
result.obligations = _.map(
|
||||
balanceSheet.obligations as {[key: string]: string},
|
||||
(value, currency) => ({currency, value})
|
||||
if (balanceSheet.obligations != null) {
|
||||
result.obligations = Object.entries(balanceSheet.obligations as {[key: string]: string}).map(
|
||||
([currency, value]) => ({currency, value})
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ function getLedgerVersionHelper(
|
||||
connection: Connection,
|
||||
optionValue?: number
|
||||
): Promise<number> {
|
||||
if (optionValue !== undefined && optionValue !== null) {
|
||||
if (optionValue != null && optionValue !== null) {
|
||||
return Promise.resolve(optionValue)
|
||||
}
|
||||
return connection.getLedgerVersion()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as assert from 'assert'
|
||||
import {removeUndefined} from '../../common'
|
||||
import {classicAddressToXAddress} from 'ripple-address-codec'
|
||||
import {parseMemos} from './utils'
|
||||
|
||||
export type FormattedAccountDelete = {
|
||||
// account (address) of an account to receive any leftover XRP after deleting the sending account.
|
||||
@@ -21,11 +22,12 @@ function parseAccountDelete(tx: any): FormattedAccountDelete {
|
||||
assert.ok(tx.TransactionType === 'AccountDelete')
|
||||
|
||||
return removeUndefined({
|
||||
memos: parseMemos(tx),
|
||||
destination: tx.Destination,
|
||||
destinationTag: tx.DestinationTag,
|
||||
destinationXAddress: classicAddressToXAddress(
|
||||
tx.Destination,
|
||||
tx.DestinationTag === undefined ? false : tx.DestinationTag,
|
||||
tx.DestinationTag == null ? false : tx.DestinationTag,
|
||||
false
|
||||
)
|
||||
})
|
||||
|
||||
@@ -14,16 +14,16 @@ function parseAccountTrustline(trustline: Trustline): FormattedTrustline {
|
||||
counterparty: trustline.account,
|
||||
qualityIn: parseQuality(trustline.quality_in) || undefined,
|
||||
qualityOut: parseQuality(trustline.quality_out) || undefined,
|
||||
ripplingDisabled: trustline.no_ripple || undefined,
|
||||
frozen: trustline.freeze || undefined,
|
||||
authorized: trustline.authorized || undefined
|
||||
ripplingDisabled: trustline.no_ripple,
|
||||
frozen: trustline.freeze,
|
||||
authorized: trustline.authorized
|
||||
})
|
||||
// rippled doesn't provide the counterparty's qualities
|
||||
const counterparty = removeUndefined({
|
||||
limit: trustline.limit_peer,
|
||||
ripplingDisabled: trustline.no_ripple_peer || undefined,
|
||||
frozen: trustline.freeze_peer || undefined,
|
||||
authorized: trustline.peer_authorized || undefined
|
||||
ripplingDisabled: trustline.no_ripple_peer,
|
||||
frozen: trustline.freeze_peer,
|
||||
authorized: trustline.peer_authorized
|
||||
})
|
||||
const state = {
|
||||
balance: trustline.balance
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import * as assert from 'assert'
|
||||
import {parseMemos} from './utils'
|
||||
|
||||
function parseOrderCancellation(tx: any): object {
|
||||
assert.ok(tx.TransactionType === 'OfferCancel')
|
||||
return {
|
||||
memos: parseMemos(tx),
|
||||
orderSequence: tx.OfferSequence
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user