fix: constr issue

- also fixed constant parsing
- added new cbor flag to eval

Co-authored-by: rvcas <x@rvcas.dev>
This commit is contained in:
Kasey White
2022-12-05 22:46:33 -05:00
committed by Lucas
parent 7875af7d35
commit 3f47a1f4b8
16 changed files with 155 additions and 329 deletions

View File

@@ -14,12 +14,31 @@ pub struct Args {
#[clap(short, long)]
flat: bool,
#[clap(short, long)]
cbor: bool,
/// Arguments to pass to the uplc program
args: Vec<String>,
}
pub fn exec(Args { script, flat, args }: Args) -> miette::Result<()> {
let mut program = if flat {
pub fn exec(
Args {
script,
flat,
args,
cbor,
}: Args,
) -> miette::Result<()> {
let mut program = if cbor {
let cbor_hex = std::fs::read_to_string(&script).into_diagnostic()?;
let raw_cbor = hex::decode(&cbor_hex).into_diagnostic()?;
let prog = Program::<FakeNamedDeBruijn>::from_cbor(&raw_cbor, &mut Vec::new())
.into_diagnostic()?;
prog.into()
} else if flat {
let bytes = std::fs::read(&script).into_diagnostic()?;
let prog = Program::<FakeNamedDeBruijn>::from_flat(&bytes).into_diagnostic()?;

View File

@@ -33,6 +33,7 @@ where
miette::bail!("failed: {} error(s), {warning_count} warning(s)", err.len(),);
};
println!("finished with {warning_count} warning(s)");
println!("\nfinished with {warning_count} warning(s)\n");
Ok(())
}