1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | 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;
|
4 | const coretypes_1 = require("./coretypes");
|
5 | const ledger_hashes_1 = require("./ledger-hashes");
|
6 | Object.defineProperty(exports, "decodeLedgerData", { enumerable: true, get: function () { return ledger_hashes_1.decodeLedgerData; } });
|
7 | const enums_1 = require("./enums");
|
8 | Object.defineProperty(exports, "XrplDefinitionsBase", { enumerable: true, get: function () { return enums_1.XrplDefinitionsBase; } });
|
9 | Object.defineProperty(exports, "TRANSACTION_TYPES", { enumerable: true, get: function () { return enums_1.TRANSACTION_TYPES; } });
|
10 | Object.defineProperty(exports, "DEFAULT_DEFINITIONS", { enumerable: true, get: function () { return enums_1.DEFAULT_DEFINITIONS; } });
|
11 | const xrpl_definitions_1 = require("./enums/xrpl-definitions");
|
12 | Object.defineProperty(exports, "XrplDefinitions", { enumerable: true, get: function () { return xrpl_definitions_1.XrplDefinitions; } });
|
13 | const types_1 = require("./types");
|
14 | Object.defineProperty(exports, "coreTypes", { enumerable: true, get: function () { return types_1.coreTypes; } });
|
15 | const utils_1 = require("@xrplf/isomorphic/utils");
|
16 | const { signingData, signingClaimData, multiSigningData, binaryToJSON, serializeObject, } = coretypes_1.binary;
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | function decode(binary, definitions) {
|
25 | if (typeof binary !== 'string') {
|
26 | throw new Error('binary must be a hex string');
|
27 | }
|
28 | return binaryToJSON(binary, definitions);
|
29 | }
|
30 | exports.decode = decode;
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | function encode(json, definitions) {
|
40 | if (typeof json !== 'object') {
|
41 | throw new Error();
|
42 | }
|
43 | return (0, utils_1.bytesToHex)(serializeObject(json, { definitions }));
|
44 | }
|
45 | exports.encode = encode;
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | function encodeForSigning(json, definitions) {
|
55 | if (typeof json !== 'object') {
|
56 | throw new Error();
|
57 | }
|
58 | return (0, utils_1.bytesToHex)(signingData(json, coretypes_1.HashPrefix.transactionSig, {
|
59 | definitions,
|
60 | }));
|
61 | }
|
62 | exports.encodeForSigning = encodeForSigning;
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | function encodeForSigningClaim(json) {
|
72 | if (typeof json !== 'object') {
|
73 | throw new Error();
|
74 | }
|
75 | return (0, utils_1.bytesToHex)(signingClaimData(json));
|
76 | }
|
77 | exports.encodeForSigningClaim = encodeForSigningClaim;
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | function encodeForMultisigning(json, signer, definitions) {
|
87 | if (typeof json !== 'object') {
|
88 | throw new Error();
|
89 | }
|
90 | if (json['SigningPubKey'] !== '') {
|
91 | throw new Error();
|
92 | }
|
93 | const definitionsOpt = definitions ? { definitions } : undefined;
|
94 | return (0, utils_1.bytesToHex)(multiSigningData(json, signer, definitionsOpt));
|
95 | }
|
96 | exports.encodeForMultisigning = encodeForMultisigning;
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 | function encodeQuality(value) {
|
104 | if (typeof value !== 'string') {
|
105 | throw new Error();
|
106 | }
|
107 | return (0, utils_1.bytesToHex)(coretypes_1.quality.encode(value));
|
108 | }
|
109 | exports.encodeQuality = encodeQuality;
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 | function decodeQuality(value) {
|
117 | if (typeof value !== 'string') {
|
118 | throw new Error();
|
119 | }
|
120 | return coretypes_1.quality.decode(value).toString();
|
121 | }
|
122 | exports.decodeQuality = decodeQuality;
|
123 |
|
\ | No newline at end of file |