feat: move input from json to helper method

This commit is contained in:
rvcas
2022-09-24 19:40:07 -04:00
parent 3cb24a1d00
commit 8620332b75
5 changed files with 33 additions and 12 deletions

View File

@@ -20,16 +20,21 @@ pub enum Args {
pub enum TxCommand {
/// Simulate a transaction by evaluating it's script
Simulate {
/// A file containing cbor hex
input: PathBuf,
/// Toggle whether input is raw cbor or a hex string
#[clap(short, long)]
cbor: bool,
/// Json file containing resolved inputs
#[clap(short, long)]
resolved_inputs: PathBuf,
#[clap(short, long)]
slot_length: u64,
#[clap(short, long)]
#[clap(long)]
zero_time: u64,
#[clap(short, long)]
#[clap(long)]
zero_slot: u64,
},
}

View File

@@ -1,8 +1,4 @@
use std::{
fmt::Write as _,
fs::{self, File},
io::BufReader,
};
use std::{fmt::Write as _, fs};
use pallas_traverse::{Era, MultiEraTx};
use uplc::{
@@ -46,9 +42,7 @@ fn main() -> anyhow::Result<()> {
println!("Simulating: {}", tx.hash());
if let Some(tx_babbage) = tx.as_babbage() {
let file = File::open(&resolved_inputs)?;
let reader = BufReader::new(file);
let resolved_inputs: Vec<ResolvedInput> = serde_json::from_reader(reader)?;
let resolved_inputs = ResolvedInput::from_json(&resolved_inputs)?;
let slot_config = SlotConfig {
zero_time,