mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-05 05:15:48 +00:00
Compare commits
558 Commits
1.0.0-beta
...
1.10.0
| 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 | ||
|
|
362bb13da1 | ||
|
|
d76a5fc87a | ||
|
|
824f87a692 | ||
|
|
fa2385ee1c | ||
|
|
2be7a8fa94 | ||
|
|
7d6a3a7518 | ||
|
|
61692a5e34 | ||
|
|
e82c585955 | ||
|
|
bc50603111 | ||
|
|
debb9cb3a5 | ||
|
|
4fd74b3671 | ||
|
|
eb4ac74ce6 | ||
|
|
cf4d2b2c1a | ||
|
|
c79b044aaa | ||
|
|
32718d583b | ||
|
|
c3965f325b | ||
|
|
7b77177962 | ||
|
|
3781b798a1 | ||
|
|
31314212a5 | ||
|
|
7d36cfa068 | ||
|
|
848c179fd4 | ||
|
|
e2cecd07e4 | ||
|
|
08b76fba22 | ||
|
|
2642589ea4 | ||
|
|
965dc4bd87 | ||
|
|
c9689ec2a8 | ||
|
|
9a3ef216f9 | ||
|
|
e8817d9e0b | ||
|
|
abb1d23ee2 | ||
|
|
9636849c63 | ||
|
|
4aa76b38f9 | ||
|
|
03655b4ed2 | ||
|
|
f1ec45769b | ||
|
|
5db1f5668c | ||
|
|
dd4c6a0353 | ||
|
|
95a2655501 | ||
|
|
2ba31c5b75 | ||
|
|
33fb35138f | ||
|
|
ed26f9a763 | ||
|
|
415a61f06a | ||
|
|
4eb64b5e72 | ||
|
|
9e96fa3473 | ||
|
|
1c1a3fa583 | ||
|
|
c985838cdd | ||
|
|
81dfd99642 | ||
|
|
9f6fa6a4fd | ||
|
|
6b4fa159ea | ||
|
|
782787a5b9 | ||
|
|
fd0f64fe54 | ||
|
|
c7e08378ac | ||
|
|
382cf4cb1f | ||
|
|
be71af5c55 | ||
|
|
97f9812876 | ||
|
|
dcc50e1b36 | ||
|
|
ae8824fb11 | ||
|
|
337ab2993b | ||
|
|
a4782764dd | ||
|
|
0a4c28f799 | ||
|
|
1470a0d234 | ||
|
|
bc19db9ddd | ||
|
|
d96b0d3986 | ||
|
|
a5c35586f7 | ||
|
|
a54655c0ff | ||
|
|
2681e81d6b | ||
|
|
2a0234e5ce | ||
|
|
6b326a6efd | ||
|
|
48d2bf849f | ||
|
|
4ab808b6de | ||
|
|
e5496e84a6 | ||
|
|
83b5c7f678 | ||
|
|
e6c9617e01 | ||
|
|
6c5fcc3dc6 | ||
|
|
2931bb2863 | ||
|
|
d745b128e3 | ||
|
|
73b952ec0d | ||
|
|
be961fb9a7 | ||
|
|
851d84bde8 | ||
|
|
854c4ebfdd | ||
|
|
a77448f7c0 | ||
|
|
0dc33f3d88 | ||
|
|
aaff0257b0 | ||
|
|
3557a57bbd | ||
|
|
051d23edff | ||
|
|
ccb91c1268 | ||
|
|
6c1c0eee59 | ||
|
|
f1c1c7033a | ||
|
|
bc352c4cf0 | ||
|
|
1980fa9fa4 | ||
|
|
6cabb2e935 | ||
|
|
05411527ee | ||
|
|
3c13da66b3 | ||
|
|
5d6af09508 | ||
|
|
15bf721d24 | ||
|
|
14351c9512 | ||
|
|
3b13de5310 | ||
|
|
f92eff2df8 | ||
|
|
a65ac5f8f0 | ||
|
|
0e36a1c505 | ||
|
|
f5bed635e0 | ||
|
|
905ab9f2e4 | ||
|
|
547b63b891 | ||
|
|
c26ddb497e | ||
|
|
2e81cfb56f | ||
|
|
337cb6574a | ||
|
|
abcb6bfecb | ||
|
|
797fda3363 | ||
|
|
bd920ee5bb | ||
|
|
2720970e1f | ||
|
|
b7a12d4bbb | ||
|
|
b4f6135b96 | ||
|
|
7d65bf4641 | ||
|
|
656c81a72c | ||
|
|
bfd0374ef6 | ||
|
|
bf1a772e40 | ||
|
|
8ede100594 | ||
|
|
927f1f6d9a | ||
|
|
0be4c6f233 | ||
|
|
912eea5037 | ||
|
|
06a029b89c | ||
|
|
df708a77d2 | ||
|
|
31232ad50c | ||
|
|
7abaf61e11 | ||
|
|
903a6e31b8 | ||
|
|
2eb5898e8b | ||
|
|
dc2bc0291b | ||
|
|
1357f7eeb4 | ||
|
|
b0cb0a759b | ||
|
|
19d0ca6bfc | ||
|
|
26d03fe2a5 | ||
|
|
dfa61df40a | ||
|
|
d154cced14 | ||
|
|
80b96d9bc9 | ||
|
|
8fa30f71eb | ||
|
|
804094b1ce | ||
|
|
9caf077b58 | ||
|
|
1a5ba06ca3 | ||
|
|
657cad9ffd | ||
|
|
a338a936db | ||
|
|
226e10bca2 | ||
|
|
3a5a989011 | ||
|
|
c9720ef061 | ||
|
|
b6927f178f | ||
|
|
6b40e4fe9d | ||
|
|
59ec56db4c | ||
|
|
a8119d678a | ||
|
|
8e38e313b2 | ||
|
|
b7b75d78ae | ||
|
|
824efb6b59 | ||
|
|
c151ca202c | ||
|
|
b9a64c92e7 | ||
|
|
bcaa06721a | ||
|
|
06227ef12b | ||
|
|
c17827e030 | ||
|
|
97ca0f0b21 | ||
|
|
e4e6419e50 | ||
|
|
fd8c883cf4 | ||
|
|
6b66a59673 | ||
|
|
46177338c2 | ||
|
|
6fcff9b106 | ||
|
|
208f5f6c5c | ||
|
|
de3e2a9867 | ||
|
|
40eea3c659 | ||
|
|
4f9b6b9186 | ||
|
|
4a848ec527 | ||
|
|
10414e169c | ||
|
|
1a6c68d028 | ||
|
|
9156734ced | ||
|
|
0dfe3ff4ac | ||
|
|
3a8c7f02cc | ||
|
|
e03b192fcc | ||
|
|
cf40bd2c30 | ||
|
|
4082e88416 | ||
|
|
27abc10d93 | ||
|
|
d6474d71f2 | ||
|
|
d57603e854 | ||
|
|
ac92584678 | ||
|
|
c234be0a8c | ||
|
|
7c6b8398cf | ||
|
|
7de677c953 | ||
|
|
aa23f44555 | ||
|
|
901d75a1eb | ||
|
|
aa95286810 | ||
|
|
f6b3f661d6 | ||
|
|
0850d85791 | ||
|
|
c564400ac4 | ||
|
|
94ab545ffe | ||
|
|
e10df203b7 | ||
|
|
eea20a6eab | ||
|
|
5f208801ee | ||
|
|
0a22697e5d | ||
|
|
30cf4f0b00 | ||
|
|
e4bb88a725 | ||
|
|
e3822e6bc3 | ||
|
|
20d3be0d1d | ||
|
|
1785863686 | ||
|
|
ea4ced3cc1 | ||
|
|
149008d18b | ||
|
|
55a21d2eec | ||
|
|
c7491e631a | ||
|
|
468a205e36 | ||
|
|
bebe951a57 | ||
|
|
85a8ab32ef | ||
|
|
34ddbe170c | ||
|
|
e9846eb249 | ||
|
|
7cc418ac93 | ||
|
|
69532a4f23 | ||
|
|
f59419d96f | ||
|
|
7f288d0555 | ||
|
|
53afa8c276 | ||
|
|
22f4dd2f75 | ||
|
|
0989152024 | ||
|
|
f74809d361 | ||
|
|
9724cf7776 | ||
|
|
909e5438a8 | ||
|
|
3c534d87c0 | ||
|
|
4022a59705 | ||
|
|
138e7942da | ||
|
|
d7d26a3ae1 | ||
|
|
23504821cf | ||
|
|
b09da3e8f1 | ||
|
|
f3dd2fec99 | ||
|
|
462e375800 | ||
|
|
ca8c881375 | ||
|
|
96605a57d4 | ||
|
|
491ce40081 | ||
|
|
f33eb07bdd | ||
|
|
8bb1dc9b47 | ||
|
|
78b50472da | ||
|
|
e0259b37ed | ||
|
|
bf863a2594 | ||
|
|
edd174881e | ||
|
|
0bf747f6fc | ||
|
|
ab4d2b5d58 | ||
|
|
1b81280358 | ||
|
|
32f4eea3b8 | ||
|
|
1a3a49decb | ||
|
|
416717aff6 | ||
|
|
769d955a40 | ||
|
|
6de85b841d | ||
|
|
66db127245 | ||
|
|
b4c6af29e4 | ||
|
|
7192606e21 | ||
|
|
932be02e9e | ||
|
|
fc524894c6 | ||
|
|
f5196389e8 | ||
|
|
27be06c5c9 | ||
|
|
1d3ddb5e85 | ||
|
|
2145c104fd | ||
|
|
64e0d098e7 | ||
|
|
50d8cbb0ee | ||
|
|
9580397558 | ||
|
|
cf544b74f5 | ||
|
|
312f831efb | ||
|
|
f5bad5d28e | ||
|
|
9b7d255200 | ||
|
|
7a027bdd93 | ||
|
|
439a611a9e | ||
|
|
5f92b230aa | ||
|
|
29bc5303ae | ||
|
|
5314e5e7e9 | ||
|
|
c88462c99b | ||
|
|
0b552f1a7e | ||
|
|
552635a3c7 | ||
|
|
ca769bee39 | ||
|
|
b7ca0a0a14 | ||
|
|
84097a3179 | ||
|
|
8ba36b2588 | ||
|
|
e1d4ebc5f6 | ||
|
|
9e712d6089 | ||
|
|
90bea3dc6b | ||
|
|
bf480bb971 | ||
|
|
a94b48be50 | ||
|
|
abed42d848 | ||
|
|
3d6e795ca5 | ||
|
|
a3cbe8e9d4 | ||
|
|
0a2000098a | ||
|
|
a2348b5133 | ||
|
|
20d2f9d894 | ||
|
|
321f908e76 | ||
|
|
49875cb0e5 | ||
|
|
fa6a2c5bbb | ||
|
|
1074c00b60 | ||
|
|
8a8b10541e | ||
|
|
46cf4d677c | ||
|
|
94587d7515 | ||
|
|
14ec58ef9a | ||
|
|
8f4f6f3de0 | ||
|
|
f8c0ac3ce0 | ||
|
|
8ebad98912 | ||
|
|
08429b6110 | ||
|
|
0e128e15f1 | ||
|
|
b77a12fd0d | ||
|
|
a98526b398 | ||
|
|
5639bf9d48 | ||
|
|
c626685103 | ||
|
|
e233d15fbb | ||
|
|
a5d83900d9 | ||
|
|
d8dbeedcc2 | ||
|
|
56b67d62a3 | ||
|
|
dc084b4bd9 | ||
|
|
1bc0eab7ae | ||
|
|
ca14d1b108 | ||
|
|
d6757aced2 | ||
|
|
5c84eed292 | ||
|
|
b648387a57 | ||
|
|
5232f95c3f | ||
|
|
0742960ec4 | ||
|
|
4c41b7f8df | ||
|
|
c5d0c24237 | ||
|
|
8b5c51ceaa | ||
|
|
c09bceb66a | ||
|
|
e7afd3ec76 | ||
|
|
3d30be3472 | ||
|
|
e08367365f | ||
|
|
6692fbeed4 | ||
|
|
36a9e7a7cf | ||
|
|
49b5ff5fd9 | ||
|
|
1bde56a11a | ||
|
|
f47d7b6935 | ||
|
|
2dbad40a34 | ||
|
|
39f6a51794 | ||
|
|
7ec128c2e4 | ||
|
|
b55f0e849e | ||
|
|
f158390ba1 | ||
|
|
e4b245104a | ||
|
|
789497b07e | ||
|
|
5cf01ba099 | ||
|
|
e8669891f8 | ||
|
|
ac0f265a5b | ||
|
|
fcd6b430e1 | ||
|
|
f3ad8a9b80 | ||
|
|
43ff824da1 | ||
|
|
b8022610ca | ||
|
|
03defe203a | ||
|
|
aedcbe56b3 | ||
|
|
c365db460a | ||
|
|
cfdc4752d0 | ||
|
|
e1964ac5ed | ||
|
|
e17ab9cd8f | ||
|
|
edc15b8727 | ||
|
|
034f8d41fc | ||
|
|
0fa70db1e1 | ||
|
|
fa7ba9b72b | ||
|
|
3a20123e0f | ||
|
|
03510d1bc4 | ||
|
|
8b116f637a | ||
|
|
9c49de6552 | ||
|
|
842347bcab | ||
|
|
628b9c4853 | ||
|
|
d60b6ee33f | ||
|
|
4f4fcbbc70 | ||
|
|
cc896670dc | ||
|
|
eb2a497dee | ||
|
|
0cf5ce1416 | ||
|
|
988381d584 | ||
|
|
0b163eae23 | ||
|
|
3a3ff8a65e | ||
|
|
9f183a6dfc | ||
|
|
fadfd4e06c | ||
|
|
eb521faa8d | ||
|
|
6b572ca862 | ||
|
|
d075ec6716 | ||
|
|
14e6bf5ef9 | ||
|
|
b6bddd3b0e | ||
|
|
d5ed9b6cf5 | ||
|
|
7a9912d4e0 | ||
|
|
4d2ddceb4e | ||
|
|
ae2aed675a | ||
|
|
1d7cb41218 | ||
|
|
76db002eb5 | ||
|
|
ebb64ba177 | ||
|
|
1a685e2b68 | ||
|
|
9c561885a1 | ||
|
|
612e98b198 | ||
|
|
0a41d5ccf1 | ||
|
|
ba8fe1f32c | ||
|
|
0f840876a5 | ||
|
|
ac3900b6f4 | ||
|
|
5e138b9937 | ||
|
|
82d50cd903 | ||
|
|
c5b1d4daac | ||
|
|
b4a30d49d8 | ||
|
|
229360d1b9 | ||
|
|
d627d362af | ||
|
|
7ca7a07942 | ||
|
|
09f81fa3cd | ||
|
|
b03bf9c7f1 | ||
|
|
4d696369fe | ||
|
|
bcb80ea5f5 | ||
|
|
1be2ee5875 | ||
|
|
3554e807df | ||
|
|
5ffbd6e86d | ||
|
|
e2572c61cf | ||
|
|
7df2b74d43 | ||
|
|
f51a69f080 | ||
|
|
c0a2d9fc2b | ||
|
|
51dad19f88 | ||
|
|
3d1a530796 | ||
|
|
f6a22d2121 | ||
|
|
6f2d448059 | ||
|
|
0d5103a3f3 | ||
|
|
4da80028bf | ||
|
|
bb40dbde9d | ||
|
|
50fc36ec3e | ||
|
|
1abcef73a0 | ||
|
|
0d7879b25c | ||
|
|
8278dc5b5b | ||
|
|
c90d486454 | ||
|
|
35f9b7ec8d | ||
|
|
69e621af86 | ||
|
|
0e92e696d4 | ||
|
|
0b1445bfe9 | ||
|
|
db2d7ba1f5 | ||
|
|
d82703f41b | ||
|
|
8213861ab7 | ||
|
|
a842c380cf | ||
|
|
5bf6f1849a | ||
|
|
bfe4877f73 | ||
|
|
63dcddf6f4 | ||
|
|
68735ddb35 | ||
|
|
1fd9ca7ef2 | ||
|
|
2445004333 | ||
|
|
dc148bf954 | ||
|
|
f3c34bd75a | ||
|
|
5419e67dbc | ||
|
|
8d37da0952 | ||
|
|
a8075d98df | ||
|
|
fcc205b85a | ||
|
|
0f5056221f | ||
|
|
8384ace746 | ||
|
|
040cabece0 | ||
|
|
319a8d6ab2 | ||
|
|
50a7320886 | ||
|
|
418987476e | ||
|
|
89e4ff328c | ||
|
|
04bf49cb43 | ||
|
|
1c017df2a3 | ||
|
|
5fed1f08e4 | ||
|
|
82c349c8c4 | ||
|
|
0f7af6a4e9 | ||
|
|
8db1791ed2 | ||
|
|
a29ec1b8c7 | ||
|
|
232a760a58 | ||
|
|
f4ad04d334 | ||
|
|
8dfec20871 | ||
|
|
64745017e9 | ||
|
|
37edede728 | ||
|
|
f785605db8 | ||
|
|
01ad30ab07 | ||
|
|
e08d507462 | ||
|
|
4c23bd5ad3 | ||
|
|
b15abd5376 | ||
|
|
79971f906b | ||
|
|
9eec98778f | ||
|
|
dcd0e14142 | ||
|
|
cfcbc9aab7 | ||
|
|
a80de5658a | ||
|
|
34215eb309 | ||
|
|
9458005d7f | ||
|
|
5f36df0172 | ||
|
|
3ff4929a49 | ||
|
|
4bea69d647 | ||
|
|
09541dae86 | ||
|
|
bcbcc53c87 | ||
|
|
76f120bec9 | ||
|
|
f8bf28876d | ||
|
|
b03795df09 | ||
|
|
dbe20d6574 | ||
|
|
0550fab73e | ||
|
|
3f2d9d198e | ||
|
|
b9c953fce6 | ||
|
|
181cfd69de | ||
|
|
569766b8f8 | ||
|
|
53a232ebdc | ||
|
|
4c9a2ff538 | ||
|
|
dc623cd049 | ||
|
|
7cd517268b | ||
|
|
0c98082b25 |
29
.eslintrc.json
Normal file
29
.eslintrc.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"node": true,
|
||||
"mocha": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended"
|
||||
],
|
||||
"globals": {
|
||||
"NodeJS": true
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
"no-useless-constructor": 0,
|
||||
"no-unused-vars": 0,
|
||||
"no-prototype-builtins": 0,
|
||||
"require-atomic-updates": 0,
|
||||
"no-dupe-class-members": 0
|
||||
}
|
||||
}
|
||||
13
.github/dependabot.yml
vendored
Normal file
13
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: monthly
|
||||
time: "15:00"
|
||||
open-pull-requests-limit: 10
|
||||
ignore:
|
||||
- dependency-name: jsonschema
|
||||
versions:
|
||||
- "> 1.2.2"
|
||||
- "< 2"
|
||||
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.
|
||||
-->
|
||||
67
.github/workflows/codeql-analysis.yml
vendored
Normal file
67
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ develop, master ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ develop ]
|
||||
schedule:
|
||||
- cron: '44 5 * * 6'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'javascript' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||
# Learn more:
|
||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
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
|
||||
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1,5 +1,9 @@
|
||||
# .gitignore
|
||||
|
||||
# Ignore package locks other than Yarn.
|
||||
package-lock.json
|
||||
npm-shrinkwrap.json
|
||||
|
||||
# Ignore vim swap files.
|
||||
*.swp
|
||||
|
||||
@@ -54,6 +58,9 @@ npm-debug.log
|
||||
# Ignore dist folder, built from tsc
|
||||
dist/
|
||||
|
||||
# TypeScript incremental compilation cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Ignore perf test cache
|
||||
scripts/cache
|
||||
|
||||
@@ -61,3 +68,6 @@ scripts/cache
|
||||
|
||||
# nyc (istanbul)
|
||||
.nyc_output
|
||||
|
||||
# browser tests
|
||||
test-compiled-for-web
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
lib-cov
|
||||
coverage.html
|
||||
src
|
||||
dist/bower
|
||||
10
.prettierrc
Normal file
10
.prettierrc
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"parser": "typescript",
|
||||
"printWidth": 80,
|
||||
"tabWidth": 2,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"quoteProps": "consistent",
|
||||
"bracketSpacing": false
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 6
|
||||
- 8
|
||||
- 9
|
||||
- 10
|
||||
- 12
|
||||
- 13
|
||||
script:
|
||||
- yarn compile
|
||||
- yarn test
|
||||
- yarn build
|
||||
- yarn lint
|
||||
|
||||
163
APPLICATIONS.md
Normal file
163
APPLICATIONS.md
Normal file
@@ -0,0 +1,163 @@
|
||||
# Applications using ripple-lib (RippleAPI)
|
||||
|
||||
A curated list of some of the projects and apps that leverage `ripple-lib` in some way.
|
||||
|
||||
**Have one to add?** Please edit this file and open a PR!
|
||||
|
||||
## Notice (disclaimer)
|
||||
|
||||
These sites are independent of Ripple and have not been authorized, endorsed, sponsored or otherwise approved by Ripple or its affiliates.
|
||||
|
||||
Warning: Use at your own risk.
|
||||
|
||||
## Exchanges
|
||||
|
||||
- **[The World Exchange](https://www.theworldexchange.net/)**
|
||||
|
||||
Trade, issue, and send directly on the XRP Ledger. A user interface for the XRPL's decentralized exchange.
|
||||
|
||||
- **[Bitso](https://bitso.com/)**
|
||||
|
||||
Exchange allowing clients to buy and sell XRP, based in Mexico.
|
||||
|
||||
## Explorers
|
||||
|
||||
- **[xrpintel - XRP Intelligence](https://xrpintel.com/)**
|
||||
|
||||
Monitor the XRP Network in real time and explore historical statistics.
|
||||
|
||||
- **[XRP Charts](https://xrpcharts.ripple.com/)** (xrpcharts.ripple.com)
|
||||
|
||||
XRP Charts provides information based on public data, including trade volume, top markets, metrics, transactions, and more.
|
||||
|
||||
- **[Ripple Live](https://gatehub.net/live)** (gatehub.net/live)
|
||||
|
||||
Visualize XRP network transactions.
|
||||
|
||||
- **[XRPL Dev. Dashboard](https://xrp.fans/)** (xrp.fans)
|
||||
|
||||
Debugging dashboard for `rippled-ws-client-pool`, transaction and query explorer, and transaction signing and submission tool.
|
||||
|
||||
- **[XRP Value](http://xrpvalue.com/)**
|
||||
|
||||
Real-time XRP price, trades, and orderbook data from the XRP Ledger.
|
||||
|
||||
- **[Bithomp - XRP Explorer](https://bithomp.com/explorer/)**
|
||||
|
||||
Look up information by entering an address, transaction hash, username, or PayID.
|
||||
|
||||
- **[Bithomp - XRPL validators](https://bithomp.com/validators)**
|
||||
|
||||
List of XRPL validators, nodes, and testnet validators.
|
||||
|
||||
- **[XRP Scan - XRP Ledger explorer](https://xrpscan.com)**
|
||||
|
||||
XRP Ledger explorer, metrics and analytics.
|
||||
|
||||
- **[xrplorer](https://xrplorer.com)**
|
||||
|
||||
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/)**
|
||||
|
||||
Users can use the xumm application to track their accounts, balances and transactions. The true power of xumm is the platform available for developers.
|
||||
|
||||
- **[Xpring Wallet](https://xpring.io)** (uses `ripple-keypairs`)
|
||||
|
||||
Non-custodial XRP wallet.
|
||||
|
||||
- **[XRP Toolkit](https://www.xrptoolkit.com)**
|
||||
|
||||
A web interface to the XRP Ledger, supporting both hardware and software wallets.
|
||||
|
||||
- **[Toast Wallet](https://toastwallet.com/)**
|
||||
|
||||
A free, open source XRP Wallet for iOS, Android, Windows, Mac and Linux.
|
||||
|
||||
- **[Toastify Ledger](https://github.com/WietseWind/toastify-ledger)** (uses `ripple-keypairs`)
|
||||
|
||||
Add a Regular Key to a mnemonic XRP Wallet (e.g. Ledger Nano S) to use the account with a Family Seed (secret).
|
||||
|
||||
- **[Bithomp-submit](https://github.com/Bithomp/bithomp-submit)** (GitHub)
|
||||
|
||||
A tool to submit an offline-signed XRPL transaction.
|
||||
|
||||
- **[Kyte](https://kyteapp.co/)** (kyteapp.co) ([Source](https://github.com/WietseWind/Zerp-Wallet)) (Deprecated)
|
||||
|
||||
Web-based XRP wallet.
|
||||
|
||||
- **[XRP Vanity Address Generator](https://github.com/WietseWind/xrp-vanity-generator)** (Node.js)
|
||||
|
||||
A vanity address is a wallet address containing a few characters you like at the beginning or the end of the wallet address.
|
||||
|
||||
- **[XRP Account Mnemonic Recovery](https://github.com/WietseWind/xrp-mnemonic-recovery)** (uses `ripple-keypairs`)
|
||||
|
||||
Recover a 24 word mnemonic if one word is wrong or one word is missing.
|
||||
|
||||
## Send and request payments
|
||||
|
||||
- **[XRP Tip Bot](https://www.xrptipbot.com/)**
|
||||
|
||||
A bot that enables users on reddit, Twitter and Discord to send XRP to each other through reddit comments and Twitter tweets.
|
||||
|
||||
- **[XRP Text](https://xrptext.com/)**
|
||||
|
||||
Send XRP using SMS text messages.
|
||||
|
||||
- **[XRParrot](https://xrparrot.com/)** (uses `ripple-address-codec`)
|
||||
|
||||
Easy EUR (SEPA) to XRP transfer (currency conversion).
|
||||
|
||||
- **[XRP Payment](https://xrpayments.co/)** (xrpayments.co)
|
||||
|
||||
Tool for generating a XRP payment request URI in a QR code, with currency converter.
|
||||
|
||||
## Development tools
|
||||
|
||||
- **[XRP Faucets for Testnet and Devnet](https://xrpl.org/xrp-testnet-faucet.html)**
|
||||
|
||||
Get some test funds for development on the test network. The faucet uses `ripple-lib`.
|
||||
|
||||
## Code samples and libraries
|
||||
|
||||
- **[ilp-plugin-xrp-paychan](https://github.com/interledgerjs/ilp-plugin-xrp-paychan)**
|
||||
|
||||
Send ILP payments using XRP and payment channels (PayChan).
|
||||
|
||||
- **[RunKit: WietseWind](https://runkit.com/wietsewind/)**
|
||||
|
||||
XRP Ledger code samples for Node.js.
|
||||
|
||||
- **[GitHub Gist: WietseWind](https://gist.github.com/WietseWind)**
|
||||
|
||||
XRP Ledger code samples for Node.js and the web (mostly).
|
||||
|
||||
- **[rippled-ws-client-sign](https://github.com/WietseWind/rippled-ws-client-sign)**
|
||||
|
||||
Sign transactions, with support for MultiSign.
|
||||
|
||||
- **[ILP-enabled power switch](https://xrpcommunity.blog/raspberry-pi-interledger-xp-powerswitch-howto/)** ([video](https://www.youtube.com/watch?v=c-eS0HQUuJg)) (uses [`moneyd-uplink-xrp`](https://github.com/interledgerjs/moneyd-uplink-xrp))
|
||||
|
||||
For about $30 in parts (Raspberry Pi, 3.3V Relay board and a few wires) you can build your own power switch that will switch on if a streaming ILP payment comes in. When the payment stream stops, the power turns off.
|
||||
|
||||
## Related apps that do not appear to use ripple-lib
|
||||
|
||||
- **[XRP Stats](https://ledger.exposed/)** (ledger.exposed)
|
||||
|
||||
Rich list, live ledger stats and XRP distribution. Visualize escrows and flow of funds.
|
||||
216
Gulpfile.js
216
Gulpfile.js
@@ -1,216 +0,0 @@
|
||||
/* eslint-disable no-var, no-param-reassign */
|
||||
/* these eslint rules are disabled because gulp does not support babel yet */
|
||||
'use strict';
|
||||
const _ = require('lodash');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const assert = require('assert');
|
||||
const gulp = require('gulp');
|
||||
const rename = require('gulp-rename');
|
||||
const webpack = require('webpack');
|
||||
const bump = require('gulp-bump');
|
||||
const argv = require('yargs').argv;
|
||||
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
|
||||
|
||||
var pkg = require('./package.json');
|
||||
|
||||
var uglifyOptions = {
|
||||
mangle: {
|
||||
reserved: ['_', 'RippleError', 'RippledError', 'UnexpectedError',
|
||||
'LedgerVersionError', 'ConnectionError', 'NotConnectedError',
|
||||
'DisconnectedError', 'TimeoutError', 'ResponseFormatError',
|
||||
'ValidationError', 'NotFoundError', 'MissingLedgerHistoryError',
|
||||
'PendingLedgerVersionError'
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
function getWebpackConfig(extension, overrides) {
|
||||
overrides = overrides || {};
|
||||
let defaults = {
|
||||
cache: true,
|
||||
externals: [{
|
||||
'lodash': '_'
|
||||
}],
|
||||
entry: './src/index.ts',
|
||||
output: {
|
||||
library: 'ripple',
|
||||
path: path.join(__dirname, 'build/'),
|
||||
filename: ['ripple-', extension].join(pkg.version)
|
||||
},
|
||||
plugins: [
|
||||
new webpack.NormalModuleReplacementPlugin(/^ws$/, './wswrapper'),
|
||||
new webpack.NormalModuleReplacementPlugin(/^\.\/wallet$/, './wallet-web'),
|
||||
new webpack.NormalModuleReplacementPlugin(/^.*setup-api$/,
|
||||
'./setup-api-web')
|
||||
],
|
||||
module: {
|
||||
rules: [{
|
||||
test: /jayson/,
|
||||
use: 'null',
|
||||
}, {
|
||||
test: /\.ts$/,
|
||||
use: [{
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
compilerOptions: {declaration: false}
|
||||
},
|
||||
}],
|
||||
}, {
|
||||
test: /\.json/,
|
||||
use: 'json-loader',
|
||||
}]
|
||||
},
|
||||
resolve: {
|
||||
extensions: [ '.ts', '.js' ]
|
||||
},
|
||||
};
|
||||
return _.assign({}, defaults, overrides);
|
||||
}
|
||||
|
||||
function webpackConfigForWebTest(testFileName, path) {
|
||||
var match = testFileName.match(/\/?([^\/]*)-test.js$/);
|
||||
if (!match) {
|
||||
assert(false, 'wrong filename:' + testFileName);
|
||||
}
|
||||
var configOverrides = {
|
||||
externals: [{
|
||||
'lodash': '_',
|
||||
'ripple-api': 'ripple',
|
||||
'net': 'null'
|
||||
}],
|
||||
entry: testFileName,
|
||||
output: {
|
||||
library: match[1].replace(/-/g, '_'),
|
||||
path: './test-compiled-for-web/' + (path ? path : ''),
|
||||
filename: match[1] + '-test.js'
|
||||
}
|
||||
};
|
||||
return getWebpackConfig('.js', configOverrides);
|
||||
}
|
||||
|
||||
gulp.task('build-tests', function(callback) {
|
||||
var times = 0;
|
||||
function done() {
|
||||
if (++times >= 5) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
webpack(webpackConfigForWebTest('./test/rangeset-test.js'), done);
|
||||
webpack(webpackConfigForWebTest('./test/connection-test.js'), done);
|
||||
webpack(webpackConfigForWebTest('./test/api-test.js'), done);
|
||||
webpack(webpackConfigForWebTest('./test/broadcast-api-test.js'), done);
|
||||
webpack(webpackConfigForWebTest('./test/integration/integration-test.js',
|
||||
'integration/'), done);
|
||||
});
|
||||
|
||||
function createLink(from, to) {
|
||||
if (fs.existsSync(to)) {
|
||||
fs.unlinkSync(to);
|
||||
}
|
||||
fs.linkSync(from, to);
|
||||
}
|
||||
|
||||
function createBuildLink(callback) {
|
||||
return function(err, res) {
|
||||
createLink('./build/ripple-' + pkg.version + '.js',
|
||||
'./build/ripple-latest.js');
|
||||
callback(err, res);
|
||||
};
|
||||
}
|
||||
|
||||
gulp.task('build', function(callback) {
|
||||
webpack(getWebpackConfig('.js'), createBuildLink(callback));
|
||||
});
|
||||
|
||||
gulp.task('build-min', function(callback) {
|
||||
const webpackConfig = getWebpackConfig('-min.js');
|
||||
webpackConfig.plugins.push(new UglifyJsPlugin({uglifyOptions}));
|
||||
webpack(webpackConfig, function() {
|
||||
createLink('./build/ripple-' + pkg.version + '-min.js',
|
||||
'./build/ripple-latest-min.js');
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('build-debug', function(callback) {
|
||||
const webpackConfig = getWebpackConfig('-debug.js', {devtool: 'eval'});
|
||||
webpackConfig.plugins.unshift(new webpack.LoaderOptionsPlugin({debug: true}));
|
||||
webpack(webpackConfig, callback);
|
||||
});
|
||||
|
||||
/**
|
||||
* Generate a WebPack external for a given unavailable module which replaces
|
||||
* that module's constructor with an error-thrower
|
||||
*/
|
||||
function buildUseError(cons) {
|
||||
return ('var {<CONS>:function(){throw new Error('
|
||||
+ '"Class is unavailable in this build: <CONS>")}}')
|
||||
.replace(new RegExp('<CONS>', 'g'), cons);
|
||||
}
|
||||
|
||||
gulp.task('build-core', function(callback) {
|
||||
var configOverrides = {
|
||||
cache: false,
|
||||
entry: './src/remote.ts',
|
||||
externals: [{
|
||||
'./transaction': buildUseError('Transaction'),
|
||||
'./orderbook': buildUseError('OrderBook'),
|
||||
'./account': buildUseError('Account'),
|
||||
'./serializedobject': buildUseError('SerializedObject')
|
||||
}],
|
||||
plugins: [
|
||||
new UglifyJsPlugin()
|
||||
]
|
||||
};
|
||||
webpack(getWebpackConfig('-core.js', configOverrides), callback);
|
||||
});
|
||||
|
||||
gulp.task('bower-build', ['build'], function() {
|
||||
return gulp.src(['./build/ripple-', '.js'].join(pkg.version))
|
||||
.pipe(rename('ripple.js'))
|
||||
.pipe(gulp.dest('./dist/bower'));
|
||||
});
|
||||
|
||||
gulp.task('bower-build-min', ['build-min'], function() {
|
||||
return gulp.src(['./build/ripple-', '-min.js'].join(pkg.version))
|
||||
.pipe(rename('ripple-min.js'))
|
||||
.pipe(gulp.dest('./dist/bower'));
|
||||
});
|
||||
|
||||
gulp.task('bower-build-debug', ['build-debug'], function() {
|
||||
return gulp.src(['./build/ripple-', '-debug.js'].join(pkg.version))
|
||||
.pipe(rename('ripple-debug.js'))
|
||||
.pipe(gulp.dest('./dist/bower'));
|
||||
});
|
||||
|
||||
gulp.task('bower-version', function() {
|
||||
gulp.src('./dist/bower/bower.json')
|
||||
.pipe(bump({version: pkg.version}))
|
||||
.pipe(gulp.dest('./dist/bower'));
|
||||
});
|
||||
|
||||
gulp.task('bower', ['bower-build', 'bower-build-min', 'bower-build-debug',
|
||||
'bower-version']);
|
||||
|
||||
gulp.task('watch', function() {
|
||||
gulp.watch('src/*', ['build-debug']);
|
||||
});
|
||||
|
||||
gulp.task('version-bump', function() {
|
||||
if (!argv.type) {
|
||||
throw new Error('No type found, pass it in using the --type argument');
|
||||
}
|
||||
|
||||
gulp.src('./package.json')
|
||||
.pipe(bump({type: argv.type}))
|
||||
.pipe(gulp.dest('./'));
|
||||
});
|
||||
|
||||
gulp.task('version-beta', function() {
|
||||
gulp.src('./package.json')
|
||||
.pipe(bump({version: pkg.version + '-beta'}))
|
||||
.pipe(gulp.dest('./'));
|
||||
});
|
||||
|
||||
gulp.task('default', ['build', 'build-debug', 'build-min']);
|
||||
874
HISTORY.md
874
HISTORY.md
@@ -1,5 +1,876 @@
|
||||
# ripple-lib Release History
|
||||
|
||||
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.
|
||||
* `classicAddressToXAddress` / `xAddressToClassicAddress`
|
||||
* `isValidXAddress` / `isValidClassicAddress`
|
||||
* `encodeSeed` / `decodeSeed`
|
||||
* `encodeAccountID` / `decodeAccountID`
|
||||
* `encodeNodePublic` / `decodeNodePublic`
|
||||
* `encodeAccountPublic` / `decodeAccountPublic`
|
||||
* `encodeXAddress` / `decodeXAddress`
|
||||
|
||||
Example 1. Encode an X-address with tag 4294967295:
|
||||
```js
|
||||
const RippleAPI = require('ripple-lib').RippleAPI
|
||||
const xAddress = RippleAPI.classicAddressToXAddress('rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf', 4294967295)
|
||||
console.log(xAddress)
|
||||
```
|
||||
|
||||
Output for Example 1:
|
||||
```
|
||||
XVLhHMPHU98es4dbozjVtdWzVrDjtV18pX8yuPT7y4xaEHi
|
||||
```
|
||||
|
||||
Example 2. Encode a test address for use with Testnet or Devnet:
|
||||
```js
|
||||
const RippleAPI = require('ripple-lib').RippleAPI
|
||||
const address = RippleAPI.classicAddressToXAddress('r3SVzk8ApofDJuVBPKdmbbLjWGCCXpBQ2g', 123, true)
|
||||
console.log(address)
|
||||
```
|
||||
|
||||
Output for Example 2:
|
||||
```
|
||||
T7oKJ3q7s94kDH6tpkBowhetT1JKfcfdSCmAXbS75iATyLD
|
||||
```
|
||||
|
||||
Example 3. Decode an X-address:
|
||||
```js
|
||||
const RippleAPI = require('ripple-lib').RippleAPI
|
||||
const address = RippleAPI.xAddressToClassicAddress('XVLhHMPHU98es4dbozjVtdWzVrDjtV18pX8yuPT7y4xaEHi')
|
||||
console.log(address)
|
||||
```
|
||||
|
||||
Output for Example 3:
|
||||
```js
|
||||
{
|
||||
classicAddress: 'rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf',
|
||||
tag: 4294967295,
|
||||
test: false
|
||||
}
|
||||
```
|
||||
|
||||
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
|
||||
* Add missing transaction type links (#1378)
|
||||
* Bug fixes
|
||||
* 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.
|
||||
```
|
||||
% shasum -a 256 build/*
|
||||
a1fd24b65d81ea5dbc36d74da7a6317267a048bba084effff5380d47299c3c63 build/ripple-latest-min.js
|
||||
fc17a5572001d814ea6b81aa701fcb66882ec031c68afb769a8ea8b71c6529a6 build/ripple-latest-min.js.LICENSE.txt
|
||||
410f78105c4f23c13671ec94f963ef47179393bfcad65ff610bc838c5a3c6a65 build/ripple-latest.js
|
||||
```
|
||||
|
||||
## 1.9.1 (2021-02-25)
|
||||
|
||||
* Docs
|
||||
* Add transaction specifications: (#1352)
|
||||
* Ticket Create
|
||||
* Account Delete
|
||||
* Deposit Preauth
|
||||
* Update link to subscribe page (#1354)
|
||||
* Bug fixes
|
||||
* Allow connectionTimeout option to be customized (#1355)
|
||||
* Dependencies
|
||||
* Bump ripple-keypairs to 1.0.3
|
||||
* Bump elliptic to 6.5.4 (this patches a potential security issue, although we do not believe that the issue affects ripple-lib: [details](https://github.com/ripple/ripple-keypairs/security/advisories/GHSA-w6x3-9ph2-7x54))
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found below.
|
||||
```
|
||||
% shasum -a 256 build/*
|
||||
f59e0221a7218460eea59b0441a0ee2d2a14484dd473ed5373283852798516c7 build/ripple-latest-min.js
|
||||
fc17a5572001d814ea6b81aa701fcb66882ec031c68afb769a8ea8b71c6529a6 build/ripple-latest-min.js.LICENSE.txt
|
||||
731ed44cbff8db26bcf256e0e3f3ac3fe90a10b6c227701d67918a5d643c5b29 build/ripple-latest.js
|
||||
```
|
||||
|
||||
## 1.9.0 (2020-12-07)
|
||||
|
||||
* New features
|
||||
* Support for tickets (TicketBatch amendment required - not yet activated on live/main network)
|
||||
* `prepareTicketCreate`
|
||||
* Types: Add LedgerClosedEvent and export more types
|
||||
* Docs
|
||||
* Improve descriptions of get-ledger response time fields
|
||||
* Applications
|
||||
* Add Bithomp explorer
|
||||
* Add example of reliable transaction submission
|
||||
* Node.js
|
||||
* Require Node.js version 10.13.0+
|
||||
* Internal
|
||||
* Update webpack, webpack-cli, mocha, nyc, ripple-binary-codec
|
||||
* Run prettier to format code
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found below.
|
||||
```
|
||||
% shasum -a 256 build/*
|
||||
2d3ae057ad637df272f98cfe940ea9e1317588e5bbf4fee47c8b16d6e6e71d85 build/ripple-latest-min.js
|
||||
8cbbc7bb482f68bcc8d411bae2e42effdb14ddfa562fcbc329a373910b85cf8c build/ripple-latest.js
|
||||
```
|
||||
|
||||
## 1.8.2 (2020-10-23)
|
||||
|
||||
* Bug fixes
|
||||
* Browser compatibility: Use ripple-binary-codec 0.2.x to prevent browser issues (#1321)
|
||||
* Memory leak: Clear awaiting response promises to prevent memory leak (#1302)
|
||||
* Feature: getSettings() - allow ledgerVersion to be 'validated', 'closed', or 'current' (#1298)
|
||||
* Docs: Update APPLICATIONS.md
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
ba760c36028b8a3ce267386e188a422890dfb1b03bc87c852a4c2034ea9bac2e ripple-latest-min.js
|
||||
7e5281eb9623602284b9f11564f0f3a36cfde305f2c2f7a32e0d29a04913c817 ripple-latest.js
|
||||
```
|
||||
|
||||
## 1.8.1 (2020-09-25)
|
||||
|
||||
* Internal
|
||||
* Bump elliptic to 6.5.3 (this patches a potential security issue, although we do not believe that the issue affects ripple-lib)
|
||||
* Bump ripple-binary-codec to 1.0.2
|
||||
* Bump lodash to 4.17.19
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
0895f349944fa11bb1976b2c350c0eb143dfd09abbfc7c2be33aed5c2a4b9ee8 ripple-latest-min.js
|
||||
7c00188a28f9d295d8e66aa08b340294d2fe49f635d154fb0df049ae8572c195 ripple-latest.js
|
||||
```
|
||||
|
||||
## 1.8.0 (2020-07-06)
|
||||
|
||||
* [Document `request('submit', ...)` method](https://github.com/ripple/ripple-lib/blob/develop/docs/index.md#submit), which includes additional useful information in the response
|
||||
* Update [list of applications using ripple-lib](https://github.com/ripple/ripple-lib/blob/1.7.0/APPLICATIONS.md)
|
||||
|
||||
## 1.7.1 (2020-05-26)
|
||||
|
||||
* Fix preparePayment when using source.amount/destination.minAmount (#1295) (Fix #1237) (Thanks to @leobel)
|
||||
* Docs
|
||||
* Fix generateXAddress example (#1286)
|
||||
* Update Transaction Streams link (#1278)
|
||||
* Dependencies
|
||||
* Update assert-diff, mocha, webpack-bundle-analyzer, @typescript-eslint/parser, @typescript-eslint/eslint-plugin, @types/ws, @types/node, ws, ts-node, eventemitter2
|
||||
|
||||
## 1.7.0 (2020-04-28)
|
||||
|
||||
* Export hashing functions (#1275)
|
||||
* Add failHard (fail_hard) option in `submit` method (#1029)
|
||||
* Add type for parseAccountFlags (#1258)
|
||||
* Add api.connection.getReserveBase() (#1259)
|
||||
* Travis: remove node 8 (#1257)
|
||||
* Dependencies
|
||||
* Update ripple-address-codec, @types/ws, @types/lodash, https-proxy-agent
|
||||
* Update devDependencies: eventemitter2, nyc, ejs, @types/node, webpack, ts-node, prettier, @typescript-eslint/eslint-plugin
|
||||
|
||||
## 1.6.5 (2020-03-23)
|
||||
|
||||
* APPLICATIONS.md: Add xrplorer.com
|
||||
* Internal: Fix typos
|
||||
* Dependencies
|
||||
* Update @types/ws, @types/node, @typescript-eslint/eslint-plugin, @types/mocha, webpack, typescript, mocha, assert-diff
|
||||
* Remove mocha-junit-reporter
|
||||
|
||||
## 1.6.4 (2020-02-18)
|
||||
|
||||
* Fix generateXAddress() and generateAddress() with no entropy (#1211, #1209)
|
||||
* Internal
|
||||
* Improve unit tests
|
||||
* Dependencies
|
||||
* Update webpack-cli, @types/node, webpack, @typescript-eslint/eslint-plugin,
|
||||
typescript, ripple-keypairs
|
||||
|
||||
## 1.6.3 (2020-02-05)
|
||||
|
||||
* Update ripple-keypairs to 1.0.0
|
||||
* Bug fix: Assign event listener to socket close event on open before attempting post-open logic (#1186)
|
||||
* Protects against possible unhandled rejection in disconnect
|
||||
* Adds the Connection `_ws.close` event listener post `_ws.open` before executing any post `_ws.open` logic, i.e. `Connection._subscribeToLedger`
|
||||
* This prevents a reconnection error loop that occurs if `Connection._ws` is never cleaned up by the unreachable `_ws.close` event listener
|
||||
* Also ensures that a possible disconnect() promise rejection is not unhandled if any `_ws.open` logic in `Connection.connect()` throws
|
||||
* Dependencies
|
||||
* Update mocha-junit-reporter, @types/node, mocha, @typescript-eslint/eslint-plugin, ripple-address-codec
|
||||
|
||||
## 1.6.2 (2020-01-17)
|
||||
|
||||
* Bug fix: Catch possible error in reconnect() on _heartbeat(), emit reconnect error (#1179)
|
||||
* Docs: Fix whitespace
|
||||
* Dependencies
|
||||
* Update @typescript-eslint/eslint-plugin, ts-node, @types/node, @types/ws, typescript
|
||||
|
||||
## 1.6.1 (2020-01-14)
|
||||
|
||||
> **Update Note:** In this release we refactored the internal connection logic of ripple-lib to improve resiliency across dropped messages and reconnects. The external interface remains the same, with zero changes to public methods/properties. However, If you experience any problems around connections, requests, and request retries, please [file an issue]( https://github.com/ripple/ripple-lib/issues/new) with the repo (and be sure to test against v1.6.0 to confirm that the problem was introduced in this version).
|
||||
|
||||
* Documentation
|
||||
* Document message type 'path_find' (#1121) (thanks @r0bertz)
|
||||
* Improve documentation for address generation; functions that can be called offline; generateXAddress() (#1158, #1159, #1169) (thanks @hbergren)
|
||||
* Add [Security Policy](https://github.com/ripple/ripple-lib/blob/develop/SECURITY.md)
|
||||
* Bug fixes
|
||||
* Types: Fix AccountObjectsResponse structure (#1127) (thanks @you21979)
|
||||
* In some cases, ripple-lib would fail to wait for the connection to be ready (#1119)
|
||||
* Dependencies
|
||||
* Update docs dependencies, ejs and doctoc (#1153)
|
||||
* Update eslint, ripple-lib-transactionparser, typescript, nyc, ws, @types/node, ripple-binary-codec, mocha, mocha-junit-reporter
|
||||
* Internal
|
||||
* Add LedgerHistory to Connection (#1119): Moved ledger logic into its own Ledger class
|
||||
|
||||
## 1.6.0 (2020-01-06)
|
||||
|
||||
* Add support for AccountDelete (#1120)
|
||||
* Improve error type given on rejected message _send to be DisconnectedError (#1098)
|
||||
* Internal
|
||||
* Add unit test for unhandled promise rejection warning on message _send (#1098)
|
||||
* Dependencies
|
||||
* Update @types/node, @typescript-eslint/parser
|
||||
|
||||
## 1.5.1 (2019-12-28)
|
||||
|
||||
* Fix support for CDNs (#1142)
|
||||
* Internal
|
||||
* Clean up connection trace logic (#1114)
|
||||
* Clean up the connection config (#1115)
|
||||
* Run prettier format (#1116)
|
||||
* Update eslint command (#1118)
|
||||
* Dependencies
|
||||
* Update webpack-cli, webpack, ts-node, @types/lodash, @types/ws, @types/node, @typescript-eslint/parser, @typescript-eslint/eslint-plugin, https-proxy-agent, mocha, eventemitter2
|
||||
|
||||
## 1.5.0 (2019-12-14)
|
||||
|
||||
* Add support for `WalletLocator` (#1083)
|
||||
* Types: Move and de-dupe `TransactionJSON` type (#1096)
|
||||
* This resolves an error surfaced by [TypeScript 3.7](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#local-and-imported-type-declarations-now-conflict)
|
||||
* Add a heartbeat to detect hung connections (#1101)
|
||||
* Dependencies
|
||||
* Update TypeScript version (#1096)
|
||||
* Update ripple-lib-transactionparser to 0.8.1 (#1097)
|
||||
* Update ripple-binary-codec to 0.2.5
|
||||
* Update webpack (#1112)
|
||||
* Require node 8 and yarn (#1107)
|
||||
* Testing: Refactor and add unit tests
|
||||
* Fix some errors caught by the improved tests
|
||||
|
||||
## 1.4.2 (2019-11-14)
|
||||
|
||||
* Add support for tick size (#1090) (thanks @RareData)
|
||||
* Update email hash default to allow proper clearing (#1089) (thanks @RareData)
|
||||
* Fix Unhandled Promise Rejection Warning on message `_send`
|
||||
* Add an immediate catch to the `_send` promise passed to `_whenReady` in case there is rejection before async handlers are added (#1092) (thanks @nickewansmith)
|
||||
* Docs improvements
|
||||
* Add XRP Toolkit reference (#1088)
|
||||
* Internal improvements
|
||||
* Add a prettier config
|
||||
* Update Node.js Testing Versions (#1085)
|
||||
* Testing matrix based on: https://nodejs.org/en/about/releases/
|
||||
- Node 11 is no longer supported (not LTS)
|
||||
- Node 12 added (active LTS)
|
||||
- Node 13 added ("current" release)
|
||||
|
||||
## 1.4.1 (2019-11-06)
|
||||
|
||||
* Compatibility: Change TypeScript compile target back to `es6` (#1071)
|
||||
* WARNING: This allows for the use of Node v6, which is no longer supported by Node.js, as it was end-of-life'd in April 2019
|
||||
* We recommend updating to Node v8/v10 ASAP in order to get security updates and fixes from the Node.js team
|
||||
* We are not actively running tests against Node v6 (ref #1076)
|
||||
* Docs: `getAccountObjects` doc fix
|
||||
* Dependencies:
|
||||
* Update `bignumber.js`
|
||||
* Update `ripple-keypairs`
|
||||
* Update `ws`
|
||||
* Build process: Update `webpack` flow
|
||||
|
||||
## 1.4.0 (2019-10-28)
|
||||
|
||||
* Unref timer so it does not hang the Node.js process
|
||||
* Add a 2-second timeout for connect()
|
||||
* Improve getTransaction() error when tx has not been validated yet
|
||||
* Add support for the new X-address format
|
||||
* Fix error in Safari, Chrome 78, Firefox 70
|
||||
* Some error messages have changed slightly. For example:
|
||||
* `-instance.Account is not of a type(s) string,instance.Account does not conform to the "address" format`
|
||||
* `+instance.Account is not of a type(s) string,instance.Account is not exactly one from <xAddress>,<classicAddress>`
|
||||
|
||||
### Internal improvements
|
||||
|
||||
* Reduce dependency size
|
||||
* Move tests to TypeScript
|
||||
* Replace tslint with eslint
|
||||
* Update https-proxy-agent
|
||||
* Add tests
|
||||
|
||||
## 1.3.4 (2019-10-18)
|
||||
|
||||
* Update ripple-lib-transactionparser
|
||||
* Improve error message when signing fails (e.g. due to trailing zeros)
|
||||
* Integrate ripple-hashes (in TypeScript with improved naming and docs)
|
||||
* Add multi-signing example to sign() method docs
|
||||
* Update TypeScript
|
||||
|
||||
## 1.3.3 (2019-09-10)
|
||||
|
||||
* Expand node version compatibility to support Node.js 12 ([ripple-binary-codec#32](https://github.com/ripple/ripple-binary-codec/issues/32))
|
||||
|
||||
## 1.3.2 (2019-09-03)
|
||||
|
||||
* Export and document `rippleTimeToISO8601()` method
|
||||
* Add type for isValidAddress (fixes error TS7016, #1032)
|
||||
* Docs: update recommended Node.js version (#1031)
|
||||
|
||||
When using this release with [rippled](https://github.com/ripple/rippled), we recommend using [rippled version 1.3.1](https://github.com/ripple/rippled/releases/tag/1.3.1) or later.
|
||||
|
||||
## 1.3.1 (2019-08-26)
|
||||
|
||||
* Upgrade to gulp 4 (#1030)
|
||||
* Remove http server (unused)
|
||||
* Update dependencies
|
||||
|
||||
There are no changes in the browser version with this release. The npm package for Node.js should be slightly smaller.
|
||||
|
||||
When using this release with [rippled](https://github.com/ripple/rippled), we recommend using [rippled version 1.3.1](https://github.com/ripple/rippled/releases/tag/1.3.1).
|
||||
|
||||
## 1.3.0 (2019-08-16)
|
||||
|
||||
### Bug fixes:
|
||||
|
||||
* Breaking change: Fix `getServerInfo` (#1012)
|
||||
|
||||
Before:
|
||||
```
|
||||
{
|
||||
// ...
|
||||
"load": {
|
||||
"jobTypes": {
|
||||
"0": {"jobType": "untrustedValidation", "perSecond": 10},
|
||||
"1": {"jobType": "ledgerData", "peakTime": 2, "perSecond": 2},
|
||||
"2": {"inProgress": 1, "jobType": "clientCommand", "perSecond": 1},
|
||||
"3": {"jobType": "transaction", "perSecond": 1},
|
||||
// ...
|
||||
},
|
||||
"threads": 6
|
||||
},
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
After:
|
||||
```
|
||||
{
|
||||
// ...
|
||||
"load": {
|
||||
"jobTypes": [
|
||||
{
|
||||
"jobType": "untrustedValidation",
|
||||
"perSecond": 8
|
||||
},
|
||||
{
|
||||
"avgTime": 2,
|
||||
"jobType": "ledgerData",
|
||||
"peakTime": 72,
|
||||
"perSecond": 2
|
||||
},
|
||||
{
|
||||
"inProgress": 1,
|
||||
"jobType": "clientCommand",
|
||||
"perSecond": 1
|
||||
},
|
||||
{
|
||||
"jobType": "transaction",
|
||||
"perSecond": 1
|
||||
},
|
||||
// ...
|
||||
],
|
||||
"threads": 6
|
||||
},
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
* Sign method - verify accurate encoding (#1026)
|
||||
* In previous versions, the following could be encoded incorrectly:
|
||||
* Amounts of XRP with more than 6 decimal places
|
||||
* Amounts of XRP drops with any decimal places
|
||||
* In versions 1.2.5 and 1.3.0, amounts that are invalid in this way will throw an error
|
||||
* Expand `APIOptions` by extending `ConnectionOptions` (#1018, fixes #1017)
|
||||
* Fix docs for destination.address (#1011)
|
||||
|
||||
### New features:
|
||||
|
||||
* Support removing a signer list (#1021)
|
||||
* Export `setCanonicalFlag` method from `src/transaction/utils`
|
||||
|
||||
### Improvements:
|
||||
|
||||
* Clean up phrasing in schema descriptions (#1023)
|
||||
* Improve docs
|
||||
* Update dependencies
|
||||
|
||||
Since this release fixes a bug that could cause transactions to be serialized incorrectly during the signing process, it has also been simultaneously released as version 1.2.5 (patch release).
|
||||
|
||||
When using this release with [rippled](https://github.com/ripple/rippled), we recommend using [rippled version 1.3.1](https://github.com/ripple/rippled/releases/tag/1.3.1).
|
||||
|
||||
## 1.2.4 (2019-06-06)
|
||||
|
||||
* Update README.md
|
||||
* Clarify docs
|
||||
* Update dependencies
|
||||
* Fix typos
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
4f09c056ccc51bc6cf17b128b559112e9c5adf19cc96ac8f9a06faee185697a7 ripple-1.2.4-debug.js
|
||||
5da1c75a02d76b0b105d98355ee4561f5d5036e8d5d0237efd5960812dcaa1fd ripple-1.2.4-min.js
|
||||
e147f303e880a65db149d2a5b9183b75814bd8145cd00740bcc4679d867192c8 ripple-1.2.4.js
|
||||
```
|
||||
|
||||
## 1.2.3 (2019-04-30)
|
||||
|
||||
* Fix browser builds
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
efb0f29cde94534a015d8a2171abb11b9a4345ba01418bf5b6ab6042a6d51dde ripple-1.2.3-debug.js
|
||||
b86145c0e30099b966ed8d3830ba25988d72877f1f87044d9954d6707be098ac ripple-1.2.3-min.js
|
||||
e027d91c7321d41ba94bb1bdc77dcff0107a5fd9eb833c6dbd06f1bbedef3900 ripple-1.2.3.js
|
||||
```
|
||||
|
||||
## 1.2.2 (2019-04-15)
|
||||
|
||||
* Prevent `prepareTransaction` from overwriting `Fee` and/or `LastLedgerSequence` (#997)
|
||||
* Add `deliveredAmount` as optional field for type `Outcome` (#996)
|
||||
* Fix build failure with TS strict checks (#993)
|
||||
|
||||
Minor changes:
|
||||
|
||||
* Use TypeScript project references
|
||||
* Travis: Drop node 9 and add node 11 for testing
|
||||
* Bump versions of devDependencies
|
||||
|
||||
Note: There is no browser version of this release.
|
||||
|
||||
## 1.2.1 (2019-03-23)
|
||||
|
||||
* Update `ripple-binary-codec` to 0.2.1 to support `tecKILLED`
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
|
||||
```
|
||||
% shasum -a 256 *
|
||||
531c2a8f4bf6d6b5bd4afe6a40b6a68a77179a343902cfa4210d7e35b5697af0 ripple-1.2.1-debug.js
|
||||
201ee99922b16b7e32afb5317ef4bb9facc23b20c272bb5c4ed7010f5d996cab ripple-1.2.1-min.js
|
||||
c1b984581299bf00e0e3c8ac4e62eadfc9b190bd78a2458a76e59ceb56046148 ripple-1.2.1.js
|
||||
```
|
||||
|
||||
## 1.2.0 (2019-03-19)
|
||||
|
||||
This release:
|
||||
|
||||
* changes the way you handle errors for the `prepare*` methods.
|
||||
* improves the `message` field of `RippledError`s.
|
||||
* allows `Sequence` to be set in the transaction JSON provided to
|
||||
`prepareTransaction`.
|
||||
|
||||
For details, continue reading:
|
||||
|
||||
### [BREAKING CHANGE] `prepare*` methods reject the Promise on error
|
||||
|
||||
The `prepare*` methods now always reject the Promise when an error occurs, instead of throwing.
|
||||
|
||||
Previously, the methods would synchronously throw on validation errors, despite being asynchronous methods that return Promises.
|
||||
|
||||
In other words, to handle errors in the past, you would need to use a try/catch block:
|
||||
|
||||
```
|
||||
// OBSOLETE - no need for try/catch anymore
|
||||
try {
|
||||
api.preparePayment(address, payment, instructions).then(prepared => {
|
||||
res.send(prepared.txJSON);
|
||||
}).catch(error => {
|
||||
// Handle asynchronous error
|
||||
});
|
||||
} catch (error) {
|
||||
// Handle synchronous error
|
||||
}
|
||||
```
|
||||
|
||||
Now, you can rely on the Promise's `catch` handler, which is called with the error when the Promise is rejected:
|
||||
|
||||
```
|
||||
api.preparePayment(address, payment, instructions).then(prepared => {
|
||||
res.send(prepared.txJSON);
|
||||
}).catch(error => {
|
||||
// Handle error
|
||||
});
|
||||
```
|
||||
|
||||
This applies to:
|
||||
* preparePayment
|
||||
* prepareTrustline
|
||||
* prepareOrder
|
||||
* prepareOrderCancellation
|
||||
* prepareSettings
|
||||
* prepareEscrowCreation
|
||||
* prepareEscrowExecution
|
||||
* prepareCheckCreate
|
||||
* prepareCheckCash
|
||||
* prepareCheckCancel
|
||||
* preparePaymentChannelCreate
|
||||
* preparePaymentChannelClaim
|
||||
* preparePaymentChannelFund
|
||||
|
||||
### Improved `RippledError` `message`
|
||||
|
||||
Previously, `RippledErrors` (errors from rippled) used rippled's `error` field as the `message`.
|
||||
|
||||
Now, the `error_message` field is used as the `message`.
|
||||
|
||||
This helps to surface the specific cause of an error.
|
||||
|
||||
For example, before:
|
||||
```
|
||||
[RippledError(invalidParams, { error: 'invalidParams',
|
||||
error_code: 31,
|
||||
error_message: 'Missing field \'account\'.',
|
||||
id: 3,
|
||||
request: { command: 'account_info', id: 3 },
|
||||
status: 'error',
|
||||
type: 'response' })]
|
||||
```
|
||||
|
||||
After:
|
||||
```
|
||||
[RippledError(Missing field 'account'., { error: 'invalidParams',
|
||||
error_code: 31,
|
||||
error_message: 'Missing field \'account\'.',
|
||||
id: 3,
|
||||
request: { command: 'account_info', id: 3 },
|
||||
status: 'error',
|
||||
type: 'response' })]
|
||||
```
|
||||
|
||||
In this case, you can see at a glance that `account` is the missing field.
|
||||
|
||||
The `error` field is still available in `errorObject.data.error`.
|
||||
|
||||
When `error_message` is not set (as with e.g. error 'entryNotFound'), the `error` field is used as the `message`.
|
||||
|
||||
### [BUG FIX] `prepareTransaction` does not overwrite the `Sequence` field
|
||||
|
||||
The `prepareTransaction` method now allows `Sequence` to be set in the Transaction JSON object, instead of overwriting it with the account's expected sequence based on the state of the ledger.
|
||||
|
||||
Previously, you had to use the `sequence` field in the `instructions` object to manually set a transaction's sequence number.
|
||||
|
||||
### New in rippled 1.2.1
|
||||
|
||||
As this is the first release of ripple-lib following the release of rippled 1.2.1, we would like to highlight the following API improvements:
|
||||
|
||||
1. The [`delivered_amount` field](https://developers.ripple.com/partial-payments.html#the-delivered-amount-field) has been added to the `ledger` method, and to transaction subscriptions.
|
||||
|
||||
api.getLedger({includeTransactions: true, includeAllData: true, ledgerVersion: 17718771}).then(...)
|
||||
|
||||
You can also call `ledger` directly:
|
||||
|
||||
request('ledger', {...}).then(...)
|
||||
|
||||
2. [Support for Ed25519 seeds encoded using ripple-lib](https://github.com/ripple/rippled/pull/2734)
|
||||
|
||||
You have access to these improvements when you use a rippled server running version 1.2.1 or later. At the time of writing, we recommend using rippled version **1.2.2** or later.
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
13021fe3efbdd59faf68597b0b18204b39847b285cca82f84c737e3d19922cc2 ripple-1.2.0-debug.js
|
||||
0070225e731afd8c2c0a0976111ebf326c19a96ee1549368de9f016abdd53d2f ripple-1.2.0-min.js
|
||||
d440268397c03ad5137a3294e53a07b959ef93cd23b1990d6f82621c4776ba9f ripple-1.2.0.js
|
||||
```
|
||||
|
||||
## 1.1.2 (2018-12-12)
|
||||
|
||||
+ Update `submit` response (#978)
|
||||
+ Includes the full object returned by rippled, while keeping the existing
|
||||
fields for backward compatibility
|
||||
+ Add `getLedger` option for ledger hash (#980)
|
||||
+ Use the `ledgerHash` option to get a specific ledger by hash
|
||||
|
||||
Thanks to @alexchiriac for the contributions in this release.
|
||||
|
||||
When using `ripple-lib` with `rippled`, we recommend using `rippled` version
|
||||
1.1.2 or later.
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
e6cc52395d0c3e205263777ba2e528e50f4d1f84bb4b16763a3bf7f5fcc290f5 ripple-1.1.2-debug.js
|
||||
82df879bc2970e0e4fd161975a99448b4859b0cde751d8ea34e9f51d672090b9 ripple-1.1.2-min.js
|
||||
12f56330dc71bba8ac3004025cbc9698413a0c619df302dda105b31228a67319 ripple-1.1.2.js
|
||||
```
|
||||
|
||||
## 1.1.1 (2018-11-27)
|
||||
|
||||
+ Fix `getOrderbook` offer sorting (#970)
|
||||
+ **BREAKING CHANGE:** The ordering of offers returned by `getOrderbook` has
|
||||
been changed so that offers with the best quality are sorted first
|
||||
+ Add new helper methods for working with the `rippled` APIs:
|
||||
+ `formatBidsAndAsks`: Takes offers and returns a formatted order book object
|
||||
with bids and asks
|
||||
+ `renameCounterpartyToIssuer`: Takes an object and renames the `counterparty`
|
||||
field to `issuer`
|
||||
+ TypeScript: Add return type for `generateAddress` (#968)
|
||||
|
||||
When using `ripple-lib` with `rippled`, we recommend using `rippled` version 1.1.1 or
|
||||
later.
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
e151900e49bb5482b02bef5b0b1542ea586076363b072ae616f6d4d2f7f5b8a1 ripple-1.1.1-debug.js
|
||||
6aee3757b29de285f361e20862261090033c07a13fd09f4a3cc4c097b6e84b55 ripple-1.1.1-min.js
|
||||
bea4a889fb9ee4092324c6667490ea66469bdde869ddc1aaddf5e9d12b0cf091 ripple-1.1.1.js
|
||||
```
|
||||
|
||||
## 1.1.0 (2018-10-31)
|
||||
|
||||
+ Add support for Node.js v10 LTS (#964)
|
||||
+ Add [DepositPreauth](https://developers.ripple.com/depositauth.html) ([#958](https://github.com/ripple/ripple-lib/pull/958))
|
||||
+ In `FormattedTransactionType`, the `Outcome`'s `balanceChanges` property had
|
||||
the wrong type. This is now fixed (#955)
|
||||
+ Add/fix docs for: xrpToDrops, dropsToXrp, iso8601ToRippleTime, schemaValidator, isValidAddress, isValidSecret, deriveKeypair, deriveAddress
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
e1d742092b3c0fcee97a875e18db4baeab3bbc82f08b96e883ee188c5f0cfb37 ripple-1.1.0-debug.js
|
||||
f28921f57a133678dcb3cb54c497626bd76b1f953d22d61f3ddca31c8947d552 ripple-1.1.0-min.js
|
||||
3696871a80c1102635699994adcaf00cdfdfcff5014fc2eba3d8f8d8437c8f91 ripple-1.1.0.js
|
||||
```
|
||||
|
||||
## 1.0.2 (2018-10-16)
|
||||
|
||||
+ Fix #954: Exclude SendMax from all XRP to XRP payments (thanks @jefftrudeau)
|
||||
+ TypeScript
|
||||
+ book_offers returns offers type OfferLedgerEntry (#951)
|
||||
+ Use `object` (#936)
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
2556fe17296e127ed44e7066e90a6175e2b164f00ca3c1aa7b1c554f31c688dd ripple-1.0.2-debug.js
|
||||
e0342ea21eac32a1024c62034fba09c6f26dd3e7371b23ea1e153e03135cd590 ripple-1.0.2-min.js
|
||||
c7286c517497d018d02d09257e81172b61d36c8b9885a077af68e8133c3b3b9b ripple-1.0.2.js
|
||||
```
|
||||
|
||||
## 1.0.1 (2018-09-27)
|
||||
|
||||
+ Add address/secret/key validation and derivation methods ([#932](https://github.com/ripple/ripple-lib/pull/932))
|
||||
+ `isValidAddress(address: string) : boolean`: Checks if the specified string contains a valid address.
|
||||
+ `isValidSecret(secret: string): boolean`: Checks if the specified string contains a valid secret.
|
||||
+ `deriveKeypair(seed: string): {privateKey: string, publicKey: string}`: Derive a public and private key from a seed.
|
||||
+ `deriveAddress(publicKey: string): string`: Derive an XRP Ledger address from a public key.
|
||||
+ To derive an address from a secret:
|
||||
1. Derive the public key from the secret.
|
||||
2. Derive the address from the public key.
|
||||
+ Example: `const address = api.deriveAddress(api.deriveKeypair(secret).publicKey)`
|
||||
+ Update server regex to accommodate UDS (#944)
|
||||
+ Include memos when parsing trustlines (#949)
|
||||
+ Add remaining LedgerEntry types (#943)
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
9b6408641ce83659afcd5765c256c35829a4fcb4c3244dc9ca6bf27c871a45c4 ripple-1.0.1-debug.js
|
||||
7ab2b69fe59c2d4a74638116e2ba3b387155eb2d23e48a01bbf7beb72911f898 ripple-1.0.1-min.js
|
||||
8bb4dcad9ce25a27003b1d73d71ddf41b8a5af02ece4ebbfeaff4aeb91f3b8c4 ripple-1.0.1.js
|
||||
```
|
||||
|
||||
## 1.0.0 (2018-08-30)
|
||||
|
||||
We are pleased to announce the release of `ripple-lib` version 1.0.0.
|
||||
|
||||
This version features a range of changes and improvements that make the library
|
||||
more capable and flexible. It includes new methods for accessing rippled APIs,
|
||||
including subscriptions.
|
||||
|
||||
When using this version with `rippled` for online functionality, we recommend
|
||||
using `rippled` version 1.0.1 or later.
|
||||
|
||||
Here is a summary of the changes since `ripple-lib` version 0.22.0, which was
|
||||
the last non-beta version.
|
||||
|
||||
### New Features
|
||||
|
||||
+ [Add `request()`, `hasNextPage()`, and `requestNextPage()` for accessing `rippled`
|
||||
APIs](https://github.com/ripple/ripple-lib/blob/09541dae86bc859bf5928ac65b2645dfaaf7f8b1/docs/index.md#rippled-apis).
|
||||
+ Add `prepareTransaction()` for preparing raw `txJSON`.
|
||||
+ XRP amounts can be specified in drops. Also, `xrpToDrops()` and `dropsToXrp()`
|
||||
are available to make conversions.
|
||||
+ `getTransaction` responses can include a new `channelChanges` property that
|
||||
describes the details of a payment channel.
|
||||
|
||||
### Data Validation and Errors
|
||||
|
||||
+ [Amounts in drops and XRP are checked for
|
||||
validity](https://github.com/ripple/ripple-lib/blob/develop/HISTORY.md#100-beta1-2018-05-24).
|
||||
+ [A maximum fee is now
|
||||
imposed](https://github.com/ripple/ripple-lib/blob/develop/HISTORY.md#100-beta2-2018-06-08). Exceeding it causes a `ValidationError` to be
|
||||
thrown.
|
||||
+ Errors are improved and more data validation was added.
|
||||
+ Bug fix: `getPaths` now filters paths correctly and works correctly when the
|
||||
destination currency is XRP.
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
The following changes were introduced in 1.0.0.
|
||||
|
||||
+ `getTransaction()` and `getTransactions()`
|
||||
+ The `specification.destination.amount` field has been removed from the parsed transaction response.
|
||||
+ To determine the amount that a transaction delivered, use `outcome.deliveredAmount`.
|
||||
+ If you require the provisional requested `Amount` from the original transaction:
|
||||
+ Use `getTransaction`'s `includeRawTransaction` option, or
|
||||
+ Use `getTransactions`'s `includeRawTransactions` option, or
|
||||
+ Use the rippled APIs directly with `request`. For example, call the API methods `tx`, `account_tx`, etc.
|
||||
+ `getLedger()` response object
|
||||
+ The `rawTransactions` field has been removed (for consistency with `getTransaction()` and `getTransactions()`).
|
||||
+ Instead, within each `transaction`, use the new `rawTransaction` JSON string.
|
||||
+ The `metaData` field has been renamed to `meta` for consistency with rippled's `tx` method.
|
||||
+ `ledger_index` has been added to each raw transaction.
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
06e5efcb6846ad45dedfd85cfa2ef4bdeb608b15ccbfb60b872c995d97342426 ripple-1.0.0-debug.js
|
||||
cdb26b928a89ce228c727d1ff966df266eb46b2f76bd94f81cbeb0a9d75febf0 ripple-1.0.0-min.js
|
||||
f74ee804e8a945a994e4e3901a0a3eb52292fbdcbff61ed30cefb8ffbcba50c3 ripple-1.0.0.js
|
||||
```
|
||||
|
||||
## 1.0.0-beta.5 (2018-08-11)
|
||||
|
||||
+ [Fix a TypeScript error by importing the `Prepare` type](https://github.com/ripple/ripple-lib/commit/7cd517268bda5fe74b91dad02fedf8b51b7eae9b)
|
||||
|
||||
## 1.0.0-beta.4 (2018-08-10)
|
||||
|
||||
+ [Add `prepareTransaction()`](https://github.com/ripple/ripple-lib/pull/898)
|
||||
@@ -168,6 +1039,9 @@ below.
|
||||
## 0.19.0 (2018-03-02)
|
||||
|
||||
+ [Add support for Checks](https://github.com/ripple/ripple-lib/pull/853)
|
||||
+ **CheckCreate** adds a check entry to the ledger. The check is a promise from the source of the check that the destination of the check may cash the check and receive up to the SendMax specified on the check. The check may have an (optional) expiration, after which the check may no longer be cashed.
|
||||
+ **CheckCancel** removes the check from the ledger without transferring funds. Either the check's source or destination can cancel the check at any time. After a check has expired, any account can cancel the check.
|
||||
+ **CheckCash** is a request by the destination of the check to transfer a requested amount of funds, up to the check's SendMax, from the source to the destination. The destination may receive less than the SendMax due to transfer fees.
|
||||
+ [Add support for the Deposit Authorization account root flag](https://github.com/ripple/ripple-lib/pull/852)
|
||||
+ [Generate .ts.d TypeScript declaration files](https://github.com/ripple/ripple-lib/pull/851)
|
||||
+ [Improve documentation of getTransactions params](https://github.com/ripple/ripple-lib/pull/856)
|
||||
|
||||
141
README.md
141
README.md
@@ -1,34 +1,110 @@
|
||||
# ripple-lib
|
||||
# ripple-lib (RippleAPI)
|
||||
|
||||
A JavaScript API for interacting with the XRP Ledger
|
||||
|
||||
[](https://circleci.com/gh/ripple/ripple-lib/tree/develop) [](https://coveralls.io/r/ripple/ripple-lib?branch=develop)
|
||||
A JavaScript/TypeScript API for interacting with the XRP Ledger
|
||||
|
||||
[](https://www.npmjs.org/package/ripple-lib)
|
||||
|
||||
This is the recommended library for integrating a JavaScript/TypeScript app with the XRP Ledger, especially if you intend to use advanced functionality such as IOUs, payment paths, the decentralized exchange, account settings, payment channels, escrows, multi-signing, and more.
|
||||
|
||||
## [➡️ Reference Documentation](https://xrpl.org/rippleapi-reference.html)
|
||||
|
||||
See the full reference documentation on the XRP Ledger Dev Portal.
|
||||
|
||||
## [➡️ Applications and Projects](APPLICATIONS.md)
|
||||
|
||||
What is ripple-lib used for? The applications on the list linked above use `ripple-lib`. Open a PR to add your app or project to the list!
|
||||
|
||||
### Features
|
||||
|
||||
+ Connect to a `rippled` server from Node.js or a web browser
|
||||
+ Issue [rippled API](https://ripple.com/build/rippled-apis/) requests
|
||||
+ Listen to events on the XRP Ledger (transaction, ledger, etc.)
|
||||
+ Helpers for creating requests and parsing responses for the [rippled API](https://developers.ripple.com/rippled-api.html)
|
||||
+ Listen to events on the XRP Ledger (transactions, ledger, validations, etc.)
|
||||
+ Sign and submit transactions to the XRP Ledger
|
||||
+ Type definitions for TypeScript
|
||||
|
||||
### Requirements
|
||||
|
||||
+ **[Node.js v14](https://nodejs.org/)** is recommended. Other versions may work but are not frequently tested.
|
||||
+ **[Yarn](https://yarnpkg.com/)** is recommended. `npm` may work but we use `yarn.lock`.
|
||||
|
||||
## Getting Started
|
||||
|
||||
See also: [RippleAPI Beginners Guide](https://ripple.com/build/rippleapi-beginners-guide/)
|
||||
See also: [RippleAPI Beginners Guide](https://xrpl.org/get-started-with-rippleapi-for-javascript.html)
|
||||
|
||||
You can use `npm`, but we recommend using `yarn` for the added assurance provided by `yarn.lock`.
|
||||
|
||||
+ [Yarn Installation Instructions](https://yarnpkg.com/en/docs/install)
|
||||
|
||||
Install `ripple-lib`:
|
||||
In an existing project (with `package.json`), install `ripple-lib`:
|
||||
```
|
||||
$ yarn add ripple-lib
|
||||
```
|
||||
|
||||
Then see the [documentation](https://github.com/ripple/ripple-lib/blob/develop/docs/index.md) and [code samples](https://github.com/ripple/ripple-lib/tree/develop/docs/samples).
|
||||
Then see the [documentation](#documentation).
|
||||
|
||||
### Mailing lists
|
||||
### 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
|
||||
|
||||
+ [RippleAPI Beginners Guide](https://xrpl.org/get-started-with-rippleapi-for-javascript.html)
|
||||
+ [RippleAPI Full Reference Documentation](https://xrpl.org/rippleapi-reference.html) ([in this repo](https://github.com/ripple/ripple-lib/blob/develop/docs/index.md))
|
||||
+ [Code Samples](https://github.com/ripple/ripple-lib/tree/develop/docs/samples)
|
||||
|
||||
### Mailing Lists
|
||||
|
||||
We have a low-traffic mailing list for announcements of new ripple-lib releases. (About 1 email per week)
|
||||
|
||||
@@ -40,34 +116,41 @@ If you're using the XRP Ledger in production, you should run a [rippled server](
|
||||
|
||||
## Development
|
||||
|
||||
To build the library for Node.js:
|
||||
```
|
||||
$ yarn compile
|
||||
```
|
||||
|
||||
The TypeScript compiler will [output](./tsconfig.json#L7) the resulting JS files in `./dist/npm/`.
|
||||
|
||||
To build the library for the browser:
|
||||
To build the library for Node.js and the browser:
|
||||
```
|
||||
$ yarn build
|
||||
```
|
||||
|
||||
Gulp will [output](./Gulpfile.js) the resulting JS files in `./build/`.
|
||||
The TypeScript compiler will [output](./tsconfig.json#L7) the resulting JS files in `./dist/npm/`.
|
||||
|
||||
For more details, see the `scripts` in `package.json`.
|
||||
webpack will output the resulting JS files in `./build/`.
|
||||
|
||||
## Running tests
|
||||
For details, see the `scripts` in `package.json`.
|
||||
|
||||
## Running Tests
|
||||
|
||||
### Unit Tests
|
||||
|
||||
1. Clone the repository
|
||||
2. `cd` into the repository and install dependencies with `yarn install`
|
||||
3. `yarn test` or `yarn test --coverage` (`istanbul` will create coverage reports in `coverage/lcov-report/`)
|
||||
3. `yarn test`
|
||||
|
||||
### Linting
|
||||
|
||||
Run `yarn lint` to lint the code with `eslint`.
|
||||
|
||||
## Generating Documentation
|
||||
|
||||
The continuous integration tests require that the documentation stays up-to-date. If you make changes to the JSON schemas, fixtures, or documentation sources, you must update the documentation by running `yarn run docgen`.
|
||||
Do not edit `./docs/index.md` directly because it is a generated file.
|
||||
|
||||
`npm` may be used instead of `yarn` in the commands above.
|
||||
Instead, edit the appropriate `.md.ejs` files in `./docs/src/`.
|
||||
|
||||
If you make changes to the JSON schemas, fixtures, or documentation sources, update the documentation by running `yarn run docgen`.
|
||||
|
||||
## More Information
|
||||
|
||||
+ [Ripple Developer Center](https://ripple.com/build/)
|
||||
+ [ripple-lib-announce mailing list](https://groups.google.com/forum/#!forum/ripple-lib-announce) - subscribe for release announcements
|
||||
+ [RippleAPI Reference](https://xrpl.org/rippleapi-reference.html) - XRP Ledger Dev Portal
|
||||
+ [XRP Ledger Dev Portal](https://xrpl.org/)
|
||||
|
||||
[](https://travis-ci.org/ripple/ripple-lib)
|
||||
|
||||
29
SECURITY.md
Normal file
29
SECURITY.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
This table shows which versions of ripple-lib are currently supported with security updates:
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ---------------------- |
|
||||
| 1.x | :white_check_mark: Yes |
|
||||
| 0.x | :x: No |
|
||||
|
||||
## Responsible disclosure security policy
|
||||
|
||||
The responsible disclosure of vulnerabilities helps to protect users of the project. Vulnerabilities are first triaged in a private manner, and only publicly disclosed after a reasonable time period that allows patching the vulnerability and provides an upgrade path for users.
|
||||
|
||||
When contacting us directly via email, we will do our best to respond in a reasonable time to resolve the issue. Do not disclose the vulnerability until it has been patched and users have been given time to upgrade.
|
||||
|
||||
We kindly ask you to refrain from malicious acts that put our users, the project, or any of the project’s team members at risk.
|
||||
|
||||
## Reporting a security issue
|
||||
|
||||
Security is a top priority. But no matter how much effort we put into security, there can still be vulnerabilities present.
|
||||
|
||||
If you discover a security vulnerability, please use the following means of communications to report it to us:
|
||||
|
||||
- Report the security issue to bugs@ripple.com
|
||||
- [Ripple Bug Bounty](https://ripple.com/bug-bounty/)
|
||||
|
||||
Your efforts to responsibly disclose your findings are sincerely appreciated and will be taken into account to acknowledge your contributions.
|
||||
9
custom_typings/node.d.ts
vendored
9
custom_typings/node.d.ts
vendored
@@ -1,9 +0,0 @@
|
||||
/**
|
||||
* This is an extension of Node's `process` object to include the browser
|
||||
* property, which is added by webpack.
|
||||
*/
|
||||
interface AmbiguousProcess extends NodeJS.Process {
|
||||
browser?: true
|
||||
}
|
||||
|
||||
declare var process: AmbiguousProcess;
|
||||
2510
docs/index.md
2510
docs/index.md
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,5 @@
|
||||
Usage:
|
||||
babel-node balances.js
|
||||
babel-node cancelall.js (requires setting address and secret in source file first)
|
||||
babel-node payment.js (requires setting address and secret in source file first)
|
||||
babel-node ticket.js (requires setting address and secret in source file first)
|
||||
|
||||
31
docs/samples/ticket.js
Normal file
31
docs/samples/ticket.js
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
const RippleAPI = require('../../src').RippleAPI; // require('ripple-lib')
|
||||
|
||||
const address = 'INSERT ADDRESS HERE';
|
||||
const secret = 'INSERT SECRET HERE';
|
||||
|
||||
const api = new RippleAPI({server: 'wss://s1.ripple.com:443'});
|
||||
const instructions = {
|
||||
maxLedgerVersionOffset: 5
|
||||
};
|
||||
const numberOfTickets = 1;
|
||||
|
||||
function quit(message) {
|
||||
console.log(message);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
function fail(message) {
|
||||
console.error(message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
api.connect().then(() => {
|
||||
console.log('Connected...');
|
||||
return api.prepareTicketCreate(address, numberOfTickets, instructions).then(prepared => {
|
||||
console.log('Ticket transaction prepared...');
|
||||
const {signedTransaction} = api.sign(prepared.txJSON, secret);
|
||||
console.log('Ticket transaction signed...');
|
||||
api.submit(signedTransaction).then(quit, fail);
|
||||
});
|
||||
}).catch(fail);
|
||||
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.
|
||||
@@ -6,11 +6,23 @@
|
||||
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
|
||||
```
|
||||
|
||||
Every XRP Ledger account has an *address*, which is a base58-encoding of a hash of the account's public key. XRP Ledger addresses always start with the lowercase letter `r`.
|
||||
```json
|
||||
"X7AcgcsBL6XDcUb289X4mJ8djcdyKaB5hJDWMArnXr61cqZ"
|
||||
```
|
||||
|
||||
An *address* refers to a specific XRP Ledger account. It is a base-58 encoding of a hash of the account's public key. There are two kinds of addresses in common use:
|
||||
|
||||
### Classic Address
|
||||
|
||||
A *classic address* encodes a hash of the account's public key and a checksum. It has no other data. This kind of address always starts with the lowercase letter `r`.
|
||||
|
||||
### X-address
|
||||
|
||||
An *X-address* encodes a hash of the account's public key, a tag, and a checksum. This kind of address starts with the uppercase letter `X` if it is intended for use on the production XRP Ledger (mainnet). It starts with the uppercase letter `T` if it is intended for use on a test network such as Testnet or Devnet.
|
||||
|
||||
## Account Sequence Number
|
||||
|
||||
Every XRP Ledger account has a *sequence number* that is used to keep transactions in order. Every transaction must have a sequence number. A transaction can only be executed if it has the next sequence number in order, of the account sending it. This prevents one transaction from executing twice and transactions executing out of order. The sequence number starts at `1` and increments for each transaction that the account makes.
|
||||
Every XRP Ledger account has a *sequence number* that is used to keep transactions in order. Every transaction must have a sequence or a ticketSequence number. A transaction can only be executed if it has the next sequence number in order, of the account sending it, or uses a previously generated ticketSequence number. This prevents one transaction from executing twice and transactions executing out of order. The sequence number starts at `1` and increments for each transaction that the account makes.
|
||||
|
||||
## Currency
|
||||
|
||||
@@ -19,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`.
|
||||
|
||||
@@ -52,4 +64,4 @@ A *lax lax amount* allows either or both the counterparty and value to be omitte
|
||||
|
||||
A *balance* is an amount than can have a negative value.
|
||||
|
||||
<%- renderSchema('objects/amount-base.json') %>
|
||||
<%- renderSchema('objects/amountbase.json') %>
|
||||
|
||||
@@ -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.11.3**. RippleAPI may work on older Node.js versions if you use [Babel](https://babeljs.io/) for [ECMAScript 6](https://babeljs.io/docs/learn-es2015/) support.
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## computeLedgerHash
|
||||
|
||||
`computeLedgerHash(ledger: Object): string`
|
||||
`computeLedgerHash(ledger: object): string`
|
||||
|
||||
Compute the hash of a ledger.
|
||||
|
||||
|
||||
19
docs/src/deriveAddress.md.ejs
Normal file
19
docs/src/deriveAddress.md.ejs
Normal file
@@ -0,0 +1,19 @@
|
||||
## deriveAddress
|
||||
|
||||
`deriveAddress(publicKey: string): string`
|
||||
|
||||
Derive an XRP Ledger address from a public key.
|
||||
|
||||
### Parameters
|
||||
|
||||
This method takes one parameter, the public key from which to derive the address.
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns a string corresponding to the address derived from the public key.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
var address = api.deriveAddress(public_key);
|
||||
```
|
||||
21
docs/src/deriveKeypair.md.ejs
Normal file
21
docs/src/deriveKeypair.md.ejs
Normal file
@@ -0,0 +1,21 @@
|
||||
## deriveKeypair
|
||||
|
||||
`deriveKeypair(seed: string): {privateKey: string, publicKey: string}`
|
||||
|
||||
Derive a public and private key from a seed.
|
||||
|
||||
### Parameters
|
||||
|
||||
This method takes one parameter, the seed from which to derive the public and private key.
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns an object containing the public and private components of the keypair corresponding to the seed.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
var keypair = api.deriveKeypair(seed)
|
||||
var public_key = keypair.publicKey;
|
||||
var private_key = keypair.privateKey;
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
|
||||
254
docs/src/formatBidsAndAsks.md.ejs
Normal file
254
docs/src/formatBidsAndAsks.md.ejs
Normal file
@@ -0,0 +1,254 @@
|
||||
## formatBidsAndAsks
|
||||
|
||||
`formatBidsAndAsks(orderbookInfo: {base: Issue, counter: Issue}, offers: BookOffer[]): orderbook`
|
||||
|
||||
Returns formatted bids and asks, which make up an orderbook.
|
||||
|
||||
This is a static method on the `RippleAPI` class.
|
||||
|
||||
### Parameters
|
||||
|
||||
This method takes two parameters.
|
||||
|
||||
1. An `OrderbookInfo` object: `{ base: Issue, counter: Issue }`.
|
||||
2. An array of `BookOffer` objects.
|
||||
|
||||
### 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. Both `bids` and `asks` are formatted the same way.
|
||||
|
||||
Object structure:
|
||||
|
||||
<%- 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` [book_offers method](https://xrpl.org/book_offers.html).
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
const orderbookInfo = {
|
||||
"base": {
|
||||
"currency": "USD",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
},
|
||||
"counter": {
|
||||
"currency": "BTC",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
}
|
||||
};
|
||||
|
||||
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
||||
|
||||
return Promise.all(
|
||||
[
|
||||
this.api.request('book_offers', {
|
||||
taker_gets: RippleAPI.renameCounterpartyToIssuer(orderbookInfo.base),
|
||||
taker_pays: RippleAPI.renameCounterpartyToIssuer(orderbookInfo.counter),
|
||||
ledger_index: 'validated',
|
||||
limit: 20,
|
||||
taker: address
|
||||
}),
|
||||
this.api.request('book_offers', {
|
||||
taker_gets: RippleAPI.renameCounterpartyToIssuer(orderbookInfo.counter),
|
||||
taker_pays: RippleAPI.renameCounterpartyToIssuer(orderbookInfo.base),
|
||||
ledger_index: 'validated',
|
||||
limit: 20,
|
||||
taker: address
|
||||
})
|
||||
]
|
||||
).then((directOfferResults, reverseOfferResults) => {
|
||||
const directOffers = (directOfferResults ? directOfferResults : []).reduce((acc, res) => acc.concat(res.offers), [])
|
||||
const reverseOffers = (reverseOfferResults ? reverseOfferResults : []).reduce((acc, res) => acc.concat(res.offers), [])
|
||||
const orderbook = RippleAPI.formatBidsAndAsks(orderbookInfo, [...directOffers, ...reverseOffers]);
|
||||
console.log(JSON.stringify(orderbook, null, 2));
|
||||
});
|
||||
```
|
||||
|
||||
```
|
||||
{
|
||||
"bids": [
|
||||
{
|
||||
"specification": {
|
||||
"direction": "buy",
|
||||
"quantity": {
|
||||
"currency": "USD",
|
||||
"value": "0.71800168",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
},
|
||||
"totalPrice": {
|
||||
"currency": "BTC",
|
||||
"value": "0.00016708342",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"maker": "rUKoQ1Zhn6c8EfPsaVa2Yx5NqaKN1JQSvq",
|
||||
"sequence": 262660,
|
||||
"makerExchangeRate": "4297.264683713081"
|
||||
},
|
||||
"data": {
|
||||
"Account": "rUKoQ1Zhn6c8EfPsaVa2Yx5NqaKN1JQSvq",
|
||||
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98580F4456E6FA8239",
|
||||
"BookNode": "0000000000000000",
|
||||
"Flags": 0,
|
||||
"LedgerEntryType": "Offer",
|
||||
"OwnerNode": "000000000000001D",
|
||||
"PreviousTxnID": "16D75506C6317723FC03543130B5E0AAB13E8AD22514C1DB098BE05771C90447",
|
||||
"PreviousTxnLgrSeq": 43127860,
|
||||
"Sequence": 262660,
|
||||
"TakerGets": {
|
||||
"currency": "BTC",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"value": "0.00016708342"
|
||||
},
|
||||
"TakerPays": {
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"value": "0.71800168"
|
||||
},
|
||||
"index": "DE877FB94EF892A4BCC58DB8CDE063D97AB5133201905DE6C8650B5DEA19E11B",
|
||||
"owner_funds": "0.03358376764081196",
|
||||
"quality": "4297.264683713081"
|
||||
}
|
||||
},
|
||||
{
|
||||
"specification": {
|
||||
"direction": "buy",
|
||||
"quantity": {
|
||||
"currency": "USD",
|
||||
"value": "1.6770875",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
},
|
||||
"totalPrice": {
|
||||
"currency": "BTC",
|
||||
"value": "0.00038681218",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"maker": "rpmL45YbZWKgp8AH8EjBSknWo5c8dNuuBM",
|
||||
"sequence": 231459,
|
||||
"makerExchangeRate": "4335.663628792661"
|
||||
},
|
||||
"data": {
|
||||
"Account": "rpmL45YbZWKgp8AH8EjBSknWo5c8dNuuBM",
|
||||
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98580F67435A75B355",
|
||||
"BookNode": "0000000000000000",
|
||||
"Flags": 0,
|
||||
"LedgerEntryType": "Offer",
|
||||
"OwnerNode": "0000000000000001",
|
||||
"PreviousTxnID": "F049EAFDDDA7B99970F77533743D95C9E12A16FE6C56215A0B09C32C4D23163F",
|
||||
"PreviousTxnLgrSeq": 43127094,
|
||||
"Sequence": 231459,
|
||||
"TakerGets": {
|
||||
"currency": "BTC",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"value": "0.00038681218"
|
||||
},
|
||||
"TakerPays": {
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"value": "1.6770875"
|
||||
},
|
||||
"index": "3B314A51BD57601CA1509834DF9462037BF4B05AFCC1E1EFD334DB4E2D7B2AA6",
|
||||
"owner_funds": "0.03906802968738533",
|
||||
"quality": "4335.663628792661"
|
||||
}
|
||||
},
|
||||
// ... trimmed for brevity ...
|
||||
],
|
||||
"asks": [
|
||||
{
|
||||
"specification": {
|
||||
"direction": "sell",
|
||||
"quantity": {
|
||||
"currency": "USD",
|
||||
"value": "0.71085738",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
},
|
||||
"totalPrice": {
|
||||
"currency": "BTC",
|
||||
"value": "0.00016876265",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"maker": "rUKoQ1Zhn6c8EfPsaVa2Yx5NqaKN1JQSvq",
|
||||
"sequence": 262664,
|
||||
"makerExchangeRate": "0.0002374071856720401"
|
||||
},
|
||||
"data": {
|
||||
"Account": "rUKoQ1Zhn6c8EfPsaVa2Yx5NqaKN1JQSvq",
|
||||
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A451086F34ADB0EA11",
|
||||
"BookNode": "0000000000000000",
|
||||
"Flags": 0,
|
||||
"LedgerEntryType": "Offer",
|
||||
"OwnerNode": "000000000000001D",
|
||||
"PreviousTxnID": "54CE0B2783AF973718FAFA35E864A3C172BE488EBBB6F2852611C6DAC8893BDF",
|
||||
"PreviousTxnLgrSeq": 43127875,
|
||||
"Sequence": 262664,
|
||||
"TakerGets": {
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"value": "0.71085738"
|
||||
},
|
||||
"TakerPays": {
|
||||
"currency": "BTC",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"value": "0.00016876265"
|
||||
},
|
||||
"index": "2D4ED103D6B3FEFA21BC385C53B63359F5678E5AA5429DDE6E1D8FE8B41CD6A8",
|
||||
"owner_funds": "142.8821425048244",
|
||||
"quality": "0.0002374071856720401"
|
||||
}
|
||||
},
|
||||
{
|
||||
"specification": {
|
||||
"direction": "sell",
|
||||
"quantity": {
|
||||
"currency": "USD",
|
||||
"value": "1.6438778",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
},
|
||||
"totalPrice": {
|
||||
"currency": "BTC",
|
||||
"value": "0.00039462656",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"maker": "rpmL45YbZWKgp8AH8EjBSknWo5c8dNuuBM",
|
||||
"sequence": 231483,
|
||||
"makerExchangeRate": "0.0002400583303698121"
|
||||
},
|
||||
"data": {
|
||||
"Account": "rpmL45YbZWKgp8AH8EjBSknWo5c8dNuuBM",
|
||||
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4510887515B1216C9",
|
||||
"BookNode": "0000000000000000",
|
||||
"Flags": 0,
|
||||
"LedgerEntryType": "Offer",
|
||||
"OwnerNode": "0000000000000001",
|
||||
"PreviousTxnID": "6FA370F52C45F6149482156FF7B4226713AECE991FB7D053F74172CB0B8F24E9",
|
||||
"PreviousTxnLgrSeq": 43127158,
|
||||
"Sequence": 231483,
|
||||
"TakerGets": {
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"value": "1.6438778"
|
||||
},
|
||||
"TakerPays": {
|
||||
"currency": "BTC",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"value": "0.00039462656"
|
||||
},
|
||||
"index": "735F9661AD006BA0776859BE371D445555FC0815604603AC056469C16AC84AE3",
|
||||
"owner_funds": "166.0316626329364",
|
||||
"quality": "0.0002400583303698121"
|
||||
}
|
||||
},
|
||||
// ... trimmed for brevity ...
|
||||
]
|
||||
}
|
||||
```
|
||||
@@ -1,6 +1,8 @@
|
||||
## generateAddress
|
||||
|
||||
`generateAddress(): {address: string, secret: string}`
|
||||
`generateAddress(options?: object): {address: string, secret: string}`
|
||||
|
||||
Deprecated: This method returns a classic address. If you do not need the classic address, use `generateXAddress` instead.
|
||||
|
||||
Generate a new XRP Ledger address and corresponding secret.
|
||||
|
||||
|
||||
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') %>
|
||||
23
docs/src/generateXAddress.md.ejs
Normal file
23
docs/src/generateXAddress.md.ejs
Normal file
@@ -0,0 +1,23 @@
|
||||
## generateXAddress
|
||||
|
||||
`generateXAddress(options?: object): {address: string, secret: string}`
|
||||
|
||||
Generate a new XRP Ledger address and corresponding secret.
|
||||
|
||||
### Parameters
|
||||
|
||||
<%- renderSchema('input/generate-x-address.json') %>
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns an object with the following structure:
|
||||
|
||||
<%- renderSchema('output/generate-x-address.json') %>
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
return api.generateXAddress();
|
||||
```
|
||||
|
||||
<%- renderFixture('responses/generate-x-address.json') %>
|
||||
@@ -1,6 +1,6 @@
|
||||
## getAccountInfo
|
||||
|
||||
`getAccountInfo(address: string, options: Object): Promise<Object>`
|
||||
`getAccountInfo(address: string, options: object): Promise<object>`
|
||||
|
||||
Returns information for the specified account. Note: For account data that is modifiable by the user, see [getSettings](#getsettings).
|
||||
|
||||
|
||||
@@ -15,12 +15,13 @@ This method returns a promise that resolves with an object with the following st
|
||||
<%- renderSchema('output/get-account-objects.json') %>
|
||||
|
||||
The types of objects that may be returned include:
|
||||
* Offer objects for orders that are currently live, unfunded, or expired but not yet removed.
|
||||
* RippleState objects for trust lines where this account's side is not in the default state.
|
||||
* A SignerList object if the account has multi-signing enabled.
|
||||
* Escrow objects for held payments that have not yet been executed or canceled.
|
||||
* PayChannel objects for open payment channels.
|
||||
* Check objects for pending checks.
|
||||
|
||||
* `Offer` objects for orders that are currently live, unfunded, or expired but not yet removed.
|
||||
* `RippleState` objects for trust lines where this account's side is not in the default state.
|
||||
* A `SignerList` object if the account has multi-signing enabled.
|
||||
* `Escrow` objects for held payments that have not yet been executed or canceled.
|
||||
* `PayChannel` objects for open payment channels.
|
||||
* `Check` objects for pending checks.
|
||||
|
||||
### Example
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## getBalanceSheet
|
||||
|
||||
`getBalanceSheet(address: string, options: Object): Promise<Object>`
|
||||
`getBalanceSheet(address: string, options: object): Promise<object>`
|
||||
|
||||
Returns aggregate balances by currency plus a breakdown of assets and obligations for a specified account.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## getBalances
|
||||
|
||||
`getBalances(address: string, options: Object): Promise<Array<Object>>`
|
||||
`getBalances(address: string, options: object): Promise<Array<object>>`
|
||||
|
||||
Returns balances for a specified account.
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## getLedger
|
||||
|
||||
`getLedger(options: Object): Promise<Object>`
|
||||
`getLedger(options: object): Promise<object>`
|
||||
|
||||
Returns header information for the specified ledger (or the most recent validated ledger if no ledger is specified). Optionally, all the transactions that were validated in the ledger or the account state information can be returned with the ledger header.
|
||||
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
## getOrderbook
|
||||
|
||||
`getOrderbook(address: string, orderbook: Object, options: Object): Promise<Object>`
|
||||
`getOrderbook(address: string, orderbook: object, options: object): Promise<object>`
|
||||
|
||||
Returns open orders for the specified account. Open orders are orders that have not yet been fully executed and are still in the order book.
|
||||
|
||||
**Breaking change:** In ripple-lib 1.1.0 and earlier, orders returned by this method were not sorted correctly. Orders are now sorted correctly, from best to worst.
|
||||
|
||||
**See also:** An alternative way to get orderbooks is with `request` and [`formatBidsAndAsks`](#formatbidsandasks).
|
||||
|
||||
### Parameters
|
||||
|
||||
<%- renderSchema('input/get-orderbook.json') %>
|
||||
|
||||
### 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
|
||||
**Raw order data:** The response includes a `data` property containing the raw order data. This may include `owner_funds`, `Flags`, and other fields.
|
||||
|
||||
(Requires ripple-lib 0.22.0 or higher.) 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
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## getOrders
|
||||
|
||||
`getOrders(address: string, options: Object): Promise<Array<Object>>`
|
||||
`getOrders(address: string, options: object): Promise<Array<object>>`
|
||||
|
||||
Returns open orders for the specified account. Open orders are orders that have not yet been fully executed and are still in the order book.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## getPaths
|
||||
|
||||
`getPaths(pathfind: Object): Promise<Array<Object>>`
|
||||
`getPaths(pathfind: object): Promise<Array<object>>`
|
||||
|
||||
Finds paths to send a payment. Paths are options for how to route a payment.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## getPaymentChannel
|
||||
|
||||
`getPaymentChannel(id: string): Promise<Object>`
|
||||
`getPaymentChannel(id: string): Promise<object>`
|
||||
|
||||
Returns specified payment channel.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## getSettings
|
||||
|
||||
`getSettings(address: string, options: Object): Promise<Object>`
|
||||
`getSettings(address: string, options: object): Promise<object>`
|
||||
|
||||
Returns settings for the specified account. Note: For account data that is not modifiable by the user, see [getAccountInfo](#getaccountinfo).
|
||||
|
||||
@@ -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') %>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## getTransaction
|
||||
|
||||
`getTransaction(id: string, options: Object): Promise<Object>`
|
||||
`getTransaction(id: string, options: object): Promise<object>`
|
||||
|
||||
Retrieves a transaction by its [Transaction ID](#transaction-id).
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## getTransactions
|
||||
|
||||
`getTransactions(address: string, options: Object): Promise<Array<Object>>`
|
||||
`getTransactions(address: string, options: object): Promise<Array<object>>`
|
||||
|
||||
Retrieves historical transactions of an account.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## getTrustlines
|
||||
|
||||
`getTrustlines(address: string, options: Object): Promise<Array<Object>>`
|
||||
`getTrustlines(address: string, options: object): Promise<Array<object>>`
|
||||
|
||||
Returns trustlines for a specified account.
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,52 +1,72 @@
|
||||
<% include introduction.md.ejs %>
|
||||
<% include boilerplate.md.ejs %>
|
||||
<% include offline.md.ejs %>
|
||||
<% include basictypes.md.ejs %>
|
||||
<% include transactions.md.ejs %>
|
||||
<% include specifications.md.ejs %>
|
||||
<% include rippledAPIs.md.ejs %>
|
||||
<% include request.md.ejs %>
|
||||
<% include hasNextPage.md.ejs %>
|
||||
<% include requestNextPage.md.ejs %>
|
||||
<% include methods.md.ejs %>
|
||||
<% include connect.md.ejs %>
|
||||
<% include disconnect.md.ejs %>
|
||||
<% include isConnected.md.ejs %>
|
||||
<% include getServerInfo.md.ejs %>
|
||||
<% include getFee.md.ejs %>
|
||||
<% include getLedgerVersion.md.ejs %>
|
||||
<% include getTransaction.md.ejs %>
|
||||
<% include getTransactions.md.ejs %>
|
||||
<% include getTrustlines.md.ejs %>
|
||||
<% include getBalances.md.ejs %>
|
||||
<% include getBalanceSheet.md.ejs %>
|
||||
<% include getPaths.md.ejs %>
|
||||
<% include getOrders.md.ejs %>
|
||||
<% include getOrderbook.md.ejs %>
|
||||
<% include getSettings.md.ejs %>
|
||||
<% include getAccountInfo.md.ejs %>
|
||||
<% include getAccountObjects.md.ejs %>
|
||||
<% include getPaymentChannel.md.ejs %>
|
||||
<% include getLedger.md.ejs %>
|
||||
<% include preparePayment.md.ejs %>
|
||||
<% include prepareTrustline.md.ejs %>
|
||||
<% include prepareOrder.md.ejs %>
|
||||
<% include prepareOrderCancellation.md.ejs %>
|
||||
<% include prepareSettings.md.ejs %>
|
||||
<% include prepareEscrowCreation.md.ejs %>
|
||||
<% include prepareEscrowCancellation.md.ejs %>
|
||||
<% include prepareEscrowExecution.md.ejs %>
|
||||
<% include preparePaymentChannelCreate.md.ejs %>
|
||||
<% include preparePaymentChannelClaim.md.ejs %>
|
||||
<% include preparePaymentChannelFund.md.ejs %>
|
||||
<% include prepareCheckCreate.md.ejs %>
|
||||
<% include prepareCheckCancel.md.ejs %>
|
||||
<% include prepareCheckCash.md.ejs %>
|
||||
<% include sign.md.ejs %>
|
||||
<% include combine.md.ejs %>
|
||||
<% include submit.md.ejs %>
|
||||
<% include generateAddress.md.ejs %>
|
||||
<% include signPaymentChannelClaim.md.ejs %>
|
||||
<% include verifyPaymentChannelClaim.md.ejs %>
|
||||
<% include computeLedgerHash.md.ejs %>
|
||||
<% include events.md.ejs %>
|
||||
<%- include('introduction.md.ejs') %>
|
||||
<%- include('boilerplate.md.ejs') %>
|
||||
<%- include('offline.md.ejs') %>
|
||||
<%- include('basictypes.md.ejs') %>
|
||||
<%- include('transactions.md.ejs') %>
|
||||
<%- include('specifications.md.ejs') %>
|
||||
<%- include('rippledAPIs.md.ejs') %>
|
||||
<%- include('request.md.ejs') %>
|
||||
<%- include('hasNextPage.md.ejs') %>
|
||||
<%- include('requestNextPage.md.ejs') %>
|
||||
|
||||
<%- include('staticMethods.md.ejs') %>
|
||||
<%- include('renameCounterpartyToIssuer.md.ejs') %>
|
||||
<%- include('formatBidsAndAsks.md.ejs') %>
|
||||
|
||||
<%- include('methods.md.ejs') %>
|
||||
<%- include('connect.md.ejs') %>
|
||||
<%- include('disconnect.md.ejs') %>
|
||||
<%- include('isConnected.md.ejs') %>
|
||||
<%- include('getServerInfo.md.ejs') %>
|
||||
<%- include('getFee.md.ejs') %>
|
||||
<%- include('getLedgerVersion.md.ejs') %>
|
||||
<%- include('getTransaction.md.ejs') %>
|
||||
<%- include('getTransactions.md.ejs') %>
|
||||
<%- include('getTrustlines.md.ejs') %>
|
||||
<%- include('getBalances.md.ejs') %>
|
||||
<%- include('getBalanceSheet.md.ejs') %>
|
||||
<%- include('getPaths.md.ejs') %>
|
||||
<%- include('getOrders.md.ejs') %>
|
||||
<%- include('getOrderbook.md.ejs') %>
|
||||
<%- include('getSettings.md.ejs') %>
|
||||
<%- include('getAccountInfo.md.ejs') %>
|
||||
<%- include('getAccountObjects.md.ejs') %>
|
||||
<%- include('getPaymentChannel.md.ejs') %>
|
||||
<%- include('getLedger.md.ejs') %>
|
||||
<%- include('parseAccountFlags.md.ejs') %>
|
||||
<%- include('prepareTransaction.md.ejs') %>
|
||||
<%- include('preparePayment.md.ejs') %>
|
||||
<%- include('prepareTrustline.md.ejs') %>
|
||||
<%- include('prepareOrder.md.ejs') %>
|
||||
<%- include('prepareOrderCancellation.md.ejs') %>
|
||||
<%- include('prepareSettings.md.ejs') %>
|
||||
<%- include('prepareEscrowCreation.md.ejs') %>
|
||||
<%- include('prepareEscrowCancellation.md.ejs') %>
|
||||
<%- include('prepareEscrowExecution.md.ejs') %>
|
||||
<%- include('preparePaymentChannelCreate.md.ejs') %>
|
||||
<%- include('preparePaymentChannelClaim.md.ejs') %>
|
||||
<%- include('preparePaymentChannelFund.md.ejs') %>
|
||||
<%- include('prepareCheckCreate.md.ejs') %>
|
||||
<%- include('prepareCheckCancel.md.ejs') %>
|
||||
<%- include('prepareCheckCash.md.ejs') %>
|
||||
<%- include('prepareTicketCreate.md.ejs') %>
|
||||
<%- include('sign.md.ejs') %>
|
||||
<%- include('combine.md.ejs') %>
|
||||
<%- include('submit.md.ejs') %>
|
||||
<%- include('generateXAddress.md.ejs') %>
|
||||
<%- include('generateAddress.md.ejs') %>
|
||||
<%- include('isValidAddress.md.ejs') %>
|
||||
<%- 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') %>
|
||||
<%- include('xrpToDropsAndDropsToXrp.md.ejs') %>
|
||||
<%- 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,6 +1,7 @@
|
||||
# Introduction
|
||||
|
||||
RippleAPI (ripple-lib) is the official client library to the XRP Ledger. Currently, RippleAPI is only available in JavaScript.
|
||||
RippleAPI (ripple-lib) is the official client library to the XRP Ledger. Currently, RippleAPI is only available in JavaScript/TypeScript.
|
||||
|
||||
Using RippleAPI, you can:
|
||||
|
||||
* [Query transactions from the XRP Ledger history](#gettransaction)
|
||||
@@ -8,3 +9,7 @@ Using RippleAPI, you can:
|
||||
* [Submit](#submit) transactions to the XRP Ledger, including [Payments](#payment), [Orders](#order), [Settings changes](#settings), and [other types](#transaction-types)
|
||||
* [Generate a new XRP Ledger Address](#generateaddress)
|
||||
* ... and [much more](#api-methods).
|
||||
|
||||
This page contains documentation for ripple-lib. To use ripple-lib with npm/yarn, begin with the [Getting Started](https://github.com/ripple/ripple-lib#getting-started) steps.
|
||||
|
||||
**What is ripple-lib used for?** Here's a [list of applications that use `ripple-lib`](https://github.com/ripple/ripple-lib/blob/develop/APPLICATIONS.md). Open a PR to add your app or project to the list!
|
||||
|
||||
19
docs/src/isValidAddress.md.ejs
Normal file
19
docs/src/isValidAddress.md.ejs
Normal file
@@ -0,0 +1,19 @@
|
||||
## isValidAddress
|
||||
|
||||
`isValidAddress(address: string): boolean`
|
||||
|
||||
Checks if the specified string contains a valid address. X-addresses are considered valid with ripple-lib v1.4.0 and higher.
|
||||
|
||||
### Parameters
|
||||
|
||||
This method takes one parameter, the address to validate.
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns `true` if the address is valid and `false` if it is not.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
return api.isValidAddress("address")
|
||||
```
|
||||
19
docs/src/isValidSecret.md.ejs
Normal file
19
docs/src/isValidSecret.md.ejs
Normal file
@@ -0,0 +1,19 @@
|
||||
## isValidSecret
|
||||
|
||||
`isValidSecret(secret: string): boolean`
|
||||
|
||||
Checks if the specified string contains a valid secret.
|
||||
|
||||
### Parameters
|
||||
|
||||
This method takes one parameter, the secret which to validate.
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns `true` if the secret is valid and `false` if it is not.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
return api.isValidSecret("secret")
|
||||
```
|
||||
27
docs/src/iso8601ToRippleTime.md.ejs
Normal file
27
docs/src/iso8601ToRippleTime.md.ejs
Normal file
@@ -0,0 +1,27 @@
|
||||
## iso8601ToRippleTime
|
||||
|
||||
`iso8601ToRippleTime(iso8601: string): number`
|
||||
|
||||
This method parses a string representation of a date, and returns the number of seconds since the "Ripple Epoch" of January 1, 2000 (00:00 UTC).
|
||||
|
||||
The Ripple Epoch is 946684800 seconds after the Unix Epoch.
|
||||
|
||||
This method is useful for creating timestamps to use with the rippled APIs. The rippled APIs represent time as an unsigned integer of the number of seconds since the Ripple Epoch.
|
||||
|
||||
### Parameters
|
||||
|
||||
`iso8601`: A string representing a date and time. This string is parsed using JavaScript's `Date.parse()` method.
|
||||
|
||||
### Return Value
|
||||
|
||||
The number of seconds since the Ripple Epoch.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
api.iso8601ToRippleTime('2017-02-17T15:04:57Z');
|
||||
```
|
||||
|
||||
```json
|
||||
540659097
|
||||
```
|
||||
@@ -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;
|
||||
@@ -23,4 +23,5 @@ Methods that depend on the state of the XRP Ledger are unavailable in offline mo
|
||||
* [prepareEscrowExecution](#prepareescrowexecution)
|
||||
* [sign](#sign)
|
||||
* [generateAddress](#generateaddress)
|
||||
* [generateXAddress](#generatexaddress)
|
||||
* [computeLedgerHash](#computeledgerhash)
|
||||
|
||||
35
docs/src/parseAccountFlags.md.ejs
Normal file
35
docs/src/parseAccountFlags.md.ejs
Normal file
@@ -0,0 +1,35 @@
|
||||
## parseAccountFlags
|
||||
|
||||
`parseAccountFlags(Flags: number): object`
|
||||
|
||||
Parse an `AccountRoot` object's [`Flags`](https://xrpl.org/accountroot.html#accountroot-flags).
|
||||
|
||||
### Parameters
|
||||
|
||||
This method takes one parameter, the AccountRoot `Flags` number to parse. Note that flags have different mappings on other types of objects or in transactions such as AccountSet.
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns an object with containing a key for each AccountRoot flag known to this version of RippleAPI. Each flag has a boolean value of `true` or `false`.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
const account_info = await api.request('account_info', {account: 'rKsdkGhyZH6b2Zzd5hNnEqSv2wpznn4n6N'})
|
||||
const flags = api.parseAccountFlags(account_info.account_data.Flags)
|
||||
console.log(JSON.stringify(flags, null, 2))
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"passwordSpent": false,
|
||||
"requireDestinationTag": false,
|
||||
"requireAuthorization": false,
|
||||
"depositAuth": true,
|
||||
"disallowIncomingXRP": false,
|
||||
"disableMasterKey": false,
|
||||
"noFreeze": false,
|
||||
"globalFreeze": false,
|
||||
"defaultRipple": false
|
||||
}
|
||||
```
|
||||
@@ -1,8 +1,8 @@
|
||||
## prepareCheckCancel
|
||||
|
||||
`prepareCheckCancel(address: string, checkCancel: Object, instructions: Object): Promise<Object>`
|
||||
`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
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## prepareCheckCash
|
||||
|
||||
`prepareCheckCash(address: string, checkCash: Object, instructions: Object): Promise<Object>`
|
||||
`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
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## prepareCheckCreate
|
||||
|
||||
`prepareCheckCreate(address: string, checkCreate: Object, instructions: Object): Promise<Object>`
|
||||
`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
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## prepareEscrowCancellation
|
||||
|
||||
`prepareEscrowCancellation(address: string, escrowCancellation: Object, instructions: Object): Promise<Object>`
|
||||
`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
|
||||
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
## prepareEscrowCreation
|
||||
|
||||
`prepareEscrowCreation(address: string, escrowCreation: Object, instructions: Object): Promise<Object>`
|
||||
`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
|
||||
|
||||
<%- renderSchema('input/prepare-escrow-creation.json') %>
|
||||
|
||||
This is a convenience method for generating the EscrowCreate JSON used by rippled, so the same restrictions apply.
|
||||
|
||||
Field mapping: `allowCancelAfter` is equivalent to rippled's `CancelAfter`; `allowExecuteAfter` is equivalent to `FinishAfter`. At the `allowCancelAfter` time, the escrow is considered expired. This means that the funds can only be returned to the sender. At the `allowExecuteAfter` time, the escrow is permitted to be released to the recipient (if the `condition` is fulfilled).
|
||||
|
||||
Note that `allowCancelAfter` must be chronologically later than `allowExecuteAfter`.
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns a promise that resolves with an object with the following structure:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## prepareEscrowExecution
|
||||
|
||||
`prepareEscrowExecution(address: string, escrowExecution: Object, instructions: Object): Promise<Object>`
|
||||
`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
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## prepareOrder
|
||||
|
||||
`prepareOrder(address: string, order: Object, instructions: Object): Promise<Object>`
|
||||
`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
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## prepareOrderCancellation
|
||||
|
||||
`prepareOrderCancellation(address: string, orderCancellation: Object, instructions: Object): Promise<Object>`
|
||||
`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
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## preparePayment
|
||||
|
||||
`preparePayment(address: string, payment: Object, instructions: Object): Promise<Object>`
|
||||
`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
|
||||
|
||||
@@ -23,8 +23,11 @@ All "prepare*" methods have the same return type.
|
||||
```javascript
|
||||
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
||||
const payment = <%- importFile('test/fixtures/requests/prepare-payment.json') %>;
|
||||
return api.preparePayment(address, payment).then(prepared =>
|
||||
{/* ... */});
|
||||
return api.preparePayment(address, payment).then(prepared => {
|
||||
/* ... */
|
||||
}).catch(error => {
|
||||
/* ... as with all prepare* methods, use a Promise catch block to handle errors ... */
|
||||
})
|
||||
```
|
||||
|
||||
<%- renderFixture("responses/prepare-payment.json") %>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## preparePaymentChannelClaim
|
||||
|
||||
`preparePaymentChannelClaim(address: string, paymentChannelClaim: Object, instructions: Object): Promise<Object>`
|
||||
`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
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## preparePaymentChannelCreate
|
||||
|
||||
`preparePaymentChannelCreate(address: string, paymentChannelCreate: Object, instructions: Object): Promise<Object>`
|
||||
`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
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## preparePaymentChannelFund
|
||||
|
||||
`preparePaymentChannelFund(address: string, paymentChannelFund: Object, instructions: Object): Promise<Object>`
|
||||
`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
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## prepareSettings
|
||||
|
||||
`prepareSettings(address: string, settings: Object, instructions: Object): Promise<Object>`
|
||||
`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
|
||||
|
||||
|
||||
34
docs/src/prepareTicketCreate.md.ejs
Normal file
34
docs/src/prepareTicketCreate.md.ejs
Normal file
@@ -0,0 +1,34 @@
|
||||
## prepareTicketCreate
|
||||
|
||||
`prepareTicketCreate(address: string, ticketCount: number, instructions: object): Promise<object>`
|
||||
|
||||
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.
|
||||
|
||||
### Parameters
|
||||
|
||||
<%- renderSchema("input/prepare-ticket-create.json") %>
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns a promise that resolves with an object with the following structure:
|
||||
|
||||
<aside class="notice">
|
||||
All "prepare*" methods have the same return type.
|
||||
</aside>
|
||||
|
||||
<%- renderSchema("output/prepare.json") %>
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
||||
return api.prepareTicketCreate(address, 2).then(prepared => {
|
||||
/* ... */
|
||||
}).catch(error => {
|
||||
/* ... as with all prepare* methods, use a Promise catch block to handle errors ... */
|
||||
})
|
||||
```
|
||||
|
||||
<%- renderFixture("responses/prepare-ticket-create.json") %>
|
||||
50
docs/src/prepareTransaction.md.ejs
Normal file
50
docs/src/prepareTransaction.md.ejs
Normal file
@@ -0,0 +1,50 @@
|
||||
## prepareTransaction
|
||||
|
||||
`prepareTransaction(transaction: object, instructions: object): Promise<object>`
|
||||
|
||||
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://xrpl.org/transaction-types.html).
|
||||
|
||||
Notably, this is the preferred method for preparing `DepositPreauth` or `AccountDelete` transactions.
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description
|
||||
---- | ---- | -----------
|
||||
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
|
||||
|
||||
This method returns a promise that resolves with an object with the following structure:
|
||||
|
||||
<aside class="notice">
|
||||
All "prepare*" methods have the same return type.
|
||||
</aside>
|
||||
|
||||
<%- renderSchema("output/prepare.json") %>
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
async function preparedPreauth() {
|
||||
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
||||
return api.prepareTransaction({
|
||||
TransactionType: 'DepositPreauth',
|
||||
Account: address,
|
||||
Authorize: 'rMyVso4p83khNyHdV1m1PggV9QNadCj8wM'
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
```javascript
|
||||
{
|
||||
txJSON: '{"TransactionType":"DepositPreauth","Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","Authorize":"rMyVso4p83khNyHdV1m1PggV9QNadCj8wM","Flags":2147483648,"LastLedgerSequence":13561714,"Fee":"12","Sequence":1}',
|
||||
instructions: {
|
||||
fee: '0.000012',
|
||||
sequence: 1,
|
||||
maxLedgerVersion: 13561714
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,8 +1,8 @@
|
||||
## prepareTrustline
|
||||
|
||||
`prepareTrustline(address: string, trustline: Object, instructions: Object): Promise<Object>`
|
||||
`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
|
||||
|
||||
|
||||
37
docs/src/renameCounterpartyToIssuer.md.ejs
Normal file
37
docs/src/renameCounterpartyToIssuer.md.ejs
Normal file
@@ -0,0 +1,37 @@
|
||||
## renameCounterpartyToIssuer
|
||||
|
||||
`renameCounterpartyToIssuer(issue: {currency: string, counterparty: address}): {currency: string, issuer: address}`
|
||||
|
||||
Returns an object with the `counterparty` field renamed to `issuer`. This is useful because RippleAPI generally uses the name `counterparty` while the rippled API generally uses the name `issuer`.
|
||||
|
||||
This is a static method on the `RippleAPI` class.
|
||||
|
||||
### Parameters
|
||||
|
||||
This method takes one parameter, an object with a `counterparty` field.
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns a new object based on the source object, but with `issuer` instead of `counterparty`.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
const orderbookInfo = {
|
||||
"base": {
|
||||
"currency": "USD",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
},
|
||||
"counter": {
|
||||
"currency": "BTC",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
}
|
||||
};
|
||||
console.log(RippleAPI.renameCounterpartyToIssuer(orderbookInfo.base))
|
||||
console.log(RippleAPI.renameCounterpartyToIssuer(orderbookInfo.counter))
|
||||
```
|
||||
|
||||
```
|
||||
{ currency: 'USD', issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B' }
|
||||
{ currency: 'BTC', issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B' }
|
||||
```
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
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://ripple.com/build/rippled-apis/#specifying-ledgers).
|
||||
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).
|
||||
|
||||
### Return Value
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
27
docs/src/rippleTimeToISO8601.md.ejs
Normal file
27
docs/src/rippleTimeToISO8601.md.ejs
Normal file
@@ -0,0 +1,27 @@
|
||||
## rippleTimeToISO8601
|
||||
|
||||
`rippleTimeToISO8601(rippleTime: number): string`
|
||||
|
||||
This method takes the number of seconds since the "Ripple Epoch" of January 1, 2000 (00:00 UTC) and returns a string representation of a date.
|
||||
|
||||
The Ripple Epoch is 946684800 seconds after the Unix Epoch.
|
||||
|
||||
This method is useful for interpreting timestamps returned by the rippled APIs. The rippled APIs represent time as an unsigned integer of the number of seconds since the Ripple Epoch.
|
||||
|
||||
### Parameters
|
||||
|
||||
`rippleTime`: A number of seconds since the Ripple Epoch.
|
||||
|
||||
### Return Value
|
||||
|
||||
A string representing a date and time, created by calling a `Date` object's `toISOString()` method.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
api.rippleTimeToISO8601(540659097);
|
||||
```
|
||||
|
||||
```json
|
||||
'2017-02-17T15:04:57.000Z'
|
||||
```
|
||||
@@ -1,15 +1,21 @@
|
||||
# rippled APIs
|
||||
|
||||
ripple-lib relies on [rippled APIs](https://ripple.com/build/rippled-apis/) for all online functionality. With ripple-lib version 1.0.0 and higher, you can easily access rippled APIs through ripple-lib. 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).
|
||||
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://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://ripple.com/build/rippled-apis/#specifying-currency-amounts). 1 XRP = 1000000 drops.
|
||||
When using rippled APIs:
|
||||
|
||||
* [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
|
||||
|
||||
The `rippled` server can push updates to your client when various events happen. Refer to [Subscriptions in the `rippled` API docs](https://ripple.com/build/rippled-apis/#subscriptions) for details.
|
||||
The `rippled` server can push updates to your client when various events happen.
|
||||
Refer to [Subscriptions in the `rippled` API docs](https://xrpl.org/subscribe.html) for details.
|
||||
|
||||
Note that the `streams` parameter for generic streams takes an array. For example, to subscribe to the `validations` stream, use `{ streams: [ 'validations' ] }`.
|
||||
|
||||
@@ -32,15 +38,16 @@ Type | Description
|
||||
`ledgerClosed` | Sent by the `ledger` stream when the consensus process declares a new fully validated ledger. The message identifies the ledger and provides some information about its contents.
|
||||
`validationReceived` | Sent by the `validations` stream when the server receives a validation message, also called a validation vote, regardless of whether the server trusts the validator.
|
||||
`manifestReceived` | Sent by the `manifests` stream when the server receives a manifest.
|
||||
`transaction` | Sent by many subscriptions including `transactions`, `transactions_proposed`, `accounts`, `accounts_proposed`, and `book` (Order Book). See [Transaction Streams](https://ripple.com/build/rippled-apis/#transaction-streams) for details.
|
||||
`transaction` | Sent by many subscriptions including `transactions`, `transactions_proposed`, `accounts`, `accounts_proposed`, and `book` (Order Book). See [Transaction Streams](https://xrpl.org/subscribe.html#transaction-streams) for details.
|
||||
`peerStatusChange` | (Admin-only) Reports a large amount of information on the activities of other `rippled` servers to which the server is connected.
|
||||
`path_find` | Asynchronous follow-up response to the currently open path\_find request. See [rippled path\_find method](https://xrpl.org/path_find.html) for details.
|
||||
|
||||
To register your listener function, use `connection.on(type, handler)`.
|
||||
|
||||
Here is an example of listening for transactions on given account(s):
|
||||
```
|
||||
const account = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn' // Replace with the account you want notifications for
|
||||
api.connect().then(() => { // Omit this if you are already connected
|
||||
api.connect().then(() => {
|
||||
|
||||
// 'transaction' can be replaced with the relevant `type` from the table above
|
||||
api.connection.on('transaction', (event) => {
|
||||
@@ -52,9 +59,7 @@ api.connect().then(() => { // Omit this if you are already connected
|
||||
api.request('subscribe', {
|
||||
accounts: [ account ]
|
||||
}).then(response => {
|
||||
if (response.status === 'success') {
|
||||
console.log('Successfully subscribed')
|
||||
}
|
||||
console.log('Successfully subscribed')
|
||||
}).catch(error => {
|
||||
// Handle `error`
|
||||
})
|
||||
@@ -63,4 +68,4 @@ api.connect().then(() => { // Omit this if you are already connected
|
||||
|
||||
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).
|
||||
|
||||
35
docs/src/schemaValidator.md.ejs
Normal file
35
docs/src/schemaValidator.md.ejs
Normal file
@@ -0,0 +1,35 @@
|
||||
## schemaValidator
|
||||
|
||||
Unlike the rest of the ripple-lib API, schemaValidator is a static object on RippleAPI. It provides utility methods that do not use a server.
|
||||
|
||||
## schemaValidate
|
||||
|
||||
`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 throws a `ValidationError` if the object does not conform to the schema.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
RippleAPI.schemaValidator.schemaValidate('sign', {
|
||||
signedTransaction: '12000322800000002400000017201B0086955368400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8744630440220680070A157682D9EB510E8AD58C35DC9C8346B155077D73792E88120B7A3B6B1022079537D3300C9B4D2D3D62ACCE1E66CDA893F9612CB2577ADEC8154B933765336770B6578616D706C652E636F6D81145E7B112523F68D2F5E879DB4EAC51C6698A69304',
|
||||
id: '10B54D31384A49336C36A5907E3C28227139E282D3C7F734FEA351DE446F3674'
|
||||
})
|
||||
```
|
||||
|
||||
```json
|
||||
undefined
|
||||
```
|
||||
|
||||
If the object is valid (conforms to the schema), nothing is returned. Otherwise, `schemaValidate` throws an error:
|
||||
|
||||
```javascript
|
||||
RippleAPI.schemaValidator.schemaValidate('sign', {
|
||||
signedTransaction: '12000322800000002400000017201B0086955368400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8744630440220680070A157682D9EB510E8AD58C35DC9C8346B155077D73792E88120B7A3B6B1022079537D3300C9B4D2D3D62ACCE1E66CDA893F9612CB2577ADEC8154B933765336770B6578616D706C652E636F6D81145E7B112523F68D2F5E879DB4EAC51C6698A69304',
|
||||
id: '123'
|
||||
})
|
||||
```
|
||||
|
||||
```
|
||||
[ValidationError(instance.id does not match pattern "^[A-F0-9]{64}$")]
|
||||
```
|
||||
@@ -1,16 +1,22 @@
|
||||
## sign
|
||||
|
||||
```
|
||||
sign(txJSON: string, secret: string, options: Object): {signedTransaction: string, id: string}
|
||||
sign(txJSON: string, keypair: Object, options: Object): {signedTransaction: string, id: string}
|
||||
sign(txJSON: string, secret: string, options: object): {signedTransaction: string, id: string}
|
||||
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 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`
|
||||
|
||||
### Parameters
|
||||
|
||||
<%- renderSchema("input/sign.json") %>
|
||||
|
||||
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
|
||||
|
||||
This method returns an object with the following structure:
|
||||
@@ -20,10 +26,116 @@ 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);
|
||||
```
|
||||
|
||||
<%- renderFixture("responses/sign.json") %>
|
||||
|
||||
### 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;
|
||||
|
||||
// jon's address will have a multi-signing setup with a quorum of 2
|
||||
const jon = {
|
||||
account: 'rJKpme4m2zBQceBuU89d7vLMzgoUw2Ptj',
|
||||
secret: 'sh4Va7b1wQof8knHFV2sxwX12fSgK'
|
||||
};
|
||||
const aya = {
|
||||
account: 'rnrPdBjs98fFFfmRpL6hM7exT788SWQPFN',
|
||||
secret: 'snaMuMrXeVc2Vd4NYvHofeGNjgYoe'
|
||||
};
|
||||
const bran = {
|
||||
account: 'rJ93RLnT1t5A8fCr7HTScw7WtfKJMRXodH',
|
||||
secret: 'shQtQ8Um5MS218yvEU3Ehy1eZQKqH'
|
||||
};
|
||||
|
||||
// Setup the signers list with a quorum of 2
|
||||
const multiSignSetupTransaction = {
|
||||
"Flags": 0,
|
||||
"TransactionType": "SignerListSet",
|
||||
"Account": "rJKpme4m2zBQceBuU89d7vLMzgoUw2Ptj",
|
||||
"Fee": "120",
|
||||
"SignerQuorum": 2,
|
||||
"SignerEntries": [
|
||||
{
|
||||
"SignerEntry": {
|
||||
"Account": "rnrPdBjs98fFFfmRpL6hM7exT788SWQPFN",
|
||||
"SignerWeight": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"SignerEntry": {
|
||||
"Account": "rJ93RLnT1t5A8fCr7HTScw7WtfKJMRXodH",
|
||||
"SignerWeight": 1
|
||||
}
|
||||
},
|
||||
]
|
||||
};
|
||||
|
||||
// a transaction which requires multi signing
|
||||
const multiSignPaymentTransaction = {
|
||||
TransactionType: 'Payment',
|
||||
Account: 'rJKpme4m2zBQceBuU89d7vLMzgoUw2Ptj',
|
||||
Destination: 'rJ93RLnT1t5A8fCr7HTScw7WtfKJMRXodH',
|
||||
Amount: '88000000'
|
||||
};
|
||||
|
||||
const multiSignPaymentInstruction = {
|
||||
signersCount: 2
|
||||
};
|
||||
|
||||
const api = new RippleAPI({
|
||||
server: 'wss://s.altnet.rippletest.net:51233'
|
||||
});
|
||||
|
||||
api.connect().then(() => {
|
||||
// adding the multi signing feature to jon's account
|
||||
api.prepareTransaction(multiSignSetupTransaction).then((prepared) => {
|
||||
console.log(prepared);
|
||||
jonSign = api.sign(prepared.txJSON, jon.secret).signedTransaction;
|
||||
api.submit(jonSign).then( response => {
|
||||
console.log(response.resultCode, response.resultMessage);
|
||||
|
||||
// multi sign a transaction
|
||||
api.prepareTransaction(multiSignPaymentTransaction, multiSignPaymentInstruction).then(prepared => {
|
||||
console.log(prepared);
|
||||
|
||||
// Aya and Bran sign it too but with 'signAs' set to their own account
|
||||
let ayaSign = api.sign(prepared.txJSON, aya.secret, {'signAs': aya.account}).signedTransaction;
|
||||
let branSign = api.sign(prepared.txJSON, bran.secret, {'signAs': bran.account}).signedTransaction;
|
||||
|
||||
// signatures are combined and submitted
|
||||
let combinedTx = api.combine([ayaSign, branSign]);
|
||||
api.submit(combinedTx.signedTransaction).then(response => {
|
||||
console.log(response.tx_json.hash);
|
||||
return api.disconnect();
|
||||
}).catch(console.error);
|
||||
}).catch(console.error);
|
||||
}).catch(console.error)
|
||||
}).catch(console.error);
|
||||
}).catch(console.error);
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -1,143 +1,185 @@
|
||||
# Transaction Specifications
|
||||
|
||||
A *transaction specification* specifies what a transaction should do. Each [Transaction Type](#transaction-types) has its own type of specification.
|
||||
A *transaction specification* specifies what a transaction should do. Each [Transaction Type](#transaction-types) has its own type of specification, which corresponds to the [native XRP Ledger transaction types](https://xrpl.org/transaction-types.html).
|
||||
|
||||
## Payment
|
||||
## Account Delete
|
||||
|
||||
See [Transaction Types](#transaction-types) for a description.
|
||||
Delete your account and send the remaining XRP elsewhere. (Native transaction type: [AccountDelete](https://xrpl.org/accountdelete.html))
|
||||
|
||||
<%- renderSchema('specifications/payment.json') %>
|
||||
<%- renderSchema('specifications/account-delete.json') %>
|
||||
|
||||
### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-payment.json') %>
|
||||
|
||||
## Trustline
|
||||
|
||||
See [Transaction Types](#transaction-types) for a description.
|
||||
|
||||
<%- renderSchema('specifications/trustline.json') %>
|
||||
|
||||
### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-trustline.json') %>
|
||||
|
||||
## Order
|
||||
|
||||
See [Transaction Types](#transaction-types) for a description.
|
||||
|
||||
<%- renderSchema('specifications/order.json') %>
|
||||
|
||||
### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-order.json') %>
|
||||
|
||||
## Order Cancellation
|
||||
|
||||
See [Transaction Types](#transaction-types) for a description.
|
||||
|
||||
<%- renderSchema('specifications/order-cancellation.json') %>
|
||||
|
||||
### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-order-cancellation.json') %>
|
||||
|
||||
## Settings
|
||||
|
||||
See [Transaction Types](#transaction-types) for a description.
|
||||
|
||||
<%- renderSchema('output/get-settings.json') %>
|
||||
|
||||
### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-settings.json') %>
|
||||
|
||||
## Escrow Creation
|
||||
|
||||
See [Transaction Types](#transaction-types) for a description.
|
||||
|
||||
<%- renderSchema('specifications/escrow-creation.json') %>
|
||||
|
||||
### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-escrow-creation.json') %>
|
||||
|
||||
## Escrow Cancellation
|
||||
|
||||
See [Transaction Types](#transaction-types) for a description.
|
||||
|
||||
<%- renderSchema('specifications/escrow-cancellation.json') %>
|
||||
|
||||
### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-escrow-cancellation.json') %>
|
||||
|
||||
## Escrow Execution
|
||||
|
||||
See [Transaction Types](#transaction-types) for a description.
|
||||
|
||||
<%- renderSchema('specifications/escrow-execution.json') %>
|
||||
|
||||
### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-escrow-execution.json') %>
|
||||
|
||||
## Check Create
|
||||
|
||||
See [Transaction Types](#transaction-types) for a description.
|
||||
|
||||
<%- renderSchema('specifications/check-create.json') %>
|
||||
|
||||
### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-check-create.json') %>
|
||||
> **Note:** To prepare an Account Delete transaction, use [`prepareTransaction()`](#preparetransaction) with the [native transaction format](https://xrpl.org/accountdelete.html).
|
||||
|
||||
## Check Cancel
|
||||
|
||||
See [Transaction Types](#transaction-types) for a description.
|
||||
Cancel a Check that has not been redeemed. (Native transaction type: [CheckCancel](https://xrpl.org/checkcancel.html))
|
||||
|
||||
<%- renderSchema('specifications/check-cancel.json') %>
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-check-cancel.json') %>
|
||||
|
||||
|
||||
## Check Cash
|
||||
|
||||
See [Transaction Types](#transaction-types) for a description.
|
||||
Redeem a Check for up to its stated value. (Native transaction type: [CheckCash](https://xrpl.org/checkcash.html))
|
||||
|
||||
<%- renderSchema('specifications/check-cash.json') %>
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-check-cash-amount.json') %>
|
||||
|
||||
## Payment Channel Create
|
||||
|
||||
See [Transaction Types](#transaction-types) for a description.
|
||||
## Check Create
|
||||
|
||||
<%- renderSchema('specifications/payment-channel-create.json') %>
|
||||
Create a Check, a deferred payment that can be redeemed by the destination. (Native transaction type: [CheckCreate](https://xrpl.org/checkcreate.html))
|
||||
|
||||
### Example
|
||||
<%- renderSchema('specifications/check-create.json') %>
|
||||
|
||||
<%- renderFixture('requests/prepare-payment-channel-create.json') %>
|
||||
#### Example
|
||||
|
||||
## Payment Channel Fund
|
||||
<%- renderFixture('requests/prepare-check-create.json') %>
|
||||
|
||||
See [Transaction Types](#transaction-types) for a description.
|
||||
|
||||
<%- renderSchema('specifications/payment-channel-fund.json') %>
|
||||
## Deposit Preauth
|
||||
|
||||
### Example
|
||||
Preauthorize an sender to deposit money at an account using [Deposit Authorization](https://xrpl.org/depositauth.html). (Native transaction type: [DepositPreauth](https://xrpl.org/depositpreauth.html))
|
||||
|
||||
<%- renderSchema('specifications/deposit-preauth.json') %>
|
||||
|
||||
> **Note:** To prepare a Deposit Preauth transaction, use [`prepareTransaction()`](#preparetransaction) with the [native transaction format](https://xrpl.org/depositpreauth.html).
|
||||
|
||||
|
||||
## Escrow Cancellation
|
||||
|
||||
Cancel an Escrow that has passed its expiration. (Native transaction type: [EscrowCancel](https://xrpl.org/escrowcancel.html))
|
||||
|
||||
<%- renderSchema('specifications/escrow-cancellation.json') %>
|
||||
|
||||
#### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-escrow-cancellation.json') %>
|
||||
|
||||
|
||||
## Escrow Creation
|
||||
|
||||
Create an Escrow that locks up XRP until a given time or condition is met. (Native transaction type: [EscrowCreate](https://xrpl.org/escrowcreate.html))
|
||||
|
||||
<%- renderSchema('specifications/escrow-creation.json') %>
|
||||
|
||||
#### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-escrow-creation.json') %>
|
||||
|
||||
|
||||
## Escrow Execution
|
||||
|
||||
Deliver XRP from an Escrow after its conditions have been met. (Native transaction type: [EscrowFinish](https://xrpl.org/escrowfinish.html))
|
||||
|
||||
<%- renderSchema('specifications/escrow-execution.json') %>
|
||||
|
||||
#### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-escrow-execution.json') %>
|
||||
|
||||
|
||||
## Order
|
||||
|
||||
Create and execute a limit order in the decentralized exchange. (Native transaction type: [OfferCreate](https://xrpl.org/offercreate.html))
|
||||
|
||||
<%- renderSchema('specifications/order.json') %>
|
||||
|
||||
The following invalid flag combination causes a `ValidationError`: `immediateOrCancel` and `fillOrKill`. These fields are mutually exclusive, and cannot both be set at the same time.
|
||||
|
||||
#### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-order.json') %>
|
||||
|
||||
|
||||
## Order Cancellation
|
||||
|
||||
Cancel an order in the decentralized exchange. (Native transaction type: [OfferCancel](https://xrpl.org/offercancel.html))
|
||||
|
||||
<%- renderSchema('specifications/order-cancellation.json') %>
|
||||
|
||||
#### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-order-cancellation.json') %>
|
||||
|
||||
|
||||
## Payment
|
||||
|
||||
Send value from one account to another. (Native transaction type: [Payment](https://xrpl.org/payment.html))
|
||||
|
||||
<%- renderSchema('specifications/payment.json') %>
|
||||
|
||||
#### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-payment.json') %>
|
||||
|
||||
<%- renderFixture('requests/prepare-payment-channel-fund.json') %>
|
||||
|
||||
## Payment Channel Claim
|
||||
|
||||
See [Transaction Types](#transaction-types) for a description.
|
||||
Redeem XRP from a Payment Channel. (Native transaction type: [PaymentChannelClaim](https://xrpl.org/paymentchannelclaim.html))
|
||||
|
||||
<%- renderSchema('specifications/payment-channel-claim.json') %>
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-payment-channel-claim.json') %>
|
||||
|
||||
|
||||
## Payment Channel Create
|
||||
|
||||
Create a Payment Channel with XRP set aside for asynchronous payments. (Native transaction type: [PaymentChannelCreate](https://xrpl.org/paymentchannelcreate.html))
|
||||
|
||||
<%- renderSchema('specifications/payment-channel-create.json') %>
|
||||
|
||||
#### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-payment-channel-create.json') %>
|
||||
|
||||
|
||||
## Payment Channel Fund
|
||||
|
||||
Add XRP to a Payment Channel. (Native transaction type: [PaymentChannelFund](https://xrpl.org/paymentchannelfund.html))
|
||||
|
||||
<%- renderSchema('specifications/payment-channel-fund.json') %>
|
||||
|
||||
#### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-payment-channel-fund.json') %>
|
||||
|
||||
|
||||
|
||||
## Settings
|
||||
|
||||
Change account settings. (Native transaction types: [AccountSet](https://xrpl.org/accountset.html), [SetRegularKey](https://xrpl.org/setregularkey.html), [SignerListSet](https://xrpl.org/signerlistset.html))
|
||||
|
||||
<%- renderSchema('output/get-settings.json') %>
|
||||
|
||||
#### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-settings.json') %>
|
||||
|
||||
|
||||
## Ticket Create
|
||||
|
||||
Set aside account Sequence numbers as Tickets to be used by later transactions.
|
||||
|
||||
> **Caution:** As of 2021-01-22, Tickets are not yet available on the XRP Ledger.
|
||||
|
||||
> **Note:** To prepare a Ticket Create transaction, use [`prepareTransaction()`](#preparetransaction) with the native transaction format. <!-- Future link: https://xrpl.org/ticketcreate.html -->
|
||||
|
||||
|
||||
## Trustline
|
||||
|
||||
Create or modify a trust line between two accounts, for an issued currency. (Native transaction type: [TrustSet](https://xrpl.org/trustset.html))
|
||||
|
||||
<%- renderSchema('specifications/trustline.json') %>
|
||||
|
||||
#### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-trustline.json') %>
|
||||
|
||||
100
docs/src/staticMethods.md.ejs
Normal file
100
docs/src/staticMethods.md.ejs
Normal file
@@ -0,0 +1,100 @@
|
||||
# Static Methods
|
||||
|
||||
You can access static methods directly on the `RippleAPI` class. For example, `RippleAPI.computeBinaryTransactionHash(...)`.
|
||||
|
||||
A few of the most commonly-used methods are documented below.
|
||||
|
||||
For a full list, refer to these docs:
|
||||
|
||||
- [XRP Ledger Hashes](https://github.com/ripple/ripple-lib/blob/develop/src/common/hashes/README.md)
|
||||
- [ripple-address-codec API](https://github.com/ripple/ripple-address-codec/blob/master/README.md#api)
|
||||
|
||||
## computeBinaryTransactionHash
|
||||
|
||||
`computeBinaryTransactionHash(txBlobHex: string): string`
|
||||
|
||||
Returns the hash (id) of a binary transaction blob.
|
||||
|
||||
This is a static method on the `RippleAPI` class.
|
||||
|
||||
### Parameters
|
||||
|
||||
This method takes one parameter, a string containing a binary transaction in hex.
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns a string representing the transaction's id (hash).
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
const signed_blob = '120000228000000024000B2E5A201B0066374B61400000003B9ACA0068400000000000000C732102356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC74473045022100B3721EEB1ED6DFF29FB8B209E2DE6B54A0A6E44D52D926342F3D334BE98F08640220367A74107AD5DEAEFA3AB2984C161FC23F30B2704BB5CC984358BA262177A4568114F667B0CA50CC7709A220B0561B85E53A48461FA883142B71D8B09B4EE8DAA68FB936C23E3A974713BDAC'
|
||||
if (typeof signed_blob === 'string' && signed_blob.match(/^[A-F0-9]+$/)) {
|
||||
const id = RippleAPI.computeBinaryTransactionHash(signed_blob)
|
||||
console.log('Transaction hash:', id')
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
Transaction hash: 80C5E11E1A21A626759D6CB944B33DBAAC66BD704A289C86E330B847904F5C13
|
||||
```
|
||||
|
||||
[RunKit Example: computeBinaryTransactionHash](https://runkit.com/intelliot/computebinarytransactionhash-example)
|
||||
|
||||
## classicAddressToXAddress
|
||||
|
||||
`classicAddressToXAddress(classicAddress: string, tag: number | false[, test: boolean]): string`
|
||||
|
||||
Convert a classic address and tag to an X-address.
|
||||
|
||||
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
|
||||
|
||||
```javascript
|
||||
const RippleAPI = require('ripple-lib').RippleAPI
|
||||
const xAddress = RippleAPI.classicAddressToXAddress('rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf', 4294967295)
|
||||
console.log(xAddress)
|
||||
```
|
||||
|
||||
```
|
||||
XVLhHMPHU98es4dbozjVtdWzVrDjtV18pX8yuPT7y4xaEHi
|
||||
```
|
||||
|
||||
### Example: Encode a test address for use with Testnet or Devnet
|
||||
|
||||
```javascript
|
||||
const RippleAPI = require('ripple-lib').RippleAPI
|
||||
const address = RippleAPI.classicAddressToXAddress('r3SVzk8ApofDJuVBPKdmbbLjWGCCXpBQ2g', 123, true)
|
||||
console.log(address)
|
||||
```
|
||||
|
||||
```
|
||||
T7oKJ3q7s94kDH6tpkBowhetT1JKfcfdSCmAXbS75iATyLD
|
||||
```
|
||||
|
||||
## xAddressToClassicAddress
|
||||
|
||||
`xAddressToClassicAddress(xAddress: string): {classicAddress: string, tag: number | false, test: boolean}`
|
||||
|
||||
Convert an X-address to a classic address and tag.
|
||||
|
||||
Since `0` is a valid tag, use `if (tag !== false)` to you want to check for a tag.
|
||||
|
||||
If the address is intended for use on a test network, `test === true`. Otherwise, `test === false`.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
const RippleAPI = require('ripple-lib').RippleAPI
|
||||
const address = RippleAPI.xAddressToClassicAddress('XVLhHMPHU98es4dbozjVtdWzVrDjtV18pX8yuPT7y4xaEHi')
|
||||
console.log(address)
|
||||
```
|
||||
|
||||
```
|
||||
{
|
||||
classicAddress: 'rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf',
|
||||
tag: 4294967295,
|
||||
test: false
|
||||
}
|
||||
```
|
||||
@@ -1,25 +1,83 @@
|
||||
## submit
|
||||
|
||||
`submit(signedTransaction: string): Promise<Object>`
|
||||
`request('submit', {tx_blob: string, fail_hard: boolean}): Promise<object>`
|
||||
|
||||
Submits a signed transaction. The transaction is not guaranteed to succeed; it must be verified with [getTransaction](#gettransaction).
|
||||
The `submit` method applies a transaction and sends it to the network to be confirmed and included in future ledgers.
|
||||
|
||||
This method takes a signed, serialized transaction as a binary blob, and submits it to the network as-is. Since signed transaction objects are immutable, no part of the transaction can be modified or automatically filled in after submission.
|
||||
|
||||
To send a transaction as robustly as possible, you should construct and sign it in advance, persist it somewhere that you can access even after a power outage, then `submit` it as a `tx_blob`. After submission, monitor the network with the `tx` method to see if the transaction was successfully applied; if a restart or other problem occurs, you can safely re-submit the `tx_blob` transaction: it won't be applied twice since it has the same sequence number as the old transaction.
|
||||
|
||||
### Parameters
|
||||
|
||||
<%- renderSchema('input/submit.json') %>
|
||||
| `Field` | Type | Description |
|
||||
|:------------|:--------|:-----------------------------------------------------|
|
||||
| `tx_blob` | String | Hex representation of the signed transaction to submit. This can be a multi-signed transaction. |
|
||||
| `fail_hard` | Boolean | (Optional, defaults to false) If true, and the transaction fails locally, do not retry or relay the transaction to other servers |
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns an object with the following structure:
|
||||
When successful, this method returns an object containing the following fields:
|
||||
|
||||
<%- renderSchema('output/submit.json') %>
|
||||
| `Field` | Type | Description |
|
||||
|:------------------------|:--------|:-----------------------------------------|
|
||||
| `engine_result` | String | Text [result code](https://xrpl.org/transaction-results.html) indicating the preliminary result of the transaction, for example `tesSUCCESS` |
|
||||
| `engine_result_code` | Integer | Numeric version of the [result code](https://xrpl.org/transaction-results.html). **Not recommended.** |
|
||||
| `engine_result_message` | String | Human-readable explanation of the transaction's preliminary result |
|
||||
| `tx_blob` | String | The complete transaction in hex string format |
|
||||
| `tx_json` | Object | The complete transaction in JSON format |
|
||||
| `accepted` | Boolean | The value `true` indicates that the transaction was applied, queued, broadcast, or kept for later. The value `false` indicates that none of those happened, so the transaction cannot possibly succeed as long as you do not submit it again and have not already submitted it another time. [New in: rippled 1.5.0] |
|
||||
| `account_sequence_available` | Number | The next [Sequence Number](https://xrpl.org/basic-data-types.html#account-sequence) available for the sending account after all pending and [queued](https://xrpl.org/transaction-queue.html) transactions. [New in: rippled 1.5.0] |
|
||||
| `account_sequence_next` | number | The next [Sequence Number](https://xrpl.org/basic-data-types.html#account-sequence) for the sending account after all transactions that have been provisionally applied, but not transactions in the [queue](https://xrpl.org/transaction-queue.html). [New in: rippled 1.5.0] |
|
||||
| `applied` | Boolean | The value `true` indicates that this transaction was applied to the open ledger. In this case, the transaction is likely, but not guaranteed, to be validated in the next ledger version. [New in: rippled 1.5.0] |
|
||||
| `broadcast` | Boolean | The value `true` indicates this transaction was broadcast to peer servers in the peer-to-peer XRP Ledger network. (Note: if the server has no peers, such as in [stand-alone mode](https://xrpl.org/rippled-server-modes.html#reasons-to-run-a-rippled-server-in-stand-alone-mode), the server uses the value `true` for cases where it _would_ have broadcast the transaction.) The value `false` indicates the transaction was not broadcast to any other servers. [New in: rippled 1.5.0] |
|
||||
| `kept` | Boolean | The value `true` indicates that the transaction was kept to be retried later. [New in: rippled 1.5.0] |
|
||||
| `queued` | Boolean | The value `true` indicates the transaction was put in the [Transaction Queue](https://xrpl.org/transaction-queue.html), which means it is likely to be included in a future ledger version. [New in: rippled 1.5.0] |
|
||||
| `open_ledger_cost` | String | The current [open ledger cost](https://xrpl.org/transaction-cost.html#open-ledger-cost) before processing this transaction. Transactions with a lower cost are likely to be [queued](https://xrpl.org/transaction-queue.html). [New in: rippled 1.5.0] |
|
||||
| `validated_ledger_index` | Integer | The [ledger index](https://xrpl.org/basic-data-types.html#ledger-index) of the newest validated ledger at the time of submission. This provides a lower bound on the ledger versions that the transaction can appear in as a result of this request. (The transaction could only have been validated in this ledger version or earlier if it had already been submitted before.) |
|
||||
|
||||
Note: Many situations can prevent a transaction from processing successfully, such as a lack of trust lines connecting the two accounts in a payment, or changes in the state of the ledger since the time the transaction was constructed. Even if nothing is wrong, it may take several seconds to close and validate the ledger version that includes the transaction. Do not consider the transaction's results final until they appear in a validated ledger version.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
const signedTransaction = '12000322800000002400000017201B0086955368400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D874473045022100BDE09A1F6670403F341C21A77CF35BA47E45CDE974096E1AA5FC39811D8269E702203D60291B9A27F1DCABA9CF5DED307B4F23223E0B6F156991DB601DFB9C41CE1C770A726970706C652E636F6D81145E7B112523F68D2F5E879DB4EAC51C6698A69304';
|
||||
return api.submit(signedTransaction)
|
||||
.then(result => {/* ... */});
|
||||
const signedTransaction = '12000022800000002400000007201B007008BC61400000000754D4C068400000000000000C732103E8110048477E60F292DEDA67CF518511E70A15E1E3771B3C024026E1F824832874473045022100D659C836C24FF346A87054E463078D805B19EFE9F10348FD4C6ED6C3F3C4D750022060BE0BFD5E2C4963A1B0E0F21D5BA800969863BA486F71E75C08D76D77C45B22811492F80A3F3849DBB5714A4F2C691CE7D47BEED58083141266204CFBC657E65D9B4D30301FF98644693935';
|
||||
const failHard = false;
|
||||
const result = await api.request('submit', {
|
||||
tx_blob: signedTransaction,
|
||||
fail_hard: failHard // optional
|
||||
});
|
||||
```
|
||||
|
||||
<%- renderFixture('responses/submit.json') %>
|
||||
```json
|
||||
{
|
||||
"accepted": true,
|
||||
"account_sequence_available": 8,
|
||||
"account_sequence_next": 8,
|
||||
"applied": true,
|
||||
"broadcast": true,
|
||||
"engine_result": "tesSUCCESS",
|
||||
"engine_result_code": 0,
|
||||
"engine_result_message": "The transaction was applied. Only final in a validated ledger.",
|
||||
"kept": true,
|
||||
"open_ledger_cost": "10",
|
||||
"queued": false,
|
||||
"tx_blob": "12000022800000002400000007201B007008BC61400000000754D4C068400000000000000C732103E8110048477E60F292DEDA67CF518511E70A15E1E3771B3C024026E1F824832874473045022100D659C836C24FF346A87054E463078D805B19EFE9F10348FD4C6ED6C3F3C4D750022060BE0BFD5E2C4963A1B0E0F21D5BA800969863BA486F71E75C08D76D77C45B22811492F80A3F3849DBB5714A4F2C691CE7D47BEED58083141266204CFBC657E65D9B4D30301FF98644693935",
|
||||
"tx_json": {
|
||||
"Account": "rNQao3Z1irwRjKWSs8heL4a8WKLPKfLrXs",
|
||||
"Amount": "123000000",
|
||||
"Destination": "rpgHWJdXkSvvzikdJCpuMzU7zWnuqsJRCZ",
|
||||
"Fee": "12",
|
||||
"Flags": 2147483648,
|
||||
"LastLedgerSequence": 7342268,
|
||||
"Sequence": 7,
|
||||
"SigningPubKey": "03E8110048477E60F292DEDA67CF518511E70A15E1E3771B3C024026E1F8248328",
|
||||
"TransactionType": "Payment",
|
||||
"TxnSignature": "3045022100D659C836C24FF346A87054E463078D805B19EFE9F10348FD4C6ED6C3F3C4D750022060BE0BFD5E2C4963A1B0E0F21D5BA800969863BA486F71E75C08D76D77C45B22",
|
||||
"hash": "FE8D68D7FF5805EB07AF15A1ADF07FB5463CCD2C6C0A15981EB3D26A02E1551C"
|
||||
},
|
||||
"validated_ledger_index": 7341775
|
||||
}
|
||||
```
|
||||
|
||||
(In ripple-lib 1.8.0, [the old `submit` method](https://github.com/ripple/ripple-lib/blob/1.7.0/docs/index.md#submit) was deprecated.)
|
||||
|
||||
@@ -6,20 +6,21 @@ 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` transactions creates or modifies a trust line between two accounts.
|
||||
[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 unreedemed Check, removing it from the ledger without sending any money.
|
||||
[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.
|
||||
[paymentChannelCreate](#payment-channel-create) | A `paymentChannelCreate` transaction opens a payment channel between two addresses with XRP set aside for asynchronous payments.
|
||||
[paymentChannelFund](#payment-channel-fund) | A `paymentChannelFund` transaction adds XRP to a payment channel and optionally sets a new expiration for the channel.
|
||||
[paymentChannelClaim](#payment-channel-claim) | A `paymentChannelClaim` transaction withdraws XRP from a channel and optionally requests to close it.
|
||||
[ticketCreate](#ticket-create) | A successful `ticketCreate` transaction adds a Ticket in the directory of the owning account.
|
||||
|
||||
## Transaction Flow
|
||||
|
||||
@@ -37,23 +38,26 @@ Executing a transaction with `RippleAPI` requires the following four steps:
|
||||
* [prepareCheckCreate](#preparecheckcreate)
|
||||
* [prepareCheckCancel](#preparecheckcancel)
|
||||
* [prepareCheckCash](#preparecheckcash)
|
||||
* [prepareTicketCreate](#prepareticketcreate)
|
||||
2. [Sign](#sign) - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place. For multisignature transactions, the `signedTransaction` fields returned by `sign` must be collected and passed to the [combine](#combine) method.
|
||||
3. [Submit](#submit) - Submit the transaction to the connected server.
|
||||
4. Verify - Verify that the transaction got validated by querying with [getTransaction](#gettransaction). This is necessary because transactions may fail even if they were successfully submitted.
|
||||
|
||||
## Transaction Fees
|
||||
|
||||
Every transaction must destroy a small amount of XRP as a cost to send the transaction. This is also called a *transaction fee*. The transaction cost is designed to increase along with the load on the XRP Ledger, making it very expensive to deliberately or inadvertently overload the peer-to-peer network that powers the XRP Ledger.
|
||||
Every transaction must destroy a small amount of XRP as a cost to apply the transaction to the ledger. This is also called a *transaction fee*. The transaction cost is designed to increase along with the load on the XRP Ledger, making it very expensive to deliberately or inadvertently overload the peer-to-peer network that powers the XRP Ledger.
|
||||
|
||||
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` is 20 drops × (1 + 2 Signatures) = 60 drops. See [Transaction Cost](https://xrpl.org/transaction-cost.html).
|
||||
|
||||
## Transaction Instructions
|
||||
|
||||
Transaction instructions indicate how to execute a transaction, complementary with the [transaction specification](#transaction-specifications).
|
||||
|
||||
<%- renderSchema("objects/instructions.json") %>
|
||||
|
||||
We recommend that you specify a `maxLedgerVersion` so that you can quickly determine that a failed transaction will never succeeed 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
|
||||
|
||||
|
||||
81
docs/src/txFlags.md.ejs
Normal file
81
docs/src/txFlags.md.ejs
Normal file
@@ -0,0 +1,81 @@
|
||||
## txFlags
|
||||
|
||||
`txFlags.TRANSACTION_TYPE.FLAG`
|
||||
|
||||
This object provides constants for use when creating or interpreting transaction flags. Most transactions have a set of bit-flags that represent various options that affect how a transaction should behave. These options are represented as binary values that can be combined with bitwise-or operations to encode multiple flags at once.
|
||||
|
||||
Most flags only have meaning for a specific transaction type. The same bitwise value may be reused for flags on different transaction types, so it is important to pay attention to the transaction type when setting and reading flags.
|
||||
|
||||
Bits that are not defined as flags MUST be 0.
|
||||
|
||||
### Global Flag
|
||||
|
||||
Applies globally to all transactions.
|
||||
|
||||
`txFlags.Universal.FullyCanonicalSig`: Require a fully-canonical signature. When preparing transactions, ripple-lib enables this flag for you.
|
||||
|
||||
### Payment Flags
|
||||
|
||||
`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://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://xrpl.org/payment.html#limit-quality) for details.
|
||||
|
||||
### OfferCreate Flags
|
||||
|
||||
`txFlags.OfferCreate.Passive`: If enabled, the offer does not consume offers that exactly match it, and instead becomes an Offer object in the ledger. It still consumes offers that cross it.
|
||||
|
||||
`txFlags.OfferCreate.ImmediateOrCancel`: Treat the offer as an Immediate or Cancel order. If enabled, the offer never becomes a ledger object: it only tries to match existing offers in the ledger.
|
||||
|
||||
`txFlags.OfferCreate.FillOrKill`: Treat the offer as a Fill or Kill order.
|
||||
|
||||
`txFlags.OfferCreate.Sell`: Treat the offer as a Sell order. With `order.direction = 'sell'`, exchange the entire `order.quantity`, even if it means obtaining more than the `order.totalPrice` amount in exchange. If using `prepareOrder`, ripple-lib sets this flag for you.
|
||||
|
||||
### TrustSet Flags
|
||||
|
||||
`txFlags.TrustSet.SetAuth`: Authorize the other party to hold issuances from this account. (No effect unless using the AccountSet.RequireAuth flag.) Cannot be unset.
|
||||
|
||||
`txFlags.TrustSet.NoRipple`: Obsolete.
|
||||
|
||||
`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://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.
|
||||
|
||||
`txFlags.TrustSet.ClearFreeze`: Unfreeze the trustline.
|
||||
|
||||
### AccountSet Flags
|
||||
|
||||
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://xrpl.org/accountset.html#accountset-flags).
|
||||
|
||||
The AccountSet transaction type has some transaction flags, but their use is discouraged.
|
||||
|
||||
* `txFlags.AccountSet.RequireDestTag`
|
||||
* `txFlags.AccountSet.OptionalDestTag`
|
||||
* `txFlags.AccountSet.RequireAuth`
|
||||
* `txFlags.AccountSet.OptionalAuth`
|
||||
* `txFlags.AccountSet.DisallowXRP`
|
||||
* `txFlags.AccountSet.AllowXRP`
|
||||
|
||||
### PaymentChannelClaim Flags
|
||||
|
||||
`txFlags.PaymentChannelClaim.Renew`: Clear the channel's Expiration time. (Expiration is different from the channel's immutable CancelAfter time.) Only the source address of the payment channel can use this flag.
|
||||
|
||||
`txFlags.PaymentChannelClaim.Close`: Request to close the channel. Only the channel source and destination addresses can use this flag. This flag closes the channel immediately if it has no more XRP allocated to it after processing the current claim, or if the destination address uses it. If the source address uses this flag when the channel still holds XRP, this schedules the channel to close after SettleDelay seconds have passed. (Specifically, this sets the Expiration of the channel to the close time of the previous ledger plus the channel's SettleDelay time, unless the channel already has an earlier Expiration time.) If the destination address uses this flag when the channel still holds XRP, any XRP that remains after processing the claim is returned to the source address.
|
||||
|
||||
### Other Transaction Types
|
||||
|
||||
The remaining transaction types do not have any flags at this time.
|
||||
|
||||
* OfferCancel
|
||||
* SetRegularKey
|
||||
* SignerListSet
|
||||
* EscrowCreate
|
||||
* EscrowFinish
|
||||
* EscrowCancel
|
||||
* PaymentChannelCreate
|
||||
* PaymentChannelFund
|
||||
47
docs/src/xrpToDropsAndDropsToXrp.md.ejs
Normal file
47
docs/src/xrpToDropsAndDropsToXrp.md.ejs
Normal file
@@ -0,0 +1,47 @@
|
||||
## xrpToDrops
|
||||
|
||||
`xrpToDrops(xrp: string | BigNumber): string`
|
||||
|
||||
Converts an XRP amount to drops. 1 XRP = 1,000,000 drops, so 1 drop = 0.000001 XRP. This method is useful when converting amounts for use with the rippled API, which requires XRP amounts to be specified in drops.
|
||||
|
||||
### Parameters
|
||||
|
||||
`xrp`: A string or BigNumber representing an amount of XRP. If `xrp` is a string, it may start with `-`, must contain at least one number, and may contain up to one `.`. This method throws a `ValidationError` for invalid input.
|
||||
|
||||
### Return Value
|
||||
|
||||
A string representing an equivalent amount of drops.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
return api.xrpToDrops('1');
|
||||
```
|
||||
|
||||
```json
|
||||
'1000000'
|
||||
```
|
||||
|
||||
## dropsToXrp
|
||||
|
||||
`dropsToXrp(drops: string | BigNumber): string`
|
||||
|
||||
Converts an amount of drops to XRP. 1 drop = 0.000001 XRP, so 1 XRP = 1,000,000 drops. This method is useful when converting amounts from the rippled API, which describes XRP amounts in drops.
|
||||
|
||||
### Parameters
|
||||
|
||||
`drops`: A string or BigNumber representing an amount of drops. If `drops` is a string, it may start with `-` and must contain at least one number. This method throws a `ValidationError` for invalid input.
|
||||
|
||||
### Return Value
|
||||
|
||||
A string representing an equivalent amount of XRP.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
return api.dropsToXrp('1');
|
||||
```
|
||||
|
||||
```json
|
||||
'0.000001'
|
||||
```
|
||||
118
package.json
118
package.json
@@ -1,77 +1,92 @@
|
||||
{
|
||||
"name": "ripple-lib",
|
||||
"version": "1.0.0-beta.4",
|
||||
"version": "1.10.0",
|
||||
"license": "ISC",
|
||||
"description": "A JavaScript API for interacting with Ripple in Node.js and the browser",
|
||||
"description": "A TypeScript/JavaScript API for interacting with the XRP Ledger in Node.js and the browser",
|
||||
"files": [
|
||||
"dist/npm/*",
|
||||
"build/*"
|
||||
"build/ripple-latest-min.js",
|
||||
"build/ripple-latest.js"
|
||||
],
|
||||
"main": "dist/npm/",
|
||||
"unpkg": "build/ripple-latest-min.js",
|
||||
"jsdelivr": "build/ripple-latest-min.js",
|
||||
"types": "dist/npm/index.d.ts",
|
||||
"browser": {
|
||||
"ws": "./dist/npm/common/wswrapper.js"
|
||||
"ws": "./dist/npm/common/wswrapper.js",
|
||||
"https-proxy-agent": false
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/lodash": "^4.14.85",
|
||||
"@types/ws": "^3.2.0",
|
||||
"bignumber.js": "^4.1.0",
|
||||
"https-proxy-agent": "2.2.1",
|
||||
"@types/lodash": "^4.14.136",
|
||||
"@types/ws": "^7.2.0",
|
||||
"bignumber.js": "^9.0.0",
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"jsonschema": "1.2.2",
|
||||
"lodash": "^4.17.4",
|
||||
"ripple-address-codec": "^2.0.1",
|
||||
"ripple-binary-codec": "^0.1.13",
|
||||
"ripple-hashes": "^0.3.1",
|
||||
"ripple-keypairs": "^0.10.1",
|
||||
"ripple-lib-transactionparser": "0.7.1",
|
||||
"ws": "^3.3.1"
|
||||
"ripple-address-codec": "^4.1.1",
|
||||
"ripple-binary-codec": "^1.1.3",
|
||||
"ripple-keypairs": "^1.0.3",
|
||||
"ripple-lib-transactionparser": "0.8.2",
|
||||
"ws": "^7.2.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"elliptic": "^6.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^8.0.53",
|
||||
"assert-diff": "^1.0.1",
|
||||
"coveralls": "^2.13.1",
|
||||
"doctoc": "^0.15.0",
|
||||
"ejs": "^2.3.4",
|
||||
"eventemitter2": "^0.4.14",
|
||||
"gulp": "^3.8.10",
|
||||
"gulp-bump": "^0.1.13",
|
||||
"gulp-rename": "^1.2.0",
|
||||
"http-server": "^0.8.5",
|
||||
"jayson": "^1.2.2",
|
||||
"json-loader": "^0.5.2",
|
||||
"@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",
|
||||
"assert-diff": "^3.0.0",
|
||||
"buffer": "^6.0.2",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"doctoc": "^2.0.0",
|
||||
"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": "^2.1.0",
|
||||
"mocha-in-sauce": "^0.0.1",
|
||||
"mocha-junit-reporter": "^1.9.1",
|
||||
"null-loader": "^0.1.1",
|
||||
"nyc": "^11.3.0",
|
||||
"source-map-support": "^0.5.0",
|
||||
"ts-loader": "^3.2.0",
|
||||
"ts-node": "^3.3.0",
|
||||
"tslint": "^5.8.0",
|
||||
"tslint-eslint-rules": "^4.1.1",
|
||||
"typescript": "2.9.2",
|
||||
"uglifyjs-webpack-plugin": "^1.1.4",
|
||||
"webpack": "^3.10.0",
|
||||
"yargs": "^8.0.2"
|
||||
"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",
|
||||
"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",
|
||||
"webpack-cli": "^4.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp",
|
||||
"build:schemas": "mkdir -p dist/npm/common && cp -r src/common/schemas dist/npm/common/",
|
||||
"build:lib": "tsc --build",
|
||||
"build:web": "webpack",
|
||||
"build": "yarn build:schemas && yarn build:lib && yarn build:web",
|
||||
"analyze": "yarn build:web --analyze",
|
||||
"watch": "yarn build:lib --watch",
|
||||
"clean": "rm -rf dist/npm",
|
||||
"doctoc": "doctoc docs/index.md --title '# RippleAPI Reference' --github --maxlevel 2",
|
||||
"docgen": "node --harmony scripts/build_docs.js",
|
||||
"clean": "rm -rf dist/npm",
|
||||
"compile": "mkdir -p dist/npm/common && cp -r src/common/schemas dist/npm/common/ && tsc",
|
||||
"watch": "tsc -w",
|
||||
"prepublish": "npm run clean && npm run compile && npm run build",
|
||||
"test": "nyc mocha",
|
||||
"coveralls": "cat ./coverage/lcov.info | coveralls",
|
||||
"lint": "tslint -p ./",
|
||||
"prepublish": "yarn clean && yarn build",
|
||||
"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",
|
||||
"start": "node scripts/http.js",
|
||||
"sauce": "node scripts/sauce-runner.js"
|
||||
"compile:snippets": "tsc -p snippets/tsconfig.json",
|
||||
"start:snippet": "npm run compile:snippets && node ./snippets/dist/start.js",
|
||||
"inspect:snippet": "npm run compile:snippets && node inspect ./snippets/dist/start.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -79,6 +94,7 @@
|
||||
},
|
||||
"readmeFilename": "README.md",
|
||||
"engines": {
|
||||
"node": ">=6.12.3"
|
||||
"node": ">=10.13.0",
|
||||
"yarn": "^1.15.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,12 @@ lint() {
|
||||
|
||||
unittest() {
|
||||
# test "src"
|
||||
mocha test --reporter mocha-junit-reporter --reporter-options mochaFile=$CIRCLE_TEST_REPORTS/test-results.xml
|
||||
|
||||
# TODO: replace/upgrade mocha-junit-reporter
|
||||
#mocha test --reporter mocha-junit-reporter --reporter-options mochaFile=$CIRCLE_TEST_REPORTS/test-results.xml
|
||||
|
||||
yarn test --coverage
|
||||
yarn run coveralls
|
||||
#yarn run coveralls
|
||||
|
||||
# test compiled version in "dist/npm"
|
||||
$(npm bin)/babel -D --optional runtime --ignore "**/node_modules/**" -d test-compiled/ test/
|
||||
@@ -45,7 +48,6 @@ unittest() {
|
||||
|
||||
integrationtest() {
|
||||
mocha test/integration/integration-test.js
|
||||
mocha test/integration/http-integration-test.js
|
||||
|
||||
# run integration tests in PhantomJS
|
||||
#gulp build-tests build-min
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const createHTTPServer = require('../dist/npm/http').createHTTPServer;
|
||||
const port = 5990;
|
||||
const serverUrl = 'wss://s1.ripple.com';
|
||||
|
||||
|
||||
function main() {
|
||||
const server = createHTTPServer({server: serverUrl}, port);
|
||||
server.start().then(() => {
|
||||
console.log('Server started on port ' + String(port));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
main();
|
||||
@@ -1,100 +0,0 @@
|
||||
|
||||
const _ = require('lodash');
|
||||
const MochaSauce = require('mocha-in-sauce');
|
||||
|
||||
const testUrl = 'http://testripple.circleci.com:8080/test/saucerunner.html';
|
||||
|
||||
|
||||
function main() {
|
||||
// uncomment for more debug info
|
||||
// process.env.DEBUG = '*';
|
||||
|
||||
// configure
|
||||
const config = {
|
||||
name: 'RippleAPI',
|
||||
host: 'localhost',
|
||||
port: 4445,
|
||||
maxDuration: 180000,
|
||||
// the current build name (optional)
|
||||
build: Date.now(),
|
||||
url: testUrl,
|
||||
runSauceConnect: true
|
||||
};
|
||||
|
||||
if (process.env.CIRCLE_BUILD_NUM) {
|
||||
config.build = process.env.CIRCLE_BUILD_NUM;
|
||||
config.tags = [process.env.CIRCLE_BRANCH, process.env.CIRCLE_SHA1];
|
||||
config.tunnelIdentifier = process.env.CIRCLE_BUILD_NUM;
|
||||
}
|
||||
|
||||
const sauce = new MochaSauce(config);
|
||||
|
||||
sauce.concurrency(5);
|
||||
|
||||
// setup what browsers to test with
|
||||
sauce.browser({browserName: 'firefox', platform: 'Linux',
|
||||
version: '43'});
|
||||
sauce.browser({browserName: 'firefox', platform: 'Windows 8.1',
|
||||
version: '43'});
|
||||
sauce.browser({browserName: 'firefox', platform: 'OS X 10.11',
|
||||
version: '43'});
|
||||
sauce.browser({browserName: 'safari', platform: 'OS X 10.11',
|
||||
version: '9'});
|
||||
sauce.browser({browserName: 'safari', platform: 'OS X 10.10',
|
||||
version: '8'});
|
||||
sauce.browser({browserName: 'safari', platform: 'OS X 10.9',
|
||||
version: '7'});
|
||||
sauce.browser({browserName: 'chrome', platform: 'OS X 10.11',
|
||||
version: '47'});
|
||||
sauce.browser({browserName: 'chrome', platform: 'Linux',
|
||||
version: '47'});
|
||||
sauce.browser({browserName: 'chrome', platform: 'Windows 8.1',
|
||||
version: '47'});
|
||||
sauce.browser({browserName: 'internet explorer', platform: 'Windows 10',
|
||||
version: '11'});
|
||||
sauce.browser({browserName: 'MicrosoftEdge', platform: 'Windows 10',
|
||||
version: '20'});
|
||||
|
||||
sauce.on('init', function(browser) {
|
||||
console.log(' init : %s %s', browser.browserName, browser.platform);
|
||||
});
|
||||
|
||||
sauce.on('start', function(browser) {
|
||||
console.log(' start : %s %s', browser.browserName, browser.platform);
|
||||
});
|
||||
|
||||
sauce.on('end', function(browser, res) {
|
||||
console.log(' end : %s %s : %d failures', browser.browserName,
|
||||
browser.platform, res && res.failures);
|
||||
});
|
||||
|
||||
sauce.on('connected', sauceConnectProcess => {
|
||||
sauceConnectProcess.on('exit', function(code, /* signal */) {
|
||||
if (code > 0) {
|
||||
console.log('something wrong - exiting');
|
||||
process.exit();
|
||||
} else {
|
||||
console.log('normal tunnel exit');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
sauce.start(function(err, res) {
|
||||
let failure = false;
|
||||
if (err) {
|
||||
console.log('Error starting Sauce');
|
||||
console.error(err);
|
||||
process.exitCode = 2;
|
||||
} else {
|
||||
console.log('-------------- done --------------');
|
||||
failure = _.some(res, 'failures');
|
||||
console.log('Tests are failed:', failure);
|
||||
if (failure) {
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
9
snippets/src/decoder.ts
Normal file
9
snippets/src/decoder.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import * as codec from 'ripple-binary-codec'
|
||||
|
||||
const original = codec.decode('12000022800200002400000001201B00EF81E661EC6386F26FC0FFFF0000000000000000000000005553440000000000054F6F784A58F9EFB0A9EB90B83464F9D166461968400000000000000C6940000000000000646AD3504529A0465E2E0000000000000000000000005553440000000000054F6F784A58F9EFB0A9EB90B83464F9D1664619732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D87446304402200A693FB5CA6B21250EBDFD8CFF526EE0DF7C9E4E31EB0660692E75E6A93BF5F802203CC39463DDA21386898CA31E18AD1A6828647D65741DD637BAD71BC83E29DB9481145E7B112523F68D2F5E879DB4EAC51C6698A693048314CA6EDC7A28252DAEA6F2045B24F4D7C333E146170112300000000000000000000000005553440000000000054F6F784A58F9EFB0A9EB90B83464F9D166461900')
|
||||
|
||||
const test = codec.decode('12000022800200002400000017201B008694F261EC6386F26FC0FFFF0000000000000000000000005553440000000000054F6F784A58F9EFB0A9EB90B83464F9D166461968400000000000000C6940000000000000646AD3504529A0465E2E0000000000000000000000005553440000000000054F6F784A58F9EFB0A9EB90B83464F9D1664619732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D874473045022100D8B57E8E06EAE27B1343AF8CAD3F501E18260CCF8BCED08066074106F0F191A3022058FEA6CE9E7FA69D1244C3A70F18983CC2DAF0B10CBB86A6677CF2A5D2B8A68081145E7B112523F68D2F5E879DB4EAC51C6698A693048314CA6EDC7A28252DAEA6F2045B24F4D7C333E146170112300000000000000000000000005553440000000000054F6F784A58F9EFB0A9EB90B83464F9D166461900')
|
||||
|
||||
console.log('original:', JSON.stringify(original))
|
||||
|
||||
console.log('test:', JSON.stringify(test))
|
||||
17
snippets/src/getTransaction.ts
Normal file
17
snippets/src/getTransaction.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import {RippleAPI} from '../../dist/npm'
|
||||
|
||||
const api = new RippleAPI({
|
||||
server: 'wss://s.altnet.rippletest.net:51233'
|
||||
})
|
||||
|
||||
getTransaction()
|
||||
|
||||
async function getTransaction() {
|
||||
await api.connect()
|
||||
const ledger = await api.getLedger({includeTransactions: true})
|
||||
console.log(ledger)
|
||||
const tx = await api.getTransaction(ledger.transactionHashes[0])
|
||||
console.log(tx)
|
||||
console.log('deliveredAmount:', tx.outcome.deliveredAmount)
|
||||
process.exit(0)
|
||||
}
|
||||
13
snippets/src/parseAccountFlags.ts
Normal file
13
snippets/src/parseAccountFlags.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import {RippleAPI} from '../../dist/npm'
|
||||
|
||||
const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'})
|
||||
|
||||
parseAccountFlags()
|
||||
|
||||
async function parseAccountFlags() {
|
||||
await api.connect()
|
||||
const account_info = await api.request('account_info', {account: 'rKsdkGhyZH6b2Zzd5hNnEqSv2wpznn4n6N'})
|
||||
const flags = api.parseAccountFlags(account_info.account_data.Flags)
|
||||
console.log(JSON.stringify(flags, null, 2))
|
||||
process.exit(0)
|
||||
}
|
||||
47
snippets/src/paths.ts
Normal file
47
snippets/src/paths.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import {RippleAPI} from '../../dist/npm'
|
||||
|
||||
const api = new RippleAPI({
|
||||
// server: 'wss://s.altnet.rippletest.net:51233'
|
||||
// server: 'ws://35.158.96.209:51233'
|
||||
server: 'ws://34.210.87.206:51233'
|
||||
})
|
||||
|
||||
sign()
|
||||
|
||||
async function sign() {
|
||||
await api.connect()
|
||||
const pathfind: any = {
|
||||
source: {
|
||||
address: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59',
|
||||
amount: {
|
||||
currency: 'drops',
|
||||
value: '100'
|
||||
}
|
||||
},
|
||||
destination: {
|
||||
address: 'rKT4JX4cCof6LcDYRz8o3rGRu7qxzZ2Zwj',
|
||||
amount: {
|
||||
currency: 'USD',
|
||||
counterparty: 'rVnYNK9yuxBz4uP8zC8LEFokM2nqH3poc'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await api.getPaths(pathfind).then(async (data) => {
|
||||
console.log('paths:', JSON.stringify(data))
|
||||
const fakeSecret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
|
||||
|
||||
pathfind.paths = data[0].paths
|
||||
pathfind.destination = data[0].destination
|
||||
await api.preparePayment('r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59', pathfind).then(ret => {
|
||||
const signed = api.sign(ret.txJSON, fakeSecret)
|
||||
console.log('signed:', signed)
|
||||
}).catch(err => {
|
||||
console.log('ERR 1:', JSON.stringify(err))
|
||||
})
|
||||
}).catch(err => {
|
||||
console.log('ERR 2:', err)
|
||||
})
|
||||
|
||||
api.disconnect()
|
||||
}
|
||||
200
snippets/src/reliableTransactionSubmission.ts
Normal file
200
snippets/src/reliableTransactionSubmission.ts
Normal file
@@ -0,0 +1,200 @@
|
||||
import {
|
||||
RippleAPI,
|
||||
AccountInfoResponse,
|
||||
LedgerClosedEvent
|
||||
} from '../../dist/npm'
|
||||
import https = require('https')
|
||||
|
||||
/**
|
||||
* When implementing Reliable Transaction Submission, there are many potential solutions, each with different trade-offs. The main decision points are:
|
||||
* 1) Transaction preparation:
|
||||
* - How do we decide which account sequence and LastLedgerSequence numbers to use?
|
||||
* (To prevent unintentional duplicate transactions, an {account, account_sequence} pair can be used as a transaction's idempotency key)
|
||||
* - How do we decide how much to pay for the transaction fee? (If our transactions have been failing due to low fee, we should consider increasing this value)
|
||||
* 2) Transaction status retrieval. Options include:
|
||||
* - Poll for transaction status:
|
||||
* - On a regular interval (e.g. every 3-5 seconds), or
|
||||
* - When a new validated ledger is detected
|
||||
* + (To accommodate an edge case in transaction retrieval, check the sending account's Sequence number to confirm that it has the expected value;
|
||||
* alternatively, wait until a few additional ledgers have been validated before deciding that a transaction has definitively not been included in a validated ledger)
|
||||
* - Listen for transaction status: scan all validated transactions to see if our transactions are among them
|
||||
* 3) What do we do when a transaction fails? It is possible to implement retry logic, but caution is advised. Note that there are a few ways for a transaction to fail:
|
||||
* A) `tec`: The transaction was included in a ledger but only claimed the transaction fee
|
||||
* B) `tesSUCCESS` but unexpected result: The transaction was successful but did not have the expected result. This generally does not occur for XRP-to-XRP payments
|
||||
* C) The transaction was not, and never will be, included in a validated ledger [3C]
|
||||
*
|
||||
* References:
|
||||
* - https://xrpl.org/reliable-transaction-submission.html
|
||||
* - https://xrpl.org/send-xrp.html
|
||||
* - https://xrpl.org/look-up-transaction-results.html
|
||||
* - https://xrpl.org/get-started-with-rippleapi-for-javascript.html
|
||||
* - https://xrpl.org/monitor-incoming-payments-with-websocket.html
|
||||
*
|
||||
* For the implementation in this example, we have made the following decisions:
|
||||
* 1) The script will choose the account sequence and LastLedgerSequence numbers automatically. We allow ripple-lib to choose the fee.
|
||||
* Payments are defined upfront, and idempotency is not needed. If the script is run a second time, duplicate payments will result.
|
||||
* 2) We will listen for notification that a new validated ledger has been found, and poll for transaction status at that time.
|
||||
* Futhermore, as a precaution, we will wait until the server is 3 ledgers past the transaction's LastLedgerSequence
|
||||
* (with the transaction nowhere to be seen) before deciding that it has definitively failed per [3C]
|
||||
* 3) Transactions will not be automatically retried. Transactions are limited to XRP-to-XRP payments and cannot "succeed" in an unexpected way.
|
||||
*/
|
||||
reliableTransactionSubmissionExample()
|
||||
|
||||
async function reliableTransactionSubmissionExample() {
|
||||
/**
|
||||
* Array of payments to execute.
|
||||
*
|
||||
* For brevity, these are XRP-to-XRP payments, taking a source, destination, and an amount in drops.
|
||||
*
|
||||
* The script will attempt to make all of these payments as quickly as possible, and report the final status of each. Transactions that fail are NOT retried.
|
||||
*/
|
||||
const payments = []
|
||||
|
||||
const sourceAccount = (await generateTestnetAccount()).account
|
||||
console.log(`Generated new Testnet account: ${sourceAccount.classicAddress}/${sourceAccount.secret}`)
|
||||
// Send amounts from 1 drop to 10 drops
|
||||
for (let i = 1; i <= 10; i++) {
|
||||
payments.push({
|
||||
source: sourceAccount,
|
||||
destination: 'rhsoCozhUxwcyQgzFi1FVRoMVQgk7cZd4L', // Random Testnet destination
|
||||
amount_drops: i.toString(),
|
||||
})
|
||||
}
|
||||
const results = await performPayments(payments)
|
||||
console.log(JSON.stringify(results, null, 2))
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
async function performPayments(payments) {
|
||||
const finalResults = []
|
||||
const txFinalizedPromises = []
|
||||
const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'})
|
||||
await api.connect()
|
||||
|
||||
for (let i = 0; i < payments.length; i++) {
|
||||
const payment = payments[i]
|
||||
const account_info: AccountInfoResponse = await api.request('account_info', {
|
||||
account: payment.source.classicAddress,
|
||||
ledger_index: 'current'})
|
||||
const sequence = account_info.account_data.Sequence
|
||||
const preparedPayment = await api.preparePayment(payment.source.classicAddress, {
|
||||
source: {
|
||||
address: payment.source.classicAddress,
|
||||
amount: {
|
||||
value: payment.amount_drops,
|
||||
currency: 'drops'
|
||||
}
|
||||
},
|
||||
destination: {
|
||||
address: payment.destination,
|
||||
minAmount: {
|
||||
value: payment.amount_drops,
|
||||
currency: 'drops'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
sequence
|
||||
})
|
||||
const signed = api.sign(preparedPayment.txJSON, payment.source.secret)
|
||||
finalResults.push({
|
||||
id: signed.id
|
||||
})
|
||||
const result = await api.submit(signed.signedTransaction)
|
||||
|
||||
// Most of the time we'll get 'tesSUCCESS' or (after many submissions) 'terQUEUED'
|
||||
console.log(`tx ${i} - tentative: ${result.resultCode}`)
|
||||
|
||||
const txFinalizedPromise = new Promise<void>((resolve) => {
|
||||
const ledgerClosedCallback = async (event: LedgerClosedEvent) => {
|
||||
let status
|
||||
try {
|
||||
status = await api.getTransaction(signed.id)
|
||||
} catch (e) {
|
||||
// Typical error when the tx hasn't been validated yet:
|
||||
if (e.name !== 'MissingLedgerHistoryError') {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
if (event.ledger_index > preparedPayment.instructions.maxLedgerVersion + 3) {
|
||||
// Assumptions:
|
||||
// - We are still connected to the same rippled server
|
||||
// - No ledger gaps occurred
|
||||
// - All ledgers between the time we submitted the tx and now have been checked for the tx
|
||||
status = {
|
||||
finalResult: 'Transaction was not, and never will be, included in a validated ledger'
|
||||
}
|
||||
} else {
|
||||
// Check again later:
|
||||
api.connection.once('ledgerClosed', ledgerClosedCallback)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for (let j = 0; j < finalResults.length; j++) {
|
||||
if (finalResults[j].id === signed.id) {
|
||||
finalResults[j].result = status.address ? {
|
||||
source: status.address,
|
||||
destination: status.specification.destination.address,
|
||||
deliveredAmount: status.outcome.deliveredAmount,
|
||||
result: status.outcome.result,
|
||||
timestamp: status.outcome.timestamp,
|
||||
ledgerVersion: status.outcome.ledgerVersion
|
||||
} : status
|
||||
process.stdout.write('.')
|
||||
return resolve()
|
||||
}
|
||||
}
|
||||
}
|
||||
api.connection.once('ledgerClosed', ledgerClosedCallback)
|
||||
})
|
||||
txFinalizedPromises.push(txFinalizedPromise)
|
||||
}
|
||||
await Promise.all(txFinalizedPromises)
|
||||
return finalResults
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new Testnet account by requesting one from the faucet
|
||||
*/
|
||||
async function generateTestnetAccount(): Promise<{
|
||||
account: {
|
||||
xAddress: string,
|
||||
classicAddress, string,
|
||||
secret: string
|
||||
},
|
||||
balance: number
|
||||
}> {
|
||||
const options = {
|
||||
hostname: 'faucet.altnet.rippletest.net',
|
||||
port: 443,
|
||||
path: '/accounts',
|
||||
method: 'POST'
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = https.request(options, response => {
|
||||
const chunks = []
|
||||
response.on('data', d => {
|
||||
chunks.push(d)
|
||||
})
|
||||
response.on('end', () => {
|
||||
const body = Buffer.concat(chunks).toString()
|
||||
|
||||
// "application/json; charset=utf-8"
|
||||
if (response.headers['content-type'].startsWith('application/json')) {
|
||||
resolve(JSON.parse(body))
|
||||
} else {
|
||||
reject({
|
||||
statusCode: response.statusCode,
|
||||
contentType: response.headers['content-type'],
|
||||
body
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
request.on('error', error => {
|
||||
console.error(error)
|
||||
reject(error)
|
||||
})
|
||||
request.end()
|
||||
})
|
||||
}
|
||||
13
snippets/tsconfig.json
Normal file
13
snippets/tsconfig.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"extends": "../tsconfig-base",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"references": [
|
||||
{ "path": "../src" }
|
||||
],
|
||||
"include": [
|
||||
"./src/**/*.ts"
|
||||
]
|
||||
}
|
||||
330
src/api.ts
330
src/api.ts
@@ -1,12 +1,15 @@
|
||||
import {EventEmitter} from 'events'
|
||||
import {
|
||||
Connection,
|
||||
constants,
|
||||
errors,
|
||||
validate,
|
||||
xrpToDrops,
|
||||
dropsToXrp,
|
||||
rippleTimeToISO8601,
|
||||
iso8601ToRippleTime,
|
||||
txFlags
|
||||
txFlags,
|
||||
ensureClassicAddress,
|
||||
} from './common'
|
||||
import {
|
||||
connect,
|
||||
@@ -22,8 +25,8 @@ import getBalances from './ledger/balances'
|
||||
import getBalanceSheet from './ledger/balance-sheet'
|
||||
import getPaths from './ledger/pathfind'
|
||||
import getOrders from './ledger/orders'
|
||||
import getOrderbook from './ledger/orderbook'
|
||||
import getSettings from './ledger/settings'
|
||||
import {getOrderbook, formatBidsAndAsks} from './ledger/orderbook'
|
||||
import {getSettings, parseAccountFlags} from './ledger/settings'
|
||||
import getAccountInfo from './ledger/accountinfo'
|
||||
import getAccountObjects from './ledger/accountobjects'
|
||||
import getPaymentChannel from './ledger/payment-channel'
|
||||
@@ -41,42 +44,85 @@ import prepareCheckCreate from './transaction/check-create'
|
||||
import prepareCheckCancel from './transaction/check-cancel'
|
||||
import prepareCheckCash from './transaction/check-cash'
|
||||
import prepareSettings from './transaction/settings'
|
||||
import prepareTicketCreate from './transaction/ticket'
|
||||
import sign from './transaction/sign'
|
||||
import combine from './transaction/combine'
|
||||
import submit from './transaction/submit'
|
||||
import {generateAddressAPI} 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'
|
||||
import verifyPaymentChannelClaim from './offline/verify-payment-channel-claim'
|
||||
import getLedger from './ledger/ledger'
|
||||
|
||||
import {
|
||||
AccountObjectsRequest, AccountObjectsResponse,
|
||||
AccountOffersRequest, AccountOffersResponse,
|
||||
AccountInfoRequest, AccountInfoResponse,
|
||||
AccountLinesRequest, AccountLinesResponse,
|
||||
BookOffersRequest, BookOffersResponse,
|
||||
GatewayBalancesRequest, GatewayBalancesResponse,
|
||||
LedgerRequest, LedgerResponse,
|
||||
LedgerEntryRequest, LedgerEntryResponse,
|
||||
ServerInfoRequest, ServerInfoResponse
|
||||
AccountObjectsRequest,
|
||||
AccountObjectsResponse,
|
||||
AccountOffersRequest,
|
||||
AccountOffersResponse,
|
||||
AccountInfoRequest,
|
||||
AccountInfoResponse,
|
||||
AccountLinesRequest,
|
||||
AccountLinesResponse,
|
||||
BookOffersRequest,
|
||||
BookOffersResponse,
|
||||
GatewayBalancesRequest,
|
||||
GatewayBalancesResponse,
|
||||
LedgerRequest,
|
||||
LedgerResponse,
|
||||
LedgerDataRequest,
|
||||
LedgerDataResponse,
|
||||
LedgerEntryRequest,
|
||||
LedgerEntryResponse,
|
||||
ServerInfoRequest,
|
||||
ServerInfoResponse
|
||||
} from './common/types/commands'
|
||||
|
||||
|
||||
import RangeSet from './common/rangeset'
|
||||
import * as ledgerUtils from './ledger/utils'
|
||||
import * as transactionUtils from './transaction/utils'
|
||||
import * as schemaValidator from './common/schema-validator'
|
||||
import {getServerInfo, getFee} from './common/serverinfo'
|
||||
import {clamp} from './ledger/utils'
|
||||
import {Instructions} from './transaction/types'
|
||||
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 {
|
||||
computeBinaryTransactionHash,
|
||||
computeTransactionHash,
|
||||
computeBinaryTransactionSigningHash,
|
||||
computeAccountLedgerObjectID,
|
||||
computeSignerListLedgerObjectID,
|
||||
computeOrderID,
|
||||
computeTrustlineHash,
|
||||
computeTransactionTreeHash,
|
||||
computeStateTreeHash,
|
||||
computeEscrowHash,
|
||||
computePaymentChannelHash
|
||||
} from './common/hashes'
|
||||
|
||||
export type APIOptions = {
|
||||
server?: string,
|
||||
feeCushion?: number,
|
||||
maxFeeXRP?: string,
|
||||
trace?: boolean,
|
||||
proxy?: string,
|
||||
import generateFaucetWallet from './wallet/wallet-generation'
|
||||
|
||||
export interface APIOptions extends ConnectionUserOptions {
|
||||
server?: string
|
||||
feeCushion?: number
|
||||
maxFeeXRP?: string
|
||||
proxy?: string
|
||||
timeout?: number
|
||||
}
|
||||
|
||||
@@ -85,7 +131,7 @@ export type APIOptions = {
|
||||
* command. This varies from command to command, but we need to know it to
|
||||
* properly count across many requests.
|
||||
*/
|
||||
function getCollectKeyFromCommand(command: string): string|undefined {
|
||||
function getCollectKeyFromCommand(command: string): string | undefined {
|
||||
switch (command) {
|
||||
case 'account_offers':
|
||||
case 'book_offers':
|
||||
@@ -113,15 +159,18 @@ class RippleAPI extends EventEmitter {
|
||||
schemaValidator
|
||||
}
|
||||
|
||||
static renameCounterpartyToIssuer = renameCounterpartyToIssuer
|
||||
static formatBidsAndAsks = formatBidsAndAsks
|
||||
|
||||
constructor(options: APIOptions = {}) {
|
||||
super()
|
||||
validate.apiOptions(options)
|
||||
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.connection.on('ledgerClosed', (message) => {
|
||||
this.emit('ledger', formatLedgerClose(message))
|
||||
})
|
||||
this.connection.on('error', (errorCode, errorMessage, data) => {
|
||||
@@ -130,8 +179,15 @@ class RippleAPI extends EventEmitter {
|
||||
this.connection.on('connected', () => {
|
||||
this.emit('connected')
|
||||
})
|
||||
this.connection.on('disconnected', code => {
|
||||
this.emit('disconnected', code)
|
||||
this.connection.on('disconnected', (code) => {
|
||||
let finalCode = code
|
||||
// 1005: This is a backwards-compatible fix for this change in the ws library: https://github.com/websockets/ws/issues/1257
|
||||
// 4000: Connection uses a 4000 code internally to indicate a manual disconnect/close
|
||||
// TODO: Remove in next major, breaking version
|
||||
if (finalCode === 1005 || finalCode === 4000) {
|
||||
finalCode = 1000
|
||||
}
|
||||
this.emit('disconnected', finalCode)
|
||||
})
|
||||
} else {
|
||||
// use null object pattern to provide better error message if user
|
||||
@@ -140,35 +196,56 @@ class RippleAPI extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Makes a request to the API with the given command and
|
||||
* additional request body parameters.
|
||||
*/
|
||||
async request(command: 'account_info', params: AccountInfoRequest):
|
||||
Promise<AccountInfoResponse>
|
||||
async request(command: 'account_lines', params: AccountLinesRequest):
|
||||
Promise<AccountLinesResponse>
|
||||
async request(command: 'account_objects', params: AccountObjectsRequest):
|
||||
Promise<AccountObjectsResponse>
|
||||
async request(command: 'account_offers', params: AccountOffersRequest):
|
||||
Promise<AccountOffersResponse>
|
||||
async request(command: 'book_offers', params: BookOffersRequest):
|
||||
Promise<BookOffersResponse>
|
||||
async request(command: 'gateway_balances', params: GatewayBalancesRequest):
|
||||
Promise<GatewayBalancesResponse>
|
||||
async request(command: 'ledger', params: LedgerRequest):
|
||||
Promise<LedgerResponse>
|
||||
async request(command: 'ledger_entry', params: LedgerEntryRequest):
|
||||
Promise<LedgerEntryResponse>
|
||||
async request(command: 'server_info', params?: ServerInfoRequest):
|
||||
Promise<ServerInfoResponse>
|
||||
async request(command: string, params: any):
|
||||
Promise<any>
|
||||
async request(
|
||||
command: 'account_info',
|
||||
params: AccountInfoRequest
|
||||
): Promise<AccountInfoResponse>
|
||||
async request(
|
||||
command: 'account_lines',
|
||||
params: AccountLinesRequest
|
||||
): Promise<AccountLinesResponse>
|
||||
async request(
|
||||
command: 'account_objects',
|
||||
params: AccountObjectsRequest
|
||||
): Promise<AccountObjectsResponse>
|
||||
async request(
|
||||
command: 'account_offers',
|
||||
params: AccountOffersRequest
|
||||
): Promise<AccountOffersResponse>
|
||||
async request(
|
||||
command: 'book_offers',
|
||||
params: BookOffersRequest
|
||||
): Promise<BookOffersResponse>
|
||||
async request(
|
||||
command: 'gateway_balances',
|
||||
params: GatewayBalancesRequest
|
||||
): Promise<GatewayBalancesResponse>
|
||||
async request(
|
||||
command: 'ledger',
|
||||
params: LedgerRequest
|
||||
): Promise<LedgerResponse>
|
||||
async request(
|
||||
command: 'ledger_data',
|
||||
params?: LedgerDataRequest
|
||||
): Promise<LedgerDataResponse>
|
||||
async request(
|
||||
command: 'ledger_entry',
|
||||
params: LedgerEntryRequest
|
||||
): Promise<LedgerEntryResponse>
|
||||
async request(
|
||||
command: 'server_info',
|
||||
params?: ServerInfoRequest
|
||||
): Promise<ServerInfoResponse>
|
||||
async request(command: string, params: any): Promise<any>
|
||||
async request(command: string, params: any = {}): Promise<any> {
|
||||
return this.connection.request({
|
||||
...params,
|
||||
command
|
||||
command,
|
||||
account: params.account ? ensureClassicAddress(params.account) : undefined
|
||||
})
|
||||
}
|
||||
|
||||
@@ -188,7 +265,7 @@ class RippleAPI extends EventEmitter {
|
||||
command: string,
|
||||
params: object = {},
|
||||
currentResponse: T
|
||||
): Promise<object> {
|
||||
): Promise<T> {
|
||||
if (!currentResponse.marker) {
|
||||
return Promise.reject(
|
||||
new errors.NotFoundError('response does not have a next page')
|
||||
@@ -203,9 +280,12 @@ class RippleAPI extends EventEmitter {
|
||||
/**
|
||||
* Prepare a transaction.
|
||||
*
|
||||
* You can later submit the transaction with `submit()`.
|
||||
* You can later submit the transaction with a `submit` request.
|
||||
*/
|
||||
async prepareTransaction(txJSON: object, instructions: Instructions = {}) {
|
||||
async prepareTransaction(
|
||||
txJSON: TransactionJSON,
|
||||
instructions: Instructions = {}
|
||||
): Promise<Prepare> {
|
||||
return transactionUtils.prepareTransaction(txJSON, this, instructions)
|
||||
}
|
||||
|
||||
@@ -233,16 +313,23 @@ class RippleAPI extends EventEmitter {
|
||||
* general use. Instead, use rippled's built-in pagination and make multiple
|
||||
* requests as needed.
|
||||
*/
|
||||
async _requestAll(command: 'account_offers', params: AccountOffersRequest):
|
||||
Promise<AccountOffersResponse[]>
|
||||
async _requestAll(command: 'book_offers', params: BookOffersRequest):
|
||||
Promise<BookOffersResponse[]>
|
||||
async _requestAll(command: 'account_lines', params: AccountLinesRequest):
|
||||
Promise<AccountLinesResponse[]>
|
||||
async _requestAll(
|
||||
command: 'account_offers',
|
||||
params: AccountOffersRequest
|
||||
): Promise<AccountOffersResponse[]>
|
||||
async _requestAll(
|
||||
command: 'book_offers',
|
||||
params: BookOffersRequest
|
||||
): Promise<BookOffersResponse[]>
|
||||
async _requestAll(
|
||||
command: 'account_lines',
|
||||
params: AccountLinesRequest
|
||||
): Promise<AccountLinesResponse[]>
|
||||
async _requestAll(
|
||||
command: string,
|
||||
params: any = {},
|
||||
options: {collect?: string} = {}): Promise<any[]> {
|
||||
options: {collect?: string} = {}
|
||||
): Promise<any[]> {
|
||||
// The data under collection is keyed based on the command. Fail if command
|
||||
// not recognized and collection key not provided.
|
||||
const collectKey = options.collect || getCollectKeyFromCommand(command)
|
||||
@@ -251,8 +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
|
||||
@@ -276,10 +362,14 @@ class RippleAPI extends EventEmitter {
|
||||
} else {
|
||||
lastBatchLength = 0
|
||||
}
|
||||
} while(!!marker && count < countTo && lastBatchLength !== 0)
|
||||
} while (!!marker && count < countTo && lastBatchLength !== 0)
|
||||
return results
|
||||
}
|
||||
|
||||
// @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
|
||||
isConnected = isConnected
|
||||
@@ -293,13 +383,14 @@ class RippleAPI extends EventEmitter {
|
||||
getBalances = getBalances
|
||||
getBalanceSheet = getBalanceSheet
|
||||
getPaths = getPaths
|
||||
getOrders = getOrders
|
||||
getOrderbook = getOrderbook
|
||||
getOrders = getOrders
|
||||
getSettings = getSettings
|
||||
getAccountInfo = getAccountInfo
|
||||
getAccountObjects = getAccountObjects
|
||||
getPaymentChannel = getPaymentChannel
|
||||
getLedger = getLedger
|
||||
parseAccountFlags = parseAccountFlags
|
||||
|
||||
preparePayment = preparePayment
|
||||
prepareTrustline = prepareTrustline
|
||||
@@ -314,23 +405,116 @@ class RippleAPI extends EventEmitter {
|
||||
prepareCheckCreate = prepareCheckCreate
|
||||
prepareCheckCash = prepareCheckCash
|
||||
prepareCheckCancel = prepareCheckCancel
|
||||
prepareTicketCreate = prepareTicketCreate
|
||||
prepareSettings = prepareSettings
|
||||
sign = sign
|
||||
combine = combine
|
||||
submit = submit
|
||||
|
||||
generateAddress = generateAddressAPI
|
||||
computeLedgerHash = computeLedgerHash
|
||||
signPaymentChannelClaim = signPaymentChannelClaim
|
||||
verifyPaymentChannelClaim = verifyPaymentChannelClaim
|
||||
submit = submit // @deprecated Use api.request('submit', { tx_blob: signedTransaction }) instead
|
||||
|
||||
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
|
||||
|
||||
xrpToDrops = xrpToDrops
|
||||
dropsToXrp = dropsToXrp
|
||||
iso8601ToRippleTime = iso8601ToRippleTime
|
||||
static deriveXAddress = deriveXAddress
|
||||
|
||||
// RippleAPI.deriveClassicAddress (static) is a new name for api.deriveAddress
|
||||
static deriveClassicAddress = deriveAddress
|
||||
|
||||
/**
|
||||
* 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 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
|
||||
// @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 // @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,
|
||||
AccountObjectsResponse,
|
||||
AccountOffersRequest,
|
||||
AccountOffersResponse,
|
||||
AccountInfoRequest,
|
||||
AccountInfoResponse,
|
||||
AccountLinesRequest,
|
||||
AccountLinesResponse,
|
||||
BookOffersRequest,
|
||||
BookOffersResponse,
|
||||
GatewayBalancesRequest,
|
||||
GatewayBalancesResponse,
|
||||
LedgerRequest,
|
||||
LedgerResponse,
|
||||
LedgerDataRequest,
|
||||
LedgerDataResponse,
|
||||
LedgerEntryRequest,
|
||||
LedgerEntryResponse,
|
||||
ServerInfoRequest,
|
||||
ServerInfoResponse
|
||||
}
|
||||
|
||||
@@ -1,56 +1,57 @@
|
||||
|
||||
import * as _ from 'lodash'
|
||||
import {RippleAPI} from './api'
|
||||
import {RippleAPI, APIOptions} from './api'
|
||||
|
||||
class RippleAPIBroadcast extends RippleAPI {
|
||||
|
||||
ledgerVersion: number | undefined = undefined
|
||||
private _apis: RippleAPI[]
|
||||
|
||||
constructor(servers, options) {
|
||||
constructor(servers, options: APIOptions = {}) {
|
||||
super(options)
|
||||
|
||||
const apis: RippleAPI[] = servers.map(server => new RippleAPI(
|
||||
_.assign({}, options, {server})
|
||||
))
|
||||
const apis: RippleAPI[] = servers.map(
|
||||
(server) => new RippleAPI(Object.assign({}, options, {server}))
|
||||
)
|
||||
|
||||
// exposed for testing
|
||||
this._apis = apis
|
||||
|
||||
this.getMethodNames().forEach(name => {
|
||||
this[name] = function() { // eslint-disable-line no-loop-func
|
||||
return Promise.race(apis.map(api => api[name](...arguments)))
|
||||
this.getMethodNames().forEach((name) => {
|
||||
this[name] = function () {
|
||||
// eslint-disable-line no-loop-func
|
||||
return Promise.race(apis.map((api) => api[name](...arguments)))
|
||||
}
|
||||
})
|
||||
|
||||
// connection methods must be overridden to apply to all api instances
|
||||
this.connect = async function() {
|
||||
await Promise.all(apis.map(api => api.connect()))
|
||||
this.connect = async function () {
|
||||
await Promise.all(apis.map((api) => api.connect()))
|
||||
}
|
||||
this.disconnect = async function() {
|
||||
await Promise.all(apis.map(api => api.disconnect()))
|
||||
this.disconnect = async function () {
|
||||
await Promise.all(apis.map((api) => api.disconnect()))
|
||||
}
|
||||
this.isConnected = function() {
|
||||
return apis.map(api => api.isConnected()).every(Boolean)
|
||||
this.isConnected = function () {
|
||||
return apis.map((api) => api.isConnected()).every(Boolean)
|
||||
}
|
||||
|
||||
// synchronous methods are all passed directly to the first api instance
|
||||
const defaultAPI = apis[0]
|
||||
const syncMethods = ['sign', 'generateAddress', 'computeLedgerHash']
|
||||
syncMethods.forEach(name => {
|
||||
syncMethods.forEach((name) => {
|
||||
this[name] = defaultAPI[name].bind(defaultAPI)
|
||||
})
|
||||
|
||||
apis.forEach(api => {
|
||||
apis.forEach((api) => {
|
||||
api.on('ledger', this.onLedgerEvent.bind(this))
|
||||
api.on('error', (errorCode, errorMessage, data) =>
|
||||
this.emit('error', errorCode, errorMessage, data))
|
||||
this.emit('error', errorCode, errorMessage, data)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
onLedgerEvent(ledger) {
|
||||
if (ledger.ledgerVersion > this.ledgerVersion ||
|
||||
this.ledgerVersion === undefined) {
|
||||
if (
|
||||
ledger.ledgerVersion > this.ledgerVersion ||
|
||||
this.ledgerVersion == null
|
||||
) {
|
||||
this.ledgerVersion = ledger.ledgerVersion
|
||||
this.emit('ledger', ledger)
|
||||
}
|
||||
@@ -68,6 +69,4 @@ class RippleAPIBroadcast extends RippleAPI {
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
RippleAPIBroadcast
|
||||
}
|
||||
export {RippleAPIBroadcast}
|
||||
|
||||
44
src/common/backoff.ts
Normal file
44
src/common/backoff.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Original code based on "backo" - https://github.com/segmentio/backo
|
||||
* MIT License - Copyright 2014 Segment.io
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Back off strategy that increases exponentially. Useful with repeated
|
||||
* setTimeout calls over a network (where the destination may be down).
|
||||
*/
|
||||
export class ExponentialBackoff {
|
||||
private readonly ms: number
|
||||
private readonly max: number
|
||||
private readonly factor: number = 2
|
||||
private readonly jitter: number = 0
|
||||
attempts: number = 0
|
||||
|
||||
constructor(opts: {min?: number; max?: number} = {}) {
|
||||
this.ms = opts.min || 100
|
||||
this.max = opts.max || 10000
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the backoff duration.
|
||||
*/
|
||||
duration() {
|
||||
var ms = this.ms * Math.pow(this.factor, this.attempts++)
|
||||
if (this.jitter) {
|
||||
var rand = Math.random()
|
||||
var deviation = Math.floor(rand * this.jitter * ms)
|
||||
ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation
|
||||
}
|
||||
return Math.min(ms, this.max) | 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the number of attempts.
|
||||
*/
|
||||
reset() {
|
||||
this.attempts = 0
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
|
||||
function setPrototypeOf(object, prototype) {
|
||||
// Object.setPrototypeOf not supported on Internet Explorer 9
|
||||
Object.setPrototypeOf ? Object.setPrototypeOf(object, prototype) :
|
||||
// @ts-ignore: Specifically a fallback for IE9
|
||||
object.__proto__ = prototype
|
||||
Object.setPrototypeOf
|
||||
? Object.setPrototypeOf(object, prototype)
|
||||
: // @ts-ignore: Specifically a fallback for IE9
|
||||
(object.__proto__ = prototype)
|
||||
}
|
||||
|
||||
function getConstructorName(object: Object): string {
|
||||
// hack for internet explorer
|
||||
if (!object.constructor.name) {
|
||||
return object.constructor.toString().match(/^function\s+([^(]*)/)![1]
|
||||
function getConstructorName(object: object): string {
|
||||
if (object.constructor.name) {
|
||||
return object.constructor.name
|
||||
}
|
||||
return object.constructor.name
|
||||
// try to guess it on legacy browsers (ie)
|
||||
const constructorString = object.constructor.toString()
|
||||
const functionConstructor = constructorString.match(/^function\s+([^(]*)/)
|
||||
const classConstructor = constructorString.match(/^class\s([^\s]*)/)
|
||||
return functionConstructor ? functionConstructor[1] : classConstructor[1]
|
||||
}
|
||||
|
||||
export {
|
||||
getConstructorName,
|
||||
setPrototypeOf
|
||||
}
|
||||
export {getConstructorName, setPrototypeOf}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,49 @@
|
||||
|
||||
import {txFlagIndices} from './txflags'
|
||||
|
||||
// Ordering from https://developers.ripple.com/accountroot.html
|
||||
const accountRootFlags = {
|
||||
PasswordSpent: 0x00010000, // password set fee is spent
|
||||
RequireDestTag: 0x00020000, // require a DestinationTag for payments
|
||||
RequireAuth: 0x00040000, // require authorization to hold IOUs
|
||||
DepositAuth: 0x01000000, // require account to auth deposits
|
||||
DisallowXRP: 0x00080000, // disallow sending XRP
|
||||
DisableMaster: 0x00100000, // force regular key
|
||||
NoFreeze: 0x00200000, // permanently disallowed freezing trustlines
|
||||
GlobalFreeze: 0x00400000, // trustlines globally frozen
|
||||
DefaultRipple: 0x00800000
|
||||
// lsfDefaultRipple:
|
||||
// Enable rippling on trust lines by default.
|
||||
// Required for issuing addresses; discouraged for others.
|
||||
DefaultRipple: 0x00800000,
|
||||
|
||||
// lsfDepositAuth:
|
||||
// Require account to auth deposits.
|
||||
// This account can only receive funds from transactions it sends,
|
||||
// or preauthorized accounts.
|
||||
DepositAuth: 0x01000000,
|
||||
|
||||
// lsfDisableMaster:
|
||||
// Force regular key.
|
||||
// Disallows use of the master key.
|
||||
DisableMaster: 0x00100000,
|
||||
|
||||
// lsfDisallowXRP:
|
||||
// Disallow sending XRP.
|
||||
// Not enforced by rippled; client applications should check.
|
||||
DisallowXRP: 0x00080000,
|
||||
|
||||
// lsfGlobalFreeze:
|
||||
// Trustlines globally frozen.
|
||||
GlobalFreeze: 0x00400000,
|
||||
|
||||
// lsfNoFreeze:
|
||||
// Permanently disallowed freezing trustlines.
|
||||
// Once enabled, cannot be disabled.
|
||||
NoFreeze: 0x00200000,
|
||||
|
||||
// lsfPasswordSpent:
|
||||
// Password set fee is spent.
|
||||
// The account has used its free SetRegularKey transaction.
|
||||
PasswordSpent: 0x00010000,
|
||||
|
||||
// lsfRequireAuth:
|
||||
// Require authorization to hold IOUs (issuances).
|
||||
RequireAuth: 0x00040000,
|
||||
|
||||
// lsfRequireDestTag:
|
||||
// Require a DestinationTag for incoming payments.
|
||||
RequireDestTag: 0x00020000
|
||||
}
|
||||
|
||||
const AccountFlags = {
|
||||
@@ -25,7 +58,19 @@ const AccountFlags = {
|
||||
defaultRipple: accountRootFlags.DefaultRipple
|
||||
}
|
||||
|
||||
const AccountFlagIndices = {
|
||||
export interface Settings {
|
||||
passwordSpent?: boolean
|
||||
requireDestinationTag?: boolean
|
||||
requireAuthorization?: boolean
|
||||
depositAuth?: boolean
|
||||
disallowIncomingXRP?: boolean
|
||||
disableMasterKey?: boolean
|
||||
noFreeze?: boolean
|
||||
globalFreeze?: boolean
|
||||
defaultRipple?: boolean
|
||||
}
|
||||
|
||||
const AccountSetFlags = {
|
||||
requireDestinationTag: txFlagIndices.AccountSet.asfRequireDest,
|
||||
requireAuthorization: txFlagIndices.AccountSet.asfRequireAuth,
|
||||
depositAuth: txFlagIndices.AccountSet.asfDepositAuth,
|
||||
@@ -38,15 +83,17 @@ const AccountFlagIndices = {
|
||||
}
|
||||
|
||||
const AccountFields = {
|
||||
EmailHash: {name: 'emailHash', encoding: 'hex',
|
||||
length: 32, defaults: '0'},
|
||||
EmailHash: {
|
||||
name: 'emailHash',
|
||||
encoding: 'hex',
|
||||
length: 32,
|
||||
defaults: '00000000000000000000000000000000'
|
||||
},
|
||||
WalletLocator: {name: 'walletLocator'},
|
||||
MessageKey: {name: 'messageKey'},
|
||||
Domain: {name: 'domain', encoding: 'hex'},
|
||||
TransferRate: {name: 'transferRate', defaults: 0, shift: 9}
|
||||
TransferRate: {name: 'transferRate', defaults: 0, shift: 9},
|
||||
TickSize: {name: 'tickSize', defaults: 0}
|
||||
}
|
||||
|
||||
export {
|
||||
AccountFields,
|
||||
AccountFlagIndices,
|
||||
AccountFlags
|
||||
}
|
||||
export {AccountFields, AccountSetFlags, AccountFlags}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
import {inspect} from 'util'
|
||||
import * as browserHacks from './browser-hacks'
|
||||
|
||||
class RippleError extends Error {
|
||||
|
||||
name: string
|
||||
message: string
|
||||
data?: any
|
||||
@@ -56,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)
|
||||
@@ -70,8 +70,11 @@ class MissingLedgerHistoryError extends RippleError {
|
||||
|
||||
class PendingLedgerVersionError extends RippleError {
|
||||
constructor(message?: string) {
|
||||
super(message || 'maxLedgerVersion is greater than server\'s most recent ' +
|
||||
' validated ledger')
|
||||
super(
|
||||
message ||
|
||||
"maxLedgerVersion is greater than server's most recent" +
|
||||
' validated ledger'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,5 +92,6 @@ export {
|
||||
NotFoundError,
|
||||
PendingLedgerVersionError,
|
||||
MissingLedgerHistoryError,
|
||||
LedgerVersionError
|
||||
LedgerVersionError,
|
||||
XRPLFaucetError
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user