Skip to content

Commit

Permalink
feat(cognitarium): implement store query msg
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Jun 1, 2023
1 parent 24e4c45 commit 4f0b8fb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 3 additions & 3 deletions contracts/okp4-cognitarium/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {

pub mod query {
use super::*;
use crate::msg::StoreStat;
use crate::msg::StoreResponse;

pub fn store(deps: Deps) -> StdResult<StoreStat> {
Err(StdError::generic_err("Not implemented"))
pub fn store(deps: Deps) -> StdResult<StoreResponse> {
STORE.load(deps.storage).map(|s| s.into())
}
}

Expand Down
21 changes: 21 additions & 0 deletions contracts/okp4-cognitarium/src/state/store.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::msg;
use crate::msg::StoreResponse;
use cosmwasm_std::{Addr, Uint128};
use cw_storage_plus::Item;
use serde::{Deserialize, Serialize};
Expand All @@ -22,6 +23,16 @@ impl Store {
}
}

impl From<Store> for StoreResponse {
fn from(value: Store) -> Self {
Self {
owner: value.owner.into(),
limits: value.limits.into(),
stat: value.stat.into(),
}
}
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct StoreLimits {
pub max_triple_count: Uint128,
Expand Down Expand Up @@ -67,3 +78,13 @@ pub struct StoreStat {
pub namespace_count: Uint128,
pub byte_size: Uint128,
}

impl From<StoreStat> for msg::StoreStat {
fn from(value: StoreStat) -> Self {
Self {
triple_count: value.triple_count,
namespace_count: value.namespace_count,
byte_size: value.byte_size,
}
}
}

0 comments on commit 4f0b8fb

Please sign in to comment.