Skip to content

Commit

Permalink
add get_propostal_status with simple majority to eth_relayer
Browse files Browse the repository at this point in the history
  • Loading branch information
pscott committed Sep 5, 2023
1 parent aba2f37 commit fbade62
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions starknet/src/execution_strategies/eth_relayer.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod EthRelayerExecutionStrategy {
use serde::Serde;
use starknet::{info, syscalls, EthAddress};
use sx::interfaces::IExecutionStrategy;
use sx::types::{Proposal, ProposalStatus};
use sx::types::{Proposal, ProposalStatus, FinalizationStatus};

#[storage]
struct Storage {}
Expand All @@ -24,10 +24,7 @@ mod EthRelayerExecutionStrategy {
// We cannot have early proposal execution with this strategy because we determine the proposal status
// on L1 in a separate tx and therefore cannot ensure that the proposal is not still in the voting period
// when it is executed.
assert(
info::get_block_timestamp() >= proposal.max_end_timestamp.into(),
'Before max end timestamp'
);
self.get_proposal_status(proposal.clone(), votes_for, votes_against, votes_abstain);

let space = info::get_caller_address();

Expand Down Expand Up @@ -61,8 +58,24 @@ mod EthRelayerExecutionStrategy {
votes_against: u256,
votes_abstain: u256,
) -> ProposalStatus {
panic_with_felt252('unimplemented');
ProposalStatus::Cancelled(())
let timestamp: u32 = info::get_block_timestamp().try_into().unwrap();
if proposal.finalization_status == FinalizationStatus::Cancelled(()) {
ProposalStatus::Cancelled(())
} else if proposal.finalization_status == FinalizationStatus::Executed(()) {
ProposalStatus::Executed(())
} else if timestamp < proposal.start_timestamp {
ProposalStatus::VotingPeriod(())
} else if timestamp <= proposal.max_end_timestamp {
ProposalStatus::VotingPeriod(())
} else {
// Timestamp > max_end_timestamp, simple majority

if votes_for > votes_against {
ProposalStatus::Accepted(())
} else {
ProposalStatus::Rejected(())
}
}
}
}
}

0 comments on commit fbade62

Please sign in to comment.