Skip to content

Commit

Permalink
Event, Filter: allow any kind number
Browse files Browse the repository at this point in the history
Fixes #275
  • Loading branch information
alexgleason authored and fiatjaf committed Aug 12, 2023
1 parent e00362e commit df6f887
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {bytesToHex} from '@noble/hashes/utils'
import {getPublicKey} from './keys.ts'
import {utf8Encoder} from './utils.ts'

/** @deprecated Use numbers instead. */
/* eslint-disable no-unused-vars */
export enum Kind {
Metadata = 0,
Expand Down Expand Up @@ -33,18 +34,18 @@ export enum Kind {
Article = 30023
}

export type EventTemplate<K extends number = Kind> = {
export type EventTemplate<K extends number = number> = {
kind: K
tags: string[][]
content: string
created_at: number
}

export type UnsignedEvent<K extends number = Kind> = EventTemplate<K> & {
export type UnsignedEvent<K extends number = number> = EventTemplate<K> & {
pubkey: string
}

export type Event<K extends number = Kind> = UnsignedEvent<K> & {
export type Event<K extends number = number> = UnsignedEvent<K> & {
id: string
sig: string
}
Expand All @@ -60,7 +61,7 @@ export function getBlankEvent<K>(kind: K | Kind.Blank = Kind.Blank) {
}
}

export function finishEvent<K extends number = Kind>(
export function finishEvent<K extends number = number>(
t: EventTemplate<K>,
privateKey: string
): Event<K> {
Expand Down
2 changes: 1 addition & 1 deletion filter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Event, type Kind} from './event.ts'

export type Filter<K extends number = Kind> = {
export type Filter<K extends number = number> = {
ids?: string[]
kinds?: K[]
authors?: string[]
Expand Down

0 comments on commit df6f887

Please sign in to comment.