survive nonstandard eth_chainId
This commit is contained in:
parent
3afd0a78c6
commit
9f4b9cdb92
|
@ -125,11 +125,13 @@ impl Web3Connection {
|
|||
|
||||
// TODO: passing empty_params like this feels awkward.
|
||||
let empty_params: Option<()> = None;
|
||||
let found_chain_id: String = active_request_handle
|
||||
// TODO: some rpcs (on bsc and fantom) do not return an id
|
||||
let found_chain_id: Result<String, _> = active_request_handle
|
||||
.request("eth_chainId", empty_params)
|
||||
.await
|
||||
.unwrap();
|
||||
.await;
|
||||
|
||||
match found_chain_id {
|
||||
Ok(found_chain_id) => {
|
||||
let found_chain_id =
|
||||
usize::from_str_radix(found_chain_id.trim_start_matches("0x"), 16).unwrap();
|
||||
|
||||
|
@ -140,6 +142,15 @@ impl Web3Connection {
|
|||
found_chain_id
|
||||
));
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
// TODO: this is not the right way to use anyhow
|
||||
let e_str = format!("{}", e);
|
||||
let e = anyhow::Error::from(e).context(format!("{:?}: {}", connection, e_str));
|
||||
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
|
||||
info!("Successful connection: {}", connection);
|
||||
|
||||
|
|
Loading…
Reference in New Issue