Skip to content

Commit

Permalink
emit encrypted event
Browse files Browse the repository at this point in the history
  • Loading branch information
DougAnderson444 committed Jan 10, 2024
1 parent 316e2d7 commit b50c5a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 17 additions & 1 deletion crates/seed-keeper-wit-ui/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,23 @@ impl Output {
}

match get_encrypted() {
Ok(encrypted) => Value::from(encrypted),
Ok(encrypted) => {
// if serde feature, emit the serialized encrypted seed as an event
#[cfg(feature = "serde")]
{
use crate::wurbo_in::emit;
// set seed in events::Events::Encrypted to emit it
let encr_evt =
events::Contexts::Events(events::Event::Encrypted(encrypted.clone()));
// serialize the event
let serialized = serde_json::to_string(&encr_evt).unwrap();
println!("serialized Encrypted Event: {}", serialized);
// emit the event
emit(&serialized);
}

Value::from(encrypted)
}
Err(e) => Value::from(format!("Error in Output getting encrypted: {:?}", e)),
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/seed-keeper-wit-ui/wit/in.wit
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ interface wurbo-in {
// Add an event listener to the given element
addeventlistener: func(details: listen-details);

// Emit events from this component. Messages should be serialized JSON strings of Event type.
emit: func(message: string);

}

0 comments on commit b50c5a8

Please sign in to comment.