49 lines
1.7 KiB
Rust
49 lines
1.7 KiB
Rust
/// OSIRIS Freezone Registration Flow Example
|
|
///
|
|
/// Demonstrates a complete freezone registration flow with all steps
|
|
|
|
use osiris::register_osiris_full;
|
|
use rhai::Engine;
|
|
use std::fs;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
println!("=== OSIRIS Freezone Registration Flow ===\n");
|
|
|
|
// Create a new raw engine and register all OSIRIS components
|
|
let mut engine = Engine::new_raw();
|
|
register_osiris_full(&mut engine);
|
|
|
|
// Set up context tags with SIGNATORIES for get_context
|
|
let mut tag_map = rhai::Map::new();
|
|
let signatories: rhai::Array = vec![
|
|
rhai::Dynamic::from("freezone_admin".to_string()),
|
|
rhai::Dynamic::from("kyc_officer".to_string()),
|
|
rhai::Dynamic::from("payment_processor".to_string()),
|
|
];
|
|
tag_map.insert("SIGNATORIES".into(), rhai::Dynamic::from(signatories));
|
|
tag_map.insert("DB_PATH".into(), "/tmp/osiris_freezone".to_string().into());
|
|
tag_map.insert("CONTEXT_ID".into(), "freezone_context".to_string().into());
|
|
engine.set_default_tag(rhai::Dynamic::from(tag_map));
|
|
|
|
// Read and execute the freezone script
|
|
let script_path = concat!(env!("CARGO_MANIFEST_DIR"), "/examples/freezone/freezone.rhai");
|
|
let script_content = fs::read_to_string(script_path)?;
|
|
|
|
match engine.eval::<rhai::Dynamic>(&script_content) {
|
|
Ok(result) => {
|
|
println!("\n✓ Freezone registration flow completed successfully!");
|
|
if !result.is_unit() {
|
|
println!("Result: {}", result);
|
|
}
|
|
}
|
|
Err(e) => {
|
|
eprintln!("\n✗ Error: {}", e);
|
|
eprintln!("Error details: {:?}", e);
|
|
return Err(e.into());
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|