Skip to content

Commit

Permalink
Revert "fixed todos"
Browse files Browse the repository at this point in the history
  • Loading branch information
FroVolod committed Aug 23, 2024
1 parent de8521d commit 0bc6131
Showing 1 changed file with 22 additions and 48 deletions.
70 changes: 22 additions & 48 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,61 +417,37 @@ async fn view_account(
account_id: account_id.clone(),
},
};
// let request_payload = request_payload(&query_view_method_request)?;

tracing::info!(
target: "near_teach_me",
parent: &tracing::Span::none(),
"I am making HTTP call to NEAR JSON RPC to query information about `{}` account, learn more https://docs.near.org/api/rpc/contracts#view-account",
account_id
);
tracing::info!(
target: "near_teach_me",
parent: &tracing::Span::none(),
"HTTP POST {}",
json_rpc_client.server_addr()
);
// tracing::info!(
// target: "near_teach_me",
// parent: &tracing::Span::none(),
// "JSON Body:\n{}",
// indent_payload(&format!("{:#}", request_payload))
// );

if let Ok(request_payload) = near_jsonrpc_client::methods::to_json(&query_view_method_request) {
tracing::info!(
target: "near_teach_me",
parent: &tracing::Span::none(),
"HTTP POST {}",
json_rpc_client.server_addr()
);
tracing::info!(
target: "near_teach_me",
parent: &tracing::Span::none(),
"JSON Request Body:\n{}",
indent_payload(&format!("{:#}", request_payload))
);
}
let query_view_method_response = json_rpc_client.call(query_view_method_request).await;

let query_view_method_response = json_rpc_client
.call(query_view_method_request)
.await
.inspect_err(|err| match err {
near_jsonrpc_client::errors::JsonRpcError::TransportError(transport_error) => {
tracing::info!(
target: "near_teach_me",
parent: &tracing::Span::none(),
"JSON RPC Request failed due to connectivity issue:\n{}",
indent_payload(&format!("{:#?}", transport_error))
);
}
near_jsonrpc_client::errors::JsonRpcError::ServerError(
near_jsonrpc_client::errors::JsonRpcServerError::HandlerError(handler_error),
) => {
tracing::info!(
target: "near_teach_me",
parent: &tracing::Span::none(),
"JSON RPC Request returned a handling error:\n{}",
indent_payload(&serde_json::to_string_pretty(handler_error).unwrap_or_else(|_| handler_error.to_string()))
);
}
near_jsonrpc_client::errors::JsonRpcError::ServerError(server_error) => {
tracing::info!(
target: "near_teach_me",
parent: &tracing::Span::none(),
"JSON RPC Request returned a generic server error:\n{}",
indent_payload(&format!("{:#?}", server_error))
);
}
})
.inspect(teach_me_call_response);
// let response_payload = response_payload(&query_view_method_response)?;

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

query_view_method_response
}
Expand Down Expand Up @@ -2297,7 +2273,6 @@ impl JsonRpcClientExt for near_jsonrpc_client::JsonRpcClient {
);

self.blocking_call(query_view_method_request)
.inspect(teach_me_call_response)
}

#[tracing::instrument(name = "Getting a list of", skip_all)]
Expand Down Expand Up @@ -2330,7 +2305,6 @@ impl JsonRpcClientExt for near_jsonrpc_client::JsonRpcClient {
);

self.blocking_call(query_view_method_request)
.inspect(teach_me_call_response)
}

#[tracing::instrument(name = "Getting information about", skip_all)]
Expand Down

0 comments on commit 0bc6131

Please sign in to comment.