Skip to content

Commit

Permalink
chore(utxorpc): update spec to v0.14 and update redeemer mapper (#559)
Browse files Browse the repository at this point in the history
Co-authored-by: ricomiles <[email protected]>
  • Loading branch information
scarmuega and ricomiles authored Dec 14, 2024
1 parent 2864ff4 commit 227b578
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pallas-traverse/src/redeemers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::borrow::Cow;

use pallas_codec::minicbor;
use pallas_primitives::{alonzo, conway};

use crate::MultiEraRedeemer;
Expand Down Expand Up @@ -78,4 +79,11 @@ impl<'b> MultiEraRedeemer<'b> {
})),
)
}

pub fn encode(&self) -> Vec<u8> {
match self {
MultiEraRedeemer::AlonzoCompatible(x) => minicbor::to_vec(x).unwrap(),
MultiEraRedeemer::Conway(k, v) => minicbor::to_vec((k, v)).unwrap(),
}
}
}
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
6 changes: 6 additions & 0 deletions pallas-utxorpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ impl<C: LedgerContext> Mapper<C> {
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,
memory: x.ex_units().mem,
}),
original_cbor: x.encode().into(),
}
}

Expand Down
34 changes: 34 additions & 0 deletions test_data/u5c1.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
"inputs": [
{
"redeemer": {
"exUnits": {
"memory": "2893153",
"steps": "1254988362"
},
"originalCbor": "hAAAGgAtxsCCGgAsJWEaSs2aSg==",
"payload": {
"bigInt": {
"int": "3000000"
Expand All @@ -33,6 +38,12 @@
},
{
"redeemer": {
"exUnits": {
"memory": "29039",
"steps": "9759373"
},
"index": 1,
"originalCbor": "hAAB2HmAghlxbxoAlOqN",
"payload": {
"constr": {
"tag": 121
Expand All @@ -45,6 +56,12 @@
{
"outputIndex": 2,
"redeemer": {
"exUnits": {
"memory": "23776",
"steps": "8949203"
},
"index": 2,
"originalCbor": "hAAC2HmAghlc4BoAiI3T",
"payload": {
"constr": {
"tag": 121
Expand Down Expand Up @@ -1384,6 +1401,12 @@
},
{
"redeemer": {
"exUnits": {
"memory": "862260",
"steps": "283080173"
},
"index": 1,
"originalCbor": "hAAB2HmAghoADSg0GhDfde0=",
"payload": {
"constr": {
"tag": 121
Expand Down Expand Up @@ -2018,6 +2041,12 @@
},
{
"redeemer": {
"exUnits": {
"memory": "312977",
"steps": "151500123"
},
"index": 1,
"originalCbor": "hAAB2HqfUCgL7p8Ifi1y1Y0n3fHPaAb/ghoABMaRGgkHtVs=",
"payload": {
"constr": {
"fields": [
Expand All @@ -2043,6 +2072,11 @@
],
"policyId": "J5+ELDPu2QVLnjxwzWo7MimCWcJLeLiVy0HZGg==",
"redeemer": {
"exUnits": {
"memory": "56931",
"steps": "22622736"
},
"originalCbor": "hAEA2HmAghneYxoBWTIQ",
"payload": {
"constr": {
"tag": 121
Expand Down

0 comments on commit 227b578

Please sign in to comment.