ripple-binary-codec 1.1.2 → 1.2.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +3 -3
  2. package/dist/ShaMap/ShaMap.d.ts +3 -0
  3. package/dist/ShaMap/ShaMap.js +25 -0
  4. package/dist/ShaMap/ShaMap.js.map +1 -0
  5. package/dist/ShaMap/ShaMapInner.d.ts +66 -0
  6. package/dist/ShaMap/ShaMapInner.js +145 -0
  7. package/dist/ShaMap/ShaMapInner.js.map +1 -0
  8. package/dist/ShaMap/ShaMapLeaf.d.ts +42 -0
  9. package/dist/ShaMap/ShaMapLeaf.js +84 -0
  10. package/dist/ShaMap/ShaMapLeaf.js.map +1 -0
  11. package/dist/ShaMap/ShaMapNode.d.ts +13 -0
  12. package/dist/ShaMap/ShaMapNode.js +12 -0
  13. package/dist/ShaMap/ShaMapNode.js.map +1 -0
  14. package/dist/ShaMap/index.d.ts +3 -0
  15. package/dist/ShaMap/index.js +9 -0
  16. package/dist/ShaMap/index.js.map +1 -0
  17. package/dist/enums/Bytes.d.ts +10 -0
  18. package/dist/enums/Bytes.js +30 -0
  19. package/dist/enums/Bytes.js.map +1 -0
  20. package/dist/enums/BytesLookup.d.ts +8 -0
  21. package/dist/enums/BytesLookup.js +29 -0
  22. package/dist/enums/BytesLookup.js.map +1 -0
  23. package/dist/enums/Field.d.ts +3 -0
  24. package/dist/enums/Field.js +9 -0
  25. package/dist/enums/Field.js.map +1 -0
  26. package/dist/enums/FieldInfo.d.ts +7 -0
  27. package/dist/enums/FieldInfo.js +3 -0
  28. package/dist/enums/FieldInfo.js.map +1 -0
  29. package/dist/enums/FieldInstance.d.ts +14 -0
  30. package/dist/enums/FieldInstance.js +3 -0
  31. package/dist/enums/FieldInstance.js.map +1 -0
  32. package/dist/enums/FieldLookup.d.ts +11 -0
  33. package/dist/enums/FieldLookup.js +102 -0
  34. package/dist/enums/FieldLookup.js.map +1 -0
  35. package/dist/enums/definitions.json +191 -5
  36. package/dist/hashes.js +2 -1
  37. package/dist/hashes.js.map +1 -1
  38. package/dist/serdes/BinaryParser.d.ts +100 -0
  39. package/dist/serdes/BinaryParser.js +200 -0
  40. package/dist/serdes/BinaryParser.js.map +1 -0
  41. package/dist/serdes/BinarySerializer.d.ts +50 -0
  42. package/dist/serdes/BinarySerializer.js +105 -0
  43. package/dist/serdes/BinarySerializer.js.map +1 -0
  44. package/dist/serdes/BytesList.d.ts +28 -0
  45. package/dist/serdes/BytesList.js +48 -0
  46. package/dist/serdes/BytesList.js.map +1 -0
  47. package/dist/types/Comparable.d.ts +18 -0
  48. package/dist/types/Comparable.js +43 -0
  49. package/dist/types/Comparable.js.map +1 -0
  50. package/dist/types/PathSet/Hop.d.ts +41 -0
  51. package/dist/types/PathSet/Hop.js +116 -0
  52. package/dist/types/PathSet/Hop.js.map +1 -0
  53. package/dist/types/PathSet/Path.d.ts +33 -0
  54. package/dist/types/PathSet/Path.js +83 -0
  55. package/dist/types/PathSet/Path.js.map +1 -0
  56. package/dist/types/PathSet/index.d.ts +29 -0
  57. package/dist/types/PathSet/index.js +98 -0
  58. package/dist/types/PathSet/index.js.map +1 -0
  59. package/dist/types/SerializedType.d.ts +47 -0
  60. package/dist/types/SerializedType.js +69 -0
  61. package/dist/types/SerializedType.js.map +1 -0
  62. package/dist/types/currency.d.ts +3 -10
  63. package/dist/types/currency.js +22 -23
  64. package/dist/types/currency.js.map +1 -1
  65. package/dist/types/uint-64.js +3 -5
  66. package/dist/types/uint-64.js.map +1 -1
  67. package/package.json +4 -3
  68. package/test/binary-parser.test.js +2 -2
  69. package/test/fixtures/data-driven-tests.json +2 -790
  70. package/test/hash.test.js +8 -4
  71. package/test/lower-case-hex.test.js +2 -1
  72. package/test/uint.test.js +77 -0
  73. package/HISTORY.md +0 -86
