Skip to content

Commit a10b438

Browse files
committed
collect cross call results
1 parent 9b2fcfd commit a10b438

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

rpc-server/src/modules/transactions/methods.rs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,30 @@ pub async fn emulate_tx(
276276
}
277277
}
278278
}
279+
let cross_call_results =
280+
cross_action_call(&data, account_id, tx_actions_collector.get_actions().await).await?;
281+
results.extend(cross_call_results);
282+
Ok(results)
283+
}
279284

280-
// Processes cross-contract actions collected during transaction emulation.
281-
//
282-
// Iterates over each cross-contract action in the `tx_actions_collector`, currently supporting only
283-
// `FunctionCallWeight` actions. For each supported action, it converts the method name from bytes to a string,
284-
// retrieves the latest block view, and processes the function call, collecting the results. Unsupported actions
285-
// are logged for debugging purposes.
286-
for cross_action in tx_actions_collector.get_actions().await {
285+
/// Processes cross-contract actions collected during transaction emulation.
286+
///
287+
/// Iterates over each cross-contract action in the `tx_actions_collector`, currently supporting only
288+
/// `FunctionCallWeight` actions. For each supported action, it converts the method name from bytes to a string,
289+
/// retrieves the latest block view, and processes the function call, collecting the results. Unsupported actions
290+
/// are logged for debugging purposes.
291+
pub async fn cross_action_call(
292+
data: &Data<ServerContext>,
293+
account_id: &near_primitives::types::AccountId,
294+
tx_actions: Vec<near_vm_runner::logic::mocks::mock_external::MockAction>,
295+
) -> Result<
296+
Vec<crate::modules::transactions::EmulateTransactionResponse>,
297+
near_jsonrpc::primitives::errors::RpcError,
298+
> {
299+
let tx_actions_collector =
300+
std::sync::Arc::new(crate::modules::transactions::TxActionsCollector::new());
301+
let mut results = vec![];
302+
for cross_action in tx_actions {
287303
match cross_action {
288304
near_vm_runner::logic::mocks::mock_external::MockAction::FunctionCallWeight {
289305
method_name,
@@ -313,6 +329,13 @@ pub async fn emulate_tx(
313329
call_results.into(),
314330
),
315331
);
332+
let cross_results = Box::pin(cross_action_call(
333+
data,
334+
account_id,
335+
tx_actions_collector.get_actions().await,
336+
))
337+
.await?;
338+
results.extend(cross_results);
316339
}
317340
_ => {
318341
tracing::debug!(

0 commit comments

Comments
 (0)