@transia/ripple-binary-codec 1.4.6-alpha.9 → 2.5.1-quantum.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 +1 -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 +1535 -919
- 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 +1537 -921
- 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 +6 -7
- package/dist/serdes/binary-serializer.js +12 -35
- 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 +63 -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 +3385 -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 +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 +76 -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 +66 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/issue.d.ts +48 -0
- package/dist/src/types/issue.js +104 -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-number.d.ts +54 -0
- package/dist/src/types/st-number.js +208 -0
- package/dist/src/types/st-number.js.map +1 -0
- package/dist/src/types/st-object.d.ts +32 -0
- package/dist/src/types/st-object.js +173 -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 +38 -0
- package/dist/src/types/uint-64.js +107 -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 +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 +1 -2
- package/dist/types/account-id.js +4 -6
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.d.ts +31 -8
- package/dist/types/amount.js +125 -43
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.d.ts +1 -2
- package/dist/types/blob.js +5 -2
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.d.ts +1 -2
- package/dist/types/currency.js +13 -13
- package/dist/types/currency.js.map +1 -1
- package/dist/types/hash-128.d.ts +1 -2
- package/dist/types/hash-128.js +3 -3
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.d.ts +1 -2
- package/dist/types/hash-160.js +1 -2
- 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 +1 -2
- package/dist/types/hash-256.js +1 -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 +2 -1
- package/dist/types/index.js +11 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/issue.d.ts +48 -0
- package/dist/types/issue.js +104 -0
- package/dist/types/issue.js.map +1 -0
- package/dist/types/path-set.js +12 -12
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +23 -16
- package/dist/types/serialized-type.js +15 -7
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.d.ts +5 -2
- package/dist/types/st-array.js +17 -11
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-number.d.ts +54 -0
- package/dist/types/st-number.js +208 -0
- package/dist/types/st-number.js.map +1 -0
- package/dist/types/st-object.js +32 -8
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.d.ts +1 -2
- package/dist/types/uint-16.js +6 -5
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.d.ts +1 -2
- package/dist/types/uint-32.js +7 -6
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +6 -7
- package/dist/types/uint-64.js +44 -24
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.d.ts +1 -2
- package/dist/types/uint-8.js +7 -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 +1 -2
- package/dist/types/vector-256.js +2 -4
- 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 +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 +74 -0
- package/src/enums/constants.ts +5 -0
- package/src/enums/definitions.json +3390 -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 +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 +86 -0
- package/src/types/index.ts +68 -0
- package/src/types/issue.ts +136 -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-number.ts +233 -0
- package/src/types/st-object.ts +215 -0
- package/src/types/uint-16.ts +53 -0
- package/src/types/uint-32.ts +59 -0
- package/src/types/uint-64.ts +135 -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 +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
package/dist/types/hash-256.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Hash256 = void 0;
|
|
4
4
|
const hash_1 = require("./hash");
|
|
5
|
-
const buffer_1 = require("buffer/");
|
|
6
5
|
/**
|
|
7
6
|
* Hash with a width of 256 bits
|
|
8
7
|
*/
|
|
@@ -13,5 +12,5 @@ class Hash256 extends hash_1.Hash {
|
|
|
13
12
|
}
|
|
14
13
|
exports.Hash256 = Hash256;
|
|
15
14
|
Hash256.width = 32;
|
|
16
|
-
Hash256.ZERO_256 = new Hash256(
|
|
15
|
+
Hash256.ZERO_256 = new Hash256(new Uint8Array(Hash256.width));
|
|
17
16
|
//# sourceMappingURL=hash-256.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-256.js","sourceRoot":"","sources":["../../src/types/hash-256.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;
|
|
1
|
+
{"version":3,"file":"hash-256.js","sourceRoot":"","sources":["../../src/types/hash-256.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAE7B;;GAEG;AACH,MAAM,OAAQ,SAAQ,WAAI;IAIxB,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACxC,CAAC;;AAGM,0BAAO;AARE,aAAK,GAAG,EAAE,CAAA;AACV,gBAAQ,GAAG,IAAI,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
package/dist/types/hash.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Comparable } from './serialized-type';
|
|
2
2
|
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
-
import { Buffer } from 'buffer/';
|
|
4
3
|
/**
|
|
5
4
|
* Base class defining how to encode and decode hashes
|
|
6
5
|
*/
|
|
7
|
-
declare class Hash extends Comparable {
|
|
6
|
+
declare class Hash extends Comparable<Hash | string> {
|
|
8
7
|
static readonly width: number;
|
|
9
|
-
constructor(bytes:
|
|
8
|
+
constructor(bytes: Uint8Array);
|
|
10
9
|
/**
|
|
11
10
|
* Construct a Hash object from an existing Hash object or a hex-string
|
|
12
11
|
*
|
package/dist/types/hash.js
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Hash = void 0;
|
|
4
4
|
const serialized_type_1 = require("./serialized-type");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("@transia/isomorphic/utils");
|
|
6
|
+
const utils_2 = require("../utils");
|
|
6
7
|
/**
|
|
7
8
|
* Base class defining how to encode and decode hashes
|
|
8
9
|
*/
|
|
9
10
|
class Hash extends serialized_type_1.Comparable {
|
|
10
11
|
constructor(bytes) {
|
|
11
12
|
super(bytes);
|
|
12
|
-
if (this.bytes.
|
|
13
|
+
if (this.bytes.length !== this.constructor.width) {
|
|
13
14
|
throw new Error(`Invalid Hash length ${this.bytes.byteLength}`);
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -23,7 +24,10 @@ class Hash extends serialized_type_1.Comparable {
|
|
|
23
24
|
return value;
|
|
24
25
|
}
|
|
25
26
|
if (typeof value === 'string') {
|
|
26
|
-
|
|
27
|
+
if (!utils_1.HEX_REGEX.test(value)) {
|
|
28
|
+
throw new Error(`Invalid hash string ${value}`);
|
|
29
|
+
}
|
|
30
|
+
return new this((0, utils_1.hexToBytes)(value));
|
|
27
31
|
}
|
|
28
32
|
throw new Error('Cannot construct Hash from given value');
|
|
29
33
|
}
|
|
@@ -42,7 +46,7 @@ class Hash extends serialized_type_1.Comparable {
|
|
|
42
46
|
* @param other The Hash to compare this to
|
|
43
47
|
*/
|
|
44
48
|
compareTo(other) {
|
|
45
|
-
return
|
|
49
|
+
return (0, utils_2.compare)(this.bytes, this.constructor.from(other).bytes);
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
52
|
* @returns the hex-string representation of this Hash
|
package/dist/types/hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/types/hash.ts"],"names":[],"mappings":";;;AAAA,uDAA8C;AAE9C,
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/types/hash.ts"],"names":[],"mappings":";;;AAAA,uDAA8C;AAE9C,qDAAiE;AACjE,oCAAkC;AAElC;;GAEG;AACH,MAAM,IAAK,SAAQ,4BAAyB;IAG1C,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,CAAC,CAAA;QACZ,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAM,IAAI,CAAC,WAA2B,CAAC,KAAK,EAAE;YACjE,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAA;SAChE;IACH,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAA0B,KAAQ;QAC3C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,CAAA;SACb;QACD,OAAO,CAAC,CAAA;IACV,CAAC;CACF;AAEQ,oBAAI"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Blob } from './blob';
|
|
|
4
4
|
import { Currency } from './currency';
|
|
5
5
|
import { Hash128 } from './hash-128';
|
|
6
6
|
import { Hash160 } from './hash-160';
|
|
7
|
+
import { Hash192 } from './hash-192';
|
|
7
8
|
import { Hash256 } from './hash-256';
|
|
8
9
|
import { PathSet } from './path-set';
|
|
9
10
|
import { STArray } from './st-array';
|
|
@@ -15,4 +16,4 @@ import { UInt8 } from './uint-8';
|
|
|
15
16
|
import { Vector256 } from './vector-256';
|
|
16
17
|
import { type SerializedType } from './serialized-type';
|
|
17
18
|
declare const coreTypes: Record<string, typeof SerializedType>;
|
|
18
|
-
export { coreTypes, AccountID, Amount, Blob, Currency, Hash128, Hash160, Hash256, PathSet, STArray, STObject, UInt8, UInt16, UInt32, UInt64, Vector256, };
|
|
19
|
+
export { coreTypes, AccountID, Amount, Blob, Currency, Hash128, Hash160, Hash192, Hash256, PathSet, STArray, STObject, UInt8, UInt16, UInt32, UInt64, Vector256, };
|
package/dist/types/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Vector256 = exports.UInt64 = exports.UInt32 = exports.UInt16 = exports.UInt8 = exports.STObject = exports.STArray = exports.PathSet = exports.Hash256 = exports.Hash160 = exports.Hash128 = exports.Currency = exports.Blob = exports.Amount = exports.AccountID = exports.coreTypes = void 0;
|
|
3
|
+
exports.Vector256 = exports.UInt64 = exports.UInt32 = exports.UInt16 = exports.UInt8 = exports.STObject = exports.STArray = exports.PathSet = exports.Hash256 = exports.Hash192 = exports.Hash160 = exports.Hash128 = exports.Currency = exports.Blob = exports.Amount = exports.AccountID = exports.coreTypes = void 0;
|
|
4
4
|
const account_id_1 = require("./account-id");
|
|
5
5
|
Object.defineProperty(exports, "AccountID", { enumerable: true, get: function () { return account_id_1.AccountID; } });
|
|
6
6
|
const amount_1 = require("./amount");
|
|
@@ -13,8 +13,12 @@ const hash_128_1 = require("./hash-128");
|
|
|
13
13
|
Object.defineProperty(exports, "Hash128", { enumerable: true, get: function () { return hash_128_1.Hash128; } });
|
|
14
14
|
const hash_160_1 = require("./hash-160");
|
|
15
15
|
Object.defineProperty(exports, "Hash160", { enumerable: true, get: function () { return hash_160_1.Hash160; } });
|
|
16
|
+
const hash_192_1 = require("./hash-192");
|
|
17
|
+
Object.defineProperty(exports, "Hash192", { enumerable: true, get: function () { return hash_192_1.Hash192; } });
|
|
16
18
|
const hash_256_1 = require("./hash-256");
|
|
17
19
|
Object.defineProperty(exports, "Hash256", { enumerable: true, get: function () { return hash_256_1.Hash256; } });
|
|
20
|
+
const issue_1 = require("./issue");
|
|
21
|
+
const st_number_1 = require("./st-number");
|
|
18
22
|
const path_set_1 = require("./path-set");
|
|
19
23
|
Object.defineProperty(exports, "PathSet", { enumerable: true, get: function () { return path_set_1.PathSet; } });
|
|
20
24
|
const st_array_1 = require("./st-array");
|
|
@@ -31,6 +35,7 @@ const uint_8_1 = require("./uint-8");
|
|
|
31
35
|
Object.defineProperty(exports, "UInt8", { enumerable: true, get: function () { return uint_8_1.UInt8; } });
|
|
32
36
|
const vector_256_1 = require("./vector-256");
|
|
33
37
|
Object.defineProperty(exports, "Vector256", { enumerable: true, get: function () { return vector_256_1.Vector256; } });
|
|
38
|
+
const xchain_bridge_1 = require("./xchain-bridge");
|
|
34
39
|
const enums_1 = require("../enums");
|
|
35
40
|
const coreTypes = {
|
|
36
41
|
AccountID: account_id_1.AccountID,
|
|
@@ -39,7 +44,10 @@ const coreTypes = {
|
|
|
39
44
|
Currency: currency_1.Currency,
|
|
40
45
|
Hash128: hash_128_1.Hash128,
|
|
41
46
|
Hash160: hash_160_1.Hash160,
|
|
47
|
+
Hash192: hash_192_1.Hash192,
|
|
42
48
|
Hash256: hash_256_1.Hash256,
|
|
49
|
+
Issue: issue_1.Issue,
|
|
50
|
+
Number: st_number_1.STNumber,
|
|
43
51
|
PathSet: path_set_1.PathSet,
|
|
44
52
|
STArray: st_array_1.STArray,
|
|
45
53
|
STObject: st_object_1.STObject,
|
|
@@ -48,10 +56,11 @@ const coreTypes = {
|
|
|
48
56
|
UInt32: uint_32_1.UInt32,
|
|
49
57
|
UInt64: uint_64_1.UInt64,
|
|
50
58
|
Vector256: vector_256_1.Vector256,
|
|
59
|
+
XChainBridge: xchain_bridge_1.XChainBridge,
|
|
51
60
|
};
|
|
52
61
|
exports.coreTypes = coreTypes;
|
|
53
62
|
// Ensures that the DEFAULT_DEFINITIONS object connects these types to fields for serializing/deserializing
|
|
54
63
|
// This is done here instead of in enums/index.ts to avoid a circular dependency
|
|
55
|
-
// because some of the above types depend on
|
|
64
|
+
// because some of the above types depend on BinarySerializer which depends on enums/index.ts.
|
|
56
65
|
enums_1.DEFAULT_DEFINITIONS.associateTypes(coreTypes);
|
|
57
66
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAmDtC,0FAnDO,sBAAS,OAmDP;AAlDX,qCAAiC;AAmD/B,uFAnDO,eAAM,OAmDP;AAlDR,iCAA6B;AAmD3B,qFAnDO,WAAI,OAmDP;AAlDN,yCAAqC;AAmDnC,yFAnDO,mBAAQ,OAmDP;AAlDV,yCAAoC;AAmDlC,wFAnDO,kBAAO,OAmDP;AAlDT,yCAAoC;AAmDlC,wFAnDO,kBAAO,OAmDP;AAlDT,yCAAoC;AAmDlC,wFAnDO,kBAAO,OAmDP;AAlDT,yCAAoC;AAmDlC,wFAnDO,kBAAO,OAmDP;AAlDT,mCAA+B;AAC/B,2CAAsC;AACtC,yCAAoC;AAiDlC,wFAjDO,kBAAO,OAiDP;AAhDT,yCAAoC;AAiDlC,wFAjDO,kBAAO,OAiDP;AAhDT,2CAAsC;AAiDpC,yFAjDO,oBAAQ,OAiDP;AAhDV,uCAAkC;AAkDhC,uFAlDO,gBAAM,OAkDP;AAjDR,uCAAkC;AAkDhC,uFAlDO,gBAAM,OAkDP;AAjDR,uCAAkC;AAkDhC,uFAlDO,gBAAM,OAkDP;AAjDR,qCAAgC;AA8C9B,sFA9CO,cAAK,OA8CP;AA7CP,6CAAwC;AAiDtC,0FAjDO,sBAAS,OAiDP;AAhDX,mDAA8C;AAE9C,oCAA8C;AAE9C,MAAM,SAAS,GAA0C;IACvD,SAAS,EAAT,sBAAS;IACT,MAAM,EAAN,eAAM;IACN,IAAI,EAAJ,WAAI;IACJ,QAAQ,EAAR,mBAAQ;IACR,OAAO,EAAP,kBAAO;IACP,OAAO,EAAP,kBAAO;IACP,OAAO,EAAP,kBAAO;IACP,OAAO,EAAP,kBAAO;IACP,KAAK,EAAL,aAAK;IACL,MAAM,EAAE,oBAAQ;IAChB,OAAO,EAAP,kBAAO;IACP,OAAO,EAAP,kBAAO;IACP,QAAQ,EAAR,oBAAQ;IACR,KAAK,EAAL,cAAK;IACL,MAAM,EAAN,gBAAM;IACN,MAAM,EAAN,gBAAM;IACN,MAAM,EAAN,gBAAM;IACN,SAAS,EAAT,sBAAS;IACT,YAAY,EAAZ,4BAAY;CACb,CAAA;AAQC,8BAAS;AANX,2GAA2G;AAC3G,gFAAgF;AAChF,8FAA8F;AAC9F,2BAAmB,CAAC,cAAc,CAAC,SAAS,CAAC,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
2
|
+
import { JsonObject, SerializedType } from './serialized-type';
|
|
3
|
+
interface XRPIssue extends JsonObject {
|
|
4
|
+
currency: string;
|
|
5
|
+
}
|
|
6
|
+
interface IOUIssue extends JsonObject {
|
|
7
|
+
currency: string;
|
|
8
|
+
issuer: string;
|
|
9
|
+
}
|
|
10
|
+
interface MPTIssue extends JsonObject {
|
|
11
|
+
mpt_issuance_id: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Interface for JSON objects that represent issues
|
|
15
|
+
*/
|
|
16
|
+
type IssueObject = XRPIssue | IOUIssue | MPTIssue;
|
|
17
|
+
/**
|
|
18
|
+
* Class for serializing/Deserializing Amounts
|
|
19
|
+
*/
|
|
20
|
+
declare class Issue extends SerializedType {
|
|
21
|
+
static readonly ZERO_ISSUED_CURRENCY: Issue;
|
|
22
|
+
constructor(bytes: Uint8Array);
|
|
23
|
+
/**
|
|
24
|
+
* Construct an amount from an IOU or string amount
|
|
25
|
+
*
|
|
26
|
+
* @param value An Amount, object representing an IOU, MPTAmount, or a string
|
|
27
|
+
* representing an integer amount
|
|
28
|
+
* @returns An Issue object
|
|
29
|
+
*/
|
|
30
|
+
static from<T extends Issue | IssueObject>(value: T): Issue;
|
|
31
|
+
/**
|
|
32
|
+
* Read an amount from a BinaryParser
|
|
33
|
+
*
|
|
34
|
+
* @param parser BinaryParser to read the Amount from
|
|
35
|
+
* @param hint The number of bytes to consume from the parser.
|
|
36
|
+
* For an MPT amount, pass 24 (the fixed length for Hash192).
|
|
37
|
+
*
|
|
38
|
+
* @returns An Issue object
|
|
39
|
+
*/
|
|
40
|
+
static fromParser(parser: BinaryParser, hint?: number): Issue;
|
|
41
|
+
/**
|
|
42
|
+
* Get the JSON representation of this Amount
|
|
43
|
+
*
|
|
44
|
+
* @returns the JSON interpretation of this.bytes
|
|
45
|
+
*/
|
|
46
|
+
toJSON(): IssueObject;
|
|
47
|
+
}
|
|
48
|
+
export { Issue, IssueObject };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Issue = void 0;
|
|
4
|
+
const utils_1 = require("@transia/isomorphic/utils");
|
|
5
|
+
const binary_parser_1 = require("../serdes/binary-parser");
|
|
6
|
+
const account_id_1 = require("./account-id");
|
|
7
|
+
const currency_1 = require("./currency");
|
|
8
|
+
const serialized_type_1 = require("./serialized-type");
|
|
9
|
+
const hash_192_1 = require("./hash-192");
|
|
10
|
+
/**
|
|
11
|
+
* Type guard for Issue Object
|
|
12
|
+
*/
|
|
13
|
+
function isIssueObject(arg) {
|
|
14
|
+
const keys = Object.keys(arg).sort();
|
|
15
|
+
const isXRP = keys.length === 1 && keys[0] === 'currency';
|
|
16
|
+
const isIOU = keys.length === 2 && keys[0] === 'currency' && keys[1] === 'issuer';
|
|
17
|
+
const isMPT = keys.length === 1 && keys[0] === 'mpt_issuance_id';
|
|
18
|
+
return isXRP || isIOU || isMPT;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Class for serializing/Deserializing Amounts
|
|
22
|
+
*/
|
|
23
|
+
class Issue extends serialized_type_1.SerializedType {
|
|
24
|
+
constructor(bytes) {
|
|
25
|
+
super(bytes !== null && bytes !== void 0 ? bytes : Issue.ZERO_ISSUED_CURRENCY.bytes);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Construct an amount from an IOU or string amount
|
|
29
|
+
*
|
|
30
|
+
* @param value An Amount, object representing an IOU, MPTAmount, or a string
|
|
31
|
+
* representing an integer amount
|
|
32
|
+
* @returns An Issue object
|
|
33
|
+
*/
|
|
34
|
+
static from(value) {
|
|
35
|
+
if (value instanceof Issue) {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
if (isIssueObject(value)) {
|
|
39
|
+
if (value.currency) {
|
|
40
|
+
const currency = currency_1.Currency.from(value.currency.toString()).toBytes();
|
|
41
|
+
//IOU case
|
|
42
|
+
if (value.issuer) {
|
|
43
|
+
const issuer = account_id_1.AccountID.from(value.issuer.toString()).toBytes();
|
|
44
|
+
return new Issue((0, utils_1.concat)([currency, issuer]));
|
|
45
|
+
}
|
|
46
|
+
//XRP case
|
|
47
|
+
return new Issue(currency);
|
|
48
|
+
}
|
|
49
|
+
// MPT case
|
|
50
|
+
if (value.mpt_issuance_id) {
|
|
51
|
+
const mptIssuanceIdBytes = hash_192_1.Hash192.from(value.mpt_issuance_id.toString()).toBytes();
|
|
52
|
+
return new Issue(mptIssuanceIdBytes);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
throw new Error('Invalid type to construct an Amount');
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Read an amount from a BinaryParser
|
|
59
|
+
*
|
|
60
|
+
* @param parser BinaryParser to read the Amount from
|
|
61
|
+
* @param hint The number of bytes to consume from the parser.
|
|
62
|
+
* For an MPT amount, pass 24 (the fixed length for Hash192).
|
|
63
|
+
*
|
|
64
|
+
* @returns An Issue object
|
|
65
|
+
*/
|
|
66
|
+
static fromParser(parser, hint) {
|
|
67
|
+
if (hint === hash_192_1.Hash192.width) {
|
|
68
|
+
const mptBytes = parser.read(hash_192_1.Hash192.width);
|
|
69
|
+
return new Issue(mptBytes);
|
|
70
|
+
}
|
|
71
|
+
const currency = parser.read(20);
|
|
72
|
+
if (new currency_1.Currency(currency).toJSON() === 'XRP') {
|
|
73
|
+
return new Issue(currency);
|
|
74
|
+
}
|
|
75
|
+
const currencyAndIssuer = [currency, parser.read(20)];
|
|
76
|
+
return new Issue((0, utils_1.concat)(currencyAndIssuer));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get the JSON representation of this Amount
|
|
80
|
+
*
|
|
81
|
+
* @returns the JSON interpretation of this.bytes
|
|
82
|
+
*/
|
|
83
|
+
toJSON() {
|
|
84
|
+
// If the buffer is exactly 24 bytes, treat it as an MPT amount.
|
|
85
|
+
if (this.toBytes().length === hash_192_1.Hash192.width) {
|
|
86
|
+
return {
|
|
87
|
+
mpt_issuance_id: this.toHex().toUpperCase(),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const parser = new binary_parser_1.BinaryParser(this.toString());
|
|
91
|
+
const currency = currency_1.Currency.fromParser(parser);
|
|
92
|
+
if (currency.toJSON() === 'XRP') {
|
|
93
|
+
return { currency: currency.toJSON() };
|
|
94
|
+
}
|
|
95
|
+
const issuer = account_id_1.AccountID.fromParser(parser);
|
|
96
|
+
return {
|
|
97
|
+
currency: currency.toJSON(),
|
|
98
|
+
issuer: issuer.toJSON(),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.Issue = Issue;
|
|
103
|
+
Issue.ZERO_ISSUED_CURRENCY = new Issue(new Uint8Array(20));
|
|
104
|
+
//# sourceMappingURL=issue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../../src/types/issue.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,2DAAsD;AAEtD,6CAAwC;AACxC,yCAAqC;AACrC,uDAA8D;AAC9D,yCAAoC;AAkBpC;;GAEG;AACH,SAAS,aAAa,CAAC,GAAG;IACxB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IACpC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,CAAA;IACzD,MAAM,KAAK,GACT,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAA;IACrE,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,CAAA;IAEhE,OAAO,KAAK,IAAI,KAAK,IAAI,KAAK,CAAA;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,KAAM,SAAQ,gCAAc;IAGhC,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,aAA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/types/path-set.js
CHANGED
|
@@ -5,7 +5,7 @@ const account_id_1 = require("./account-id");
|
|
|
5
5
|
const currency_1 = require("./currency");
|
|
6
6
|
const binary_parser_1 = require("../serdes/binary-parser");
|
|
7
7
|
const serialized_type_1 = require("./serialized-type");
|
|
8
|
-
const
|
|
8
|
+
const utils_1 = require("@transia/isomorphic/utils");
|
|
9
9
|
/**
|
|
10
10
|
* Constants for separating Paths in a PathSet
|
|
11
11
|
*/
|
|
@@ -47,7 +47,7 @@ class Hop extends serialized_type_1.SerializedType {
|
|
|
47
47
|
if (value instanceof Hop) {
|
|
48
48
|
return value;
|
|
49
49
|
}
|
|
50
|
-
const bytes = [
|
|
50
|
+
const bytes = [Uint8Array.from([0])];
|
|
51
51
|
if (value.account) {
|
|
52
52
|
bytes.push(account_id_1.AccountID.from(value.account).toBytes());
|
|
53
53
|
bytes[0][0] |= TYPE_ACCOUNT;
|
|
@@ -60,7 +60,7 @@ class Hop extends serialized_type_1.SerializedType {
|
|
|
60
60
|
bytes.push(account_id_1.AccountID.from(value.issuer).toBytes());
|
|
61
61
|
bytes[0][0] |= TYPE_ISSUER;
|
|
62
62
|
}
|
|
63
|
-
return new Hop(
|
|
63
|
+
return new Hop((0, utils_1.concat)(bytes));
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* Construct a Hop from a BinaryParser
|
|
@@ -70,7 +70,7 @@ class Hop extends serialized_type_1.SerializedType {
|
|
|
70
70
|
*/
|
|
71
71
|
static fromParser(parser) {
|
|
72
72
|
const type = parser.readUInt8();
|
|
73
|
-
const bytes = [
|
|
73
|
+
const bytes = [Uint8Array.from([type])];
|
|
74
74
|
if (type & TYPE_ACCOUNT) {
|
|
75
75
|
bytes.push(parser.read(account_id_1.AccountID.width));
|
|
76
76
|
}
|
|
@@ -80,7 +80,7 @@ class Hop extends serialized_type_1.SerializedType {
|
|
|
80
80
|
if (type & TYPE_ISSUER) {
|
|
81
81
|
bytes.push(parser.read(account_id_1.AccountID.width));
|
|
82
82
|
}
|
|
83
|
-
return new Hop(
|
|
83
|
+
return new Hop((0, utils_1.concat)(bytes));
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Get the JSON interpretation of this hop
|
|
@@ -88,7 +88,7 @@ class Hop extends serialized_type_1.SerializedType {
|
|
|
88
88
|
* @returns a HopObject, an JS object with optional account, issuer, and currency
|
|
89
89
|
*/
|
|
90
90
|
toJSON() {
|
|
91
|
-
const hopParser = new binary_parser_1.BinaryParser(this.bytes
|
|
91
|
+
const hopParser = new binary_parser_1.BinaryParser((0, utils_1.bytesToHex)(this.bytes));
|
|
92
92
|
const type = hopParser.readUInt8();
|
|
93
93
|
let account, currency, issuer;
|
|
94
94
|
if (type & TYPE_ACCOUNT) {
|
|
@@ -139,7 +139,7 @@ class Path extends serialized_type_1.SerializedType {
|
|
|
139
139
|
value.forEach((hop) => {
|
|
140
140
|
bytes.push(Hop.from(hop).toBytes());
|
|
141
141
|
});
|
|
142
|
-
return new Path(
|
|
142
|
+
return new Path((0, utils_1.concat)(bytes));
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
145
|
* Read a Path from a BinaryParser
|
|
@@ -156,7 +156,7 @@ class Path extends serialized_type_1.SerializedType {
|
|
|
156
156
|
break;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
return new Path(
|
|
159
|
+
return new Path((0, utils_1.concat)(bytes));
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
162
|
* Get the JSON representation of this Path
|
|
@@ -190,10 +190,10 @@ class PathSet extends serialized_type_1.SerializedType {
|
|
|
190
190
|
const bytes = [];
|
|
191
191
|
value.forEach((path) => {
|
|
192
192
|
bytes.push(Path.from(path).toBytes());
|
|
193
|
-
bytes.push(
|
|
193
|
+
bytes.push(Uint8Array.from([PATH_SEPARATOR_BYTE]));
|
|
194
194
|
});
|
|
195
|
-
bytes[bytes.length - 1] =
|
|
196
|
-
return new PathSet(
|
|
195
|
+
bytes[bytes.length - 1] = Uint8Array.from([PATHSET_END_BYTE]);
|
|
196
|
+
return new PathSet((0, utils_1.concat)(bytes));
|
|
197
197
|
}
|
|
198
198
|
throw new Error('Cannot construct PathSet from given value');
|
|
199
199
|
}
|
|
@@ -212,7 +212,7 @@ class PathSet extends serialized_type_1.SerializedType {
|
|
|
212
212
|
break;
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
return new PathSet(
|
|
215
|
+
return new PathSet((0, utils_1.concat)(bytes));
|
|
216
216
|
}
|
|
217
217
|
/**
|
|
218
218
|
* Get the JSON representation of this PathSet
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-set.js","sourceRoot":"","sources":["../../src/types/path-set.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AACxC,yCAAqC;AACrC,2DAAsD;AACtD,uDAA8D;AAC9D,
|
|
1
|
+
{"version":3,"file":"path-set.js","sourceRoot":"","sources":["../../src/types/path-set.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AACxC,yCAAqC;AACrC,2DAAsD;AACtD,uDAA8D;AAC9D,qDAA8D;AAE9D;;GAEG;AACH,MAAM,gBAAgB,GAAG,IAAI,CAAA;AAC7B,MAAM,mBAAmB,GAAG,IAAI,CAAA;AAEhC;;GAEG;AACH,MAAM,YAAY,GAAG,IAAI,CAAA;AACzB,MAAM,aAAa,GAAG,IAAI,CAAA;AAC1B,MAAM,WAAW,GAAG,IAAI,CAAA;AAWxB;;GAEG;AACH,SAAS,WAAW,CAAC,GAAG;IACtB,OAAO,CACL,GAAG,CAAC,MAAM,KAAK,SAAS;QACxB,GAAG,CAAC,OAAO,KAAK,SAAS;QACzB,GAAG,CAAC,QAAQ,KAAK,SAAS,CAC3B,CAAA;AACH,CAAC;AAED;;GAEG;AACH,SAAS,SAAS,CAAC,GAAG;IACpB,OAAO,CACL,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC;QACxC,CAAC,KAAK,CA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CAAC,CAAC,CAAA;SAClC;QAED,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;IAC9D,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,MAAoB;QACpC,MAAM,KAAK,GAAsB,EAAE,CAAA;QAEnC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;YAC7C,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;YAE1B,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,gBAAgB,EAAE;gBAClD,MAAK;aACN;SACF;QAED,OAAO,IAAI,OAAO,CAAC,IAAA,cAAM,EAAC,KAAK,CAAC,CAAC,CAAA;IACnC,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,MAAM,IAAI,GAA4B,EAAE,CAAA;QACxC,MAAM,UAAU,GAAG,IAAI,4BAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;QAEpD,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE;YACxB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,CAAA;YAC/C,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;SACnB;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAEQ,0BAAO"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BytesList } from '../serdes/binary-serializer';
|
|
2
2
|
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
-
import
|
|
4
|
-
import { Buffer } from 'buffer/';
|
|
3
|
+
import { XrplDefinitionsBase } from '../enums';
|
|
5
4
|
type JSON = string | number | boolean | null | undefined | JSON[] | JsonObject;
|
|
6
5
|
type JsonObject = {
|
|
7
6
|
[key: string]: JSON;
|
|
@@ -10,10 +9,10 @@ type JsonObject = {
|
|
|
10
9
|
* The base class for all binary-codec types
|
|
11
10
|
*/
|
|
12
11
|
declare class SerializedType {
|
|
13
|
-
protected readonly bytes:
|
|
14
|
-
constructor(bytes
|
|
12
|
+
protected readonly bytes: Uint8Array;
|
|
13
|
+
constructor(bytes?: Uint8Array);
|
|
15
14
|
static fromParser(parser: BinaryParser, hint?: number): SerializedType;
|
|
16
|
-
static from(value: SerializedType | JSON |
|
|
15
|
+
static from(value: SerializedType | JSON | bigint): SerializedType;
|
|
17
16
|
/**
|
|
18
17
|
* Write the bytes representation of a SerializedType to a BytesList
|
|
19
18
|
*
|
|
@@ -29,35 +28,43 @@ declare class SerializedType {
|
|
|
29
28
|
/**
|
|
30
29
|
* Get the bytes representation of a SerializedType
|
|
31
30
|
*
|
|
32
|
-
* @returns A
|
|
31
|
+
* @returns A Uint8Array of the bytes
|
|
33
32
|
*/
|
|
34
|
-
toBytes():
|
|
33
|
+
toBytes(): Uint8Array;
|
|
35
34
|
/**
|
|
36
35
|
* Return the JSON representation of a SerializedType
|
|
37
36
|
*
|
|
37
|
+
* @param _definitions rippled definitions used to parse the values of transaction types and such.
|
|
38
|
+
* Unused in default, but used in STObject, STArray
|
|
39
|
+
* Can be customized for sidechains and amendments.
|
|
38
40
|
* @returns any type, if not overloaded returns hexString representation of bytes
|
|
39
41
|
*/
|
|
40
|
-
toJSON(): JSON;
|
|
42
|
+
toJSON(_definitions?: XrplDefinitionsBase, _fieldName?: string): JSON;
|
|
41
43
|
/**
|
|
42
44
|
* @returns hexString representation of this.bytes
|
|
43
45
|
*/
|
|
44
46
|
toString(): string;
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
47
|
-
* Base class for SerializedTypes that are comparable
|
|
49
|
+
* Base class for SerializedTypes that are comparable.
|
|
50
|
+
*
|
|
51
|
+
* @template T - What types you want to allow comparisons between. You must specify all types. Primarily used to allow
|
|
52
|
+
* comparisons between built-in types (like `string`) and SerializedType subclasses (like `Hash`).
|
|
53
|
+
*
|
|
54
|
+
* Ex. `class Hash extends Comparable<Hash | string>`
|
|
48
55
|
*/
|
|
49
|
-
declare class Comparable extends SerializedType {
|
|
50
|
-
lt(other:
|
|
51
|
-
eq(other:
|
|
52
|
-
gt(other:
|
|
53
|
-
gte(other:
|
|
54
|
-
lte(other:
|
|
56
|
+
declare class Comparable<T extends Object> extends SerializedType {
|
|
57
|
+
lt(other: T): boolean;
|
|
58
|
+
eq(other: T): boolean;
|
|
59
|
+
gt(other: T): boolean;
|
|
60
|
+
gte(other: T): boolean;
|
|
61
|
+
lte(other: T): boolean;
|
|
55
62
|
/**
|
|
56
63
|
* Overload this method to define how two Comparable SerializedTypes are compared
|
|
57
64
|
*
|
|
58
65
|
* @param other The comparable object to compare this to
|
|
59
66
|
* @returns A number denoting the relationship of this and other
|
|
60
67
|
*/
|
|
61
|
-
compareTo(other:
|
|
68
|
+
compareTo(other: T): number;
|
|
62
69
|
}
|
|
63
70
|
export { SerializedType, Comparable, JSON, JsonObject };
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Comparable = exports.SerializedType = void 0;
|
|
4
4
|
const binary_serializer_1 = require("../serdes/binary-serializer");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("@transia/isomorphic/utils");
|
|
6
6
|
/**
|
|
7
7
|
* The base class for all binary-codec types
|
|
8
8
|
*/
|
|
9
9
|
class SerializedType {
|
|
10
10
|
constructor(bytes) {
|
|
11
|
-
this.bytes =
|
|
12
|
-
this.bytes = bytes !== null && bytes !== void 0 ? bytes :
|
|
11
|
+
this.bytes = new Uint8Array(0);
|
|
12
|
+
this.bytes = bytes !== null && bytes !== void 0 ? bytes : new Uint8Array(0);
|
|
13
13
|
}
|
|
14
14
|
static fromParser(parser, hint) {
|
|
15
15
|
throw new Error('fromParser not implemented');
|
|
@@ -33,12 +33,12 @@ class SerializedType {
|
|
|
33
33
|
* @returns hex String of this.bytes
|
|
34
34
|
*/
|
|
35
35
|
toHex() {
|
|
36
|
-
return this.toBytes()
|
|
36
|
+
return (0, utils_1.bytesToHex)(this.toBytes());
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Get the bytes representation of a SerializedType
|
|
40
40
|
*
|
|
41
|
-
* @returns A
|
|
41
|
+
* @returns A Uint8Array of the bytes
|
|
42
42
|
*/
|
|
43
43
|
toBytes() {
|
|
44
44
|
if (this.bytes) {
|
|
@@ -51,9 +51,12 @@ class SerializedType {
|
|
|
51
51
|
/**
|
|
52
52
|
* Return the JSON representation of a SerializedType
|
|
53
53
|
*
|
|
54
|
+
* @param _definitions rippled definitions used to parse the values of transaction types and such.
|
|
55
|
+
* Unused in default, but used in STObject, STArray
|
|
56
|
+
* Can be customized for sidechains and amendments.
|
|
54
57
|
* @returns any type, if not overloaded returns hexString representation of bytes
|
|
55
58
|
*/
|
|
56
|
-
toJSON() {
|
|
59
|
+
toJSON(_definitions, _fieldName) {
|
|
57
60
|
return this.toHex();
|
|
58
61
|
}
|
|
59
62
|
/**
|
|
@@ -65,7 +68,12 @@ class SerializedType {
|
|
|
65
68
|
}
|
|
66
69
|
exports.SerializedType = SerializedType;
|
|
67
70
|
/**
|
|
68
|
-
* Base class for SerializedTypes that are comparable
|
|
71
|
+
* Base class for SerializedTypes that are comparable.
|
|
72
|
+
*
|
|
73
|
+
* @template T - What types you want to allow comparisons between. You must specify all types. Primarily used to allow
|
|
74
|
+
* comparisons between built-in types (like `string`) and SerializedType subclasses (like `Hash`).
|
|
75
|
+
*
|
|
76
|
+
* Ex. `class Hash extends Comparable<Hash | string>`
|
|
69
77
|
*/
|
|
70
78
|
class Comparable extends SerializedType {
|
|
71
79
|
lt(other) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialized-type.js","sourceRoot":"","sources":["../../src/types/serialized-type.ts"],"names":[],"mappings":";;;AAAA,mEAAuD;AAGvD,
|
|
1
|
+
{"version":3,"file":"serialized-type.js","sourceRoot":"","sources":["../../src/types/serialized-type.ts"],"names":[],"mappings":";;;AAAA,mEAAuD;AAGvD,qDAAsD;AAMtD;;GAEG;AACH,MAAM,cAAc;IAGlB,YAAY,KAAkB;QAFX,UAAK,GAAe,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;QAGtD,IAAI,CAAC,KAAK,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;IACzC,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,MAAoB,EAAE,IAAa;QACnD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAC7C,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACtC,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,KAAqC;QAC/C,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACzB,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,IAAe;QACzB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IAED;;;;OAIG;IACH,KAAK;QACH,OAAO,IAAA,kBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IACnC,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,OAAO,IAAI,CAAC,KAAK,CAAA;SAClB;QACD,MAAM,KAAK,GAAG,IAAI,6BAAS,EAAE,CAAA;QAC7B,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QACvB,OAAO,KAAK,CAAC,OAAO,EAAE,CAAA;IACxB,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,YAAkC,EAAE,UAAmB;QAC5D,OAAO,IAAI,CAAC,KAAK,EAAE,CAAA;IACrB,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,EAAE,CAAA;IACrB,CAAC;CACF;AA0CQ,wCAAc;AAxCvB;;;;;;;GAOG;AACH,MAAM,UAA6B,SAAQ,cAAc;IACvD,EAAE,CAAC,KAAQ;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClC,CAAC;IAED,EAAE,CAAC,KAAQ;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IAED,EAAE,CAAC,KAAQ;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClC,CAAC;IAED,GAAG,CAAC,KAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;IACnC,CAAC;IAED,GAAG,CAAC,KAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClC,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,KAAQ;QAChB,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,CAAC,QAAQ,EAAE,QAAQ,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;IAC9E,CAAC;CACF;AAEwB,gCAAU"}
|
package/dist/types/st-array.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { XrplDefinitionsBase } from '../enums';
|
|
1
2
|
import { SerializedType, JsonObject } from './serialized-type';
|
|
2
3
|
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
4
|
/**
|
|
@@ -15,14 +16,16 @@ declare class STArray extends SerializedType {
|
|
|
15
16
|
* Construct an STArray from an Array of JSON Objects
|
|
16
17
|
*
|
|
17
18
|
* @param value STArray or Array of Objects to parse into an STArray
|
|
19
|
+
* @param definitions optional, types and values to use to encode/decode a transaction
|
|
18
20
|
* @returns An STArray object
|
|
19
21
|
*/
|
|
20
|
-
static from<T extends STArray | Array<JsonObject>>(value: T): STArray;
|
|
22
|
+
static from<T extends STArray | Array<JsonObject>>(value: T, definitions?: XrplDefinitionsBase): STArray;
|
|
21
23
|
/**
|
|
22
24
|
* Return the JSON representation of this.bytes
|
|
23
25
|
*
|
|
26
|
+
* @param definitions optional, types and values to use to encode/decode a transaction
|
|
24
27
|
* @returns An Array of JSON objects
|
|
25
28
|
*/
|
|
26
|
-
toJSON(): Array<JsonObject>;
|
|
29
|
+
toJSON(definitions?: XrplDefinitionsBase): Array<JsonObject>;
|
|
27
30
|
}
|
|
28
31
|
export { STArray };
|