mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
Make Event a generic type accepting Kind
This commit is contained in:
10
event.ts
10
event.ts
@@ -29,23 +29,23 @@ export enum Kind {
|
|||||||
Article = 30023
|
Article = 30023
|
||||||
}
|
}
|
||||||
|
|
||||||
export type EventTemplate = {
|
export type EventTemplate<K extends number = Kind> = {
|
||||||
kind: Kind
|
kind: K
|
||||||
tags: string[][]
|
tags: string[][]
|
||||||
content: string
|
content: string
|
||||||
created_at: number
|
created_at: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UnsignedEvent = EventTemplate & {
|
export type UnsignedEvent<K extends number = Kind> = EventTemplate<K> & {
|
||||||
pubkey: string
|
pubkey: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Event = UnsignedEvent & {
|
export type Event<K extends number = Kind> = UnsignedEvent<K> & {
|
||||||
id: string
|
id: string
|
||||||
sig: string
|
sig: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBlankEvent(): EventTemplate {
|
export function getBlankEvent(): EventTemplate<number> {
|
||||||
return {
|
return {
|
||||||
kind: 255,
|
kind: 255,
|
||||||
content: '',
|
content: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user