ripple-binary-codec 1.5.0-beta.3 → 1.5.0-beta.4
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 +21 -6
- package/dist/binary.js +28 -9
- package/dist/binary.js.map +1 -1
- package/dist/coretypes.d.ts +2 -2
- package/dist/coretypes.js +2 -1
- package/dist/coretypes.js.map +1 -1
- package/dist/enums/bytes.d.ts +1 -1
- package/dist/enums/bytes.js +24 -28
- package/dist/enums/bytes.js.map +1 -1
- package/dist/enums/definitions.json +78 -37
- package/dist/enums/field.d.ts +0 -1
- package/dist/enums/field.js +16 -22
- package/dist/enums/field.js.map +1 -1
- package/dist/enums/index.d.ts +12 -48
- package/dist/enums/index.js +18 -109
- package/dist/enums/index.js.map +1 -1
- package/dist/enums/src/enums/definitions.json +78 -37
- 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 +7 -30
- package/dist/enums/xrpl-definitions.js +12 -52
- package/dist/enums/xrpl-definitions.js.map +1 -1
- package/dist/index.d.ts +14 -6
- package/dist/index.js +24 -9
- package/dist/index.js.map +1 -1
- package/dist/ledger-hashes.d.ts +4 -1
- package/dist/ledger-hashes.js +4 -2
- package/dist/ledger-hashes.js.map +1 -1
- package/dist/serdes/binary-parser.d.ts +6 -3
- package/dist/serdes/binary-parser.js +5 -2
- package/dist/serdes/binary-parser.js.map +1 -1
- package/dist/serdes/binary-serializer.d.ts +1 -1
- package/dist/shamap.js +3 -1
- package/dist/shamap.js.map +1 -1
- package/dist/types/index.d.ts +3 -22
- package/dist/types/index.js +21 -8
- package/dist/types/index.js.map +1 -1
- package/dist/types/st-object.d.ts +6 -3
- package/dist/types/st-object.js +7 -5
- package/dist/types/st-object.js.map +1 -1
- package/package.json +6 -5
- package/test/definitions.test.js +100 -0
- package/test/fixtures/codec-fixtures.json +78 -78
- package/test/signing-data-encoding.test.js +103 -1
- package/dist/serdes/bytes-list.d.ts +0 -29
- package/dist/serdes/bytes-list.js +0 -48
- package/dist/serdes/bytes-list.js.map +0 -1
- package/dist/types/issued-currency.d.ts +0 -46
- package/dist/types/issued-currency.js +0 -108
- package/dist/types/issued-currency.js.map +0 -1
- package/dist/types/xchain-attestation-batch.d.ts +0 -44
- package/dist/types/xchain-attestation-batch.js +0 -90
- package/dist/types/xchain-attestation-batch.js.map +0 -1
|
@@ -1,25 +1,11 @@
|
|
|
1
|
+
import { type DefinitionsData, XrplDefinitionsBase } from './xrpl-definitions-base';
|
|
1
2
|
import { SerializedType } from '../types/serialized-type';
|
|
2
|
-
import { Bytes, BytesLookup } from './bytes';
|
|
3
|
-
import { FieldInfo, FieldLookup, FieldInstance } from './field';
|
|
4
|
-
interface DefinitionsData {
|
|
5
|
-
TYPES: Record<string, number>;
|
|
6
|
-
LEDGER_ENTRY_TYPES: Record<string, number>;
|
|
7
|
-
FIELDS: (string | FieldInfo)[][];
|
|
8
|
-
TRANSACTION_RESULTS: Record<string, number>;
|
|
9
|
-
TRANSACTION_TYPES: Record<string, number>;
|
|
10
|
-
}
|
|
11
3
|
/**
|
|
12
4
|
* Stores the various types and fields for rippled to be used to encode/decode information later on.
|
|
13
|
-
*
|
|
5
|
+
* Should be used instead of XrplDefinitionsBase since this defines default `types` for serializing/deserializing
|
|
6
|
+
* ledger data.
|
|
14
7
|
*/
|
|
15
|
-
declare class XrplDefinitions {
|
|
16
|
-
field: FieldLookup;
|
|
17
|
-
ledgerEntryType: BytesLookup;
|
|
18
|
-
type: BytesLookup;
|
|
19
|
-
transactionResult: BytesLookup;
|
|
20
|
-
transactionType: BytesLookup;
|
|
21
|
-
transactionNames: string[];
|
|
22
|
-
dataTypes: Record<string, typeof SerializedType>;
|
|
8
|
+
export declare class XrplDefinitions extends XrplDefinitionsBase {
|
|
23
9
|
/**
|
|
24
10
|
* Present rippled types in a typed and updatable format.
|
|
25
11
|
* For an example of the input format see `definitions.json`
|
|
@@ -28,17 +14,8 @@ declare class XrplDefinitions {
|
|
|
28
14
|
* See the definitions.test.js file for examples of how to create your own updated definitions.json.
|
|
29
15
|
*
|
|
30
16
|
* @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
|
|
31
|
-
* @param
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
constructor(enums: DefinitionsData, types?: Record<string, typeof SerializedType>);
|
|
35
|
-
/**
|
|
36
|
-
* Associates each Field to a corresponding class that TypeScript can recognize.
|
|
37
|
-
*
|
|
38
|
-
* @param types a list of type objects with the same name as the fields defined.
|
|
39
|
-
* Defaults to xrpl.js's core type definitions.
|
|
17
|
+
* @param additionalTypes - A list of SerializedType objects with the same name as the fields defined.
|
|
18
|
+
* These types will be included in addition to the coreTypes used on mainnet.
|
|
40
19
|
*/
|
|
41
|
-
|
|
42
|
-
getAssociatedTypes(): Record<string, typeof SerializedType>;
|
|
20
|
+
constructor(enums: DefinitionsData, additionalTypes?: Record<string, typeof SerializedType>);
|
|
43
21
|
}
|
|
44
|
-
export { XrplDefinitions, FieldLookup, FieldInfo, FieldInstance, Bytes, BytesLookup, };
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Object.defineProperty(exports, "BytesLookup", { enumerable: true, get: function () { return bytes_1.BytesLookup; } });
|
|
7
|
-
var field_1 = require("./field");
|
|
8
|
-
Object.defineProperty(exports, "FieldLookup", { enumerable: true, get: function () { return field_1.FieldLookup; } });
|
|
9
|
-
var constants_1 = require("./constants");
|
|
10
|
-
var types_1 = require("../types");
|
|
3
|
+
exports.XrplDefinitions = void 0;
|
|
4
|
+
const xrpl_definitions_base_1 = require("./xrpl-definitions-base");
|
|
5
|
+
const types_1 = require("../types");
|
|
11
6
|
/**
|
|
12
7
|
* Stores the various types and fields for rippled to be used to encode/decode information later on.
|
|
13
|
-
*
|
|
8
|
+
* Should be used instead of XrplDefinitionsBase since this defines default `types` for serializing/deserializing
|
|
9
|
+
* ledger data.
|
|
14
10
|
*/
|
|
15
|
-
|
|
11
|
+
class XrplDefinitions extends xrpl_definitions_base_1.XrplDefinitionsBase {
|
|
16
12
|
/**
|
|
17
13
|
* Present rippled types in a typed and updatable format.
|
|
18
14
|
* For an example of the input format see `definitions.json`
|
|
@@ -21,49 +17,13 @@ var XrplDefinitions = /** @class */ (function () {
|
|
|
21
17
|
* See the definitions.test.js file for examples of how to create your own updated definitions.json.
|
|
22
18
|
*
|
|
23
19
|
* @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
|
|
24
|
-
* @param
|
|
25
|
-
*
|
|
20
|
+
* @param additionalTypes - A list of SerializedType objects with the same name as the fields defined.
|
|
21
|
+
* These types will be included in addition to the coreTypes used on mainnet.
|
|
26
22
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.ledgerEntryType = new bytes_1.BytesLookup(enums.LEDGER_ENTRY_TYPES, constants_1.LEDGER_ENTRY_WIDTH);
|
|
31
|
-
this.transactionType = new bytes_1.BytesLookup(enums.TRANSACTION_TYPES, constants_1.TRANSACTION_TYPE_WIDTH);
|
|
32
|
-
this.transactionResult = new bytes_1.BytesLookup(enums.TRANSACTION_RESULTS, constants_1.TRANSACTION_RESULT_WIDTH);
|
|
33
|
-
this.field = new field_1.FieldLookup(enums.FIELDS, enums.TYPES);
|
|
34
|
-
this.transactionNames = Object.entries(enums.TRANSACTION_TYPES)
|
|
35
|
-
.filter(function (_a) {
|
|
36
|
-
var _key = _a[0], value = _a[1];
|
|
37
|
-
return value >= 0;
|
|
38
|
-
})
|
|
39
|
-
.map(function (_a) {
|
|
40
|
-
var key = _a[0], _value = _a[1];
|
|
41
|
-
return key;
|
|
42
|
-
});
|
|
43
|
-
this.dataTypes = {}; // Filled in via associateTypes
|
|
44
|
-
this.associateTypes(types);
|
|
23
|
+
constructor(enums, additionalTypes) {
|
|
24
|
+
const types = Object.assign({}, types_1.coreTypes, additionalTypes);
|
|
25
|
+
super(enums, types);
|
|
45
26
|
}
|
|
46
|
-
|
|
47
|
-
* Associates each Field to a corresponding class that TypeScript can recognize.
|
|
48
|
-
*
|
|
49
|
-
* @param types a list of type objects with the same name as the fields defined.
|
|
50
|
-
* Defaults to xrpl.js's core type definitions.
|
|
51
|
-
*/
|
|
52
|
-
XrplDefinitions.prototype.associateTypes = function (types) {
|
|
53
|
-
var _this = this;
|
|
54
|
-
// Overwrite any existing type definitions with the given types
|
|
55
|
-
this.dataTypes = Object.assign({}, this.dataTypes, types);
|
|
56
|
-
Object.values(this.field).forEach(function (field) {
|
|
57
|
-
field.associatedType = _this.dataTypes[field.type.name];
|
|
58
|
-
});
|
|
59
|
-
this.field['TransactionType'].associatedType = this.transactionType;
|
|
60
|
-
this.field['TransactionResult'].associatedType = this.transactionResult;
|
|
61
|
-
this.field['LedgerEntryType'].associatedType = this.ledgerEntryType;
|
|
62
|
-
};
|
|
63
|
-
XrplDefinitions.prototype.getAssociatedTypes = function () {
|
|
64
|
-
return this.dataTypes;
|
|
65
|
-
};
|
|
66
|
-
return XrplDefinitions;
|
|
67
|
-
}());
|
|
27
|
+
}
|
|
68
28
|
exports.XrplDefinitions = XrplDefinitions;
|
|
69
29
|
//# sourceMappingURL=xrpl-definitions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xrpl-definitions.js","sourceRoot":"","sources":["../../src/enums/xrpl-definitions.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"xrpl-definitions.js","sourceRoot":"","sources":["../../src/enums/xrpl-definitions.ts"],"names":[],"mappings":";;;AAAA,mEAGgC;AAChC,oCAAoC;AAGpC;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,2CAAmB;IACtD;;;;;;;;;;OAUG;IACH,YACE,KAAsB,EACtB,eAAuD;QAEvD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,iBAAS,EAAE,eAAe,CAAC,CAAA;QAC3D,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IACrB,CAAC;CACF;AAnBD,0CAmBC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
import { decodeLedgerData } from './ledger-hashes';
|
|
2
2
|
import { JsonObject } from './types/serialized-type';
|
|
3
|
-
import { TRANSACTION_TYPES } from './enums';
|
|
3
|
+
import { XrplDefinitionsBase, TRANSACTION_TYPES, DEFAULT_DEFINITIONS } from './enums';
|
|
4
|
+
import { XrplDefinitions } from './enums/xrpl-definitions';
|
|
5
|
+
import { coreTypes } from './types';
|
|
4
6
|
/**
|
|
5
7
|
* Decode a transaction
|
|
6
8
|
*
|
|
7
9
|
* @param binary hex-string of the encoded transaction
|
|
10
|
+
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
8
11
|
* @returns the JSON representation of the transaction
|
|
9
12
|
*/
|
|
10
|
-
declare function decode(binary: string): JsonObject;
|
|
13
|
+
declare function decode(binary: string, definitions?: XrplDefinitionsBase): JsonObject;
|
|
11
14
|
/**
|
|
12
15
|
* Encode a transaction
|
|
13
16
|
*
|
|
14
17
|
* @param json The JSON representation of a transaction
|
|
18
|
+
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
19
|
+
*
|
|
15
20
|
* @returns A hex-string of the encoded transaction
|
|
16
21
|
*/
|
|
17
|
-
declare function encode(json: object): string;
|
|
22
|
+
declare function encode(json: object, definitions?: XrplDefinitionsBase): string;
|
|
18
23
|
/**
|
|
19
24
|
* Encode a transaction and prepare for signing
|
|
20
25
|
*
|
|
21
26
|
* @param json JSON object representing the transaction
|
|
22
27
|
* @param signer string representing the account to sign the transaction with
|
|
28
|
+
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
23
29
|
* @returns a hex string of the encoded transaction
|
|
24
30
|
*/
|
|
25
|
-
declare function encodeForSigning(json: object): string;
|
|
31
|
+
declare function encodeForSigning(json: object, definitions?: XrplDefinitionsBase): string;
|
|
26
32
|
/**
|
|
27
33
|
* Encode a transaction and prepare for signing with a claim
|
|
28
34
|
*
|
|
29
35
|
* @param json JSON object representing the transaction
|
|
30
36
|
* @param signer string representing the account to sign the transaction with
|
|
37
|
+
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
31
38
|
* @returns a hex string of the encoded transaction
|
|
32
39
|
*/
|
|
33
40
|
declare function encodeForSigningClaim(json: object): string;
|
|
@@ -36,9 +43,10 @@ declare function encodeForSigningClaim(json: object): string;
|
|
|
36
43
|
*
|
|
37
44
|
* @param json JSON object representing the transaction
|
|
38
45
|
* @param signer string representing the account to sign the transaction with
|
|
46
|
+
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
39
47
|
* @returns a hex string of the encoded transaction
|
|
40
48
|
*/
|
|
41
|
-
declare function encodeForMultisigning(json: object, signer: string): string;
|
|
49
|
+
declare function encodeForMultisigning(json: object, signer: string, definitions?: XrplDefinitionsBase): string;
|
|
42
50
|
/**
|
|
43
51
|
* Encode a quality value
|
|
44
52
|
*
|
|
@@ -53,4 +61,4 @@ declare function encodeQuality(value: string): string;
|
|
|
53
61
|
* @returns a string representing the quality
|
|
54
62
|
*/
|
|
55
63
|
declare function decodeQuality(value: string): string;
|
|
56
|
-
export { decode, encode, encodeForSigning, encodeForSigningClaim, encodeForMultisigning, encodeQuality, decodeQuality, decodeLedgerData, TRANSACTION_TYPES, };
|
|
64
|
+
export { decode, encode, encodeForSigning, encodeForSigningClaim, encodeForMultisigning, encodeQuality, decodeQuality, decodeLedgerData, TRANSACTION_TYPES, XrplDefinitions, XrplDefinitionsBase, DEFAULT_DEFINITIONS, coreTypes, };
|
package/dist/index.js
CHANGED
|
@@ -23,34 +23,43 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.TRANSACTION_TYPES = exports.decodeLedgerData = exports.decodeQuality = exports.encodeQuality = exports.encodeForMultisigning = exports.encodeForSigningClaim = exports.encodeForSigning = exports.encode = exports.decode = void 0;
|
|
26
|
+
exports.coreTypes = exports.DEFAULT_DEFINITIONS = exports.XrplDefinitionsBase = exports.XrplDefinitions = exports.TRANSACTION_TYPES = exports.decodeLedgerData = exports.decodeQuality = exports.encodeQuality = exports.encodeForMultisigning = exports.encodeForSigningClaim = exports.encodeForSigning = exports.encode = exports.decode = void 0;
|
|
27
27
|
const assert = __importStar(require("assert"));
|
|
28
28
|
const coretypes_1 = require("./coretypes");
|
|
29
29
|
const ledger_hashes_1 = require("./ledger-hashes");
|
|
30
30
|
Object.defineProperty(exports, "decodeLedgerData", { enumerable: true, get: function () { return ledger_hashes_1.decodeLedgerData; } });
|
|
31
31
|
const enums_1 = require("./enums");
|
|
32
|
+
Object.defineProperty(exports, "XrplDefinitionsBase", { enumerable: true, get: function () { return enums_1.XrplDefinitionsBase; } });
|
|
32
33
|
Object.defineProperty(exports, "TRANSACTION_TYPES", { enumerable: true, get: function () { return enums_1.TRANSACTION_TYPES; } });
|
|
34
|
+
Object.defineProperty(exports, "DEFAULT_DEFINITIONS", { enumerable: true, get: function () { return enums_1.DEFAULT_DEFINITIONS; } });
|
|
35
|
+
const xrpl_definitions_1 = require("./enums/xrpl-definitions");
|
|
36
|
+
Object.defineProperty(exports, "XrplDefinitions", { enumerable: true, get: function () { return xrpl_definitions_1.XrplDefinitions; } });
|
|
37
|
+
const types_1 = require("./types");
|
|
38
|
+
Object.defineProperty(exports, "coreTypes", { enumerable: true, get: function () { return types_1.coreTypes; } });
|
|
33
39
|
const { signingData, signingClaimData, multiSigningData, binaryToJSON, serializeObject, } = coretypes_1.binary;
|
|
34
40
|
/**
|
|
35
41
|
* Decode a transaction
|
|
36
42
|
*
|
|
37
43
|
* @param binary hex-string of the encoded transaction
|
|
44
|
+
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
38
45
|
* @returns the JSON representation of the transaction
|
|
39
46
|
*/
|
|
40
|
-
function decode(binary) {
|
|
47
|
+
function decode(binary, definitions) {
|
|
41
48
|
assert.ok(typeof binary === 'string', 'binary must be a hex string');
|
|
42
|
-
return binaryToJSON(binary);
|
|
49
|
+
return binaryToJSON(binary, definitions);
|
|
43
50
|
}
|
|
44
51
|
exports.decode = decode;
|
|
45
52
|
/**
|
|
46
53
|
* Encode a transaction
|
|
47
54
|
*
|
|
48
55
|
* @param json The JSON representation of a transaction
|
|
56
|
+
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
57
|
+
*
|
|
49
58
|
* @returns A hex-string of the encoded transaction
|
|
50
59
|
*/
|
|
51
|
-
function encode(json) {
|
|
60
|
+
function encode(json, definitions) {
|
|
52
61
|
assert.ok(typeof json === 'object');
|
|
53
|
-
return serializeObject(json)
|
|
62
|
+
return serializeObject(json, { definitions })
|
|
54
63
|
.toString('hex')
|
|
55
64
|
.toUpperCase();
|
|
56
65
|
}
|
|
@@ -60,11 +69,14 @@ exports.encode = encode;
|
|
|
60
69
|
*
|
|
61
70
|
* @param json JSON object representing the transaction
|
|
62
71
|
* @param signer string representing the account to sign the transaction with
|
|
72
|
+
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
63
73
|
* @returns a hex string of the encoded transaction
|
|
64
74
|
*/
|
|
65
|
-
function encodeForSigning(json) {
|
|
75
|
+
function encodeForSigning(json, definitions) {
|
|
66
76
|
assert.ok(typeof json === 'object');
|
|
67
|
-
return signingData(json
|
|
77
|
+
return signingData(json, coretypes_1.HashPrefix.transactionSig, {
|
|
78
|
+
definitions,
|
|
79
|
+
})
|
|
68
80
|
.toString('hex')
|
|
69
81
|
.toUpperCase();
|
|
70
82
|
}
|
|
@@ -74,6 +86,7 @@ exports.encodeForSigning = encodeForSigning;
|
|
|
74
86
|
*
|
|
75
87
|
* @param json JSON object representing the transaction
|
|
76
88
|
* @param signer string representing the account to sign the transaction with
|
|
89
|
+
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
77
90
|
* @returns a hex string of the encoded transaction
|
|
78
91
|
*/
|
|
79
92
|
function encodeForSigningClaim(json) {
|
|
@@ -88,12 +101,14 @@ exports.encodeForSigningClaim = encodeForSigningClaim;
|
|
|
88
101
|
*
|
|
89
102
|
* @param json JSON object representing the transaction
|
|
90
103
|
* @param signer string representing the account to sign the transaction with
|
|
104
|
+
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
91
105
|
* @returns a hex string of the encoded transaction
|
|
92
106
|
*/
|
|
93
|
-
function encodeForMultisigning(json, signer) {
|
|
107
|
+
function encodeForMultisigning(json, signer, definitions) {
|
|
94
108
|
assert.ok(typeof json === 'object');
|
|
95
109
|
assert.equal(json['SigningPubKey'], '');
|
|
96
|
-
|
|
110
|
+
const definitionsOpt = definitions ? { definitions } : undefined;
|
|
111
|
+
return multiSigningData(json, signer, definitionsOpt)
|
|
97
112
|
.toString('hex')
|
|
98
113
|
.toUpperCase();
|
|
99
114
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgC;AAChC,2CAAyD;AACzD,mDAAkD;AAoIhD,iGApIO,gCAAgB,OAoIP;AAjIlB,mCAIgB;AAgId,oGAnIA,2BAAmB,OAmIA;AAFnB,kGAhIA,yBAAiB,OAgIA;AAGjB,oGAlIA,2BAAmB,OAkIA;AAhIrB,+DAA0D;AA8HxD,gGA9HO,kCAAe,OA8HP;A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AC5B,IAAY,EACZ,MAAc,EACd,WAAiC;IAEjC,MAAM,CAAC,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAA;IACnC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,CAAA;IACvC,MAAM,cAAc,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;IAChE,OAAO,gBAAgB,CAAC,IAAkB,EAAE,MAAM,EAAE,cAAc,CAAC;SAChE,QAAQ,CAAC,KAAK,CAAC;SACf,WAAW,EAAE,CAAA;AAClB,CAAC;AA6BC,sDAAqB;AA3BvB;;;;;GAKG;AACH,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,CAAC,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAA;IACpC,OAAO,mBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;AAC5D,CAAC;AAmBC,sCAAa;AAjBf;;;;;GAKG;AACH,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,CAAC,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAA;IACpC,OAAO,mBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAA;AACzC,CAAC;AASC,sCAAa"}
|
package/dist/ledger-hashes.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Hash256 } from './types/hash-256';
|
|
2
2
|
import { JsonObject } from './types/serialized-type';
|
|
3
3
|
import bigInt = require('big-integer');
|
|
4
|
+
import { XrplDefinitionsBase } from './enums';
|
|
4
5
|
/**
|
|
5
6
|
* Function computing the hash of a transaction tree
|
|
6
7
|
*
|
|
@@ -40,7 +41,9 @@ declare function ledgerHash(header: ledgerObject): Hash256;
|
|
|
40
41
|
* Decodes a serialized ledger header
|
|
41
42
|
*
|
|
42
43
|
* @param binary A serialized ledger header
|
|
44
|
+
* @param definitions Type definitions to parse the ledger objects.
|
|
45
|
+
* Used if there are non-default ledger objects to decode.
|
|
43
46
|
* @returns A JSON object describing a ledger header
|
|
44
47
|
*/
|
|
45
|
-
declare function decodeLedgerData(binary: string): object;
|
|
48
|
+
declare function decodeLedgerData(binary: string, definitions?: XrplDefinitionsBase): object;
|
|
46
49
|
export { accountStateHash, transactionTreeHash, ledgerHash, decodeLedgerData };
|
package/dist/ledger-hashes.js
CHANGED
|
@@ -137,11 +137,13 @@ exports.ledgerHash = ledgerHash;
|
|
|
137
137
|
* Decodes a serialized ledger header
|
|
138
138
|
*
|
|
139
139
|
* @param binary A serialized ledger header
|
|
140
|
+
* @param definitions Type definitions to parse the ledger objects.
|
|
141
|
+
* Used if there are non-default ledger objects to decode.
|
|
140
142
|
* @returns A JSON object describing a ledger header
|
|
141
143
|
*/
|
|
142
|
-
function decodeLedgerData(binary) {
|
|
144
|
+
function decodeLedgerData(binary, definitions) {
|
|
143
145
|
assert.ok(typeof binary === 'string', 'binary must be a hex string');
|
|
144
|
-
const parser = new binary_parser_1.BinaryParser(binary);
|
|
146
|
+
const parser = new binary_parser_1.BinaryParser(binary, definitions);
|
|
145
147
|
return {
|
|
146
148
|
ledger_index: parser.readUInt32(),
|
|
147
149
|
total_coins: parser.readType(uint_64_1.UInt64).valueOf().toString(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger-hashes.js","sourceRoot":"","sources":["../src/ledger-hashes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgC;AAChC,qCAAyD;AACzD,mDAA4C;AAC5C,qCAAqC;AACrC,qCAA4D;AAC5D,+CAA0C;AAC1C,iDAA4C;AAC5C,6CAAwC;AACxC,6CAAwC;AACxC,2CAAsC;AACtC,0DAAqD;AAErD,sCAAsC;
|
|
1
|
+
{"version":3,"file":"ledger-hashes.js","sourceRoot":"","sources":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BAAO,CAAC,CAAC,KAAK,EAAE;QAClD,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,kBAAO,CAAC,CAAC,KAAK,EAAE;QAC9C,iBAAiB,EAAE,MAAM,CAAC,UAAU,EAAE;QACtC,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;QAC/B,qBAAqB,EAAE,MAAM,CAAC,SAAS,EAAE;QACzC,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE;KAChC,CAAA;AACH,CAAC;AAE2D,4CAAgB"}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { FieldInstance } from '../enums';
|
|
2
|
-
import { SerializedType } from '../types/serialized-type';
|
|
1
|
+
import { XrplDefinitionsBase, FieldInstance } from '../enums';
|
|
2
|
+
import { type SerializedType } from '../types/serialized-type';
|
|
3
3
|
import { Buffer } from 'buffer/';
|
|
4
4
|
/**
|
|
5
5
|
* BinaryParser is used to compute fields and values from a HexString
|
|
6
6
|
*/
|
|
7
7
|
declare class BinaryParser {
|
|
8
8
|
private bytes;
|
|
9
|
+
definitions: XrplDefinitionsBase;
|
|
9
10
|
/**
|
|
10
11
|
* Initialize bytes to a hex string
|
|
11
12
|
*
|
|
12
13
|
* @param hexBytes a hex string
|
|
14
|
+
* @param definitions Rippled definitions used to parse the values of transaction types and such.
|
|
15
|
+
* Can be customized for sidechains and amendments.
|
|
13
16
|
*/
|
|
14
|
-
constructor(hexBytes: string);
|
|
17
|
+
constructor(hexBytes: string, definitions?: XrplDefinitionsBase);
|
|
15
18
|
/**
|
|
16
19
|
* Peek the first byte of the BinaryParser
|
|
17
20
|
*
|
|
@@ -35,9 +35,12 @@ class BinaryParser {
|
|
|
35
35
|
* Initialize bytes to a hex string
|
|
36
36
|
*
|
|
37
37
|
* @param hexBytes a hex string
|
|
38
|
+
* @param definitions Rippled definitions used to parse the values of transaction types and such.
|
|
39
|
+
* Can be customized for sidechains and amendments.
|
|
38
40
|
*/
|
|
39
|
-
constructor(hexBytes) {
|
|
41
|
+
constructor(hexBytes, definitions = enums_1.DEFAULT_DEFINITIONS) {
|
|
40
42
|
this.bytes = buffer_1.Buffer.from(hexBytes, 'hex');
|
|
43
|
+
this.definitions = definitions;
|
|
41
44
|
}
|
|
42
45
|
/**
|
|
43
46
|
* Peek the first byte of the BinaryParser
|
|
@@ -153,7 +156,7 @@ class BinaryParser {
|
|
|
153
156
|
* @return The field represented by the bytes at the head of the BinaryParser
|
|
154
157
|
*/
|
|
155
158
|
readField() {
|
|
156
|
-
return
|
|
159
|
+
return this.definitions.field.fromString(this.readFieldOrdinal().toString());
|
|
157
160
|
}
|
|
158
161
|
/**
|
|
159
162
|
* Read a given type from the BinaryParser
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binary-parser.js","sourceRoot":"","sources":["../../src/serdes/binary-parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"binary-parser.js","sourceRoot":"","sources":["../../src/serdes/binary-parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgC;AAChC,oCAIiB;AAEjB,oCAAgC;AAEhC;;GAEG;AACH,MAAM,YAAY;IAIhB;;;;;;OAMG;IACH,YACE,QAAgB,EAChB,cAAmC,2BAAmB;QAEtD,IAAI,CAAC,KAAK,GAAG,eAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QACzC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAED;;;;OAIG;IACH,IAAI;QACF,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,CAAC,CAAC,CAAA;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACtB,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,CAAS;QACZ,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,K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AAC,SAAS,EAAE,CAAA;QAC9B,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5C,CAAC;CACF;AAEQ,oCAAY"}
|
package/dist/shamap.js
CHANGED
|
@@ -130,7 +130,9 @@ class ShaMapInner extends ShaMapNode {
|
|
|
130
130
|
toBytesSink(list) {
|
|
131
131
|
for (let i = 0; i < this.branches.length; i++) {
|
|
132
132
|
const branch = this.branches[i];
|
|
133
|
-
const hash = branch
|
|
133
|
+
const hash = branch
|
|
134
|
+
? branch.hash()
|
|
135
|
+
: types_1.coreTypes.Hash256.ZERO_256;
|
|
134
136
|
hash.toBytesSink(list);
|
|
135
137
|
}
|
|
136
138
|
}
|
package/dist/shamap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shamap.js","sourceRoot":"","sources":["../src/shamap.ts"],"names":[],"mappings":";;;AAAA,mCAAyC;AACzC,mCAAmC;AACnC,mDAA4C;AAC5C,qCAAqC;AAGrC,oCAAgC;AAEhC;;GAEG;AACH,MAAe,UAAU;CAMxB;
|
|
1
|
+
{"version":3,"file":"shamap.js","sourceRoot":"","sources":["../src/shamap.ts"],"names":[],"mappings":";;;AAAA,mCAAyC;AACzC,mCAAmC;AACnC,mDAA4C;AAC5C,qCAAqC;AAGrC,oCAAgC;AAEhC;;GAEG;AACH,MAAe,UAAU;CAMxB;AAwKgB,gCAAU;AAtK3B;;GAEG;AACH,MAAM,UAAW,SAAQ,UAAU;IACjC,YAAmB,KAAc,EAAS,IAAiB;QACzD,KAAK,EAAE,CAAA;QADU,UAAK,GAAL,KAAK,CAAS;QAAS,SAAI,GAAJ,IAAI,CAAa;IAE3D,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;OAEG;IACH,OAAO;QACL,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;OAIG;IACH,UAAU;QACR,OAAO,IAAI,CAA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U,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;aAC5D;iBAAM,IAAI,QAAQ,YAAY,UAAU,EAAE;gBACzC,MAAM,QAAQ,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;gBAChD,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;gBACrD,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;gBACnC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;aACjC;iBAAM,IAAI,QAAQ,YAAY,WAAW,EAAE;gBAC1C,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;aACpC;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;aAC/C;SACF;IACH,CAAC;CACF;AAED,MAAM,MAAO,SAAQ,WAAW;CAAG;AAE1B,wBAAM"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { Currency } from './currency';
|
|
|
5
5
|
import { Hash128 } from './hash-128';
|
|
6
6
|
import { Hash160 } from './hash-160';
|
|
7
7
|
import { Hash256 } from './hash-256';
|
|
8
|
-
import { Issue } from './issue';
|
|
9
8
|
import { PathSet } from './path-set';
|
|
10
9
|
import { STArray } from './st-array';
|
|
11
10
|
import { STObject } from './st-object';
|
|
@@ -14,24 +13,6 @@ import { UInt32 } from './uint-32';
|
|
|
14
13
|
import { UInt64 } from './uint-64';
|
|
15
14
|
import { UInt8 } from './uint-8';
|
|
16
15
|
import { Vector256 } from './vector-256';
|
|
17
|
-
import {
|
|
18
|
-
declare const coreTypes:
|
|
19
|
-
|
|
20
|
-
Amount: typeof Amount;
|
|
21
|
-
Blob: typeof Blob;
|
|
22
|
-
Currency: typeof Currency;
|
|
23
|
-
Hash128: typeof Hash128;
|
|
24
|
-
Hash160: typeof Hash160;
|
|
25
|
-
Hash256: typeof Hash256;
|
|
26
|
-
Issue: typeof Issue;
|
|
27
|
-
PathSet: typeof PathSet;
|
|
28
|
-
STArray: typeof STArray;
|
|
29
|
-
STObject: typeof STObject;
|
|
30
|
-
UInt8: typeof UInt8;
|
|
31
|
-
UInt16: typeof UInt16;
|
|
32
|
-
UInt32: typeof UInt32;
|
|
33
|
-
UInt64: typeof UInt64;
|
|
34
|
-
Vector256: typeof Vector256;
|
|
35
|
-
XChainBridge: typeof XChainBridge;
|
|
36
|
-
};
|
|
37
|
-
export { coreTypes };
|
|
16
|
+
import { type SerializedType } from './serialized-type';
|
|
17
|
+
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, };
|
package/dist/types/index.js
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.coreTypes = void 0;
|
|
4
|
-
const enums_1 = require("../enums");
|
|
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;
|
|
5
4
|
const account_id_1 = require("./account-id");
|
|
5
|
+
Object.defineProperty(exports, "AccountID", { enumerable: true, get: function () { return account_id_1.AccountID; } });
|
|
6
6
|
const amount_1 = require("./amount");
|
|
7
|
+
Object.defineProperty(exports, "Amount", { enumerable: true, get: function () { return amount_1.Amount; } });
|
|
7
8
|
const blob_1 = require("./blob");
|
|
9
|
+
Object.defineProperty(exports, "Blob", { enumerable: true, get: function () { return blob_1.Blob; } });
|
|
8
10
|
const currency_1 = require("./currency");
|
|
11
|
+
Object.defineProperty(exports, "Currency", { enumerable: true, get: function () { return currency_1.Currency; } });
|
|
9
12
|
const hash_128_1 = require("./hash-128");
|
|
13
|
+
Object.defineProperty(exports, "Hash128", { enumerable: true, get: function () { return hash_128_1.Hash128; } });
|
|
10
14
|
const hash_160_1 = require("./hash-160");
|
|
15
|
+
Object.defineProperty(exports, "Hash160", { enumerable: true, get: function () { return hash_160_1.Hash160; } });
|
|
11
16
|
const hash_256_1 = require("./hash-256");
|
|
17
|
+
Object.defineProperty(exports, "Hash256", { enumerable: true, get: function () { return hash_256_1.Hash256; } });
|
|
12
18
|
const issue_1 = require("./issue");
|
|
13
19
|
const path_set_1 = require("./path-set");
|
|
20
|
+
Object.defineProperty(exports, "PathSet", { enumerable: true, get: function () { return path_set_1.PathSet; } });
|
|
14
21
|
const st_array_1 = require("./st-array");
|
|
22
|
+
Object.defineProperty(exports, "STArray", { enumerable: true, get: function () { return st_array_1.STArray; } });
|
|
15
23
|
const st_object_1 = require("./st-object");
|
|
24
|
+
Object.defineProperty(exports, "STObject", { enumerable: true, get: function () { return st_object_1.STObject; } });
|
|
16
25
|
const uint_16_1 = require("./uint-16");
|
|
26
|
+
Object.defineProperty(exports, "UInt16", { enumerable: true, get: function () { return uint_16_1.UInt16; } });
|
|
17
27
|
const uint_32_1 = require("./uint-32");
|
|
28
|
+
Object.defineProperty(exports, "UInt32", { enumerable: true, get: function () { return uint_32_1.UInt32; } });
|
|
18
29
|
const uint_64_1 = require("./uint-64");
|
|
30
|
+
Object.defineProperty(exports, "UInt64", { enumerable: true, get: function () { return uint_64_1.UInt64; } });
|
|
19
31
|
const uint_8_1 = require("./uint-8");
|
|
32
|
+
Object.defineProperty(exports, "UInt8", { enumerable: true, get: function () { return uint_8_1.UInt8; } });
|
|
20
33
|
const vector_256_1 = require("./vector-256");
|
|
34
|
+
Object.defineProperty(exports, "Vector256", { enumerable: true, get: function () { return vector_256_1.Vector256; } });
|
|
21
35
|
const xchain_bridge_1 = require("./xchain-bridge");
|
|
36
|
+
const enums_1 = require("../enums");
|
|
22
37
|
const coreTypes = {
|
|
23
38
|
AccountID: account_id_1.AccountID,
|
|
24
39
|
Amount: amount_1.Amount,
|
|
@@ -39,10 +54,8 @@ const coreTypes = {
|
|
|
39
54
|
XChainBridge: xchain_bridge_1.XChainBridge,
|
|
40
55
|
};
|
|
41
56
|
exports.coreTypes = coreTypes;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
enums_1.
|
|
46
|
-
enums_1.Field['TransactionResult'].associatedType = enums_1.TransactionResult;
|
|
47
|
-
enums_1.Field['LedgerEntryType'].associatedType = enums_1.LedgerEntryType;
|
|
57
|
+
// Ensures that the DEFAULT_DEFINITIONS object connects these types to fields for serializing/deserializing
|
|
58
|
+
// This is done here instead of in enums/index.ts to avoid a circular dependency
|
|
59
|
+
// because some of the above types depend on BinarySerializer which depends on enums/index.ts.
|
|
60
|
+
enums_1.DEFAULT_DEFINITIONS.associateTypes(coreTypes);
|
|
48
61
|
//# 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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AA+CtC,0FA/CO,sBAAS,OA+CP;AA9CX,qCAAiC;AA+C/B,uFA/CO,eAAM,OA+CP;AA9CR,iCAA6B;AA+C3B,qFA/CO,WAAI,OA+CP;AA9CN,yCAAqC;AA+CnC,yFA/CO,mBAAQ,OA+CP;AA9CV,yCAAoC;AA+ClC,wFA/CO,kBAAO,OA+CP;AA9CT,yCAAoC;AA+ClC,wFA/CO,kBAAO,OA+CP;AA9CT,yCAAoC;AA+ClC,wFA/CO,kBAAO,OA+CP;AA9CT,mCAA+B;AAC/B,yCAAoC;AA8ClC,wFA9CO,kBAAO,OA8CP;AA7CT,yCAAoC;AA8ClC,wFA9CO,kBAAO,OA8CP;AA7CT,2CAAsC;AA8CpC,yFA9CO,oBAAQ,OA8CP;AA7CV,uCAAkC;AA+ChC,uFA/CO,gBAAM,OA+CP;AA9CR,uCAAkC;AA+ChC,uFA/CO,gBAAM,OA+CP;AA9CR,uCAAkC;AA+ChC,uFA/CO,gBAAM,OA+CP;AA9CR,qCAAgC;AA2C9B,sFA3CO,cAAK,OA2CP;AA1CP,6CAAwC;AA8CtC,0FA9CO,sBAAS,OA8CP;AA7CX,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,KAAK,EAAL,aAAK;IACL,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"}
|
|
@@ -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
|
/**
|
|
@@ -16,14 +17,16 @@ declare class STObject extends SerializedType {
|
|
|
16
17
|
*
|
|
17
18
|
* @param value An object to include
|
|
18
19
|
* @param filter optional, denote which field to include in serialized object
|
|
20
|
+
* @param definitions optional, types and values to use to encode/decode a transaction
|
|
19
21
|
* @returns a STObject object
|
|
20
22
|
*/
|
|
21
|
-
static from<T extends STObject | JsonObject>(value: T, filter?: (...any: any[]) => boolean): STObject;
|
|
23
|
+
static from<T extends STObject | JsonObject>(value: T, filter?: (...any: any[]) => boolean, definitions?: XrplDefinitionsBase): STObject;
|
|
22
24
|
/**
|
|
23
25
|
* Get the JSON interpretation of this.bytes
|
|
24
|
-
*
|
|
26
|
+
* @param definitions rippled definitions used to parse the values of transaction types and such.
|
|
27
|
+
* Can be customized for sidechains and amendments.
|
|
25
28
|
* @returns a JSON object
|
|
26
29
|
*/
|
|
27
|
-
toJSON(): JsonObject;
|
|
30
|
+
toJSON(definitions?: XrplDefinitionsBase): JsonObject;
|
|
28
31
|
}
|
|
29
32
|
export { STObject };
|