thegraph: Fix hashing algorithm in string_to_h256
use ethabi::{Contract, Event};
use ethereum_types::H256;
-use tiny_keccak::sha3_256;
+use tiny_keccak::Keccak;
/// Hashes a string to a H256 hash.
-fn string_to_h256(string: &str) -> H256 {
- let bytes = string.as_bytes();
- let hash = sha3_256(bytes);
- H256::from_slice(&hash[0..32])
+fn string_to_h256(s: &str) -> H256 {
+ let mut result = [0u8; 32];
+
+ let data: Vec<u8> = From::from(s);
+ let mut sponge = Keccak::new_keccak256();
+ sponge.update(&data);
+ sponge.finalize(&mut result);
+
+ H256::from_slice(&result)
}
/// Returns the contract event with the given signature, if it exists.
