123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- "use strict";
- var assert = require("assert");
- var coretypes_1 = require("./coretypes");
- var ledger_hashes_1 = require("./ledger-hashes");
- var enums_1 = require("./enums");
- var signingData = coretypes_1.binary.signingData, signingClaimData = coretypes_1.binary.signingClaimData, multiSigningData = coretypes_1.binary.multiSigningData, binaryToJSON = coretypes_1.binary.binaryToJSON, serializeObject = coretypes_1.binary.serializeObject;
- /**
- * Decode a transaction
- *
- * @param binary hex-string of the encoded transaction
- * @returns the JSON representation of the transaction
- */
- function decode(binary) {
- assert.ok(typeof binary === 'string', 'binary must be a hex string');
- return binaryToJSON(binary);
- }
- /**
- * Encode a transaction
- *
- * @param json The JSON representation of a transaction
- * @returns A hex-string of the encoded transaction
- */
- function encode(json) {
- assert.ok(typeof json === 'object');
- return serializeObject(json)
- .toString('hex')
- .toUpperCase();
- }
- /**
- * Encode a transaction and prepare for signing
- *
- * @param json JSON object representing the transaction
- * @param signer string representing the account to sign the transaction with
- * @returns a hex string of the encoded transaction
- */
- function encodeForSigning(json) {
- assert.ok(typeof json === 'object');
- return signingData(json)
- .toString('hex')
- .toUpperCase();
- }
- /**
- * Encode a transaction and prepare for signing with a claim
- *
- * @param json JSON object representing the transaction
- * @param signer string representing the account to sign the transaction with
- * @returns a hex string of the encoded transaction
- */
- function encodeForSigningClaim(json) {
- assert.ok(typeof json === 'object');
- return signingClaimData(json)
- .toString('hex')
- .toUpperCase();
- }
- /**
- * Encode a transaction and prepare for multi-signing
- *
- * @param json JSON object representing the transaction
- * @param signer string representing the account to sign the transaction with
- * @returns a hex string of the encoded transaction
- */
- function encodeForMultisigning(json, signer) {
- assert.ok(typeof json === 'object');
- assert.equal(json['SigningPubKey'], '');
- return multiSigningData(json, signer)
- .toString('hex')
- .toUpperCase();
- }
- /**
- * Encode a quality value
- *
- * @param value string representation of a number
- * @returns a hex-string representing the quality
- */
- function encodeQuality(value) {
- assert.ok(typeof value === 'string');
- return coretypes_1.quality.encode(value).toString('hex').toUpperCase();
- }
- /**
- * Decode a quality value
- *
- * @param value hex-string of a quality
- * @returns a string representing the quality
- */
- function decodeQuality(value) {
- assert.ok(typeof value === 'string');
- return coretypes_1.quality.decode(value).toString();
- }
- module.exports = {
- decode: decode,
- encode: encode,
- encodeForSigning: encodeForSigning,
- encodeForSigningClaim: encodeForSigningClaim,
- encodeForMultisigning: encodeForMultisigning,
- encodeQuality: encodeQuality,
- decodeQuality: decodeQuality,
- decodeLedgerData: ledger_hashes_1.decodeLedgerData,
- TRANSACTION_TYPES: enums_1.TRANSACTION_TYPES,
- };
- //# sourceMappingURL=index.js.map
|