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

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/dist/binary.d.ts +6 -6
  2. package/dist/binary.js.map +1 -1
  3. package/dist/coretypes.d.ts +8 -8
  4. package/dist/coretypes.js.map +1 -1
  5. package/dist/enums/index.d.ts +6 -5
  6. package/dist/enums/index.js +3 -2
  7. package/dist/enums/index.js.map +1 -1
  8. package/dist/enums/utils-renumber.js +12 -12
  9. package/dist/enums/utils-renumber.js.map +1 -1
  10. package/dist/hash-prefixes.d.ts +1 -1
  11. package/dist/hash-prefixes.js.map +1 -1
  12. package/dist/hashes.d.ts +3 -3
  13. package/dist/hashes.js +5 -4
  14. package/dist/hashes.js.map +1 -1
  15. package/dist/index.d.ts +2 -2
  16. package/dist/index.js +13 -13
  17. package/dist/index.js.map +1 -1
  18. package/dist/ledger-hashes.d.ts +3 -3
  19. package/dist/ledger-hashes.js +5 -5
  20. package/dist/ledger-hashes.js.map +1 -1
  21. package/dist/quality.d.ts +2 -2
  22. package/dist/quality.js +4 -4
  23. package/dist/quality.js.map +1 -1
  24. package/dist/serdes/binary-parser.d.ts +3 -3
  25. package/dist/serdes/binary-parser.js +10 -10
  26. package/dist/serdes/binary-parser.js.map +1 -1
  27. package/dist/serdes/binary-serializer.d.ts +5 -5
  28. package/dist/serdes/binary-serializer.js +13 -8
  29. package/dist/serdes/binary-serializer.js.map +1 -1
  30. package/dist/shamap.d.ts +3 -3
  31. package/dist/shamap.js +5 -3
  32. package/dist/shamap.js.map +1 -1
  33. package/dist/types/account-id.d.ts +2 -2
  34. package/dist/types/account-id.js +12 -10
  35. package/dist/types/account-id.js.map +1 -1
  36. package/dist/types/amount.d.ts +3 -3
  37. package/dist/types/amount.js +23 -21
  38. package/dist/types/amount.js.map +1 -1
  39. package/dist/types/blob.d.ts +3 -3
  40. package/dist/types/blob.js +6 -4
  41. package/dist/types/blob.js.map +1 -1
  42. package/dist/types/currency.d.ts +2 -2
  43. package/dist/types/currency.js +14 -12
  44. package/dist/types/currency.js.map +1 -1
  45. package/dist/types/hash-128.d.ts +2 -2
  46. package/dist/types/hash-128.js +3 -1
  47. package/dist/types/hash-128.js.map +1 -1
  48. package/dist/types/hash-160.d.ts +2 -2
  49. package/dist/types/hash-160.js +3 -1
  50. package/dist/types/hash-160.js.map +1 -1
  51. package/dist/types/hash-256.d.ts +2 -2
  52. package/dist/types/hash-256.js +3 -1
  53. package/dist/types/hash-256.js.map +1 -1
  54. package/dist/types/hash.d.ts +3 -3
  55. package/dist/types/hash.js +7 -5
  56. package/dist/types/hash.js.map +1 -1
  57. package/dist/types/index.d.ts +15 -15
  58. package/dist/types/index.js +3 -3
  59. package/dist/types/index.js.map +1 -1
  60. package/dist/types/path-set.d.ts +2 -2
  61. package/dist/types/path-set.js +5 -3
  62. package/dist/types/path-set.js.map +1 -1
  63. package/dist/types/serialized-type.d.ts +4 -4
  64. package/dist/types/serialized-type.js +7 -5
  65. package/dist/types/serialized-type.js.map +1 -1
  66. package/dist/types/st-array.d.ts +2 -2
  67. package/dist/types/st-array.js +6 -4
  68. package/dist/types/st-array.js.map +1 -1
  69. package/dist/types/st-object.d.ts +2 -2
  70. package/dist/types/st-object.js +25 -14
  71. package/dist/types/st-object.js.map +1 -1
  72. package/dist/types/uint-16.d.ts +3 -3
  73. package/dist/types/uint-16.js +5 -3
  74. package/dist/types/uint-16.js.map +1 -1
  75. package/dist/types/uint-32.d.ts +3 -3
  76. package/dist/types/uint-32.js +6 -4
  77. package/dist/types/uint-32.js.map +1 -1
  78. package/dist/types/uint-64.d.ts +4 -4
  79. package/dist/types/uint-64.js +12 -10
  80. package/dist/types/uint-64.js.map +1 -1
  81. package/dist/types/uint-8.d.ts +3 -3
  82. package/dist/types/uint-8.js +5 -3
  83. package/dist/types/uint-8.js.map +1 -1
  84. package/dist/types/uint.d.ts +3 -3
  85. package/dist/types/uint.js +4 -2
  86. package/dist/types/uint.js.map +1 -1
  87. package/dist/types/vector-256.d.ts +3 -3
  88. package/dist/types/vector-256.js +7 -5
  89. package/dist/types/vector-256.js.map +1 -1
  90. package/package.json +14 -29
  91. package/test/amount.test.js +29 -29
  92. package/test/binary-json.test.js +24 -26
  93. package/test/binary-parser.test.js +225 -227
  94. package/test/binary-serializer.test.js +194 -169
  95. package/test/fixtures/negative-unl.json +4 -4
  96. package/test/fixtures/nf-token.json +547 -0
  97. package/test/hash.test.js +85 -78
  98. package/test/ledger.test.js +19 -19
  99. package/test/lower-case-hex.test.js +28 -28
  100. package/test/pseudo-transaction.test.js +26 -26
  101. package/test/quality.test.js +13 -13
  102. package/test/shamap.test.js +54 -54
  103. package/test/signing-data-encoding.test.js +79 -79
  104. package/test/tx-encode-decode.test.js +63 -63
  105. package/test/types.test.js +23 -23
  106. package/test/uint.test.js +107 -107
  107. package/test/x-address.test.js +106 -106
  108. package/dist/ShaMap/ShaMap.d.ts +0 -3
  109. package/dist/ShaMap/ShaMap.js +0 -25
  110. package/dist/ShaMap/ShaMap.js.map +0 -1
  111. package/dist/ShaMap/ShaMapInner.d.ts +0 -66
  112. package/dist/ShaMap/ShaMapInner.js +0 -145
  113. package/dist/ShaMap/ShaMapInner.js.map +0 -1
  114. package/dist/ShaMap/ShaMapLeaf.d.ts +0 -42
  115. package/dist/ShaMap/ShaMapLeaf.js +0 -84
  116. package/dist/ShaMap/ShaMapLeaf.js.map +0 -1
  117. package/dist/ShaMap/ShaMapNode.d.ts +0 -13
  118. package/dist/ShaMap/ShaMapNode.js +0 -12
  119. package/dist/ShaMap/ShaMapNode.js.map +0 -1
  120. package/dist/ShaMap/index.d.ts +0 -3
  121. package/dist/ShaMap/index.js +0 -9
  122. package/dist/ShaMap/index.js.map +0 -1
  123. package/dist/enums/Bytes.d.ts +0 -10
  124. package/dist/enums/Bytes.js +0 -30
  125. package/dist/enums/Bytes.js.map +0 -1
  126. package/dist/enums/BytesLookup.d.ts +0 -8
  127. package/dist/enums/BytesLookup.js +0 -29
  128. package/dist/enums/BytesLookup.js.map +0 -1
  129. package/dist/enums/Field.d.ts +0 -3
  130. package/dist/enums/Field.js +0 -9
  131. package/dist/enums/Field.js.map +0 -1
  132. package/dist/enums/FieldInfo.d.ts +0 -7
  133. package/dist/enums/FieldInfo.js +0 -3
  134. package/dist/enums/FieldInfo.js.map +0 -1
  135. package/dist/enums/FieldInstance.d.ts +0 -14
  136. package/dist/enums/FieldInstance.js +0 -3
  137. package/dist/enums/FieldInstance.js.map +0 -1
  138. package/dist/enums/FieldLookup.d.ts +0 -11
  139. package/dist/enums/FieldLookup.js +0 -102
  140. package/dist/enums/FieldLookup.js.map +0 -1
  141. package/dist/serdes/BinaryParser.d.ts +0 -100
  142. package/dist/serdes/BinaryParser.js +0 -200
  143. package/dist/serdes/BinaryParser.js.map +0 -1
  144. package/dist/serdes/BinarySerializer.d.ts +0 -50
  145. package/dist/serdes/BinarySerializer.js +0 -105
  146. package/dist/serdes/BinarySerializer.js.map +0 -1
  147. package/dist/serdes/BytesList.d.ts +0 -28
  148. package/dist/serdes/BytesList.js +0 -48
  149. package/dist/serdes/BytesList.js.map +0 -1
  150. package/dist/types/Comparable.d.ts +0 -18
  151. package/dist/types/Comparable.js +0 -43
  152. package/dist/types/Comparable.js.map +0 -1
  153. package/dist/types/PathSet/Hop.d.ts +0 -41
  154. package/dist/types/PathSet/Hop.js +0 -116
  155. package/dist/types/PathSet/Hop.js.map +0 -1
  156. package/dist/types/PathSet/Path.d.ts +0 -33
  157. package/dist/types/PathSet/Path.js +0 -83
  158. package/dist/types/PathSet/Path.js.map +0 -1
  159. package/dist/types/PathSet/index.d.ts +0 -29
  160. package/dist/types/PathSet/index.js +0 -98
  161. package/dist/types/PathSet/index.js.map +0 -1
  162. package/dist/types/SerializedType.d.ts +0 -47
  163. package/dist/types/SerializedType.js +0 -69
  164. package/dist/types/SerializedType.js.map +0 -1
