mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-14 10:58:52 +00:00
turn Kind enum into a simple object with numbers.
This commit is contained in:
60
event.ts
60
event.ts
@@ -8,35 +8,33 @@ import { utf8Encoder } from './utils.ts'
|
||||
/** Designates a verified event signature. */
|
||||
export const verifiedSymbol = Symbol('verified')
|
||||
|
||||
/** @deprecated Use numbers instead. */
|
||||
/* eslint-disable no-unused-vars */
|
||||
export enum Kind {
|
||||
Metadata = 0,
|
||||
Text = 1,
|
||||
RecommendRelay = 2,
|
||||
Contacts = 3,
|
||||
EncryptedDirectMessage = 4,
|
||||
EventDeletion = 5,
|
||||
Repost = 6,
|
||||
Reaction = 7,
|
||||
BadgeAward = 8,
|
||||
ChannelCreation = 40,
|
||||
ChannelMetadata = 41,
|
||||
ChannelMessage = 42,
|
||||
ChannelHideMessage = 43,
|
||||
ChannelMuteUser = 44,
|
||||
Blank = 255,
|
||||
Report = 1984,
|
||||
ZapRequest = 9734,
|
||||
Zap = 9735,
|
||||
RelayList = 10002,
|
||||
ClientAuth = 22242,
|
||||
NwcRequest = 23194,
|
||||
HttpAuth = 27235,
|
||||
ProfileBadge = 30008,
|
||||
BadgeDefinition = 30009,
|
||||
Article = 30023,
|
||||
FileMetadata = 1063,
|
||||
export const Kind = {
|
||||
Metadata: 0,
|
||||
Text: 1,
|
||||
RecommendRelay: 2,
|
||||
Contacts: 3,
|
||||
EncryptedDirectMessage: 4,
|
||||
EventDeletion: 5,
|
||||
Repost: 6,
|
||||
Reaction: 7,
|
||||
BadgeAward: 8,
|
||||
ChannelCreation: 40,
|
||||
ChannelMetadata: 41,
|
||||
ChannelMessage: 42,
|
||||
ChannelHideMessage: 43,
|
||||
ChannelMuteUser: 44,
|
||||
Blank: 255,
|
||||
Report: 1984,
|
||||
ZapRequest: 9734,
|
||||
Zap: 9735,
|
||||
RelayList: 10002,
|
||||
ClientAuth: 22242,
|
||||
NwcRequest: 23194,
|
||||
HttpAuth: 27235,
|
||||
ProfileBadge: 30008,
|
||||
BadgeDefinition: 30009,
|
||||
Article: 30023,
|
||||
FileMetadata: 1063,
|
||||
}
|
||||
|
||||
export interface Event<K extends number = number> {
|
||||
@@ -61,9 +59,7 @@ export interface VerifiedEvent<K extends number = number> extends Event<K> {
|
||||
[verifiedSymbol]: true
|
||||
}
|
||||
|
||||
export function getBlankEvent(): EventTemplate<Kind.Blank>
|
||||
export function getBlankEvent<K extends number>(kind: K): EventTemplate<K>
|
||||
export function getBlankEvent<K>(kind: K | Kind.Blank = Kind.Blank) {
|
||||
export function getBlankEvent(kind: number = 255): EventTemplate {
|
||||
return {
|
||||
kind,
|
||||
content: '',
|
||||
|
||||
Reference in New Issue
Block a user