Skip to content

Commit

Permalink
feat get_latest_proposal_id (CarmineOptions#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
scobi7 committed Aug 5, 2024
1 parent 48c407c commit f2a40a1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/proposals.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use starknet::ContractAddress;
trait IProposals<TContractState> {
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
Expand Down Expand Up @@ -34,6 +36,7 @@ trait IProposals<TContractState> {
prop_id: felt252,
);
fn get_total_delegated_to(self: @TContractState, to_addr: ContractAddress) -> u128;

}

#[starknet::component]
Expand Down Expand Up @@ -300,6 +303,10 @@ mod proposals {
self.proposal_details.read(prop_id)
}

fn get_latest_proposal_id(self: @ComponentState<TContractState>) -> felt252 {
self.get_free_prop_id_timestamp() - 1
}

fn get_live_proposals(self: @ComponentState<TContractState>) -> Array<felt252> {
let max: u32 = self.get_free_prop_id_timestamp().try_into().unwrap();
let mut i: u32 = 0;
Expand Down

0 comments on commit f2a40a1

Please sign in to comment.