ripple-binary-codec 1.6.0-beta.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/binary.d.ts +21 -6
- package/dist/binary.js +47 -32
- package/dist/binary.js.map +1 -1
- package/dist/coretypes.d.ts +2 -2
- package/dist/coretypes.js +33 -9
- package/dist/coretypes.js.map +1 -1
- package/dist/enums/bytes.d.ts +26 -0
- package/dist/enums/bytes.js +64 -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 +14 -572
- package/dist/enums/field.d.ts +29 -0
- package/dist/enums/field.js +59 -0
- package/dist/enums/field.js.map +1 -0
- package/dist/enums/index.d.ts +12 -48
- package/dist/enums/index.js +42 -124
- package/dist/enums/index.js.map +1 -1
- package/dist/enums/src/enums/definitions.json +14 -572
- package/dist/enums/utils-renumber.js +14 -14
- 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.js +3 -3
- package/dist/hash-prefixes.js.map +1 -1
- package/dist/hashes.js +21 -43
- package/dist/hashes.js.map +1 -1
- package/dist/index.d.ts +14 -16
- package/dist/index.js +62 -24
- package/dist/index.js.map +1 -1
- package/dist/ledger-hashes.d.ts +5 -2
- package/dist/ledger-hashes.js +54 -29
- package/dist/ledger-hashes.js.map +1 -1
- package/dist/quality.js +18 -21
- package/dist/quality.js.map +1 -1
- package/dist/serdes/binary-parser.d.ts +6 -3
- package/dist/serdes/binary-parser.js +82 -57
- package/dist/serdes/binary-parser.js.map +1 -1
- package/dist/serdes/binary-serializer.d.ts +1 -1
- package/dist/serdes/binary-serializer.js +59 -40
- package/dist/serdes/binary-serializer.js.map +1 -1
- package/dist/shamap.js +72 -98
- package/dist/shamap.js.map +1 -1
- package/dist/types/account-id.js +18 -35
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.js +71 -88
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.js +10 -27
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.js +26 -44
- package/dist/types/currency.js.map +1 -1
- package/dist/types/hash-128.d.ts +6 -0
- package/dist/types/hash-128.js +23 -25
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.js +8 -25
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-256.js +8 -25
- package/dist/types/hash-256.js.map +1 -1
- package/dist/types/hash.js +20 -38
- package/dist/types/hash.js.map +1 -1
- package/dist/types/index.d.ts +3 -24
- package/dist/types/index.js +37 -30
- package/dist/types/index.js.map +1 -1
- package/dist/types/path-set.js +57 -87
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +3 -3
- package/dist/types/serialized-type.js +35 -56
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.js +26 -46
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-object.d.ts +6 -3
- package/dist/types/st-object.js +52 -74
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.js +15 -32
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.js +16 -33
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +1 -1
- package/dist/types/uint-64.js +30 -47
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.js +15 -32
- package/dist/types/uint-8.js.map +1 -1
- package/dist/types/uint.d.ts +1 -1
- package/dist/types/uint.js +10 -27
- package/dist/types/uint.js.map +1 -1
- package/dist/types/vector-256.js +23 -40
- package/dist/types/vector-256.js.map +1 -1
- package/package.json +7 -7
- package/test/amount.test.js +1 -1
- package/test/binary-json.test.js +1 -1
- package/test/binary-parser.test.js +4 -4
- package/test/binary-serializer.test.js +3 -3
- package/test/definitions.test.js +100 -0
- package/test/fixtures/codec-fixtures.json +14 -468
- package/test/hash.test.js +28 -2
- package/test/ledger.test.js +1 -1
- package/test/lower-case-hex.test.js +1 -1
- package/test/pseudo-transaction.test.js +1 -1
- package/test/quality.test.js +1 -1
- package/test/shamap.test.js +3 -3
- package/test/signing-data-encoding.test.js +104 -2
- package/test/tx-encode-decode.test.js +1 -1
- package/test/types.test.js +2 -2
- package/test/uint.test.js +2 -2
- package/test/x-address.test.js +1 -1
- package/dist/types/issue.d.ts +0 -39
- package/dist/types/issue.js +0 -98
- package/dist/types/issue.js.map +0 -1
- package/dist/types/xchain-attestation-batch.d.ts +0 -44
- package/dist/types/xchain-attestation-batch.js +0 -107
- package/dist/types/xchain-attestation-batch.js.map +0 -1
- package/dist/types/xchain-bridge.d.ts +0 -45
- package/dist/types/xchain-bridge.js +0 -119
- package/dist/types/xchain-bridge.js.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Quick script to re-number values
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
const input = {
|
|
6
6
|
temBAD_SEND_XRP_PATHS: -283,
|
|
7
7
|
temBAD_SEQUENCE: -282,
|
|
8
8
|
temBAD_SIGNATURE: -281,
|
|
@@ -93,35 +93,35 @@ var input = {
|
|
|
93
93
|
tecHAS_OBLIGATIONS: 151,
|
|
94
94
|
tecTOO_SOON: 152,
|
|
95
95
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
Object.keys(input).forEach(
|
|
96
|
+
let startingFromTemBADSENDXRPPATHS = -284;
|
|
97
|
+
let startingFromTefFAILURE = -199;
|
|
98
|
+
let startingFromTerRETRY = -99;
|
|
99
|
+
const tesSUCCESS = 0;
|
|
100
|
+
let startingFromTecCLAIM = 100;
|
|
101
|
+
const startingFromTecDIRFULL = 121;
|
|
102
|
+
let previousKey = 'tem';
|
|
103
|
+
Object.keys(input).forEach((key) => {
|
|
104
104
|
if (key.substring(0, 3) !== previousKey.substring(0, 3)) {
|
|
105
105
|
console.log();
|
|
106
106
|
previousKey = key;
|
|
107
107
|
}
|
|
108
108
|
if (key.substring(0, 3) === 'tem') {
|
|
109
|
-
console.log(
|
|
109
|
+
console.log(` "${key}": ${startingFromTemBADSENDXRPPATHS++},`);
|
|
110
110
|
}
|
|
111
111
|
else if (key.substring(0, 3) === 'tef') {
|
|
112
|
-
console.log(
|
|
112
|
+
console.log(` "${key}": ${startingFromTefFAILURE++},`);
|
|
113
113
|
}
|
|
114
114
|
else if (key.substring(0, 3) === 'ter') {
|
|
115
|
-
console.log(
|
|
115
|
+
console.log(` "${key}": ${startingFromTerRETRY++},`);
|
|
116
116
|
}
|
|
117
117
|
else if (key.substring(0, 3) === 'tes') {
|
|
118
|
-
console.log(
|
|
118
|
+
console.log(` "${key}": ${tesSUCCESS},`);
|
|
119
119
|
}
|
|
120
120
|
else if (key.substring(0, 3) === 'tec') {
|
|
121
121
|
if (key === 'tecDIR_FULL') {
|
|
122
122
|
startingFromTecCLAIM = startingFromTecDIRFULL;
|
|
123
123
|
}
|
|
124
|
-
console.log(
|
|
124
|
+
console.log(` "${key}": ${startingFromTecCLAIM++},`);
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
127
|
//# sourceMappingURL=utils-renumber.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-renumber.js","sourceRoot":"","sources":["../../src/enums/utils-renumber.ts"],"names":[],"mappings":";AAAA;;GAEG;AAEH,
|
|
1
|
+
{"version":3,"file":"utils-renumber.js","sourceRoot":"","sources":["../../src/enums/utils-renumber.ts"],"names":[],"mappings":";AAAA;;GAEG;AAEH,MAAM,KAAK,GAAG;IACZ,qBAAqB,EAAE,CAAC,GAAG;IAC3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C,CAAA;KAC5C;SAAM,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE;QACxC,IAAI,GAAG,KAAK,aAAa,EAAE;YACzB,oBAAoB,GAAG,sBAAsB,CAAA;SAC9C;QACD,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,MAAM,oBAAoB,EAAE,GAAG,CAAC,CAAA;KACxD;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
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
|
+
/**
|
|
12
|
+
* Stores the various types and fields for rippled to be used to encode/decode information later on.
|
|
13
|
+
* XrplDefinitions should be instantiated instead of this class.
|
|
14
|
+
*/
|
|
15
|
+
declare class XrplDefinitionsBase {
|
|
16
|
+
field: FieldLookup;
|
|
17
|
+
ledgerEntryType: BytesLookup;
|
|
18
|
+
type: BytesLookup;
|
|
19
|
+
transactionResult: BytesLookup;
|
|
20
|
+
transactionType: BytesLookup;
|
|
21
|
+
transactionNames: string[];
|
|
22
|
+
dataTypes: Record<string, typeof SerializedType>;
|
|
23
|
+
/**
|
|
24
|
+
* Present rippled types in a typed and updatable format.
|
|
25
|
+
* For an example of the input format see `definitions.json`
|
|
26
|
+
* To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
|
|
27
|
+
*
|
|
28
|
+
* See the definitions.test.js file for examples of how to create your own updated definitions.json.
|
|
29
|
+
*
|
|
30
|
+
* @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
|
|
31
|
+
* @param types - A list of type objects with the same name as the fields defined.
|
|
32
|
+
* You can use the coreTypes object if you are not adding new types.
|
|
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.
|
|
40
|
+
*/
|
|
41
|
+
associateTypes(types: Record<string, typeof SerializedType>): void;
|
|
42
|
+
getAssociatedTypes(): Record<string, typeof SerializedType>;
|
|
43
|
+
}
|
|
44
|
+
export { DefinitionsData, XrplDefinitionsBase, FieldLookup, FieldInfo, FieldInstance, Bytes, BytesLookup, };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BytesLookup = exports.Bytes = exports.FieldLookup = exports.XrplDefinitionsBase = void 0;
|
|
4
|
+
const bytes_1 = require("./bytes");
|
|
5
|
+
Object.defineProperty(exports, "Bytes", { enumerable: true, get: function () { return bytes_1.Bytes; } });
|
|
6
|
+
Object.defineProperty(exports, "BytesLookup", { enumerable: true, get: function () { return bytes_1.BytesLookup; } });
|
|
7
|
+
const field_1 = require("./field");
|
|
8
|
+
Object.defineProperty(exports, "FieldLookup", { enumerable: true, get: function () { return field_1.FieldLookup; } });
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
/**
|
|
11
|
+
* Stores the various types and fields for rippled to be used to encode/decode information later on.
|
|
12
|
+
* XrplDefinitions should be instantiated instead of this class.
|
|
13
|
+
*/
|
|
14
|
+
class XrplDefinitionsBase {
|
|
15
|
+
/**
|
|
16
|
+
* Present rippled types in a typed and updatable format.
|
|
17
|
+
* For an example of the input format see `definitions.json`
|
|
18
|
+
* To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
|
|
19
|
+
*
|
|
20
|
+
* See the definitions.test.js file for examples of how to create your own updated definitions.json.
|
|
21
|
+
*
|
|
22
|
+
* @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
|
|
23
|
+
* @param types - A list of type objects with the same name as the fields defined.
|
|
24
|
+
* You can use the coreTypes object if you are not adding new types.
|
|
25
|
+
*/
|
|
26
|
+
constructor(enums, types) {
|
|
27
|
+
this.type = new bytes_1.BytesLookup(enums.TYPES, constants_1.TYPE_WIDTH);
|
|
28
|
+
this.ledgerEntryType = new bytes_1.BytesLookup(enums.LEDGER_ENTRY_TYPES, constants_1.LEDGER_ENTRY_WIDTH);
|
|
29
|
+
this.transactionType = new bytes_1.BytesLookup(enums.TRANSACTION_TYPES, constants_1.TRANSACTION_TYPE_WIDTH);
|
|
30
|
+
this.transactionResult = new bytes_1.BytesLookup(enums.TRANSACTION_RESULTS, constants_1.TRANSACTION_RESULT_WIDTH);
|
|
31
|
+
this.field = new field_1.FieldLookup(enums.FIELDS, enums.TYPES);
|
|
32
|
+
this.transactionNames = Object.entries(enums.TRANSACTION_TYPES)
|
|
33
|
+
.filter(([_key, value]) => value >= 0)
|
|
34
|
+
.map(([key, _value]) => key);
|
|
35
|
+
this.dataTypes = {}; // Filled in via associateTypes
|
|
36
|
+
this.associateTypes(types);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Associates each Field to a corresponding class that TypeScript can recognize.
|
|
40
|
+
*
|
|
41
|
+
* @param types a list of type objects with the same name as the fields defined.
|
|
42
|
+
* Defaults to xrpl.js's core type definitions.
|
|
43
|
+
*/
|
|
44
|
+
associateTypes(types) {
|
|
45
|
+
// Overwrite any existing type definitions with the given types
|
|
46
|
+
this.dataTypes = Object.assign({}, this.dataTypes, types);
|
|
47
|
+
Object.values(this.field).forEach((field) => {
|
|
48
|
+
field.associatedType = this.dataTypes[field.type.name];
|
|
49
|
+
});
|
|
50
|
+
this.field['TransactionType'].associatedType = this.transactionType;
|
|
51
|
+
this.field['TransactionResult'].associatedType = this.transactionResult;
|
|
52
|
+
this.field['LedgerEntryType'].associatedType = this.ledgerEntryType;
|
|
53
|
+
}
|
|
54
|
+
getAssociatedTypes() {
|
|
55
|
+
return this.dataTypes;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.XrplDefinitionsBase = XrplDefinitionsBase;
|
|
59
|
+
//# sourceMappingURL=xrpl-definitions-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xrpl-definitions-base.js","sourceRoot":"","sources":["../../src/enums/xrpl-definitions-base.ts"],"names":[],"mappings":";;;AACA,mCAA4C;AA2G1C,sFA3GO,aAAK,OA2GP;AACL,4FA5Gc,mBAAW,OA4Gd;AA3Gb,mCAA+D;AAuG7D,4FAvGkB,mBAAW,OAuGlB;AAtGb,2CAKoB;AAUpB;;;GAGG;AACH,MAAM,mBAAmB;IAgBvB;;;;;;;;;;OAUG;IACH,YACE,KAAsB,EACtB,KAA4C;QAE5C,IAAI,CAAC,IAAI,GAAG,IAAI,mBAAW,CAAC,KAAK,CAAC,KAAK,EAAE,sBAAU,CAAC,CAAA;QACpD,IAAI,CAAC,eAAe,GAAG,IAAI,mBAAW,CACpC,KAAK,CAAC,kBAAkB,EACxB,8BAAkB,CACnB,CAAA;QACD,IAAI,CAAC,eAAe,GAAG,IAAI,mBAAW,CACpC,KAAK,CAAC,iBAAiB,EACvB,kCAAsB,CACvB,CAAA;QACD,IAAI,CAAC,iBAAiB,GAAG,IAAI,mBAAW,CACtC,KAAK,CAAC,mBAAmB,EACzB,oCAAwB,CACzB,CAAA;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,mBAAW,CAC1B,KAAK,CAAC,MAAoC,EAC1C,KAAK,CAAC,KAAK,CACZ,CAAA;QACD,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC;aAC5D,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC;aACrC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAA;QAE9B,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA,CAAC,+BAA+B;QACnD,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IAC5B,CAAC;IAED;;;;;OAKG;IACI,cAAc,CAAC,KAA4C;QAChE,+DAA+D;QAC/D,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QAEzD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC1C,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACxD,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,cAAc,GAAG,IAAI,CAAC,eAAe,CAAA;QACnE,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAA;QACvE,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,cAAc,GAAG,IAAI,CAAC,eAAe,CAAA;IACrE,CAAC;IAEM,kBAAkB;QACvB,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;CACF;AAIC,kDAAmB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type DefinitionsData, XrplDefinitionsBase } from './xrpl-definitions-base';
|
|
2
|
+
import { SerializedType } from '../types/serialized-type';
|
|
3
|
+
/**
|
|
4
|
+
* Stores the various types and fields for rippled to be used to encode/decode information later on.
|
|
5
|
+
* Should be used instead of XrplDefinitionsBase since this defines default `types` for serializing/deserializing
|
|
6
|
+
* ledger data.
|
|
7
|
+
*/
|
|
8
|
+
export declare class XrplDefinitions extends XrplDefinitionsBase {
|
|
9
|
+
/**
|
|
10
|
+
* Present rippled types in a typed and updatable format.
|
|
11
|
+
* For an example of the input format see `definitions.json`
|
|
12
|
+
* To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
|
|
13
|
+
*
|
|
14
|
+
* See the definitions.test.js file for examples of how to create your own updated definitions.json.
|
|
15
|
+
*
|
|
16
|
+
* @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
|
|
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.
|
|
19
|
+
*/
|
|
20
|
+
constructor(enums: DefinitionsData, additionalTypes?: Record<string, typeof SerializedType>);
|
|
21
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XrplDefinitions = void 0;
|
|
4
|
+
const xrpl_definitions_base_1 = require("./xrpl-definitions-base");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
/**
|
|
7
|
+
* Stores the various types and fields for rippled to be used to encode/decode information later on.
|
|
8
|
+
* Should be used instead of XrplDefinitionsBase since this defines default `types` for serializing/deserializing
|
|
9
|
+
* ledger data.
|
|
10
|
+
*/
|
|
11
|
+
class XrplDefinitions extends xrpl_definitions_base_1.XrplDefinitionsBase {
|
|
12
|
+
/**
|
|
13
|
+
* Present rippled types in a typed and updatable format.
|
|
14
|
+
* For an example of the input format see `definitions.json`
|
|
15
|
+
* To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
|
|
16
|
+
*
|
|
17
|
+
* See the definitions.test.js file for examples of how to create your own updated definitions.json.
|
|
18
|
+
*
|
|
19
|
+
* @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
|
|
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.
|
|
22
|
+
*/
|
|
23
|
+
constructor(enums, additionalTypes) {
|
|
24
|
+
const types = Object.assign({}, types_1.coreTypes, additionalTypes);
|
|
25
|
+
super(enums, types);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.XrplDefinitions = XrplDefinitions;
|
|
29
|
+
//# sourceMappingURL=xrpl-definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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/hash-prefixes.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HashPrefix = void 0;
|
|
4
|
-
|
|
4
|
+
const buffer_1 = require("buffer/");
|
|
5
5
|
/**
|
|
6
6
|
* Write a 32 bit integer to a Buffer
|
|
7
7
|
*
|
|
@@ -9,14 +9,14 @@ var buffer_1 = require("buffer/");
|
|
|
9
9
|
* @returns a buffer with the bytes representation of uint32
|
|
10
10
|
*/
|
|
11
11
|
function bytes(uint32) {
|
|
12
|
-
|
|
12
|
+
const result = buffer_1.Buffer.alloc(4);
|
|
13
13
|
result.writeUInt32BE(uint32, 0);
|
|
14
14
|
return result;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Maps HashPrefix names to their byte representation
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
const HashPrefix = {
|
|
20
20
|
transactionID: bytes(0x54584e00),
|
|
21
21
|
// transaction plus metadata
|
|
22
22
|
transaction: bytes(0x534e4400),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-prefixes.js","sourceRoot":"","sources":["../src/hash-prefixes.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"hash-prefixes.js","sourceRoot":"","sources":["../src/hash-prefixes.ts"],"names":[],"mappings":";;;AAAA,oCAAgC;AAEhC;;;;;GAKG;AACH,SAAS,KAAK,CAAC,MAAc;IAC3B,MAAM,MAAM,GAAG,eAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC9B,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAC/B,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAA2B;IACzC,aAAa,EAAE,KAAK,CAAC,UAAU,CAAC;IAChC,4BAA4B;IAC5B,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC;IAC9B,gBAAgB;IAChB,iBAAiB,EAAE,KAAK,CAAC,UAAU,CAAC;IACpC,qBAAqB;IACrB,SAAS,EAAE,KAAK,CAAC,UAAU,CAAC;IAC5B,iCAAiC;IACjC,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC;IAC/B,4BAA4B;IAC5B,cAAc,EAAE,KAAK,CAAC,UAAU,CAAC;IACjC,4BAA4B;IAC5B,mBAAmB,EAAE,KAAK,CAAC,UAAU,CAAC;IACtC,yBAAyB;IACzB,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC;IAC7B,uBAAuB;IACvB,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC;IAC3B,wBAAwB;IACxB,mBAAmB,EAAE,KAAK,CAAC,UAAU,CAAC;CACvC,CAAA;AAEQ,gCAAU"}
|
package/dist/hashes.js
CHANGED
|
@@ -1,36 +1,19 @@
|
|
|
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.transactionID = exports.sha512Half = exports.Sha512Half = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
4
|
+
const hash_prefixes_1 = require("./hash-prefixes");
|
|
5
|
+
const createHash = require("create-hash");
|
|
6
|
+
const hash_256_1 = require("./types/hash-256");
|
|
7
|
+
const binary_serializer_1 = require("./serdes/binary-serializer");
|
|
8
|
+
const buffer_1 = require("buffer/");
|
|
24
9
|
/**
|
|
25
10
|
* Class for hashing with SHA512
|
|
26
11
|
* @extends BytesList So SerializedTypes can write bytes to a Sha512Half
|
|
27
12
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
_this.hash = createHash('sha512');
|
|
33
|
-
return _this;
|
|
13
|
+
class Sha512Half extends binary_serializer_1.BytesList {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.hash = createHash('sha512');
|
|
34
17
|
}
|
|
35
18
|
/**
|
|
36
19
|
* Construct a new Sha512Hash and write bytes this.hash
|
|
@@ -38,37 +21,36 @@ var Sha512Half = /** @class */ (function (_super) {
|
|
|
38
21
|
* @param bytes bytes to write to this.hash
|
|
39
22
|
* @returns the new Sha512Hash object
|
|
40
23
|
*/
|
|
41
|
-
|
|
24
|
+
static put(bytes) {
|
|
42
25
|
return new Sha512Half().put(bytes);
|
|
43
|
-
}
|
|
26
|
+
}
|
|
44
27
|
/**
|
|
45
28
|
* Write bytes to an existing Sha512Hash
|
|
46
29
|
*
|
|
47
30
|
* @param bytes bytes to write to object
|
|
48
31
|
* @returns the Sha512 object
|
|
49
32
|
*/
|
|
50
|
-
|
|
33
|
+
put(bytes) {
|
|
51
34
|
this.hash.update(bytes);
|
|
52
35
|
return this;
|
|
53
|
-
}
|
|
36
|
+
}
|
|
54
37
|
/**
|
|
55
38
|
* Compute SHA512 hash and slice in half
|
|
56
39
|
*
|
|
57
40
|
* @returns half of a SHA512 hash
|
|
58
41
|
*/
|
|
59
|
-
|
|
42
|
+
finish256() {
|
|
60
43
|
return buffer_1.Buffer.from(this.hash.digest().slice(0, 32));
|
|
61
|
-
}
|
|
44
|
+
}
|
|
62
45
|
/**
|
|
63
46
|
* Constructs a Hash256 from the Sha512Half object
|
|
64
47
|
*
|
|
65
48
|
* @returns a Hash256 object
|
|
66
49
|
*/
|
|
67
|
-
|
|
50
|
+
finish() {
|
|
68
51
|
return new hash_256_1.Hash256(this.finish256());
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
}(binary_serializer_1.BytesList));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
72
54
|
exports.Sha512Half = Sha512Half;
|
|
73
55
|
/**
|
|
74
56
|
* compute SHA512 hash of a list of bytes
|
|
@@ -76,13 +58,9 @@ exports.Sha512Half = Sha512Half;
|
|
|
76
58
|
* @param args zero or more arguments to hash
|
|
77
59
|
* @returns the sha512half hash of the arguments.
|
|
78
60
|
*/
|
|
79
|
-
function sha512Half() {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
args[_i] = arguments[_i];
|
|
83
|
-
}
|
|
84
|
-
var hash = new Sha512Half();
|
|
85
|
-
args.forEach(function (a) { return hash.put(a); });
|
|
61
|
+
function sha512Half(...args) {
|
|
62
|
+
const hash = new Sha512Half();
|
|
63
|
+
args.forEach((a) => hash.put(a));
|
|
86
64
|
return hash.finish256();
|
|
87
65
|
}
|
|
88
66
|
exports.sha512Half = sha512Half;
|
package/dist/hashes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashes.js","sourceRoot":"","sources":["../src/hashes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hashes.js","sourceRoot":"","sources":["../src/hashes.ts"],"names":[],"mappings":";;;AAAA,mDAA4C;AAC5C,0CAA0C;AAC1C,+CAA0C;AAC1C,kEAAsD;AACtD,oCAAgC;AAEhC;;;GAGG;AACH,MAAM,UAAW,SAAQ,6BAAS;IAAlC;;QACU,SAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;IAwCrC,CAAC;IAtCC;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,KAAa;QACtB,OAAO,IAAI,UAAU,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,KAAa;QACf,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACvB,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;OAIG;IACH,SAAS;QACP,OAAO,eAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;IACrD,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,OAAO,IAAI,kBAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;IACtC,CAAC;CACF;AAwBQ,gCAAU;AAtBnB;;;;;GAKG;AACH,SAAS,UAAU,CAAC,GAAG,IAAc;IACnC,MAAM,IAAI,GAAG,IAAI,UAAU,EAAE,CAAA;IAC7B,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAChC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAA;AACzB,CAAC;AAYoB,gCAAU;AAV/B;;;;;GAKG;AACH,SAAS,aAAa,CAAC,UAAkB;IACvC,OAAO,IAAI,kBAAO,CAAC,UAAU,CAAC,0BAAU,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,CAAA;AACtE,CAAC;AAEgC,sCAAa"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,40 @@
|
|
|
1
1
|
import { decodeLedgerData } from './ledger-hashes';
|
|
2
2
|
import { JsonObject } from './types/serialized-type';
|
|
3
|
+
import { XrplDefinitionsBase, TRANSACTION_TYPES, DEFAULT_DEFINITIONS } from './enums';
|
|
4
|
+
import { XrplDefinitions } from './enums/xrpl-definitions';
|
|
5
|
+
import { coreTypes } from './types';
|
|
3
6
|
/**
|
|
4
7
|
* Decode a transaction
|
|
5
8
|
*
|
|
6
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.
|
|
7
11
|
* @returns the JSON representation of the transaction
|
|
8
12
|
*/
|
|
9
|
-
declare function decode(binary: string): JsonObject;
|
|
13
|
+
declare function decode(binary: string, definitions?: XrplDefinitionsBase): JsonObject;
|
|
10
14
|
/**
|
|
11
15
|
* Encode a transaction
|
|
12
16
|
*
|
|
13
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
|
+
*
|
|
14
20
|
* @returns A hex-string of the encoded transaction
|
|
15
21
|
*/
|
|
16
|
-
declare function encode(json: object): string;
|
|
22
|
+
declare function encode(json: object, definitions?: XrplDefinitionsBase): string;
|
|
17
23
|
/**
|
|
18
24
|
* Encode a transaction and prepare for signing
|
|
19
25
|
*
|
|
20
26
|
* @param json JSON object representing the transaction
|
|
21
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.
|
|
22
29
|
* @returns a hex string of the encoded transaction
|
|
23
30
|
*/
|
|
24
|
-
declare function encodeForSigning(json: object): string;
|
|
31
|
+
declare function encodeForSigning(json: object, definitions?: XrplDefinitionsBase): string;
|
|
25
32
|
/**
|
|
26
33
|
* Encode a transaction and prepare for signing with a claim
|
|
27
34
|
*
|
|
28
35
|
* @param json JSON object representing the transaction
|
|
29
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.
|
|
30
38
|
* @returns a hex string of the encoded transaction
|
|
31
39
|
*/
|
|
32
40
|
declare function encodeForSigningClaim(json: object): string;
|
|
@@ -35,9 +43,10 @@ declare function encodeForSigningClaim(json: object): string;
|
|
|
35
43
|
*
|
|
36
44
|
* @param json JSON object representing the transaction
|
|
37
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.
|
|
38
47
|
* @returns a hex string of the encoded transaction
|
|
39
48
|
*/
|
|
40
|
-
declare function encodeForMultisigning(json: object, signer: string): string;
|
|
49
|
+
declare function encodeForMultisigning(json: object, signer: string, definitions?: XrplDefinitionsBase): string;
|
|
41
50
|
/**
|
|
42
51
|
* Encode a quality value
|
|
43
52
|
*
|
|
@@ -52,15 +61,4 @@ declare function encodeQuality(value: string): string;
|
|
|
52
61
|
* @returns a string representing the quality
|
|
53
62
|
*/
|
|
54
63
|
declare function decodeQuality(value: string): string;
|
|
55
|
-
|
|
56
|
-
decode: typeof decode;
|
|
57
|
-
encode: typeof encode;
|
|
58
|
-
encodeForSigning: typeof encodeForSigning;
|
|
59
|
-
encodeForSigningClaim: typeof encodeForSigningClaim;
|
|
60
|
-
encodeForMultisigning: typeof encodeForMultisigning;
|
|
61
|
-
encodeQuality: typeof encodeQuality;
|
|
62
|
-
decodeQuality: typeof decodeQuality;
|
|
63
|
-
decodeLedgerData: typeof decodeLedgerData;
|
|
64
|
-
TRANSACTION_TYPES: string[];
|
|
65
|
-
};
|
|
66
|
-
export = _default;
|
|
64
|
+
export { decode, encode, encodeForSigning, encodeForSigningClaim, encodeForMultisigning, encodeQuality, decodeQuality, decodeLedgerData, TRANSACTION_TYPES, XrplDefinitions, XrplDefinitionsBase, DEFAULT_DEFINITIONS, coreTypes, };
|
package/dist/index.js
CHANGED
|
@@ -1,49 +1,92 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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
|
+
const assert = __importStar(require("assert"));
|
|
28
|
+
const coretypes_1 = require("./coretypes");
|
|
29
|
+
const ledger_hashes_1 = require("./ledger-hashes");
|
|
30
|
+
Object.defineProperty(exports, "decodeLedgerData", { enumerable: true, get: function () { return ledger_hashes_1.decodeLedgerData; } });
|
|
31
|
+
const enums_1 = require("./enums");
|
|
32
|
+
Object.defineProperty(exports, "XrplDefinitionsBase", { enumerable: true, get: function () { return enums_1.XrplDefinitionsBase; } });
|
|
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; } });
|
|
39
|
+
const { signingData, signingClaimData, multiSigningData, binaryToJSON, serializeObject, } = coretypes_1.binary;
|
|
7
40
|
/**
|
|
8
41
|
* Decode a transaction
|
|
9
42
|
*
|
|
10
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.
|
|
11
45
|
* @returns the JSON representation of the transaction
|
|
12
46
|
*/
|
|
13
|
-
function decode(binary) {
|
|
47
|
+
function decode(binary, definitions) {
|
|
14
48
|
assert.ok(typeof binary === 'string', 'binary must be a hex string');
|
|
15
|
-
return binaryToJSON(binary);
|
|
49
|
+
return binaryToJSON(binary, definitions);
|
|
16
50
|
}
|
|
51
|
+
exports.decode = decode;
|
|
17
52
|
/**
|
|
18
53
|
* Encode a transaction
|
|
19
54
|
*
|
|
20
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
|
+
*
|
|
21
58
|
* @returns A hex-string of the encoded transaction
|
|
22
59
|
*/
|
|
23
|
-
function encode(json) {
|
|
60
|
+
function encode(json, definitions) {
|
|
24
61
|
assert.ok(typeof json === 'object');
|
|
25
|
-
return serializeObject(json)
|
|
62
|
+
return serializeObject(json, { definitions })
|
|
26
63
|
.toString('hex')
|
|
27
64
|
.toUpperCase();
|
|
28
65
|
}
|
|
66
|
+
exports.encode = encode;
|
|
29
67
|
/**
|
|
30
68
|
* Encode a transaction and prepare for signing
|
|
31
69
|
*
|
|
32
70
|
* @param json JSON object representing the transaction
|
|
33
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.
|
|
34
73
|
* @returns a hex string of the encoded transaction
|
|
35
74
|
*/
|
|
36
|
-
function encodeForSigning(json) {
|
|
75
|
+
function encodeForSigning(json, definitions) {
|
|
37
76
|
assert.ok(typeof json === 'object');
|
|
38
|
-
return signingData(json
|
|
77
|
+
return signingData(json, coretypes_1.HashPrefix.transactionSig, {
|
|
78
|
+
definitions,
|
|
79
|
+
})
|
|
39
80
|
.toString('hex')
|
|
40
81
|
.toUpperCase();
|
|
41
82
|
}
|
|
83
|
+
exports.encodeForSigning = encodeForSigning;
|
|
42
84
|
/**
|
|
43
85
|
* Encode a transaction and prepare for signing with a claim
|
|
44
86
|
*
|
|
45
87
|
* @param json JSON object representing the transaction
|
|
46
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.
|
|
47
90
|
* @returns a hex string of the encoded transaction
|
|
48
91
|
*/
|
|
49
92
|
function encodeForSigningClaim(json) {
|
|
@@ -52,20 +95,24 @@ function encodeForSigningClaim(json) {
|
|
|
52
95
|
.toString('hex')
|
|
53
96
|
.toUpperCase();
|
|
54
97
|
}
|
|
98
|
+
exports.encodeForSigningClaim = encodeForSigningClaim;
|
|
55
99
|
/**
|
|
56
100
|
* Encode a transaction and prepare for multi-signing
|
|
57
101
|
*
|
|
58
102
|
* @param json JSON object representing the transaction
|
|
59
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.
|
|
60
105
|
* @returns a hex string of the encoded transaction
|
|
61
106
|
*/
|
|
62
|
-
function encodeForMultisigning(json, signer) {
|
|
107
|
+
function encodeForMultisigning(json, signer, definitions) {
|
|
63
108
|
assert.ok(typeof json === 'object');
|
|
64
109
|
assert.equal(json['SigningPubKey'], '');
|
|
65
|
-
|
|
110
|
+
const definitionsOpt = definitions ? { definitions } : undefined;
|
|
111
|
+
return multiSigningData(json, signer, definitionsOpt)
|
|
66
112
|
.toString('hex')
|
|
67
113
|
.toUpperCase();
|
|
68
114
|
}
|
|
115
|
+
exports.encodeForMultisigning = encodeForMultisigning;
|
|
69
116
|
/**
|
|
70
117
|
* Encode a quality value
|
|
71
118
|
*
|
|
@@ -76,6 +123,7 @@ function encodeQuality(value) {
|
|
|
76
123
|
assert.ok(typeof value === 'string');
|
|
77
124
|
return coretypes_1.quality.encode(value).toString('hex').toUpperCase();
|
|
78
125
|
}
|
|
126
|
+
exports.encodeQuality = encodeQuality;
|
|
79
127
|
/**
|
|
80
128
|
* Decode a quality value
|
|
81
129
|
*
|
|
@@ -86,15 +134,5 @@ function decodeQuality(value) {
|
|
|
86
134
|
assert.ok(typeof value === 'string');
|
|
87
135
|
return coretypes_1.quality.decode(value).toString();
|
|
88
136
|
}
|
|
89
|
-
|
|
90
|
-
decode: decode,
|
|
91
|
-
encode: encode,
|
|
92
|
-
encodeForSigning: encodeForSigning,
|
|
93
|
-
encodeForSigningClaim: encodeForSigningClaim,
|
|
94
|
-
encodeForMultisigning: encodeForMultisigning,
|
|
95
|
-
encodeQuality: encodeQuality,
|
|
96
|
-
decodeQuality: decodeQuality,
|
|
97
|
-
decodeLedgerData: ledger_hashes_1.decodeLedgerData,
|
|
98
|
-
TRANSACTION_TYPES: enums_1.TRANSACTION_TYPES,
|
|
99
|
-
};
|
|
137
|
+
exports.decodeQuality = decodeQuality;
|
|
100
138
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
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;AA7HjB,mCAAmC;AAgIjC,0FAhIO,iBAAS,OAgIP;AA9HX,MAAM,EACJ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,eAAe,GAChB,GAAG,kBAAM,CAAA;AAEV;;;;;;GAMG;AACH,SAAS,MAAM,CAAC,MAAc,EAAE,W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