ripple-binary-codec 1.5.0-beta.2 → 1.5.0-beta.4
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.
- package/dist/binary.d.ts +23 -7
- package/dist/binary.js +54 -33
- package/dist/binary.js.map +1 -1
- package/dist/coretypes.d.ts +2 -2
- package/dist/coretypes.js +33 -9
- package/dist/coretypes.js.map +1 -1
- package/dist/enums/bytes.d.ts +26 -0
- package/dist/enums/bytes.js +64 -0
- package/dist/enums/bytes.js.map +1 -0
- package/dist/enums/constants.d.ts +4 -0
- package/dist/enums/constants.js +8 -0
- package/dist/enums/constants.js.map +1 -0
- package/dist/enums/definitions.json +108 -138
- package/dist/enums/field.d.ts +29 -0
- package/dist/enums/field.js +59 -0
- package/dist/enums/field.js.map +1 -0
- package/dist/enums/index.d.ts +12 -48
- package/dist/enums/index.js +42 -124
- package/dist/enums/index.js.map +1 -1
- package/dist/enums/src/enums/definitions.json +108 -138
- package/dist/enums/utils-renumber.js +14 -14
- package/dist/enums/utils-renumber.js.map +1 -1
- package/dist/enums/xrpl-definitions-base.d.ts +44 -0
- package/dist/enums/xrpl-definitions-base.js +59 -0
- package/dist/enums/xrpl-definitions-base.js.map +1 -0
- package/dist/enums/xrpl-definitions.d.ts +21 -0
- package/dist/enums/xrpl-definitions.js +29 -0
- package/dist/enums/xrpl-definitions.js.map +1 -0
- package/dist/hash-prefixes.js +3 -3
- package/dist/hash-prefixes.js.map +1 -1
- package/dist/hashes.js +21 -43
- package/dist/hashes.js.map +1 -1
- package/dist/index.d.ts +14 -16
- package/dist/index.js +62 -24
- package/dist/index.js.map +1 -1
- package/dist/ledger-hashes.d.ts +5 -2
- package/dist/ledger-hashes.js +54 -29
- package/dist/ledger-hashes.js.map +1 -1
- package/dist/quality.js +18 -21
- package/dist/quality.js.map +1 -1
- package/dist/serdes/binary-parser.d.ts +6 -3
- package/dist/serdes/binary-parser.js +82 -57
- package/dist/serdes/binary-parser.js.map +1 -1
- package/dist/serdes/binary-serializer.d.ts +1 -1
- package/dist/serdes/binary-serializer.js +59 -40
- package/dist/serdes/binary-serializer.js.map +1 -1
- package/dist/shamap.js +72 -98
- package/dist/shamap.js.map +1 -1
- package/dist/types/account-id.js +18 -35
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.js +71 -88
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.js +10 -27
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.js +26 -44
- package/dist/types/currency.js.map +1 -1
- package/dist/types/hash-128.d.ts +6 -0
- package/dist/types/hash-128.js +23 -25
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.js +8 -25
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-256.js +8 -25
- package/dist/types/hash-256.js.map +1 -1
- package/dist/types/hash.js +20 -38
- package/dist/types/hash.js.map +1 -1
- package/dist/types/index.d.ts +3 -24
- package/dist/types/index.js +39 -28
- package/dist/types/index.js.map +1 -1
- package/dist/types/issue.js +24 -41
- package/dist/types/issue.js.map +1 -1
- package/dist/types/path-set.js +57 -87
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +3 -3
- package/dist/types/serialized-type.js +35 -56
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.js +26 -46
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-object.d.ts +6 -3
- package/dist/types/st-object.js +52 -74
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.js +15 -32
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.js +16 -33
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +1 -1
- package/dist/types/uint-64.js +30 -47
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.js +15 -32
- package/dist/types/uint-8.js.map +1 -1
- package/dist/types/uint.d.ts +1 -1
- package/dist/types/uint.js +10 -27
- package/dist/types/uint.js.map +1 -1
- package/dist/types/vector-256.js +23 -40
- package/dist/types/vector-256.js.map +1 -1
- package/dist/types/xchain-bridge.js +44 -61
- package/dist/types/xchain-bridge.js.map +1 -1
- package/package.json +7 -7
- package/test/amount.test.js +1 -1
- package/test/binary-json.test.js +1 -1
- package/test/binary-parser.test.js +4 -4
- package/test/binary-serializer.test.js +3 -3
- package/test/definitions.test.js +100 -0
- package/test/fixtures/codec-fixtures.json +136 -196
- package/test/hash.test.js +28 -2
- package/test/ledger.test.js +1 -1
- package/test/lower-case-hex.test.js +1 -1
- package/test/pseudo-transaction.test.js +1 -1
- package/test/quality.test.js +1 -1
- package/test/shamap.test.js +3 -3
- package/test/signing-data-encoding.test.js +128 -3
- package/test/tx-encode-decode.test.js +1 -1
- package/test/types.test.js +2 -2
- package/test/uint.test.js +2 -2
- package/test/x-address.test.js +1 -1
- package/dist/types/issued-currency.d.ts +0 -46
- package/dist/types/issued-currency.js +0 -108
- package/dist/types/issued-currency.js.map +0 -1
- package/dist/types/xchain-attestation-batch.d.ts +0 -44
- package/dist/types/xchain-attestation-batch.js +0 -107
- package/dist/types/xchain-attestation-batch.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { XrplDefinitionsBase } from '../enums';
|
|
1
2
|
import { SerializedType, JsonObject } from './serialized-type';
|
|
2
3
|
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
4
|
/**
|
|
@@ -16,14 +17,16 @@ declare class STObject extends SerializedType {
|
|
|
16
17
|
*
|
|
17
18
|
* @param value An object to include
|
|
18
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
|
|
19
21
|
* @returns a STObject object
|
|
20
22
|
*/
|
|
21
|
-
static from<T extends STObject | JsonObject>(value: T, filter?: (...any: any[]) => boolean): STObject;
|
|
23
|
+
static from<T extends STObject | JsonObject>(value: T, filter?: (...any: any[]) => boolean, definitions?: XrplDefinitionsBase): STObject;
|
|
22
24
|
/**
|
|
23
25
|
* Get the JSON interpretation of this.bytes
|
|
24
|
-
*
|
|
26
|
+
* @param definitions rippled definitions used to parse the values of transaction types and such.
|
|
27
|
+
* Can be customized for sidechains and amendments.
|
|
25
28
|
* @returns a JSON object
|
|
26
29
|
*/
|
|
27
|
-
toJSON(): JsonObject;
|
|
30
|
+
toJSON(definitions?: XrplDefinitionsBase): JsonObject;
|
|
28
31
|
}
|
|
29
32
|
export { STObject };
|
package/dist/types/st-object.js
CHANGED
|
@@ -1,34 +1,19 @@
|
|
|
1
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.STObject = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
4
|
+
const enums_1 = require("../enums");
|
|
5
|
+
const serialized_type_1 = require("./serialized-type");
|
|
6
|
+
const ripple_address_codec_1 = require("ripple-address-codec");
|
|
7
|
+
const binary_parser_1 = require("../serdes/binary-parser");
|
|
8
|
+
const binary_serializer_1 = require("../serdes/binary-serializer");
|
|
9
|
+
const buffer_1 = require("buffer/");
|
|
10
|
+
const OBJECT_END_MARKER_BYTE = buffer_1.Buffer.from([0xe1]);
|
|
11
|
+
const OBJECT_END_MARKER = 'ObjectEndMarker';
|
|
12
|
+
const ST_OBJECT = 'STObject';
|
|
13
|
+
const DESTINATION = 'Destination';
|
|
14
|
+
const ACCOUNT = 'Account';
|
|
15
|
+
const SOURCE_TAG = 'SourceTag';
|
|
16
|
+
const DEST_TAG = 'DestinationTag';
|
|
32
17
|
/**
|
|
33
18
|
* Break down an X-Address into an account and a tag
|
|
34
19
|
*
|
|
@@ -36,17 +21,17 @@ var DEST_TAG = 'DestinationTag';
|
|
|
36
21
|
* @param xAddress X-Address corresponding to the field
|
|
37
22
|
*/
|
|
38
23
|
function handleXAddress(field, xAddress) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var tagName;
|
|
24
|
+
const decoded = (0, ripple_address_codec_1.xAddressToClassicAddress)(xAddress);
|
|
25
|
+
let tagName;
|
|
42
26
|
if (field === DESTINATION)
|
|
43
27
|
tagName = DEST_TAG;
|
|
44
28
|
else if (field === ACCOUNT)
|
|
45
29
|
tagName = SOURCE_TAG;
|
|
46
30
|
else if (decoded.tag !== false)
|
|
47
|
-
throw new Error(
|
|
31
|
+
throw new Error(`${field} cannot have an associated tag`);
|
|
48
32
|
return decoded.tag !== false
|
|
49
|
-
?
|
|
33
|
+
? { [field]: decoded.classicAddress, [tagName]: decoded.tag }
|
|
34
|
+
: { [field]: decoded.classicAddress };
|
|
50
35
|
}
|
|
51
36
|
/**
|
|
52
37
|
* Validate that two objects don't both have the same tag fields
|
|
@@ -64,74 +49,67 @@ function checkForDuplicateTags(obj1, obj2) {
|
|
|
64
49
|
/**
|
|
65
50
|
* Class for Serializing/Deserializing objects
|
|
66
51
|
*/
|
|
67
|
-
|
|
68
|
-
__extends(STObject, _super);
|
|
69
|
-
function STObject() {
|
|
70
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
71
|
-
}
|
|
52
|
+
class STObject extends serialized_type_1.SerializedType {
|
|
72
53
|
/**
|
|
73
54
|
* Construct a STObject from a BinaryParser
|
|
74
55
|
*
|
|
75
56
|
* @param parser BinaryParser to read STObject from
|
|
76
57
|
* @returns A STObject object
|
|
77
58
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
59
|
+
static fromParser(parser) {
|
|
60
|
+
const list = new binary_serializer_1.BytesList();
|
|
61
|
+
const bytes = new binary_serializer_1.BinarySerializer(list);
|
|
81
62
|
while (!parser.end()) {
|
|
82
|
-
|
|
63
|
+
const field = parser.readField();
|
|
83
64
|
if (field.name === OBJECT_END_MARKER) {
|
|
84
65
|
break;
|
|
85
66
|
}
|
|
86
|
-
|
|
67
|
+
const associatedValue = parser.readFieldValue(field);
|
|
87
68
|
bytes.writeFieldAndValue(field, associatedValue);
|
|
88
69
|
if (field.type.name === ST_OBJECT) {
|
|
89
70
|
bytes.put(OBJECT_END_MARKER_BYTE);
|
|
90
71
|
}
|
|
91
72
|
}
|
|
92
73
|
return new STObject(list.toBytes());
|
|
93
|
-
}
|
|
74
|
+
}
|
|
94
75
|
/**
|
|
95
76
|
* Construct a STObject from a JSON object
|
|
96
77
|
*
|
|
97
78
|
* @param value An object to include
|
|
98
79
|
* @param filter optional, denote which field to include in serialized object
|
|
80
|
+
* @param definitions optional, types and values to use to encode/decode a transaction
|
|
99
81
|
* @returns a STObject object
|
|
100
82
|
*/
|
|
101
|
-
|
|
83
|
+
static from(value, filter, definitions = enums_1.DEFAULT_DEFINITIONS) {
|
|
102
84
|
if (value instanceof STObject) {
|
|
103
85
|
return value;
|
|
104
86
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
var key = _a[0], val = _a[1];
|
|
111
|
-
var handled = undefined;
|
|
87
|
+
const list = new binary_serializer_1.BytesList();
|
|
88
|
+
const bytes = new binary_serializer_1.BinarySerializer(list);
|
|
89
|
+
let isUnlModify = false;
|
|
90
|
+
const xAddressDecoded = Object.entries(value).reduce((acc, [key, val]) => {
|
|
91
|
+
let handled = undefined;
|
|
112
92
|
if (val && (0, ripple_address_codec_1.isValidXAddress)(val.toString())) {
|
|
113
93
|
handled = handleXAddress(key, val.toString());
|
|
114
94
|
checkForDuplicateTags(handled, value);
|
|
115
95
|
}
|
|
116
|
-
return Object.assign(acc, handled !== null && handled !== void 0 ? handled :
|
|
96
|
+
return Object.assign(acc, handled !== null && handled !== void 0 ? handled : { [key]: val });
|
|
117
97
|
}, {});
|
|
118
|
-
|
|
119
|
-
.map(
|
|
120
|
-
.filter(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
})
|
|
125
|
-
.sort(function (a, b) {
|
|
98
|
+
let sorted = Object.keys(xAddressDecoded)
|
|
99
|
+
.map((f) => definitions.field[f])
|
|
100
|
+
.filter((f) => f !== undefined &&
|
|
101
|
+
xAddressDecoded[f.name] !== undefined &&
|
|
102
|
+
f.isSerialized)
|
|
103
|
+
.sort((a, b) => {
|
|
126
104
|
return a.ordinal - b.ordinal;
|
|
127
105
|
});
|
|
128
106
|
if (filter !== undefined) {
|
|
129
107
|
sorted = sorted.filter(filter);
|
|
130
108
|
}
|
|
131
|
-
sorted.forEach(
|
|
132
|
-
|
|
109
|
+
sorted.forEach((field) => {
|
|
110
|
+
const associatedValue = field.associatedType.from(xAddressDecoded[field.name]);
|
|
133
111
|
if (associatedValue == undefined) {
|
|
134
|
-
throw new TypeError(
|
|
112
|
+
throw new TypeError(`Unable to interpret "${field.name}: ${xAddressDecoded[field.name]}".`);
|
|
135
113
|
}
|
|
136
114
|
if (associatedValue.name === 'UNLModify') {
|
|
137
115
|
// triggered when the TransactionType field has a value of 'UNLModify'
|
|
@@ -140,32 +118,32 @@ var STObject = /** @class */ (function (_super) {
|
|
|
140
118
|
// true when in the UNLModify pseudotransaction (after the transaction type has been processed) and working with the
|
|
141
119
|
// Account field
|
|
142
120
|
// The Account field must not be a part of the UNLModify pseudotransaction encoding, due to a bug in rippled
|
|
143
|
-
|
|
121
|
+
const isUnlModifyWorkaround = field.name == 'Account' && isUnlModify;
|
|
144
122
|
bytes.writeFieldAndValue(field, associatedValue, isUnlModifyWorkaround);
|
|
145
123
|
if (field.type.name === ST_OBJECT) {
|
|
146
124
|
bytes.put(OBJECT_END_MARKER_BYTE);
|
|
147
125
|
}
|
|
148
126
|
});
|
|
149
127
|
return new STObject(list.toBytes());
|
|
150
|
-
}
|
|
128
|
+
}
|
|
151
129
|
/**
|
|
152
130
|
* Get the JSON interpretation of this.bytes
|
|
153
|
-
*
|
|
131
|
+
* @param definitions rippled definitions used to parse the values of transaction types and such.
|
|
132
|
+
* Can be customized for sidechains and amendments.
|
|
154
133
|
* @returns a JSON object
|
|
155
134
|
*/
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
135
|
+
toJSON(definitions) {
|
|
136
|
+
const objectParser = new binary_parser_1.BinaryParser(this.toString(), definitions);
|
|
137
|
+
const accumulator = {};
|
|
159
138
|
while (!objectParser.end()) {
|
|
160
|
-
|
|
139
|
+
const field = objectParser.readField();
|
|
161
140
|
if (field.name === OBJECT_END_MARKER) {
|
|
162
141
|
break;
|
|
163
142
|
}
|
|
164
143
|
accumulator[field.name] = objectParser.readFieldValue(field).toJSON();
|
|
165
144
|
}
|
|
166
145
|
return accumulator;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
}(serialized_type_1.SerializedType));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
170
148
|
exports.STObject = STObject;
|
|
171
149
|
//# sourceMappingURL=st-object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"st-object.js","sourceRoot":"","sources":["../../src/types/st-object.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"st-object.js","sourceRoot":"","sources":["../../src/types/st-object.ts"],"names":[],"mappings":";;;AAAA,oCAKiB;AACjB,uDAA8D;AAC9D,+DAAg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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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.UInt16 = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
const uint_1 = require("./uint");
|
|
5
|
+
const buffer_1 = require("buffer/");
|
|
21
6
|
/**
|
|
22
7
|
* Derived UInt class for serializing/deserializing 16 bit UInt
|
|
23
8
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : UInt16.defaultUInt16.bytes) || this;
|
|
9
|
+
class UInt16 extends uint_1.UInt {
|
|
10
|
+
constructor(bytes) {
|
|
11
|
+
super(bytes !== null && bytes !== void 0 ? bytes : UInt16.defaultUInt16.bytes);
|
|
28
12
|
}
|
|
29
|
-
|
|
13
|
+
static fromParser(parser) {
|
|
30
14
|
return new UInt16(parser.read(UInt16.width));
|
|
31
|
-
}
|
|
15
|
+
}
|
|
32
16
|
/**
|
|
33
17
|
* Construct a UInt16 object from a number
|
|
34
18
|
*
|
|
35
19
|
* @param val UInt16 object or number
|
|
36
20
|
*/
|
|
37
|
-
|
|
21
|
+
static from(val) {
|
|
38
22
|
if (val instanceof UInt16) {
|
|
39
23
|
return val;
|
|
40
24
|
}
|
|
41
25
|
if (typeof val === 'number') {
|
|
42
|
-
|
|
26
|
+
const buf = buffer_1.Buffer.alloc(UInt16.width);
|
|
43
27
|
buf.writeUInt16BE(val, 0);
|
|
44
28
|
return new UInt16(buf);
|
|
45
29
|
}
|
|
46
30
|
throw new Error('Can not construct UInt16 with given value');
|
|
47
|
-
}
|
|
31
|
+
}
|
|
48
32
|
/**
|
|
49
33
|
* get the value of a UInt16 object
|
|
50
34
|
*
|
|
51
35
|
* @returns the number represented by this.bytes
|
|
52
36
|
*/
|
|
53
|
-
|
|
37
|
+
valueOf() {
|
|
54
38
|
return this.bytes.readUInt16BE(0);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
UInt16.defaultUInt16 = new UInt16(buffer_1.Buffer.alloc(UInt16.width));
|
|
58
|
-
return UInt16;
|
|
59
|
-
}(uint_1.UInt));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
60
41
|
exports.UInt16 = UInt16;
|
|
42
|
+
UInt16.width = 16 / 8; // 2
|
|
43
|
+
UInt16.defaultUInt16 = new UInt16(buffer_1.Buffer.alloc(UInt16.width));
|
|
61
44
|
//# sourceMappingURL=uint-16.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint-16.js","sourceRoot":"","sources":["../../src/types/uint-16.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uint-16.js","sourceRoot":"","sources":["../../src/types/uint-16.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAE7B,oCAAgC;AAEhC;;GAEG;AACH,MAAM,MAAO,SAAQ,WAAI;IAIvB,YAAY,KAAa;QACvB,KAAK,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAC5C,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,MAAoB;QACpC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAC9C,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAA4B,GAAM;QAC3C,IAAI,GAAG,YAAY,MAAM,EAAE;YACzB,OAAO,GAAG,CAAA;SACX;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,MAAM,GAAG,GAAG,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACtC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;YACzB,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;SACvB;QAED,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;IAC9D,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;IACnC,CAAC;;AAGM,wBAAM;AAxCa,YAAK,GAAW,EAAE,GAAG,CAAC,CAAA,CAAC,IAAI;AACrC,oBAAa,GAAW,IAAI,MAAM,CAAC,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
package/dist/types/uint-32.js
CHANGED
|
@@ -1,46 +1,30 @@
|
|
|
1
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.UInt32 = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
const uint_1 = require("./uint");
|
|
5
|
+
const buffer_1 = require("buffer/");
|
|
21
6
|
/**
|
|
22
7
|
* Derived UInt class for serializing/deserializing 32 bit UInt
|
|
23
8
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : UInt32.defaultUInt32.bytes) || this;
|
|
9
|
+
class UInt32 extends uint_1.UInt {
|
|
10
|
+
constructor(bytes) {
|
|
11
|
+
super(bytes !== null && bytes !== void 0 ? bytes : UInt32.defaultUInt32.bytes);
|
|
28
12
|
}
|
|
29
|
-
|
|
13
|
+
static fromParser(parser) {
|
|
30
14
|
return new UInt32(parser.read(UInt32.width));
|
|
31
|
-
}
|
|
15
|
+
}
|
|
32
16
|
/**
|
|
33
17
|
* Construct a UInt32 object from a number
|
|
34
18
|
*
|
|
35
19
|
* @param val UInt32 object or number
|
|
36
20
|
*/
|
|
37
|
-
|
|
21
|
+
static from(val) {
|
|
38
22
|
if (val instanceof UInt32) {
|
|
39
23
|
return val;
|
|
40
24
|
}
|
|
41
|
-
|
|
25
|
+
const buf = buffer_1.Buffer.alloc(UInt32.width);
|
|
42
26
|
if (typeof val === 'string') {
|
|
43
|
-
|
|
27
|
+
const num = Number.parseInt(val);
|
|
44
28
|
buf.writeUInt32BE(num, 0);
|
|
45
29
|
return new UInt32(buf);
|
|
46
30
|
}
|
|
@@ -49,18 +33,17 @@ var UInt32 = /** @class */ (function (_super) {
|
|
|
49
33
|
return new UInt32(buf);
|
|
50
34
|
}
|
|
51
35
|
throw new Error('Cannot construct UInt32 from given value');
|
|
52
|
-
}
|
|
36
|
+
}
|
|
53
37
|
/**
|
|
54
38
|
* get the value of a UInt32 object
|
|
55
39
|
*
|
|
56
40
|
* @returns the number represented by this.bytes
|
|
57
41
|
*/
|
|
58
|
-
|
|
42
|
+
valueOf() {
|
|
59
43
|
return this.bytes.readUInt32BE(0);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
UInt32.defaultUInt32 = new UInt32(buffer_1.Buffer.alloc(UInt32.width));
|
|
63
|
-
return UInt32;
|
|
64
|
-
}(uint_1.UInt));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
65
46
|
exports.UInt32 = UInt32;
|
|
47
|
+
UInt32.width = 32 / 8; // 4
|
|
48
|
+
UInt32.defaultUInt32 = new UInt32(buffer_1.Buffer.alloc(UInt32.width));
|
|
66
49
|
//# sourceMappingURL=uint-32.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint-32.js","sourceRoot":"","sources":["../../src/types/uint-32.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uint-32.js","sourceRoot":"","sources":["../../src/types/uint-32.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAE7B,oCAAgC;AAEhC;;GAEG;AACH,MAAM,MAAO,SAAQ,WAAI;IAIvB,YAAY,KAAa;QACvB,KAAK,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAC5C,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,MAAoB;QACpC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAC9C,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAqC,GAAM;QACpD,IAAI,GAAG,YAAY,MAAM,EAAE;YACzB,OAAO,GAAG,CAAA;SACX;QAED,MAAM,GAAG,GAAG,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAEtC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;YAChC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;YACzB,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;SACvB;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;YACzB,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;SACvB;QAED,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;IAC7D,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;IACnC,CAAC;;AAGM,wBAAM;AA/Ca,YAAK,GAAW,EAAE,GAAG,CAAC,CAAA,CAAC,IAAI;AACrC,oBAAa,GAAW,IAAI,MAAM,CAAC,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
package/dist/types/uint-64.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UInt } from './uint';
|
|
2
2
|
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
-
import
|
|
3
|
+
import bigInt = require('big-integer');
|
|
4
4
|
import { Buffer } from 'buffer/';
|
|
5
5
|
/**
|
|
6
6
|
* Derived UInt class for serializing/deserializing 64 bit UInt
|
package/dist/types/uint-64.js
CHANGED
|
@@ -1,104 +1,87 @@
|
|
|
1
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.UInt64 = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
const uint_1 = require("./uint");
|
|
5
|
+
const bigInt = require("big-integer");
|
|
6
|
+
const big_integer_1 = require("big-integer");
|
|
7
|
+
const buffer_1 = require("buffer/");
|
|
8
|
+
const HEX_REGEX = /^[a-fA-F0-9]{1,16}$/;
|
|
9
|
+
const mask = bigInt(0x00000000ffffffff);
|
|
25
10
|
/**
|
|
26
11
|
* Derived UInt class for serializing/deserializing 64 bit UInt
|
|
27
12
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : UInt64.defaultUInt64.bytes) || this;
|
|
13
|
+
class UInt64 extends uint_1.UInt {
|
|
14
|
+
constructor(bytes) {
|
|
15
|
+
super(bytes !== null && bytes !== void 0 ? bytes : UInt64.defaultUInt64.bytes);
|
|
32
16
|
}
|
|
33
|
-
|
|
17
|
+
static fromParser(parser) {
|
|
34
18
|
return new UInt64(parser.read(UInt64.width));
|
|
35
|
-
}
|
|
19
|
+
}
|
|
36
20
|
/**
|
|
37
21
|
* Construct a UInt64 object
|
|
38
22
|
*
|
|
39
23
|
* @param val A UInt64, hex-string, bigInt, or number
|
|
40
24
|
* @returns A UInt64 object
|
|
41
25
|
*/
|
|
42
|
-
|
|
26
|
+
static from(val) {
|
|
43
27
|
if (val instanceof UInt64) {
|
|
44
28
|
return val;
|
|
45
29
|
}
|
|
46
|
-
|
|
30
|
+
let buf = buffer_1.Buffer.alloc(UInt64.width);
|
|
47
31
|
if (typeof val === 'number') {
|
|
48
32
|
if (val < 0) {
|
|
49
33
|
throw new Error('value must be an unsigned integer');
|
|
50
34
|
}
|
|
51
|
-
|
|
52
|
-
|
|
35
|
+
const number = bigInt(val);
|
|
36
|
+
const intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)];
|
|
53
37
|
intBuf[0].writeUInt32BE(Number(number.shiftRight(32)), 0);
|
|
54
38
|
intBuf[1].writeUInt32BE(Number(number.and(mask)), 0);
|
|
55
39
|
return new UInt64(buffer_1.Buffer.concat(intBuf));
|
|
56
40
|
}
|
|
57
41
|
if (typeof val === 'string') {
|
|
58
42
|
if (!HEX_REGEX.test(val)) {
|
|
59
|
-
throw new Error(
|
|
43
|
+
throw new Error(`${val} is not a valid hex-string`);
|
|
60
44
|
}
|
|
61
|
-
|
|
45
|
+
const strBuf = val.padStart(16, '0');
|
|
62
46
|
buf = buffer_1.Buffer.from(strBuf, 'hex');
|
|
63
47
|
return new UInt64(buf);
|
|
64
48
|
}
|
|
65
49
|
if ((0, big_integer_1.isInstance)(val)) {
|
|
66
|
-
|
|
50
|
+
const intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)];
|
|
67
51
|
intBuf[0].writeUInt32BE(Number(val.shiftRight(bigInt(32))), 0);
|
|
68
52
|
intBuf[1].writeUInt32BE(Number(val.and(mask)), 0);
|
|
69
53
|
return new UInt64(buffer_1.Buffer.concat(intBuf));
|
|
70
54
|
}
|
|
71
55
|
throw new Error('Cannot construct UInt64 from given value');
|
|
72
|
-
}
|
|
56
|
+
}
|
|
73
57
|
/**
|
|
74
58
|
* The JSON representation of a UInt64 object
|
|
75
59
|
*
|
|
76
60
|
* @returns a hex-string
|
|
77
61
|
*/
|
|
78
|
-
|
|
62
|
+
toJSON() {
|
|
79
63
|
return this.bytes.toString('hex').toUpperCase();
|
|
80
|
-
}
|
|
64
|
+
}
|
|
81
65
|
/**
|
|
82
66
|
* Get the value of the UInt64
|
|
83
67
|
*
|
|
84
68
|
* @returns the number represented buy this.bytes
|
|
85
69
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
70
|
+
valueOf() {
|
|
71
|
+
const msb = bigInt(this.bytes.slice(0, 4).readUInt32BE(0));
|
|
72
|
+
const lsb = bigInt(this.bytes.slice(4).readUInt32BE(0));
|
|
89
73
|
return msb.shiftLeft(bigInt(32)).or(lsb);
|
|
90
|
-
}
|
|
74
|
+
}
|
|
91
75
|
/**
|
|
92
76
|
* Get the bytes representation of the UInt64 object
|
|
93
77
|
*
|
|
94
78
|
* @returns 8 bytes representing the UInt64
|
|
95
79
|
*/
|
|
96
|
-
|
|
80
|
+
toBytes() {
|
|
97
81
|
return this.bytes;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
UInt64.defaultUInt64 = new UInt64(buffer_1.Buffer.alloc(UInt64.width));
|
|
101
|
-
return UInt64;
|
|
102
|
-
}(uint_1.UInt));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
103
84
|
exports.UInt64 = UInt64;
|
|
85
|
+
UInt64.width = 64 / 8; // 8
|
|
86
|
+
UInt64.defaultUInt64 = new UInt64(buffer_1.Buffer.alloc(UInt64.width));
|
|
104
87
|
//# sourceMappingURL=uint-64.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint-64.js","sourceRoot":"","sources":["../../src/types/uint-64.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uint-64.js","sourceRoot":"","sources":["../../src/types/uint-64.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAE7B,sCAAsC;AACtC,6CAAwC;AACxC,oCAAgC;AAEhC,MAAM,SAAS,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