Hello, I'm updating my SCs to prevent using heap memory, but I'm out of ideas could someone help me ?
I want to check inside the smartcontract if caller addresses are whitelisted like this in the init function
self.allowlist().insert(ManagedAddress::from_address(&Address::from(H256::from(hex!("1ff238d3d35e0f942b384aaaa111xxxxxxxxxxxxxxxxxxxxxx")))));
Even if I used 'ManagedAddress' it's not enough to prevent heap mem usage, how do you manage whitelist for your SCs guys ?
I don't know if this should be your implementation, but yes, this should do it.
let address: [u8; 32] = hex!("1ff238d3d35e0f942b384aaaa111xxxxxxxxxxxxxxxxxxxxxx");
self.allowlist().insert(ManagedAddress::new_from_bytes(&address));
Any reason why you would want to hardcode the address in your contract instead of providing it as an argument?
I don't know if this should be your implementation, but yes, this should do it. let address: [u8; 32] = hex!("1ff238d3d35e0f942b384aaaa111xxxxxxxxxxxxxxxxxxxxxx"); self.allowlist().insert(ManagedAddress::new_from_bytes(&address));
I'm just guessing, but for example managed sha256 doesn't use H256, so maybe this is because of that pub fn sha256_legacy_alloc(&self, data: &[u8]) -> H256 { H256::from(A::crypto_api_impl().sha256_legacy(data)) } pub fn sha256_legacy_managed(
&self,
data: &ManagedBuffer,
) -> ManagedByteArray {
let mut data_buffer = [0u8; MAX_INPUT_LEN];
let data_buffer_slice = data.load_to_byte_array(&mut data_buffer);
ManagedByteArray::new_from_bytes(&A::crypto_api_impl().sha256_legacy(data_buffer_slice))
}