Skip to content

Commit

Permalink
feat(cognitarium): introduce blank node id counter state
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Feb 27, 2024
1 parent 458b536 commit 2e60a12
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion contracts/okp4-cognitarium/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use cw2::set_contract_version;

use crate::error::ContractError;
use crate::msg::{DataFormat, ExecuteMsg, InstantiateMsg, QueryMsg};
use crate::state::{Store, NAMESPACE_KEY_INCREMENT, STORE};
use crate::state::{Store, BLANK_NODE_IDENTIFIER_COUNTER, NAMESPACE_KEY_INCREMENT, STORE};

// version info for migration info
const CONTRACT_NAME: &str = concat!("crates.io:", env!("CARGO_PKG_NAME"));
Expand All @@ -24,6 +24,7 @@ pub fn instantiate(

STORE.save(deps.storage, &Store::new(info.sender, msg.limits.into()))?;
NAMESPACE_KEY_INCREMENT.save(deps.storage, &0u128)?;
BLANK_NODE_IDENTIFIER_COUNTER.save(deps.storage, &0u128)?;

Ok(Response::default())
}
Expand Down Expand Up @@ -443,6 +444,10 @@ mod tests {
);

assert_eq!(NAMESPACE_KEY_INCREMENT.load(&deps.storage).unwrap(), 0u128);
assert_eq!(
BLANK_NODE_IDENTIFIER_COUNTER.load(&deps.storage).unwrap(),
0u128
);
}

#[test]
Expand Down
4 changes: 4 additions & 0 deletions contracts/okp4-cognitarium/src/state/blank_nodes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use cw_storage_plus::Item;

/// A counter serving as blank node unique identifier generator.
pub const BLANK_NODE_IDENTIFIER_COUNTER: Item<'_, u128> = Item::new("blank_node_key");
2 changes: 2 additions & 0 deletions contracts/okp4-cognitarium/src/state/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
mod blank_nodes;
mod namespaces;
mod store;
mod triples;

pub use blank_nodes::*;
pub use namespaces::*;
pub use store::*;
pub use triples::*;

0 comments on commit 2e60a12

Please sign in to comment.