I have created a contract which requires to query the length of a HashMap, So when the Key of this particular HashMap I use as Vec<u8> , the length is always returned as 0, whereas If I use String as the Key type, the function works perfectly fine. Am I missing something in here? Sharing the Query function snippet below for reference:
pub fn get_no_of_root_hashes(deps: Deps) -> Result<usize, ContractError> {
let state = STATE.load(deps.storage)?;
println!("Query: {:?}", state.root_hashes.len());
Ok(state.root_hashes.len())
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
pub struct State {
pub owner: cosmwasm_std::Addr,
pub com_to_pub_key: HashMap<u64, Vec<u8>>,
pub root_hashes: HashMap<Vec<u8>, u64>,
}