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,116 +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
- /* eslint-disable no-bitwise -- this file needs to use bitwise operations */
17
- var buffer_1 = require("buffer/");
18
- var BinaryParser_1 = require("../../serdes/BinaryParser");
19
- var account_id_1 = require("../account-id");
20
- var currency_1 = require("../currency");
21
- var SerializedType_1 = require("../SerializedType");
22
- /**
23
- * Constant for masking types of a Hop.
24
- */
25
- var TYPE_ACCOUNT = 0x01;
26
- var TYPE_CURRENCY = 0x10;
27
- var TYPE_ISSUER = 0x20;
28
- /**
29
- * Serialize and Deserialize a Hop.
30
- */
31
- var Hop = /** @class */ (function (_super) {
32
- __extends(Hop, _super);
33
- function Hop() {
34
- return _super !== null && _super.apply(this, arguments) || this;
35
- }
36
- /**
37
- * Create a Hop from a HopObject.
38
- *
39
- * @param value - Either a hop or HopObject to create a hop with.
40
- * @returns A Hop.
41
- */
42
- Hop.from = function (value) {
43
- if (value instanceof Hop) {
44
- return value;
45
- }
46
- var bytes = [buffer_1.Buffer.from([0])];
47
- if (value.account) {
48
- bytes.push(account_id_1.default.from(value.account).toBytes());
49
- bytes[0][0] |= TYPE_ACCOUNT;
50
- }
51
- if (value.currency) {
52
- bytes.push(currency_1.default.from(value.currency).toBytes());
53
- bytes[0][0] |= TYPE_CURRENCY;
54
- }
55
- if (value.issuer) {
56
- bytes.push(account_id_1.default.from(value.issuer).toBytes());
57
- bytes[0][0] |= TYPE_ISSUER;
58
- }
59
- return new Hop(buffer_1.Buffer.concat(bytes));
60
- };
61
- /**
62
- * Construct a Hop from a BinaryParser.
63
- *
64
- * @param parser - BinaryParser to read the Hop from.
65
- * @returns A Hop.
66
- */
67
- Hop.fromParser = function (parser) {
68
- var type = parser.readUInt8();
69
- var bytes = [buffer_1.Buffer.from([type])];
70
- if (type & TYPE_ACCOUNT) {
71
- bytes.push(parser.read(account_id_1.default.WIDTH));
72
- }
73
- if (type & TYPE_CURRENCY) {
74
- bytes.push(parser.read(currency_1.default.WIDTH));
75
- }
76
- if (type & TYPE_ISSUER) {
77
- bytes.push(parser.read(account_id_1.default.WIDTH));
78
- }
79
- return new Hop(buffer_1.Buffer.concat(bytes));
80
- };
81
- /**
82
- * Get the JSON interpretation of this hop.
83
- *
84
- * @returns A HopObject, an JS object with optional account, issuer, and currency.
85
- */
86
- Hop.prototype.toJSON = function () {
87
- var hopParser = new BinaryParser_1.default(this.bytes.toString('hex'));
88
- var type = hopParser.readUInt8();
89
- var result = {};
90
- /* eslint-disable @typescript-eslint/consistent-type-assertions --
91
- * TODO it may be possible to get rid of this with a generic type on the
92
- * SerializedType.fromParser func */
93
- if (type & TYPE_ACCOUNT) {
94
- result.account = account_id_1.default.fromParser(hopParser).toJSON();
95
- }
96
- if (type & TYPE_CURRENCY) {
97
- result.currency = currency_1.default.fromParser(hopParser).toJSON();
98
- }
99
- if (type & TYPE_ISSUER) {
100
- result.issuer = account_id_1.default.fromParser(hopParser).toJSON();
101
- }
102
- /* eslint-enable @typescript-eslint/consistent-type-assertions */
103
- return result;
104
- };
105
- /**
106
- * Get a number representing the type of this hop.
107
- *
108
- * @returns A number to be bitwise and-ed with TYPE_ constants to describe the types in the hop.
109
- */
110
- Hop.prototype.type = function () {
111
- return this.bytes[0];
112
- };
113
- return Hop;
114
- }(SerializedType_1.default));
115
- exports.default = Hop;
116
- //# sourceMappingURL=Hop.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Hop.js","sourceRoot":"","sources":["../../../src/types/PathSet/Hop.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA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AC,MAAM,GAAG,oBAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,EAAY,CAAA;SACnE;QACD,iEAAiE;QAEjE,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;OAIG;IACI,kBAAI,GAAX;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACtB,CAAC;IACH,UAAC;AAAD,CAAC,AA9FD,CAAiC,wBAAc,GA8F9C"}
@@ -1,33 +0,0 @@
1
- import BinaryParser from '../../serdes/BinaryParser';
2
- import SerializedType from '../SerializedType';
3
- import { HopObject } from './Hop';
4
- /**
5
- * Constants for separating Paths in a PathSet.
6
- */
7
- export declare const PATHSET_END_BYTE = 0;
8
- export declare const PATH_SEPARATOR_BYTE = 255;
9
- /**
10
- * Class for serializing/deserializing Paths.
11
- */
12
- export default class Path extends SerializedType {
13
- /**
14
- * Construct a Path from an array of Hops.
15
- *
16
- * @param value - Path or array of HopObjects to construct a Path.
17
- * @returns The Path.
18
- */
19
- static from(value: Path | HopObject[]): Path;
20
- /**
21
- * Read a Path from a BinaryParser.
22
- *
23
- * @param parser - BinaryParser to read Path from.
24
- * @returns The Path represented by the bytes read from the BinaryParser.
25
- */
26
- static fromParser(parser: BinaryParser): Path;
27
- /**
28
- * Get the JSON representation of this Path.
29
- *
30
- * @returns An Array of HopObject constructed from this.bytes.
31
- */
32
- toJSON(): HopObject[];
33
- }
@@ -1,83 +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
- exports.PATH_SEPARATOR_BYTE = exports.PATHSET_END_BYTE = void 0;
17
- var buffer_1 = require("buffer/");
18
- var BinaryParser_1 = require("../../serdes/BinaryParser");
19
- var SerializedType_1 = require("../SerializedType");
20
- var Hop_1 = require("./Hop");
21
- /**
22
- * Constants for separating Paths in a PathSet.
23
- */
24
- exports.PATHSET_END_BYTE = 0x00;
25
- exports.PATH_SEPARATOR_BYTE = 0xff;
26
- /**
27
- * Class for serializing/deserializing Paths.
28
- */
29
- var Path = /** @class */ (function (_super) {
30
- __extends(Path, _super);
31
- function Path() {
32
- return _super !== null && _super.apply(this, arguments) || this;
33
- }
34
- /**
35
- * Construct a Path from an array of Hops.
36
- *
37
- * @param value - Path or array of HopObjects to construct a Path.
38
- * @returns The Path.
39
- */
40
- Path.from = function (value) {
41
- if (value instanceof Path) {
42
- return value;
43
- }
44
- var bytes = [];
45
- value.forEach(function (hop) {
46
- bytes.push(Hop_1.default.from(hop).toBytes());
47
- });
48
- return new Path(buffer_1.Buffer.concat(bytes));
49
- };
50
- /**
51
- * Read a Path from a BinaryParser.
52
- *
53
- * @param parser - BinaryParser to read Path from.
54
- * @returns The Path represented by the bytes read from the BinaryParser.
55
- */
56
- Path.fromParser = function (parser) {
57
- var bytes = [];
58
- while (!parser.end()) {
59
- bytes.push(Hop_1.default.fromParser(parser).toBytes());
60
- if (parser.peek() === exports.PATHSET_END_BYTE ||
61
- parser.peek() === exports.PATH_SEPARATOR_BYTE) {
62
- break;
63
- }
64
- }
65
- return new Path(buffer_1.Buffer.concat(bytes));
66
- };
67
- /**
68
- * Get the JSON representation of this Path.
69
- *
70
- * @returns An Array of HopObject constructed from this.bytes.
71
- */
72
- Path.prototype.toJSON = function () {
73
- var json = [];
74
- var pathParser = new BinaryParser_1.default(this.toString());
75
- while (!pathParser.end()) {
76
- json.push(Hop_1.default.fromParser(pathParser).toJSON());
77
- }
78
- return json;
79
- };
80
- return Path;
81
- }(SerializedType_1.default));
82
- exports.default = Path;
83
- //# sourceMappingURL=Path.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Path.js","sourceRoot":"","sources":["../../../src/types/PathSet/Path.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kCAAgC;AAEhC,0DAAoD;AACpD,oDAA8C;AAE9C,6BAAsC;AAEtC;;GAEG;AACU,QAAA,gBAAgB,GAAG,IAAI,CAAA;AACvB,QAAA,mBAAmB,GAAG,IAAI,CAAA;AAEvC;;GAEG;AACH;IAAkC,wBAAc;IAAhD;;IAwDA,CAAC;IAvDC;;;;;OAKG;IACW,SAAI,GAAlB,UAAmB,KAAyB;QAC1C,IAAI,KAAK,YAAY,IAAI,EAAE;YACzB,OAAO,KAAK,CAAA;SACb;QAED,IAAM,KAAK,GAAa,EAAE,CAAA;QAC1B,KAAK,CAAC,OAAO,CAAC,UAAC,GAAc;YAC3B,KAAK,CAAC,IAAI,CAAC,aAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;QACrC,CAAC,CAAC,CAAA;QAEF,OAAO,IAAI,IAAI,CAAC,eAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IACvC,CAAC;IAED;;;;;OAKG;IACW,eAAU,GAAxB,UAAyB,MAAoB;QAC3C,IAAM,KAAK,GAAa,EAAE,CAAA;QAC1B,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,CAAC,aAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;YAE5C,IACE,MAAM,CAAC,IAAI,EAAE,KAAK,wBAAgB;gBAClC,MAAM,CAAC,IAAI,EAAE,KAAK,2BAAmB,EACrC;gBACA,MAAK;aACN;SACF;QACD,OAAO,IAAI,IAAI,CAAC,eAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IACvC,CAAC;IAED;;;;OAIG;IACI,qBAAM,GAAb;QACE,IAAM,IAAI,GAAgB,EAAE,CAAA;QAC5B,IAAM,UAAU,GAAG,IAAI,sBAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;QAEpD,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE;YACxB,IAAI,CAAC,IAAI,CAAC,aAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,CAAA;SAC/C;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IACH,WAAC;AAAD,CAAC,AAxDD,CAAkC,wBAAc,GAwD/C"}
@@ -1,29 +0,0 @@
1
- import BinaryParser from '../../serdes/BinaryParser';
2
- import SerializedType from '../SerializedType';
3
- import { HopObject } from './Hop';
4
- /**
5
- * Deserialize and Serialize the PathSet type.
6
- */
7
- export default class PathSet extends SerializedType {
8
- /**
9
- * Construct a PathSet from an Array of Arrays representing paths.
10
- *
11
- * @param value - A PathSet or Array of Array of HopObjects.
12
- * @returns The PathSet constructed from value.
13
- * @throws Error.
14
- */
15
- static from<T extends PathSet | HopObject[][]>(value: T): PathSet;
16
- /**
17
- * Construct a PathSet from a BinaryParser.
18
- *
19
- * @param parser - A BinaryParser to read PathSet from.
20
- * @returns The PathSet read from parser.
21
- */
22
- static fromParser(parser: BinaryParser): PathSet;
23
- /**
24
- * Get the JSON representation of this PathSet.
25
- *
26
- * @returns An Array of Array of HopObjects, representing this PathSet.
27
- */
28
- toJSON(): HopObject[][];
29
- }
@@ -1,98 +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 buffer_1 = require("buffer/");
17
- var BinaryParser_1 = require("../../serdes/BinaryParser");
18
- var SerializedType_1 = require("../SerializedType");
19
- var Path_1 = require("./Path");
20
- function isHopObject(arg) {
21
- var _a, _b, _c;
22
- /* eslint-disable @typescript-eslint/consistent-type-assertions --
23
- * TODO is there any way to write this without a type assertion? */
24
- return (((_a = arg) === null || _a === void 0 ? void 0 : _a.issuer) !== undefined ||
25
- ((_b = arg) === null || _b === void 0 ? void 0 : _b.account) !== undefined ||
26
- ((_c = arg) === null || _c === void 0 ? void 0 : _c.currency) !== undefined);
27
- /* eslint-enable @typescript-eslint/consistent-type-assertions */
28
- }
29
- function isPathSet(arg) {
30
- return ((Array.isArray(arg) && arg.length === 0) ||
31
- (Array.isArray(arg) && Array.isArray(arg[0]) && arg[0].length === 0) ||
32
- (Array.isArray(arg) && Array.isArray(arg[0]) && isHopObject(arg[0][0])));
33
- }
34
- /**
35
- * Deserialize and Serialize the PathSet type.
36
- */
37
- var PathSet = /** @class */ (function (_super) {
38
- __extends(PathSet, _super);
39
- function PathSet() {
40
- return _super !== null && _super.apply(this, arguments) || this;
41
- }
42
- /**
43
- * Construct a PathSet from an Array of Arrays representing paths.
44
- *
45
- * @param value - A PathSet or Array of Array of HopObjects.
46
- * @returns The PathSet constructed from value.
47
- * @throws Error.
48
- */
49
- PathSet.from = function (value) {
50
- if (value instanceof PathSet) {
51
- return value;
52
- }
53
- if (isPathSet(value)) {
54
- var bytes_1 = [];
55
- value.forEach(function (path) {
56
- bytes_1.push(Path_1.default.from(path).toBytes());
57
- bytes_1.push(buffer_1.Buffer.from([Path_1.PATH_SEPARATOR_BYTE]));
58
- });
59
- bytes_1[bytes_1.length - 1] = buffer_1.Buffer.from([Path_1.PATHSET_END_BYTE]);
60
- return new PathSet(buffer_1.Buffer.concat(bytes_1));
61
- }
62
- throw new Error('Cannot construct PathSet from given value');
63
- };
64
- /**
65
- * Construct a PathSet from a BinaryParser.
66
- *
67
- * @param parser - A BinaryParser to read PathSet from.
68
- * @returns The PathSet read from parser.
69
- */
70
- PathSet.fromParser = function (parser) {
71
- var bytes = [];
72
- while (!parser.end()) {
73
- bytes.push(Path_1.default.fromParser(parser).toBytes());
74
- bytes.push(parser.read(1));
75
- if (bytes[bytes.length - 1][0] === Path_1.PATHSET_END_BYTE) {
76
- break;
77
- }
78
- }
79
- return new PathSet(buffer_1.Buffer.concat(bytes));
80
- };
81
- /**
82
- * Get the JSON representation of this PathSet.
83
- *
84
- * @returns An Array of Array of HopObjects, representing this PathSet.
85
- */
86
- PathSet.prototype.toJSON = function () {
87
- var json = [];
88
- var pathParser = new BinaryParser_1.default(this.toString());
89
- while (!pathParser.end()) {
90
- json.push(Path_1.default.fromParser(pathParser).toJSON());
91
- pathParser.skip(1);
92
- }
93
- return json;
94
- };
95
- return PathSet;
96
- }(SerializedType_1.default));
97
- exports.default = PathSet;
98
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/PathSet/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kCAAgC;AAEhC,0DAAoD;AACpD,oDAA8C;AAG9C,+BAAoE;AAEpE,SAAS,WAAW,CAAC,GAAG;;IACtB;uEACmE;IACnE,OAAO,CACL,OAAC,GAAiB,0CAAE,MAAM,MAAK,SAAS;QACxC,OAAC,GAAiB,0CAAE,OAAO,MAAK,SAAS;QACzC,OAAC,GAAiB,0CAAE,QAAQ,MAAK,SAAS,CAC3C,CAAA;IACD,iEAAiE;AACnE,CAAC;AAED,SAAS,SAAS,CAAC,GAAG;IACpB,OAAO,CACL,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC;QACxC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,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I,CAAC,cAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;YAC7C,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;YAE1B,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,uBAAgB,EAAE;gBACnD,MAAK;aACN;SACF;QAED,OAAO,IAAI,OAAO,CAAC,eAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAC1C,CAAC;IAED;;;;OAIG;IACI,wBAAM,GAAb;QACE,IAAM,IAAI,GAAkB,EAAE,CAAA;QAC9B,IAAM,UAAU,GAAG,IAAI,sBAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;QAEpD,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE;YACxB,IAAI,CAAC,IAAI,CAAC,cAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,CAAA;YAC/C,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;SACnB;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IACH,cAAC;AAAD,CAAC,AAlED,CAAqC,wBAAc,GAkElD"}
@@ -1,47 +0,0 @@
1
- import * as bigInt from 'big-integer';
2
- import { Buffer } from 'buffer/';
3
- import type BinaryParser from '../serdes/BinaryParser';
4
- import BytesList from '../serdes/BytesList';
5
- export declare type JSON = string | number | boolean | null | undefined | JSON[] | JsonObject;
6
- export interface JsonObject {
7
- [key: string]: JSON;
8
- }
9
- /**
10
- * The base class for all binary-codec types.
11
- */
12
- export default 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
- * Return the HexString representation of this type.
43
- *
44
- * @returns HexString representation of this.bytes.
45
- */
46
- toString(): string;
47
- }
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var buffer_1 = require("buffer/");
4
- var BytesList_1 = require("../serdes/BytesList");
5
- /**
6
- * The base class for all binary-codec types.
7
- */
8
- var SerializedType = /** @class */ (function () {
9
- function SerializedType(bytes) {
10
- this.bytes = buffer_1.Buffer.alloc(0);
11
- this.bytes = bytes !== null && bytes !== void 0 ? bytes : buffer_1.Buffer.alloc(0);
12
- }
13
- SerializedType.fromParser = function (parser, hint) {
14
- throw new Error('fromParser not implemented');
15
- return this.fromParser(parser, hint);
16
- };
17
- SerializedType.from = function (value) {
18
- throw new Error('from not implemented');
19
- return this.from(value);
20
- };
21
- /**
22
- * Write the bytes representation of a SerializedType to a BytesList.
23
- *
24
- * @param list - The BytesList to write SerializedType bytes to.
25
- */
26
- SerializedType.prototype.toBytesSink = function (list) {
27
- list.put(this.bytes);
28
- };
29
- /**
30
- * Get the hex representation of a SerializedType's bytes.
31
- *
32
- * @returns Hex String of this.bytes.
33
- */
34
- SerializedType.prototype.toHex = function () {
35
- return this.toBytes().toString('hex').toUpperCase();
36
- };
37
- /**
38
- * Get the bytes representation of a SerializedType.
39
- *
40
- * @returns A buffer of the bytes.
41
- */
42
- SerializedType.prototype.toBytes = function () {
43
- if (this.bytes) {
44
- return this.bytes;
45
- }
46
- var bytes = new BytesList_1.default();
47
- this.toBytesSink(bytes);
48
- return bytes.toBytes();
49
- };
50
- /**
51
- * Return the JSON representation of a SerializedType.
52
- *
53
- * @returns Any type, if not overloaded returns hexString representation of bytes.
54
- */
55
- SerializedType.prototype.toJSON = function () {
56
- return this.toHex();
57
- };
58
- /**
59
- * Return the HexString representation of this type.
60
- *
61
- * @returns HexString representation of this.bytes.
62
- */
63
- SerializedType.prototype.toString = function () {
64
- return this.toHex();
65
- };
66
- return SerializedType;
67
- }());
68
- exports.default = SerializedType;
69
- //# sourceMappingURL=SerializedType.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SerializedType.js","sourceRoot":"","sources":["../../src/types/SerializedType.ts"],"names":[],"mappings":";;AACA,kCAAgC;AAGhC,iDAA2C;AAe3C;;GAEG;AACH;IAGE,wBAAmB,KAAa;QAFb,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;IAEa,yBAAU,GAAxB,UACE,MAAoB,EACpB,IAAa;QAEb,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAC7C,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACtC,CAAC;IAEa,mBAAI,GAAlB,UACE,KAAgD;QAEhD,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACzB,CAAC;IAED;;;;OAIG;IACI,oCAAW,GAAlB,UAAmB,IAAe;QAChC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IAED;;;;OAIG;IACI,8BAAK,GAAZ;QACE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,QAA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