@@ -1,100 +0,0 @@
1
- import { Buffer } from 'buffer/';
2
- import { FieldInstance } from '../enums';
3
- import SerializedType from '../types/SerializedType';
4
- /**
5
- * BinaryParser is used to compute fields and values from a HexString.
6
- */
7
- export default class BinaryParser {
8
- private _bytes;
9
- /**
10
- * Initialize bytes to a hex string.
11
- *
12
- * @param hexBytes - A hex string.
13
- */
14
- constructor(hexBytes: string);
15
- /**
16
- * Get the type associated with a given field.
17
- *
18
- * @param field - The field that you wan to get the type of.
19
- * @returns The type associated with the given field.
20
- */
21
- private static typeForField;
22
- /**
23
- * Peek the first byte of the BinaryParser.
24
- *
25
- * @returns The first byte of the BinaryParser.
26
- */
27
- peek(): number;
28
- /**
29
- * Consume the first n bytes of the BinaryParser.
30
- *
31
- * @param n - The number of bytes to skip.
32
- */
33
- skip(n: number): void;
34
- /**
35
- * Read the first n bytes from the BinaryParser.
36
- *
37
- * @param n - The number of bytes to read.
38
- * @returns The bytes.
39
- */
40
- read(n: number): Buffer;
41
- /**
42
- * Read an integer of given size.
43
- *
44
- * @param n - The number of bytes to read.
45
- * @returns The number represented by those bytes.
46
- */
47
- readUIntN(n: number): number;
48
- readUInt8(): number;
49
- readUInt16(): number;
50
- readUInt32(): number;
51
- size(): number;
52
- end(customEnd?: number): boolean;
53
- /**
54
- * Reads variable length encoded bytes.
55
- *
56
- * @returns The variable length bytes.
57
- */
58
- readVariableLength(): Buffer;
59
- /**
60
- * Reads the length of the variable length encoded bytes.
61
- *
62
- * @returns The length of the variable length encoded bytes.
63
- * @throws Error.
64
- */
65
- readVariableLengthLength(): number;
66
- /**
67
- * Reads the field ordinal from the BinaryParser.
68
- *
69
- * @returns Field ordinal.
70
- * @throws Error.
71
- */
72
- readFieldOrdinal(): number;
73
- /**
74
- * Read the field from the BinaryParser.
75
- *
76
- * @returns The field represented by the bytes at the head of the BinaryParser.
77
- */
78
- readField(): FieldInstance;
79
- /**
80
- * Read a given type from the BinaryParser.
81
- *
82
- * @param type - The type that you want to read from the BinaryParser.
83
- * @returns The instance of that type read from the BinaryParser.
84
- */
85
- readType(type: typeof SerializedType): SerializedType;
86
- /**
87
- * Read value of the type specified by field from the BinaryParser.
88
- *
89
- * @param field - The field that you want to get the associated value for.
90
- * @returns The value associated with the given field.
91
- * @throws Error.
92
- */
93
- readFieldValue(field: FieldInstance): SerializedType;
94
- /**
95
- * Get the next field and value from the BinaryParser.
96
- *
97
- * @returns The field and value.
98
- */
99
- readFieldAndValue(): [FieldInstance, SerializedType];
100
- }
@@ -1,200 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable no-bitwise -- this file needs to use bitwise operations */
4
- var assert = require("assert");
5
- var buffer_1 = require("buffer/");
6
- var enums_1 = require("../enums");
7
- var uint_16_1 = require("../types/uint-16");
8
- var uint_32_1 = require("../types/uint-32");
9
- var uint_8_1 = require("../types/uint-8");
10
- /**
11
- * BinaryParser is used to compute fields and values from a HexString.
12
- */
13
- var BinaryParser = /** @class */ (function () {
14
- /**
15
- * Initialize bytes to a hex string.
16
- *
17
- * @param hexBytes - A hex string.
18
- */
19
- function BinaryParser(hexBytes) {
20
- this._bytes = buffer_1.Buffer.from(hexBytes, 'hex');
21
- }
22
- /**
23
- * Get the type associated with a given field.
24
- *
25
- * @param field - The field that you wan to get the type of.
26
- * @returns The type associated with the given field.
27
- */
28
- BinaryParser.typeForField = function (field) {
29
- return field.associatedType;
30
- };
31
- /**
32
- * Peek the first byte of the BinaryParser.
33
- *
34
- * @returns The first byte of the BinaryParser.
35
- */
36
- BinaryParser.prototype.peek = function () {
37
- assert(this._bytes.byteLength !== 0);
38
- return this._bytes[0];
39
- };
40
- /**
41
- * Consume the first n bytes of the BinaryParser.
42
- *
43
- * @param n - The number of bytes to skip.
44
- */
45
- BinaryParser.prototype.skip = function (n) {
46
- assert(n <= this._bytes.byteLength);
47
- this._bytes = this._bytes.slice(n);
48
- };
49
- /**
50
- * Read the first n bytes from the BinaryParser.
51
- *
52
- * @param n - The number of bytes to read.
53
- * @returns The bytes.
54
- */
55
- BinaryParser.prototype.read = function (n) {
56
- assert(n <= this._bytes.byteLength);
57
- var slice = this._bytes.slice(0, n);
58
- this.skip(n);
59
- return slice;
60
- };
61
- /**
62
- * Read an integer of given size.
63
- *
64
- * @param n - The number of bytes to read.
65
- * @returns The number represented by those bytes.
66
- */
67
- /* eslint-disable @typescript-eslint/no-magic-numbers --
68
- * TODO refactor */
69
- BinaryParser.prototype.readUIntN = function (n) {
70
- assert(n > 0 && n <= 4, 'invalid n');
71
- return this.read(n).reduce(function (accum, current) { return (accum << 8) | current; }) >>> 0;
72
- };
73
- /* eslint-enable @typescript-eslint/no-magic-numbers */
74
- BinaryParser.prototype.readUInt8 = function () {
75
- return this.readUIntN(uint_8_1.default.WIDTH);
76
- };
77
- BinaryParser.prototype.readUInt16 = function () {
78
- return this.readUIntN(uint_16_1.default.WIDTH);
79
- };
80
- BinaryParser.prototype.readUInt32 = function () {
81
- return this.readUIntN(uint_32_1.default.WIDTH);
82
- };
83
- BinaryParser.prototype.size = function () {
84
- return this._bytes.byteLength;
85
- };
86
- BinaryParser.prototype.end = function (customEnd) {
87
- var length = this._bytes.byteLength;
88
- return length === 0 || (customEnd !== undefined && length <= customEnd);
89
- };
90
- /**
91
- * Reads variable length encoded bytes.
92
- *
93
- * @returns The variable length bytes.
94
- */
95
- BinaryParser.prototype.readVariableLength = function () {
96
- return this.read(this.readVariableLengthLength());
97
- };
98
- /**
99
- * Reads the length of the variable length encoded bytes.
100
- *
101
- * @returns The length of the variable length encoded bytes.
102
- * @throws Error.
103
- */
104
- /* eslint-disable @typescript-eslint/no-magic-numbers --
105
- * TODO refactor */
106
- BinaryParser.prototype.readVariableLengthLength = function () {
107
- var b1 = this.readUInt8();
108
- if (b1 <= 192) {
109
- return b1;
110
- }
111
- if (b1 <= 240) {
112
- var b2 = this.readUInt8();
113
- return 193 + (b1 - 193) * 256 + b2;
114
- }
115
- if (b1 <= 254) {
116
- var b2 = this.readUInt8();
117
- var b3 = this.readUInt8();
118
- return 12481 + (b1 - 241) * 65536 + b2 * 256 + b3;
119
- }
120
- throw new Error('Invalid variable length indicator');
121
- };
122
- /* eslint-enable @typescript-eslint/no-magic-numbers */
123
- /**
124
- * Reads the field ordinal from the BinaryParser.
125
- *
126
- * @returns Field ordinal.
127
- * @throws Error.
128
- */
129
- /* eslint-disable @typescript-eslint/no-magic-numbers --
130
- * TODO refactor */
131
- BinaryParser.prototype.readFieldOrdinal = function () {
132
- var type = this.readUInt8();
133
- var nth = type & 15;
134
- type >>= 4;
135
- if (type === 0) {
136
- type = this.readUInt8();
137
- if (type === 0 || type < 16) {
138
- throw new Error('Cannot read FieldOrdinal, type_code out of range');
139
- }
140
- }
141
- if (nth === 0) {
142
- nth = this.readUInt8();
143
- if (nth === 0 || nth < 16) {
144
- throw new Error('Cannot read FieldOrdinal, field_code out of range');
145
- }
146
- }
147
- return (type << 16) | nth;
148
- };
149
- /* eslint-enable @typescript-eslint/no-magic-numbers */
150
- /**
151
- * Read the field from the BinaryParser.
152
- *
153
- * @returns The field represented by the bytes at the head of the BinaryParser.
154
- */
155
- BinaryParser.prototype.readField = function () {
156
- return enums_1.Field.get(this.readFieldOrdinal().toString());
157
- };
158
- /**
159
- * Read a given type from the BinaryParser.
160
- *
161
- * @param type - The type that you want to read from the BinaryParser.
162
- * @returns The instance of that type read from the BinaryParser.
163
- */
164
- BinaryParser.prototype.readType = function (type) {
165
- return type.fromParser(this);
166
- };
167
- /**
168
- * Read value of the type specified by field from the BinaryParser.
169
- *
170
- * @param field - The field that you want to get the associated value for.
171
- * @returns The value associated with the given field.
172
- * @throws Error.
173
- */
174
- BinaryParser.prototype.readFieldValue = function (field) {
175
- var type = BinaryParser.typeForField(field);
176
- if (!type) {
177
- throw new Error("unsupported: (" + field.name + ", " + field.type.name + ")");
178
- }
179
- var sizeHint = field.isVariableLengthEncoded
180
- ? this.readVariableLengthLength()
181
- : undefined;
182
- var value = type.fromParser(this, sizeHint);
183
- if (value === undefined) {
184
- throw new Error("fromParser for (" + field.name + ", " + field.type.name + ") -> undefined ");
185
- }
186
- return value;
187
- };
188
- /**
189
- * Get the next field and value from the BinaryParser.
190
- *
191
- * @returns The field and value.
192
- */
193
- BinaryParser.prototype.readFieldAndValue = function () {
194
- var field = this.readField();
195
- return [field, this.readFieldValue(field)];
196
- };
197
- return BinaryParser;
198
- }());
199
- exports.default = BinaryParser;
200
- //# sourceMappingURL=BinaryParser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BinaryParser.js","sourceRoot":"","sources":["../../src/serdes/BinaryParser.ts"],"names":[],"mappings":";;AAAA,4EAA4E;AAC5E,+BAAgC;AAEhC,kCAAgC;AAEhC,kCAA+C;AAE/C,4CAAqC;AACrC,4CAAqC;AACrC,0CAAmC;AAEnC;;GAEG;AACH;IAGE;;;;OAIG;IACH,sBAAmB,QAAgB;QACjC,IAAI,CAAC,MAAM,GAAG,eAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;IAC5C,CAAC;IAED;;;;;OAKG;IACY,yBAAY,GAA3B,UAA4B,KAAoB;QAC9C,OAAO,KAAK,CAAC,cAAc,CAAA;IAC7B,CAAC;IAED;;;;OAIG;IACI,2BAAI,GAAX;QACE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,KAAK,CAAC,CAAC,CAAA;QACpC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IACvB,CAAC;IAED;;;;OAIG;IACI,2BAAI,GAAX,UAAY,CAAS;QACnB,MAAM,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;QACnC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACpC,CAAC;IAED;;;;;OAKG;IACI,2BAAI,GAAX,UAAY,CAAS;QACnB,MAAM,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;QAEnC,IAAM,KAAK,GAAG,IAAI,CAAC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@
1
- import { Buffer } from 'buffer/';
2
- import { FieldInstance } from '../enums';
3
- import SerializedType from '../types/SerializedType';
4
- import BytesList from './BytesList';
5
- /**
6
- * BinarySerializer is used to write fields and values to buffers.
7
- */
8
- export default class BinarySerializer {
9
- private readonly _sink;
10
- constructor(sink: BytesList);
11
- private static encodeVariableLength;
12
- /**
13
- * Write a value to this BinarySerializer.
14
- *
15
- * @param value - A SerializedType value.
16
- */
17
- write(value: SerializedType): void;
18
- /**
19
- * Write bytes to this BinarySerializer.
20
- *
21
- * @param bytes - The bytes to write.
22
- */
23
- put(bytes: Buffer): void;
24
- /**
25
- * Write a value of a given type to this BinarySerializer.
26
- *
27
- * @param type - The type to write.
28
- * @param value - A value of that type.
29
- */
30
- writeType(type: typeof SerializedType, value: SerializedType): void;
31
- /**
32
- * Write BytesList to this BinarySerializer.
33
- *
34
- * @param bl - BytesList to write to BinarySerializer.
35
- */
36
- writeBytesList(bl: BytesList): void;
37
- /**
38
- * Write field and value to BinarySerializer.
39
- *
40
- * @param field - Field to write to BinarySerializer.
41
- * @param value - Value to write to BinarySerializer.
42
- */
43
- writeFieldAndValue(field: FieldInstance, value: SerializedType): void;
44
- /**
45
- * Write a variable length encoded value to the BinarySerializer.
46
- *
47
- * @param value - Length encoded value to write to BytesList.
48
- */
49
- writeLengthEncoded(value: SerializedType): void;
50
- }
@@ -1,105 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable no-bitwise -- this file needs to use bitwise operations */
4
- var assert = require("assert");
5
- var buffer_1 = require("buffer/");
6
- var BytesList_1 = require("./BytesList");
7
- /**
8
- * BinarySerializer is used to write fields and values to buffers.
9
- */
10
- var BinarySerializer = /** @class */ (function () {
11
- function BinarySerializer(sink) {
12
- this._sink = new BytesList_1.default();
13
- this._sink = sink;
14
- }
15
- /* eslint-disable max-statements, @typescript-eslint/no-magic-numbers --
16
- * TODO refactor */
17
- BinarySerializer.encodeVariableLength = function (inputLength) {
18
- var length = inputLength;
19
- var lenBytes = buffer_1.Buffer.alloc(3);
20
- if (length <= 192) {
21
- lenBytes[0] = length;
22
- return lenBytes.slice(0, 1);
23
- }
24
- if (length <= 12480) {
25
- length -= 193;
26
- lenBytes[0] = 193 + (length >>> 8);
27
- lenBytes[1] = length & 0xff;
28
- return lenBytes.slice(0, 2);
29
- }
30
- if (length <= 918744) {
31
- length -= 12481;
32
- lenBytes[0] = 241 + (length >>> 16);
33
- lenBytes[1] = (length >> 8) & 0xff;
34
- lenBytes[2] = length & 0xff;
35
- return lenBytes.slice(0, 3);
36
- }
37
- throw new Error('Overflow error');
38
- };
39
- /* eslint-enable max-statements, @typescript-eslint/no-magic-numbers */
40
- /**
41
- * Write a value to this BinarySerializer.
42
- *
43
- * @param value - A SerializedType value.
44
- */
45
- BinarySerializer.prototype.write = function (value) {
46
- value.toBytesSink(this._sink);
47
- };
48
- /**
49
- * Write bytes to this BinarySerializer.
50
- *
51
- * @param bytes - The bytes to write.
52
- */
53
- BinarySerializer.prototype.put = function (bytes) {
54
- this._sink.put(bytes);
55
- };
56
- /**
57
- * Write a value of a given type to this BinarySerializer.
58
- *
59
- * @param type - The type to write.
60
- * @param value - A value of that type.
61
- */
62
- BinarySerializer.prototype.writeType = function (type, value) {
63
- this.write(type.from(value));
64
- };
65
- /**
66
- * Write BytesList to this BinarySerializer.
67
- *
68
- * @param bl - BytesList to write to BinarySerializer.
69
- */
70
- BinarySerializer.prototype.writeBytesList = function (bl) {
71
- bl.toBytesSink(this._sink);
72
- };
73
- /**
74
- * Write field and value to BinarySerializer.
75
- *
76
- * @param field - Field to write to BinarySerializer.
77
- * @param value - Value to write to BinarySerializer.
78
- */
79
- BinarySerializer.prototype.writeFieldAndValue = function (field, value) {
80
- var associatedValue = field.associatedType.from(value);
81
- assert(associatedValue.toBytesSink !== undefined);
82
- assert(field.name !== undefined);
83
- this._sink.put(field.header);
84
- if (field.isVariableLengthEncoded) {
85
- this.writeLengthEncoded(associatedValue);
86
- }
87
- else {
88
- associatedValue.toBytesSink(this._sink);
89
- }
90
- };
91
- /**
92
- * Write a variable length encoded value to the BinarySerializer.
93
- *
94
- * @param value - Length encoded value to write to BytesList.
95
- */
96
- BinarySerializer.prototype.writeLengthEncoded = function (value) {
97
- var bytes = new BytesList_1.default();
98
- value.toBytesSink(bytes);
99
- this.put(BinarySerializer.encodeVariableLength(bytes.getLength()));
100
- this.writeBytesList(bytes);
101
- };
102
- return BinarySerializer;
103
- }());
104
- exports.default = BinarySerializer;
105
- //# sourceMappingURL=BinarySerializer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BinarySerializer.js","sourceRoot":"","sources":["../../src/serdes/BinarySerializer.ts"],"names":[],"mappings":";;AAAA,4EAA4E;AAC5E,+BAAgC;AAEhC,kCAAgC;AAKhC,yCAAmC;AAEnC;;GAEG;AACH;IAGE,0BAAmB,IAAe;QAFjB,UAAK,GAAc,IAAI,mBAAS,EAAE,CAAA;QAGjD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IACnB,CAAC;IAED;uBACmB;IACJ,qCAAoB,GAAnC,UAAoC,WAAmB;QACrD,IAAI,MAAM,GAAG,WAAW,CAAA;QACxB,IAAM,QAAQ,GAAG,eAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAChC,IAAI,MAAM,IAAI,GAAG,EAAE;YACjB,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,CAAA;YACpB,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;SAC5B;QACD,IAAI,MAAM,IAAI,KAAK,EAAE;YACnB,MAAM,IAAI,GAAG,CAAA;YACb,QAAQ,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,CAAA;YAClC,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,CAAA;YAC3B,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA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EhC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAE5B,IAAI,KAAK,CAAC,uBAAuB,EAAE;YACjC,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAA;SACzC;aAAM;YACL,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;SACxC;IACH,CAAC;IAED;;;;OAIG;IACI,6CAAkB,GAAzB,UAA0B,KAAqB;QAC7C,IAAM,KAAK,GAAG,IAAI,mBAAS,EAAE,CAAA;QAC7B,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QACxB,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;QAClE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IAC5B,CAAC;IACH,uBAAC;AAAD,CAAC,AArGD,IAqGC"}
@@ -1,28 +0,0 @@
1
- import { Buffer } from 'buffer/';
2
- /**
3
- * Bytes list is a collection of buffer objects.
4
- */
5
- export default class BytesList {
6
- private readonly _bytesArray;
7
- /**
8
- * Get the total number of bytes in the BytesList.
9
- *
10
- * @returns The number of bytes.
11
- */
12
- getLength(): number;
13
- /**
14
- * Put bytes in the BytesList.
15
- *
16
- * @param bytesArg - A Buffer.
17
- * @returns This BytesList.
18
- */
19
- put(bytesArg: Buffer | Uint8Array): BytesList;
20
- /**
21
- * Write this BytesList to the back of another bytes list.
22
- *
23
- * @param list - The BytesList to write to.
24
- */
25
- toBytesSink(list: BytesList): void;
26
- toBytes(): Buffer;
27
- toHex(): string;
28
- }
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var buffer_1 = require("buffer/");
4
- /**
5
- * Bytes list is a collection of buffer objects.
6
- */
7
- var BytesList = /** @class */ (function () {
8
- function BytesList() {
9
- this._bytesArray = [];
10
- }
11
- /**
12
- * Get the total number of bytes in the BytesList.
13
- *
14
- * @returns The number of bytes.
15
- */
16
- BytesList.prototype.getLength = function () {
17
- return buffer_1.Buffer.concat(this._bytesArray).byteLength;
18
- };
19
- /**
20
- * Put bytes in the BytesList.
21
- *
22
- * @param bytesArg - A Buffer.
23
- * @returns This BytesList.
24
- */
25
- BytesList.prototype.put = function (bytesArg) {
26
- // Temporary, to catch instances of Uint8Array being passed in
27
- var bytes = buffer_1.Buffer.from(bytesArg);
28
- this._bytesArray.push(bytes);
29
- return this;
30
- };
31
- /**
32
- * Write this BytesList to the back of another bytes list.
33
- *
34
- * @param list - The BytesList to write to.
35
- */
36
- BytesList.prototype.toBytesSink = function (list) {
37
- list.put(this.toBytes());
38
- };
39
- BytesList.prototype.toBytes = function () {
40
- return buffer_1.Buffer.concat(this._bytesArray);
41
- };
42
- BytesList.prototype.toHex = function () {
43
- return this.toBytes().toString('hex').toUpperCase();
44
- };
45
- return BytesList;
46
- }());
47
- exports.default = BytesList;
48
- //# sourceMappingURL=BytesList.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BytesList.js","sourceRoot":"","sources":["../../src/serdes/BytesList.ts"],"names":[],"mappings":";;AAAA,kCAAgC;AAEhC;;GAEG;AACH;IAAA;QACmB,gBAAW,GAAa,EAAE,CAAA;IAyC7C,CAAC;IAvCC;;;;OAIG;IACI,6BAAS,GAAhB;QACE,OAAO,eAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,UAAU,CAAA;IACnD,CAAC;IAED;;;;;OAKG;IACI,uBAAG,GAAV,UAAW,QAA6B;QACtC,8DAA8D;QAC9D,IAAM,KAAK,GAAG,eAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAEnC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;OAIG;IACI,+BAAW,GAAlB,UAAmB,IAAe;QAChC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IAC1B,CAAC;IAEM,2BAAO,GAAd;QACE,OAAO,eAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IACxC,CAAC;IAEM,yBAAK,GAAZ;QACE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;IACrD,CAAC;IACH,gBAAC;AAAD,CAAC,AA1CD,IA0CC"}
@@ -1,18 +0,0 @@
1
- import SerializedType from './SerializedType';
2
- /**
3
- * Base class for SerializedTypes that are comparable.
4
- */
5
- export default abstract class Comparable extends SerializedType {
6
- lt(other: Comparable): boolean;
7
- eq(other: Comparable): boolean;
8
- gt(other: Comparable): boolean;
9
- gte(other: Comparable): boolean;
10
- lte(other: Comparable): boolean;
11
- /**
12
- * Overload this method to define how two Comparable SerializedTypes are compared.
13
- *
14
- * @param other - The comparable object to compare this to.
15
- * @returns 1, 0, or 1 depending on how the objects relate to each other.
16
- */
17
- abstract compareTo(other: Comparable): number;
18
- }
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- var SerializedType_1 = require("./SerializedType");
17
- /**
18
- * Base class for SerializedTypes that are comparable.
19
- */
20
- var Comparable = /** @class */ (function (_super) {
21
- __extends(Comparable, _super);
22
- function Comparable() {
23
- return _super !== null && _super.apply(this, arguments) || this;
24
- }
25
- Comparable.prototype.lt = function (other) {
26
- return this.compareTo(other) < 0;
27
- };
28
- Comparable.prototype.eq = function (other) {
29
- return this.compareTo(other) === 0;
30
- };
31
- Comparable.prototype.gt = function (other) {
32
- return this.compareTo(other) > 0;
33
- };
34
- Comparable.prototype.gte = function (other) {
35
- return this.compareTo(other) > -1;
36
- };
37
- Comparable.prototype.lte = function (other) {
38
- return this.compareTo(other) < 1;
39
- };
40
- return Comparable;
41
- }(SerializedType_1.default));
42
- exports.default = Comparable;
43
- //# sourceMappingURL=Comparable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Comparable.js","sourceRoot":"","sources":["../../src/types/Comparable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAA6C;AAE7C;;GAEG;AACH;IAAiD,8BAAc;IAA/D;;IA4BA,CAAC;IA3BQ,uBAAE,GAAT,UAAU,KAAiB;QACzB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClC,CAAC;IAEM,uBAAE,GAAT,UAAU,KAAiB;QACzB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IAEM,uBAAE,GAAT,UAAU,KAAiB;QACzB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClC,CAAC;IAEM,wBAAG,GAAV,UAAW,KAAiB;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;IACnC,CAAC;IAEM,wBAAG,GAAV,UAAW,KAAiB;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClC,CAAC;IASH,iBAAC;AAAD,CAAC,AA5BD,CAAiD,wBAAc,GA4B9D"}
@@ -1,41 +0,0 @@
1
- import BinaryParser from '../../serdes/BinaryParser';
2
- import SerializedType, { JsonObject } from '../SerializedType';
3
- /**
4
- * The object representation of a Hop, an issuer AccountID, an account AccountID, and a Currency.
5
- */
6
- export interface HopObject extends JsonObject {
7
- issuer?: string;
8
- account?: string;
9
- currency?: string;
10
- }
11
- /**
12
- * Serialize and Deserialize a Hop.
13
- */
14
- export default class Hop extends SerializedType {
15
- /**
16
- * Create a Hop from a HopObject.
17
- *
18
- * @param value - Either a hop or HopObject to create a hop with.
19
- * @returns A Hop.
20
- */
21
- static from(value: Hop | HopObject): Hop;
22
- /**
23
- * Construct a Hop from a BinaryParser.
24
- *
25
- * @param parser - BinaryParser to read the Hop from.
26
- * @returns A Hop.
27
- */
28
- static fromParser(parser: BinaryParser): Hop;
29
- /**
30
- * Get the JSON interpretation of this hop.
31
- *
32
- * @returns A HopObject, an JS object with optional account, issuer, and currency.
33
- */
34
- toJSON(): HopObject;
35
- /**
36
- * Get a number representing the type of this hop.
37
- *
38
- * @returns A number to be bitwise and-ed with TYPE_ constants to describe the types in the hop.
39
- */
40
- type(): number;
41
- }