Skip to content

Commit

Permalink
feat: added callback counter query
Browse files Browse the repository at this point in the history
  • Loading branch information
srdtrk committed Jun 19, 2023
1 parent 70f534c commit 1ada6a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::GetContractState {} => to_binary(&query::state(deps)?),
QueryMsg::GetChannel {} => to_binary(&query::channel(deps)?),
QueryMsg::GetCallbackCounter {} => to_binary(&query::callback_counter(deps)?),
}
}

Expand Down Expand Up @@ -140,6 +141,11 @@ mod query {
pub fn channel(deps: Deps) -> StdResult<ChannelState> {
CHANNEL_STATE.load(deps.storage)
}

/// Returns the saved callback counter.
pub fn callback_counter(deps: Deps) -> StdResult<CallbackCounter> {
CALLBACK_COUNTER.load(deps.storage)
}
}

#[cfg(test)]
Expand Down
4 changes: 3 additions & 1 deletion src/types/msg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::Binary;

use crate::types::state::{ChannelState, ContractState};
use crate::types::state::{CallbackCounter, ChannelState, ContractState};

Check warning on line 4 in src/types/msg.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused imports: `CallbackCounter`, `ChannelState`, `ContractState`

#[cw_serde]
pub struct InstantiateMsg {
Expand Down Expand Up @@ -54,4 +54,6 @@ pub enum QueryMsg {
GetChannel {},
#[returns(ContractState)]
GetContractState {},
#[returns(CallbackCounter)]
GetCallbackCounter {},
}

0 comments on commit 1ada6a9

Please sign in to comment.