From 895f1113d793b9c4f4ff9de8c0d1aaf8d41b81a8 Mon Sep 17 00:00:00 2001 From: Daniel Savu <23065004+daniel-savu@users.noreply.github.com> Date: Tue, 21 Nov 2023 12:01:03 +0000 Subject: [PATCH] refactor: clean up --- .../src/settings/parser/connection_parser.rs | 36 +++++++++---------- rust/hyperlane-core/src/traits/mod.rs | 2 +- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/rust/hyperlane-base/src/settings/parser/connection_parser.rs b/rust/hyperlane-base/src/settings/parser/connection_parser.rs index ece977c2d7..5a56cb253b 100644 --- a/rust/hyperlane-base/src/settings/parser/connection_parser.rs +++ b/rust/hyperlane-base/src/settings/parser/connection_parser.rs @@ -14,27 +14,23 @@ pub fn build_ethereum_connection_conf( err: &mut ConfigParsingError, default_rpc_consensus_type: &str, ) -> Option { - if rpcs.len() <= 1 { - rpcs.into_iter().next().map(|url| { - ChainConnectionConf::Ethereum(h_eth::ConnectionConf::Http { url: url.clone() }) - }) - } else { - let rpc_consensus_type = chain - .chain(err) - .get_opt_key("rpcConsensusType") - .parse_string() - .unwrap_or(default_rpc_consensus_type); - match rpc_consensus_type { - "single" => Some(h_eth::ConnectionConf::Http { - url: rpcs.clone().into_iter().next().unwrap(), - }), - "fallback" => Some(h_eth::ConnectionConf::HttpFallback { urls: rpcs.clone() }), - "quorum" => Some(h_eth::ConnectionConf::HttpQuorum { urls: rpcs.clone() }), - ty => Err(eyre!("unknown rpc consensus type `{ty}`")) - .take_err(err, || &chain.cwp + "rpc_consensus_type"), - } - .map(ChainConnectionConf::Ethereum) + let Some(first_url) = rpcs.clone().into_iter().next() else { + return None; + }; + let rpc_consensus_type = chain + .chain(err) + .get_opt_key("rpcConsensusType") + .parse_string() + .unwrap_or(default_rpc_consensus_type); + + match rpc_consensus_type { + "single" => Some(h_eth::ConnectionConf::Http { url: first_url }), + "fallback" => Some(h_eth::ConnectionConf::HttpFallback { urls: rpcs.clone() }), + "quorum" => Some(h_eth::ConnectionConf::HttpQuorum { urls: rpcs.clone() }), + ty => Err(eyre!("unknown rpc consensus type `{ty}`")) + .take_err(err, || &chain.cwp + "rpc_consensus_type"), } + .map(ChainConnectionConf::Ethereum) } pub fn build_cosmos_connection_conf( diff --git a/rust/hyperlane-core/src/traits/mod.rs b/rust/hyperlane-core/src/traits/mod.rs index 86fb6b2f22..555082dbc5 100644 --- a/rust/hyperlane-core/src/traits/mod.rs +++ b/rust/hyperlane-core/src/traits/mod.rs @@ -73,7 +73,7 @@ impl TryFrom for TxOutco transaction_id: H256::from_slice(hex::decode(response.txhash)?.as_slice()).into(), executed: response.code == 0, gas_used: U256::from(response.gas_used), - gas_price: U256::from(response.gas_wanted), + gas_price: U256::one(), }) } }