ripple-binary-codec
Advanced tools
Comparing version 0.1.10 to 0.1.11
@@ -9,4 +9,21 @@ 'use strict';var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {return typeof obj;} : function (obj) {return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;};var assert = require('assert'); | ||
coreTypes.quality;var _coreTypes$binary = coreTypes.binary;var bytesToHex = _coreTypes$binary.bytesToHex;var signingData = _coreTypes$binary.signingData;var signingClaimData = _coreTypes$binary.signingClaimData;var multiSigningData = _coreTypes$binary.multiSigningData;var binaryToJSON = _coreTypes$binary.binaryToJSON;var serializeObject = _coreTypes$binary.serializeObject; | ||
coreTypes.quality;var _coreTypes$binary = coreTypes.binary;var bytesToHex = _coreTypes$binary.bytesToHex;var signingData = _coreTypes$binary.signingData;var signingClaimData = _coreTypes$binary.signingClaimData;var multiSigningData = _coreTypes$binary.multiSigningData;var binaryToJSON = _coreTypes$binary.binaryToJSON;var serializeObject = _coreTypes$binary.serializeObject;var BinaryParser = _coreTypes$binary.BinaryParser; | ||
function decodeLedgerData(binary) { | ||
assert(typeof binary === 'string', 'binary must be a hex string'); | ||
var parser = new BinaryParser(binary); | ||
return { | ||
ledger_index: parser.readUInt32(), | ||
total_coins: parser.readType(coreTypes.UInt64).valueOf().toString(), | ||
parent_hash: parser.readType(coreTypes.Hash256).toHex(), | ||
transaction_hash: parser.readType(coreTypes.Hash256).toHex(), | ||
account_hash: parser.readType(coreTypes.Hash256).toHex(), | ||
parent_close_time: parser.readUInt32(), | ||
close_time: parser.readUInt32(), | ||
close_time_resolution: parser.readUInt8(), | ||
close_flags: parser.readUInt8() };} | ||
function decode(binary) { | ||
@@ -55,2 +72,3 @@ assert(typeof binary === 'string', 'binary must be a hex string'); | ||
encodeQuality: encodeQuality, | ||
decodeQuality: decodeQuality }; | ||
decodeQuality: decodeQuality, | ||
decodeLedgerData: decodeLedgerData }; |
{ | ||
"name": "ripple-binary-codec", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "ripple binary codec", | ||
@@ -5,0 +5,0 @@ "files": [ |
const assert = require('assert'); | ||
const fixtures = require('./fixtures/codec-fixtures.json'); | ||
const {decode, encode} = require('../src'); | ||
const {decode, encode, decodeLedgerData} = require('../src'); | ||
@@ -27,2 +27,12 @@ function json(object) { | ||
makeSuite('accountState', fixtures.accountState); | ||
describe('ledgerData', function() { | ||
fixtures.ledgerData.forEach((t, test_n) => { | ||
it(`ledgerData[${test_n}] can decode ${t.binary} to ${json(t.json)}`, | ||
() => { | ||
const decoded = decodeLedgerData(t.binary); | ||
assert.deepEqual(t.json, decoded); | ||
}); | ||
}); | ||
}) | ||
}); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
894103
12694