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    // Additional Stellar-specific fields can be added here.
27}
28
29impl StellarNetworkConfig {
30    /// Validates the specific configuration fields for a Stellar network.
31    ///
32    /// # Returns
33    /// - `Ok(())` if the Stellar configuration is valid.
34    /// - `Err(ConfigFileError)` if validation fails (e.g., missing fields, invalid URLs).
35    pub fn validate(&self) -> Result<(), ConfigFileError> {
36        self.common.validate()?;
37        Ok(())
38    }
39
40    /// Merges this Stellar configuration with a parent Stellar configuration.
41    /// Parent values are used as defaults, child values take precedence.
42    pub fn merge_with_parent(&self, parent: &Self) -> Self {
43        Self {
44            common: self.common.merge_with_parent(&parent.common),
45            passphrase: self
46                .passphrase
47                .clone()
48                .or_else(|| parent.passphrase.clone()),
49            // Add Stellar-specific field merging here as they are added to the struct
50        }
51    }
52}