Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update utxorpc-spec version 0.14.0 and update redeemer mapper #557

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pallas-utxorpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ authors = ["Santiago Carmuega <[email protected]>"]

[dependencies]
# utxorpc-spec = { path = "../../../utxorpc/spec/gen/rust" }
utxorpc-spec = { version = "0.11.0" }
utxorpc-spec = { version = "0.14.0" }

pallas-traverse = { version = "=0.31.0", path = "../pallas-traverse" }
pallas-primitives = { version = "=0.31.0", path = "../pallas-primitives" }
Expand Down
17 changes: 16 additions & 1 deletion pallas-utxorpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{collections::HashMap, ops::Deref};

use pallas_codec::utils::KeyValuePairs;
use pallas_codec::{minicbor, utils::KeyValuePairs};
use pallas_crypto::hash::Hash;
use pallas_primitives::{alonzo, babbage, conway};
use pallas_traverse as trv;
Expand Down Expand Up @@ -62,9 +62,24 @@ impl<C: LedgerContext> Mapper<C> {
}

pub fn map_redeemer(&self, x: &trv::MultiEraRedeemer) -> u5c::Redeemer {
let cbor = match x {
trv::MultiEraRedeemer::AlonzoCompatible(_) => {
minicbor::to_vec(x.as_alonzo()).unwrap()
}
trv::MultiEraRedeemer::Conway(_,_) => {
minicbor::to_vec(x.as_conway()).unwrap()
}
_ => todo!(),
};
u5c::Redeemer {
purpose: self.map_purpose(&x.tag()).into(),
payload: self.map_plutus_datum(x.data()).into(),
index: x.index().into(),
ex_units: Some(u5c::ExUnits{
steps: x.ex_units().steps as u64,
memory: x.ex_units().mem as u64
}),
original_cbor: cbor.into()
}
}

Expand Down