Move UPLC dump into separate function + log event.

```
    Compiling aiken-lang/stdlib 43d8e740ffdf5febc59e51b7f0d5f8506115340c (examples/hello_world/build/packages/aiken-lang-stdlib)
    Compiling aiken-lang/hello_world 1.0.0 (examples/hello_world)
   Generating project's blueprint (examples/hello_world/plutus.json)
    Exporting UPLC (examples/hello_world/artifacts)
  ```
This commit is contained in:
KtorZ
2023-01-27 10:47:08 +01:00
parent b667b7f7b7
commit f8970ecb9e
4 changed files with 29 additions and 11 deletions

View File

@@ -184,6 +184,20 @@ where
self.compile(options)
}
pub fn dump_uplc(&self, blueprint: &Blueprint) -> Result<(), Error> {
let dir = self.root.join("artifacts");
self.event_listener
.handle_event(Event::DumpingUPLC { path: dir.clone() });
fs::create_dir_all(&dir)?;
for validator in &blueprint.validators {
// TODO: Also include validator name.
let path = dir.clone().join(format!("{}.uplc", validator.purpose));
fs::write(&path, validator.program.to_pretty())
.map_err(|error| Error::FileIo { error, path })?;
}
Ok(())
}
pub fn compile(&mut self, options: Options) -> Result<(), Error> {
self.compile_deps()?;
@@ -222,14 +236,7 @@ where
}
if uplc_dump {
let dir = self.root.join("artifacts");
fs::create_dir_all(&dir)?;
for validator in &blueprint.validators {
// TODO: Also include validator name.
let path = dir.clone().join(format!("{}.uplc", validator.purpose));
fs::write(&path, validator.program.to_pretty())
.map_err(|error| Error::FileIo { error, path })?;
}
self.dump_uplc(&blueprint)?;
}
let json = serde_json::to_string_pretty(&blueprint).unwrap();

View File

@@ -22,6 +22,9 @@ pub enum Event {
GeneratingBlueprint {
path: PathBuf,
},
DumpingUPLC {
path: PathBuf,
},
GeneratingUPLCFor {
name: String,
path: PathBuf,