blueprint_client_tangle/
config.rs1extern crate alloc;
7
8use alloc::string::String;
9use alloy_primitives::Address;
10use serde::{Deserialize, Serialize};
11use std::path::PathBuf;
12use url::Url;
13
14#[derive(Debug, Clone, Serialize, Deserialize)]
18pub struct TangleSettings {
19 pub blueprint_id: u64,
21 pub service_id: Option<u64>,
25 pub tangle_contract: Address,
27 pub restaking_contract: Address,
29 pub status_registry_contract: Address,
31}
32
33impl Default for TangleSettings {
34 fn default() -> Self {
35 Self {
36 blueprint_id: 0,
37 service_id: None,
38 tangle_contract: Address::ZERO,
40 restaking_contract: Address::ZERO,
41 status_registry_contract: Address::ZERO,
42 }
43 }
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48pub struct TangleClientConfig {
49 pub http_rpc_endpoint: Url,
51 pub ws_rpc_endpoint: Url,
53 pub keystore_uri: String,
55 pub data_dir: PathBuf,
57 pub settings: TangleSettings,
59 pub test_mode: bool,
61 #[serde(default)]
63 pub dry_run: bool,
64}
65
66impl TangleClientConfig {
67 pub fn new(
69 http_rpc_endpoint: impl Into<Url>,
70 ws_rpc_endpoint: impl Into<Url>,
71 keystore_uri: impl Into<String>,
72 settings: TangleSettings,
73 ) -> Self {
74 Self {
75 http_rpc_endpoint: http_rpc_endpoint.into(),
76 ws_rpc_endpoint: ws_rpc_endpoint.into(),
77 keystore_uri: keystore_uri.into(),
78 data_dir: PathBuf::default(),
79 settings,
80 test_mode: false,
81 dry_run: false,
82 }
83 }
84
85 pub fn data_dir(mut self, path: impl Into<PathBuf>) -> Self {
87 self.data_dir = path.into();
88 self
89 }
90
91 pub fn test_mode(mut self, test_mode: bool) -> Self {
93 self.test_mode = test_mode;
94 self
95 }
96
97 pub fn dry_run(mut self, dry_run: bool) -> Self {
99 self.dry_run = dry_run;
100 self
101 }
102
103 pub fn keystore_config(&self) -> blueprint_keystore::KeystoreConfig {
105 blueprint_keystore::KeystoreConfig::new().fs_root(self.keystore_uri.replace("file://", ""))
106 }
107}