Skip to content

Commit f025e9d

Browse files
authored
fix: bootstrapper environment variables (#751)
1 parent ae38bba commit f025e9d

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

bootstrapper/src/configs/devnet.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"l1_deployer_address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
77
"l1_wait_time": "15",
88
"sn_os_program_hash": "0x41fc2a467ef8649580631912517edcab7674173f1dbfa2e9b64fbcd82bc4d79",
9-
"config_hash_version": "StarknetOsConfig2",
109
"app_chain_id": "MADARA_DEVNET",
1110
"fee_token_address": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
1211
"native_fee_token_address": "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",

bootstrapper/src/main.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ pub struct ConfigBuilder {
7676
pub eth_rpc: Option<String>,
7777
pub eth_priv_key: Option<String>,
7878
pub rollup_priv_key: Option<String>,
79-
pub rollup_seq_url: String,
80-
pub rollup_declare_v0_seq_url: String,
79+
pub rollup_seq_url: Option<String>,
80+
pub rollup_declare_v0_seq_url: Option<String>,
8181
pub eth_chain_id: u64,
8282
pub l1_deployer_address: String,
8383
pub l1_wait_time: String,
84-
pub sn_os_program_hash: String,
85-
pub config_hash_version: String,
84+
pub sn_os_program_hash: Option<String>,
85+
pub config_hash_version: Option<String>,
8686
pub app_chain_id: String,
8787
pub fee_token_address: String,
8888
pub native_fee_token_address: String,
@@ -108,13 +108,13 @@ impl Default for ConfigBuilder {
108108
eth_rpc: Some("http://127.0.0.1:8545".to_string()),
109109
eth_priv_key: Some("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".to_string()),
110110
rollup_priv_key: Some("0xabcd".to_string()),
111-
rollup_seq_url: "http://127.0.0.1:19944".to_string(),
112-
rollup_declare_v0_seq_url: "http://127.0.0.1:19943".to_string(),
111+
rollup_seq_url: Some("http://127.0.0.1:19944".to_string()),
112+
rollup_declare_v0_seq_url: Some("http://127.0.0.1:19943".to_string()),
113113
eth_chain_id: 31337,
114114
l1_deployer_address: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".to_string(),
115115
l1_wait_time: "15".to_string(),
116-
sn_os_program_hash: "0x1e324682835e60c4779a683b32713504aed894fd73842f7d05b18e7bd29cd70".to_string(),
117-
config_hash_version: "StarknetOsConfig2".to_string(),
116+
sn_os_program_hash: Some("0x1e324682835e60c4779a683b32713504aed894fd73842f7d05b18e7bd29cd70".to_string()),
117+
config_hash_version: Some("StarknetOsConfig2".to_string()),
118118
app_chain_id: "MADARA_DEVNET".to_string(),
119119
fee_token_address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7".to_string(),
120120
native_fee_token_address: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d".to_string(),
@@ -153,16 +153,16 @@ impl ConfigBuilder {
153153
self.rollup_priv_key = Some(rollup_priv_key);
154154
}
155155
if let Ok(rollup_seq_url) = std::env::var("ROLLUP_SEQ_URL") {
156-
self.rollup_seq_url = rollup_seq_url;
156+
self.rollup_seq_url = Some(rollup_seq_url);
157157
}
158158
if let Ok(rollup_declare_v0_seq_url) = std::env::var("ROLLUP_DECLARE_V0_SEQ_URL") {
159-
self.rollup_declare_v0_seq_url = rollup_declare_v0_seq_url;
159+
self.rollup_declare_v0_seq_url = Some(rollup_declare_v0_seq_url);
160160
}
161161
if let Ok(sn_os_program_hash) = std::env::var("SN_OS_PROGRAM_HASH") {
162-
self.sn_os_program_hash = sn_os_program_hash;
162+
self.sn_os_program_hash = Some(sn_os_program_hash);
163163
}
164164
if let Ok(config_hash_version) = std::env::var("CONFIG_HASH_VERSION") {
165-
self.config_hash_version = config_hash_version;
165+
self.config_hash_version = Some(config_hash_version);
166166
}
167167
self
168168
}
@@ -178,13 +178,21 @@ impl ConfigBuilder {
178178
rollup_priv_key: self.rollup_priv_key.ok_or_else(|| {
179179
color_eyre::eyre::eyre!("ROLLUP_PRIVATE_KEY must be provided in config file or environment")
180180
})?,
181-
rollup_seq_url: self.rollup_seq_url,
182-
rollup_declare_v0_seq_url: self.rollup_declare_v0_seq_url,
181+
rollup_seq_url: self.rollup_seq_url.ok_or_else(|| {
182+
color_eyre::eyre::eyre!("ROLLUP_SEQ_URL must be provided in config file or environment")
183+
})?,
184+
rollup_declare_v0_seq_url: self.rollup_declare_v0_seq_url.ok_or_else(|| {
185+
color_eyre::eyre::eyre!("ROLLUP_DECLARE_V0_SEQ_URL must be provided in config file or environment")
186+
})?,
183187
eth_chain_id: self.eth_chain_id,
184188
l1_deployer_address: self.l1_deployer_address,
185189
l1_wait_time: self.l1_wait_time,
186-
sn_os_program_hash: self.sn_os_program_hash,
187-
config_hash_version: self.config_hash_version,
190+
sn_os_program_hash: self.sn_os_program_hash.ok_or_else(|| {
191+
color_eyre::eyre::eyre!("SN_OS_PROGRAM_HASH must be provided in config file or environment")
192+
})?,
193+
config_hash_version: self.config_hash_version.ok_or_else(|| {
194+
color_eyre::eyre::eyre!("CONFIG_HASH_VERSION must be provided in config file or environment")
195+
})?,
188196
app_chain_id: self.app_chain_id,
189197
fee_token_address: self.fee_token_address,
190198
native_fee_token_address: self.native_fee_token_address,

0 commit comments

Comments
 (0)