Skip to content

Commit af84d74

Browse files
committed
chain/ethereum: migrate chain_id call to use alloy
1 parent 2374d17 commit af84d74

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

chain/ethereum/src/ethereum_adapter.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,19 +1185,17 @@ impl EthereumAdapter {
11851185

11861186
pub async fn chain_id(&self) -> Result<u64, Error> {
11871187
let logger = self.logger.clone();
1188-
let web3 = self.web3.clone();
1189-
u64::try_from(
1190-
retry("chain_id RPC call", &logger)
1191-
.redact_log_urls(true)
1192-
.no_limit()
1193-
.timeout_secs(ENV_VARS.json_rpc_timeout.as_secs())
1194-
.run(move || {
1195-
let web3 = web3.cheap_clone();
1196-
async move { web3.eth().chain_id().await }
1197-
})
1198-
.await?,
1199-
)
1200-
.map_err(Error::msg)
1188+
let alloy = self.alloy.clone();
1189+
retry("chain_id RPC call", &logger)
1190+
.redact_log_urls(true)
1191+
.no_limit()
1192+
.timeout_secs(ENV_VARS.json_rpc_timeout.as_secs())
1193+
.run(move || {
1194+
let alloy = alloy.cheap_clone();
1195+
async move { alloy.get_chain_id().await.map_err(Error::from) }
1196+
})
1197+
.await
1198+
.map_err(|e| e.into_inner().unwrap_or(EthereumRpcError::Timeout.into()))
12011199
}
12021200
}
12031201

0 commit comments

Comments
 (0)