diff --git a/CHANGELOG.md b/CHANGELOG.md index 8807efcf1..bb4b9d649 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ * relay-builder: add min POW difficulty option to `RelayBuilder` ([Yuki Kishimoto]) * pool: add `RelayPool::force_remove_relay` method ([Yuki Kishimoto]) * zapper: add `WebLNZapper` struct (moved from `nostr-webln` crate) ([Yuki Kishimoto]) +* ffi(nostr): add `tag_kind_to_string` func ([Yuki Kishimoto]) * book: add some examples ([RydalWater]) ### Fixed diff --git a/bindings/nostr-ffi/src/event/tag.rs b/bindings/nostr-ffi/src/event/tag.rs index 9c59f75cf..ce2198ba6 100644 --- a/bindings/nostr-ffi/src/event/tag.rs +++ b/bindings/nostr-ffi/src/event/tag.rs @@ -234,6 +234,13 @@ impl<'a> From for tag::TagKind<'a> { } } +/// Convert tag kind to string +#[uniffi::export] +pub fn tag_kind_to_string(kind: TagKind) -> String { + let kind: tag::TagKind<'_> = kind.into(); + kind.to_string() +} + /// Tag #[derive(Debug, PartialEq, Eq, Hash, Object)] #[uniffi::export(Debug, Eq, Hash)] diff --git a/bindings/nostr-ffi/tests/test_to_string.py b/bindings/nostr-ffi/tests/test_to_string.py index bf2182ba9..d0aea341c 100644 --- a/bindings/nostr-ffi/tests/test_to_string.py +++ b/bindings/nostr-ffi/tests/test_to_string.py @@ -3,3 +3,6 @@ addr = "30023:aa4fc8665f5696e33db7e1a572e3b0f5b3d615837b0f362dcb1c8068b098c7b4:ipsum" coordinate = Coordinate.parse(addr) assert addr == coordinate.__str__() + +t_kind = TagKind.NONCE() +assert tag_kind_to_string(t_kind) == "nonce"