Skip to content

Commit

Permalink
updated sending_signed_transaction()
Browse files Browse the repository at this point in the history
  • Loading branch information
FroVolod committed Aug 26, 2024
1 parent 34bac8a commit c47df15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2364,7 +2364,7 @@ impl JsonRpcClientExt for near_jsonrpc_client::JsonRpcClient {
}
}

fn teach_me_call_response(response: &impl serde::Serialize) {
pub(crate) fn teach_me_call_response(response: &impl serde::Serialize) {
if let Ok(response_payload) = serde_json::to_value(response) {
tracing::info!(
target: "near_teach_me",
Expand Down
28 changes: 5 additions & 23 deletions src/transaction_signature_options/send/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,17 @@ pub fn sending_signed_transaction(
near_jsonrpc_client::methods::broadcast_tx_commit::RpcBroadcastTxCommitRequest {
signed_transaction: signed_transaction.clone(),
};
let request_payload = near_jsonrpc_client::methods::to_json(&request)?;

tracing::info!(
target: "near_teach_me",
parent: &tracing::Span::none(),
"I am making HTTP call to NEAR JSON RPC to broadcast a transaction, learn more https://docs.near.org/api/rpc/transactions#send-tx"
);
tracing::info!(
target: "near_teach_me",
parent: &tracing::Span::none(),
"HTTP POST {}",
network_config.rpc_url.as_str(),
);
tracing::info!(
target: "near_teach_me",
parent: &tracing::Span::none(),
"JSON Body:\n{}",
crate::common::indent_payload(&format!("{:#}", request_payload))
);

let transaction_info_result = network_config.json_rpc_client().blocking_call(request);
let transaction_info_result = network_config
.json_rpc_client()
.blocking_call(request)
.inspect(crate::common::teach_me_call_response);
match transaction_info_result {
Ok(response) => {
break response;
Expand All @@ -130,15 +120,6 @@ pub fn sending_signed_transaction(
};
};

let response_payload = serde_json::to_value(&transaction_info)?;

tracing::info!(
target: "near_teach_me",
parent: &tracing::Span::none(),
"JSON RPC Response:\n{}",
crate::common::indent_payload(&format!("{:#}", response_payload))
);

Ok(transaction_info)
}

Expand All @@ -148,6 +129,7 @@ pub fn sending_signed_transaction(
)]
pub fn sleep_after_error(additional_message_for_name: String) {
tracing::Span::current().pb_set_message(&additional_message_for_name);
tracing::info!(target: "near_teach_me", "{}", &additional_message_for_name);
std::thread::sleep(std::time::Duration::from_secs(5));
}

Expand Down

0 comments on commit c47df15

Please sign in to comment.