use tari_template_abi::{EngineOp, call_engine, rust::prelude::*};
use crate::args::{GenerateRandomAction, GenerateRandomInvokeArg, InvokeResult};
pub fn random_bytes(len: u32) -> Vec<u8> {
let resp: InvokeResult = call_engine(EngineOp::GenerateRandomInvoke, &GenerateRandomInvokeArg {
action: GenerateRandomAction::GetRandomBytes { len },
});
resp.decode().expect("Failed to decode random bytes")
}
pub fn random_u32() -> u32 {
let v = random_bytes(4);
u32::from_le_bytes(v.as_slice().try_into().unwrap())
}