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

@@ -1,5 +1,5 @@
use crate::{
ast::{DeBruijn, FakeNamedDeBruijn, NamedDeBruijn, Program},
ast::{FakeNamedDeBruijn, NamedDeBruijn, Program},
machine::cost_model::ExBudget,
PlutusData,
};

View File

@@ -1,3 +1,5 @@
use std::{fs::File, io::BufReader, path::PathBuf};
use pallas_codec::utils::KeyValuePairs;
use pallas_crypto::hash::Hash;
use pallas_primitives::babbage::{
@@ -14,6 +16,26 @@ pub struct ResolvedInput {
pub output: TransactionOutput,
}
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("{0}")]
File(#[from] std::io::Error),
#[error("{0}")]
Serde(#[from] serde_json::error::Error),
}
impl ResolvedInput {
pub fn from_json(file: &PathBuf) -> Result<Vec<Self>, Error> {
let file = File::open(file)?;
let reader = BufReader::new(file);
let resolved_inputs: Vec<ResolvedInput> = serde_json::from_reader(reader)?;
Ok(resolved_inputs)
}
}
#[derive(Debug, PartialEq, Clone)]
pub struct TxInInfo {
pub out_ref: TransactionInput,

View File

@@ -43,7 +43,7 @@ pub trait ToPlutusData {
fn to_plutus_data(&self) -> PlutusData;
}
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct MintValue {
pub mint_value: Mint,
}