diff --git a/apps/src/lib/client/rpc.rs b/apps/src/lib/client/rpc.rs index d750ccc759..22fb627860 100644 --- a/apps/src/lib/client/rpc.rs +++ b/apps/src/lib/client/rpc.rs @@ -1045,23 +1045,39 @@ pub async fn query_proposal_result< return; }; - let is_author_steward = query_pgf_stewards(client) - .await - .iter() - .any(|steward| steward.address.eq(&proposal.author)); - let tally_type = proposal.get_tally_type(is_author_steward); - let total_voting_power = - get_total_staked_tokens(client, proposal.voting_end_epoch).await; + let proposal_result_key = + governance_storage::get_proposal_result_key(proposal_id); + let proposal_result = + // Try to directly query the result in storage first + match query_storage_value(client, &proposal_result_key).await { + Ok(result) => result, + Err(_) => { + // If failure, run the tally + let is_author_steward = query_pgf_stewards(client) + .await + .iter() + .any(|steward| steward.address.eq(&proposal.author)); + let tally_type = proposal.get_tally_type(is_author_steward); + let total_voting_power = get_total_staked_tokens( + client, + proposal.voting_end_epoch, + ) + .await; - let votes = compute_proposal_votes( - client, - proposal_id, - proposal.voting_end_epoch, - ) - .await; + let votes = compute_proposal_votes( + client, + proposal_id, + proposal.voting_end_epoch, + ) + .await; - let proposal_result = - compute_proposal_result(votes, total_voting_power, tally_type); + compute_proposal_result( + votes, + total_voting_power, + tally_type, + ) + } + }; display_line!(IO, "Proposal Id: {} ", proposal_id); display_line!(IO, "{:4}{}", "", proposal_result);