diff --git a/bridges/centralized-ethereum/src/actors/watch_dog.rs b/bridges/centralized-ethereum/src/actors/watch_dog.rs
index 1c6633148..708439a07 100644
--- a/bridges/centralized-ethereum/src/actors/watch_dog.rs
+++ b/bridges/centralized-ethereum/src/actors/watch_dog.rs
@@ -119,59 +119,27 @@ impl WatchDog {
if let Err(err) = check_wit_connection_status(&wit_jsonrpc_socket).await {
status = err;
}
- let wit_client = JsonRpcClient::start(&wit_jsonrpc_socket)
- .expect("cannot start JSON/WIT connection");
- let wit_account = match fetch_wit_account(&wit_client).await {
- Ok(pkh) => pkh,
+ let wit_client = match JsonRpcClient::start(&wit_jsonrpc_socket) {
+ Ok(client) => client,
+ Err(_) => return (None, None),
+ };
+ let (wit_account, wit_balance, wit_utxos_above_threshold) = match fetch_wit_info(
+ &wit_client,
+ wit_utxo_min_value_threshold
+ ).await {
+ Ok((wit_account, wit_balance, wit_utxos_above_threshold)) => {
+ (wit_account, wit_balance, wit_utxos_above_threshold)
+ }
Err(err) => {
if status.eq("up-and-running") {
status = err;
}
- None
- }
- };
-
- let wit_balance = match wit_account.clone() {
- Some(pkh) => match fetch_wit_account_balance(&wit_client, pkh.as_str()).await {
- Ok(wit_balance) => wit_balance,
- Err(err) => {
- if status.eq("up-and-running") {
- status = err;
- }
- None
- }
- },
- None => None,
- };
-
- let wit_utxos_above_threshold = match wit_account.clone() {
- Some(pkh) => {
- match fetch_wit_account_count_utxos_above(
- &wit_client,
- pkh.as_str(),
- wit_utxo_min_value_threshold,
- )
- .await
- {
- Ok(wit_utxos_above_threshold) => wit_utxos_above_threshold,
- Err(err) => {
- if status.eq("up-and-running") {
- status = err;
- }
- None
- }
- }
+ (None, None, None)
}
- None => None,
};
let eth_balance = match check_eth_account_balance(ð_jsonrpc_url, eth_account).await {
- Ok(Some(eth_balance)) => {
- let eth_balance: f64 = eth_balance.to_string().parse().unwrap_or_default();
- //Some(Unit::Wei(ð_balance.to_string()).to_eth_str().unwrap_or_default()),
- Some(eth_balance / 1000000000000000000.0)
- }
- Ok(None) => None,
+ Ok(eth_balance) => eth_balance,
Err(err) => {
if status.eq("up-and-running") {
status = err;
@@ -248,7 +216,7 @@ impl WatchDog {
async fn check_eth_account_balance(
eth_jsonrpc_url: &str,
eth_account: H160,
-) -> Result