Add createEvent and now
This commit is contained in:
@@ -2,6 +2,11 @@ import type {Event} from 'nostr-tools'
|
||||
import {verifySignature, getEventHash, matchFilter as nostrToolsMatchFilter} from 'nostr-tools'
|
||||
import {cached} from "./LRUCache"
|
||||
|
||||
// ===========================================================================
|
||||
// General-purpose
|
||||
|
||||
const now = () => Math.round(Date.now() / 1000)
|
||||
|
||||
// ===========================================================================
|
||||
// Relays
|
||||
|
||||
@@ -44,6 +49,9 @@ export const toNostrURI = (s: string) => `nostr:${s}`
|
||||
// ===========================================================================
|
||||
// Events
|
||||
|
||||
export const createEvent = (kind: number, {content = "", tags = [], created_at = now()}) =>
|
||||
({kind, content, tags, created_at})
|
||||
|
||||
export const hasValidSignature = cached({
|
||||
maxSize: 10000,
|
||||
getKey: ([e]: any[]) => [getEventHash(e), e.sig].join(":"),
|
||||
|
||||
Reference in New Issue
Block a user