feat(interop): introduce field-mask context for u5c (#502)
This commit is contained in:
parent
81390296a3
commit
c6621730eb
2 changed files with 12 additions and 0 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue