mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-21 12:45:50 +00:00
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
const coreTypes = require('@niq/ripple-core');
|
|
const {quality,
|
|
binary: {bytesToHex,
|
|
signingData,
|
|
multiSigningData,
|
|
binaryToJSON,
|
|
serializeObject}} = coreTypes;
|
|
|
|
exports.decode = function(binary) {
|
|
assert(typeof binary === 'string', 'binary must be a hex string');
|
|
return binaryToJSON(binary);
|
|
};
|
|
|
|
exports.encode = function(json) {
|
|
assert(typeof json === 'object');
|
|
return bytesToHex(serializeObject(json));
|
|
};
|
|
|
|
exports.encodeForSigning = function(json) {
|
|
assert(typeof json === 'object');
|
|
return bytesToHex(signingData(json));
|
|
};
|
|
|
|
exports.encodeForMultisigning = function(json, signer) {
|
|
assert(typeof json === 'object');
|
|
return bytesToHex(multiSigningData(json, signer));
|
|
};
|
|
|
|
exports.encodeQuality = function(value) {
|
|
assert(typeof value === 'string');
|
|
return bytesToHex(quality.encode(value));
|
|
};
|
|
|
|
exports.decodeQuality = function(value) {
|
|
assert(typeof value === 'string');
|
|
return quality.decode(value).toString();
|
|
};
|