use cairo_native::{
context::NativeContext, executor::JitNativeExecutor, utils::testing::cairo_to_sierra, Value,
};
use starknet_types_core::felt::Felt;
use std::path::Path;
fn main() {
let program_path = Path::new("programs/examples/hello.cairo");
let native_context = NativeContext::new();
let sierra_program = cairo_to_sierra(program_path).unwrap();
let native_program = native_context
.compile(&sierra_program, false, Some(Default::default()), None)
.unwrap();
let params = &[Value::Felt252(Felt::from_bytes_be_slice(b"user"))];
let entry_point = "hello::hello::greet";
let entry_point_id = cairo_native::utils::find_function_id(&sierra_program, entry_point)
.expect("entry point not found");
let native_executor =
JitNativeExecutor::from_native_module(native_program, Default::default()).unwrap();
let result = native_executor
.invoke_dynamic(entry_point_id, params, None)
.unwrap();
println!("Cairo program was compiled and executed successfully.");
println!("{:?}", result);
}