Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@harmoniclabs/uplc

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harmoniclabs/uplc - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

dist/UPLCTerm/dataFromStringWithOffset.d.ts

2

dist/UPLCProgram/UPLCVersion.d.ts

@@ -12,2 +12,4 @@ import { CanBeUInteger } from "../utils/ints.js";

toString(): string;
static fromString(str: string): UPLCVersion;
}
export declare const defaultUplcVersion: UPLCVersion;
"use strict";
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UPLCVersion = void 0;
exports.defaultUplcVersion = exports.UPLCVersion = void 0;
var ints_1 = require("../utils/ints.js");

@@ -38,4 +54,9 @@ var UPLCVersion = /** @class */ (function () {

};
UPLCVersion.fromString = function (str) {
var _a = __read(str.split("."), 3), a = _a[0], b = _a[1], c = _a[2];
return new UPLCVersion(BigInt(a), BigInt(b), BigInt(c));
};
return UPLCVersion;
}());
exports.UPLCVersion = UPLCVersion;
exports.defaultUplcVersion = new UPLCVersion(1, 1, 0);

5

dist/UPLCTerm/parseUPLCText.d.ts
import { ConstType, ConstValue } from "../UPLCTerms/index.js";
import { UPLCTerm } from "./UPLCTerm.js";
import { UPLCVersion } from "../UPLCProgram/index.js";
type ParseUPLCTextEnv = {
[x: string]: number;
};
export declare function _parseUPLCText(str: string, env: ParseUPLCTextEnv, dbn: number): {
export declare function _parseUPLCText(str: string, env: ParseUPLCTextEnv, dbn: number, version: UPLCVersion): {
term: UPLCTerm;

@@ -18,3 +19,3 @@ offset: number;

};
export declare function parseUPLCText(str: string): UPLCTerm;
export declare function parseUPLCText(str: string, version?: UPLCVersion): UPLCTerm;
/**

@@ -21,0 +22,0 @@ *

@@ -21,3 +21,8 @@ "use strict";

var uint8array_utils_1 = require("@harmoniclabs/uint8array-utils");
function _parseUPLCText(str, env, dbn) {
var indexOfNextCommaOutsideParentesis_1 = require("../utils/indexOfNextCommaOutsideParentesis.js");
var indexOfNextUnmatchedParentesis_1 = require("../utils/indexOfNextUnmatchedParentesis.js");
var getTextBetweenMatchingQuotes_1 = require("../utils/getTextBetweenMatchingQuotes.js");
var indexOfMany_1 = require("../utils/indexOfMany.js");
var UPLCProgram_1 = require("../UPLCProgram/index.js");
function _parseUPLCText(str, env, dbn, version) {
// clone (other branches migh modify vars dbns)

@@ -38,9 +43,5 @@ env = __assign({}, env);

if (s === void 0) { s = str; }
var fstSpaceIdx = s.indexOf(" ");
if (fstSpaceIdx < 0) {
fstSpaceIdx = s.indexOf("\n");
if (fstSpaceIdx < 0) {
fstSpaceIdx = str.length - 1;
}
}
var fstSpaceIdx = s.search(/\s/);
if (fstSpaceIdx < 0)
fstSpaceIdx = str.length - 1;
var varName = s.slice(0, fstSpaceIdx).trim();

@@ -50,4 +51,5 @@ while (varName.endsWith(")") ||

varName.endsWith(" ") ||
varName.endsWith("\n"))
varName.endsWith("\n")) {
varName = varName.slice(0, varName.length - 1);
}
return varName;

@@ -61,5 +63,5 @@ };

offset += getOffsetToNextClosingBracket(str, "[", "]");
var fn = _parseUPLCText(str, env, dbn);
var fn = _parseUPLCText(str, env, dbn, version);
str = str.slice(fn.offset + 1);
var arg = _parseUPLCText(str, env, dbn);
var arg = _parseUPLCText(str, env, dbn, version);
return {

@@ -72,4 +74,4 @@ term: new UPLCTerms_1.Application(fn.term, arg.term),

sliceTrimIncr(1);
offset += getOffsetToNextClosingBracket(str, "(", ")");
if (str.startsWith("error")) {
offset += getOffsetToNextClosingBracket(str, "(", ")");
return {

@@ -81,4 +83,5 @@ term: new UPLCTerms_1.ErrorUPLC(),

if (str.startsWith("delay")) {
offset += getOffsetToNextClosingBracket(str, "(", ")");
return {
term: new UPLCTerms_1.Delay(_parseUPLCText(str.slice(5), env, dbn).term),
term: new UPLCTerms_1.Delay(_parseUPLCText(str.slice(5), env, dbn, version).term),
offset: offset

@@ -88,3 +91,4 @@ };

if (str.startsWith("force")) {
var directChild = _parseUPLCText(str.slice(5), env, dbn).term;
offset += getOffsetToNextClosingBracket(str, "(", ")");
var directChild = _parseUPLCText(str.slice(5), env, dbn, version).term;
if (directChild instanceof UPLCTerms_1.Builtin &&

@@ -109,2 +113,3 @@ (0, UPLCTerms_1.getNRequiredForces)(directChild.tag) === 1)

if (str.startsWith("builtin")) {
offset += getOffsetToNextClosingBracket(str, "(", ")");
str = str.slice(7).trimStart();

@@ -117,2 +122,3 @@ return {

if (str.startsWith("lam")) {
offset += getOffsetToNextClosingBracket(str, "(", ")");
str = str.slice(3).trimStart();

@@ -123,11 +129,55 @@ var varName_1 = getNextWord();

return {
term: new UPLCTerms_1.Lambda(_parseUPLCText(str, env, dbn + 1).term),
term: new UPLCTerms_1.Lambda(_parseUPLCText(str, env, dbn + 1, version).term),
offset: offset
};
}
if (str.startsWith("case")) {
if (!version.isV3Friendly())
throw new Error("case uplc node found on program version: " + version.toString());
sliceTrimIncr(4);
var closeIdx = (0, indexOfNextUnmatchedParentesis_1.indexOfNextUnmatchedParentesis)(str);
str = str.slice(0, closeIdx).trim();
var terms = [];
while (str.length > 0) {
var _a = _parseUPLCText(str, env, dbn, version), term = _a.term, offset_1 = _a.offset;
terms.push(term);
str = str.slice(offset_1).trim();
}
if (terms.length < 1)
throw new Error("ill formed uplc, missing constr term on case");
return {
term: new UPLCTerms_1.Case(terms.shift(), terms),
offset: offset + closeIdx + 1
};
}
// "constr" MUST BE before "con"
if (str.startsWith("constr")) {
if (!version.isV3Friendly())
throw new Error("case uplc node found on program version: " + version.toString());
sliceTrimIncr(6);
var closeIdx = (0, indexOfNextUnmatchedParentesis_1.indexOfNextUnmatchedParentesis)(str);
str = str.slice(0, closeIdx);
var _b = parseConstValueOfType(str, UPLCTerms_1.constT.int), idx = _b.value, idxOffset = _b.offset;
str = str.slice(idxOffset);
if (typeof idx !== "bigint")
throw new Error("ill formed uplc; constr expects u64 index");
var terms = [];
str = str.trim();
while (str.length > 0) {
var _c = _parseUPLCText(str, env, dbn, version), term = _c.term, offset_2 = _c.offset;
terms.push(term);
str = str.slice(offset_2).trim();
}
return {
term: new UPLCTerms_1.Constr(idx, terms),
offset: offset + closeIdx + 1
};
}
if (str.startsWith("con")) {
sliceTrimIncr(3);
offset += getOffsetToNextClosingBracket(str, "(", ")");
str = str.slice(3).trimStart();
var t = parseConstType(str);
sliceTrimIncr(t.offset);
str = str.slice(t.offset).trimStart();
var v = parseConstValueOfType(str, t.type);
str = str.slice(v.offset).trimStart();
return {

@@ -152,3 +202,4 @@ term: new UPLCTerms_1.UPLCConst(t.type, v.value),

// console.log( env, `"${varName}"`, Object.keys( env )[0] === varName )
throwIllFormed();
// throwIllFormed();
throw new Error("unbound variable found");
}

@@ -165,2 +216,5 @@ return {

}
function isLowestNonNegative(a, b) {
return a >= 0 && (b < 0 || a < b);
}
function parseConstValueOfType(str, t) {

@@ -183,5 +237,16 @@ var offset = 0;

if ((0, UPLCTerms_1.constTypeEq)(t, UPLCTerms_1.constT.int)) {
var endInteger = str.indexOf(" ");
var value = parseInt(str.slice(0, endInteger));
sliceTrimIncr(endInteger + 1);
var closeIndex = str.indexOf(")");
var regExpRes = str
.slice(0, closeIndex < 0 ? undefined : closeIndex)
// \+?\-? -> 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(/\+?\-?(?<!\.)(?<!(#|x)\d*)\d+(?!(\.|x))/);
if (regExpRes === null)
throw new Error("could not find integer for constant uplc");
var nStr = regExpRes[0];
var value = BigInt(nStr);
sliceTrimIncr(str.indexOf(nStr) + nStr.length);
return {

@@ -193,6 +258,10 @@ value: value,

if ((0, UPLCTerms_1.constTypeEq)(t, UPLCTerms_1.constT.str)) {
sliceTrimIncr(str.indexOf('"') + 1);
var closingQuoteIdx = str.indexOf('"');
var value = str.slice(0, closingQuoteIdx);
sliceTrimIncr(closingQuoteIdx + 1);
var quoteIdx = str.indexOf('"');
if (!/^\s*$/.test(str.slice(0, quoteIdx)))
throw new Error("ill formed uplc");
sliceTrimIncr(quoteIdx);
var value = (0, getTextBetweenMatchingQuotes_1.getTextBetweenMatchingQuotes)(str);
if (typeof value !== "string")
throw new Error("missing constant string value");
sliceTrimIncr(value.length + 2);
return {

@@ -204,8 +273,21 @@ value: value,

if ((0, UPLCTerms_1.constTypeEq)(t, UPLCTerms_1.constT.bool)) {
var value = str.startsWith("True") ? true : false;
sliceTrimIncr(value ? 4 : 5);
return {
value: value,
offset: offset
};
var trueIdx = str.indexOf("True");
var falseIdx = str.indexOf("False");
if (trueIdx < 0 && falseIdx < 0)
throw new Error("expected boolean value; found none");
var isTrue = isLowestNonNegative(trueIdx, falseIdx);
if (isTrue) {
sliceTrimIncr(trueIdx + 4);
return {
value: true,
offset: offset
};
}
else {
sliceTrimIncr(falseIdx + 5);
return {
value: false,
offset: offset
};
}
}

@@ -215,9 +297,10 @@ if ((0, UPLCTerms_1.constTypeEq)(t, UPLCTerms_1.constT.byteStr)) {

var i = 0;
while (isHexChar(str[i++]))
while (i < str.length && isHexChar(str[i++]))
;
i--; // last char is not hex
!isHexChar(str[i - 1]) && i--;
var hex = str.slice(0, i);
// we can handle it but plutus conformance doesn't allow it
if (hex.length % 2 === 1)
throw new Error("invalid bytestring value");
if (hex.length % 2 === 1) {
throw new Error("invalid bytestring value: received: " + hex);
}
sliceTrimIncr(i);

@@ -230,11 +313,7 @@ return {

if ((0, UPLCTerms_1.constTypeEq)(t, UPLCTerms_1.constT.data)) {
sliceTrimIncr(str.indexOf("#") + 1);
var i = 0;
while (isHexChar(str[i++]))
;
i--; // last char is not hex
var hex = str.slice(0, i);
sliceTrimIncr(i);
sliceTrimIncr(0);
var _a = (0, plutus_data_1.dataFromStringWithOffset)(str), data = _a.data, dataOffset = _a.offset;
offset += dataOffset;
return {
value: (0, plutus_data_1.dataFromCbor)(hex),
value: data,
offset: offset

@@ -244,13 +323,19 @@ };

if ((0, UPLCTerms_1.constTypeEq)(t, UPLCTerms_1.constT.bls12_381_G1_element)) {
sliceTrimIncr(str.indexOf("0x") + 2);
var value = (0, crypto_1.bls12_381_G1_uncompress)((0, uint8array_utils_1.fromHex)(str.slice(0, 96) // 48 bytes; 96 hex chars
));
sliceTrimIncr(96);
var original = str;
str = str.slice(0, str.indexOf(")") + 1).trimStart();
offset += (original.length - original.indexOf(str)) + 2 /*0x*/ + 96;
var match = str.match(/^0x[0-9a-fA-F]{96}(?![0-9a-fA-F]+)/); // 48 bytes; 96 hex chars
if (!match)
throw new Error("missing bls g1 compressed elem");
var value = (0, crypto_1.bls12_381_G1_uncompress)((0, uint8array_utils_1.fromHex)(match[0].slice(2)));
return { value: value, offset: offset };
}
if ((0, UPLCTerms_1.constTypeEq)(t, UPLCTerms_1.constT.bls12_381_G2_element)) {
sliceTrimIncr(str.indexOf("0x") + 2);
var value = (0, crypto_1.bls12_381_G2_uncompress)((0, uint8array_utils_1.fromHex)(str.slice(0, 192) // 96 bytes; 192 hex chars
));
sliceTrimIncr(192);
var original = str;
str = str.slice(0, str.indexOf(")") + 1).trimStart();
offset += (original.length - original.indexOf(str)) + 2 /*0x*/ + 192;
var match = str.match(/^0x[0-9a-fA-F]{192}(?![0-9a-fA-F]+)/); // 96 bytes; 192 hex chars
if (!match)
throw new Error("missing bls g2 compressed elem");
var value = (0, crypto_1.bls12_381_G2_uncompress)((0, uint8array_utils_1.fromHex)(match[0].slice(2)));
return { value: value, offset: offset };

@@ -263,8 +348,8 @@ }

