newton_cli/
config.rs

1use newton_prover_core::config::{key::EcdsaKey, ConfigLoader};
2use serde::{Deserialize, Serialize};
3
4/// Aggregator Config
5#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
6pub struct NewtonCliConfig {
7    /// Ethereum RPC URL
8    pub eth_rpc_url: String,
9    /// Newton RPC URL
10    pub newton_rpc_url: String,
11    /// Signer
12    pub signer: EcdsaKey,
13    /// Dashboard bearer token for API authentication
14    #[serde(skip_serializing_if = "Option::is_none", default)]
15    pub dashboard_bearer_token: Option<String>,
16    /// Dashboard API base URL
17    #[serde(skip_serializing_if = "Option::is_none", default)]
18    pub dashboard_api_base_url: Option<String>,
19}
20
21// Implement ConfigLoader trait - provides load_config method automatically
22impl ConfigLoader for NewtonCliConfig {
23    const FILE_NAME: &'static str = "newton-cli";
24    const ENV_PREFIX: &'static str = "NEWTON_CLI";
25}
26
27impl NewtonCliConfig {
28    /// Set eth rpc url
29    pub fn set_eth_rpc_url(&mut self, eth_rpc_url: String) {
30        self.eth_rpc_url = eth_rpc_url;
31    }
32
33    /// Set newton rpc url
34    pub fn set_newton_rpc_url(&mut self, newton_rpc_url: String) {
35        self.newton_rpc_url = newton_rpc_url;
36    }
37
38    /// Set signer
39    pub fn set_signer(&mut self, signer: EcdsaKey) {
40        self.signer = signer;
41    }
42
43    /// Set dashboard bearer token
44    pub fn set_dashboard_bearer_token(&mut self, token: Option<String>) {
45        self.dashboard_bearer_token = token;
46    }
47
48    /// Set dashboard API base URL
49    pub fn set_dashboard_api_base_url(&mut self, url: Option<String>) {
50        self.dashboard_api_base_url = url;
51    }
52}