Skip to content

Commit

Permalink
Merge pull request #10 from HerodotusDev/feat/index-world-chain-sepolia
Browse files Browse the repository at this point in the history
Start indexing world chain sepolia
  • Loading branch information
mikjakbiak authored Sep 16, 2024
2 parents de6eb3b + 29084ec commit 4cddd48
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
9 changes: 6 additions & 3 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub enum ChainName {
Base,
Optimism,
Zora,
WorldChain,
}

impl ToString for ChainName {
Expand All @@ -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(),
}
}
}
Expand All @@ -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")),
}
}
Expand Down Expand Up @@ -86,9 +89,9 @@ impl FromStr for Network {
type Err = eyre::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
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,
Expand Down
8 changes: 8 additions & 0 deletions crates/monitor_events/networks/world_chain_sepolia.json
Original file line number Diff line number Diff line change
@@ -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
}
6 changes: 3 additions & 3 deletions crates/monitor_events/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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)",
Expand Down Expand Up @@ -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) =
Expand Down
11 changes: 11 additions & 0 deletions pm2.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 4cddd48

Please sign in to comment.