diff --git a/crates/torii/core/src/engine.rs b/crates/torii/core/src/engine.rs index d70c5a79c5..81f499f0ca 100644 --- a/crates/torii/core/src/engine.rs +++ b/crates/torii/core/src/engine.rs @@ -245,7 +245,9 @@ where ) -> Result<()> { self.db.store_event(event_id, event, invoke_receipt.transaction_hash); for processor in &self.processors.event { - if get_selector_from_name(&processor.event_key())? == event.keys[0] { + if get_selector_from_name(&processor.event_key())? == event.keys[0] + && processor.validate(event) + { processor .process(&self.world, self.db, block, invoke_receipt, event_id, event) .await?; diff --git a/crates/torii/core/src/processors/metadata_update.rs b/crates/torii/core/src/processors/metadata_update.rs index 2d1f7e5fa7..7ed9c3005d 100644 --- a/crates/torii/core/src/processors/metadata_update.rs +++ b/crates/torii/core/src/processors/metadata_update.rs @@ -21,6 +21,18 @@ where "MetadataUpdate".to_string() } + fn validate(&self, event: &Event) -> bool { + if event.keys.len() > 1 { + info!( + "invalid keys for event {}: {}", + >::event_key(self), + >::event_keys_as_string(self, event), + ); + return false; + } + true + } + async fn process( &self, _world: &WorldContractReader

, diff --git a/crates/torii/core/src/processors/mod.rs b/crates/torii/core/src/processors/mod.rs index 528076ad20..e8cb64da42 100644 --- a/crates/torii/core/src/processors/mod.rs +++ b/crates/torii/core/src/processors/mod.rs @@ -18,6 +18,12 @@ where { fn event_key(&self) -> String; + fn event_keys_as_string(&self, event: &Event) -> String { + event.keys.iter().map(|i| format!("{:#064x}", i)).collect::>().join(",") + } + + fn validate(&self, event: &Event) -> bool; + #[allow(clippy::too_many_arguments)] async fn process( &self, diff --git a/crates/torii/core/src/processors/register_model.rs b/crates/torii/core/src/processors/register_model.rs index 2b67fa0baa..2d63014c93 100644 --- a/crates/torii/core/src/processors/register_model.rs +++ b/crates/torii/core/src/processors/register_model.rs @@ -22,6 +22,18 @@ where "ModelRegistered".to_string() } + fn validate(&self, event: &Event) -> bool { + if event.keys.len() > 1 { + info!( + "invalid keys for event {}: {}", + >::event_key(self), + >::event_keys_as_string(self, event), + ); + return false; + } + true + } + async fn process( &self, world: &WorldContractReader

, diff --git a/crates/torii/core/src/processors/store_set_record.rs b/crates/torii/core/src/processors/store_set_record.rs index 9d59ef80fe..6c655eb37a 100644 --- a/crates/torii/core/src/processors/store_set_record.rs +++ b/crates/torii/core/src/processors/store_set_record.rs @@ -26,6 +26,18 @@ where "StoreSetRecord".to_string() } + fn validate(&self, event: &Event) -> bool { + if event.keys.len() > 1 { + info!( + "invalid keys for event {}: {}", + >::event_key(self), + >::event_keys_as_string(self, event), + ); + return false; + } + true + } + async fn process( &self, world: &WorldContractReader

,