ripple-binary-codec 1.0.0-rc3 → 1.0.1-mpt-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -4
- package/dist/binary.d.ts +34 -20
- package/dist/binary.js +51 -34
- package/dist/binary.js.map +1 -1
- package/dist/coretypes.d.ts +9 -9
- package/dist/coretypes.js +33 -9
- package/dist/coretypes.js.map +1 -1
- package/dist/enums/bytes.d.ts +25 -0
- package/dist/enums/bytes.js +63 -0
- package/dist/enums/bytes.js.map +1 -0
- package/dist/enums/constants.d.ts +4 -0
- package/dist/enums/constants.js +8 -0
- package/dist/enums/constants.js.map +1 -0
- package/dist/enums/definitions.json +2954 -1760
- package/dist/enums/field.d.ts +28 -0
- package/dist/enums/field.js +58 -0
- package/dist/enums/field.js.map +1 -0
- package/dist/enums/index.d.ts +12 -46
- package/dist/enums/index.js +22 -110
- package/dist/enums/index.js.map +1 -1
- package/dist/enums/src/enums/definitions.json +2961 -0
- package/dist/enums/utils-renumber.js +20 -20
- package/dist/enums/utils-renumber.js.map +1 -1
- package/dist/enums/xrpl-definitions-base.d.ts +44 -0
- package/dist/enums/xrpl-definitions-base.js +59 -0
- package/dist/enums/xrpl-definitions-base.js.map +1 -0
- package/dist/enums/xrpl-definitions.d.ts +21 -0
- package/dist/enums/xrpl-definitions.js +29 -0
- package/dist/enums/xrpl-definitions.js.map +1 -0
- package/dist/hash-prefixes.d.ts +1 -2
- package/dist/hash-prefixes.js +7 -6
- package/dist/hash-prefixes.js.map +1 -1
- package/dist/hashes.d.ts +7 -8
- package/dist/hashes.js +23 -44
- package/dist/hashes.js.map +1 -1
- package/dist/index.d.ts +16 -17
- package/dist/index.js +65 -40
- package/dist/index.js.map +1 -1
- package/dist/ledger-hashes.d.ts +6 -3
- package/dist/ledger-hashes.js +40 -33
- package/dist/ledger-hashes.js.map +1 -1
- package/dist/quality.d.ts +3 -4
- package/dist/quality.js +20 -19
- package/dist/quality.js.map +1 -1
- package/dist/serdes/binary-parser.d.ts +8 -6
- package/dist/serdes/binary-parser.js +74 -64
- package/dist/serdes/binary-parser.js.map +1 -1
- package/dist/serdes/binary-serializer.d.ts +10 -11
- package/dist/serdes/binary-serializer.js +50 -48
- package/dist/serdes/binary-serializer.js.map +1 -1
- package/dist/shamap.d.ts +6 -7
- package/dist/shamap.js +74 -97
- package/dist/shamap.js.map +1 -1
- package/dist/src/binary.d.ts +90 -0
- package/dist/src/binary.js +128 -0
- package/dist/src/binary.js.map +1 -0
- package/dist/src/coretypes.d.ts +9 -0
- package/dist/src/coretypes.js +48 -0
- package/dist/src/coretypes.js.map +1 -0
- package/dist/src/enums/bytes.d.ts +25 -0
- package/dist/src/enums/bytes.js +63 -0
- package/dist/src/enums/bytes.js.map +1 -0
- package/dist/src/enums/constants.d.ts +4 -0
- package/dist/src/enums/constants.js +8 -0
- package/dist/src/enums/constants.js.map +1 -0
- package/dist/src/enums/definitions.json +2956 -0
- package/dist/src/enums/field.d.ts +28 -0
- package/dist/src/enums/field.js +58 -0
- package/dist/src/enums/field.js.map +1 -0
- package/dist/src/enums/index.d.ts +12 -0
- package/dist/src/enums/index.js +31 -0
- package/dist/src/enums/index.js.map +1 -0
- package/dist/src/enums/utils-renumber.d.ts +101 -0
- package/dist/src/enums/utils-renumber.js +127 -0
- package/dist/src/enums/utils-renumber.js.map +1 -0
- package/dist/src/enums/xrpl-definitions-base.d.ts +44 -0
- package/dist/src/enums/xrpl-definitions-base.js +59 -0
- package/dist/src/enums/xrpl-definitions-base.js.map +1 -0
- package/dist/src/enums/xrpl-definitions.d.ts +21 -0
- package/dist/src/enums/xrpl-definitions.js +29 -0
- package/dist/src/enums/xrpl-definitions.js.map +1 -0
- package/dist/src/hash-prefixes.d.ts +5 -0
- package/dist/src/hash-prefixes.js +41 -0
- package/dist/src/hash-prefixes.js.map +1 -0
- package/dist/src/hashes.d.ts +50 -0
- package/dist/src/hashes.js +76 -0
- package/dist/src/hashes.js.map +1 -0
- package/dist/src/index.d.ts +64 -0
- package/dist/src/index.js +123 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/ledger-hashes.d.ts +48 -0
- package/dist/src/ledger-hashes.js +141 -0
- package/dist/src/ledger-hashes.js.map +1 -0
- package/dist/src/quality.d.ts +21 -0
- package/dist/src/quality.js +42 -0
- package/dist/src/quality.js.map +1 -0
- package/dist/src/serdes/binary-parser.d.ts +100 -0
- package/dist/src/serdes/binary-parser.js +194 -0
- package/dist/src/serdes/binary-parser.js.map +1 -0
- package/dist/src/serdes/binary-serializer.d.ts +81 -0
- package/dist/src/serdes/binary-serializer.js +149 -0
- package/dist/src/serdes/binary-serializer.js.map +1 -0
- package/dist/src/shamap.d.ts +102 -0
- package/dist/src/shamap.js +172 -0
- package/dist/src/shamap.js.map +1 -0
- package/dist/src/types/account-id.d.ts +35 -0
- package/dist/src/types/account-id.js +69 -0
- package/dist/src/types/account-id.js.map +1 -0
- package/dist/src/types/amount.d.ts +91 -0
- package/dist/src/types/amount.js +289 -0
- package/dist/src/types/amount.js.map +1 -0
- package/dist/src/types/blob.d.ts +24 -0
- package/dist/src/types/blob.js +40 -0
- package/dist/src/types/blob.js.map +1 -0
- package/dist/src/types/currency.d.ts +28 -0
- package/dist/src/types/currency.js +127 -0
- package/dist/src/types/currency.js.map +1 -0
- package/dist/src/types/hash-128.d.ts +16 -0
- package/dist/src/types/hash-128.js +32 -0
- package/dist/src/types/hash-128.js.map +1 -0
- package/dist/src/types/hash-160.d.ts +10 -0
- package/dist/src/types/hash-160.js +19 -0
- package/dist/src/types/hash-160.js.map +1 -0
- package/dist/src/types/hash-192.d.ts +10 -0
- package/dist/src/types/hash-192.js +19 -0
- package/dist/src/types/hash-192.js.map +1 -0
- package/dist/src/types/hash-256.d.ts +10 -0
- package/dist/src/types/hash-256.js +16 -0
- package/dist/src/types/hash-256.js.map +1 -0
- package/dist/src/types/hash.d.ts +40 -0
- package/dist/src/types/hash.js +73 -0
- package/dist/src/types/hash.js.map +1 -0
- package/dist/src/types/index.d.ts +19 -0
- package/dist/src/types/index.js +64 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/issue.d.ts +38 -0
- package/dist/src/types/issue.js +81 -0
- package/dist/src/types/issue.js.map +1 -0
- package/dist/src/types/path-set.d.ts +36 -0
- package/dist/src/types/path-set.js +233 -0
- package/dist/src/types/path-set.js.map +1 -0
- package/dist/src/types/serialized-type.d.ts +70 -0
- package/dist/src/types/serialized-type.js +105 -0
- package/dist/src/types/serialized-type.js.map +1 -0
- package/dist/src/types/st-array.d.ts +31 -0
- package/dist/src/types/st-array.js +83 -0
- package/dist/src/types/st-array.js.map +1 -0
- package/dist/src/types/st-object.d.ts +32 -0
- package/dist/src/types/st-object.js +155 -0
- package/dist/src/types/st-object.js.map +1 -0
- package/dist/src/types/uint-16.d.ts +24 -0
- package/dist/src/types/uint-16.js +45 -0
- package/dist/src/types/uint-16.js.map +1 -0
- package/dist/src/types/uint-32.d.ts +24 -0
- package/dist/src/types/uint-32.js +50 -0
- package/dist/src/types/uint-32.js.map +1 -0
- package/dist/src/types/uint-64.d.ts +37 -0
- package/dist/src/types/uint-64.js +86 -0
- package/dist/src/types/uint-64.js.map +1 -0
- package/dist/src/types/uint-8.d.ts +24 -0
- package/dist/src/types/uint-8.js +46 -0
- package/dist/src/types/uint-8.js.map +1 -0
- package/dist/src/types/uint.d.ts +29 -0
- package/dist/src/types/uint.js +47 -0
- package/dist/src/types/uint.js.map +1 -0
- package/dist/src/types/vector-256.d.ts +30 -0
- package/dist/src/types/vector-256.js +73 -0
- package/dist/src/types/vector-256.js.map +1 -0
- package/dist/src/types/xchain-bridge.d.ts +44 -0
- package/dist/src/types/xchain-bridge.js +102 -0
- package/dist/src/types/xchain-bridge.js.map +1 -0
- package/dist/src/utils.d.ts +47 -0
- package/dist/src/utils.js +137 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/account-id.d.ts +2 -3
- package/dist/types/account-id.js +29 -37
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.d.ts +33 -10
- package/dist/types/amount.js +181 -101
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.d.ts +3 -4
- package/dist/types/blob.js +13 -27
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.d.ts +5 -13
- package/dist/types/currency.js +52 -65
- package/dist/types/currency.js.map +1 -1
- package/dist/types/hash-128.d.ts +8 -3
- package/dist/types/hash-128.js +23 -22
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.d.ts +2 -3
- package/dist/types/hash-160.js +7 -24
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-192.d.ts +10 -0
- package/dist/types/hash-192.js +19 -0
- package/dist/types/hash-192.js.map +1 -0
- package/dist/types/hash-256.d.ts +2 -3
- package/dist/types/hash-256.js +7 -22
- package/dist/types/hash-256.js.map +1 -1
- package/dist/types/hash.d.ts +4 -5
- package/dist/types/hash.js +25 -39
- package/dist/types/hash.js.map +1 -1
- package/dist/types/index.d.ts +19 -33
- package/dist/types/index.js +44 -24
- package/dist/types/index.js.map +1 -1
- package/dist/types/issue.d.ts +38 -0
- package/dist/types/issue.js +81 -0
- package/dist/types/issue.js.map +1 -0
- package/dist/types/path-set.d.ts +2 -2
- package/dist/types/path-set.js +73 -94
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +26 -18
- package/dist/types/serialized-type.js +50 -60
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.d.ts +7 -4
- package/dist/types/st-array.js +33 -47
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-object.d.ts +8 -5
- package/dist/types/st-object.js +73 -70
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.d.ts +3 -4
- package/dist/types/uint-16.js +20 -33
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.d.ts +3 -4
- package/dist/types/uint-32.js +23 -36
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +5 -6
- package/dist/types/uint-64.js +44 -48
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.d.ts +3 -4
- package/dist/types/uint-8.js +21 -33
- package/dist/types/uint-8.js.map +1 -1
- package/dist/types/uint.d.ts +5 -5
- package/dist/types/uint.js +17 -27
- package/dist/types/uint.js.map +1 -1
- package/dist/types/vector-256.d.ts +3 -4
- package/dist/types/vector-256.js +28 -45
- package/dist/types/vector-256.js.map +1 -1
- package/dist/types/xchain-bridge.d.ts +44 -0
- package/dist/types/xchain-bridge.js +102 -0
- package/dist/types/xchain-bridge.js.map +1 -0
- package/dist/utils.d.ts +47 -0
- package/dist/utils.js +137 -0
- package/dist/utils.js.map +1 -0
- package/package.json +23 -34
- package/src/README.md +5 -0
- package/src/binary.ts +194 -0
- package/src/coretypes.ts +31 -0
- package/src/enums/README.md +144 -0
- package/src/enums/bytes.ts +74 -0
- package/src/enums/constants.ts +4 -0
- package/src/enums/definitions.json +2961 -0
- package/src/enums/field.ts +84 -0
- package/src/enums/index.ts +34 -0
- package/src/enums/utils-renumber.ts +134 -0
- package/src/enums/xrpl-definitions-base.ts +111 -0
- package/src/enums/xrpl-definitions.ts +32 -0
- package/src/hash-prefixes.ts +40 -0
- package/src/hashes.ts +75 -0
- package/src/index.ts +153 -0
- package/src/ledger-hashes.ts +191 -0
- package/src/quality.ts +38 -0
- package/src/serdes/binary-parser.ts +224 -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 +43 -0
- package/src/types/currency.ts +140 -0
- package/src/types/hash-128.ts +33 -0
- package/src/types/hash-160.ts +19 -0
- package/src/types/hash-192.ts +19 -0
- package/src/types/hash-256.ts +15 -0
- package/src/types/hash.ts +83 -0
- package/src/types/index.ts +66 -0
- package/src/types/issue.ts +96 -0
- package/src/types/path-set.ts +290 -0
- package/src/types/serialized-type.ts +122 -0
- package/src/types/st-array.ts +107 -0
- package/src/types/st-object.ts +192 -0
- package/src/types/uint-16.ts +53 -0
- package/src/types/uint-32.ts +59 -0
- package/src/types/uint-64.ts +104 -0
- package/src/types/uint-8.ts +52 -0
- package/src/types/uint.ts +60 -0
- package/src/types/vector-256.ts +79 -0
- package/src/types/xchain-bridge.ts +128 -0
- package/src/utils.ts +152 -0
- package/HISTORY.md +0 -68
- package/test/amount.test.js +0 -43
- package/test/binary-json.test.js +0 -47
- package/test/binary-parser.test.js +0 -397
- package/test/binary-serializer.test.js +0 -191
- package/test/fixtures/account-tx-transactions.db +0 -0
- package/test/fixtures/codec-fixtures.json +0 -4466
- package/test/fixtures/data-driven-tests.json +0 -3721
- package/test/fixtures/delivermin-tx-binary.json +0 -1
- package/test/fixtures/delivermin-tx.json +0 -98
- package/test/fixtures/deposit-preauth-tx-binary.json +0 -1
- package/test/fixtures/deposit-preauth-tx-meta-binary.json +0 -1
- package/test/fixtures/deposit-preauth-tx.json +0 -58
- package/test/fixtures/escrow-cancel-binary.json +0 -1
- package/test/fixtures/escrow-cancel-tx.json +0 -6
- package/test/fixtures/escrow-create-binary.json +0 -1
- package/test/fixtures/escrow-create-tx.json +0 -10
- package/test/fixtures/escrow-finish-binary.json +0 -1
- package/test/fixtures/escrow-finish-meta-binary.json +0 -1
- package/test/fixtures/escrow-finish-tx.json +0 -95
- package/test/fixtures/ledger-full-38129.json +0 -1
- package/test/fixtures/ledger-full-40000.json +0 -1
- package/test/fixtures/negative-unl.json +0 -12
- package/test/fixtures/payment-channel-claim-binary.json +0 -1
- package/test/fixtures/payment-channel-claim-tx.json +0 -8
- package/test/fixtures/payment-channel-create-binary.json +0 -1
- package/test/fixtures/payment-channel-create-tx.json +0 -11
- package/test/fixtures/payment-channel-fund-binary.json +0 -1
- package/test/fixtures/payment-channel-fund-tx.json +0 -7
- package/test/fixtures/signerlistset-tx-binary.json +0 -1
- package/test/fixtures/signerlistset-tx-meta-binary.json +0 -1
- package/test/fixtures/signerlistset-tx.json +0 -94
- package/test/fixtures/x-codec-fixtures.json +0 -188
- package/test/hash.test.js +0 -68
- package/test/ledger.test.js +0 -29
- package/test/lower-case-hex.test.js +0 -45
- package/test/pseudo-transaction.test.js +0 -38
- package/test/quality.test.js +0 -15
- package/test/shamap.test.js +0 -88
- package/test/signing-data-encoding.test.js +0 -129
- package/test/tx-encode-decode.test.js +0 -80
- package/test/types.test.js +0 -34
- package/test/uint.test.js +0 -40
- package/test/utils.js +0 -29
- package/test/x-address.test.js +0 -147
package/dist/types/path-set.js
CHANGED
|
@@ -1,34 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.PathSet = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
const account_id_1 = require("./account-id");
|
|
5
|
+
const currency_1 = require("./currency");
|
|
6
|
+
const binary_parser_1 = require("../serdes/binary-parser");
|
|
7
|
+
const serialized_type_1 = require("./serialized-type");
|
|
8
|
+
const utils_1 = require("@xrplf/isomorphic/utils");
|
|
21
9
|
/**
|
|
22
10
|
* Constants for separating Paths in a PathSet
|
|
23
11
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
const PATHSET_END_BYTE = 0x00;
|
|
13
|
+
const PATH_SEPARATOR_BYTE = 0xff;
|
|
26
14
|
/**
|
|
27
15
|
* Constant for masking types of a Hop
|
|
28
16
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
const TYPE_ACCOUNT = 0x01;
|
|
18
|
+
const TYPE_CURRENCY = 0x10;
|
|
19
|
+
const TYPE_ISSUER = 0x20;
|
|
32
20
|
/**
|
|
33
21
|
* TypeGuard for HopObject
|
|
34
22
|
*/
|
|
@@ -48,22 +36,18 @@ function isPathSet(arg) {
|
|
|
48
36
|
/**
|
|
49
37
|
* Serialize and Deserialize a Hop
|
|
50
38
|
*/
|
|
51
|
-
|
|
52
|
-
__extends(Hop, _super);
|
|
53
|
-
function Hop() {
|
|
54
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
55
|
-
}
|
|
39
|
+
class Hop extends serialized_type_1.SerializedType {
|
|
56
40
|
/**
|
|
57
41
|
* Create a Hop from a HopObject
|
|
58
42
|
*
|
|
59
43
|
* @param value Either a hop or HopObject to create a hop with
|
|
60
44
|
* @returns a Hop
|
|
61
45
|
*/
|
|
62
|
-
|
|
46
|
+
static from(value) {
|
|
63
47
|
if (value instanceof Hop) {
|
|
64
48
|
return value;
|
|
65
49
|
}
|
|
66
|
-
|
|
50
|
+
const bytes = [Uint8Array.from([0])];
|
|
67
51
|
if (value.account) {
|
|
68
52
|
bytes.push(account_id_1.AccountID.from(value.account).toBytes());
|
|
69
53
|
bytes[0][0] |= TYPE_ACCOUNT;
|
|
@@ -76,17 +60,17 @@ var Hop = /** @class */ (function (_super) {
|
|
|
76
60
|
bytes.push(account_id_1.AccountID.from(value.issuer).toBytes());
|
|
77
61
|
bytes[0][0] |= TYPE_ISSUER;
|
|
78
62
|
}
|
|
79
|
-
return new Hop(
|
|
80
|
-
}
|
|
63
|
+
return new Hop((0, utils_1.concat)(bytes));
|
|
64
|
+
}
|
|
81
65
|
/**
|
|
82
66
|
* Construct a Hop from a BinaryParser
|
|
83
67
|
*
|
|
84
68
|
* @param parser BinaryParser to read the Hop from
|
|
85
69
|
* @returns a Hop
|
|
86
70
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
71
|
+
static fromParser(parser) {
|
|
72
|
+
const type = parser.readUInt8();
|
|
73
|
+
const bytes = [Uint8Array.from([type])];
|
|
90
74
|
if (type & TYPE_ACCOUNT) {
|
|
91
75
|
bytes.push(parser.read(account_id_1.AccountID.width));
|
|
92
76
|
}
|
|
@@ -96,17 +80,17 @@ var Hop = /** @class */ (function (_super) {
|
|
|
96
80
|
if (type & TYPE_ISSUER) {
|
|
97
81
|
bytes.push(parser.read(account_id_1.AccountID.width));
|
|
98
82
|
}
|
|
99
|
-
return new Hop(
|
|
100
|
-
}
|
|
83
|
+
return new Hop((0, utils_1.concat)(bytes));
|
|
84
|
+
}
|
|
101
85
|
/**
|
|
102
86
|
* Get the JSON interpretation of this hop
|
|
103
87
|
*
|
|
104
88
|
* @returns a HopObject, an JS object with optional account, issuer, and currency
|
|
105
89
|
*/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
90
|
+
toJSON() {
|
|
91
|
+
const hopParser = new binary_parser_1.BinaryParser((0, utils_1.bytesToHex)(this.bytes));
|
|
92
|
+
const type = hopParser.readUInt8();
|
|
93
|
+
let account, currency, issuer;
|
|
110
94
|
if (type & TYPE_ACCOUNT) {
|
|
111
95
|
account = account_id_1.AccountID.fromParser(hopParser).toJSON();
|
|
112
96
|
}
|
|
@@ -116,54 +100,55 @@ var Hop = /** @class */ (function (_super) {
|
|
|
116
100
|
if (type & TYPE_ISSUER) {
|
|
117
101
|
issuer = account_id_1.AccountID.fromParser(hopParser).toJSON();
|
|
118
102
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
103
|
+
const result = {};
|
|
104
|
+
if (account) {
|
|
105
|
+
result.account = account;
|
|
106
|
+
}
|
|
107
|
+
if (issuer) {
|
|
108
|
+
result.issuer = issuer;
|
|
109
|
+
}
|
|
110
|
+
if (currency) {
|
|
111
|
+
result.currency = currency;
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
125
115
|
/**
|
|
126
116
|
* get a number representing the type of this hop
|
|
127
117
|
*
|
|
128
118
|
* @returns a number to be bitwise and-ed with TYPE_ constants to describe the types in the hop
|
|
129
119
|
*/
|
|
130
|
-
|
|
120
|
+
type() {
|
|
131
121
|
return this.bytes[0];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
}(serialized_type_1.SerializedType));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
135
124
|
/**
|
|
136
125
|
* Class for serializing/deserializing Paths
|
|
137
126
|
*/
|
|
138
|
-
|
|
139
|
-
__extends(Path, _super);
|
|
140
|
-
function Path() {
|
|
141
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
142
|
-
}
|
|
127
|
+
class Path extends serialized_type_1.SerializedType {
|
|
143
128
|
/**
|
|
144
129
|
* construct a Path from an array of Hops
|
|
145
130
|
*
|
|
146
131
|
* @param value Path or array of HopObjects to construct a Path
|
|
147
132
|
* @returns the Path
|
|
148
133
|
*/
|
|
149
|
-
|
|
134
|
+
static from(value) {
|
|
150
135
|
if (value instanceof Path) {
|
|
151
136
|
return value;
|
|
152
137
|
}
|
|
153
|
-
|
|
154
|
-
value.forEach(
|
|
138
|
+
const bytes = [];
|
|
139
|
+
value.forEach((hop) => {
|
|
155
140
|
bytes.push(Hop.from(hop).toBytes());
|
|
156
141
|
});
|
|
157
|
-
return new Path(
|
|
158
|
-
}
|
|
142
|
+
return new Path((0, utils_1.concat)(bytes));
|
|
143
|
+
}
|
|
159
144
|
/**
|
|
160
145
|
* Read a Path from a BinaryParser
|
|
161
146
|
*
|
|
162
147
|
* @param parser BinaryParser to read Path from
|
|
163
148
|
* @returns the Path represented by the bytes read from the BinaryParser
|
|
164
149
|
*/
|
|
165
|
-
|
|
166
|
-
|
|
150
|
+
static fromParser(parser) {
|
|
151
|
+
const bytes = [];
|
|
167
152
|
while (!parser.end()) {
|
|
168
153
|
bytes.push(Hop.fromParser(parser).toBytes());
|
|
169
154
|
if (parser.peek() === PATHSET_END_BYTE ||
|
|
@@ -171,60 +156,55 @@ var Path = /** @class */ (function (_super) {
|
|
|
171
156
|
break;
|
|
172
157
|
}
|
|
173
158
|
}
|
|
174
|
-
return new Path(
|
|
175
|
-
}
|
|
159
|
+
return new Path((0, utils_1.concat)(bytes));
|
|
160
|
+
}
|
|
176
161
|
/**
|
|
177
162
|
* Get the JSON representation of this Path
|
|
178
163
|
*
|
|
179
164
|
* @returns an Array of HopObject constructed from this.bytes
|
|
180
165
|
*/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
166
|
+
toJSON() {
|
|
167
|
+
const json = [];
|
|
168
|
+
const pathParser = new binary_parser_1.BinaryParser(this.toString());
|
|
184
169
|
while (!pathParser.end()) {
|
|
185
170
|
json.push(Hop.fromParser(pathParser).toJSON());
|
|
186
171
|
}
|
|
187
172
|
return json;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
}(serialized_type_1.SerializedType));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
191
175
|
/**
|
|
192
176
|
* Deserialize and Serialize the PathSet type
|
|
193
177
|
*/
|
|
194
|
-
|
|
195
|
-
__extends(PathSet, _super);
|
|
196
|
-
function PathSet() {
|
|
197
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
198
|
-
}
|
|
178
|
+
class PathSet extends serialized_type_1.SerializedType {
|
|
199
179
|
/**
|
|
200
180
|
* Construct a PathSet from an Array of Arrays representing paths
|
|
201
181
|
*
|
|
202
182
|
* @param value A PathSet or Array of Array of HopObjects
|
|
203
183
|
* @returns the PathSet constructed from value
|
|
204
184
|
*/
|
|
205
|
-
|
|
185
|
+
static from(value) {
|
|
206
186
|
if (value instanceof PathSet) {
|
|
207
187
|
return value;
|
|
208
188
|
}
|
|
209
189
|
if (isPathSet(value)) {
|
|
210
|
-
|
|
211
|
-
value.forEach(
|
|
212
|
-
|
|
213
|
-
|
|
190
|
+
const bytes = [];
|
|
191
|
+
value.forEach((path) => {
|
|
192
|
+
bytes.push(Path.from(path).toBytes());
|
|
193
|
+
bytes.push(Uint8Array.from([PATH_SEPARATOR_BYTE]));
|
|
214
194
|
});
|
|
215
|
-
|
|
216
|
-
return new PathSet(
|
|
195
|
+
bytes[bytes.length - 1] = Uint8Array.from([PATHSET_END_BYTE]);
|
|
196
|
+
return new PathSet((0, utils_1.concat)(bytes));
|
|
217
197
|
}
|
|
218
|
-
throw new Error(
|
|
219
|
-
}
|
|
198
|
+
throw new Error('Cannot construct PathSet from given value');
|
|
199
|
+
}
|
|
220
200
|
/**
|
|
221
201
|
* Construct a PathSet from a BinaryParser
|
|
222
202
|
*
|
|
223
203
|
* @param parser A BinaryParser to read PathSet from
|
|
224
204
|
* @returns the PathSet read from parser
|
|
225
205
|
*/
|
|
226
|
-
|
|
227
|
-
|
|
206
|
+
static fromParser(parser) {
|
|
207
|
+
const bytes = [];
|
|
228
208
|
while (!parser.end()) {
|
|
229
209
|
bytes.push(Path.fromParser(parser).toBytes());
|
|
230
210
|
bytes.push(parser.read(1));
|
|
@@ -232,23 +212,22 @@ var PathSet = /** @class */ (function (_super) {
|
|
|
232
212
|
break;
|
|
233
213
|
}
|
|
234
214
|
}
|
|
235
|
-
return new PathSet(
|
|
236
|
-
}
|
|
215
|
+
return new PathSet((0, utils_1.concat)(bytes));
|
|
216
|
+
}
|
|
237
217
|
/**
|
|
238
218
|
* Get the JSON representation of this PathSet
|
|
239
219
|
*
|
|
240
220
|
* @returns an Array of Array of HopObjects, representing this PathSet
|
|
241
221
|
*/
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
222
|
+
toJSON() {
|
|
223
|
+
const json = [];
|
|
224
|
+
const pathParser = new binary_parser_1.BinaryParser(this.toString());
|
|
245
225
|
while (!pathParser.end()) {
|
|
246
226
|
json.push(Path.fromParser(pathParser).toJSON());
|
|
247
227
|
pathParser.skip(1);
|
|
248
228
|
}
|
|
249
229
|
return json;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
}(serialized_type_1.SerializedType));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
253
232
|
exports.PathSet = PathSet;
|
|
254
233
|
//# sourceMappingURL=path-set.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-set.js","sourceRoot":"","sources":["../../src/types/path-set.ts"],"names":[],"mappings":"
|
|
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,mDAA4D;AAE5D;;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,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;QACpE,CAAC,KAAK,CAAC,OAA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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,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { BytesList } from '../serdes/binary-serializer';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
+
import { XrplDefinitionsBase } from '../enums';
|
|
4
|
+
type JSON = string | number | boolean | null | undefined | JSON[] | JsonObject;
|
|
5
|
+
type JsonObject = {
|
|
6
6
|
[key: string]: JSON;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* The base class for all binary-codec types
|
|
10
10
|
*/
|
|
11
11
|
declare class SerializedType {
|
|
12
|
-
protected readonly bytes:
|
|
13
|
-
constructor(bytes
|
|
12
|
+
protected readonly bytes: Uint8Array;
|
|
13
|
+
constructor(bytes?: Uint8Array);
|
|
14
14
|
static fromParser(parser: BinaryParser, hint?: number): SerializedType;
|
|
15
15
|
static from(value: SerializedType | JSON | bigint): SerializedType;
|
|
16
16
|
/**
|
|
@@ -28,35 +28,43 @@ declare class SerializedType {
|
|
|
28
28
|
/**
|
|
29
29
|
* Get the bytes representation of a SerializedType
|
|
30
30
|
*
|
|
31
|
-
* @returns A
|
|
31
|
+
* @returns A Uint8Array of the bytes
|
|
32
32
|
*/
|
|
33
|
-
toBytes():
|
|
33
|
+
toBytes(): Uint8Array;
|
|
34
34
|
/**
|
|
35
35
|
* Return the JSON representation of a SerializedType
|
|
36
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.
|
|
37
40
|
* @returns any type, if not overloaded returns hexString representation of bytes
|
|
38
41
|
*/
|
|
39
|
-
toJSON(): JSON;
|
|
42
|
+
toJSON(_definitions?: XrplDefinitionsBase): JSON;
|
|
40
43
|
/**
|
|
41
44
|
* @returns hexString representation of this.bytes
|
|
42
45
|
*/
|
|
43
46
|
toString(): string;
|
|
44
47
|
}
|
|
45
48
|
/**
|
|
46
|
-
* 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>`
|
|
47
55
|
*/
|
|
48
|
-
declare class Comparable extends SerializedType {
|
|
49
|
-
lt(other:
|
|
50
|
-
eq(other:
|
|
51
|
-
gt(other:
|
|
52
|
-
gte(other:
|
|
53
|
-
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;
|
|
54
62
|
/**
|
|
55
63
|
* Overload this method to define how two Comparable SerializedTypes are compared
|
|
56
64
|
*
|
|
57
65
|
* @param other The comparable object to compare this to
|
|
58
66
|
* @returns A number denoting the relationship of this and other
|
|
59
67
|
*/
|
|
60
|
-
compareTo(other:
|
|
68
|
+
compareTo(other: T): number;
|
|
61
69
|
}
|
|
62
70
|
export { SerializedType, Comparable, JSON, JsonObject };
|
|
@@ -1,115 +1,105 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.Comparable = exports.SerializedType = void 0;
|
|
17
|
-
|
|
4
|
+
const binary_serializer_1 = require("../serdes/binary-serializer");
|
|
5
|
+
const utils_1 = require("@xrplf/isomorphic/utils");
|
|
18
6
|
/**
|
|
19
7
|
* The base class for all binary-codec types
|
|
20
8
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.bytes =
|
|
24
|
-
this.bytes = bytes !== null && bytes !== void 0 ? bytes :
|
|
9
|
+
class SerializedType {
|
|
10
|
+
constructor(bytes) {
|
|
11
|
+
this.bytes = new Uint8Array(0);
|
|
12
|
+
this.bytes = bytes !== null && bytes !== void 0 ? bytes : new Uint8Array(0);
|
|
25
13
|
}
|
|
26
|
-
|
|
27
|
-
throw new Error(
|
|
14
|
+
static fromParser(parser, hint) {
|
|
15
|
+
throw new Error('fromParser not implemented');
|
|
28
16
|
return this.fromParser(parser, hint);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
throw new Error(
|
|
17
|
+
}
|
|
18
|
+
static from(value) {
|
|
19
|
+
throw new Error('from not implemented');
|
|
32
20
|
return this.from(value);
|
|
33
|
-
}
|
|
21
|
+
}
|
|
34
22
|
/**
|
|
35
23
|
* Write the bytes representation of a SerializedType to a BytesList
|
|
36
24
|
*
|
|
37
25
|
* @param list The BytesList to write SerializedType bytes to
|
|
38
26
|
*/
|
|
39
|
-
|
|
27
|
+
toBytesSink(list) {
|
|
40
28
|
list.put(this.bytes);
|
|
41
|
-
}
|
|
29
|
+
}
|
|
42
30
|
/**
|
|
43
31
|
* Get the hex representation of a SerializedType's bytes
|
|
44
32
|
*
|
|
45
33
|
* @returns hex String of this.bytes
|
|
46
34
|
*/
|
|
47
|
-
|
|
48
|
-
return this.toBytes()
|
|
49
|
-
}
|
|
35
|
+
toHex() {
|
|
36
|
+
return (0, utils_1.bytesToHex)(this.toBytes());
|
|
37
|
+
}
|
|
50
38
|
/**
|
|
51
39
|
* Get the bytes representation of a SerializedType
|
|
52
40
|
*
|
|
53
|
-
* @returns A
|
|
41
|
+
* @returns A Uint8Array of the bytes
|
|
54
42
|
*/
|
|
55
|
-
|
|
43
|
+
toBytes() {
|
|
56
44
|
if (this.bytes) {
|
|
57
45
|
return this.bytes;
|
|
58
46
|
}
|
|
59
|
-
|
|
47
|
+
const bytes = new binary_serializer_1.BytesList();
|
|
60
48
|
this.toBytesSink(bytes);
|
|
61
49
|
return bytes.toBytes();
|
|
62
|
-
}
|
|
50
|
+
}
|
|
63
51
|
/**
|
|
64
52
|
* Return the JSON representation of a SerializedType
|
|
65
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.
|
|
66
57
|
* @returns any type, if not overloaded returns hexString representation of bytes
|
|
67
58
|
*/
|
|
68
|
-
|
|
59
|
+
toJSON(_definitions) {
|
|
69
60
|
return this.toHex();
|
|
70
|
-
}
|
|
61
|
+
}
|
|
71
62
|
/**
|
|
72
63
|
* @returns hexString representation of this.bytes
|
|
73
64
|
*/
|
|
74
|
-
|
|
65
|
+
toString() {
|
|
75
66
|
return this.toHex();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
}());
|
|
67
|
+
}
|
|
68
|
+
}
|
|
79
69
|
exports.SerializedType = SerializedType;
|
|
80
70
|
/**
|
|
81
|
-
* 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>`
|
|
82
77
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
function Comparable() {
|
|
86
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
87
|
-
}
|
|
88
|
-
Comparable.prototype.lt = function (other) {
|
|
78
|
+
class Comparable extends SerializedType {
|
|
79
|
+
lt(other) {
|
|
89
80
|
return this.compareTo(other) < 0;
|
|
90
|
-
}
|
|
91
|
-
|
|
81
|
+
}
|
|
82
|
+
eq(other) {
|
|
92
83
|
return this.compareTo(other) === 0;
|
|
93
|
-
}
|
|
94
|
-
|
|
84
|
+
}
|
|
85
|
+
gt(other) {
|
|
95
86
|
return this.compareTo(other) > 0;
|
|
96
|
-
}
|
|
97
|
-
|
|
87
|
+
}
|
|
88
|
+
gte(other) {
|
|
98
89
|
return this.compareTo(other) > -1;
|
|
99
|
-
}
|
|
100
|
-
|
|
90
|
+
}
|
|
91
|
+
lte(other) {
|
|
101
92
|
return this.compareTo(other) < 1;
|
|
102
|
-
}
|
|
93
|
+
}
|
|
103
94
|
/**
|
|
104
95
|
* Overload this method to define how two Comparable SerializedTypes are compared
|
|
105
96
|
*
|
|
106
97
|
* @param other The comparable object to compare this to
|
|
107
98
|
* @returns A number denoting the relationship of this and other
|
|
108
99
|
*/
|
|
109
|
-
|
|
110
|
-
throw new Error(
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
}(SerializedType));
|
|
100
|
+
compareTo(other) {
|
|
101
|
+
throw new Error(`cannot compare ${this.toString()} and ${other.toString()}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
114
104
|
exports.Comparable = Comparable;
|
|
115
105
|
//# sourceMappingURL=serialized-type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialized-type.js","sourceRoot":"","sources":["../../src/types/serialized-type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serialized-type.js","sourceRoot":"","sources":["../../src/types/serialized-type.ts"],"names":[],"mappings":";;;AAAA,mEAAuD;AAGvD,mDAAoD;AAMpD;;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,MA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C,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,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { XrplDefinitionsBase } from '../enums';
|
|
2
|
+
import { SerializedType, JsonObject } from './serialized-type';
|
|
3
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
4
|
/**
|
|
4
5
|
* Class for serializing and deserializing Arrays of Objects
|
|
5
6
|
*/
|
|
@@ -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 };
|