sliceTrimIncr(str.indexOf("(") + 1);
var fst = parseConstValueOfType(str, UPLCTerms_1.constPairTypeUtils.getFirstTypeArgument(t));
sliceTrimIncr(fst.offset);
sliceTrimIncr(str.indexOf(",") + 1);
var snd = parseConstValueOfType(str, UPLCTerms_1.constPairTypeUtils.getSecondTypeArgument(t));
sliceTrimIncr(snd.offset);
sliceTrimIncr(str.indexOf(")") + 1);
var commaIdx = (0, indexOfNextCommaOutsideParentesis_1.indexOfNextCommaOutsideParentesis)(str);
var fst = parseConstValueOfType(str.slice(0, commaIdx), UPLCTerms_1.constPairTypeUtils.getFirstTypeArgument(t));
sliceTrimIncr(commaIdx + 1);
var closeIdx = (0, indexOfNextUnmatchedParentesis_1.indexOfNextUnmatchedParentesis)(str);
var snd = parseConstValueOfType(str.slice(0, closeIdx), UPLCTerms_1.constPairTypeUtils.getSecondTypeArgument(t));
sliceTrimIncr(closeIdx + 1);
return {

@@ -363,46 +448,60 @@ value: new pair_1.Pair(fst.value, snd.value),

throw new Error("bls12_381_MlResult const not supported in textual UPLC");
if (str.startsWith("list")) {
var fstValidIndex = str.indexOf("(") + 1;
if (fstValidIndex < 1)
throw new Error("invalid uplc contant type");
sliceTrimIncr(fstValidIndex);
var elems = parseConstType(str);
sliceTrimIncr(elems.offset);
while (!str.startsWith(")"))
sliceTrimIncr(1);
if (str.startsWith("(")) {
sliceTrimIncr(1);
return {
type: UPLCTerms_1.constT.listOf(elems.type),
offset: offset
};
}
if (str.startsWith("pair")) {
var fstValidIndex = str.indexOf("(") + 1;
if (fstValidIndex < 1)
throw new Error("invalid uplc contant type");
sliceTrimIncr(fstValidIndex);
var fst = parseConstType(str);
sliceTrimIncr(fst.offset);
while (str.startsWith(",") ||
str.startsWith(" ") ||
str.startsWith("\n"))
var listIdx = str.indexOf("list");
var pairIdx = str.indexOf("pair");
if (listIdx < 0 && pairIdx < 0)
throw new Error("invalid constant type; expected list or pair");
var isList = isLowestNonNegative(listIdx, pairIdx);
var isPair = isLowestNonNegative(pairIdx, listIdx);
if (isList) {
sliceTrimIncr(listIdx + 4);
var elems = parseConstType(str);
sliceTrimIncr(elems.offset);
while (!str.startsWith(")"))
sliceTrimIncr(1);
sliceTrimIncr(1);
var snd = parseConstType(str);
sliceTrimIncr(snd.offset);
while (!str.startsWith(")"))
return {
type: UPLCTerms_1.constT.listOf(elems.type),
offset: offset
};
}
else if (isPair) {
sliceTrimIncr(pairIdx + 4);
var fst = parseConstType(str);
sliceTrimIncr(fst.offset);
while (str.startsWith(" ") ||
str.startsWith("\n"))
sliceTrimIncr(1);
var snd = parseConstType(str);
sliceTrimIncr(snd.offset);
while (!str.startsWith(")"))
sliceTrimIncr(1);
sliceTrimIncr(1);
sliceTrimIncr(1);
return {
type: UPLCTerms_1.constT.pairOf(fst.type, snd.type),
offset: offset
};
return {
type: UPLCTerms_1.constT.pairOf(fst.type, snd.type),
offset: offset
};
}
else {
console.log(str, listIdx, pairIdx);
throw new Error("invalid constant type; missing list or pair");
}
}
throw new Error("unknown UPLC const type");
throw new Error("unknown UPLC const type; src: " + str);
}
exports.parseConstType = parseConstType;
function parseUPLCText(str) {
function parseUPLCText(str, version) {
if (version === void 0) { version = UPLCProgram_1.defaultUplcVersion; }
str = str.trim();
if (str.startsWith("(program"))
str = str.slice(str.indexOf("(", 1), str.length - 1);
return _parseUPLCText(str, {}, 0).term;
if (str.startsWith("(program")) {
str = str.slice(8, str.lastIndexOf(")")).trim();
var verStr = str.match(/^\d+\.\d+\.\d+(?!\.)/);
if (!verStr)
throw new Error("uplc program without version");
version = UPLCProgram_1.UPLCVersion.fromString(verStr[0]);
str = str.slice((0, indexOfMany_1.indexOfMany)(str, "(", "["));
}
version = version instanceof UPLCProgram_1.UPLCVersion ? version : UPLCProgram_1.defaultUplcVersion;
return _parseUPLCText(str, {}, 0, version).term;
}

@@ -441,1 +540,20 @@ exports.parseUPLCText = parseUPLCText;

exports.getOffsetToNextClosingBracket = getOffsetToNextClosingBracket;
// we have `dataFromString` from "@harmoniclabs/plutus-data"
// but no way to reliably retreive the offset
// seo
function myDataFromStringWithOffset(str) {
var original = str;
var openIdx = str.indexOf("(");
if (openIdx < 0)
throw new Error("missign opening wrapping parentesis for data");
str = str.slice(openIdx + 1);
var offset = original.length - str.length;
var closeIdx = (0, indexOfNextUnmatchedParentesis_1.indexOfNextUnmatchedParentesis)(str);
if (closeIdx < 0)
throw new Error("missign closing wrapping parentesis for data");
offset += closeIdx + 1;
return {
data: (0, plutus_data_1.dataFromString)(str.slice(0, closeIdx).trim()),
offset: offset
};
}

@@ -56,1 +56,2 @@ import { UPLCVar } from "../UPLCTerms/UPLCVar/index.js";

export declare function getUPLCVarRefsInTerm(term: UPLCTerm, varDeBruijn?: number | bigint): number;
export declare function eqUPLCTerm(a: UPLCTerm, b: UPLCTerm): boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUPLCVarRefsInTerm = exports.hasMultipleRefsInTerm = exports.hasAnyRefsInTerm = exports.prettyUPLC = exports.showUPLC = exports.showConstType = exports.showUPLCConstValue = exports.isClosedTerm = exports.isPureUPLCTerm = exports.isUPLCTerm = void 0;
exports.eqUPLCTerm = exports.getUPLCVarRefsInTerm = exports.hasMultipleRefsInTerm = exports.hasAnyRefsInTerm = exports.prettyUPLC = exports.showUPLC = exports.showConstType = exports.showUPLCConstValue = exports.isClosedTerm = exports.isPureUPLCTerm = exports.isUPLCTerm = void 0;
var UPLCVar_1 = require("../UPLCTerms/UPLCVar/index.js");

@@ -123,3 +123,3 @@ var Delay_1 = require("../UPLCTerms/Delay.js");

if ((0, plutus_data_1.isData)(v))
return "#" + (0, plutus_data_1.dataToCbor)(v).toString();
return v.toString();
if ((0, crypto_1.isBlsG1)(v))

@@ -140,6 +140,6 @@ return "0x".concat((0, uint8array_utils_1.toHex)((0, crypto_1.bls12_381_G1_compress)(v)));

if (t[0] === ConstType_1.ConstTyTag.list) {
return "list( ".concat(showConstType(ConstType_1.constListTypeUtils.getTypeArgument(t)), " )");
return "(list ".concat(showConstType(ConstType_1.constListTypeUtils.getTypeArgument(t)), ")");
}
if (t[0] === ConstType_1.ConstTyTag.pair) {
return "pair( ".concat(showConstType(ConstType_1.constPairTypeUtils.getFirstTypeArgument(t)), ", ").concat(showConstType(ConstType_1.constPairTypeUtils.getSecondTypeArgument(t)), " )");
return "(pair ".concat(showConstType(ConstType_1.constPairTypeUtils.getFirstTypeArgument(t)), " ").concat(showConstType(ConstType_1.constPairTypeUtils.getSecondTypeArgument(t)), ")");
}

@@ -179,6 +179,6 @@ return (0, ConstType_1.constTypeToStirng)(t);

if (t instanceof Constr_1.Constr) {
return "(constr " + t.index.toString() + " [" + t.terms.map(function (term) { return _showUPLC(term, dbn); }).join(",") + "])";
return "(constr " + t.index.toString() + " " + t.terms.map(function (term) { return _showUPLC(term, dbn); }).join(" ") + ")";
}
if (t instanceof Case_1.Case) {
return "(case " + _showUPLC(t.constrTerm, dbn) + " [" + t.continuations.map(function (term) { return _showUPLC(term, dbn); }).join(",") + "])";
return "(case " + _showUPLC(t.constrTerm, dbn) + " " + t.continuations.map(function (term) { return _showUPLC(term, dbn); }).join(" ") + ")";
}

@@ -359,1 +359,43 @@ return "";

}
// type UPLCTerm = UPLCVar | Delay | Lambda | Application | UPLCConst | Force | ErrorUPLC | Builtin | Constr | Case;
function eqUPLCTerm(a, b) {
if (a instanceof ErrorUPLC_1.ErrorUPLC)
return b instanceof ErrorUPLC_1.ErrorUPLC;
if (a instanceof UPLCVar_1.UPLCVar && b instanceof UPLCVar_1.UPLCVar)
return a.deBruijn === b.deBruijn;
if (a instanceof Delay_1.Delay && b instanceof Delay_1.Delay)
return eqUPLCTerm(a.delayedTerm, b.delayedTerm);
if (a instanceof Lambda_1.Lambda && b instanceof Lambda_1.Lambda)
return eqUPLCTerm(a.body, b.body);
if (a instanceof Application_1.Application && b instanceof Application_1.Application)
return (eqUPLCTerm(a.argTerm, b.argTerm) &&
eqUPLCTerm(a.funcTerm, b.funcTerm));
if (a instanceof UPLCConst_1.UPLCConst && b instanceof UPLCConst_1.UPLCConst)
return ((0, ConstType_1.constTypeEq)(a.type, b.type) &&
(0, ConstValue_1.canConstValueBeOfConstType)(a.value, a.type) &&
(0, ConstValue_1.canConstValueBeOfConstType)(b.value, b.type) &&
(function () {
try {
return (0, ConstValue_1.eqConstValue)(a.value, b.value);
}
catch (e) {
if (e instanceof RangeError)
return false;
throw e;
}
})());
if (a instanceof Force_1.Force && b instanceof Force_1.Force)
return eqUPLCTerm(a.termToForce, b.termToForce);
if (a instanceof Builtin_1.Builtin && b instanceof Builtin_1.Builtin)
return a.tag === b.tag;
if (a instanceof Constr_1.Constr && b instanceof Constr_1.Constr)
return (a.index === b.index &&
a.terms.length === b.terms.length &&
a.terms.every(function (t, i) { return eqUPLCTerm(t, b.terms[i]); }));
if (a instanceof Case_1.Case && b instanceof Case_1.Case)
return (eqUPLCTerm(a.constrTerm, b.constrTerm) &&
a.continuations.length === b.continuations.length &&
a.continuations.every(function (t, i) { return eqUPLCTerm(t, b.continuations[i]); }));
return false;
}
exports.eqUPLCTerm = eqUPLCTerm;

@@ -152,3 +152,3 @@ "use strict";

case UPLCBuiltinTag.lessThanInteger: return "lessThanInteger";
case UPLCBuiltinTag.lessThanEqualInteger: return "lessThanEqualInteger";
case UPLCBuiltinTag.lessThanEqualInteger: return "lessThanEqualsInteger";
case UPLCBuiltinTag.appendByteString: return "appendByteString";

@@ -226,3 +226,3 @@ case UPLCBuiltinTag.consByteString: return "consByteString";

function builtinTagFromString(tag) {
switch (tag) {
switch (tag.trim()) {
case "addInteger": return UPLCBuiltinTag.addInteger;

@@ -238,2 +238,3 @@ case "subtractInteger": return UPLCBuiltinTag.subtractInteger;

case "lessThanEqualInteger": return UPLCBuiltinTag.lessThanEqualInteger;
case "lessThanEqualsInteger": return UPLCBuiltinTag.lessThanEqualInteger;
case "appendByteString": return UPLCBuiltinTag.appendByteString;

@@ -302,2 +303,4 @@ case "consByteString": return UPLCBuiltinTag.consByteString;

case "blake2b_224": return UPLCBuiltinTag.blake2b_224;
case "integerToByteString": return UPLCBuiltinTag.integerToByteString;
case "byteStringToInteger": return UPLCBuiltinTag.byteStringToInteger;
default:

@@ -304,0 +307,0 @@ // tag; // check that is of type 'never'

{
"name": "@harmoniclabs/uplc",
"version": "1.2.2",
"version": "1.2.3",
"description": "",

@@ -43,5 +43,5 @@ "main": "./dist/index.js",

"@harmoniclabs/cbor": "^1.3.0",
"@harmoniclabs/crypto": "^0.2.3",
"@harmoniclabs/crypto": "^0.2.4",
"@harmoniclabs/pair": "^1.0.0",
"@harmoniclabs/plutus-data": "^1.2.0"
"@harmoniclabs/plutus-data": "^1.2.4"
},

@@ -48,0 +48,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc