feat(interop): introduce field-mask context for u5c (#502)

This commit is contained in:
Santiago Carmuega 2024-08-15 10:35:58 -03:00 committed by GitHub
parent 9020cc512b
commit 27c4967824
2 changed files with 12 additions and 0 deletions

View file

@ -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;
@ -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,
}
}
}