Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszjasiuk committed Jun 4, 2024
1 parent 1b7a0ef commit b573387
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions chain/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,12 @@ async fn initial_query(
tracing::info!("Querying proposals...");
let proposals = query_all_proposals(client).await.into_rpc_error()?;
let proposals_with_tally =
namada_service::query_tallies(&client, proposals.clone())
namada_service::query_tallies(client, proposals.clone())
.await
.into_rpc_error()?;

let proposals_votes = namada_service::query_all_votes(
&client,
client,
proposals.iter().map(|p| p.id).collect(),
)
.await
Expand Down
5 changes: 2 additions & 3 deletions chain/src/services/namada.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,7 @@ pub async fn query_tallies(
) -> anyhow::Result<Vec<(GovernanceProposal, TallyType)>> {
let proposals = futures::stream::iter(proposals)
.filter_map(|proposal| async move {
let is_steward =
is_steward(&client, &proposal.author).await.ok()?;
let is_steward = is_steward(client, &proposal.author).await.ok()?;

let tally_type = TallyType::from(&proposal.r#type, is_steward);

Expand Down Expand Up @@ -475,7 +474,7 @@ pub async fn query_all_votes(
.collect::<Vec<_>>()
.await;

anyhow::Ok(votes.iter().cloned().flatten().collect())
anyhow::Ok(votes.iter().flatten().cloned().collect())
}

fn to_block_height(block_height: u32) -> NamadaSdkBlockHeight {
Expand Down
19 changes: 15 additions & 4 deletions seeder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ use seeder::state::AppState;
use shared::balance::Balance;
use shared::bond::Bond;
use shared::error::{AsDbError, ContextDbInteractError, MainError};
use shared::proposal::{GovernanceProposal, GovernanceProposalStatus};
use shared::proposal::{
GovernanceProposal, GovernanceProposalStatus, TallyType,
};
use shared::rewards::Reward;
use shared::unbond::Unbond;
use shared::validator::Validator;
Expand Down Expand Up @@ -58,6 +60,15 @@ async fn main() -> anyhow::Result<(), MainError> {
.map(GovernanceProposal::fake)
.collect::<Vec<GovernanceProposal>>();

let governance_proposals_with_tally = governance_proposals
.iter()
.cloned()
.map(|proposal| {
let tally_type = TallyType::fake();
(proposal, tally_type)
})
.collect::<Vec<(GovernanceProposal, TallyType)>>();

let governance_proposals_status = (0..config.total_proposals)
.map(GovernanceProposalStatus::fake)
.collect::<Vec<GovernanceProposalStatus>>();
Expand Down Expand Up @@ -149,10 +160,10 @@ async fn main() -> anyhow::Result<(), MainError> {

diesel::insert_into(governance_proposals::table)
.values::<&Vec<GovernanceProposalInsertDb>>(
&governance_proposals
&governance_proposals_with_tally
.into_iter()
.map(|proposal| {
GovernanceProposalInsertDb::from_governance_proposal(proposal)
.map(|(proposal, tally_type)| {
GovernanceProposalInsertDb::from_governance_proposal(proposal, tally_type)
})
.collect::<Vec<_>>(),
)
Expand Down
4 changes: 4 additions & 0 deletions shared/src/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ pub enum TallyType {

// TODO: copied from namada for time being
impl TallyType {
pub fn fake() -> Self {
rand::random()
}

pub fn from(
proposal_type: &GovernanceProposalKind,
is_steward: bool,
Expand Down

0 comments on commit b573387

Please sign in to comment.