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