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(utxorpc): update spec to v0.14 and update redeemer mapper #559

Merged
merged 3 commits into from
Dec 14, 2024
Merged
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
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
Loading