@harmoniclabs/plutus-data
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -31,5 +31,25 @@ "use strict"; | ||
if (openBracketIdx < 0) { | ||
var length_1 = str.trimEnd().length; | ||
str = str.trim(); | ||
return { formatted: [str], length: length_1 }; // I or B | ||
var intMatch = str | ||
// I\s+ -> "I" followed by one or more space | ||
// \+?\-? -> may or may nost start with "+" or "-" | ||
// (?<!\.) -> MUST NOT have dots before | ||
// (?<!(#|x)\d*) -> MUST NOT have before "#" or "x" with 0 or more digits (escluded bls elements and bytestrings) | ||
// \d+ -> one or more digits | ||
// (?!(\.|x)) -> MUST NOT have dots after or "x" (x excludes "0x" which are bls elems) | ||
.match(/I\s+\+?\-?(?<!\.)(?<!(#|x)\d*)\d+(?!(\.|x))/); | ||
var bsMatch = str.match(/B\s*#[0-9a-fA-F]*/); | ||
if (!bsMatch && !intMatch) | ||
throw new Error("expected Data I or B; found none"); | ||
var match = bsMatch && intMatch ? | ||
(str.indexOf(bsMatch[0]) < str.indexOf(intMatch[0]) ? | ||
bsMatch : | ||
intMatch) : | ||
(!bsMatch ? intMatch : bsMatch); | ||
if (!match) | ||
throw new Error("expected Data I or B; found none"); | ||
var formattedStr = match[0]; | ||
return { | ||
formatted: [formattedStr], | ||
offset: str.indexOf(formattedStr) + formattedStr.length | ||
}; // I or B | ||
} | ||
@@ -41,3 +61,3 @@ var start = str.slice(0, openBracketIdx).trim(); | ||
var nOpen = 0; | ||
var isMap = start.startsWith("Map"); | ||
var isMap = /^\(?(\s*)?Map/.test(str); | ||
var insidePair = false; | ||
@@ -60,3 +80,3 @@ var pairK = undefined; | ||
formatted: [start, rest], | ||
length: i | ||
offset: i + 1 | ||
}; | ||
@@ -117,4 +137,4 @@ } | ||
function dataFromStringWithOffset(str) { | ||
var _a = formatStringByBrackets(str), words = _a.formatted, length = _a.length; | ||
return { data: parseWords(words), offset: length }; | ||
var _a = formatStringByBrackets(str), words = _a.formatted, offset = _a.offset; | ||
return { data: parseWords(words), offset: offset }; | ||
} | ||
@@ -135,3 +155,3 @@ exports.dataFromStringWithOffset = dataFromStringWithOffset; | ||
start = start.slice(1); | ||
if (start.startsWith("Constr")) { | ||
if (/^\(?(\s*)?Constr/.test(start)) { | ||
var _a = __read(start.split(" "), 2), _ = _a[0], idxStr = _a[1]; | ||
@@ -146,3 +166,3 @@ var idx = BigInt(idxStr); | ||
} | ||
if (start.startsWith("Map")) { | ||
if (/^\(?(\s*)?Map/.test(start)) { | ||
if (Array.isArray(words[1])) { | ||
@@ -158,3 +178,3 @@ var pairs = words[1]; | ||
} | ||
if (start.startsWith("List")) { | ||
if (/^\(?(\s*)?List/.test(start)) { | ||
if (Array.isArray(words[1])) { | ||
@@ -171,7 +191,6 @@ return new DataList_1.DataList(words[1].map(parseWords)); | ||
if (start[0] === "B") { | ||
var _c = __read(start.split("#"), 2), _ = _c[0], valStr = _c[1]; | ||
return new DataB_1.DataB(valStr.trim()); | ||
var _c = __read(start.split("#"), 2), _ = _c[0], valueStr = _c[1]; | ||
return new DataB_1.DataB(valueStr); | ||
} | ||
console.log(words); | ||
throw new Error("invalid string to parse Data"); | ||
throw new Error("invalid string to parse Data; " + JSON.stringify(words)); | ||
} |
{ | ||
"name": "@harmoniclabs/plutus-data", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "", | ||
@@ -38,3 +38,3 @@ "main": "./dist/index.js", | ||
"@harmoniclabs/biguint": "^1.0.0", | ||
"@harmoniclabs/crypto": "^0.2.0", | ||
"@harmoniclabs/crypto": "^0.2.4", | ||
"@harmoniclabs/uint8array-utils": "^1.0.0" | ||
@@ -41,0 +41,0 @@ }, |
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
38629
760
980
Updated@harmoniclabs/crypto@^0.2.4