Skip to content

Commit

Permalink
feat(ucs01-relay-api): added cosmos account hasher
Browse files Browse the repository at this point in the history
  • Loading branch information
PoisonPhang committed Apr 8, 2024
1 parent f1a7b90 commit 1a76501
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cosmwasm/ucs01-relay-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ serde = { workspace = true }
serde-json-wasm = { workspace = true }
unionlabs = { workspace = true }
go-parse-duration = { workspace = true }
sha2 = { workspace = true }
14 changes: 14 additions & 0 deletions cosmwasm/ucs01-relay-api/src/middleware.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use unionlabs::{
id::{ChannelId, PortId},
validated::{Validate, Validated},
Expand Down Expand Up @@ -63,5 +64,18 @@ impl<T: Into<String> + From<String>> Validate<T> 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<u8> {
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()
}

0 comments on commit 1a76501

Please sign in to comment.