diff --git a/contracts/injective-auction-pool/src/contract.rs b/contracts/injective-auction-pool/src/contract.rs index 9e5661d..56ce2c8 100644 --- a/contracts/injective-auction-pool/src/contract.rs +++ b/contracts/injective-auction-pool/src/contract.rs @@ -9,6 +9,7 @@ use injective_auction::auction_pool::{Config, ExecuteMsg, InstantiateMsg, QueryM use crate::error::ContractError; use crate::executions::{self, settle_auction}; use crate::helpers::{query_current_auction, validate_percentage}; +use crate::queries; use crate::state::{Auction, BIDDING_BALANCE, CONFIG, UNSETTLED_AUCTION}; const CONTRACT_NAME: &str = "crates.io:injective-auction-pool"; @@ -128,6 +129,8 @@ pub fn execute( } #[entry_point] -pub fn query(_deps: Deps, _env: Env, _msg: QueryMsg) -> StdResult { - unimplemented!() +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + match msg { + QueryMsg::Config {} => queries::query_config(deps), + } } diff --git a/contracts/injective-auction-pool/src/lib.rs b/contracts/injective-auction-pool/src/lib.rs index 3c47f89..948c365 100644 --- a/contracts/injective-auction-pool/src/lib.rs +++ b/contracts/injective-auction-pool/src/lib.rs @@ -3,6 +3,7 @@ mod error; pub mod executions; pub mod helpers; pub mod msg; +pub mod queries; pub mod state; pub use crate::error::ContractError; diff --git a/contracts/injective-auction-pool/src/queries.rs b/contracts/injective-auction-pool/src/queries.rs new file mode 100644 index 0000000..8dd7eaa --- /dev/null +++ b/contracts/injective-auction-pool/src/queries.rs @@ -0,0 +1,10 @@ +use cosmwasm_std::{to_json_binary, Binary, Deps, StdResult}; +use injective_auction::auction_pool::ConfigResponse; + +use crate::state::CONFIG; + +pub fn query_config(deps: Deps) -> StdResult { + to_json_binary(&ConfigResponse { + config: CONFIG.load(deps.storage)?, + }) +} diff --git a/contracts/injective-auction-pool/src/tests/unit_tests.rs b/contracts/injective-auction-pool/src/tests/unit_tests.rs index 7547d0d..3292d2f 100644 --- a/contracts/injective-auction-pool/src/tests/unit_tests.rs +++ b/contracts/injective-auction-pool/src/tests/unit_tests.rs @@ -7,13 +7,13 @@ use cosmwasm_std::{ OwnedDeps, Querier, QuerierResult, QueryRequest, Uint128, WasmMsg, }; use injective_auction::auction::{Coin, MsgBid, QueryCurrentAuctionBasketResponse}; -use injective_auction::auction_pool::{ExecuteMsg, InstantiateMsg}; +use injective_auction::auction_pool::{ConfigResponse, ExecuteMsg, InstantiateMsg, QueryMsg}; use prost::Message; use std::marker::PhantomData; use treasurechest::tf::tokenfactory::TokenFactoryType; -use crate::contract::{execute, instantiate}; -use crate::state::{BIDDING_BALANCE, CONFIG}; +use crate::contract::{execute, instantiate, query}; +use crate::state::BIDDING_BALANCE; use crate::ContractError; pub struct AuctionQuerier { @@ -154,7 +154,10 @@ fn update_config() { ] ); - let config = CONFIG.load(&deps.storage).unwrap(); + // query the config to check if it was updated + let msg = QueryMsg::Config {}; + let res: ConfigResponse = from_json(&query(deps.as_ref(), env.clone(), msg).unwrap()).unwrap(); + let config = res.config; assert_eq!(config.owner, Addr::unchecked("new_owner")); assert_eq!(config.rewards_fee, Decimal::percent(20)); assert_eq!(config.rewards_fee_addr, "new_rewards_addr".to_string()); diff --git a/packages/injective_auction/src/auction_pool.rs b/packages/injective_auction/src/auction_pool.rs index 7102a96..4e19b0f 100644 --- a/packages/injective_auction/src/auction_pool.rs +++ b/packages/injective_auction/src/auction_pool.rs @@ -60,7 +60,15 @@ pub enum ExecuteMsg { #[cw_serde] #[derive(QueryResponses)] -pub enum QueryMsg {} +pub enum QueryMsg { + #[returns(ConfigResponse)] + Config {}, +} + +#[cw_serde] +pub struct ConfigResponse { + pub config: Config, +} #[cw_serde] /// Config of the contract