From f2a40a1ddc479a4a87040870fefd7b034d64b551 Mon Sep 17 00:00:00 2001 From: scobi Date: Mon, 5 Aug 2024 10:44:29 +0000 Subject: [PATCH] feat get_latest_proposal_id (#116) --- src/proposals.cairo | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/proposals.cairo b/src/proposals.cairo index 1d5bbd2e..8c2697a7 100644 --- a/src/proposals.cairo +++ b/src/proposals.cairo @@ -7,6 +7,8 @@ use starknet::ContractAddress; trait IProposals { fn vote(ref self: TContractState, prop_id: felt252, opinion: felt252); fn get_proposal_details(self: @TContractState, prop_id: felt252) -> PropDetails; + fn get_latest_proposal_id(self: @TContractState) -> felt252; + fn get_vote_counts(self: @TContractState, prop_id: felt252) -> (u128, u128); fn submit_proposal( ref self: TContractState, payload: felt252, to_upgrade: ContractType @@ -34,6 +36,7 @@ trait IProposals { prop_id: felt252, ); fn get_total_delegated_to(self: @TContractState, to_addr: ContractAddress) -> u128; + } #[starknet::component] @@ -300,6 +303,10 @@ mod proposals { self.proposal_details.read(prop_id) } + fn get_latest_proposal_id(self: @ComponentState) -> felt252 { + self.get_free_prop_id_timestamp() - 1 + } + fn get_live_proposals(self: @ComponentState) -> Array { let max: u32 = self.get_free_prop_id_timestamp().try_into().unwrap(); let mut i: u32 = 0;