Skip to content

Commit

Permalink
feat(law): implement the program query
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeneux committed Mar 24, 2023
1 parent 17e31d1 commit fe4b0da
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions contracts/cw-law-stone/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,22 @@ pub fn execute(
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(_deps: Deps<'_>, _env: Env, _msg: QueryMsg) -> StdResult<Binary> {
Err(StdError::generic_err("Not implemented"))
pub fn query(deps: Deps<'_, LogicCustomQuery>, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Ask { .. } => Err(StdError::generic_err("not implemented")),
QueryMsg::Program => to_binary(&query::program(deps)?),
}
}

pub mod query {
use super::*;
use crate::msg::ProgramResponse;
use crate::state::PROGRAM;

pub fn program(deps: Deps<'_, LogicCustomQuery>) -> StdResult<ProgramResponse> {
let program = PROGRAM.load(deps.storage)?;
Ok(ProgramResponse::from(program))
}
}

#[cfg_attr(not(feature = "library"), entry_point)]
Expand Down

0 comments on commit fe4b0da

Please sign in to comment.