1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use std::iter::{repeat, zip};
use fuels_types::{param_types::ParamType, ByteArray};
use sha2::{Digest, Sha256};
pub fn first_four_bytes_of_sha256_hash(string: &str) -> ByteArray {
let string_as_bytes = string.as_bytes();
let mut hasher = Sha256::new();
hasher.update(string_as_bytes);
let result = hasher.finalize();
let mut output = ByteArray::default();
output[4..].copy_from_slice(&result[..4]);
output
}
pub fn generate_unused_field_names(types: Vec<ParamType>) -> Vec<(String, ParamType)> {
zip(repeat("unused".to_string()), types).collect()
}