openzeppelin_monitor/models/blockchain/mod.rs
1//! Blockchain-specific model implementations.
2//!
3//! This module contains type definitions and implementations for different
4//! blockchain platforms (EVM, Stellar, etc). Each submodule implements the
5//! platform-specific logic for blocks, transactions, and event monitoring.
6
7use serde::{Deserialize, Serialize};
8
9pub mod evm;
10pub mod stellar;
11
12/// Supported blockchain platform types
13#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
14#[serde(deny_unknown_fields)]
15pub enum BlockChainType {
16 /// Ethereum Virtual Machine based chains
17 EVM,
18 /// Stellar blockchain
19 Stellar,
20 /// Midnight blockchain (not yet implemented)
21 Midnight,
22 /// Solana blockchain (not yet implemented)
23 Solana,
24}
25
26/// Block data from different blockchain platforms
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub enum BlockType {
29 /// EVM block and transaction data
30 ///
31 /// # Note
32 /// Box is used here to equalize the enum variants
33 EVM(Box<evm::EVMBlock>),
34 /// Stellar ledger and transaction data
35 ///
36 /// # Note
37 /// Box is used here to equalize the enum variants
38 Stellar(Box<stellar::StellarBlock>),
39}
40
41impl BlockType {
42 pub fn number(&self) -> Option<u64> {
43 match self {
44 BlockType::EVM(b) => b.number(),
45 BlockType::Stellar(b) => b.number(),
46 }
47 }
48}
49
50/// Transaction data from different blockchain platforms
51#[derive(Debug, Clone, Serialize, Deserialize)]
52pub enum TransactionType {
53 /// EVM transaction
54 EVM(evm::EVMTransaction),
55 /// Stellar transaction
56 Stellar(Box<stellar::StellarTransaction>),
57}
58
59/// Contract spec from different blockchain platforms
60#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
61#[serde(untagged)]
62pub enum ContractSpec {
63 /// EVM contract spec
64 EVM(evm::EVMContractSpec),
65 /// Stellar contract spec
66 Stellar(stellar::StellarContractSpec),
67}
68
69/// Monitor match results from different blockchain platforms
70#[derive(Debug, Clone, Serialize, Deserialize)]
71pub enum MonitorMatch {
72 /// Matched conditions from EVM chains
73 ///
74 /// # Note
75 /// Box is used here to equalize the enum variants
76 EVM(Box<evm::EVMMonitorMatch>),
77 /// Matched conditions from Stellar chains
78 ///
79 /// # Note
80 /// Box is used here to equalize the enum variants
81 Stellar(Box<stellar::StellarMonitorMatch>),
82}
83
84/// Structure to hold block processing results
85///
86/// This is used to pass the results of block processing to the trigger handler
87#[derive(Debug, Clone, Serialize, Deserialize)]
88pub struct ProcessedBlock {
89 pub block_number: u64,
90 pub network_slug: String,
91 pub processing_results: Vec<MonitorMatch>,
92}