Skip to content

Commit 217e388

Browse files
committed
nostr: rename NIP-51 EventBuilder set constructors and Kind variants
Ref #465 Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 6edf9c7 commit 217e388

File tree

6 files changed

+101
-100
lines changed

6 files changed

+101
-100
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
### Changed
2929

30+
* nostr: rename NIP-51 `EventBuilder` set constructors and `Kind` variants ([Yuki Kishimoto])
3031
* pool: use per-purpose dedicated relay channels ([Yuki Kishimoto])
3132
* ffi(sdk): convert `RelayPool::handle_notifications` method to async/future ([Yuki Kishimoto])
3233

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -682,65 +682,65 @@ impl EventBuilder {
682682
}
683683
}
684684

685-
/// Follow sets
685+
/// Follow set
686686
///
687687
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
688688
#[uniffi::constructor]
689-
pub fn follow_sets(publick_keys: Vec<Arc<PublicKey>>) -> Self {
689+
pub fn follow_set(public_keys: Vec<Arc<PublicKey>>) -> Self {
690690
Self {
691-
inner: nostr::EventBuilder::follow_sets(publick_keys.into_iter().map(|p| **p)),
691+
inner: nostr::EventBuilder::follow_set(public_keys.into_iter().map(|p| **p)),
692692
}
693693
}
694694

695-
/// Relay sets
695+
/// Relay set
696696
///
697697
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
698698
#[uniffi::constructor]
699-
pub fn relay_sets(relay: Vec<String>) -> Self {
699+
pub fn relay_set(relays: Vec<String>) -> Self {
700700
Self {
701-
inner: nostr::EventBuilder::relay_sets(relay.into_iter().map(UncheckedUrl::from)),
701+
inner: nostr::EventBuilder::relay_set(relays.into_iter().map(UncheckedUrl::from)),
702702
}
703703
}
704704

705-
/// Bookmark sets
705+
/// Bookmark set
706706
///
707707
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
708708
#[uniffi::constructor]
709-
pub fn bookmarks_sets(list: Bookmarks) -> Result<Self> {
709+
pub fn bookmarks_set(list: Bookmarks) -> Result<Self> {
710710
Ok(Self {
711-
inner: nostr::EventBuilder::bookmarks_sets(list.try_into()?),
711+
inner: nostr::EventBuilder::bookmarks_set(list.try_into()?),
712712
})
713713
}
714714

715-
/// Article Curation sets
715+
/// Article Curation set
716716
///
717717
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
718718
#[uniffi::constructor]
719-
pub fn articles_curation_sets(list: ArticlesCuration) -> Self {
719+
pub fn articles_curation_set(list: ArticlesCuration) -> Self {
720720
Self {
721-
inner: nostr::EventBuilder::articles_curation_sets(list.into()),
721+
inner: nostr::EventBuilder::articles_curation_set(list.into()),
722722
}
723723
}
724724

725-
/// Videos Curation sets
725+
/// Videos Curation set
726726
///
727727
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
728728
#[uniffi::constructor]
729-
pub fn videos_curation_sets(video: Vec<Arc<Coordinate>>) -> Self {
729+
pub fn videos_curation_set(video: Vec<Arc<Coordinate>>) -> Self {
730730
Self {
731-
inner: nostr::EventBuilder::videos_curation_sets(
731+
inner: nostr::EventBuilder::videos_curation_set(
732732
video.into_iter().map(|c| c.as_ref().deref().clone()),
733733
),
734734
}
735735
}
736736

737-
/// Emoji sets
737+
/// Emoji set
738738
///
739739
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
740740
#[uniffi::constructor]
741-
pub fn emoji_sets(emojis: Vec<EmojiInfo>) -> Self {
741+
pub fn emoji_set(emojis: Vec<EmojiInfo>) -> Self {
742742
Self {
743-
inner: nostr::EventBuilder::emoji_sets(emojis.into_iter().map(|e| e.into())),
743+
inner: nostr::EventBuilder::emoji_set(emojis.into_iter().map(|e| e.into())),
744744
}
745745
}
746746

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

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -153,38 +153,38 @@ pub enum KindEnum {
153153
///
154154
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
155155
Emojis,
156-
/// Follow Sets
156+
/// Follow Set
157157
///
158158
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
159-
FollowSets,
160-
/// Relay Sets
159+
FollowSet,
160+
/// Relay Set
161161
///
162162
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
163-
RelaySets,
164-
/// Bookmark Sets
163+
RelaySet,
164+
/// Bookmark Set
165165
///
166166
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
167-
BookmarkSets,
168-
/// Articles Curation Sets
167+
BookmarkSet,
168+
/// Articles Curation Set
169169
///
170170
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
171-
ArticlesCurationSets,
172-
/// Videos Curation Sets
171+
ArticlesCurationSet,
172+
/// Videos Curation Set
173173
///
174174
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
175-
VideosCurationSets,
176-
/// Interest Sets
175+
VideosCurationSet,
176+
/// Interest Set
177177
///
178178
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
179-
InterestSets,
180-
/// Emoji Sets
179+
InterestSet,
180+
/// Emoji Set
181181
///
182182
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
183-
EmojiSets,
184-
/// Release Artifact Sets
183+
EmojiSet,
184+
/// Release Artifact Set
185185
///
186186
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
187-
ReleaseArtifactSets,
187+
ReleaseArtifactSet,
188188
/// Relay List Metadata (NIP65)
189189
RelayList,
190190
/// Client Authentication (NIP42)
@@ -288,14 +288,14 @@ impl From<nostr::Kind> for KindEnum {
288288
nostr::Kind::SimpleGroups => Self::SimpleGroups,
289289
nostr::Kind::Interests => Self::Interests,
290290
nostr::Kind::Emojis => Self::Emojis,
291-
nostr::Kind::FollowSets => Self::FollowSets,
292-
nostr::Kind::RelaySets => Self::RelaySets,
293-
nostr::Kind::BookmarkSets => Self::BookmarkSets,
294-
nostr::Kind::ArticlesCurationSets => Self::ArticlesCurationSets,
295-
nostr::Kind::VideosCurationSets => Self::VideosCurationSets,
296-
nostr::Kind::InterestSets => Self::InterestSets,
297-
nostr::Kind::EmojiSets => Self::EmojiSets,
298-
nostr::Kind::ReleaseArtifactSets => Self::ReleaseArtifactSets,
291+
nostr::Kind::FollowSet => Self::FollowSet,
292+
nostr::Kind::RelaySet => Self::RelaySet,
293+
nostr::Kind::BookmarkSet => Self::BookmarkSet,
294+
nostr::Kind::ArticlesCurationSet => Self::ArticlesCurationSet,
295+
nostr::Kind::VideosCurationSet => Self::VideosCurationSet,
296+
nostr::Kind::InterestSet => Self::InterestSet,
297+
nostr::Kind::EmojiSet => Self::EmojiSet,
298+
nostr::Kind::ReleaseArtifactSet => Self::ReleaseArtifactSet,
299299
nostr::Kind::RelayList => Self::RelayList,
300300
nostr::Kind::Authentication => Self::Authentication,
301301
nostr::Kind::WalletConnectRequest => Self::WalletConnectRequest,
@@ -366,14 +366,14 @@ impl From<KindEnum> for nostr::Kind {
366366
KindEnum::SimpleGroups => Self::SimpleGroups,
367367
KindEnum::Interests => Self::Interests,
368368
KindEnum::Emojis => Self::Emojis,
369-
KindEnum::FollowSets => Self::FollowSets,
370-
KindEnum::RelaySets => Self::RelaySets,
371-
KindEnum::BookmarkSets => Self::BookmarkSets,
372-
KindEnum::ArticlesCurationSets => Self::ArticlesCurationSets,
373-
KindEnum::VideosCurationSets => Self::VideosCurationSets,
374-
KindEnum::InterestSets => Self::InterestSets,
375-
KindEnum::EmojiSets => Self::EmojiSets,
376-
KindEnum::ReleaseArtifactSets => Self::ReleaseArtifactSets,
369+
KindEnum::FollowSet => Self::FollowSet,
370+
KindEnum::RelaySet => Self::RelaySet,
371+
KindEnum::BookmarkSet => Self::BookmarkSet,
372+
KindEnum::ArticlesCurationSet => Self::ArticlesCurationSet,
373+
KindEnum::VideosCurationSet => Self::VideosCurationSet,
374+
KindEnum::InterestSet => Self::InterestSet,
375+
KindEnum::EmojiSet => Self::EmojiSet,
376+
KindEnum::ReleaseArtifactSet => Self::ReleaseArtifactSet,
377377
KindEnum::RelayList => Self::RelayList,
378378
KindEnum::Authentication => Self::Authentication,
379379
KindEnum::WalletConnectRequest => Self::WalletConnectRequest,

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -701,63 +701,63 @@ impl JsEventBuilder {
701701
}
702702
}
703703

704-
/// Follow sets
704+
/// Follow set
705705
///
706706
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
707-
#[wasm_bindgen(js_name = followSets)]
708-
pub fn follow_sets(public_keys: Vec<JsPublicKey>) -> Self {
707+
#[wasm_bindgen(js_name = followSet)]
708+
pub fn follow_set(public_keys: Vec<JsPublicKey>) -> Self {
709709
Self {
710-
inner: EventBuilder::follow_sets(public_keys.into_iter().map(|p| p.into())),
710+
inner: EventBuilder::follow_set(public_keys.into_iter().map(|p| p.into())),
711711
}
712712
}
713713

714-
/// Relay sets
714+
/// Relay set
715715
///
716716
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
717-
#[wasm_bindgen(js_name = relaySets)]
718-
pub fn relay_sets(relays: Vec<String>) -> Self {
717+
#[wasm_bindgen(js_name = relaySet)]
718+
pub fn relay_set(relays: Vec<String>) -> Self {
719719
Self {
720-
inner: EventBuilder::relay_sets(relays.into_iter().map(UncheckedUrl::from)),
720+
inner: EventBuilder::relay_set(relays.into_iter().map(UncheckedUrl::from)),
721721
}
722722
}
723723

724-
/// Bookmark sets
724+
/// Bookmark set
725725
///
726726
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
727-
#[wasm_bindgen(js_name = bookmarksSets)]
728-
pub fn bookmarks_sets(list: &JsBookmarks) -> Result<JsEventBuilder> {
727+
#[wasm_bindgen(js_name = bookmarksSet)]
728+
pub fn bookmarks_set(list: &JsBookmarks) -> Result<JsEventBuilder> {
729729
Ok(Self {
730-
inner: EventBuilder::bookmarks_sets(list.clone().try_into()?),
730+
inner: EventBuilder::bookmarks_set(list.clone().try_into()?),
731731
})
732732
}
733733

734-
/// Article Curation sets
734+
/// Article Curation set
735735
///
736736
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
737-
#[wasm_bindgen(js_name = articlesCurationSets)]
738-
pub fn articles_curation_sets(list: &JsArticlesCuration) -> Self {
737+
#[wasm_bindgen(js_name = articlesCurationSet)]
738+
pub fn articles_curation_set(list: &JsArticlesCuration) -> Self {
739739
Self {
740-
inner: EventBuilder::articles_curation_sets(list.clone().into()),
740+
inner: EventBuilder::articles_curation_set(list.clone().into()),
741741
}
742742
}
743743

744-
/// Videos Curation sets
744+
/// Videos Curation set
745745
///
746746
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
747-
#[wasm_bindgen(js_name = videosCurationSets)]
748-
pub fn videos_curation_sets(video: Vec<JsCoordinate>) -> Self {
747+
#[wasm_bindgen(js_name = videosCurationSet)]
748+
pub fn videos_curation_set(video: Vec<JsCoordinate>) -> Self {
749749
Self {
750-
inner: EventBuilder::videos_curation_sets(video.into_iter().map(|c| c.deref().clone())),
750+
inner: EventBuilder::videos_curation_set(video.into_iter().map(|c| c.deref().clone())),
751751
}
752752
}
753753

754-
/// Emoji sets
754+
/// Emoji set
755755
///
756756
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
757-
#[wasm_bindgen(js_name = emojiSets)]
758-
pub fn emoji_sets(emoji: Vec<JsEmojiInfo>) -> Self {
757+
#[wasm_bindgen(js_name = emojiSet)]
758+
pub fn emoji_set(emoji: Vec<JsEmojiInfo>) -> Self {
759759
Self {
760-
inner: EventBuilder::emoji_sets(emoji.into_iter().map(|e| e.into())),
760+
inner: EventBuilder::emoji_set(emoji.into_iter().map(|e| e.into())),
761761
}
762762
}
763763

crates/nostr/src/event/builder.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,82 +1505,82 @@ impl EventBuilder {
15051505
Self::new(Kind::Emojis, "", tags)
15061506
}
15071507

1508-
/// Follow sets
1508+
/// Follow set
15091509
///
15101510
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
15111511
#[inline]
1512-
pub fn follow_sets<I>(public_keys: I) -> Self
1512+
pub fn follow_set<I>(public_keys: I) -> Self
15131513
where
15141514
I: IntoIterator<Item = PublicKey>,
15151515
{
15161516
Self::new(
1517-
Kind::FollowSets,
1517+
Kind::FollowSet,
15181518
"",
15191519
public_keys.into_iter().map(Tag::public_key),
15201520
)
15211521
}
15221522

1523-
/// Relay sets
1523+
/// Relay set
15241524
///
15251525
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
15261526
#[inline]
1527-
pub fn relay_sets<I>(relay: I) -> Self
1527+
pub fn relay_set<I>(relay: I) -> Self
15281528
where
15291529
I: IntoIterator<Item = UncheckedUrl>,
15301530
{
15311531
Self::new(
1532-
Kind::RelaySets,
1532+
Kind::RelaySet,
15331533
"",
15341534
relay
15351535
.into_iter()
15361536
.map(|r| Tag::from_standardized_without_cell(TagStandard::Relay(r))),
15371537
)
15381538
}
15391539

1540-
/// Bookmark sets
1540+
/// Bookmark set
15411541
///
15421542
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
15431543
#[inline]
1544-
pub fn bookmarks_sets(list: Bookmarks) -> Self {
1544+
pub fn bookmarks_set(list: Bookmarks) -> Self {
15451545
let tags: Vec<Tag> = list.into();
1546-
Self::new(Kind::BookmarkSets, "", tags)
1546+
Self::new(Kind::BookmarkSet, "", tags)
15471547
}
15481548

1549-
/// Article Curation sets
1549+
/// Article Curation set
15501550
///
15511551
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
15521552
#[inline]
1553-
pub fn articles_curation_sets(list: ArticlesCuration) -> Self {
1553+
pub fn articles_curation_set(list: ArticlesCuration) -> Self {
15541554
let tags: Vec<Tag> = list.into();
1555-
Self::new(Kind::ArticlesCurationSets, "", tags)
1555+
Self::new(Kind::ArticlesCurationSet, "", tags)
15561556
}
15571557

1558-
/// Videos Curation sets
1558+
/// Videos Curation set
15591559
///
15601560
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
15611561
#[inline]
1562-
pub fn videos_curation_sets<I>(video: I) -> Self
1562+
pub fn videos_curation_set<I>(video: I) -> Self
15631563
where
15641564
I: IntoIterator<Item = Coordinate>,
15651565
{
15661566
Self::new(
1567-
Kind::VideosCurationSets,
1567+
Kind::VideosCurationSet,
15681568
"",
15691569
video.into_iter().map(Tag::from),
15701570
)
15711571
}
15721572

1573-
/// Emoji sets
1573+
/// Emoji set
15741574
///
15751575
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
1576-
pub fn emoji_sets<I>(emoji: I) -> Self
1576+
pub fn emoji_set<I>(emoji: I) -> Self
15771577
where
15781578
I: IntoIterator<Item = (String, UncheckedUrl)>,
15791579
{
15801580
let tags = emoji.into_iter().map(|(s, url)| {
15811581
Tag::from_standardized_without_cell(TagStandard::Emoji { shortcode: s, url })
15821582
});
1583-
Self::new(Kind::EmojiSets, "", tags)
1583+
Self::new(Kind::EmojiSet, "", tags)
15841584
}
15851585

15861586
/// Label

0 commit comments

Comments
 (0)