Skip to content

Commit

Permalink
refactor: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-savu committed Nov 21, 2023
1 parent 396ba4c commit 895f111
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
36 changes: 16 additions & 20 deletions rust/hyperlane-base/src/settings/parser/connection_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,23 @@ pub fn build_ethereum_connection_conf(
err: &mut ConfigParsingError,
default_rpc_consensus_type: &str,
) -> Option<ChainConnectionConf> {
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(
Expand Down
2 changes: 1 addition & 1 deletion rust/hyperlane-core/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl TryFrom<cosmrs::proto::cosmos::base::abci::v1beta1::TxResponse> 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(),
})
}
}

0 comments on commit 895f111

Please sign in to comment.