Skip to content

Commit

Permalink
add username context
Browse files Browse the repository at this point in the history
  • Loading branch information
DougAnderson444 committed Jan 26, 2024
1 parent e20c829 commit 8d8548d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions crates/seed-keeper-wit-ui/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,23 @@ impl Output {
// if serde feature, emit the serialized encrypted seed as an event
#[cfg(feature = "serde")]
{
// WIT expects variants to be {tag: _, val: _} in lowercase,
// which we cannot get using serde
// let ctx = Context::new("events", &Message::Encrypted(encrypted.clone()));
// WIT expects variants to be {tag: _, val: _} in lower kebab-case,
// which we can get using serde rename_all, baked into the Context and Messag enums
let ctx = Context::Event(Message::Encrypted(encrypted.clone()));
let serialized =
serde_json::to_string(&ctx).expect("to be able to serialize Context");
crate::wurbo_in::emit(&serialized);

// Also emit the Username
let ctx = Context::Event(Message::Username(
self.username
.as_ref()
.map(|v| v.clone())
.unwrap_or_default(),
));
let serialized_username =
serde_json::to_string(&ctx).expect("to be able to serialize Context");
crate::wurbo_in::emit(&serialized_username);
}

Value::from(encrypted)
Expand Down

0 comments on commit 8d8548d

Please sign in to comment.