-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rpc <> Exex example #8112
Rpc <> Exex example #8112
Conversation
examples/exex/custom-rpc/src/main.rs
Outdated
@@ -0,0 +1,111 @@ | |||
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls also add the example to examples/readme.md
examples/exex/custom-rpc/src/main.rs
Outdated
let filter = Filter::new().select(0u64..).event("ETHBridgeFinalized(address,address,uint256)"); | ||
let filter_res = self.provider.new_filter(filter).await; | ||
|
||
match filter_res{ | ||
Ok(id) =>{ | ||
let data = self.provider.filter_logs(id).await; | ||
let mut deposit_count = 0; | ||
match data{ | ||
Ok(logs) =>{ | ||
for log in logs{ | ||
let val = log.log_decode::<L1StandardBridge::ETHBridgeFinalized>().ok(); | ||
|
||
if let Some(finalized_data) = val{ | ||
// let's see what to do with this data later. | ||
let da = finalized_data.data(); | ||
deposit_count += 1; | ||
} | ||
} | ||
Ok(deposit_count) | ||
}, | ||
Err(_) =>{ | ||
Ok(0) | ||
} | ||
} | ||
}, | ||
Err(_)=>{ | ||
Ok(0) | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not correct, we want this to ask the exex what the deposit count is, we don't want to calculate it ourselves on each call
examples/exex/custom-rpc/src/main.rs
Outdated
.await?; | ||
|
||
handle.wait_for_node_exit().await | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the exex is missing, pls see the other examples
examples/exex/custom-rpc/src/main.rs
Outdated
#[rpc[server, namespace="onDepositCount"]] | ||
pub trait OpDepositCountExtApi { | ||
#[method(name = "opdepositCount")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please follow the naming convention of the other namespaces
yeah , the exex is missing . I was first trying to get an idea on how to get a custom rpc . |
Clarifying that we'd like the ExEx to spawn the RPC in a custom port or path in the JSON-RPC, this is not a task for opening an additional JSON RPC namespace in the same port! |
@onbjerg thought? Please ignore the small nits for now. Just looking for more context from u |
closes paradigmxyz/reth-exex-examples#31
I am trying to write a custom rpc to calculate the no of deposits in op bridge . But getting some errors. Can u point me to correct it. Thanks