ripple-binary-codec 1.0.2 → 1.0.3-mpt-beta
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/README.md +3 -3
- package/dist/binary.d.ts +34 -20
- package/dist/binary.js +51 -34
- package/dist/binary.js.map +1 -1
- package/dist/coretypes.d.ts +9 -9
- package/dist/coretypes.js +33 -9
- package/dist/coretypes.js.map +1 -1
- package/dist/enums/bytes.d.ts +25 -0
- package/dist/enums/bytes.js +63 -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 +3066 -1760
- package/dist/enums/field.d.ts +28 -0
- package/dist/enums/field.js +58 -0
- package/dist/enums/field.js.map +1 -0
- package/dist/enums/index.d.ts +12 -46
- package/dist/enums/index.js +22 -110
- package/dist/enums/index.js.map +1 -1
- package/dist/enums/src/enums/definitions.json +3073 -0
- package/dist/enums/utils-renumber.js +20 -20
- 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.d.ts +1 -2
- package/dist/hash-prefixes.js +7 -6
- package/dist/hash-prefixes.js.map +1 -1
- package/dist/hashes.d.ts +7 -8
- package/dist/hashes.js +23 -44
- package/dist/hashes.js.map +1 -1
- package/dist/index.d.ts +16 -17
- package/dist/index.js +65 -40
- package/dist/index.js.map +1 -1
- package/dist/ledger-hashes.d.ts +6 -3
- package/dist/ledger-hashes.js +40 -33
- package/dist/ledger-hashes.js.map +1 -1
- package/dist/quality.d.ts +3 -4
- package/dist/quality.js +20 -19
- package/dist/quality.js.map +1 -1
- package/dist/serdes/binary-parser.d.ts +8 -6
- package/dist/serdes/binary-parser.js +74 -64
- package/dist/serdes/binary-parser.js.map +1 -1
- package/dist/serdes/binary-serializer.d.ts +10 -11
- package/dist/serdes/binary-serializer.js +50 -48
- package/dist/serdes/binary-serializer.js.map +1 -1
- package/dist/shamap.d.ts +6 -7
- package/dist/shamap.js +74 -97
- package/dist/shamap.js.map +1 -1
- package/dist/src/binary.d.ts +90 -0
- package/dist/src/binary.js +128 -0
- package/dist/src/binary.js.map +1 -0
- package/dist/src/coretypes.d.ts +9 -0
- package/dist/src/coretypes.js +48 -0
- package/dist/src/coretypes.js.map +1 -0
- package/dist/src/enums/bytes.d.ts +25 -0
- package/dist/src/enums/bytes.js +63 -0
- package/dist/src/enums/bytes.js.map +1 -0
- package/dist/src/enums/constants.d.ts +4 -0
- package/dist/src/enums/constants.js +8 -0
- package/dist/src/enums/constants.js.map +1 -0
- package/dist/src/enums/definitions.json +3068 -0
- package/dist/src/enums/field.d.ts +28 -0
- package/dist/src/enums/field.js +58 -0
- package/dist/src/enums/field.js.map +1 -0
- package/dist/src/enums/index.d.ts +12 -0
- package/dist/src/enums/index.js +31 -0
- package/dist/src/enums/index.js.map +1 -0
- package/dist/src/enums/utils-renumber.d.ts +101 -0
- package/dist/src/enums/utils-renumber.js +127 -0
- package/dist/src/enums/utils-renumber.js.map +1 -0
- package/dist/src/enums/xrpl-definitions-base.d.ts +44 -0
- package/dist/src/enums/xrpl-definitions-base.js +59 -0
- package/dist/src/enums/xrpl-definitions-base.js.map +1 -0
- package/dist/src/enums/xrpl-definitions.d.ts +21 -0
- package/dist/src/enums/xrpl-definitions.js +29 -0
- package/dist/src/enums/xrpl-definitions.js.map +1 -0
- package/dist/src/hash-prefixes.d.ts +5 -0
- package/dist/src/hash-prefixes.js +41 -0
- package/dist/src/hash-prefixes.js.map +1 -0
- package/dist/src/hashes.d.ts +50 -0
- package/dist/src/hashes.js +76 -0
- package/dist/src/hashes.js.map +1 -0
- package/dist/src/index.d.ts +64 -0
- package/dist/src/index.js +123 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/ledger-hashes.d.ts +48 -0
- package/dist/src/ledger-hashes.js +141 -0
- package/dist/src/ledger-hashes.js.map +1 -0
- package/dist/src/quality.d.ts +21 -0
- package/dist/src/quality.js +42 -0
- package/dist/src/quality.js.map +1 -0
- package/dist/src/serdes/binary-parser.d.ts +100 -0
- package/dist/src/serdes/binary-parser.js +194 -0
- package/dist/src/serdes/binary-parser.js.map +1 -0
- package/dist/src/serdes/binary-serializer.d.ts +81 -0
- package/dist/src/serdes/binary-serializer.js +149 -0
- package/dist/src/serdes/binary-serializer.js.map +1 -0
- package/dist/src/shamap.d.ts +102 -0
- package/dist/src/shamap.js +172 -0
- package/dist/src/shamap.js.map +1 -0
- package/dist/src/types/account-id.d.ts +35 -0
- package/dist/src/types/account-id.js +69 -0
- package/dist/src/types/account-id.js.map +1 -0
- package/dist/src/types/amount.d.ts +91 -0
- package/dist/src/types/amount.js +289 -0
- package/dist/src/types/amount.js.map +1 -0
- package/dist/src/types/blob.d.ts +24 -0
- package/dist/src/types/blob.js +43 -0
- package/dist/src/types/blob.js.map +1 -0
- package/dist/src/types/currency.d.ts +28 -0
- package/dist/src/types/currency.js +127 -0
- package/dist/src/types/currency.js.map +1 -0
- package/dist/src/types/hash-128.d.ts +16 -0
- package/dist/src/types/hash-128.js +32 -0
- package/dist/src/types/hash-128.js.map +1 -0
- package/dist/src/types/hash-160.d.ts +10 -0
- package/dist/src/types/hash-160.js +19 -0
- package/dist/src/types/hash-160.js.map +1 -0
- package/dist/src/types/hash-192.d.ts +10 -0
- package/dist/src/types/hash-192.js +19 -0
- package/dist/src/types/hash-192.js.map +1 -0
- package/dist/src/types/hash-256.d.ts +10 -0
- package/dist/src/types/hash-256.js +16 -0
- package/dist/src/types/hash-256.js.map +1 -0
- package/dist/src/types/hash.d.ts +40 -0
- package/dist/src/types/hash.js +73 -0
- package/dist/src/types/hash.js.map +1 -0
- package/dist/src/types/index.d.ts +19 -0
- package/dist/src/types/index.js +64 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/issue.d.ts +38 -0
- package/dist/src/types/issue.js +81 -0
- package/dist/src/types/issue.js.map +1 -0
- package/dist/src/types/path-set.d.ts +36 -0
- package/dist/src/types/path-set.js +233 -0
- package/dist/src/types/path-set.js.map +1 -0
- package/dist/src/types/serialized-type.d.ts +70 -0
- package/dist/src/types/serialized-type.js +105 -0
- package/dist/src/types/serialized-type.js.map +1 -0
- package/dist/src/types/st-array.d.ts +31 -0
- package/dist/src/types/st-array.js +86 -0
- package/dist/src/types/st-array.js.map +1 -0
- package/dist/src/types/st-object.d.ts +32 -0
- package/dist/src/types/st-object.js +155 -0
- package/dist/src/types/st-object.js.map +1 -0
- package/dist/src/types/uint-16.d.ts +24 -0
- package/dist/src/types/uint-16.js +45 -0
- package/dist/src/types/uint-16.js.map +1 -0
- package/dist/src/types/uint-32.d.ts +24 -0
- package/dist/src/types/uint-32.js +50 -0
- package/dist/src/types/uint-32.js.map +1 -0
- package/dist/src/types/uint-64.d.ts +37 -0
- package/dist/src/types/uint-64.js +86 -0
- package/dist/src/types/uint-64.js.map +1 -0
- package/dist/src/types/uint-8.d.ts +24 -0
- package/dist/src/types/uint-8.js +46 -0
- package/dist/src/types/uint-8.js.map +1 -0
- package/dist/src/types/uint.d.ts +29 -0
- package/dist/src/types/uint.js +47 -0
- package/dist/src/types/uint.js.map +1 -0
- package/dist/src/types/vector-256.d.ts +30 -0
- package/dist/src/types/vector-256.js +73 -0
- package/dist/src/types/vector-256.js.map +1 -0
- package/dist/src/types/xchain-bridge.d.ts +44 -0
- package/dist/src/types/xchain-bridge.js +102 -0
- package/dist/src/types/xchain-bridge.js.map +1 -0
- package/dist/src/utils.d.ts +47 -0
- package/dist/src/utils.js +137 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/account-id.d.ts +2 -3
- package/dist/types/account-id.js +29 -37
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.d.ts +33 -10
- package/dist/types/amount.js +181 -101
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.d.ts +3 -4
- package/dist/types/blob.js +16 -27
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.d.ts +5 -13
- package/dist/types/currency.js +53 -66
- package/dist/types/currency.js.map +1 -1
- package/dist/types/hash-128.d.ts +8 -3
- package/dist/types/hash-128.js +23 -22
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.d.ts +2 -3
- package/dist/types/hash-160.js +7 -24
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-192.d.ts +10 -0
- package/dist/types/hash-192.js +19 -0
- package/dist/types/hash-192.js.map +1 -0
- package/dist/types/hash-256.d.ts +2 -3
- package/dist/types/hash-256.js +7 -22
- package/dist/types/hash-256.js.map +1 -1
- package/dist/types/hash.d.ts +4 -5
- package/dist/types/hash.js +25 -39
- package/dist/types/hash.js.map +1 -1
- package/dist/types/index.d.ts +19 -33
- package/dist/types/index.js +44 -24
- package/dist/types/index.js.map +1 -1
- package/dist/types/issue.d.ts +38 -0
- package/dist/types/issue.js +81 -0
- package/dist/types/issue.js.map +1 -0
- package/dist/types/path-set.d.ts +2 -2
- package/dist/types/path-set.js +73 -94
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +26 -18
- package/dist/types/serialized-type.js +50 -60
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.d.ts +7 -4
- package/dist/types/st-array.js +36 -47
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-object.d.ts +8 -5
- package/dist/types/st-object.js +73 -74
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.d.ts +3 -4
- package/dist/types/uint-16.js +20 -33
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.d.ts +3 -4
- package/dist/types/uint-32.js +23 -36
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +5 -6
- package/dist/types/uint-64.js +44 -48
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.d.ts +3 -4
- package/dist/types/uint-8.js +21 -33
- package/dist/types/uint-8.js.map +1 -1
- package/dist/types/uint.d.ts +5 -5
- package/dist/types/uint.js +17 -27
- package/dist/types/uint.js.map +1 -1
- package/dist/types/vector-256.d.ts +3 -4
- package/dist/types/vector-256.js +28 -45
- package/dist/types/vector-256.js.map +1 -1
- package/dist/types/xchain-bridge.d.ts +44 -0
- package/dist/types/xchain-bridge.js +102 -0
- package/dist/types/xchain-bridge.js.map +1 -0
- package/dist/utils.d.ts +47 -0
- package/dist/utils.js +137 -0
- package/dist/utils.js.map +1 -0
- package/package.json +23 -33
- package/src/README.md +5 -0
- package/src/binary.ts +194 -0
- package/src/coretypes.ts +31 -0
- package/src/enums/README.md +144 -0
- package/src/enums/bytes.ts +74 -0
- package/src/enums/constants.ts +4 -0
- package/src/enums/definitions.json +3073 -0
- package/src/enums/field.ts +84 -0
- package/src/enums/index.ts +34 -0
- package/src/enums/utils-renumber.ts +134 -0
- package/src/enums/xrpl-definitions-base.ts +111 -0
- package/src/enums/xrpl-definitions.ts +32 -0
- package/src/hash-prefixes.ts +40 -0
- package/src/hashes.ts +75 -0
- package/src/index.ts +153 -0
- package/src/ledger-hashes.ts +191 -0
- package/src/quality.ts +38 -0
- package/src/serdes/binary-parser.ts +228 -0
- package/src/serdes/binary-serializer.ts +166 -0
- package/src/shamap.ts +186 -0
- package/src/types/account-id.ts +86 -0
- package/src/types/amount.ts +362 -0
- package/src/types/blob.ts +46 -0
- package/src/types/currency.ts +140 -0
- package/src/types/hash-128.ts +33 -0
- package/src/types/hash-160.ts +19 -0
- package/src/types/hash-192.ts +19 -0
- package/src/types/hash-256.ts +15 -0
- package/src/types/hash.ts +83 -0
- package/src/types/index.ts +66 -0
- package/src/types/issue.ts +96 -0
- package/src/types/path-set.ts +290 -0
- package/src/types/serialized-type.ts +122 -0
- package/src/types/st-array.ts +113 -0
- package/src/types/st-object.ts +192 -0
- package/src/types/uint-16.ts +53 -0
- package/src/types/uint-32.ts +59 -0
- package/src/types/uint-64.ts +104 -0
- package/src/types/uint-8.ts +52 -0
- package/src/types/uint.ts +60 -0
- package/src/types/vector-256.ts +79 -0
- package/src/types/xchain-bridge.ts +128 -0
- package/src/utils.ts +152 -0
- package/HISTORY.md +0 -74
- package/test/amount.test.js +0 -43
- package/test/binary-json.test.js +0 -47
- package/test/binary-parser.test.js +0 -397
- package/test/binary-serializer.test.js +0 -248
- package/test/fixtures/account-tx-transactions.db +0 -0
- package/test/fixtures/codec-fixtures.json +0 -4466
- package/test/fixtures/data-driven-tests.json +0 -3721
- package/test/fixtures/delivermin-tx-binary.json +0 -1
- package/test/fixtures/delivermin-tx.json +0 -98
- package/test/fixtures/deposit-preauth-tx-binary.json +0 -1
- package/test/fixtures/deposit-preauth-tx-meta-binary.json +0 -1
- package/test/fixtures/deposit-preauth-tx.json +0 -58
- package/test/fixtures/escrow-cancel-binary.json +0 -1
- package/test/fixtures/escrow-cancel-tx.json +0 -6
- package/test/fixtures/escrow-create-binary.json +0 -1
- package/test/fixtures/escrow-create-tx.json +0 -10
- package/test/fixtures/escrow-finish-binary.json +0 -1
- package/test/fixtures/escrow-finish-meta-binary.json +0 -1
- package/test/fixtures/escrow-finish-tx.json +0 -95
- package/test/fixtures/ledger-full-38129.json +0 -1
- package/test/fixtures/ledger-full-40000.json +0 -1
- package/test/fixtures/negative-unl.json +0 -12
- package/test/fixtures/payment-channel-claim-binary.json +0 -1
- package/test/fixtures/payment-channel-claim-tx.json +0 -8
- package/test/fixtures/payment-channel-create-binary.json +0 -1
- package/test/fixtures/payment-channel-create-tx.json +0 -11
- package/test/fixtures/payment-channel-fund-binary.json +0 -1
- package/test/fixtures/payment-channel-fund-tx.json +0 -7
- package/test/fixtures/signerlistset-tx-binary.json +0 -1
- package/test/fixtures/signerlistset-tx-meta-binary.json +0 -1
- package/test/fixtures/signerlistset-tx.json +0 -94
- package/test/fixtures/x-codec-fixtures.json +0 -188
- package/test/hash.test.js +0 -82
- package/test/ledger.test.js +0 -29
- package/test/lower-case-hex.test.js +0 -45
- package/test/pseudo-transaction.test.js +0 -38
- package/test/quality.test.js +0 -15
- package/test/shamap.test.js +0 -88
- package/test/signing-data-encoding.test.js +0 -129
- package/test/tx-encode-decode.test.js +0 -80
- package/test/types.test.js +0 -34
- package/test/uint.test.js +0 -40
- package/test/utils.js +0 -29
- package/test/x-address.test.js +0 -147
package/dist/types/uint-32.js
CHANGED
|
@@ -1,63 +1,50 @@
|
|
|
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 (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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.UInt32 = void 0;
|
|
17
|
-
|
|
4
|
+
const uint_1 = require("./uint");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
18
6
|
/**
|
|
19
7
|
* Derived UInt class for serializing/deserializing 32 bit UInt
|
|
20
8
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
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);
|
|
25
12
|
}
|
|
26
|
-
|
|
13
|
+
static fromParser(parser) {
|
|
27
14
|
return new UInt32(parser.read(UInt32.width));
|
|
28
|
-
}
|
|
15
|
+
}
|
|
29
16
|
/**
|
|
30
17
|
* Construct a UInt32 object from a number
|
|
31
18
|
*
|
|
32
19
|
* @param val UInt32 object or number
|
|
33
20
|
*/
|
|
34
|
-
|
|
21
|
+
static from(val) {
|
|
35
22
|
if (val instanceof UInt32) {
|
|
36
23
|
return val;
|
|
37
24
|
}
|
|
38
|
-
|
|
39
|
-
if (typeof val ===
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
const buf = new Uint8Array(UInt32.width);
|
|
26
|
+
if (typeof val === 'string') {
|
|
27
|
+
const num = Number.parseInt(val);
|
|
28
|
+
(0, utils_1.writeUInt32BE)(buf, num, 0);
|
|
42
29
|
return new UInt32(buf);
|
|
43
30
|
}
|
|
44
|
-
if (typeof val ===
|
|
45
|
-
|
|
31
|
+
if (typeof val === 'number') {
|
|
32
|
+
UInt32.checkUintRange(val, 0, 0xffffffff);
|
|
33
|
+
(0, utils_1.writeUInt32BE)(buf, val, 0);
|
|
46
34
|
return new UInt32(buf);
|
|
47
35
|
}
|
|
48
|
-
throw new Error(
|
|
49
|
-
}
|
|
36
|
+
throw new Error('Cannot construct UInt32 from given value');
|
|
37
|
+
}
|
|
50
38
|
/**
|
|
51
39
|
* get the value of a UInt32 object
|
|
52
40
|
*
|
|
53
41
|
* @returns the number represented by this.bytes
|
|
54
42
|
*/
|
|
55
|
-
|
|
56
|
-
return this.bytes
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
UInt32.defaultUInt32 = new UInt32(Buffer.alloc(UInt32.width));
|
|
60
|
-
return UInt32;
|
|
61
|
-
}(uint_1.UInt));
|
|
43
|
+
valueOf() {
|
|
44
|
+
return parseInt((0, utils_1.readUInt32BE)(this.bytes, 0), 10);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
62
47
|
exports.UInt32 = UInt32;
|
|
48
|
+
UInt32.width = 32 / 8; // 4
|
|
49
|
+
UInt32.defaultUInt32 = new UInt32(new Uint8Array(UInt32.width));
|
|
63
50
|
//# 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,oCAAsD;AAEtD;;GAEG;AACH,MAAM,MAAO,SAAQ,WAAI;IAMvB,YAAY,KAAiB;QAC3B,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,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAExC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;YAChC,IAAA,qBAAa,EAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;YAC1B,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;SACvB;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,EAAE,UAAU,CAAC,CAAA;YACzC,IAAA,qBAAa,EAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;YAC1B,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;SACvB;QAED,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;IAC7D,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,OAAO,QAAQ,CAAC,IAAA,oBAAY,EAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAClD,CAAC;;AAGM,wBAAM;AAlDa,YAAK,GAAW,EAAE,GAAG,CAAC,CAAA,CAAC,IAAI;AACrC,oBAAa,GAAW,IAAI,MAAM,CAChD,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAC7B,CAAA"}
|
package/dist/types/uint-64.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { BinaryParser } from "../serdes/binary-parser";
|
|
1
|
+
import { UInt } from './uint';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
4
3
|
/**
|
|
5
4
|
* Derived UInt class for serializing/deserializing 64 bit UInt
|
|
6
5
|
*/
|
|
7
6
|
declare class UInt64 extends UInt {
|
|
8
7
|
protected static readonly width: number;
|
|
9
8
|
static readonly defaultUInt64: UInt64;
|
|
10
|
-
constructor(bytes:
|
|
9
|
+
constructor(bytes: Uint8Array);
|
|
11
10
|
static fromParser(parser: BinaryParser): UInt;
|
|
12
11
|
/**
|
|
13
12
|
* Construct a UInt64 object
|
|
14
13
|
*
|
|
15
|
-
* @param val A UInt64, hex-string,
|
|
14
|
+
* @param val A UInt64, hex-string, bigInt, or number
|
|
16
15
|
* @returns A UInt64 object
|
|
17
16
|
*/
|
|
18
17
|
static from<T extends UInt64 | string | bigint | number>(val: T): UInt64;
|
|
@@ -33,6 +32,6 @@ declare class UInt64 extends UInt {
|
|
|
33
32
|
*
|
|
34
33
|
* @returns 8 bytes representing the UInt64
|
|
35
34
|
*/
|
|
36
|
-
toBytes():
|
|
35
|
+
toBytes(): Uint8Array;
|
|
37
36
|
}
|
|
38
37
|
export { UInt64 };
|
package/dist/types/uint-64.js
CHANGED
|
@@ -1,90 +1,86 @@
|
|
|
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 (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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.UInt64 = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
const uint_1 = require("./uint");
|
|
5
|
+
const utils_1 = require("@xrplf/isomorphic/utils");
|
|
6
|
+
const utils_2 = require("../utils");
|
|
7
|
+
const HEX_REGEX = /^[a-fA-F0-9]{1,16}$/;
|
|
8
|
+
const mask = BigInt(0x00000000ffffffff);
|
|
19
9
|
/**
|
|
20
10
|
* Derived UInt class for serializing/deserializing 64 bit UInt
|
|
21
11
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : UInt64.defaultUInt64.bytes) || this;
|
|
12
|
+
class UInt64 extends uint_1.UInt {
|
|
13
|
+
constructor(bytes) {
|
|
14
|
+
super(bytes !== null && bytes !== void 0 ? bytes : UInt64.defaultUInt64.bytes);
|
|
26
15
|
}
|
|
27
|
-
|
|
16
|
+
static fromParser(parser) {
|
|
28
17
|
return new UInt64(parser.read(UInt64.width));
|
|
29
|
-
}
|
|
18
|
+
}
|
|
30
19
|
/**
|
|
31
20
|
* Construct a UInt64 object
|
|
32
21
|
*
|
|
33
|
-
* @param val A UInt64, hex-string,
|
|
22
|
+
* @param val A UInt64, hex-string, bigInt, or number
|
|
34
23
|
* @returns A UInt64 object
|
|
35
24
|
*/
|
|
36
|
-
|
|
25
|
+
static from(val) {
|
|
37
26
|
if (val instanceof UInt64) {
|
|
38
27
|
return val;
|
|
39
28
|
}
|
|
40
|
-
|
|
41
|
-
if (typeof val ===
|
|
29
|
+
let buf = new Uint8Array(UInt64.width);
|
|
30
|
+
if (typeof val === 'number') {
|
|
42
31
|
if (val < 0) {
|
|
43
|
-
throw new Error(
|
|
32
|
+
throw new Error('value must be an unsigned integer');
|
|
44
33
|
}
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
const number = BigInt(val);
|
|
35
|
+
const intBuf = [new Uint8Array(4), new Uint8Array(4)];
|
|
36
|
+
(0, utils_2.writeUInt32BE)(intBuf[0], Number(number >> BigInt(32)), 0);
|
|
37
|
+
(0, utils_2.writeUInt32BE)(intBuf[1], Number(number & BigInt(mask)), 0);
|
|
38
|
+
return new UInt64((0, utils_1.concat)(intBuf));
|
|
47
39
|
}
|
|
48
|
-
if (typeof val ===
|
|
40
|
+
if (typeof val === 'string') {
|
|
49
41
|
if (!HEX_REGEX.test(val)) {
|
|
50
|
-
throw new Error(val
|
|
42
|
+
throw new Error(`${val} is not a valid hex-string`);
|
|
51
43
|
}
|
|
52
|
-
|
|
44
|
+
const strBuf = val.padStart(16, '0');
|
|
45
|
+
buf = (0, utils_1.hexToBytes)(strBuf);
|
|
53
46
|
return new UInt64(buf);
|
|
54
47
|
}
|
|
55
|
-
if (typeof val ===
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
if (typeof val === 'bigint') {
|
|
49
|
+
const intBuf = [new Uint8Array(4), new Uint8Array(4)];
|
|
50
|
+
(0, utils_2.writeUInt32BE)(intBuf[0], Number(Number(val >> BigInt(32))), 0);
|
|
51
|
+
(0, utils_2.writeUInt32BE)(intBuf[1], Number(val & BigInt(mask)), 0);
|
|
52
|
+
return new UInt64((0, utils_1.concat)(intBuf));
|
|
58
53
|
}
|
|
59
|
-
throw new Error(
|
|
60
|
-
}
|
|
54
|
+
throw new Error('Cannot construct UInt64 from given value');
|
|
55
|
+
}
|
|
61
56
|
/**
|
|
62
57
|
* The JSON representation of a UInt64 object
|
|
63
58
|
*
|
|
64
59
|
* @returns a hex-string
|
|
65
60
|
*/
|
|
66
|
-
|
|
67
|
-
return this.bytes
|
|
68
|
-
}
|
|
61
|
+
toJSON() {
|
|
62
|
+
return (0, utils_1.bytesToHex)(this.bytes);
|
|
63
|
+
}
|
|
69
64
|
/**
|
|
70
65
|
* Get the value of the UInt64
|
|
71
66
|
*
|
|
72
67
|
* @returns the number represented buy this.bytes
|
|
73
68
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
valueOf() {
|
|
70
|
+
const msb = BigInt((0, utils_2.readUInt32BE)(this.bytes.slice(0, 4), 0));
|
|
71
|
+
const lsb = BigInt((0, utils_2.readUInt32BE)(this.bytes.slice(4), 0));
|
|
72
|
+
return (msb << BigInt(32)) | lsb;
|
|
73
|
+
}
|
|
77
74
|
/**
|
|
78
75
|
* Get the bytes representation of the UInt64 object
|
|
79
76
|
*
|
|
80
77
|
* @returns 8 bytes representing the UInt64
|
|
81
78
|
*/
|
|
82
|
-
|
|
79
|
+
toBytes() {
|
|
83
80
|
return this.bytes;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
UInt64.defaultUInt64 = new UInt64(Buffer.alloc(UInt64.width));
|
|
87
|
-
return UInt64;
|
|
88
|
-
}(uint_1.UInt));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
89
83
|
exports.UInt64 = UInt64;
|
|
84
|
+
UInt64.width = 64 / 8; // 8
|
|
85
|
+
UInt64.defaultUInt64 = new UInt64(new Uint8Array(UInt64.width));
|
|
90
86
|
//# 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,mDAAwE;AACxE,oCAAsD;AAEtD,MAAM,SAAS,GAAG,qBAAqB,CAAA;AACvC,MAAM,IAAI,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAA;AAEvC;;GAEG;AACH,MAAM,MAAO,SAAQ,WAAI;IAMvB,YAAY,KAAiB;QAC3B,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;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAA8C,GAAM;QAC7D,IAAI,GAAG,YAAY,MAAM,EAAE;YACzB,OAAO,GAAG,CAAA;SACX;QAED,IAAI,GAAG,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAEtC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,IAAI,GAAG,GAAG,CAAC,EAAE;gBACX,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;aACrD;YAED,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;YAE1B,MAAM,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;YACrD,IAAA,qBAAa,EAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YACzD,IAAA,qBAAa,EAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YAE1D,OAAO,IAAI,MAAM,CAAC,IAAA,cAAM,EAAC,MAAM,CAAC,CAAC,CAAA;SAClC;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;gBACxB,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,4BAA4B,CAAC,CAAA;aACpD;YAED,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;YACpC,GAAG,GAAG,IAAA,kBAAU,EAAC,MAAM,CAAC,CAAA;YACxB,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;SACvB;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,MAAM,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;YACrD,IAAA,qBAAa,EAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YAC9D,IAAA,qBAAa,EAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YAEvD,OAAO,IAAI,MAAM,CAAC,IAAA,cAAM,EAAC,MAAM,CAAC,CAAC,CAAA;SAClC;QAED,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;IAC7D,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,OAAO,IAAA,kBAAU,EAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,MAAM,GAAG,GAAG,MAAM,CAAC,IAAA,oBAAY,EAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QAC3D,MAAM,GAAG,GAAG,MAAM,CAAC,IAAA,oBAAY,EAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QACxD,OAAO,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAA;IAClC,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;;AAGM,wBAAM;AA3Fa,YAAK,GAAW,EAAE,GAAG,CAAC,CAAA,CAAC,IAAI;AACrC,oBAAa,GAAW,IAAI,MAAM,CAChD,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAC7B,CAAA"}
|
package/dist/types/uint-8.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { BinaryParser } from "../serdes/binary-parser";
|
|
1
|
+
import { UInt } from './uint';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
4
3
|
/**
|
|
5
4
|
* Derived UInt class for serializing/deserializing 8 bit UInt
|
|
6
5
|
*/
|
|
7
6
|
declare class UInt8 extends UInt {
|
|
8
7
|
protected static readonly width: number;
|
|
9
8
|
static readonly defaultUInt8: UInt8;
|
|
10
|
-
constructor(bytes:
|
|
9
|
+
constructor(bytes: Uint8Array);
|
|
11
10
|
static fromParser(parser: BinaryParser): UInt;
|
|
12
11
|
/**
|
|
13
12
|
* Construct a UInt8 object from a number
|
package/dist/types/uint-8.js
CHANGED
|
@@ -1,58 +1,46 @@
|
|
|
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 (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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.UInt8 = void 0;
|
|
17
|
-
|
|
4
|
+
const uint_1 = require("./uint");
|
|
5
|
+
const utils_1 = require("@xrplf/isomorphic/utils");
|
|
6
|
+
const utils_2 = require("../utils");
|
|
18
7
|
/**
|
|
19
8
|
* Derived UInt class for serializing/deserializing 8 bit UInt
|
|
20
9
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : UInt8.defaultUInt8.bytes) || this;
|
|
10
|
+
class UInt8 extends uint_1.UInt {
|
|
11
|
+
constructor(bytes) {
|
|
12
|
+
super(bytes !== null && bytes !== void 0 ? bytes : UInt8.defaultUInt8.bytes);
|
|
25
13
|
}
|
|
26
|
-
|
|
14
|
+
static fromParser(parser) {
|
|
27
15
|
return new UInt8(parser.read(UInt8.width));
|
|
28
|
-
}
|
|
16
|
+
}
|
|
29
17
|
/**
|
|
30
18
|
* Construct a UInt8 object from a number
|
|
31
19
|
*
|
|
32
20
|
* @param val UInt8 object or number
|
|
33
21
|
*/
|
|
34
|
-
|
|
22
|
+
static from(val) {
|
|
35
23
|
if (val instanceof UInt8) {
|
|
36
24
|
return val;
|
|
37
25
|
}
|
|
38
|
-
if (typeof val ===
|
|
39
|
-
|
|
40
|
-
buf.
|
|
26
|
+
if (typeof val === 'number') {
|
|
27
|
+
UInt8.checkUintRange(val, 0, 0xff);
|
|
28
|
+
const buf = new Uint8Array(UInt8.width);
|
|
29
|
+
(0, utils_2.writeUInt8)(buf, val, 0);
|
|
41
30
|
return new UInt8(buf);
|
|
42
31
|
}
|
|
43
|
-
throw new Error(
|
|
44
|
-
}
|
|
32
|
+
throw new Error('Cannot construct UInt8 from given value');
|
|
33
|
+
}
|
|
45
34
|
/**
|
|
46
35
|
* get the value of a UInt8 object
|
|
47
36
|
*
|
|
48
37
|
* @returns the number represented by this.bytes
|
|
49
38
|
*/
|
|
50
|
-
|
|
51
|
-
return this.bytes
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
UInt8.defaultUInt8 = new UInt8(Buffer.alloc(UInt8.width));
|
|
55
|
-
return UInt8;
|
|
56
|
-
}(uint_1.UInt));
|
|
39
|
+
valueOf() {
|
|
40
|
+
return parseInt((0, utils_1.bytesToHex)(this.bytes), 16);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
57
43
|
exports.UInt8 = UInt8;
|
|
44
|
+
UInt8.width = 8 / 8; // 1
|
|
45
|
+
UInt8.defaultUInt8 = new UInt8(new Uint8Array(UInt8.width));
|
|
58
46
|
//# sourceMappingURL=uint-8.js.map
|
package/dist/types/uint-8.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint-8.js","sourceRoot":"","sources":["../../src/types/uint-8.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uint-8.js","sourceRoot":"","sources":["../../src/types/uint-8.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAE7B,mDAAoD;AACpD,oCAAqC;AAErC;;GAEG;AACH,MAAM,KAAM,SAAQ,WAAI;IAItB,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,MAAoB;QACpC,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5C,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAA2B,GAAM;QAC1C,IAAI,GAAG,YAAY,KAAK,EAAE;YACxB,OAAO,GAAG,CAAA;SACX;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,KAAK,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;YAElC,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YACvC,IAAA,kBAAU,EAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;YACvB,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;SACtB;QAED,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;IAC5D,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,OAAO,QAAQ,CAAC,IAAA,kBAAU,EAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA;IAC7C,CAAC;;AAGM,sBAAK;AA1Cc,WAAK,GAAW,CAAC,GAAG,CAAC,CAAA,CAAC,IAAI;AACpC,kBAAY,GAAU,IAAI,KAAK,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
package/dist/types/uint.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import { Comparable } from "./serialized-type";
|
|
1
|
+
import { Comparable } from './serialized-type';
|
|
3
2
|
/**
|
|
4
3
|
* Base class for serializing and deserializing unsigned integers.
|
|
5
4
|
*/
|
|
6
|
-
declare abstract class UInt extends Comparable {
|
|
5
|
+
declare abstract class UInt extends Comparable<UInt | number> {
|
|
7
6
|
protected static width: number;
|
|
8
|
-
constructor(bytes:
|
|
7
|
+
constructor(bytes: Uint8Array);
|
|
9
8
|
/**
|
|
10
9
|
* Overload of compareTo for Comparable
|
|
11
10
|
*
|
|
12
11
|
* @param other other UInt to compare this to
|
|
13
12
|
* @returns -1, 0, or 1 depending on how the objects relate to each other
|
|
14
13
|
*/
|
|
15
|
-
compareTo(other: UInt): number;
|
|
14
|
+
compareTo(other: UInt | number): number;
|
|
16
15
|
/**
|
|
17
16
|
* Convert a UInt object to JSON
|
|
18
17
|
*
|
|
@@ -25,5 +24,6 @@ declare abstract class UInt extends Comparable {
|
|
|
25
24
|
* @returns the value
|
|
26
25
|
*/
|
|
27
26
|
abstract valueOf(): number | bigint;
|
|
27
|
+
static checkUintRange(val: number, min: number, max: number): void;
|
|
28
28
|
}
|
|
29
29
|
export { UInt };
|
package/dist/types/uint.js
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
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 (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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.UInt = void 0;
|
|
17
|
-
|
|
4
|
+
const serialized_type_1 = require("./serialized-type");
|
|
18
5
|
/**
|
|
19
|
-
* Compare numbers and
|
|
6
|
+
* Compare numbers and bigInts n1 and n2
|
|
20
7
|
*
|
|
21
8
|
* @param n1 First object to compare
|
|
22
9
|
* @param n2 Second object to compare
|
|
@@ -28,10 +15,9 @@ function compare(n1, n2) {
|
|
|
28
15
|
/**
|
|
29
16
|
* Base class for serializing and deserializing unsigned integers.
|
|
30
17
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return _super.call(this, bytes) || this;
|
|
18
|
+
class UInt extends serialized_type_1.Comparable {
|
|
19
|
+
constructor(bytes) {
|
|
20
|
+
super(bytes);
|
|
35
21
|
}
|
|
36
22
|
/**
|
|
37
23
|
* Overload of compareTo for Comparable
|
|
@@ -39,19 +25,23 @@ var UInt = /** @class */ (function (_super) {
|
|
|
39
25
|
* @param other other UInt to compare this to
|
|
40
26
|
* @returns -1, 0, or 1 depending on how the objects relate to each other
|
|
41
27
|
*/
|
|
42
|
-
|
|
28
|
+
compareTo(other) {
|
|
43
29
|
return compare(this.valueOf(), other.valueOf());
|
|
44
|
-
}
|
|
30
|
+
}
|
|
45
31
|
/**
|
|
46
32
|
* Convert a UInt object to JSON
|
|
47
33
|
*
|
|
48
34
|
* @returns number or string represented by this.bytes
|
|
49
35
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return typeof val ===
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
toJSON() {
|
|
37
|
+
const val = this.valueOf();
|
|
38
|
+
return typeof val === 'number' ? val : val.toString();
|
|
39
|
+
}
|
|
40
|
+
static checkUintRange(val, min, max) {
|
|
41
|
+
if (val < min || val > max) {
|
|
42
|
+
throw new Error(`Invalid ${this.constructor.name}: ${val} must be >= ${min} and <= ${max}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
56
46
|
exports.UInt = UInt;
|
|
57
47
|
//# sourceMappingURL=uint.js.map
|
package/dist/types/uint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint.js","sourceRoot":"","sources":["../../src/types/uint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uint.js","sourceRoot":"","sources":["../../src/types/uint.ts"],"names":[],"mappings":";;;AAAA,uDAA8C;AAE9C;;;;;;GAMG;AACH,SAAS,OAAO,CAAC,EAAmB,EAAE,EAAmB;IACvD,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACxC,CAAC;AAED;;GAEG;AACH,MAAe,IAAK,SAAQ,4BAAyB;IAGnD,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,CAAC,CAAA;IACd,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,KAAoB;QAC5B,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;IACjD,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;QAC1B,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA;IACvD,CAAC;IASD,MAAM,CAAC,cAAc,CAAC,GAAW,EAAE,GAAW,EAAE,GAAW;QACzD,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,EAAE;YAC1B,MAAM,IAAI,KAAK,CACb,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,GAAG,eAAe,GAAG,WAAW,GAAG,EAAE,CAC3E,CAAA;SACF;IACH,CAAC;CACF;AAEQ,oBAAI"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { BinaryParser } from "../serdes/binary-parser";
|
|
1
|
+
import { SerializedType } from './serialized-type';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
4
3
|
/**
|
|
5
4
|
* Class for serializing and deserializing vectors of Hash256
|
|
6
5
|
*/
|
|
7
6
|
declare class Vector256 extends SerializedType {
|
|
8
|
-
constructor(bytes:
|
|
7
|
+
constructor(bytes: Uint8Array);
|
|
9
8
|
/**
|
|
10
9
|
* Construct a Vector256 from a BinaryParser
|
|
11
10
|
*
|
package/dist/types/vector-256.js
CHANGED
|
@@ -1,35 +1,22 @@
|
|
|
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 (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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.Vector256 = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
const serialized_type_1 = require("./serialized-type");
|
|
5
|
+
const hash_256_1 = require("./hash-256");
|
|
6
|
+
const binary_serializer_1 = require("../serdes/binary-serializer");
|
|
7
|
+
const utils_1 = require("@xrplf/isomorphic/utils");
|
|
20
8
|
/**
|
|
21
9
|
* TypeGuard for Array<string>
|
|
22
10
|
*/
|
|
23
11
|
function isStrings(arg) {
|
|
24
|
-
return Array.isArray(arg) && (arg.length === 0 || typeof arg[0] ===
|
|
12
|
+
return Array.isArray(arg) && (arg.length === 0 || typeof arg[0] === 'string');
|
|
25
13
|
}
|
|
26
14
|
/**
|
|
27
15
|
* Class for serializing and deserializing vectors of Hash256
|
|
28
16
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return _super.call(this, bytes) || this;
|
|
17
|
+
class Vector256 extends serialized_type_1.SerializedType {
|
|
18
|
+
constructor(bytes) {
|
|
19
|
+
super(bytes);
|
|
33
20
|
}
|
|
34
21
|
/**
|
|
35
22
|
* Construct a Vector256 from a BinaryParser
|
|
@@ -38,53 +25,49 @@ var Vector256 = /** @class */ (function (_super) {
|
|
|
38
25
|
* @param hint length of the vector, in bytes, optional
|
|
39
26
|
* @returns a Vector256 object
|
|
40
27
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
for (
|
|
28
|
+
static fromParser(parser, hint) {
|
|
29
|
+
const bytesList = new binary_serializer_1.BytesList();
|
|
30
|
+
const bytes = hint !== null && hint !== void 0 ? hint : parser.size();
|
|
31
|
+
const hashes = bytes / 32;
|
|
32
|
+
for (let i = 0; i < hashes; i++) {
|
|
46
33
|
hash_256_1.Hash256.fromParser(parser).toBytesSink(bytesList);
|
|
47
34
|
}
|
|
48
35
|
return new Vector256(bytesList.toBytes());
|
|
49
|
-
}
|
|
36
|
+
}
|
|
50
37
|
/**
|
|
51
38
|
* Construct a Vector256 object from an array of hashes
|
|
52
39
|
*
|
|
53
40
|
* @param value A Vector256 object or array of hex-strings representing Hash256's
|
|
54
41
|
* @returns a Vector256 object
|
|
55
42
|
*/
|
|
56
|
-
|
|
43
|
+
static from(value) {
|
|
57
44
|
if (value instanceof Vector256) {
|
|
58
45
|
return value;
|
|
59
46
|
}
|
|
60
47
|
if (isStrings(value)) {
|
|
61
|
-
|
|
62
|
-
value.forEach(
|
|
63
|
-
hash_256_1.Hash256.from(hash).toBytesSink(
|
|
48
|
+
const bytesList = new binary_serializer_1.BytesList();
|
|
49
|
+
value.forEach((hash) => {
|
|
50
|
+
hash_256_1.Hash256.from(hash).toBytesSink(bytesList);
|
|
64
51
|
});
|
|
65
|
-
return new Vector256(
|
|
52
|
+
return new Vector256(bytesList.toBytes());
|
|
66
53
|
}
|
|
67
|
-
throw new Error(
|
|
68
|
-
}
|
|
54
|
+
throw new Error('Cannot construct Vector256 from given value');
|
|
55
|
+
}
|
|
69
56
|
/**
|
|
70
57
|
* Return an Array of hex-strings represented by this.bytes
|
|
71
58
|
*
|
|
72
59
|
* @returns An Array of strings representing the Hash256 objects
|
|
73
60
|
*/
|
|
74
|
-
|
|
61
|
+
toJSON() {
|
|
75
62
|
if (this.bytes.byteLength % 32 !== 0) {
|
|
76
|
-
throw new Error(
|
|
63
|
+
throw new Error('Invalid bytes for Vector256');
|
|
77
64
|
}
|
|
78
|
-
|
|
79
|
-
for (
|
|
80
|
-
result.push(this.bytes
|
|
81
|
-
.slice(i, i + 32)
|
|
82
|
-
.toString("hex")
|
|
83
|
-
.toUpperCase());
|
|
65
|
+
const result = [];
|
|
66
|
+
for (let i = 0; i < this.bytes.byteLength; i += 32) {
|
|
67
|
+
result.push((0, utils_1.bytesToHex)(this.bytes.slice(i, i + 32)));
|
|
84
68
|
}
|
|
85
69
|
return result;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
}(serialized_type_1.SerializedType));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
89
72
|
exports.Vector256 = Vector256;
|
|
90
73
|
//# sourceMappingURL=vector-256.js.map
|