ripple-binary-codec
Advanced tools
Comparing version 1.1.2 to 1.1.3-beta.0
@@ -21,3 +21,3 @@ "use strict"; | ||
var buffer_1 = require("buffer/"); | ||
var HEX_REGEX = /^[A-F0-9]{16}$/; | ||
var HEX_REGEX = /^[A-F0-9]{1,16}$/; | ||
var mask = bigInt(0x00000000ffffffff); | ||
@@ -57,9 +57,7 @@ /** | ||
if (typeof val === "string") { | ||
if (val === "0") { | ||
return UInt64.from(0); | ||
} | ||
if (!HEX_REGEX.test(val)) { | ||
throw new Error(val + " is not a valid hex-string"); | ||
} | ||
buf = buffer_1.Buffer.from(val, "hex"); | ||
var strBuf = val.padStart(16, "0"); | ||
buf = buffer_1.Buffer.from(strBuf, "hex"); | ||
return new UInt64(buf); | ||
@@ -66,0 +64,0 @@ } |
{ | ||
"name": "ripple-binary-codec", | ||
"version": "1.1.2", | ||
"version": "1.1.3-beta.0", | ||
"description": "XRP Ledger binary codec", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -30,2 +30,45 @@ const { coreTypes } = require("../dist/types"); | ||
const binaryEntry1 = | ||
"1100642200000000320000000000000002580CB3C1AD2C371136AEA434246D971C5FCCD32CBF520667E131AB7B10D706E7528214BA53D10260FFCC968ACD16BA30F7CEABAD6E5D92011340A3454ACED87177146EABD5E4A256021D836D1E3617618B1EB362D10B0D1BAC6AE1ED9E8D280BBE0B6656748FD647231851C6C650794D5E6852DFA1E35E68630F"; | ||
const jsonEntry1 = { | ||
Flags: 0, | ||
IndexPrevious: "2", | ||
Indexes: [ | ||
"A3454ACED87177146EABD5E4A256021D836D1E3617618B1EB362D10B0D1BAC6A", | ||
"E1ED9E8D280BBE0B6656748FD647231851C6C650794D5E6852DFA1E35E68630F", | ||
], | ||
LedgerEntryType: "DirectoryNode", | ||
Owner: "rHzDaMNybxQppiE3uWyt2N265KvAKdiRdP", | ||
RootIndex: "0CB3C1AD2C371136AEA434246D971C5FCCD32CBF520667E131AB7B10D706E752", | ||
index: "0B4A2E68C111F7E42FAEEE405F7344560C8240840B151D9D04131EB79D080167", | ||
}; | ||
const binaryEntry2 = | ||
"1100722200210000250178D1CA37000000000000000038000000000000028355C0C37CE200B509E0A529880634F7841A9EF4CB65F03C12E6004CFAD9718D66946280000000000000000000000000000000000000004743420000000000000000000000000000000000000000000000000166D6071AFD498D000000000000000000000000000047434200000000002599D1D255BCA61189CA64C84528F2FCBE4BFC3867800000000000000000000000000000000000000047434200000000006EEBB1D1852CE667876A0B3630861FB6C6AB358E"; | ||
const jsonEntry2 = { | ||
Balance: { | ||
currency: "GCB", | ||
issuer: "rrrrrrrrrrrrrrrrrrrrBZbvji", | ||
value: "0", | ||
}, | ||
Flags: 2162688, | ||
HighLimit: { | ||
currency: "GCB", | ||
issuer: "rBfVgTnsdh8ckC19RM8aVGNuMZnpwrMP6n", | ||
value: "0", | ||
}, | ||
HighNode: "283", | ||
LedgerEntryType: "RippleState", | ||
LowLimit: { | ||
currency: "GCB", | ||
issuer: "rhRFGCy2RJTA8oxkjjtYTvofPVGqcgvXWj", | ||
value: "2000000", | ||
}, | ||
LowNode: "0", | ||
PreviousTxnID: | ||
"C0C37CE200B509E0A529880634F7841A9EF4CB65F03C12E6004CFAD9718D6694", | ||
PreviousTxnLgrSeq: 24695242, | ||
index: "0000041EFD027808D3F78C8352F97E324CB816318E00B977C74ECDDC7CD975B2", | ||
}; | ||
test("compareToTests[0]", () => { | ||
@@ -68,2 +111,7 @@ expect(UInt8.from(124).compareTo(UInt64.from(124))).toBe(0); | ||
test("UInt64 from non 16 length hex", () => { | ||
expect(encode(jsonEntry1)).toEqual(binaryEntry1); | ||
expect(encode(jsonEntry2)).toEqual(binaryEntry2); | ||
}); | ||
test("valueOfTests", () => { | ||
@@ -70,0 +118,0 @@ let val = UInt8.from(1); |
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
1087270
16704
1