ripple-binary-codec 1.0.4-beta.0 → 1.0.4-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 -36
- 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 -1780
- 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 +7 -5
- package/dist/ledger-hashes.js +40 -34
- package/dist/ledger-hashes.js.map +1 -1
- package/dist/quality.d.ts +3 -4
- package/dist/quality.js +20 -20
- 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 -113
- 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 +27 -20
- 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 +6 -8
- package/dist/types/uint-64.js +43 -57
- 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 +6 -7
- package/dist/types/uint.js +16 -26
- 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 -34
- 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 -263
- 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/ticket-create-binary.json +0 -1
- package/test/fixtures/ticket-create-tx.json +0 -7
- 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 -97
- 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,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { BinaryParser } from "../serdes/binary-parser";
|
|
4
|
-
import * as bigInt from "big-integer";
|
|
1
|
+
import { UInt } from './uint';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
5
3
|
/**
|
|
6
4
|
* Derived UInt class for serializing/deserializing 64 bit UInt
|
|
7
5
|
*/
|
|
8
6
|
declare class UInt64 extends UInt {
|
|
9
7
|
protected static readonly width: number;
|
|
10
8
|
static readonly defaultUInt64: UInt64;
|
|
11
|
-
constructor(bytes:
|
|
9
|
+
constructor(bytes: Uint8Array);
|
|
12
10
|
static fromParser(parser: BinaryParser): UInt;
|
|
13
11
|
/**
|
|
14
12
|
* Construct a UInt64 object
|
|
@@ -16,7 +14,7 @@ declare class UInt64 extends UInt {
|
|
|
16
14
|
* @param val A UInt64, hex-string, bigInt, or number
|
|
17
15
|
* @returns A UInt64 object
|
|
18
16
|
*/
|
|
19
|
-
static from<T extends UInt64 | string |
|
|
17
|
+
static from<T extends UInt64 | string | bigint | number>(val: T): UInt64;
|
|
20
18
|
/**
|
|
21
19
|
* The JSON representation of a UInt64 object
|
|
22
20
|
*
|
|
@@ -28,12 +26,12 @@ declare class UInt64 extends UInt {
|
|
|
28
26
|
*
|
|
29
27
|
* @returns the number represented buy this.bytes
|
|
30
28
|
*/
|
|
31
|
-
valueOf():
|
|
29
|
+
valueOf(): bigint;
|
|
32
30
|
/**
|
|
33
31
|
* Get the bytes representation of the UInt64 object
|
|
34
32
|
*
|
|
35
33
|
* @returns 8 bytes representing the UInt64
|
|
36
34
|
*/
|
|
37
|
-
toBytes():
|
|
35
|
+
toBytes(): Uint8Array;
|
|
38
36
|
}
|
|
39
37
|
export { UInt64 };
|
package/dist/types/uint-64.js
CHANGED
|
@@ -1,100 +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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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);
|
|
22
9
|
/**
|
|
23
10
|
* Derived UInt class for serializing/deserializing 64 bit UInt
|
|
24
11
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
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);
|
|
29
15
|
}
|
|
30
|
-
|
|
16
|
+
static fromParser(parser) {
|
|
31
17
|
return new UInt64(parser.read(UInt64.width));
|
|
32
|
-
}
|
|
18
|
+
}
|
|
33
19
|
/**
|
|
34
20
|
* Construct a UInt64 object
|
|
35
21
|
*
|
|
36
22
|
* @param val A UInt64, hex-string, bigInt, or number
|
|
37
23
|
* @returns A UInt64 object
|
|
38
24
|
*/
|
|
39
|
-
|
|
25
|
+
static from(val) {
|
|
40
26
|
if (val instanceof UInt64) {
|
|
41
27
|
return val;
|
|
42
28
|
}
|
|
43
|
-
|
|
44
|
-
if (typeof val ===
|
|
29
|
+
let buf = new Uint8Array(UInt64.width);
|
|
30
|
+
if (typeof val === 'number') {
|
|
45
31
|
if (val < 0) {
|
|
46
|
-
throw new Error(
|
|
32
|
+
throw new Error('value must be an unsigned integer');
|
|
47
33
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
intBuf[0]
|
|
51
|
-
intBuf[1]
|
|
52
|
-
return new UInt64(
|
|
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));
|
|
53
39
|
}
|
|
54
|
-
if (typeof val ===
|
|
40
|
+
if (typeof val === 'string') {
|
|
55
41
|
if (!HEX_REGEX.test(val)) {
|
|
56
|
-
throw new Error(val
|
|
42
|
+
throw new Error(`${val} is not a valid hex-string`);
|
|
57
43
|
}
|
|
58
|
-
|
|
44
|
+
const strBuf = val.padStart(16, '0');
|
|
45
|
+
buf = (0, utils_1.hexToBytes)(strBuf);
|
|
59
46
|
return new UInt64(buf);
|
|
60
47
|
}
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
intBuf[0]
|
|
64
|
-
intBuf[1]
|
|
65
|
-
return new UInt64(
|
|
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));
|
|
66
53
|
}
|
|
67
|
-
throw new Error(
|
|
68
|
-
}
|
|
54
|
+
throw new Error('Cannot construct UInt64 from given value');
|
|
55
|
+
}
|
|
69
56
|
/**
|
|
70
57
|
* The JSON representation of a UInt64 object
|
|
71
58
|
*
|
|
72
59
|
* @returns a hex-string
|
|
73
60
|
*/
|
|
74
|
-
|
|
75
|
-
return this.bytes
|
|
76
|
-
}
|
|
61
|
+
toJSON() {
|
|
62
|
+
return (0, utils_1.bytesToHex)(this.bytes);
|
|
63
|
+
}
|
|
77
64
|
/**
|
|
78
65
|
* Get the value of the UInt64
|
|
79
66
|
*
|
|
80
67
|
* @returns the number represented buy this.bytes
|
|
81
68
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return msb
|
|
86
|
-
}
|
|
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
|
+
}
|
|
87
74
|
/**
|
|
88
75
|
* Get the bytes representation of the UInt64 object
|
|
89
76
|
*
|
|
90
77
|
* @returns 8 bytes representing the UInt64
|
|
91
78
|
*/
|
|
92
|
-
|
|
79
|
+
toBytes() {
|
|
93
80
|
return this.bytes;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
UInt64.defaultUInt64 = new UInt64(Buffer.alloc(UInt64.width));
|
|
97
|
-
return UInt64;
|
|
98
|
-
}(uint_1.UInt));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
99
83
|
exports.UInt64 = UInt64;
|
|
84
|
+
UInt64.width = 64 / 8; // 8
|
|
85
|
+
UInt64.defaultUInt64 = new UInt64(new Uint8Array(UInt64.width));
|
|
100
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,19 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import * as bigInt from "big-integer";
|
|
3
|
-
import { Comparable } from "./serialized-type";
|
|
1
|
+
import { Comparable } from './serialized-type';
|
|
4
2
|
/**
|
|
5
3
|
* Base class for serializing and deserializing unsigned integers.
|
|
6
4
|
*/
|
|
7
|
-
declare abstract class UInt extends Comparable {
|
|
5
|
+
declare abstract class UInt extends Comparable<UInt | number> {
|
|
8
6
|
protected static width: number;
|
|
9
|
-
constructor(bytes:
|
|
7
|
+
constructor(bytes: Uint8Array);
|
|
10
8
|
/**
|
|
11
9
|
* Overload of compareTo for Comparable
|
|
12
10
|
*
|
|
13
11
|
* @param other other UInt to compare this to
|
|
14
12
|
* @returns -1, 0, or 1 depending on how the objects relate to each other
|
|
15
13
|
*/
|
|
16
|
-
compareTo(other: UInt): number;
|
|
14
|
+
compareTo(other: UInt | number): number;
|
|
17
15
|
/**
|
|
18
16
|
* Convert a UInt object to JSON
|
|
19
17
|
*
|
|
@@ -25,6 +23,7 @@ declare abstract class UInt extends Comparable {
|
|
|
25
23
|
*
|
|
26
24
|
* @returns the value
|
|
27
25
|
*/
|
|
28
|
-
abstract valueOf(): number |
|
|
26
|
+
abstract valueOf(): number | bigint;
|
|
27
|
+
static checkUintRange(val: number, min: number, max: number): void;
|
|
29
28
|
}
|
|
30
29
|
export { UInt };
|
package/dist/types/uint.js
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
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
6
|
* Compare numbers and bigInts n1 and n2
|
|
20
7
|
*
|
|
@@ -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
|
*
|