openzeppelin_monitor/models/core/network.rs
1use serde::{Deserialize, Serialize};
2
3use crate::models::{BlockChainType, SecretValue};
4
5/// Configuration for connecting to and interacting with a blockchain network.
6///
7/// Defines connection details and operational parameters for a specific blockchain network,
8/// supporting both EVM and Stellar-based chains.
9#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
10#[serde(deny_unknown_fields)]
11pub struct Network {
12 /// Type of blockchain (EVM, Stellar, etc)
13 pub network_type: BlockChainType,
14
15 /// Unique identifier for this network
16 pub slug: String,
17
18 /// Human-readable name of the network
19 pub name: String,
20
21 /// List of RPC endpoints with their weights for load balancing
22 pub rpc_urls: Vec<RpcUrl>,
23
24 /// Chain ID for EVM networks
25 pub chain_id: Option<u64>,
26
27 /// Network passphrase for Stellar networks
28 pub network_passphrase: Option<String>,
29
30 /// Average block time in milliseconds
31 pub block_time_ms: u64,
32
33 /// Number of blocks needed for confirmation
34 pub confirmation_blocks: u64,
35
36 /// Cron expression for how often to check for new blocks
37 pub cron_schedule: String,
38
39 /// Maximum number of past blocks to process
40 pub max_past_blocks: Option<u64>,
41
42 /// Whether to store processed blocks
43 pub store_blocks: Option<bool>,
44}
45
46/// RPC endpoint configuration with load balancing weight
47#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
48#[serde(deny_unknown_fields)]
49pub struct RpcUrl {
50 /// Type of RPC endpoint (e.g. "rpc")
51 pub type_: String,
52
53 /// URL of the RPC endpoint (can be a secret value)
54 pub url: SecretValue,
55
56 /// Weight for load balancing (0-100)
57 pub weight: u32,
58}