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