From fe4b0da6ac5aae0f36cd264279a5e6eba593ba44 Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Fri, 24 Mar 2023 08:28:06 +0100 Subject: [PATCH] feat(law): implement the program query --- contracts/cw-law-stone/src/contract.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/contracts/cw-law-stone/src/contract.rs b/contracts/cw-law-stone/src/contract.rs index 900c3df2..465acd42 100644 --- a/contracts/cw-law-stone/src/contract.rs +++ b/contracts/cw-law-stone/src/contract.rs @@ -58,8 +58,22 @@ pub fn execute( } #[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(_deps: Deps<'_>, _env: Env, _msg: QueryMsg) -> StdResult { - Err(StdError::generic_err("Not implemented")) +pub fn query(deps: Deps<'_, LogicCustomQuery>, _env: Env, msg: QueryMsg) -> StdResult { + 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 { + let program = PROGRAM.load(deps.storage)?; + Ok(ProgramResponse::from(program)) + } } #[cfg_attr(not(feature = "library"), entry_point)]