pub fn assert_can_execute_instruction(
        &self,
        proposal_instruction_data: &ProposalInstruction,
        current_unix_timestamp: UnixTimestamp,
    ) -> Result<(), ProgramError> {
        match self.state {
            ProposalState::Succeeded | ProposalState::Executing => {}
            ProposalState::Draft
            | ProposalState::SigningOff
            | ProposalState::Completed
            | ProposalState::Voting
            | ProposalState::Cancelled
            | ProposalState::Defeated => {
                return Err(GovernanceError::InvalidStateCannotExecuteInstruction.into())
            }
        }

        if self
            .voting_completed_at
            .unwrap()
            .checked_add(proposal_instruction_data.hold_up_time as i64)
            .unwrap()
            >= current_unix_timestamp
        {
            return Err(GovernanceError::CannotExecuteInstructionWithinHoldUpTime.into());
        }

        if proposal_instruction_data.executed_at.is_some() {
            return Err(GovernanceError::InstructionAlreadyExecuted.into());
        }

        Ok(())
    }
/// Checks if Instructions can be executed for the Proposal in the given state
Checks if Instructions can be executed for the Proposal in the given state
Checks if Instructions can be executed for the Proposal in the given state
pub fn assert_can_execute_instruction(
        &self,
        proposal_instruction_data: &ProposalInstruction,
        current_unix_timestamp: UnixTimestamp,
    ) -> Result<(), ProgramError> {
        match self.state {
            ProposalState::Succeeded | ProposalState::Executing => {}
            ProposalState::Draft
            | ProposalState::SigningOff
            | ProposalState::Completed
            | ProposalState::Voting
            | ProposalState::Cancelled
            | ProposalState::Defeated => {
                return Err(GovernanceError::InvalidStateCannotExecuteInstruction.into())
            }
        }
        if self
            .voting_completed_at
            .unwrap()
            .checked_add(proposal_instruction_data.hold_up_time as i64)
            .unwrap()
            >= current_unix_timestamp
        {
            return Err(GovernanceError::CannotExecuteInstructionWithinHoldUpTime.into());
        }
        if proposal_instruction_data.executed_at.is_some() {
            return Err(GovernanceError::InstructionAlreadyExecuted.into());
        }
        Ok(())
    }
pub fn assert_can_execute_instruction ( & self , proposal_instruction_data : & ProposalInstruction , current_unix_timestamp : UnixTimestamp , ) -> Result < ( ) , ProgramError > { match self . state { ProposalState :: Succeeded | ProposalState :: Executing => { } ProposalState :: Draft | ProposalState :: SigningOff | ProposalState :: Completed | ProposalState :: Voting | ProposalState :: Cancelled | ProposalState :: Defeated => { return Err ( GovernanceError :: InvalidStateCannotExecuteInstruction . into ( ) ) } } if self . voting_completed_at . unwrap ( ) . checked_add ( proposal_instruction_data . hold_up_time as i64 ) . unwrap ( ) >= current_unix_timestamp { return Err ( GovernanceError :: CannotExecuteInstructionWithinHoldUpTime . into ( ) ) ; } if proposal_instruction_data . executed_at . is_some ( ) { return Err ( GovernanceError :: InstructionAlreadyExecuted . into ( ) ) ; } Ok ( ( ) ) }
Checks if Instructions can be executed for the Proposal in the given state
Checks if Instructions can be executed for the Proposal in the given state
&self
proposal_instruction_data
&ProposalInstruction
current_unix_timestamp
UnixTimestamp
&self
proposal_instruction_data
&ProposalInstruction
current_unix_timestamp
UnixTimestamp