openzeppelin_relayer/config/config_file/network/stellar.rs
1//! Stellar Network Configuration
2//!
3//! This module provides configuration support for Stellar blockchain networks including
4//! Stellar mainnet (Pubnet), testnet, and custom Stellar-compatible networks.
5//!
6//! ## Key Features
7//!
8//! - **Full inheritance support**: Stellar networks can inherit from other Stellar networks
9//! - **Network passphrase**: Critical field for transaction signing and network identification
10//! - **Standard validation**: Inherits all common field validation requirements
11//! - **Type safety**: Inheritance only allowed between Stellar networks
12
13use super::common::NetworkConfigCommon;
14use crate::config::ConfigFileError;
15use serde::{Deserialize, Serialize};
16
17/// Configuration specific to Stellar networks.
18#[derive(Debug, Serialize, Deserialize, Clone)]
19#[serde(deny_unknown_fields)]
20pub struct StellarNetworkConfig {
21 /// Common network fields.
22 #[serde(flatten)]
23 pub common: NetworkConfigCommon,
24 /// The passphrase for the Stellar network.
25 pub passphrase: Option<String>,
26 /// The Horizon URL for the Stellar network.
27 pub horizon_url: Option<String>,
28 // Additional Stellar-specific fields can be added here.
29}
30
31impl StellarNetworkConfig {
32 /// Validates the specific configuration fields for a Stellar network.
33 ///
34 /// # Returns
35 /// - `Ok(())` if the Stellar configuration is valid.
36 /// - `Err(ConfigFileError)` if validation fails (e.g., missing fields, invalid URLs).
37 pub fn validate(&self) -> Result<(), ConfigFileError> {
38 self.common.validate()?;
39 Ok(())
40 }
41
42 /// Merges this Stellar configuration with a parent Stellar configuration.
43 /// Parent values are used as defaults, child values take precedence.
44 pub fn merge_with_parent(&self, parent: &Self) -> Self {
45 Self {
46 common: self.common.merge_with_parent(&parent.common),
47 passphrase: self
48 .passphrase
49 .clone()
50 .or_else(|| parent.passphrase.clone()),
51 horizon_url: self
52 .horizon_url
53 .clone()
54 .or_else(|| parent.horizon_url.clone()),
55 // Add Stellar-specific field merging here as they are added to the struct
56 }
57 }
58}