feat(interop): introduce field-mask context for u5c (#502)
This commit is contained in:
parent
9020cc512b
commit
27c4967824
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" }
|
pallas-crypto = { version = "=0.29.0", path = "../pallas-crypto" }
|
||||||
|
|
||||||
utxorpc-spec = { version = "0.8.0" }
|
utxorpc-spec = { version = "0.8.0" }
|
||||||
|
prost-types = "0.13.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ use pallas_crypto::hash::Hash;
|
||||||
use pallas_primitives::{alonzo, babbage, conway};
|
use pallas_primitives::{alonzo, babbage, conway};
|
||||||
use pallas_traverse as trv;
|
use pallas_traverse as trv;
|
||||||
|
|
||||||
|
use prost_types::FieldMask;
|
||||||
use trv::OriginalHash;
|
use trv::OriginalHash;
|
||||||
|
|
||||||
pub use utxorpc_spec::utxorpc::v1alpha as spec;
|
pub use utxorpc_spec::utxorpc::v1alpha as spec;
|
||||||
|
|
@ -25,12 +26,22 @@ pub trait LedgerContext: Clone {
|
||||||
#[derive(Default, Clone)]
|
#[derive(Default, Clone)]
|
||||||
pub struct Mapper<C: LedgerContext> {
|
pub struct Mapper<C: LedgerContext> {
|
||||||
ledger: Option<C>,
|
ledger: Option<C>,
|
||||||
|
mask: FieldMask,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: LedgerContext> Mapper<C> {
|
impl<C: LedgerContext> Mapper<C> {
|
||||||
pub fn new(ledger: C) -> Self {
|
pub fn new(ledger: C) -> Self {
|
||||||
Self {
|
Self {
|
||||||
ledger: Some(ledger),
|
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