fn query_poll(deps: Deps, poll_id: u64) -> Result<PollResponse, ContractError> {
    let poll = match poll_read(deps.storage).may_load(&poll_id.to_be_bytes())? {
        Some(poll) => Some(poll),
        None => return Err(ContractError::PollNotFound {}),
    }
    .unwrap();

    let mut data_list: Vec<PollExecuteMsg> = vec![];

    Ok(PollResponse {
        id: poll.id,
        creator: deps.api.addr_humanize(&poll.creator)?.to_string(),
        status: poll.status,
        end_height: poll.end_height,
        title: poll.title,
        description: poll.description,
        link: poll.link,
        deposit_amount: poll.deposit_amount,
        execute_data: if let Some(exe_msgs) = poll.execute_data.clone() {
            for msg in exe_msgs {
                let execute_data = PollExecuteMsg {
                    order: msg.order,
                    contract: deps.api.addr_humanize(&msg.contract)?.to_string(),
                    msg: msg.msg,
                };
                data_list.push(execute_data)
            }
            Some(data_list)
        } else {
            None
        },
        yes_votes: poll.yes_votes,
        no_votes: poll.no_votes,
        staked_amount: poll.staked_amount,
        total_balance_at_end_poll: poll.total_balance_at_end_poll,
    })
}
/// query_poll allows for the query of a given poll by supplying its poll_id
query_poll allows for the query of a given poll by supplying its poll_id
query_poll allows for the query of a given poll by supplying its poll_id
fn query_poll(deps: Deps, poll_id: u64) -> Result<PollResponse, ContractError> {
    let poll = match poll_read(deps.storage).may_load(&poll_id.to_be_bytes())? {
        Some(poll) => Some(poll),
        None => return Err(ContractError::PollNotFound {}),
    }
    .unwrap();
    let mut data_list: Vec<PollExecuteMsg> = vec![];
    Ok(PollResponse {
        id: poll.id,
        creator: deps.api.addr_humanize(&poll.creator)?.to_string(),
        status: poll.status,
        end_height: poll.end_height,
        title: poll.title,
        description: poll.description,
        link: poll.link,
        deposit_amount: poll.deposit_amount,
        execute_data: if let Some(exe_msgs) = poll.execute_data.clone() {
            for msg in exe_msgs {
                let execute_data = PollExecuteMsg {
                    order: msg.order,
                    contract: deps.api.addr_humanize(&msg.contract)?.to_string(),
                    msg: msg.msg,
                };
                data_list.push(execute_data)
            }
            Some(data_list)
        } else {
            None
        },
        yes_votes: poll.yes_votes,
        no_votes: poll.no_votes,
        staked_amount: poll.staked_amount,
        total_balance_at_end_poll: poll.total_balance_at_end_poll,
    })
}
fn query_poll ( deps : Deps , poll_id : u64 ) -> Result < PollResponse , ContractError > { let poll = match poll_read ( deps . storage ) . may_load ( & poll_id . to_be_bytes ( ) ) ? { Some ( poll ) => Some ( poll ) , None => return Err ( ContractError :: PollNotFound { } ) , } . unwrap ( ) ; let mut data_list : Vec < PollExecuteMsg > = vec ! [ ] ; Ok ( PollResponse { id : poll . id , creator : deps . api . addr_humanize ( & poll . creator ) ? . to_string ( ) , status : poll . status , end_height : poll . end_height , title : poll . title , description : poll . description , link : poll . link , deposit_amount : poll . deposit_amount , execute_data : if let Some ( exe_msgs ) = poll . execute_data . clone ( ) { for msg in exe_msgs { let execute_data = PollExecuteMsg { order : msg . order , contract : deps . api . addr_humanize ( & msg . contract ) ? . to_string ( ) , msg : msg . msg , } ; data_list . push ( execute_data ) } Some ( data_list ) } else { None } , yes_votes : poll . yes_votes , no_votes : poll . no_votes , staked_amount : poll . staked_amount , total_balance_at_end_poll : poll . total_balance_at_end_poll , } ) }
query_poll allows for the query of a given poll by supplying its poll_id
query_poll allows for the query of a given poll by supplying its poll_id
deps
Deps
poll_id
u64
deps
Deps
poll_id
u64