@harmoniclabs/uplc
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -11,3 +11,2 @@ "use strict"; | ||
var UPLCTerm_1 = require("../UPLCTerm/UPLCTerm.js"); | ||
var UPLCVersion_1 = require("../UPLCProgram/UPLCVersion.js"); | ||
var Application_1 = require("../UPLCTerms/Application.js"); | ||
@@ -231,2 +230,24 @@ var Builtin_1 = require("../UPLCTerms/Builtin/Builtin.js"); | ||
UPLCEncoder.prototype.encodeApplicationTerm = function (app) { | ||
// if can use case/constr terms | ||
if (this._ctx.is_v3_friendly) { | ||
var args = []; | ||
var term = app; | ||
while (term instanceof Application_1.Application) { | ||
// prepend element to keep same order | ||
args.unshift(term.argTerm); | ||
term = term.funcTerm; | ||
} | ||
// and we have more than 2 consecutive applications | ||
if (args.length > 2) { | ||
// use case and constr so that it costs | ||
// as much as only 2 applications | ||
return this.encodeCase(new Case_1.Case(new Constr_1.Constr(BigInt(0), args), | ||
// only one continutation; the last func term | ||
// (the one that expects the arguments) | ||
[term])); | ||
} | ||
// else continue with normal application encoding | ||
} | ||
// normal application encoding | ||
// always used in v1 and v2 | ||
var result = Application_1.Application.UPLCTag; | ||
@@ -463,4 +484,5 @@ this._ctx.incrementLengthBy(result.length); | ||
if (!this._ctx.is_v3_friendly) | ||
this._ctx.updateVersion(new UPLCVersion_1.UPLCVersion(1, 1, 0)); | ||
; | ||
throw new Error("'Constr' term found using UPLC version " + | ||
this._ctx.version.toString() + | ||
"; maybe you wanted to use version 1.1.0 or higher?"); | ||
var result = Constr_1.Constr.UPLCTag; | ||
@@ -474,4 +496,5 @@ result.append(serializeUInt(constr.index)); | ||
if (!this._ctx.is_v3_friendly) | ||
this._ctx.updateVersion(new UPLCVersion_1.UPLCVersion(1, 1, 0)); | ||
; | ||
throw new Error("'Case' term found using UPLC version " + | ||
this._ctx.version.toString() + | ||
"; maybe you wanted to use version 1.1.0 or higher?"); | ||
var result = Case_1.Case.UPLCTag; | ||
@@ -478,0 +501,0 @@ this._ctx.incrementLengthBy(result.length); |
@@ -7,4 +7,4 @@ import { BitStream } from "@harmoniclabs/bitstream"; | ||
terms: UPLCTerm[]; | ||
constructor(index: bigint, terms: UPLCTerm[]); | ||
constructor(index: bigint | number, terms: UPLCTerm[]); | ||
clone(): Constr; | ||
} |
@@ -7,3 +7,3 @@ "use strict"; | ||
function Constr(index, terms) { | ||
this.index = index; | ||
this.index = BigInt(index); | ||
this.terms = terms; | ||
@@ -10,0 +10,0 @@ } |
{ | ||
"name": "@harmoniclabs/uplc", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
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
238912
5082