Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
malik672 committed Dec 11, 2024
1 parent ea57ae0 commit b82aa5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions zink/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ repository.workspace = true
[lib]
proc-macro = true

[features]
selector = []

[dependencies]
heck.workspace = true
hex.workspace = true
Expand Down
4 changes: 3 additions & 1 deletion zink/codegen/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use syn::{
parse::Parse, parse_quote, spanned::Spanned, Abi, Data, DeriveInput, Error, Fields, LitByteStr,
Result, Type, Variant,
};
use zabi::keccak256;


/// Custom error type for better error handling
#[derive(Debug)]
Expand Down Expand Up @@ -313,11 +313,13 @@ fn type_to_string(ty: &Type) -> String {
}

/// Generate topic hash
#[cfg(feature = "selector")]
fn generate_topic_hash(input: &str) -> [u8; 32] {
keccak256(input.as_bytes().to_vec().as_slice())
}

/// Generate data hash
#[cfg(feature = "selector")]
fn generate_data_hash(data: &[Vec<u8>]) -> [u8; 32] {
let flattened: Vec<u8> = data.concat();
keccak256(&flattened.as_slice())
Expand Down

0 comments on commit b82aa5d

Please sign in to comment.