diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index ba24dd9..32c4ca7 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -9,6 +9,7 @@ pub enum ChainName { Base, Optimism, Zora, + WorldChain, } impl ToString for ChainName { @@ -18,6 +19,7 @@ impl ToString for ChainName { ChainName::Base => "base".to_string(), ChainName::Optimism => "optimism".to_string(), ChainName::Zora => "zora".to_string(), + ChainName::WorldChain => "world_chain".to_string(), } } } @@ -31,6 +33,7 @@ impl FromStr for ChainName { "base" => Ok(ChainName::Base), "optimism" => Ok(ChainName::Optimism), "zora" => Ok(ChainName::Zora), + "world_chain" => Ok(ChainName::WorldChain), _ => Err(eyre::eyre!("invalid chain name")), } } @@ -86,9 +89,9 @@ impl FromStr for Network { type Err = eyre::Error; fn from_str(s: &str) -> Result { - let parts: Vec<&str> = s.split('_').collect(); - let chain_name = ChainName::from_str(parts[0])?; - let chain_type = ChainType::from_str(parts[1])?; + let parts: Vec<&str> = s.rsplitn(2, '_').collect(); + let chain_name = ChainName::from_str(parts[1])?; + let chain_type = ChainType::from_str(parts[0])?; Ok(Network { chain_name, chain_type, diff --git a/crates/monitor_events/networks/world_chain_sepolia.json b/crates/monitor_events/networks/world_chain_sepolia.json new file mode 100644 index 0000000..728779e --- /dev/null +++ b/crates/monitor_events/networks/world_chain_sepolia.json @@ -0,0 +1,8 @@ +{ + "name": "world_chain_sepolia", + "l1_contract": "0xc8886f8BAb6Eaeb215aDB5f1c686BF699248300e", + "block_delay": 20, + "poll_period_sec": 60, + "batch_size": 50000, + "l1_contract_deployment_block": 6278167 +} diff --git a/crates/monitor_events/src/main.rs b/crates/monitor_events/src/main.rs index 0c7730c..617cde8 100644 --- a/crates/monitor_events/src/main.rs +++ b/crates/monitor_events/src/main.rs @@ -53,7 +53,7 @@ async fn main() -> Result<()> { }); let mut from_block_num = match chain_name { - ChainName::Optimism | ChainName::Base | ChainName::Zora => { + ChainName::Optimism | ChainName::Base | ChainName::Zora | ChainName::WorldChain => { create_opstack_table_if_not_exists(table_name.clone(), &pg_client).await } ChainName::Arbitrum => { @@ -67,7 +67,7 @@ async fn main() -> Result<()> { ); let event_signature = match chain_name { - ChainName::Optimism | ChainName::Base | ChainName::Zora => { + ChainName::Optimism | ChainName::Base | ChainName::Zora | ChainName::WorldChain => { "OutputProposed(bytes32,uint256,uint256,uint256)" } ChainName::Arbitrum => "SendRootUpdated(bytes32,bytes32)", @@ -100,7 +100,7 @@ async fn main() -> Result<()> { for log in logs.iter() { match chain_name { - ChainName::Optimism | ChainName::Base | ChainName::Zora => { + ChainName::Optimism | ChainName::Base | ChainName::Zora | ChainName::WorldChain => { let params = handle_opstack_events(log); // Insert the data into PostgreSQL if let Err(err) = diff --git a/pm2.config.js b/pm2.config.js index 4b9cb50..539898b 100644 --- a/pm2.config.js +++ b/pm2.config.js @@ -41,6 +41,17 @@ module.exports = { DB_URL: "postgresql://postgres:password@localhost:5432/l2indexer", }, }, + { + name: "monitor-world-chain-sepolia", + script: "target/release/monitor-events", + env: { + CHAIN_TYPE: "sepolia", + CHAIN_NAME: "world_chain", + RPC_URL: + "https://eth-sepolia.g.alchemy.com/v2/1cpBOW7IDNaPC1Dybn6Qbv6uMszcmjlr", + DB_URL: "postgresql://postgres:password@localhost:5432/l2indexer", + }, + }, // TODO: Zora docs haven't update sepolia `L2OutputOracle` address // { // name: 'monitor-zora-sepolia',