Skip to content

Commit 71be57f

Browse files
committed
fix(c-bridge): web3 calls parameters
1 parent a7d970d commit 71be57f

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

bridges/centralized-ethereum/src/actors/dr_reporter.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -468,15 +468,17 @@ async fn split_by_gas_limit(
468468
.function("reportResultBatch")
469469
.and_then(|f| f.encode_input(&eth_report_result_batch_params.into_tokens()));
470470

471-
let estimated_profit: Result<U256, web3::contract::Error> = wrb_contract
471+
let params = (
472+
Token::Array(query_ids),
473+
Token::Bytes(eth_report_result_batch_msg_data.unwrap_or_default()),
474+
Token::Uint(eth_gas_price),
475+
Token::Uint(eth_nanowit_wei_price),
476+
);
477+
478+
let estimated_profit: Result<(U256, U256), web3::contract::Error> = wrb_contract
472479
.query(
473480
"estimateReportEarnings",
474-
Token::Tuple(vec![
475-
Token::Tuple(query_ids),
476-
Token::Bytes(eth_report_result_batch_msg_data.unwrap_or_default()),
477-
Token::Uint(eth_gas_price),
478-
Token::Uint(eth_nanowit_wei_price),
479-
]),
481+
params,
480482
eth_from,
481483
contract::Options::with(|opt| {
482484
opt.gas = eth_max_gas.map(Into::into);
@@ -487,13 +489,12 @@ async fn split_by_gas_limit(
487489
.await;
488490

489491
match estimated_profit {
490-
Ok(estimated_profit) if estimated_profit > U256::from(0) => {
492+
Ok((revenues, expenses)) => {
491493
log::debug!(
492-
"reportResultBatch (x{} drs) estimated profit: {:?} ETH",
494+
"reportResultBatch (x{} drs) estimated profit: {} - {} ETH",
493495
batch_params.len(),
494-
Unit::Wei(&estimated_profit.to_string())
495-
.to_eth_str()
496-
.unwrap_or_default(),
496+
Unit::Wei(&revenues.to_string()).to_eth_str().unwrap_or_default(),
497+
Unit::Wei(&expenses.to_string()).to_eth_str().unwrap_or_default(),
497498
);
498499
v.push((batch_params, estimated_gas));
499500
continue;

bridges/centralized-ethereum/src/actors/eth_poller.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,10 @@ impl EthPoller {
122122
let ids = init_index..last_index;
123123
let ids: Vec<Token> = ids.map(|id| Token::Uint(id.into())).collect();
124124

125-
log::debug!("getQueryStatusBatch params => {}", Token::Tuple(ids.clone()));
126-
127-
let queries_status: Result<Vec<u8>, web3::contract::Error> = wrb_contract
125+
let queries_status: Result<Vec<Token>, web3::contract::Error> = wrb_contract
128126
.query(
129127
"getQueryStatusBatch",
130-
Token::Tuple(ids.clone()),
128+
ids.clone(),
131129
None,
132130
contract::Options::default(),
133131
None,
@@ -138,7 +136,8 @@ impl EthPoller {
138136
let mut posted_ids: Vec<Token> = vec![];
139137
for (pos, status) in queries_status.iter().enumerate() {
140138
let query_id = ids[pos].to_owned().into_uint().unwrap();
141-
match WitnetQueryStatus::from_code(*status) {
139+
let status: u8 = status.to_string().parse().unwrap();
140+
match WitnetQueryStatus::from_code(status) {
142141
WitnetQueryStatus::Unknown => {
143142
log::debug!("[{}]: not available.", query_id);
144143
}
@@ -160,7 +159,7 @@ impl EthPoller {
160159
wrb_contract
161160
.query(
162161
"extractWitnetDataRequests",
163-
Token::Tuple(posted_ids.clone()),
162+
posted_ids.clone(),
164163
None,
165164
contract::Options::default(),
166165
None,

0 commit comments

Comments
 (0)