diff --git a/crates/oracle/src/runner/oracle.rs b/crates/oracle/src/runner/oracle.rs index de8aa357..e8212470 100644 --- a/crates/oracle/src/runner/oracle.rs +++ b/crates/oracle/src/runner/oracle.rs @@ -9,13 +9,14 @@ use crate::{ use epoch_encoding::{BlockPtr, Encoder, Message, CURRENT_ENCODING_VERSION}; use std::{cmp::Ordering, collections::BTreeMap}; use tracing::{debug, error, info, warn}; +use web3::{transports::Http, Web3}; /// The main application in-memory state. pub struct Oracle { config: Config, protocol_chain: JrpcProviderForChain, indexed_chains: Vec>, - contracts: Contracts, + contracts: Contracts, } impl Oracle { @@ -23,7 +24,7 @@ impl Oracle { let protocol_chain = protocol_chain(&config); let indexed_chains = indexed_chains(&config); let contracts = Contracts::new( - protocol_chain.web3.clone(), + contracts_web3(&config), config.data_edge_address, config.epoch_manager_address, config.transaction_monitoring_options, @@ -299,6 +300,13 @@ fn protocol_chain(config: &Config) -> JrpcProviderForChain { JrpcProviderForChain::new(config.protocol_chain.id.clone(), transport) } +fn contracts_web3(config: &Config) -> Web3 { + // Unwrap/Expect: the URL string value we pass to Http::new will be parsed into an URL again. + // Since that value already comes from a parsed (and thus, valid) URL, we can assume it won't panic. + let transport = Http::new(config.protocol_chain.jrpc_url.as_str()).expect("URL to be valid"); + Web3::new(transport) +} + fn indexed_chains(config: &Config) -> Vec> { config .indexed_chains diff --git a/crates/oracle/src/runner/transaction_monitor.rs b/crates/oracle/src/runner/transaction_monitor.rs index 07121c81..cac61cb4 100644 --- a/crates/oracle/src/runner/transaction_monitor.rs +++ b/crates/oracle/src/runner/transaction_monitor.rs @@ -102,10 +102,10 @@ impl<'a, T: Transport> TransactionMonitor<'a, T> { futures.push(future) } - // Await and check if any of those transactions has a receipt + // Await and check if any of those transactions have a receipt while let Some(result) = futures.next().await { match result { - Ok(None) => {} + Ok(None) => { /* no confirmations */ } Ok(Some(receipt)) => { return Ok(Some(receipt)); }