diff --git a/src/filters/selection.rs b/src/filters/selection.rs index a630cbea..ae0b1a3c 100644 --- a/src/filters/selection.rs +++ b/src/filters/selection.rs @@ -6,7 +6,7 @@ use serde::Deserialize; use serde_json::Value as JsonValue; use crate::{ - model::{Event, EventData, MetadataRecord, MetadatumRendition, MintRecord, OutputAssetRecord}, + model::{Event, EventData, MetadataRecord, MetadatumRendition, MintRecord, OutputAssetRecord, TxOutputRecord}, pipelining::{new_inter_stage_channel, FilterProvider, PartialBootstrapResult, StageReceiver}, }; @@ -17,6 +17,7 @@ pub enum Predicate { VariantNotIn(Vec), PolicyEquals(String), AssetEquals(String), + AddressEquals(String), MetadataLabelEquals(String), MetadataAnySubLabelEquals(String), Not(Box), @@ -47,6 +48,16 @@ fn policy_matches(event: &Event, policy: &str) -> bool { } } +#[inline] +fn address_matches(event: &Event, address: &str) -> bool { + match &event.data { + EventData::TxOutput(TxOutputRecord { address: x, .. }) => { + relaxed_str_matches(x, address) + }, + _ => false, + } +} + #[inline] fn asset_matches(event: &Event, asset: &str) -> bool { match &event.data { @@ -84,6 +95,7 @@ impl Predicate { Predicate::VariantIn(x) => variant_in_matches(event, x), Predicate::VariantNotIn(x) => !variant_in_matches(event, x), Predicate::PolicyEquals(x) => policy_matches(event, x), + Predicate::AddressEquals(x) => address_matches(event, x), Predicate::AssetEquals(x) => asset_matches(event, x), Predicate::MetadataLabelEquals(x) => metadata_label_matches(event, x), Predicate::MetadataAnySubLabelEquals(x) => metadata_any_sub_label_matches(event, x),