(
config: &DVFConfig,
address: &Address,
block_num: u64,
)
| 1019 | } |
| 1020 | |
| 1021 | pub fn get_eth_codehash( |
| 1022 | config: &DVFConfig, |
| 1023 | address: &Address, |
| 1024 | block_num: u64, |
| 1025 | ) -> Result<String, ValidationError> { |
| 1026 | let code = get_eth_code(config, address, block_num)?; |
| 1027 | let code_bytes = hex::decode(code.trim_start_matches("0x"))?; |
| 1028 | |
| 1029 | // Hashing the contract code |
| 1030 | let mut hasher = Keccak::v256(); |
| 1031 | let mut output = [0u8; 32]; |
| 1032 | hasher.update(&code_bytes); |
| 1033 | hasher.finalize(&mut output); |
| 1034 | |
| 1035 | let code_hash = format!("0x{}", hex::encode(output)); |
| 1036 | |
| 1037 | info!("The codehash of the contract is {}", code_hash); |
| 1038 | |
| 1039 | Ok(code_hash) |
| 1040 | } |
| 1041 | |
| 1042 | fn u256_to_bytes(u: &U256) -> [u8; 32] { |
| 1043 | let mut res = [0u8; 32]; |
no test coverage detected