@transia/ripple-binary-codec 1.4.6-alpha.9 → 2.5.2-alpha.0
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 +30 -16
- package/dist/binary.js +36 -16
- package/dist/binary.js.map +1 -1
- package/dist/enums/bytes.d.ts +1 -2
- package/dist/enums/bytes.js +3 -2
- package/dist/enums/bytes.js.map +1 -1
- package/dist/enums/constants.d.ts +1 -0
- package/dist/enums/constants.js +6 -5
- package/dist/enums/constants.js.map +1 -1
- package/dist/enums/definitions.json +1604 -969
- package/dist/enums/field.d.ts +1 -2
- package/dist/enums/field.js +1 -2
- package/dist/enums/field.js.map +1 -1
- package/dist/enums/index.d.ts +1 -2
- package/dist/enums/index.js +5 -27
- package/dist/enums/index.js.map +1 -1
- package/dist/enums/src/enums/definitions.json +1606 -971
- package/dist/enums/xrpl-definitions-base.d.ts +5 -3
- package/dist/enums/xrpl-definitions-base.js +26 -6
- package/dist/enums/xrpl-definitions-base.js.map +1 -1
- package/dist/enums/xrpl-definitions.d.ts +2 -1
- package/dist/enums/xrpl-definitions.js +2 -1
- package/dist/enums/xrpl-definitions.js.map +1 -1
- package/dist/hash-prefixes.d.ts +1 -2
- package/dist/hash-prefixes.js +8 -6
- package/dist/hash-prefixes.js.map +1 -1
- package/dist/hashes.d.ts +6 -7
- package/dist/hashes.js +6 -7
- package/dist/hashes.js.map +1 -1
- package/dist/index.d.ts +16 -11
- package/dist/index.js +53 -58
- package/dist/index.js.map +1 -1
- package/dist/ledger-hashes.d.ts +1 -2
- package/dist/ledger-hashes.js +11 -30
- package/dist/ledger-hashes.js.map +1 -1
- package/dist/quality.d.ts +3 -4
- package/dist/quality.js +10 -8
- package/dist/quality.js.map +1 -1
- package/dist/serdes/binary-parser.d.ts +2 -3
- package/dist/serdes/binary-parser.js +16 -32
- package/dist/serdes/binary-parser.js.map +1 -1
- package/dist/serdes/binary-serializer.d.ts +7 -8
- package/dist/serdes/binary-serializer.js +14 -37
- package/dist/serdes/binary-serializer.js.map +1 -1
- package/dist/shamap.d.ts +4 -5
- package/dist/shamap.js +5 -5
- package/dist/shamap.js.map +1 -1
- package/dist/src/binary.d.ts +106 -0
- package/dist/src/binary.js +154 -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 +65 -0
- package/dist/src/enums/bytes.js.map +1 -0
- package/dist/src/enums/constants.d.ts +5 -0
- package/dist/src/enums/constants.js +9 -0
- package/dist/src/enums/constants.js.map +1 -0
- package/dist/src/enums/definitions.json +3404 -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 +47 -0
- package/dist/src/enums/xrpl-definitions-base.js +83 -0
- package/dist/src/enums/xrpl-definitions-base.js.map +1 -0
- package/dist/src/enums/xrpl-definitions.d.ts +22 -0
- package/dist/src/enums/xrpl-definitions.js +30 -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 +43 -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 +69 -0
- package/dist/src/index.js +134 -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 +37 -0
- package/dist/src/types/account-id.js +73 -0
- package/dist/src/types/account-id.js.map +1 -0
- package/dist/src/types/amount.d.ts +92 -0
- package/dist/src/types/amount.js +292 -0
- package/dist/src/types/amount.js.map +1 -0
- package/dist/src/types/blob.d.ts +25 -0
- package/dist/src/types/blob.js +46 -0
- package/dist/src/types/blob.js.map +1 -0
- package/dist/src/types/currency.d.ts +30 -0
- package/dist/src/types/currency.js +131 -0
- package/dist/src/types/currency.js.map +1 -0
- package/dist/src/types/data.d.ts +104 -0
- package/dist/src/types/data.js +387 -0
- package/dist/src/types/data.js.map +1 -0
- package/dist/src/types/dataType.d.ts +94 -0
- package/dist/src/types/dataType.js +145 -0
- package/dist/src/types/dataType.js.map +1 -0
- package/dist/src/types/hash-128.d.ts +18 -0
- package/dist/src/types/hash-128.js +36 -0
- package/dist/src/types/hash-128.js.map +1 -0
- package/dist/src/types/hash-160.d.ts +12 -0
- package/dist/src/types/hash-160.js +23 -0
- package/dist/src/types/hash-160.js.map +1 -0
- package/dist/src/types/hash-192.d.ts +12 -0
- package/dist/src/types/hash-192.js +23 -0
- package/dist/src/types/hash-192.js.map +1 -0
- package/dist/src/types/hash-256.d.ts +12 -0
- package/dist/src/types/hash-256.js +20 -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 +76 -0
- package/dist/src/types/hash.js.map +1 -0
- package/dist/src/types/index.d.ts +21 -0
- package/dist/src/types/index.js +72 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/issue.d.ts +49 -0
- package/dist/src/types/issue.js +107 -0
- package/dist/src/types/issue.js.map +1 -0
- package/dist/src/types/json.d.ts +169 -0
- package/dist/src/types/json.js +529 -0
- package/dist/src/types/json.js.map +1 -0
- package/dist/src/types/path-set.d.ts +37 -0
- package/dist/src/types/path-set.js +236 -0
- package/dist/src/types/path-set.js.map +1 -0
- package/dist/src/types/serialized-type.d.ts +117 -0
- package/dist/src/types/serialized-type.js +242 -0
- package/dist/src/types/serialized-type.js.map +1 -0
- package/dist/src/types/st-array.d.ts +32 -0
- package/dist/src/types/st-array.js +89 -0
- package/dist/src/types/st-array.js.map +1 -0
- package/dist/src/types/st-number.d.ts +55 -0
- package/dist/src/types/st-number.js +212 -0
- package/dist/src/types/st-number.js.map +1 -0
- package/dist/src/types/st-object.d.ts +33 -0
- package/dist/src/types/st-object.js +176 -0
- package/dist/src/types/st-object.js.map +1 -0
- package/dist/src/types/uint-16.d.ts +26 -0
- package/dist/src/types/uint-16.js +49 -0
- package/dist/src/types/uint-16.js.map +1 -0
- package/dist/src/types/uint-32.d.ts +26 -0
- package/dist/src/types/uint-32.js +54 -0
- package/dist/src/types/uint-32.js.map +1 -0
- package/dist/src/types/uint-64.d.ts +40 -0
- package/dist/src/types/uint-64.js +112 -0
- package/dist/src/types/uint-64.js.map +1 -0
- package/dist/src/types/uint-8.d.ts +26 -0
- package/dist/src/types/uint-8.js +50 -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 +31 -0
- package/dist/src/types/vector-256.js +76 -0
- package/dist/src/types/vector-256.js.map +1 -0
- package/dist/src/types/xchain-bridge.d.ts +45 -0
- package/dist/src/types/xchain-bridge.js +105 -0
- package/dist/src/types/xchain-bridge.js.map +1 -0
- package/dist/src/utils.d.ts +79 -0
- package/dist/src/utils.js +181 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/account-id.d.ts +3 -2
- package/dist/types/account-id.js +8 -6
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.d.ts +33 -9
- package/dist/types/amount.js +128 -43
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.d.ts +3 -3
- package/dist/types/blob.js +8 -2
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.d.ts +3 -2
- package/dist/types/currency.js +17 -13
- package/dist/types/currency.js.map +1 -1
- package/dist/types/data.d.ts +104 -0
- package/dist/types/data.js +387 -0
- package/dist/types/data.js.map +1 -0
- package/dist/types/dataType.d.ts +94 -0
- package/dist/types/dataType.js +145 -0
- package/dist/types/dataType.js.map +1 -0
- package/dist/types/hash-128.d.ts +3 -2
- package/dist/types/hash-128.js +7 -3
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.d.ts +3 -2
- package/dist/types/hash-160.js +5 -2
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-192.d.ts +12 -0
- package/dist/types/hash-192.js +23 -0
- package/dist/types/hash-192.js.map +1 -0
- package/dist/types/hash-256.d.ts +3 -2
- package/dist/types/hash-256.js +5 -2
- package/dist/types/hash-256.js.map +1 -1
- package/dist/types/hash.d.ts +2 -3
- package/dist/types/hash.js +8 -4
- package/dist/types/hash.js.map +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.js +17 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/issue.d.ts +49 -0
- package/dist/types/issue.js +107 -0
- package/dist/types/issue.js.map +1 -0
- package/dist/types/json.d.ts +169 -0
- package/dist/types/json.js +529 -0
- package/dist/types/json.js.map +1 -0
- package/dist/types/path-set.d.ts +2 -1
- package/dist/types/path-set.js +15 -12
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +70 -16
- package/dist/types/serialized-type.js +153 -8
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.d.ts +7 -3
- package/dist/types/st-array.js +20 -11
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-number.d.ts +55 -0
- package/dist/types/st-number.js +212 -0
- package/dist/types/st-number.js.map +1 -0
- package/dist/types/st-object.d.ts +2 -1
- package/dist/types/st-object.js +35 -8
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.d.ts +3 -2
- package/dist/types/uint-16.js +10 -5
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.d.ts +3 -2
- package/dist/types/uint-32.js +11 -6
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +8 -7
- package/dist/types/uint-64.js +49 -24
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.d.ts +3 -2
- package/dist/types/uint-8.js +11 -5
- package/dist/types/uint-8.js.map +1 -1
- package/dist/types/uint.d.ts +5 -6
- package/dist/types/uint.js +5 -0
- package/dist/types/uint.js.map +1 -1
- package/dist/types/vector-256.d.ts +3 -3
- package/dist/types/vector-256.js +5 -4
- package/dist/types/vector-256.js.map +1 -1
- package/dist/types/xchain-bridge.d.ts +45 -0
- package/dist/types/xchain-bridge.js +105 -0
- package/dist/types/xchain-bridge.js.map +1 -0
- package/dist/utils.d.ts +79 -0
- package/dist/utils.js +181 -0
- package/dist/utils.js.map +1 -0
- package/package.json +21 -17
- package/src/README.md +5 -0
- package/src/binary.ts +235 -0
- package/src/coretypes.ts +31 -0
- package/src/enums/README.md +144 -0
- package/src/enums/bytes.ts +80 -0
- package/src/enums/constants.ts +5 -0
- package/src/enums/definitions.json +3409 -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 +150 -0
- package/src/enums/xrpl-definitions.ts +33 -0
- package/src/hash-prefixes.ts +42 -0
- package/src/hashes.ts +75 -0
- package/src/index.ts +166 -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 +189 -0
- package/src/types/account-id.ts +91 -0
- package/src/types/amount.ts +366 -0
- package/src/types/blob.ts +50 -0
- package/src/types/currency.ts +145 -0
- package/src/types/data.ts +496 -0
- package/src/types/dataType.ts +178 -0
- package/src/types/hash-128.ts +38 -0
- package/src/types/hash-160.ts +24 -0
- package/src/types/hash-192.ts +24 -0
- package/src/types/hash-256.ts +20 -0
- package/src/types/hash.ts +86 -0
- package/src/types/index.ts +74 -0
- package/src/types/issue.ts +140 -0
- package/src/types/json.ts +641 -0
- package/src/types/path-set.ts +294 -0
- package/src/types/serialized-type.ts +271 -0
- package/src/types/st-array.ts +117 -0
- package/src/types/st-number.ts +238 -0
- package/src/types/st-object.ts +219 -0
- package/src/types/uint-16.ts +58 -0
- package/src/types/uint-32.ts +64 -0
- package/src/types/uint-64.ts +141 -0
- package/src/types/uint-8.ts +57 -0
- package/src/types/uint.ts +60 -0
- package/src/types/vector-256.ts +83 -0
- package/src/types/xchain-bridge.ts +132 -0
- package/src/utils.ts +220 -0
- package/test/amount.test.js +0 -43
- package/test/binary-json.test.js +0 -45
- package/test/binary-parser.test.js +0 -396
- package/test/binary-serializer.test.js +0 -319
- package/test/definitions.test.js +0 -100
- 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 -2919
- 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/nf-token.json +0 -547
- 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/remit-binary.json +0 -1
- package/test/fixtures/remit-tx.json +0 -39
- 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/unl-report-binary.json +0 -1
- package/test/fixtures/unl-report-meta-binary.json +0 -1
- package/test/fixtures/unl-report.json +0 -89
- package/test/fixtures/x-codec-fixtures.json +0 -188
- package/test/hash.test.js +0 -135
- package/test/ledger.test.js +0 -29
- package/test/lower-case-hex.test.js +0 -46
- package/test/pseudo-transaction.test.js +0 -38
- package/test/quality.test.js +0 -15
- package/test/shamap.test.js +0 -89
- package/test/signing-data-encoding.test.js +0 -213
- package/test/tx-encode-decode.test.js +0 -119
- package/test/types.test.js +0 -34
- package/test/uint.test.js +0 -148
- package/test/utils.js +0 -30
- package/test/x-address.test.js +0 -181
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { UInt } from './uint';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
+
import { SerializedTypeID } from './serialized-type';
|
|
4
|
+
/**
|
|
5
|
+
* Derived UInt class for serializing/deserializing 16 bit UInt
|
|
6
|
+
*/
|
|
7
|
+
declare class UInt16 extends UInt {
|
|
8
|
+
protected static readonly width: number;
|
|
9
|
+
static readonly defaultUInt16: UInt16;
|
|
10
|
+
constructor(bytes: Uint8Array);
|
|
11
|
+
static fromParser(parser: BinaryParser): UInt;
|
|
12
|
+
/**
|
|
13
|
+
* Construct a UInt16 object from a number
|
|
14
|
+
*
|
|
15
|
+
* @param val UInt16 object or number
|
|
16
|
+
*/
|
|
17
|
+
static from<T extends UInt16 | number>(val: T): UInt16;
|
|
18
|
+
/**
|
|
19
|
+
* get the value of a UInt16 object
|
|
20
|
+
*
|
|
21
|
+
* @returns the number represented by this.bytes
|
|
22
|
+
*/
|
|
23
|
+
valueOf(): number;
|
|
24
|
+
getSType(): SerializedTypeID;
|
|
25
|
+
}
|
|
26
|
+
export { UInt16 };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UInt16 = void 0;
|
|
4
|
+
const uint_1 = require("./uint");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const serialized_type_1 = require("./serialized-type");
|
|
7
|
+
/**
|
|
8
|
+
* Derived UInt class for serializing/deserializing 16 bit UInt
|
|
9
|
+
*/
|
|
10
|
+
class UInt16 extends uint_1.UInt {
|
|
11
|
+
constructor(bytes) {
|
|
12
|
+
super(bytes !== null && bytes !== void 0 ? bytes : UInt16.defaultUInt16.bytes);
|
|
13
|
+
}
|
|
14
|
+
static fromParser(parser) {
|
|
15
|
+
return new UInt16(parser.read(UInt16.width));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Construct a UInt16 object from a number
|
|
19
|
+
*
|
|
20
|
+
* @param val UInt16 object or number
|
|
21
|
+
*/
|
|
22
|
+
static from(val) {
|
|
23
|
+
if (val instanceof UInt16) {
|
|
24
|
+
return val;
|
|
25
|
+
}
|
|
26
|
+
if (typeof val === 'number') {
|
|
27
|
+
UInt16.checkUintRange(val, 0, 0xffff);
|
|
28
|
+
const buf = new Uint8Array(UInt16.width);
|
|
29
|
+
(0, utils_1.writeUInt16BE)(buf, val, 0);
|
|
30
|
+
return new UInt16(buf);
|
|
31
|
+
}
|
|
32
|
+
throw new Error('Can not construct UInt16 with given value');
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* get the value of a UInt16 object
|
|
36
|
+
*
|
|
37
|
+
* @returns the number represented by this.bytes
|
|
38
|
+
*/
|
|
39
|
+
valueOf() {
|
|
40
|
+
return parseInt((0, utils_1.readUInt16BE)(this.bytes, 0));
|
|
41
|
+
}
|
|
42
|
+
getSType() {
|
|
43
|
+
return serialized_type_1.SerializedTypeID.STI_UINT16;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.UInt16 = UInt16;
|
|
47
|
+
UInt16.width = 16 / 8; // 2
|
|
48
|
+
UInt16.defaultUInt16 = new UInt16(new Uint8Array(UInt16.width));
|
|
49
|
+
//# sourceMappingURL=uint-16.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uint-16.js","sourceRoot":"","sources":["../../../src/types/uint-16.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAE7B,oCAAsD;AACtD,uDAAoD;AAEpD;;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,CAA4B,GAAM;QAC3C,IAAI,GAAG,YAAY,MAAM,EAAE;YACzB,OAAO,GAAG,CAAA;SACX;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,CAAA;YAErC,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACxC,IAAA,qBAAa,EAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;YAC1B,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;SACvB;QAED,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;IAC9D,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,OAAO,QAAQ,CAAC,IAAA,oBAAY,EAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;IAC9C,CAAC;IAED,QAAQ;QACN,OAAO,kCAAgB,CAAC,UAAU,CAAA;IACpC,CAAC;;AAGM,wBAAM;AAhDa,YAAK,GAAW,EAAE,GAAG,CAAC,CAAA,CAAC,IAAI;AACrC,oBAAa,GAAW,IAAI,MAAM,CAChD,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAC7B,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { UInt } from './uint';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
+
import { SerializedTypeID } from './serialized-type';
|
|
4
|
+
/**
|
|
5
|
+
* Derived UInt class for serializing/deserializing 32 bit UInt
|
|
6
|
+
*/
|
|
7
|
+
declare class UInt32 extends UInt {
|
|
8
|
+
protected static readonly width: number;
|
|
9
|
+
static readonly defaultUInt32: UInt32;
|
|
10
|
+
constructor(bytes: Uint8Array);
|
|
11
|
+
static fromParser(parser: BinaryParser): UInt;
|
|
12
|
+
/**
|
|
13
|
+
* Construct a UInt32 object from a number
|
|
14
|
+
*
|
|
15
|
+
* @param val UInt32 object or number
|
|
16
|
+
*/
|
|
17
|
+
static from<T extends UInt32 | number | string>(val: T): UInt32;
|
|
18
|
+
/**
|
|
19
|
+
* get the value of a UInt32 object
|
|
20
|
+
*
|
|
21
|
+
* @returns the number represented by this.bytes
|
|
22
|
+
*/
|
|
23
|
+
valueOf(): number;
|
|
24
|
+
getSType(): SerializedTypeID;
|
|
25
|
+
}
|
|
26
|
+
export { UInt32 };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UInt32 = void 0;
|
|
4
|
+
const uint_1 = require("./uint");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const serialized_type_1 = require("./serialized-type");
|
|
7
|
+
/**
|
|
8
|
+
* Derived UInt class for serializing/deserializing 32 bit UInt
|
|
9
|
+
*/
|
|
10
|
+
class UInt32 extends uint_1.UInt {
|
|
11
|
+
constructor(bytes) {
|
|
12
|
+
super(bytes !== null && bytes !== void 0 ? bytes : UInt32.defaultUInt32.bytes);
|
|
13
|
+
}
|
|
14
|
+
static fromParser(parser) {
|
|
15
|
+
return new UInt32(parser.read(UInt32.width));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Construct a UInt32 object from a number
|
|
19
|
+
*
|
|
20
|
+
* @param val UInt32 object or number
|
|
21
|
+
*/
|
|
22
|
+
static from(val) {
|
|
23
|
+
if (val instanceof UInt32) {
|
|
24
|
+
return val;
|
|
25
|
+
}
|
|
26
|
+
const buf = new Uint8Array(UInt32.width);
|
|
27
|
+
if (typeof val === 'string') {
|
|
28
|
+
const num = Number.parseInt(val);
|
|
29
|
+
(0, utils_1.writeUInt32BE)(buf, num, 0);
|
|
30
|
+
return new UInt32(buf);
|
|
31
|
+
}
|
|
32
|
+
if (typeof val === 'number') {
|
|
33
|
+
UInt32.checkUintRange(val, 0, 0xffffffff);
|
|
34
|
+
(0, utils_1.writeUInt32BE)(buf, val, 0);
|
|
35
|
+
return new UInt32(buf);
|
|
36
|
+
}
|
|
37
|
+
throw new Error('Cannot construct UInt32 from given value');
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* get the value of a UInt32 object
|
|
41
|
+
*
|
|
42
|
+
* @returns the number represented by this.bytes
|
|
43
|
+
*/
|
|
44
|
+
valueOf() {
|
|
45
|
+
return parseInt((0, utils_1.readUInt32BE)(this.bytes, 0), 10);
|
|
46
|
+
}
|
|
47
|
+
getSType() {
|
|
48
|
+
return serialized_type_1.SerializedTypeID.STI_UINT32;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.UInt32 = UInt32;
|
|
52
|
+
UInt32.width = 32 / 8; // 4
|
|
53
|
+
UInt32.defaultUInt32 = new UInt32(new Uint8Array(UInt32.width));
|
|
54
|
+
//# sourceMappingURL=uint-32.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uint-32.js","sourceRoot":"","sources":["../../../src/types/uint-32.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAE7B,oCAAsD;AACtD,uDAAoD;AAEpD;;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;IAED,QAAQ;QACN,OAAO,kCAAgB,CAAC,UAAU,CAAA;IACpC,CAAC;;AAGM,wBAAM;AAtDa,YAAK,GAAW,EAAE,GAAG,CAAC,CAAA,CAAC,IAAI;AACrC,oBAAa,GAAW,IAAI,MAAM,CAChD,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAC7B,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { UInt } from './uint';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
+
import { XrplDefinitionsBase } from '../enums';
|
|
4
|
+
import { SerializedTypeID } from './serialized-type';
|
|
5
|
+
/**
|
|
6
|
+
* Derived UInt class for serializing/deserializing 64 bit UInt
|
|
7
|
+
*/
|
|
8
|
+
declare class UInt64 extends UInt {
|
|
9
|
+
protected static readonly width: number;
|
|
10
|
+
static readonly defaultUInt64: UInt64;
|
|
11
|
+
constructor(bytes: Uint8Array);
|
|
12
|
+
static fromParser(parser: BinaryParser): UInt;
|
|
13
|
+
/**
|
|
14
|
+
* Construct a UInt64 object
|
|
15
|
+
*
|
|
16
|
+
* @param val A UInt64, hex-string, bigInt, or number
|
|
17
|
+
* @returns A UInt64 object
|
|
18
|
+
*/
|
|
19
|
+
static from<T extends UInt64 | string | bigint | number>(val: T, fieldName?: string): UInt64;
|
|
20
|
+
/**
|
|
21
|
+
* The JSON representation of a UInt64 object
|
|
22
|
+
*
|
|
23
|
+
* @returns a hex-string
|
|
24
|
+
*/
|
|
25
|
+
toJSON(_definitions?: XrplDefinitionsBase, fieldName?: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Get the value of the UInt64
|
|
28
|
+
*
|
|
29
|
+
* @returns the number represented buy this.bytes
|
|
30
|
+
*/
|
|
31
|
+
valueOf(): bigint;
|
|
32
|
+
/**
|
|
33
|
+
* Get the bytes representation of the UInt64 object
|
|
34
|
+
*
|
|
35
|
+
* @returns 8 bytes representing the UInt64
|
|
36
|
+
*/
|
|
37
|
+
toBytes(): Uint8Array;
|
|
38
|
+
getSType(): SerializedTypeID;
|
|
39
|
+
}
|
|
40
|
+
export { UInt64 };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UInt64 = void 0;
|
|
4
|
+
const uint_1 = require("./uint");
|
|
5
|
+
const utils_1 = require("@transia/isomorphic/utils");
|
|
6
|
+
const utils_2 = require("../utils");
|
|
7
|
+
const enums_1 = require("../enums");
|
|
8
|
+
const serialized_type_1 = require("./serialized-type");
|
|
9
|
+
const HEX_REGEX = /^[a-fA-F0-9]{1,16}$/;
|
|
10
|
+
const BASE10_REGEX = /^[0-9]{1,20}$/;
|
|
11
|
+
const mask = BigInt(0x00000000ffffffff);
|
|
12
|
+
const BASE10_AMOUNT_FIELDS = new Set([
|
|
13
|
+
'MaximumAmount',
|
|
14
|
+
'OutstandingAmount',
|
|
15
|
+
'MPTAmount',
|
|
16
|
+
'LockedAmount',
|
|
17
|
+
]);
|
|
18
|
+
function isBase10(fieldName) {
|
|
19
|
+
return BASE10_AMOUNT_FIELDS.has(fieldName);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Derived UInt class for serializing/deserializing 64 bit UInt
|
|
23
|
+
*/
|
|
24
|
+
class UInt64 extends uint_1.UInt {
|
|
25
|
+
constructor(bytes) {
|
|
26
|
+
super(bytes !== null && bytes !== void 0 ? bytes : UInt64.defaultUInt64.bytes);
|
|
27
|
+
}
|
|
28
|
+
static fromParser(parser) {
|
|
29
|
+
return new UInt64(parser.read(UInt64.width));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Construct a UInt64 object
|
|
33
|
+
*
|
|
34
|
+
* @param val A UInt64, hex-string, bigInt, or number
|
|
35
|
+
* @returns A UInt64 object
|
|
36
|
+
*/
|
|
37
|
+
// eslint-disable-next-line complexity
|
|
38
|
+
static from(val, fieldName = '') {
|
|
39
|
+
if (val instanceof UInt64) {
|
|
40
|
+
return val;
|
|
41
|
+
}
|
|
42
|
+
let buf = new Uint8Array(UInt64.width);
|
|
43
|
+
if (typeof val === 'number') {
|
|
44
|
+
if (val < 0) {
|
|
45
|
+
throw new Error('value must be an unsigned integer');
|
|
46
|
+
}
|
|
47
|
+
const number = BigInt(val);
|
|
48
|
+
const intBuf = [new Uint8Array(4), new Uint8Array(4)];
|
|
49
|
+
(0, utils_2.writeUInt32BE)(intBuf[0], Number(number >> BigInt(32)), 0);
|
|
50
|
+
(0, utils_2.writeUInt32BE)(intBuf[1], Number(number & BigInt(mask)), 0);
|
|
51
|
+
return new UInt64((0, utils_1.concat)(intBuf));
|
|
52
|
+
}
|
|
53
|
+
if (typeof val === 'string') {
|
|
54
|
+
if (isBase10(fieldName)) {
|
|
55
|
+
if (!BASE10_REGEX.test(val)) {
|
|
56
|
+
throw new Error(`${fieldName} ${val} is not a valid base 10 string`);
|
|
57
|
+
}
|
|
58
|
+
val = BigInt(val).toString(16);
|
|
59
|
+
}
|
|
60
|
+
if (typeof val === 'string' && !HEX_REGEX.test(val)) {
|
|
61
|
+
throw new Error(`${val} is not a valid hex-string`);
|
|
62
|
+
}
|
|
63
|
+
const strBuf = val.padStart(16, '0');
|
|
64
|
+
buf = (0, utils_1.hexToBytes)(strBuf);
|
|
65
|
+
return new UInt64(buf);
|
|
66
|
+
}
|
|
67
|
+
if (typeof val === 'bigint') {
|
|
68
|
+
const intBuf = [new Uint8Array(4), new Uint8Array(4)];
|
|
69
|
+
(0, utils_2.writeUInt32BE)(intBuf[0], Number(Number(val >> BigInt(32))), 0);
|
|
70
|
+
(0, utils_2.writeUInt32BE)(intBuf[1], Number(val & BigInt(mask)), 0);
|
|
71
|
+
return new UInt64((0, utils_1.concat)(intBuf));
|
|
72
|
+
}
|
|
73
|
+
throw new Error('Cannot construct UInt64 from given value');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The JSON representation of a UInt64 object
|
|
77
|
+
*
|
|
78
|
+
* @returns a hex-string
|
|
79
|
+
*/
|
|
80
|
+
toJSON(_definitions = enums_1.DEFAULT_DEFINITIONS, fieldName = '') {
|
|
81
|
+
const hexString = (0, utils_1.bytesToHex)(this.bytes);
|
|
82
|
+
if (isBase10(fieldName)) {
|
|
83
|
+
return BigInt('0x' + hexString).toString(10);
|
|
84
|
+
}
|
|
85
|
+
return hexString;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get the value of the UInt64
|
|
89
|
+
*
|
|
90
|
+
* @returns the number represented buy this.bytes
|
|
91
|
+
*/
|
|
92
|
+
valueOf() {
|
|
93
|
+
const msb = BigInt((0, utils_2.readUInt32BE)(this.bytes.slice(0, 4), 0));
|
|
94
|
+
const lsb = BigInt((0, utils_2.readUInt32BE)(this.bytes.slice(4), 0));
|
|
95
|
+
return (msb << BigInt(32)) | lsb;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get the bytes representation of the UInt64 object
|
|
99
|
+
*
|
|
100
|
+
* @returns 8 bytes representing the UInt64
|
|
101
|
+
*/
|
|
102
|
+
toBytes() {
|
|
103
|
+
return this.bytes;
|
|
104
|
+
}
|
|
105
|
+
getSType() {
|
|
106
|
+
return serialized_type_1.SerializedTypeID.STI_UINT64;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.UInt64 = UInt64;
|
|
110
|
+
UInt64.width = 64 / 8; // 8
|
|
111
|
+
UInt64.defaultUInt64 = new UInt64(new Uint8Array(UInt64.width));
|
|
112
|
+
//# sourceMappingURL=uint-64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uint-64.js","sourceRoot":"","sources":["../../../src/types/uint-64.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { UInt } from './uint';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
+
import { SerializedTypeID } from './serialized-type';
|
|
4
|
+
/**
|
|
5
|
+
* Derived UInt class for serializing/deserializing 8 bit UInt
|
|
6
|
+
*/
|
|
7
|
+
declare class UInt8 extends UInt {
|
|
8
|
+
protected static readonly width: number;
|
|
9
|
+
static readonly defaultUInt8: UInt8;
|
|
10
|
+
constructor(bytes: Uint8Array);
|
|
11
|
+
static fromParser(parser: BinaryParser): UInt;
|
|
12
|
+
/**
|
|
13
|
+
* Construct a UInt8 object from a number
|
|
14
|
+
*
|
|
15
|
+
* @param val UInt8 object or number
|
|
16
|
+
*/
|
|
17
|
+
static from<T extends UInt8 | number>(val: T): UInt8;
|
|
18
|
+
/**
|
|
19
|
+
* get the value of a UInt8 object
|
|
20
|
+
*
|
|
21
|
+
* @returns the number represented by this.bytes
|
|
22
|
+
*/
|
|
23
|
+
valueOf(): number;
|
|
24
|
+
getSType(): SerializedTypeID;
|
|
25
|
+
}
|
|
26
|
+
export { UInt8 };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UInt8 = void 0;
|
|
4
|
+
const uint_1 = require("./uint");
|
|
5
|
+
const utils_1 = require("@transia/isomorphic/utils");
|
|
6
|
+
const utils_2 = require("../utils");
|
|
7
|
+
const serialized_type_1 = require("./serialized-type");
|
|
8
|
+
/**
|
|
9
|
+
* Derived UInt class for serializing/deserializing 8 bit UInt
|
|
10
|
+
*/
|
|
11
|
+
class UInt8 extends uint_1.UInt {
|
|
12
|
+
constructor(bytes) {
|
|
13
|
+
super(bytes !== null && bytes !== void 0 ? bytes : UInt8.defaultUInt8.bytes);
|
|
14
|
+
}
|
|
15
|
+
static fromParser(parser) {
|
|
16
|
+
return new UInt8(parser.read(UInt8.width));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Construct a UInt8 object from a number
|
|
20
|
+
*
|
|
21
|
+
* @param val UInt8 object or number
|
|
22
|
+
*/
|
|
23
|
+
static from(val) {
|
|
24
|
+
if (val instanceof UInt8) {
|
|
25
|
+
return val;
|
|
26
|
+
}
|
|
27
|
+
if (typeof val === 'number') {
|
|
28
|
+
UInt8.checkUintRange(val, 0, 0xff);
|
|
29
|
+
const buf = new Uint8Array(UInt8.width);
|
|
30
|
+
(0, utils_2.writeUInt8)(buf, val, 0);
|
|
31
|
+
return new UInt8(buf);
|
|
32
|
+
}
|
|
33
|
+
throw new Error('Cannot construct UInt8 from given value');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* get the value of a UInt8 object
|
|
37
|
+
*
|
|
38
|
+
* @returns the number represented by this.bytes
|
|
39
|
+
*/
|
|
40
|
+
valueOf() {
|
|
41
|
+
return parseInt((0, utils_1.bytesToHex)(this.bytes), 16);
|
|
42
|
+
}
|
|
43
|
+
getSType() {
|
|
44
|
+
return serialized_type_1.SerializedTypeID.STI_UINT8;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.UInt8 = UInt8;
|
|
48
|
+
UInt8.width = 8 / 8; // 1
|
|
49
|
+
UInt8.defaultUInt8 = new UInt8(new Uint8Array(UInt8.width));
|
|
50
|
+
//# sourceMappingURL=uint-8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uint-8.js","sourceRoot":"","sources":["../../../src/types/uint-8.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAE7B,qDAAsD;AACtD,oCAAqC;AACrC,uDAAoD;AAEpD;;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;IAED,QAAQ;QACN,OAAO,kCAAgB,CAAC,SAAS,CAAA;IACnC,CAAC;;AAGM,sBAAK;AA9Cc,WAAK,GAAW,CAAC,GAAG,CAAC,CAAA,CAAC,IAAI;AACpC,kBAAY,GAAU,IAAI,KAAK,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Comparable } from './serialized-type';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for serializing and deserializing unsigned integers.
|
|
4
|
+
*/
|
|
5
|
+
declare abstract class UInt extends Comparable<UInt | number> {
|
|
6
|
+
protected static width: number;
|
|
7
|
+
constructor(bytes: Uint8Array);
|
|
8
|
+
/**
|
|
9
|
+
* Overload of compareTo for Comparable
|
|
10
|
+
*
|
|
11
|
+
* @param other other UInt to compare this to
|
|
12
|
+
* @returns -1, 0, or 1 depending on how the objects relate to each other
|
|
13
|
+
*/
|
|
14
|
+
compareTo(other: UInt | number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Convert a UInt object to JSON
|
|
17
|
+
*
|
|
18
|
+
* @returns number or string represented by this.bytes
|
|
19
|
+
*/
|
|
20
|
+
toJSON(): number | string;
|
|
21
|
+
/**
|
|
22
|
+
* Get the value of the UInt represented by this.bytes
|
|
23
|
+
*
|
|
24
|
+
* @returns the value
|
|
25
|
+
*/
|
|
26
|
+
abstract valueOf(): number | bigint;
|
|
27
|
+
static checkUintRange(val: number, min: number, max: number): void;
|
|
28
|
+
}
|
|
29
|
+
export { UInt };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UInt = void 0;
|
|
4
|
+
const serialized_type_1 = require("./serialized-type");
|
|
5
|
+
/**
|
|
6
|
+
* Compare numbers and bigInts n1 and n2
|
|
7
|
+
*
|
|
8
|
+
* @param n1 First object to compare
|
|
9
|
+
* @param n2 Second object to compare
|
|
10
|
+
* @returns -1, 0, or 1, depending on how the two objects compare
|
|
11
|
+
*/
|
|
12
|
+
function compare(n1, n2) {
|
|
13
|
+
return n1 < n2 ? -1 : n1 == n2 ? 0 : 1;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Base class for serializing and deserializing unsigned integers.
|
|
17
|
+
*/
|
|
18
|
+
class UInt extends serialized_type_1.Comparable {
|
|
19
|
+
constructor(bytes) {
|
|
20
|
+
super(bytes);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Overload of compareTo for Comparable
|
|
24
|
+
*
|
|
25
|
+
* @param other other UInt to compare this to
|
|
26
|
+
* @returns -1, 0, or 1 depending on how the objects relate to each other
|
|
27
|
+
*/
|
|
28
|
+
compareTo(other) {
|
|
29
|
+
return compare(this.valueOf(), other.valueOf());
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Convert a UInt object to JSON
|
|
33
|
+
*
|
|
34
|
+
* @returns number or string represented by this.bytes
|
|
35
|
+
*/
|
|
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
|
+
}
|
|
46
|
+
exports.UInt = UInt;
|
|
47
|
+
//# sourceMappingURL=uint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SerializedType, SerializedTypeID } from './serialized-type';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
+
/**
|
|
4
|
+
* Class for serializing and deserializing vectors of Hash256
|
|
5
|
+
*/
|
|
6
|
+
declare class Vector256 extends SerializedType {
|
|
7
|
+
constructor(bytes: Uint8Array);
|
|
8
|
+
/**
|
|
9
|
+
* Construct a Vector256 from a BinaryParser
|
|
10
|
+
*
|
|
11
|
+
* @param parser BinaryParser to
|
|
12
|
+
* @param hint length of the vector, in bytes, optional
|
|
13
|
+
* @returns a Vector256 object
|
|
14
|
+
*/
|
|
15
|
+
static fromParser(parser: BinaryParser, hint?: number): Vector256;
|
|
16
|
+
/**
|
|
17
|
+
* Construct a Vector256 object from an array of hashes
|
|
18
|
+
*
|
|
19
|
+
* @param value A Vector256 object or array of hex-strings representing Hash256's
|
|
20
|
+
* @returns a Vector256 object
|
|
21
|
+
*/
|
|
22
|
+
static from<T extends Vector256 | Array<string>>(value: T): Vector256;
|
|
23
|
+
/**
|
|
24
|
+
* Return an Array of hex-strings represented by this.bytes
|
|
25
|
+
*
|
|
26
|
+
* @returns An Array of strings representing the Hash256 objects
|
|
27
|
+
*/
|
|
28
|
+
toJSON(): Array<string>;
|
|
29
|
+
getSType(): SerializedTypeID;
|
|
30
|
+
}
|
|
31
|
+
export { Vector256 };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Vector256 = void 0;
|
|
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("@transia/isomorphic/utils");
|
|
8
|
+
/**
|
|
9
|
+
* TypeGuard for Array<string>
|
|
10
|
+
*/
|
|
11
|
+
function isStrings(arg) {
|
|
12
|
+
return Array.isArray(arg) && (arg.length === 0 || typeof arg[0] === 'string');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Class for serializing and deserializing vectors of Hash256
|
|
16
|
+
*/
|
|
17
|
+
class Vector256 extends serialized_type_1.SerializedType {
|
|
18
|
+
constructor(bytes) {
|
|
19
|
+
super(bytes);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Construct a Vector256 from a BinaryParser
|
|
23
|
+
*
|
|
24
|
+
* @param parser BinaryParser to
|
|
25
|
+
* @param hint length of the vector, in bytes, optional
|
|
26
|
+
* @returns a Vector256 object
|
|
27
|
+
*/
|
|
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++) {
|
|
33
|
+
hash_256_1.Hash256.fromParser(parser).toBytesSink(bytesList);
|
|
34
|
+
}
|
|
35
|
+
return new Vector256(bytesList.toBytes());
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Construct a Vector256 object from an array of hashes
|
|
39
|
+
*
|
|
40
|
+
* @param value A Vector256 object or array of hex-strings representing Hash256's
|
|
41
|
+
* @returns a Vector256 object
|
|
42
|
+
*/
|
|
43
|
+
static from(value) {
|
|
44
|
+
if (value instanceof Vector256) {
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
if (isStrings(value)) {
|
|
48
|
+
const bytesList = new binary_serializer_1.BytesList();
|
|
49
|
+
value.forEach((hash) => {
|
|
50
|
+
hash_256_1.Hash256.from(hash).toBytesSink(bytesList);
|
|
51
|
+
});
|
|
52
|
+
return new Vector256(bytesList.toBytes());
|
|
53
|
+
}
|
|
54
|
+
throw new Error('Cannot construct Vector256 from given value');
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Return an Array of hex-strings represented by this.bytes
|
|
58
|
+
*
|
|
59
|
+
* @returns An Array of strings representing the Hash256 objects
|
|
60
|
+
*/
|
|
61
|
+
toJSON() {
|
|
62
|
+
if (this.bytes.byteLength % 32 !== 0) {
|
|
63
|
+
throw new Error('Invalid bytes for Vector256');
|
|
64
|
+
}
|
|
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)));
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
getSType() {
|
|
72
|
+
return serialized_type_1.SerializedTypeID.STI_VECTOR256;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.Vector256 = Vector256;
|
|
76
|
+
//# sourceMappingURL=vector-256.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector-256.js","sourceRoot":"","sources":["../../../src/types/vector-256.ts"],"names":[],"mappings":";;;AAAA,uDAAoE;AAEpE,yCAAoC;AACpC,mEAAuD;AACvD,qDAAsD;AAEtD;;GAEG;AACH,SAAS,SAAS,CAAC,GAAG;IACpB,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAA;AAC/E,CAAC;AAED;;GAEG;AACH,MAAM,SAAU,SAAQ,gCAAc;IACpC,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,CAAC,CAAA;IACd,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,UAAU,CAAC,MAAoB,EAAE,IAAa;QACnD,MAAM,SAAS,GAAG,IAAI,6BAAS,EAAE,CAAA;QACjC,MAAM,KAAK,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,MAAM,CAAC,IAAI,EAAE,CAAA;QACnC,MAAM,MAAM,GAAG,KAAK,GAAG,EAAE,CAAA;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;YAC/B,kBAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;SAClD;QACD,OAAO,IAAI,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAA;IAC3C,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAsC,KAAQ;QACvD,IAAI,KAAK,YAAY,SAAS,EAAE;YAC9B,OAAO,KAAK,CAAA;SACb;QAED,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE;YACpB,MAAM,SAAS,GAAG,IAAI,6BAAS,EAAE,CAAA;YACjC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACrB,kBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;YAC3C,CAAC,CAAC,CAAA;YACF,OAAO,IAAI,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAA;SAC1C;QAED,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;IAChE,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,EAAE,KAAK,CAAC,EAAE;YACpC,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;SAC/C;QAED,MAAM,MAAM,GAAkB,EAAE,CAAA;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE;YAClD,MAAM,CAAC,IAAI,CAAC,IAAA,kBAAU,EAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA;SACrD;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IAED,QAAQ;QACN,OAAO,kCAAgB,CAAC,aAAa,CAAA;IACvC,CAAC;CACF;AAEQ,8BAAS"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
2
|
+
import { JsonObject, SerializedType, SerializedTypeID } from './serialized-type';
|
|
3
|
+
import { IssueObject } from './issue';
|
|
4
|
+
/**
|
|
5
|
+
* Interface for JSON objects that represent cross-chain bridges
|
|
6
|
+
*/
|
|
7
|
+
interface XChainBridgeObject extends JsonObject {
|
|
8
|
+
LockingChainDoor: string;
|
|
9
|
+
LockingChainIssue: IssueObject | string;
|
|
10
|
+
IssuingChainDoor: string;
|
|
11
|
+
IssuingChainIssue: IssueObject | string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Class for serializing/deserializing XChainBridges
|
|
15
|
+
*/
|
|
16
|
+
declare class XChainBridge extends SerializedType {
|
|
17
|
+
static readonly ZERO_XCHAIN_BRIDGE: XChainBridge;
|
|
18
|
+
static readonly TYPE_ORDER: {
|
|
19
|
+
name: string;
|
|
20
|
+
type: typeof SerializedType;
|
|
21
|
+
}[];
|
|
22
|
+
constructor(bytes: Uint8Array);
|
|
23
|
+
/**
|
|
24
|
+
* Construct a cross-chain bridge from a JSON
|
|
25
|
+
*
|
|
26
|
+
* @param value XChainBridge or JSON to parse into an XChainBridge
|
|
27
|
+
* @returns An XChainBridge object
|
|
28
|
+
*/
|
|
29
|
+
static from<T extends XChainBridge | XChainBridgeObject>(value: T): XChainBridge;
|
|
30
|
+
/**
|
|
31
|
+
* Read an XChainBridge from a BinaryParser
|
|
32
|
+
*
|
|
33
|
+
* @param parser BinaryParser to read the XChainBridge from
|
|
34
|
+
* @returns An XChainBridge object
|
|
35
|
+
*/
|
|
36
|
+
static fromParser(parser: BinaryParser): XChainBridge;
|
|
37
|
+
/**
|
|
38
|
+
* Get the JSON representation of this XChainBridge
|
|
39
|
+
*
|
|
40
|
+
* @returns the JSON interpretation of this.bytes
|
|
41
|
+
*/
|
|
42
|
+
toJSON(): XChainBridgeObject;
|
|
43
|
+
getSType(): SerializedTypeID;
|
|
44
|
+
}
|
|
45
|
+
export { XChainBridge, XChainBridgeObject };
|