finishEvent: return a VerifiedEvent

This commit is contained in:
Alex Gleason
2023-09-02 17:36:53 -05:00
parent 54f3bedf38
commit 62bf592d72

View File

@@ -71,11 +71,12 @@ export function getBlankEvent<K>(kind: K | Kind.Blank = Kind.Blank) {
}
}
export function finishEvent<K extends number = number>(t: EventTemplate<K>, privateKey: string): Event<K> {
let event = t as Event<K>
export function finishEvent<K extends number = number>(t: EventTemplate<K>, privateKey: string): VerifiedEvent<K> {
const event = t as VerifiedEvent<K>
event.pubkey = getPublicKey(privateKey)
event.id = getEventHash(event)
event.sig = getSignature(event, privateKey)
event[verifiedSymbol] = true
return event
}