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