pub fn expire_poll(deps: DepsMut, env: Env, poll_id: u64) -> Result<Response, ContractError> {
    let config: Config = config_read(deps.storage).load()?;
    let mut a_poll: Poll = poll_store(deps.storage).load(&poll_id.to_be_bytes())?;

    if a_poll.status != PollStatus::Passed {
        return Err(ContractError::PollNotPassed {});
    }

    if a_poll.execute_data.is_none() {
        return Err(ContractError::NoExecuteData {});
    }

    if a_poll.end_height + config.expiration_period > env.block.height {
        return Err(ContractError::PollNotExpired {});
    }

    poll_indexer_store(deps.storage, &PollStatus::Passed).remove(&poll_id.to_be_bytes());
    poll_indexer_store(deps.storage, &PollStatus::Expired).save(&poll_id.to_be_bytes(), &true)?;

    a_poll.status = PollStatus::Expired;
    poll_store(deps.storage).save(&poll_id.to_be_bytes(), &a_poll)?;

    Ok(Response::new().add_attributes(vec![
        ("action", "expire_poll"),
        ("poll_id", poll_id.to_string().as_str()),
    ]))
}
/// ExpirePoll is used to make the poll as expired state for querying purpose
ExpirePoll is used to make the poll as expired state for querying purpose
ExpirePoll is used to make the poll as expired state for querying purpose
pub fn expire_poll(deps: DepsMut, env: Env, poll_id: u64) -> Result<Response, ContractError> {
    let config: Config = config_read(deps.storage).load()?;
    let mut a_poll: Poll = poll_store(deps.storage).load(&poll_id.to_be_bytes())?;
    if a_poll.status != PollStatus::Passed {
        return Err(ContractError::PollNotPassed {});
    }
    if a_poll.execute_data.is_none() {
        return Err(ContractError::NoExecuteData {});
    }
    if a_poll.end_height + config.expiration_period > env.block.height {
        return Err(ContractError::PollNotExpired {});
    }
    poll_indexer_store(deps.storage, &PollStatus::Passed).remove(&poll_id.to_be_bytes());
    poll_indexer_store(deps.storage, &PollStatus::Expired).save(&poll_id.to_be_bytes(), &true)?;
    a_poll.status = PollStatus::Expired;
    poll_store(deps.storage).save(&poll_id.to_be_bytes(), &a_poll)?;
    Ok(Response::new().add_attributes(vec![
        ("action", "expire_poll"),
        ("poll_id", poll_id.to_string().as_str()),
    ]))
}
pub fn expire_poll ( deps : DepsMut , env : Env , poll_id : u64 ) -> Result < Response , ContractError > { let config : Config = config_read ( deps . storage ) . load ( ) ? ; let mut a_poll : Poll = poll_store ( deps . storage ) . load ( & poll_id . to_be_bytes ( ) ) ? ; if a_poll . status != PollStatus :: Passed { return Err ( ContractError :: PollNotPassed { } ) ; } if a_poll . execute_data . is_none ( ) { return Err ( ContractError :: NoExecuteData { } ) ; } if a_poll . end_height + config . expiration_period > env . block . height { return Err ( ContractError :: PollNotExpired { } ) ; } poll_indexer_store ( deps . storage , & PollStatus :: Passed ) . remove ( & poll_id . to_be_bytes ( ) ) ; poll_indexer_store ( deps . storage , & PollStatus :: Expired ) . save ( & poll_id . to_be_bytes ( ) , & true ) ? ; a_poll . status = PollStatus :: Expired ; poll_store ( deps . storage ) . save ( & poll_id . to_be_bytes ( ) , & a_poll ) ? ; Ok ( Response :: new ( ) . add_attributes ( vec ! [ ( " " " " ) ( " " poll_id to_string ( ) as_str ( ) ) ] ) ) }
ExpirePoll is used to make the poll as expired state for querying purpose
ExpirePoll is used to make the poll as expired state for querying purpose
deps
DepsMut
env
Env
poll_id
u64
deps
DepsMut
env
Env
poll_id
u64