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
|
||||
}
|
||||
|
||||
export type EventTemplate = {
|
||||
kind: Kind
|
||||
export type EventTemplate<K extends number = Kind> = {
|
||||
kind: K
|
||||
tags: string[][]
|
||||
content: string
|
||||
created_at: number
|
||||
}
|
||||
|
||||
export type UnsignedEvent = EventTemplate & {
|
||||
export type UnsignedEvent<K extends number = Kind> = EventTemplate<K> & {
|
||||
pubkey: string
|
||||
}
|
||||
|
||||
export type Event = UnsignedEvent & {
|
||||
export type Event<K extends number = Kind> = UnsignedEvent<K> & {
|
||||
id: string
|
||||
sig: string
|
||||
}
|
||||
|
||||
export function getBlankEvent(): EventTemplate {
|
||||
export function getBlankEvent(): EventTemplate<number> {
|
||||
return {
|
||||
kind: 255,
|
||||
content: '',
|
||||
|
||||
Reference in New Issue
Block a user