diff --git a/crates/apps_lib/src/client/rpc.rs b/crates/apps_lib/src/client/rpc.rs index ab280fb4ff..a642bd4856 100644 --- a/crates/apps_lib/src/client/rpc.rs +++ b/crates/apps_lib/src/client/rpc.rs @@ -1183,11 +1183,8 @@ pub async fn query_total_supply( args: args::QueryTotalSupply, ) { let token = args.token; - let supply = unwrap_client_response::( - RPC.vp() - .token() - .total_supply(context.client(), &token) - .await, + let supply = unwrap_sdk_result( + rpc::get_token_total_supply(context.client(), &token).await, ); let amount_str = format_denominated_amount( context.client(), @@ -2046,6 +2043,14 @@ fn unwrap_client_response( }) } +/// A helper to unwrap an SDK query result. Will shut down process on error. +fn unwrap_sdk_result(response: Result) -> T { + response.unwrap_or_else(|err| { + eprintln!("Error in the query: {:?}", err); + cli::safe_exit(1) + }) +} + pub async fn compute_proposal_votes( client: &C, proposal_id: u64,