Skip to content

Commit 3327f3c

Browse files
committed
chain/ethereum: migrate chain_id call to use alloy
1 parent 3035f4e commit 3327f3c

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
@@ -1170,19 +1170,17 @@ impl EthereumAdapter {
11701170

11711171
pub async fn chain_id(&self) -> Result<u64, Error> {
11721172
let logger = self.logger.clone();
1173-
let web3 = self.web3.clone();
1174-
u64::try_from(
1175-
retry("chain_id RPC call", &logger)
1176-
.redact_log_urls(true)
1177-
.no_limit()
1178-
.timeout_secs(ENV_VARS.json_rpc_timeout.as_secs())
1179-
.run(move || {
1180-
let web3 = web3.cheap_clone();
1181-
async move { web3.eth().chain_id().await }
1182-
})
1183-
.await?,
1184-
)
1185-
.map_err(Error::msg)
1173+
let alloy = self.alloy.clone();
1174+
retry("chain_id RPC call", &logger)
1175+
.redact_log_urls(true)
1176+
.no_limit()
1177+
.timeout_secs(ENV_VARS.json_rpc_timeout.as_secs())
1178+
.run(move || {
1179+
let alloy = alloy.cheap_clone();
1180+
async move { alloy.get_chain_id().await.map_err(Error::from) }
1181+
})
1182+
.await
1183+
.map_err(|e| e.into_inner().unwrap_or(EthereumRpcError::Timeout.into()))
11861184
}
11871185
}
11881186

0 commit comments

Comments
 (0)