package/test/hash.test.js CHANGED
@@ -50,10 +50,10 @@ describe("Hash256", function () {
50
50
  });
51
51
 
52
52
  describe("Currency", function () {
53
- test("Will have a null iso() for dodgy XRP ", function () {
54
- const bad = Currency.from("0000000000000000000000005852500000000000");
55
- expect(bad.iso()).toBeUndefined();
56
- expect(bad.isNative()).toBe(false);
53
+ test("Will throw an error for dodgy XRP ", function () {
54
+ expect(() =>
55
+ Currency.from("0000000000000000000000005852500000000000")
56
+ ).toThrow();
57
57
  });
58
58
  test("Currency with lowercase letters decode to hex", () => {
59
59
  expect(Currency.from("xRp").toJSON()).toBe(
@@ -73,6 +73,10 @@ describe("Currency", function () {
73
73
  const xrp = new Currency(Buffer.alloc(20));
74
74
  expect(xrp.iso()).toBe("XRP");
75
75
  });
76
+ test("Can handle non-standard currency codes", () => {
77
+ const currency = "015841551A748AD2C1F76FF6ECB0CCCD00000000";
78
+ expect(Currency.from(currency).toJSON()).toBe(currency);
79
+ });
76
80
  test("throws on invalid reprs", function () {
77
81
  expect(() => Currency.from(Buffer.alloc(19))).toThrow();
78
82
  expect(() => Currency.from(1)).toThrow();
@@ -11,7 +11,8 @@ let json = {
11
11
  Account: "rUnFEsHjxqTswbivzL2DNHBb34rhAgZZZK",
12
12
  PreviousTxnLgrSeq: 8,
13
13
  LedgerEntryType: "AccountRoot",
14
- PreviousTxnID: "0735A0B32B2A3F4C938B76D6933003E29447DB8C7CE382BBE089402FF12A03E5".toLowerCase(),
14
+ PreviousTxnID:
15
+ "0735A0B32B2A3F4C938B76D6933003E29447DB8C7CE382BBE089402FF12A03E5".toLowerCase(),
15
16
  Flags: 0,
16
17
  Sequence: 1,
17
18
  Balance: "10000000000",
package/test/uint.test.js CHANGED
@@ -27,6 +27,77 @@ const json = {
27
27
  LowNode: "0",
28
28
  };
29
29
 
30
+ const binaryEntry0 =
31
+ "11007222001100002501EC24873700000000000000003800000000000000A35506FC7DE374089D50F81AAE13E7BBF3D0E694769331E14F55351B38D0148018EA62D44BF89AC2A40B800000000000000000000000004A50590000000000000000000000000000000000000000000000000166D6C38D7EA4C680000000000000000000000000004A5059000000000047C1258B4B79774B28176324068F759EDE226F686780000000000000000000000000000000000000004A505900000000005BBC0F22F61D9224A110650CFE21CC0C4BE13098";
32
+ const jsonEntry0 = {
33
+ Balance: {
34
+ currency: "JPY",
35
+ issuer: "rrrrrrrrrrrrrrrrrrrrBZbvji",
36
+ value: "0.3369568318",
37
+ },
38
+ Flags: 1114112,
39
+ HighLimit: {
40
+ currency: "JPY",
41
+ issuer: "r94s8px6kSw1uZ1MV98dhSRTvc6VMPoPcN",
42
+ value: "0",
43
+ },
44
+ HighNode: "a3",
45
+ LedgerEntryType: "RippleState",
46
+ LowLimit: {
47
+ currency: "JPY",
48
+ issuer: "rfYQMgj3g3Qp8VLoZNvvU35mEuuJC8nCmY",
49
+ value: "1000000000",
50
+ },
51
+ LowNode: "0",
52
+ PreviousTxnID:
53
+ "06FC7DE374089D50F81AAE13E7BBF3D0E694769331E14F55351B38D0148018EA",
54
+ PreviousTxnLgrSeq: 32253063,
55
+ index: "000319BAE0A618A7D3BB492F17E98E5D92EA0C6458AFEBED44206B5B4798A840",
56
+ };
57
+
58
+ const binaryEntry1 =
59
+ "1100642200000000320000000000000002580CB3C1AD2C371136AEA434246D971C5FCCD32CBF520667E131AB7B10D706E7528214BA53D10260FFCC968ACD16BA30F7CEABAD6E5D92011340A3454ACED87177146EABD5E4A256021D836D1E3617618B1EB362D10B0D1BAC6AE1ED9E8D280BBE0B6656748FD647231851C6C650794D5E6852DFA1E35E68630F";
60
+ const jsonEntry1 = {
61
+ Flags: 0,
62
+ IndexPrevious: "2",
63
+ Indexes: [
64
+ "A3454ACED87177146EABD5E4A256021D836D1E3617618B1EB362D10B0D1BAC6A",
65
+ "E1ED9E8D280BBE0B6656748FD647231851C6C650794D5E6852DFA1E35E68630F",
66
+ ],
67
+ LedgerEntryType: "DirectoryNode",
68
+ Owner: "rHzDaMNybxQppiE3uWyt2N265KvAKdiRdP",
69
+ RootIndex: "0CB3C1AD2C371136AEA434246D971C5FCCD32CBF520667E131AB7B10D706E752",
70
+ index: "0B4A2E68C111F7E42FAEEE405F7344560C8240840B151D9D04131EB79D080167",
71
+ };
72
+
73
+ const binaryEntry2 =
74
+ "1100722200210000250178D1CA37000000000000000038000000000000028355C0C37CE200B509E0A529880634F7841A9EF4CB65F03C12E6004CFAD9718D66946280000000000000000000000000000000000000004743420000000000000000000000000000000000000000000000000166D6071AFD498D000000000000000000000000000047434200000000002599D1D255BCA61189CA64C84528F2FCBE4BFC3867800000000000000000000000000000000000000047434200000000006EEBB1D1852CE667876A0B3630861FB6C6AB358E";
75
+ const jsonEntry2 = {
76
+ Balance: {
77
+ currency: "GCB",
78
+ issuer: "rrrrrrrrrrrrrrrrrrrrBZbvji",
79
+ value: "0",
80
+ },
81
+ Flags: 2162688,
82
+ HighLimit: {
83
+ currency: "GCB",
84
+ issuer: "rBfVgTnsdh8ckC19RM8aVGNuMZnpwrMP6n",
85
+ value: "0",
86
+ },
87
+ HighNode: "283",
88
+ LedgerEntryType: "RippleState",
89
+ LowLimit: {
90
+ currency: "GCB",
91
+ issuer: "rhRFGCy2RJTA8oxkjjtYTvofPVGqcgvXWj",
92
+ value: "2000000",
93
+ },
94
+ LowNode: "0",
95
+ PreviousTxnID:
96
+ "C0C37CE200B509E0A529880634F7841A9EF4CB65F03C12E6004CFAD9718D6694",
97
+ PreviousTxnLgrSeq: 24695242,
98
+ index: "0000041EFD027808D3F78C8352F97E324CB816318E00B977C74ECDDC7CD975B2",
99
+ };
100
+
30
101
  test("compareToTests[0]", () => {
31
102
  expect(UInt8.from(124).compareTo(UInt64.from(124))).toBe(0);
32
103
  });
@@ -64,6 +135,12 @@ test("UInt64 from string zero", () => {
64
135
  expect(encode(json)).toEqual(binary);
65
136
  });
66
137
 
138
+ test("UInt64 from non 16 length hex", () => {
139
+ expect(encode(jsonEntry0)).toEqual(binaryEntry0);
140
+ expect(encode(jsonEntry1)).toEqual(binaryEntry1);
141
+ expect(encode(jsonEntry2)).toEqual(binaryEntry2);
142
+ });
143
+
67
144
  test("valueOfTests", () => {
68
145
  let val = UInt8.from(1);
69
146
  val |= 0x2;
package/HISTORY.md DELETED
@@ -1,86 +0,0 @@
1
- # ripple-binary-codec Release History
2
-
3
- ## 1.1.2 (2021-03-10)
4
- - Fix for case UInt64.from string '0' due to changes in rippled 1.7.0
5
-
6
- ## 1.1.1 (2021-02-12)
7
- - PathSet.toJSON() does not return undefined values
8
- - Add support for X-Addresses in Issued Currency Amounts
9
- - Fix STArray error message
10
-
11
- ## 1.1.0 (2020-12-03)
12
- - Add support for Tickets (TicketBatch amendment)
13
- - Fix web browser compatibility
14
-
15
- ## 1.0.2 (2020-09-11)
16
- - Allow currencies to be encoded from any 3 character ASCII code
17
-
18
- ## 1.0.1 (2020-09-08)
19
- - Filter out fields with undefined values
20
-
21
- ## 1.0.0 (2020-08-17)
22
-
23
- - Migrate to TypeScript
24
- - Javascript classes used
25
- - Generics for constructing core types
26
- - Reduced dependencies
27
- - Dependent on create-hash, decimal.js, ripple-address-codec
28
- - Migrate testing to Jest and added tests
29
- - Tests for pseudo-transactions
30
- - Added support for NegativeUNL pseudo-transactions
31
-
32
- ## 0.2.6 (2019-12-31)
33
-
34
- - Update dependencies
35
- - decimal.js, fs-extra, mocha, handlebars, bn.js, babel-eslint, ripple-address-codec
36
-
37
- ## 0.2.5 (2019-12-14)
38
-
39
- - Add support for AccountDelete (#37)
40
-
41
- ## 0.2.4 (2019-09-04)
42
-
43
- - Update ripple-address-codec to 3.0.4
44
-
45
- ## 0.2.3 (2019-08-29)
46
-
47
- - Expand node version compatibility (#32, #33)
48
-
49
- ## 0.2.2 (2019-07-26)
50
-
51
- - Input validation - Amount and Fee should not allow fractional XRP drops ([#31](https://github.com/ripple/ripple-binary-codec/issues/31))
52
- - Fix lint errors
53
- - Update dependencies (including lodash and mocha)
54
- - Require node 10 (.nvmrc)
55
- - Remove assert-diff
56
- - Remove codecov.io as it did not appear to work. The `package.json` script was:
57
- - `"codecov": "cat ./coverage/coverage.json | ./node_modules/codecov.io/bin/codecov.io.js"`
58
-
59
- ## 0.2.1
60
-
61
- - Add tecKILLED from amendment fix1578 (PR #27 fixes #25)
62
-
63
- ## 0.2.0
64
-
65
- - Add DepositPreauth fields
66
- - https://developers.ripple.com/depositauth.html
67
-
68
- ## 0.1.14
69
-
70
- - Skip amount validation when deserializing f72c115
71
-
72
- ## 0.1.13
73
-
74
- - Add Check, CheckCreate, CheckCash, CheckCancel
75
-
76
- ## 0.1.11
77
-
78
- - Add ledger header decode function
79
-
80
- ## 0.1.8
81
-
82
- ## 0.1.7
83
-
84
- ## 0.1.6
85
-
86
- ## 0.1.3