From e2956ab937f338a58489209f4445976ff947ce31 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sat, 22 May 2021 21:20:30 -0300 Subject: [PATCH] support getBlankEvent() function. --- event.js | 10 ++++++++++ index.js | 11 +++++++++-- package.json | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/event.js b/event.js index 65707b7..b0257d6 100644 --- a/event.js +++ b/event.js @@ -2,6 +2,16 @@ import * as secp256k1 from 'noble-secp256k1' import {sha256} from './utils' +export function getBlankEvent(evt) { + return { + kind: -1, + pubkey: null, + content: '', + tags: [], + created_at: Math.round(Date.now() / 1000) + } +} + export function serializeEvent(evt) { return JSON.stringify([ 0, diff --git a/index.js b/index.js index 5ae8f8b..5bfe865 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,12 @@ import {relayConnect} from './relay' import {relayPool} from './pool' -import {signEvent, verifySignature, serializeEvent, getEventHash} from './event' +import { + getBlankEvent, + signEvent, + verifySignature, + serializeEvent, + getEventHash +} from './event' import {makeRandom32, sha256, getPublicKey} from './utils' export { @@ -12,5 +18,6 @@ export { getEventHash, makeRandom32, sha256, - getPublicKey + getPublicKey, + getBlankEvent } diff --git a/package.json b/package.json index bed29ca..01380c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nostr-tools", - "version": "0.4.3", + "version": "0.4.4", "description": "Tools for making a Nostr client.", "main": "index.js", "repository": {