@hyperionbt/helios-cli
Advanced tools
Comparing version 0.16.5 to 0.16.6
@@ -15,5 +15,5 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; | ||
const config = existsSync("./helios.config.json") ? | ||
JSON.parse(readFileSync("./helios.config.json").toString()) : | ||
{ stages: { main: {} } }; | ||
const bundle = await Bundle.initHere(config, options); | ||
JSON.parse(readFileSync("./helios.config.json").toString()) : (existsSync("./helios.config.js") ? | ||
await eval('import("./helios.config.js")') : | ||
{ stages: { main: {} } }); | ||
for (let key in config.stages) { | ||
@@ -25,2 +25,3 @@ const include = new Set(config.stages[key].include ?? []); | ||
} | ||
const bundle = await Bundle.initHere(config.stages[key]?.define ?? {}, options); | ||
const isIncluded = (name) => { | ||
@@ -44,3 +45,3 @@ if (include.size > 0) { | ||
const w = new Writer(); | ||
bundle.writeDefs(w, isIncluded); | ||
bundle.writeDefs(w, isIncluded, config.extraDatumTypes ?? {}); | ||
writeFileSync(`dist/${key}/index.js`, w.toString()); | ||
@@ -47,0 +48,0 @@ } |
@@ -12,3 +12,2 @@ import process from "node:process"; | ||
import { ModuleScript } from "./ModuleScript.js"; | ||
import { DEFAULT_CONFIG } from "./Config.js"; | ||
const RESERVED_ENDPOINTS = new Set([ | ||
@@ -27,6 +26,5 @@ "agent", | ||
#endpoints; | ||
#config; | ||
#options; | ||
#lock; // TODO: per-stage | ||
constructor(sources, validators, modules, endpoints, config, options) { | ||
constructor(sources, validators, modules, endpoints, options) { | ||
this.#sources = sources; | ||
@@ -36,10 +34,9 @@ this.#validators = validators; | ||
this.#endpoints = endpoints; | ||
this.#config = config; | ||
this.#options = options; | ||
this.#lock = existsSync("./helios-lock.json") ? JSON.parse(readFileSync("./helios-lock.json").toString()) : {}; | ||
} | ||
static async initHere(config = DEFAULT_CONFIG, options = { dumpIR: [] }) { | ||
return Bundle.init(process.cwd(), config, options); | ||
static async initHere(define = {}, options = { dumpIR: [] }) { | ||
return Bundle.init(process.cwd(), define, options); | ||
} | ||
static async init(dir, config, options) { | ||
static async init(dir, define, options) { | ||
heliosConfig.set({ | ||
@@ -73,3 +70,3 @@ CHECK_CASTS: true, | ||
case "staking": | ||
validators.add(new ValidatorScript(path, src, name, purpose)); | ||
validators.add(new ValidatorScript(path, src, name, purpose, define)); | ||
break; | ||
@@ -80,3 +77,3 @@ case "endpoint": | ||
} | ||
endpoints.add(new EndpointScript(path, src, name)); | ||
endpoints.add(new EndpointScript(path, src, name, define)); | ||
break; | ||
@@ -135,3 +132,3 @@ case "module": | ||
}); | ||
return new Bundle(sources, validators, modules, endpoints, config, options); | ||
return new Bundle(sources, validators, modules, endpoints, options); | ||
} | ||
@@ -198,3 +195,3 @@ generateDag() { | ||
} | ||
writeValidatorDefs(w, isIncluded) { | ||
writeValidatorDefs(w, isIncluded, extraDatumTypes) { | ||
w.write(`\nconst validators = {`); | ||
@@ -238,6 +235,4 @@ w.indent(); | ||
// add others | ||
if (this.#config.extraDatumTypes) { | ||
for (let datumType of (this.#config?.extraDatumTypes[v.name] ?? [])) { | ||
datumChecks.push(this.compileExtraDatumCheck(datumType)); | ||
} | ||
for (let datumType of (extraDatumTypes[v.name] ?? [])) { | ||
datumChecks.push(this.compileExtraDatumCheck(datumType)); | ||
} | ||
@@ -674,5 +669,5 @@ w.write(` | ||
} | ||
writeDefs(w, isIncluded) { | ||
writeDefs(w, isIncluded, extraDatumTypes) { | ||
this.writePreamble(w); | ||
this.writeValidatorDefs(w, isIncluded); | ||
this.writeValidatorDefs(w, isIncluded, extraDatumTypes); | ||
this.writeUnsimplifiedValidatorDefs(w, isIncluded); | ||
@@ -679,0 +674,0 @@ this.writeCodeMapSource(w, isIncluded); |
@@ -6,5 +6,7 @@ import { IR, IRProgram, Program, ToIRContext, bytesToHex } from "helios"; | ||
#program; | ||
constructor(path, src, name) { | ||
#define; | ||
constructor(path, src, name, define) { | ||
super(path, src, name); | ||
this.#program = null; | ||
this.#define = define; | ||
} | ||
@@ -14,2 +16,3 @@ get program() { | ||
this.#program = Program.newInternal(this.src, this.moduleSrcs, this.scriptTypes); | ||
this.#program.parameters = this.#define; | ||
} | ||
@@ -16,0 +19,0 @@ return this.#program; |
@@ -6,8 +6,10 @@ import { DatumRedeemerProgram, Program, ToIRContext, bytesToHex, IR, IRProgram, IRParametricProgram, MintingPolicyHashType, StakingValidatorHashType, ValidatorHashType } from "helios"; | ||
#program; | ||
#define; | ||
#validators; | ||
#dagDependencies; | ||
constructor(path, src, name, purpose) { | ||
constructor(path, src, name, purpose, define) { | ||
super(path, src, name); | ||
this.#purpose = purpose; | ||
this.#program = null; | ||
this.#define = define; | ||
this.#validators = null; | ||
@@ -32,2 +34,3 @@ this.#dagDependencies = new Set(); | ||
}); | ||
this.#program.parameters = this.#define; | ||
} | ||
@@ -34,0 +37,0 @@ return this.#program; |
@@ -15,3 +15,3 @@ #!/usr/bin/env node | ||
import genWalletPhrase from "./genWalletPhrase.js"; | ||
const VERSION = "0.16.5"; | ||
const VERSION = "0.16.6"; | ||
const USAGE = `Usage: | ||
@@ -18,0 +18,0 @@ helios [-h|--help] <command> <command-options> |
{ | ||
"name": "@hyperionbt/helios-cli", | ||
"version": "0.16.5", | ||
"version": "0.16.6", | ||
"description": "CLI tool for compiling Cardano smart contracts written in Helios, and building Cardano transactions.", | ||
@@ -22,3 +22,3 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"helios": "npm:@hyperionbt/helios@^0.16.5" | ||
"helios": "npm:@hyperionbt/helios@^0.16.6" | ||
}, | ||
@@ -25,0 +25,0 @@ "keywords": [], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
136971
2039
1