Background
NIP-58 was updated by nostr-protocol/nips#2276.
As part of that change:
- Profile Badges moved to replaceable
kind:10008.
kind:30008 is now defined as an addressable NIP-51 Badge Set event.
- A Profile Badges
kind:10008 event may contain a tags referencing Badge Sets.
The Profile Badges migration itself is tracked separately in #2279.
References:
Goal
Support Badge Sets introduced by the updated NIP-58 without treating every kind:30008 event as the deprecated Profile Badges format.
Required changes
Resolve Badge Set references from Profile Badges
A kind:10008 Profile Badges event may contain an a tag referencing an address such as:
30008:<pubkey>:<identifier>
When such a reference is present:
- recognize it as a Badge Set reference rather than a Badge Definition reference;
- fetch the corresponding
kind:30008 addressable event;
- resolve the Badge Set's ordered
a / e pairs;
- fetch the referenced
kind:30009 Badge Definition events and kind:8 Badge Award events;
- validate that the referenced awards apply to the profile owner before displaying them.
Existing direct a:30009 + e:8 pairs in Profile Badges should continue to work.
Preserve ordering
NIP-58 describes ordered badge references. Preserve the ordering of:
- direct badges in Profile Badges;
- Badge Set references in Profile Badges;
- badges within each Badge Set.
Avoid reducing these structures to unordered Sets where that would lose the display order defined by the event.
Render Badge Sets
Update the profile badge UI so Badge Sets referenced from Profile Badges can be displayed.
Badge Set metadata may include NIP-51 set metadata such as title/image/description. Decide which metadata nostter should surface, but the implementation should at minimum make the contained badges visible rather than silently ignoring a:30008:* references.
Relevant existing code includes:
web/src/lib/components/Badges.svelte
web/src/lib/author/ProfileBadges.ts
web/src/lib/Constants.ts
web/src/lib/EventHelper.ts
Badges.svelte currently only treats a tags beginning with 30009: as Badge Definitions, so 30008: Badge Set references are ignored.
Handle kind:30008 semantics correctly
Keep 30008 in the generic addressable/parameterized replaceable handling.
After #2279, the deprecated 30008 / d=profile_badges event remains a compatibility case, while other kind:30008 events should be handled as Badge Sets.
Do not globally map kind:30008 to Profile Badges.
Badge Set authoring
If nostter exposes Badge Set management, writes should use kind:30008 addressable events with a normal d identifier and ordered badge references as defined by NIP-58/NIP-51.
This would include:
- creating a Badge Set;
- editing its metadata and badge membership/order;
- referencing the set from the user's
kind:10008 Profile Badges event;
- updating/removing that reference when the set is no longer displayed.
If the management UX is substantially larger than the read/render work, the authoring UI may be split into a follow-up issue, but the data model and resolver introduced here should not preclude write support.
Validation / edge cases
Cover at least:
- Profile Badges containing only direct badges;
- Profile Badges containing only Badge Set references;
- a mixture of direct badges and Badge Sets;
- multiple Badge Sets;
- missing/deleted/unavailable Badge Set events;
- malformed
30008 addresses;
- Badge Sets containing missing Badge Definition or Badge Award events;
- awards that do not actually target the profile owner;
- duplicate badges referenced directly and through one or more sets;
- legacy
30008 / d=profile_badges compatibility coexisting with real Badge Set events.
Dependency
This work should build on or coordinate with #2279 so that Profile Badges are first-class kind:10008 events while legacy 30008 / d=profile_badges remains only a compatibility path.
Background
NIP-58 was updated by nostr-protocol/nips#2276.
As part of that change:
kind:10008.kind:30008is now defined as an addressable NIP-51 Badge Set event.kind:10008event may containatags referencing Badge Sets.The Profile Badges migration itself is tracked separately in #2279.
References:
Goal
Support Badge Sets introduced by the updated NIP-58 without treating every
kind:30008event as the deprecated Profile Badges format.Required changes
Resolve Badge Set references from Profile Badges
A
kind:10008Profile Badges event may contain anatag referencing an address such as:When such a reference is present:
kind:30008addressable event;a/epairs;kind:30009Badge Definition events andkind:8Badge Award events;Existing direct
a:30009+e:8pairs in Profile Badges should continue to work.Preserve ordering
NIP-58 describes ordered badge references. Preserve the ordering of:
Avoid reducing these structures to unordered
Sets where that would lose the display order defined by the event.Render Badge Sets
Update the profile badge UI so Badge Sets referenced from Profile Badges can be displayed.
Badge Set metadata may include NIP-51 set metadata such as title/image/description. Decide which metadata nostter should surface, but the implementation should at minimum make the contained badges visible rather than silently ignoring
a:30008:*references.Relevant existing code includes:
web/src/lib/components/Badges.svelteweb/src/lib/author/ProfileBadges.tsweb/src/lib/Constants.tsweb/src/lib/EventHelper.tsBadges.sveltecurrently only treatsatags beginning with30009:as Badge Definitions, so30008:Badge Set references are ignored.Handle
kind:30008semantics correctlyKeep
30008in the generic addressable/parameterized replaceable handling.After #2279, the deprecated
30008/d=profile_badgesevent remains a compatibility case, while otherkind:30008events should be handled as Badge Sets.Do not globally map
kind:30008to Profile Badges.Badge Set authoring
If nostter exposes Badge Set management, writes should use
kind:30008addressable events with a normaldidentifier and ordered badge references as defined by NIP-58/NIP-51.This would include:
kind:10008Profile Badges event;If the management UX is substantially larger than the read/render work, the authoring UI may be split into a follow-up issue, but the data model and resolver introduced here should not preclude write support.
Validation / edge cases
Cover at least:
30008addresses;30008/d=profile_badgescompatibility coexisting with real Badge Set events.Dependency
This work should build on or coordinate with #2279 so that Profile Badges are first-class
kind:10008events while legacy30008/d=profile_badgesremains only a compatibility path.