diff --git a/Cargo.lock b/Cargo.lock index 04ca44dd13..ad67c09b92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6829,6 +6829,7 @@ dependencies = [ "go-parse-duration", "serde", "serde-json-wasm 1.0.1", + "sha2 0.10.8", "thiserror", "token-factory-api", "unionlabs", diff --git a/cosmwasm/ucs01-relay-api/Cargo.toml b/cosmwasm/ucs01-relay-api/Cargo.toml index ab6ca560a5..bc745a916a 100644 --- a/cosmwasm/ucs01-relay-api/Cargo.toml +++ b/cosmwasm/ucs01-relay-api/Cargo.toml @@ -16,3 +16,4 @@ serde = { workspace = true } serde-json-wasm = { workspace = true } unionlabs = { workspace = true } go-parse-duration = { workspace = true } +sha2 = { workspace = true } diff --git a/cosmwasm/ucs01-relay-api/src/middleware.rs b/cosmwasm/ucs01-relay-api/src/middleware.rs index 44d7c35832..4a8facbe96 100644 --- a/cosmwasm/ucs01-relay-api/src/middleware.rs +++ b/cosmwasm/ucs01-relay-api/src/middleware.rs @@ -1,4 +1,5 @@ use serde::{Deserialize, Serialize}; +use sha2::{Digest, Sha256}; use unionlabs::{ id::{ChannelId, PortId}, validated::{Validate, Validated}, @@ -63,5 +64,18 @@ impl + From> Validate for NotEmptyString { /// the receiver address is deterministic and can be used to identify the sender on the /// initial chain. pub fn GetReceiver(channel_id: ChannelId, original_sender: String) -> String { + let sender_string = format!("{0}/{1}", channel_id.value(), original_sender); todo!() } + +fn account_hash(typ: String, key: &[u8]) -> Vec { + let mut hasher = Sha256::new(); + hasher.update(typ.as_bytes()); + let th = hasher.finalize(); + + let mut hasher = Sha256::new(); + hasher.update(th); + hasher.update(key); + + hasher.finalize()[..].into() +}