Skip to content

Commit f981b73

Browse files
committed
ffi(nostr): add EventBuilder::seal constructor
Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 55a7d46 commit f981b73

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
* pool: add `RelayPoolNotification::Authenticated` variant ([Yuki Kishimoto])
5252
* sdk: add `Client::gift_wrap_to` and `Client::send_private_msg_to` ([reyamir])
5353
* sdk: add option to autoconnect relay on `Client::add_relay` method call ([Yuki Kishimoto])
54+
* ffi(nostr): add `EventBuilder::seal` constructor ([Yuki Kishimoto])
5455
* cli: add `generate` command ([Yuki Kishimoto])
5556
* book: add some python examples ([RydalWater])
5657

bindings/nostr-ffi/src/event/builder.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,24 @@ impl EventBuilder {
584584
}
585585
}
586586

587-
// TODO: add seal
587+
/// Seal
588+
///
589+
/// <https://github.com/nostr-protocol/nips/blob/master/59.md>
590+
#[inline]
591+
#[uniffi::constructor]
592+
pub fn seal(
593+
sender_keys: &Keys,
594+
receiver_public_key: &PublicKey,
595+
rumor: &UnsignedEvent,
596+
) -> Result<Self> {
597+
Ok(Self {
598+
inner: nostr::EventBuilder::seal(
599+
sender_keys.deref(),
600+
receiver_public_key.deref(),
601+
rumor.deref().clone(),
602+
)?,
603+
})
604+
}
588605

589606
/// Private Direct message rumor
590607
///

bindings/nostr-js/src/event/builder.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,25 @@ impl JsEventBuilder {
568568
}
569569
}
570570

571-
// TODO: add seal
571+
/// Seal
572+
///
573+
/// <https://github.com/nostr-protocol/nips/blob/master/59.md>
574+
#[inline]
575+
#[wasm_bindgen]
576+
pub fn seal(
577+
sender_keys: &JsKeys,
578+
receiver_public_key: &JsPublicKey,
579+
rumor: &JsUnsignedEvent,
580+
) -> Result<JsEventBuilder> {
581+
Ok(Self {
582+
inner: nostr::EventBuilder::seal(
583+
sender_keys.deref(),
584+
receiver_public_key.deref(),
585+
rumor.deref().clone(),
586+
)
587+
.map_err(into_err)?,
588+
})
589+
}
572590

573591
/// Gift Wrap from seal
574592
///

0 commit comments

Comments
 (0)