@helios-lang/compiler
Advanced tools
Comparing version 0.17.0-78 to 0.17.0-79
{ | ||
"name": "@helios-lang/compiler", | ||
"version": "0.17.0-78", | ||
"version": "0.17.0-79", | ||
"description": "Helios is a Domain Specific Language that compiles to Plutus-Core (i.e. Cardano on-chain validator scripts). Helios is a non-Haskell alternative to Plutus. With this library you can compile Helios scripts and build Cardano transactions, all you need to build 100% client-side dApps for Cardano.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -237,3 +237,3 @@ /** | ||
const userFuncs = analyzeFunctions(moduleFunctions, validatorTypes) | ||
const userFuncs = analyzeFunctions(moduleFunctions, validatorTypes, false) | ||
@@ -281,3 +281,3 @@ // add main to the functions as well | ||
types: createTypeSchemas(moduleTypes), | ||
functions: analyzeFunctions(moduleFunctions, validatorTypes) | ||
functions: analyzeFunctions(moduleFunctions, validatorTypes, true) | ||
} | ||
@@ -377,5 +377,6 @@ } | ||
* @param {Record<string, ScriptHashType>} validatorTypes | ||
* @param {boolean} isInModule | ||
* @returns {Record<string, AnalyzedFunc>} | ||
*/ | ||
function analyzeFunctions(fns, validatorTypes) { | ||
function analyzeFunctions(fns, validatorTypes, isInModule) { | ||
return Object.fromEntries( | ||
@@ -386,3 +387,3 @@ Object.entries(fns).map(([key, fn]) => { | ||
validatorTypes, | ||
currentScriptValue: "#" | ||
currentScriptValue: "#" // Note: this is a garbage dummy value, the real values look like 'constrData(...)' | ||
}) | ||
@@ -394,3 +395,3 @@ | ||
name: key, | ||
requiresCurrentScript: requiresCurrentScript, | ||
requiresCurrentScript: isInModule && requiresCurrentScript, // UserFuncs in entry points always use the same fixed currentScript (i.e. the name of the validator) | ||
requiresScriptContext: requiresScriptContext, | ||
@@ -397,0 +398,0 @@ arguments: |
import { bytesToHex } from "@helios-lang/codec-utils" | ||
import { ErrorCollector, Source } from "@helios-lang/compiler-utils" | ||
import { SourceMappedString, compile as compileIR } from "@helios-lang/ir" | ||
import { isSome } from "@helios-lang/type-utils" | ||
import { expectSome, isSome } from "@helios-lang/type-utils" | ||
import { UplcProgramV2 } from "@helios-lang/uplc" | ||
@@ -323,2 +323,6 @@ import { ToIRContext, genExtraDefs } from "../codegen/index.js" | ||
if (!options.excludeUserFuncs.has(fullName)) { | ||
const currentScriptValue = | ||
moduleName == this.name && options.validatorIndices | ||
? `__core__constrData(${expectSome(options.validatorIndices[this.name])}, __core__mkNilData(()))` | ||
: undefined | ||
const uplc = fn | ||
@@ -329,3 +333,4 @@ .compile({ | ||
validatorTypes: this.props.validatorTypes ?? {}, | ||
validatorIndices: options.validatorIndices | ||
validatorIndices: options.validatorIndices, | ||
currentScriptValue | ||
}) | ||
@@ -337,3 +342,4 @@ .withAlt( | ||
validatorTypes: this.props.validatorTypes ?? {}, | ||
validatorIndices: options.validatorIndices | ||
validatorIndices: options.validatorIndices, | ||
currentScriptValue | ||
}) | ||
@@ -340,0 +346,0 @@ ) |
@@ -101,2 +101,3 @@ import { $, SourceMappedString, compile as compileIR } from "@helios-lang/ir" | ||
* hashDependencies: Record<string, string> | ||
* currentScriptValue?: string | ||
* }} props | ||
@@ -110,3 +111,4 @@ * @returns {UplcProgramV2} | ||
hashDependencies: props.hashDependencies, | ||
validatorIndices: props.validatorIndices | ||
validatorIndices: props.validatorIndices, | ||
currentScriptValue: props.currentScriptValue | ||
}) | ||
@@ -222,5 +224,7 @@ | ||
const requiresCurrentScript = ir.includes( | ||
"__helios__scriptcontext__current_script" | ||
) | ||
// if a non-dummy currentScriptValue was specified, then the IR won't depend on the currentScript | ||
const requiresCurrentScript = | ||
ir.includes("__helios__scriptcontext__current_script") && | ||
!(props.currentScriptValue && props.currentScriptValue.length > 1) | ||
const requiresScriptContext = ir.includes( | ||
@@ -227,0 +231,0 @@ "__helios__scriptcontext__data" |
@@ -1,1 +0,1 @@ | ||
export const VERSION = "0.17.0-78" | ||
export const VERSION = "0.17.0-79" |
@@ -39,2 +39,3 @@ /** | ||
* hashDependencies: Record<string, string> | ||
* currentScriptValue?: string | ||
* }} props | ||
@@ -48,2 +49,3 @@ * @returns {UplcProgramV2} | ||
hashDependencies: Record<string, string>; | ||
currentScriptValue?: string; | ||
}): UplcProgramV2; | ||
@@ -50,0 +52,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
export const VERSION: "0.17.0-78"; | ||
export const VERSION: "0.17.0-79"; | ||
//# sourceMappingURL=version.d.ts.map |
Sorry, the diff of this file is not supported yet
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
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
1422395
43501