openzeppelin_monitor::services::filter

Function handle_match

Source
pub async fn handle_match<T: TriggerExecutionServiceTrait>(
    matching_monitor: MonitorMatch,
    trigger_service: &T,
    trigger_scripts: &HashMap<String, (ScriptLanguage, String)>,
) -> Result<(), FilterError>
Expand description

Process a monitor match by executing associated triggers.

Takes a matched monitor event and processes it through the appropriate trigger service. Converts blockchain-specific data into a standardized format that can be used in trigger templates.

§Arguments

  • matching_monitor - The matched monitor event containing transaction and trigger information
  • trigger_service - Service responsible for executing triggers
  • trigger_scripts - Scripts to be executed for each trigger

§Returns

Result indicating success or failure of trigger execution

§Example

The function converts blockchain data into template variables like:

"monitor.name": "Transfer USDT Token"
"transaction.hash": "0x99139c8f64b9b939678e261e1553660b502d9fd01c2ab1516e699ee6c8cc5791"
"transaction.from": "0xf401346fd255e034a2e43151efe1d68c1e0f8ca5"
"transaction.to": "0x0000000000001ff3684f28c67538d4d072c22734"
"transaction.value": "24504000000000000"
"events.0.signature": "Transfer(address,address,uint256)"
"events.0.args.to": "0x70bf6634ee8cb27d04478f184b9b8bb13e5f4710"
"events.0.args.from": "0x2e8135be71230c6b1b4045696d41c09db0414226"
"events.0.args.value": "88248701"