Skip to content

Commit

Permalink
fix: add to chain_config
Browse files Browse the repository at this point in the history
  • Loading branch information
0xRampey committed Nov 20, 2024
1 parent 5d0713d commit 3d9c248
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 23 deletions.
12 changes: 0 additions & 12 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,6 @@ struct OpStackArgs {
help = "Enable fallback for weak subjectivity checkpoint. Use if --ethereum-checkpoint fails."
)]
load_external_fallback: bool,
#[clap(
short = 's',
long = "ethereum-network",
env = "ETHEREUM_NETWORK",
default_value = "MAINNET",
help = "Set the Ethereum network to use with the opstack (MAINNET, GOERLI, HOLESKY, SEPOLIA)"
)]
eth_network: Option<String>,
}

impl OpStackArgs {
Expand Down Expand Up @@ -262,10 +254,6 @@ impl OpStackArgs {
user_dict.insert("checkpoint", Value::from(hex::encode(checkpoint)));
}

if let Some(eth_network) = &self.eth_network {
user_dict.insert("eth_network", Value::from(eth_network.clone()));
}

Serialized::from(user_dict, &self.network)
}
}
Expand Down
9 changes: 1 addition & 8 deletions helios-ts/src/opstack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ pub struct OpStackClient {
#[wasm_bindgen]
impl OpStackClient {
#[wasm_bindgen(constructor)]
pub fn new(
execution_rpc: String,
network: String,
eth_network: String,
) -> Result<OpStackClient, JsError> {
pub fn new(execution_rpc: String, network: String) -> Result<OpStackClient, JsError> {
console_error_panic_hook::set_once();

let network_config = match network.as_str() {
Expand All @@ -49,9 +45,6 @@ impl OpStackClient {
rpc_socket: None,
load_external_fallback: None,
checkpoint: None,
eth_network: eth_network
.parse()
.map_err(|_| JsError::new("invalid ethereum network"))?,
};

let inner = map_err(OpStackClientBuilder::new().config(config).build())?;
Expand Down
2 changes: 1 addition & 1 deletion opstack/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ impl OpStackClientBuilder {
chain_id,
unsafe_signer,
system_config_contract: Address::ZERO,
eth_network,
},
load_external_fallback: None,
checkpoint: None,
eth_network,
}
};
let consensus = ConsensusClient::new(&config);
Expand Down
6 changes: 5 additions & 1 deletion opstack/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ pub struct Config {
pub chain: ChainConfig,
pub load_external_fallback: Option<bool>,
pub checkpoint: Option<B256>,
pub eth_network: EthNetwork,
}

#[derive(Serialize, Deserialize, Clone)]
pub struct ChainConfig {
pub chain_id: u64,
pub unsafe_signer: Address,
pub system_config_contract: Address,
pub eth_network: EthNetwork,
}

#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -79,6 +79,7 @@ impl From<Network> for NetworkConfig {
chain_id: 10,
unsafe_signer: address!("AAAA45d9549EDA09E70937013520214382Ffc4A2"),
system_config_contract: address!("229047fed2591dbec1eF1118d64F7aF3dB9EB290"),
eth_network: EthNetwork::MAINNET,
},
},
Network::Base => NetworkConfig {
Expand All @@ -87,6 +88,7 @@ impl From<Network> for NetworkConfig {
chain_id: 8453,
unsafe_signer: address!("Af6E19BE0F9cE7f8afd49a1824851023A8249e8a"),
system_config_contract: address!("73a79Fab69143498Ed3712e519A88a918e1f4072"),
eth_network: EthNetwork::MAINNET,
},
},
Network::Worldchain => NetworkConfig {
Expand All @@ -99,6 +101,7 @@ impl From<Network> for NetworkConfig {
chain_id: 480,
unsafe_signer: address!("2270d6eC8E760daA317DD978cFB98C8f144B1f3A"),
system_config_contract: address!("6ab0777fD0e609CE58F939a7F70Fe41F5Aa6300A"),
eth_network: EthNetwork::MAINNET,
},
},
Network::Zora => NetworkConfig {
Expand All @@ -107,6 +110,7 @@ impl From<Network> for NetworkConfig {
chain_id: 7777777,
unsafe_signer: address!("3Dc8Dfd0709C835cAd15a6A27e089FF4cF4C9228"),
system_config_contract: address!("A3cAB0126d5F504B071b81a3e8A2BBBF17930d86"),
eth_network: EthNetwork::MAINNET,
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion opstack/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fn verify_unsafe_signer(config: Config, signer: Arc<Mutex<Address>>) {
let run = wasm_bindgen_futures::spawn_local;

run(async move {
let mut eth_config = config.eth_network.to_base_config();
let mut eth_config = config.chain.eth_network.to_base_config();
eth_config.load_external_fallback = config.load_external_fallback.unwrap_or(false);
if let Some(checkpoint) = config.checkpoint {
eth_config.default_checkpoint = checkpoint;
Expand Down

0 comments on commit 3d9c248

Please sign in to comment.