diff --git a/Cargo.lock b/Cargo.lock index 2bfe9d46..c25984f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -232,6 +232,7 @@ dependencies = [ name = "cw-storage" version = "0.1.0" dependencies = [ + "base16ct", "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", @@ -240,6 +241,7 @@ dependencies = [ "cw2", "schemars", "serde", + "sha2 0.10.6", "thiserror", ] diff --git a/contracts/cw-storage/Cargo.toml b/contracts/cw-storage/Cargo.toml index eaf300cd..d302b013 100644 --- a/contracts/cw-storage/Cargo.toml +++ b/contracts/cw-storage/Cargo.toml @@ -35,6 +35,8 @@ cw2.workspace = true schemars.workspace = true serde.workspace = true thiserror.workspace = true +sha2 = "0.10.6" +base16ct = "0.1.1" [dev-dependencies] cw-multi-test.workspace = true diff --git a/contracts/cw-storage/src/crypto.rs b/contracts/cw-storage/src/crypto.rs new file mode 100644 index 00000000..7533fccb --- /dev/null +++ b/contracts/cw-storage/src/crypto.rs @@ -0,0 +1,5 @@ +use sha2::{Sha256, Digest}; + +pub fn sha256_hash(data: &Vec) -> String { + base16ct::lower::encode_string(&Sha256::digest(data)) +} diff --git a/contracts/cw-storage/src/lib.rs b/contracts/cw-storage/src/lib.rs index dfedc9dc..9094ecf0 100644 --- a/contracts/cw-storage/src/lib.rs +++ b/contracts/cw-storage/src/lib.rs @@ -2,5 +2,6 @@ pub mod contract; mod error; pub mod msg; pub mod state; +pub mod crypto; pub use crate::error::ContractError;