@transia/ripple-binary-codec 1.4.4-alpha.0

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 (164) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +107 -0
  3. package/dist/binary.d.ts +91 -0
  4. package/dist/binary.js +128 -0
  5. package/dist/binary.js.map +1 -0
  6. package/dist/coretypes.d.ts +9 -0
  7. package/dist/coretypes.js +48 -0
  8. package/dist/coretypes.js.map +1 -0
  9. package/dist/enums/bytes.d.ts +26 -0
  10. package/dist/enums/bytes.js +64 -0
  11. package/dist/enums/bytes.js.map +1 -0
  12. package/dist/enums/constants.d.ts +4 -0
  13. package/dist/enums/constants.js +8 -0
  14. package/dist/enums/constants.js.map +1 -0
  15. package/dist/enums/definitions.json +2476 -0
  16. package/dist/enums/field.d.ts +29 -0
  17. package/dist/enums/field.js +59 -0
  18. package/dist/enums/field.js.map +1 -0
  19. package/dist/enums/index.d.ts +13 -0
  20. package/dist/enums/index.js +53 -0
  21. package/dist/enums/index.js.map +1 -0
  22. package/dist/enums/src/enums/definitions.json +2481 -0
  23. package/dist/enums/utils-renumber.d.ts +101 -0
  24. package/dist/enums/utils-renumber.js +127 -0
  25. package/dist/enums/utils-renumber.js.map +1 -0
  26. package/dist/enums/xrpl-definitions-base.d.ts +45 -0
  27. package/dist/enums/xrpl-definitions-base.js +63 -0
  28. package/dist/enums/xrpl-definitions-base.js.map +1 -0
  29. package/dist/enums/xrpl-definitions.d.ts +21 -0
  30. package/dist/enums/xrpl-definitions.js +29 -0
  31. package/dist/enums/xrpl-definitions.js.map +1 -0
  32. package/dist/hash-prefixes.d.ts +6 -0
  33. package/dist/hash-prefixes.js +41 -0
  34. package/dist/hash-prefixes.js.map +1 -0
  35. package/dist/hashes.d.ts +51 -0
  36. package/dist/hashes.js +77 -0
  37. package/dist/hashes.js.map +1 -0
  38. package/dist/index.d.ts +64 -0
  39. package/dist/index.js +139 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/ledger-hashes.d.ts +49 -0
  42. package/dist/ledger-hashes.js +160 -0
  43. package/dist/ledger-hashes.js.map +1 -0
  44. package/dist/quality.d.ts +22 -0
  45. package/dist/quality.js +40 -0
  46. package/dist/quality.js.map +1 -0
  47. package/dist/serdes/binary-parser.d.ts +101 -0
  48. package/dist/serdes/binary-parser.js +210 -0
  49. package/dist/serdes/binary-parser.js.map +1 -0
  50. package/dist/serdes/binary-serializer.d.ts +82 -0
  51. package/dist/serdes/binary-serializer.js +172 -0
  52. package/dist/serdes/binary-serializer.js.map +1 -0
  53. package/dist/shamap.d.ts +103 -0
  54. package/dist/shamap.js +172 -0
  55. package/dist/shamap.js.map +1 -0
  56. package/dist/types/account-id.d.ts +36 -0
  57. package/dist/types/account-id.js +71 -0
  58. package/dist/types/account-id.js.map +1 -0
  59. package/dist/types/amount.d.ts +68 -0
  60. package/dist/types/amount.js +207 -0
  61. package/dist/types/amount.js.map +1 -0
  62. package/dist/types/blob.d.ts +25 -0
  63. package/dist/types/blob.js +40 -0
  64. package/dist/types/blob.js.map +1 -0
  65. package/dist/types/currency.d.ts +29 -0
  66. package/dist/types/currency.js +127 -0
  67. package/dist/types/currency.js.map +1 -0
  68. package/dist/types/hash-128.d.ts +17 -0
  69. package/dist/types/hash-128.js +32 -0
  70. package/dist/types/hash-128.js.map +1 -0
  71. package/dist/types/hash-160.d.ts +11 -0
  72. package/dist/types/hash-160.js +20 -0
  73. package/dist/types/hash-160.js.map +1 -0
  74. package/dist/types/hash-256.d.ts +11 -0
  75. package/dist/types/hash-256.js +17 -0
  76. package/dist/types/hash-256.js.map +1 -0
  77. package/dist/types/hash.d.ts +41 -0
  78. package/dist/types/hash.js +72 -0
  79. package/dist/types/hash.js.map +1 -0
  80. package/dist/types/index.d.ts +18 -0
  81. package/dist/types/index.js +57 -0
  82. package/dist/types/index.js.map +1 -0
  83. package/dist/types/issue.d.ts +39 -0
  84. package/dist/types/issue.js +81 -0
  85. package/dist/types/issue.js.map +1 -0
  86. package/dist/types/path-set.d.ts +36 -0
  87. package/dist/types/path-set.js +233 -0
  88. package/dist/types/path-set.js.map +1 -0
  89. package/dist/types/serialized-type.d.ts +63 -0
  90. package/dist/types/serialized-type.js +97 -0
  91. package/dist/types/serialized-type.js.map +1 -0
  92. package/dist/types/st-array.d.ts +28 -0
  93. package/dist/types/st-array.js +80 -0
  94. package/dist/types/st-array.js.map +1 -0
  95. package/dist/types/st-object.d.ts +32 -0
  96. package/dist/types/st-object.js +149 -0
  97. package/dist/types/st-object.js.map +1 -0
  98. package/dist/types/uint-16.d.ts +25 -0
  99. package/dist/types/uint-16.js +44 -0
  100. package/dist/types/uint-16.js.map +1 -0
  101. package/dist/types/uint-32.d.ts +25 -0
  102. package/dist/types/uint-32.js +49 -0
  103. package/dist/types/uint-32.js.map +1 -0
  104. package/dist/types/uint-64.d.ts +39 -0
  105. package/dist/types/uint-64.js +87 -0
  106. package/dist/types/uint-64.js.map +1 -0
  107. package/dist/types/uint-8.d.ts +25 -0
  108. package/dist/types/uint-8.js +44 -0
  109. package/dist/types/uint-8.js.map +1 -0
  110. package/dist/types/uint.d.ts +30 -0
  111. package/dist/types/uint.js +42 -0
  112. package/dist/types/uint.js.map +1 -0
  113. package/dist/types/vector-256.d.ts +31 -0
  114. package/dist/types/vector-256.js +75 -0
  115. package/dist/types/vector-256.js.map +1 -0
  116. package/package.json +47 -0
  117. package/test/amount.test.js +43 -0
  118. package/test/binary-json.test.js +45 -0
  119. package/test/binary-parser.test.js +396 -0
  120. package/test/binary-serializer.test.js +289 -0
  121. package/test/definitions.test.js +100 -0
  122. package/test/fixtures/account-tx-transactions.db +0 -0
  123. package/test/fixtures/codec-fixtures.json +4466 -0
  124. package/test/fixtures/data-driven-tests.json +2919 -0
  125. package/test/fixtures/delivermin-tx-binary.json +1 -0
  126. package/test/fixtures/delivermin-tx.json +98 -0
  127. package/test/fixtures/deposit-preauth-tx-binary.json +1 -0
  128. package/test/fixtures/deposit-preauth-tx-meta-binary.json +1 -0
  129. package/test/fixtures/deposit-preauth-tx.json +58 -0
  130. package/test/fixtures/escrow-cancel-binary.json +1 -0
  131. package/test/fixtures/escrow-cancel-tx.json +6 -0
  132. package/test/fixtures/escrow-create-binary.json +1 -0
  133. package/test/fixtures/escrow-create-tx.json +10 -0
  134. package/test/fixtures/escrow-finish-binary.json +1 -0
  135. package/test/fixtures/escrow-finish-meta-binary.json +1 -0
  136. package/test/fixtures/escrow-finish-tx.json +95 -0
  137. package/test/fixtures/ledger-full-38129.json +1 -0
  138. package/test/fixtures/ledger-full-40000.json +1 -0
  139. package/test/fixtures/negative-unl.json +12 -0
  140. package/test/fixtures/nf-token.json +547 -0
  141. package/test/fixtures/payment-channel-claim-binary.json +1 -0
  142. package/test/fixtures/payment-channel-claim-tx.json +8 -0
  143. package/test/fixtures/payment-channel-create-binary.json +1 -0
  144. package/test/fixtures/payment-channel-create-tx.json +11 -0
  145. package/test/fixtures/payment-channel-fund-binary.json +1 -0
  146. package/test/fixtures/payment-channel-fund-tx.json +7 -0
  147. package/test/fixtures/signerlistset-tx-binary.json +1 -0
  148. package/test/fixtures/signerlistset-tx-meta-binary.json +1 -0
  149. package/test/fixtures/signerlistset-tx.json +94 -0
  150. package/test/fixtures/ticket-create-binary.json +1 -0
  151. package/test/fixtures/ticket-create-tx.json +7 -0
  152. package/test/fixtures/x-codec-fixtures.json +188 -0
  153. package/test/hash.test.js +135 -0
  154. package/test/ledger.test.js +29 -0
  155. package/test/lower-case-hex.test.js +46 -0
  156. package/test/pseudo-transaction.test.js +38 -0
  157. package/test/quality.test.js +15 -0
  158. package/test/shamap.test.js +89 -0
  159. package/test/signing-data-encoding.test.js +242 -0
  160. package/test/tx-encode-decode.test.js +119 -0
  161. package/test/types.test.js +34 -0
  162. package/test/uint.test.js +148 -0
  163. package/test/utils.js +30 -0
  164. package/test/x-address.test.js +181 -0
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PathSet = void 0;
4
+ const account_id_1 = require("./account-id");
5
+ const currency_1 = require("./currency");
6
+ const binary_parser_1 = require("../serdes/binary-parser");
7
+ const serialized_type_1 = require("./serialized-type");
8
+ const buffer_1 = require("buffer/");
9
+ /**
10
+ * Constants for separating Paths in a PathSet
11
+ */
12
+ const PATHSET_END_BYTE = 0x00;
13
+ const PATH_SEPARATOR_BYTE = 0xff;
14
+ /**
15
+ * Constant for masking types of a Hop
16
+ */
17
+ const TYPE_ACCOUNT = 0x01;
18
+ const TYPE_CURRENCY = 0x10;
19
+ const TYPE_ISSUER = 0x20;
20
+ /**
21
+ * TypeGuard for HopObject
22
+ */
23
+ function isHopObject(arg) {
24
+ return (arg.issuer !== undefined ||
25
+ arg.account !== undefined ||
26
+ arg.currency !== undefined);
27
+ }
28
+ /**
29
+ * TypeGuard for PathSet
30
+ */
31
+ function isPathSet(arg) {
32
+ return ((Array.isArray(arg) && arg.length === 0) ||
33
+ (Array.isArray(arg) && Array.isArray(arg[0]) && arg[0].length === 0) ||
34
+ (Array.isArray(arg) && Array.isArray(arg[0]) && isHopObject(arg[0][0])));
35
+ }
36
+ /**
37
+ * Serialize and Deserialize a Hop
38
+ */
39
+ class Hop extends serialized_type_1.SerializedType {
40
+ /**
41
+ * Create a Hop from a HopObject
42
+ *
43
+ * @param value Either a hop or HopObject to create a hop with
44
+ * @returns a Hop
45
+ */
46
+ static from(value) {
47
+ if (value instanceof Hop) {
48
+ return value;
49
+ }
50
+ const bytes = [buffer_1.Buffer.from([0])];
51
+ if (value.account) {
52
+ bytes.push(account_id_1.AccountID.from(value.account).toBytes());
53
+ bytes[0][0] |= TYPE_ACCOUNT;
54
+ }
55
+ if (value.currency) {
56
+ bytes.push(currency_1.Currency.from(value.currency).toBytes());
57
+ bytes[0][0] |= TYPE_CURRENCY;
58
+ }
59
+ if (value.issuer) {
60
+ bytes.push(account_id_1.AccountID.from(value.issuer).toBytes());
61
+ bytes[0][0] |= TYPE_ISSUER;
62
+ }
63
+ return new Hop(buffer_1.Buffer.concat(bytes));
64
+ }
65
+ /**
66
+ * Construct a Hop from a BinaryParser
67
+ *
68
+ * @param parser BinaryParser to read the Hop from
69
+ * @returns a Hop
70
+ */
71
+ static fromParser(parser) {
72
+ const type = parser.readUInt8();
73
+ const bytes = [buffer_1.Buffer.from([type])];
74
+ if (type & TYPE_ACCOUNT) {
75
+ bytes.push(parser.read(account_id_1.AccountID.width));
76
+ }
77
+ if (type & TYPE_CURRENCY) {
78
+ bytes.push(parser.read(currency_1.Currency.width));
79
+ }
80
+ if (type & TYPE_ISSUER) {
81
+ bytes.push(parser.read(account_id_1.AccountID.width));
82
+ }
83
+ return new Hop(buffer_1.Buffer.concat(bytes));
84
+ }
85
+ /**
86
+ * Get the JSON interpretation of this hop
87
+ *
88
+ * @returns a HopObject, an JS object with optional account, issuer, and currency
89
+ */
90
+ toJSON() {
91
+ const hopParser = new binary_parser_1.BinaryParser(this.bytes.toString('hex'));
92
+ const type = hopParser.readUInt8();
93
+ let account, currency, issuer;
94
+ if (type & TYPE_ACCOUNT) {
95
+ account = account_id_1.AccountID.fromParser(hopParser).toJSON();
96
+ }
97
+ if (type & TYPE_CURRENCY) {
98
+ currency = currency_1.Currency.fromParser(hopParser).toJSON();
99
+ }
100
+ if (type & TYPE_ISSUER) {
101
+ issuer = account_id_1.AccountID.fromParser(hopParser).toJSON();
102
+ }
103
+ const result = {};
104
+ if (account) {
105
+ result.account = account;
106
+ }
107
+ if (issuer) {
108
+ result.issuer = issuer;
109
+ }
110
+ if (currency) {
111
+ result.currency = currency;
112
+ }
113
+ return result;
114
+ }
115
+ /**
116
+ * get a number representing the type of this hop
117
+ *
118
+ * @returns a number to be bitwise and-ed with TYPE_ constants to describe the types in the hop
119
+ */
120
+ type() {
121
+ return this.bytes[0];
122
+ }
123
+ }
124
+ /**
125
+ * Class for serializing/deserializing Paths
126
+ */
127
+ class Path extends serialized_type_1.SerializedType {
128
+ /**
129
+ * construct a Path from an array of Hops
130
+ *
131
+ * @param value Path or array of HopObjects to construct a Path
132
+ * @returns the Path
133
+ */
134
+ static from(value) {
135
+ if (value instanceof Path) {
136
+ return value;
137
+ }
138
+ const bytes = [];
139
+ value.forEach((hop) => {
140
+ bytes.push(Hop.from(hop).toBytes());
141
+ });
142
+ return new Path(buffer_1.Buffer.concat(bytes));
143
+ }
144
+ /**
145
+ * Read a Path from a BinaryParser
146
+ *
147
+ * @param parser BinaryParser to read Path from
148
+ * @returns the Path represented by the bytes read from the BinaryParser
149
+ */
150
+ static fromParser(parser) {
151
+ const bytes = [];
152
+ while (!parser.end()) {
153
+ bytes.push(Hop.fromParser(parser).toBytes());
154
+ if (parser.peek() === PATHSET_END_BYTE ||
155
+ parser.peek() === PATH_SEPARATOR_BYTE) {
156
+ break;
157
+ }
158
+ }
159
+ return new Path(buffer_1.Buffer.concat(bytes));
160
+ }
161
+ /**
162
+ * Get the JSON representation of this Path
163
+ *
164
+ * @returns an Array of HopObject constructed from this.bytes
165
+ */
166
+ toJSON() {
167
+ const json = [];
168
+ const pathParser = new binary_parser_1.BinaryParser(this.toString());
169
+ while (!pathParser.end()) {
170
+ json.push(Hop.fromParser(pathParser).toJSON());
171
+ }
172
+ return json;
173
+ }
174
+ }
175
+ /**
176
+ * Deserialize and Serialize the PathSet type
177
+ */
178
+ class PathSet extends serialized_type_1.SerializedType {
179
+ /**
180
+ * Construct a PathSet from an Array of Arrays representing paths
181
+ *
182
+ * @param value A PathSet or Array of Array of HopObjects
183
+ * @returns the PathSet constructed from value
184
+ */
185
+ static from(value) {
186
+ if (value instanceof PathSet) {
187
+ return value;
188
+ }
189
+ if (isPathSet(value)) {
190
+ const bytes = [];
191
+ value.forEach((path) => {
192
+ bytes.push(Path.from(path).toBytes());
193
+ bytes.push(buffer_1.Buffer.from([PATH_SEPARATOR_BYTE]));
194
+ });
195
+ bytes[bytes.length - 1] = buffer_1.Buffer.from([PATHSET_END_BYTE]);
196
+ return new PathSet(buffer_1.Buffer.concat(bytes));
197
+ }
198
+ throw new Error('Cannot construct PathSet from given value');
199
+ }
200
+ /**
201
+ * Construct a PathSet from a BinaryParser
202
+ *
203
+ * @param parser A BinaryParser to read PathSet from
204
+ * @returns the PathSet read from parser
205
+ */
206
+ static fromParser(parser) {
207
+ const bytes = [];
208
+ while (!parser.end()) {
209
+ bytes.push(Path.fromParser(parser).toBytes());
210
+ bytes.push(parser.read(1));
211
+ if (bytes[bytes.length - 1][0] == PATHSET_END_BYTE) {
212
+ break;
213
+ }
214
+ }
215
+ return new PathSet(buffer_1.Buffer.concat(bytes));
216
+ }
217
+ /**
218
+ * Get the JSON representation of this PathSet
219
+ *
220
+ * @returns an Array of Array of HopObjects, representing this PathSet
221
+ */
222
+ toJSON() {
223
+ const json = [];
224
+ const pathParser = new binary_parser_1.BinaryParser(this.toString());
225
+ while (!pathParser.end()) {
226
+ json.push(Path.fromParser(pathParser).toJSON());
227
+ pathParser.skip(1);
228
+ }
229
+ return json;
230
+ }
231
+ }
232
+ exports.PathSet = PathSet;
233
+ //# sourceMappingURL=path-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-set.js","sourceRoot":"","sources":["../../src/types/path-set.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AACxC,yCAAqC;AACrC,2DAAsD;AACtD,uDAA8D;AAC9D,oCAAgC;AAEhC;;GAEG;AACH,MAAM,gBAAgB,GAAG,IAAI,CAAA;AAC7B,MAAM,mBAAmB,GAAG,IAAI,CAAA;AAEhC;;GAEG;AACH,MAAM,YAAY,GAAG,IAAI,CAAA;AACzB,MAAM,aAAa,GAAG,IAAI,CAAA;AAC1B,MAAM,WAAW,GAAG,IAAI,CAAA;AAWxB;;GAEG;AACH,SAAS,WAAW,CAAC,GAAG;IACtB,OAAO,CACL,GAAG,CAAC,MAAM,KAAK,SAAS;QACxB,GAAG,CAAC,OAAO,KAAK,SAAS;QACzB,GAAG,CAAC,QAAQ,KAAK,SAAS,CAC3B,CAAA;AACH,CAAC;AAED;;GAEG;AACH,SAAS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-serializer';
2
+ import { BinaryParser } from '../serdes/binary-parser';
3
+ import bigInt = require('big-integer');
4
+ import { Buffer } from 'buffer/';
5
+ type JSON = string | number | boolean | null | undefined | JSON[] | JsonObject;
6
+ type JsonObject = {
7
+ [key: string]: JSON;
8
+ };
9
+ /**
10
+ * The base class for all binary-codec types
11
+ */
12
+ declare class SerializedType {
13
+ protected readonly bytes: Buffer;
14
+ constructor(bytes: Buffer);
15
+ static fromParser(parser: BinaryParser, hint?: number): SerializedType;
16
+ static from(value: SerializedType | JSON | bigInt.BigInteger): SerializedType;
17
+ /**
18
+ * Write the bytes representation of a SerializedType to a BytesList
19
+ *
20
+ * @param list The BytesList to write SerializedType bytes to
21
+ */
22
+ toBytesSink(list: BytesList): void;
23
+ /**
24
+ * Get the hex representation of a SerializedType's bytes
25
+ *
26
+ * @returns hex String of this.bytes
27
+ */
28
+ toHex(): string;
29
+ /**
30
+ * Get the bytes representation of a SerializedType
31
+ *
32
+ * @returns A buffer of the bytes
33
+ */
34
+ toBytes(): Buffer;
35
+ /**
36
+ * Return the JSON representation of a SerializedType
37
+ *
38
+ * @returns any type, if not overloaded returns hexString representation of bytes
39
+ */
40
+ toJSON(): JSON;
41
+ /**
42
+ * @returns hexString representation of this.bytes
43
+ */
44
+ toString(): string;
45
+ }
46
+ /**
47
+ * Base class for SerializedTypes that are comparable
48
+ */
49
+ declare class Comparable extends SerializedType {
50
+ lt(other: Comparable): boolean;
51
+ eq(other: Comparable): boolean;
52
+ gt(other: Comparable): boolean;
53
+ gte(other: Comparable): boolean;
54
+ lte(other: Comparable): boolean;
55
+ /**
56
+ * Overload this method to define how two Comparable SerializedTypes are compared
57
+ *
58
+ * @param other The comparable object to compare this to
59
+ * @returns A number denoting the relationship of this and other
60
+ */
61
+ compareTo(other: Comparable): number;
62
+ }
63
+ export { SerializedType, Comparable, JSON, JsonObject };
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Comparable = exports.SerializedType = void 0;
4
+ const binary_serializer_1 = require("../serdes/binary-serializer");
5
+ const buffer_1 = require("buffer/");
6
+ /**
7
+ * The base class for all binary-codec types
8
+ */
9
+ class SerializedType {
10
+ constructor(bytes) {
11
+ this.bytes = buffer_1.Buffer.alloc(0);
12
+ this.bytes = bytes !== null && bytes !== void 0 ? bytes : buffer_1.Buffer.alloc(0);
13
+ }
14
+ static fromParser(parser, hint) {
15
+ throw new Error('fromParser not implemented');
16
+ return this.fromParser(parser, hint);
17
+ }
18
+ static from(value) {
19
+ throw new Error('from not implemented');
20
+ return this.from(value);
21
+ }
22
+ /**
23
+ * Write the bytes representation of a SerializedType to a BytesList
24
+ *
25
+ * @param list The BytesList to write SerializedType bytes to
26
+ */
27
+ toBytesSink(list) {
28
+ list.put(this.bytes);
29
+ }
30
+ /**
31
+ * Get the hex representation of a SerializedType's bytes
32
+ *
33
+ * @returns hex String of this.bytes
34
+ */
35
+ toHex() {
36
+ return this.toBytes().toString('hex').toUpperCase();
37
+ }
38
+ /**
39
+ * Get the bytes representation of a SerializedType
40
+ *
41
+ * @returns A buffer of the bytes
42
+ */
43
+ toBytes() {
44
+ if (this.bytes) {
45
+ return this.bytes;
46
+ }
47
+ const bytes = new binary_serializer_1.BytesList();
48
+ this.toBytesSink(bytes);
49
+ return bytes.toBytes();
50
+ }
51
+ /**
52
+ * Return the JSON representation of a SerializedType
53
+ *
54
+ * @returns any type, if not overloaded returns hexString representation of bytes
55
+ */
56
+ toJSON() {
57
+ return this.toHex();
58
+ }
59
+ /**
60
+ * @returns hexString representation of this.bytes
61
+ */
62
+ toString() {
63
+ return this.toHex();
64
+ }
65
+ }
66
+ exports.SerializedType = SerializedType;
67
+ /**
68
+ * Base class for SerializedTypes that are comparable
69
+ */
70
+ class Comparable extends SerializedType {
71
+ lt(other) {
72
+ return this.compareTo(other) < 0;
73
+ }
74
+ eq(other) {
75
+ return this.compareTo(other) === 0;
76
+ }
77
+ gt(other) {
78
+ return this.compareTo(other) > 0;
79
+ }
80
+ gte(other) {
81
+ return this.compareTo(other) > -1;
82
+ }
83
+ lte(other) {
84
+ return this.compareTo(other) < 1;
85
+ }
86
+ /**
87
+ * Overload this method to define how two Comparable SerializedTypes are compared
88
+ *
89
+ * @param other The comparable object to compare this to
90
+ * @returns A number denoting the relationship of this and other
91
+ */
92
+ compareTo(other) {
93
+ throw new Error(`cannot compare ${this.toString()} and ${other.toString()}`);
94
+ }
95
+ }
96
+ exports.Comparable = Comparable;
97
+ //# sourceMappingURL=serialized-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialized-type.js","sourceRoot":"","sources":["../../src/types/serialized-type.ts"],"names":[],"mappings":";;;AAAA,mEAAuD;AAGvD,oCAAgC;AAMhC;;GAEG;AACH,MAAM,cAAc;IAGlB,YAAY,KAAa;QAFN,UAAK,GAAW,eAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAGhD,IAAI,CAAC,KAAK,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,eAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACvC,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,MAAoB,EAAE,IAAa;QACnD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAC7C,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACtC,CAAC;IAED,MAAM,CAAC,IAAI,CACT,KAAgD;QAEhD,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACzB,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,IAAe;QACzB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IAED;;;;OAIG;IACH,KAAK;QACH,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAA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ializedType, JsonObject } from './serialized-type';
2
+ import { BinaryParser } from '../serdes/binary-parser';
3
+ /**
4
+ * Class for serializing and deserializing Arrays of Objects
5
+ */
6
+ declare class STArray extends SerializedType {
7
+ /**
8
+ * Construct an STArray from a BinaryParser
9
+ *
10
+ * @param parser BinaryParser to parse an STArray from
11
+ * @returns An STArray Object
12
+ */
13
+ static fromParser(parser: BinaryParser): STArray;
14
+ /**
15
+ * Construct an STArray from an Array of JSON Objects
16
+ *
17
+ * @param value STArray or Array of Objects to parse into an STArray
18
+ * @returns An STArray object
19
+ */
20
+ static from<T extends STArray | Array<JsonObject>>(value: T): STArray;
21
+ /**
22
+ * Return the JSON representation of this.bytes
23
+ *
24
+ * @returns An Array of JSON objects
25
+ */
26
+ toJSON(): Array<JsonObject>;
27
+ }
28
+ export { STArray };
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STArray = void 0;
4
+ const serialized_type_1 = require("./serialized-type");
5
+ const st_object_1 = require("./st-object");
6
+ const binary_parser_1 = require("../serdes/binary-parser");
7
+ const buffer_1 = require("buffer/");
8
+ const ARRAY_END_MARKER = buffer_1.Buffer.from([0xf1]);
9
+ const ARRAY_END_MARKER_NAME = 'ArrayEndMarker';
10
+ const OBJECT_END_MARKER = buffer_1.Buffer.from([0xe1]);
11
+ /**
12
+ * TypeGuard for Array<JsonObject>
13
+ */
14
+ function isObjects(args) {
15
+ return (Array.isArray(args) && (args.length === 0 || typeof args[0] === 'object'));
16
+ }
17
+ /**
18
+ * Class for serializing and deserializing Arrays of Objects
19
+ */
20
+ class STArray extends serialized_type_1.SerializedType {
21
+ /**
22
+ * Construct an STArray from a BinaryParser
23
+ *
24
+ * @param parser BinaryParser to parse an STArray from
25
+ * @returns An STArray Object
26
+ */
27
+ static fromParser(parser) {
28
+ const bytes = [];
29
+ while (!parser.end()) {
30
+ const field = parser.readField();
31
+ if (field.name === ARRAY_END_MARKER_NAME) {
32
+ break;
33
+ }
34
+ bytes.push(field.header, parser.readFieldValue(field).toBytes(), OBJECT_END_MARKER);
35
+ }
36
+ bytes.push(ARRAY_END_MARKER);
37
+ return new STArray(buffer_1.Buffer.concat(bytes));
38
+ }
39
+ /**
40
+ * Construct an STArray from an Array of JSON Objects
41
+ *
42
+ * @param value STArray or Array of Objects to parse into an STArray
43
+ * @returns An STArray object
44
+ */
45
+ static from(value) {
46
+ if (value instanceof STArray) {
47
+ return value;
48
+ }
49
+ if (isObjects(value)) {
50
+ const bytes = [];
51
+ value.forEach((obj) => {
52
+ bytes.push(st_object_1.STObject.from(obj).toBytes());
53
+ });
54
+ bytes.push(ARRAY_END_MARKER);
55
+ return new STArray(buffer_1.Buffer.concat(bytes));
56
+ }
57
+ throw new Error('Cannot construct STArray from value given');
58
+ }
59
+ /**
60
+ * Return the JSON representation of this.bytes
61
+ *
62
+ * @returns An Array of JSON objects
63
+ */
64
+ toJSON() {
65
+ const result = [];
66
+ const arrayParser = new binary_parser_1.BinaryParser(this.toString());
67
+ while (!arrayParser.end()) {
68
+ const field = arrayParser.readField();
69
+ if (field.name === ARRAY_END_MARKER_NAME) {
70
+ break;
71
+ }
72
+ const outer = {};
73
+ outer[field.name] = st_object_1.STObject.fromParser(arrayParser).toJSON();
74
+ result.push(outer);
75
+ }
76
+ return result;
77
+ }
78
+ }
79
+ exports.STArray = STArray;
80
+ //# sourceMappingURL=st-array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"st-array.js","sourceRoot":"","sources":["../../src/types/st-array.ts"],"names":[],"mappings":";;;AAAA,uDAA8D;AAC9D,2CAAsC;AACtC,2DAAsD;AACtD,oCAAgC;AAEhC,MAAM,gBAAgB,GAAG,eAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;AAC5C,MAAM,qBAAqB,GAAG,gBAAgB,CAAA;AAE9C,MAAM,iBAAiB,GAAG,eAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;AAE7C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,OAAO,IAAI,OAAO,CAAC,eAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;SACzC;QAED,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;IAC9D,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,MAAM,MAAM,GAAsB,EAAE,CAAA;QAEpC,MAAM,WAAW,GAAG,IAAI,4BAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;QAErD,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE;YACzB,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,EAAE,CAAA;YACrC,IAAI,KAAK,CAAC,IAAI,KAAK,qBAAqB,EAAE;gBACxC,MAAK;aACN;YAED,MAAM,KAAK,GAAG,EAAE,CAAA;YAChB,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,oBAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,CAAA;YAC7D,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;SACnB;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAEQ,0BAAO"}
@@ -0,0 +1,32 @@
1
+ import { XrplDefinitionsBase } from '../enums';
2
+ import { SerializedType, JsonObject } from './serialized-type';
3
+ import { BinaryParser } from '../serdes/binary-parser';
4
+ /**
5
+ * Class for Serializing/Deserializing objects
6
+ */
7
+ declare class STObject extends SerializedType {
8
+ /**
9
+ * Construct a STObject from a BinaryParser
10
+ *
11
+ * @param parser BinaryParser to read STObject from
12
+ * @returns A STObject object
13
+ */
14
+ static fromParser(parser: BinaryParser): STObject;
15
+ /**
16
+ * Construct a STObject from a JSON object
17
+ *
18
+ * @param value An object to include
19
+ * @param filter optional, denote which field to include in serialized object
20
+ * @param definitions optional, types and values to use to encode/decode a transaction
21
+ * @returns a STObject object
22
+ */
23
+ static from<T extends STObject | JsonObject>(value: T, filter?: (...any: any[]) => boolean, definitions?: XrplDefinitionsBase): STObject;
24
+ /**
25
+ * Get the JSON interpretation of this.bytes
26
+ * @param definitions rippled definitions used to parse the values of transaction types and such.
27
+ * Can be customized for sidechains and amendments.
28
+ * @returns a JSON object
29
+ */
30
+ toJSON(definitions?: XrplDefinitionsBase): JsonObject;
31
+ }
32
+ export { STObject };