Skip to content

Commit

Permalink
fix: Evaluate Tx records for metadata filters (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega authored Sep 3, 2022
1 parent 4de19ee commit 525f3d3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/filters/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ use serde::Deserialize;
use serde_json::Value as JsonValue;

use crate::{
model::{Event, EventData, MetadataRecord, MetadatumRendition, MintRecord, OutputAssetRecord, TxOutputRecord},
model::{
Event, EventData, MetadataRecord, MetadatumRendition, MintRecord, OutputAssetRecord,
TransactionRecord, TxOutputRecord,
},
pipelining::{new_inter_stage_channel, FilterProvider, PartialBootstrapResult, StageReceiver},
};

Expand Down Expand Up @@ -51,9 +54,7 @@ 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)
},
EventData::TxOutput(TxOutputRecord { address: x, .. }) => relaxed_str_matches(x, address),
_ => false,
}
}
Expand All @@ -70,6 +71,9 @@ fn asset_matches(event: &Event, asset: &str) -> bool {
#[inline]
fn metadata_label_matches(event: &Event, label: &str) -> bool {
match &event.data {
EventData::Transaction(TransactionRecord {
metadata: Some(x), ..
}) => x.iter().any(|r| relaxed_str_matches(&r.label, label)),
EventData::Metadata(MetadataRecord { label: x, .. }) => relaxed_str_matches(x, label),
_ => false,
}
Expand Down

0 comments on commit 525f3d3

Please sign in to comment.