diff --git a/bindings/nostr-sdk-ffi/src/protocol/event/tag/standard.rs b/bindings/nostr-sdk-ffi/src/protocol/event/tag/standard.rs index 0cd6f9062..bb371c288 100644 --- a/bindings/nostr-sdk-ffi/src/protocol/event/tag/standard.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/event/tag/standard.rs @@ -110,6 +110,8 @@ pub enum TagStandard { }, Kind { kind: KindEnum, + /// Whether the k tag is an uppercase K or not + uppercase: bool, }, RelayUrl { relay_url: String, @@ -355,7 +357,10 @@ impl From for TagStandard { tag::TagStandard::ExternalIdentity(identity) => Self::ExternalIdentity { identity: identity.into(), }, - tag::TagStandard::Kind(kind) => Self::Kind { kind: kind.into() }, + tag::TagStandard::Kind { kind, uppercase } => Self::Kind { + kind: kind.into(), + uppercase, + }, tag::TagStandard::Relay(url) => Self::RelayUrl { relay_url: url.to_string(), }, @@ -550,7 +555,10 @@ impl TryFrom for tag::TagStandard { coordinate: coordinate.as_ref().deref().clone(), relay_url: relay_url.map(UncheckedUrl::from), }), - TagStandard::Kind { kind } => Ok(Self::Kind(kind.into())), + TagStandard::Kind { kind, uppercase } => Ok(Self::Kind { + kind: kind.into(), + uppercase, + }), TagStandard::RelayUrl { relay_url } => Ok(Self::Relay(UncheckedUrl::from(relay_url))), TagStandard::POW { nonce, difficulty } => Ok(Self::POW { nonce: nonce.parse()?, diff --git a/crates/nostr/src/event/builder.rs b/crates/nostr/src/event/builder.rs index 05f124a2e..3925f6de9 100644 --- a/crates/nostr/src/event/builder.rs +++ b/crates/nostr/src/event/builder.rs @@ -526,9 +526,10 @@ impl EventBuilder { uppercase: true, })); // Kind - tags.push(Tag::from_standardized_without_cell(TagStandard::Kind( - root.kind, - ))); + tags.push(Tag::from_standardized_without_cell(TagStandard::Kind { + kind: root.kind, + uppercase: true, + })); // Add others `p` tags tags.extend( @@ -554,9 +555,10 @@ impl EventBuilder { uppercase: false, })); // Add `k` tag of event kind - tags.push(Tag::from_standardized_without_cell(TagStandard::Kind( - reply_to.kind, - ))); + tags.push(Tag::from_standardized_without_cell(TagStandard::Kind { + kind: reply_to.kind, + uppercase: false, + })); // Add others `p` tags of reply_to event tags.extend( @@ -680,7 +682,10 @@ impl EventBuilder { uppercase: false, }), Tag::public_key(event.pubkey), - Tag::from_standardized_without_cell(TagStandard::Kind(event.kind)), + Tag::from_standardized_without_cell(TagStandard::Kind { + kind: event.kind, + uppercase: false, + }), ], ) } @@ -743,7 +748,10 @@ impl EventBuilder { tags.push(Tag::public_key(public_key)); if let Some(kind) = kind { - tags.push(Tag::from_standardized_without_cell(TagStandard::Kind(kind))); + tags.push(Tag::from_standardized_without_cell(TagStandard::Kind { + kind, + uppercase: false, + })); } Self::new(Kind::Reaction, reaction, tags) diff --git a/crates/nostr/src/event/tag/standard.rs b/crates/nostr/src/event/tag/standard.rs index ad205b3a7..5278361b3 100644 --- a/crates/nostr/src/event/tag/standard.rs +++ b/crates/nostr/src/event/tag/standard.rs @@ -103,7 +103,11 @@ pub enum TagStandard { coordinate: Coordinate, relay_url: Option, }, - Kind(Kind), + Kind { + kind: Kind, + /// Whether the k tag is an uppercase K or not + uppercase: bool, + }, Relay(UncheckedUrl), /// Proof of Work /// @@ -308,10 +312,6 @@ impl TagStandard { character: Alphabet::D, uppercase: false, }) => Ok(Self::Identifier(tag_1.to_string())), - TagKind::SingleLetter(SingleLetterTag { - character: Alphabet::K, - uppercase: false, - }) => Ok(Self::Kind(Kind::from_str(tag_1)?)), TagKind::SingleLetter(SingleLetterTag { character: Alphabet::M, uppercase: false, @@ -509,9 +509,9 @@ impl TagStandard { character: Alphabet::A, uppercase: false, }), - Self::Kind(..) => TagKind::SingleLetter(SingleLetterTag { + Self::Kind { uppercase, .. } => TagKind::SingleLetter(SingleLetterTag { character: Alphabet::K, - uppercase: false, + uppercase: *uppercase, }), Self::Relay(..) => TagKind::Relay, Self::POW { .. } => TagKind::Nonce, @@ -693,7 +693,7 @@ impl From for Vec { vec } TagStandard::ExternalIdentity(identity) => identity.into(), - TagStandard::Kind(kind) => vec![tag_kind, kind.to_string()], + TagStandard::Kind { kind, .. } => vec![tag_kind, kind.to_string()], TagStandard::Relay(url) => vec![tag_kind, url.to_string()], TagStandard::POW { nonce, difficulty } => { vec![tag_kind, nonce.to_string(), difficulty.to_string()]