Skip to content

Commit

Permalink
feat(interop): introduce field-mask context for u5c
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega committed Aug 15, 2024
1 parent 3e2c657 commit b4243c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions pallas-utxorpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pallas-codec = { version = "=0.29.0", path = "../pallas-codec" }
pallas-crypto = { version = "=0.29.0", path = "../pallas-crypto" }

utxorpc-spec = { version = "0.8.0" }
prost-types = "0.13.1"

[dev-dependencies]
hex = "0.4.3"
Expand Down
11 changes: 11 additions & 0 deletions pallas-utxorpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use pallas_crypto::hash::Hash;
use pallas_primitives::{alonzo, babbage, conway};
use pallas_traverse as trv;

use prost_types::FieldMask;
use trv::OriginalHash;

pub use utxorpc_spec::utxorpc::v1alpha as spec;
Expand All @@ -25,12 +26,22 @@ pub trait LedgerContext: Clone {
#[derive(Default, Clone)]
pub struct Mapper<C: LedgerContext> {
ledger: Option<C>,
mask: FieldMask,
}

impl<C: LedgerContext> Mapper<C> {
pub fn new(ledger: C) -> Self {
Self {
ledger: Some(ledger),
mask: FieldMask { paths: vec![] },
}
}

/// Creates a clone of this mapper using a custom field mask
pub fn masked(&self, mask: FieldMask) -> Self {
Self {
ledger: self.ledger.clone(),
mask,
}
}
}
Expand Down

0 comments on commit b4243c6

Please sign in to comment.