mirror of
https://github.com/BlowaterNostr/blowater.git
synced 2024-10-18 15:43:20 +00:00
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
/** @jsx h */
|
|
import { h, render } from "https://esm.sh/preact@10.17.1";
|
|
import { PrivateKey, PublicKey } from "../lib/nostr-ts/key.ts";
|
|
import { prepareNormalNostrEvent } from "../lib/nostr-ts/event.ts";
|
|
import { InMemoryAccountContext, NostrKind } from "../lib/nostr-ts/nostr.ts";
|
|
import { EventDetail, EventDetailItem } from "./event-detail.tsx";
|
|
import { NoteID } from "../lib/nostr-ts/nip19.ts";
|
|
|
|
const ctx = InMemoryAccountContext.New(PrivateKey.Generate());
|
|
const event = await prepareNormalNostrEvent(ctx, NostrKind.TEXT_NOTE, [["d", "nostr"]], "Pura Vida");
|
|
const publicKey = PublicKey.FromHex(event.pubkey) as PublicKey;
|
|
|
|
const items: EventDetailItem[] = [
|
|
{
|
|
title: "Event ID",
|
|
fields: [
|
|
event.id,
|
|
NoteID.FromString(event.id).bech32(),
|
|
],
|
|
},
|
|
{
|
|
title: "Author",
|
|
fields: [
|
|
publicKey.hex,
|
|
publicKey.bech32(),
|
|
],
|
|
},
|
|
{
|
|
title: "Content",
|
|
fields: [
|
|
event.content,
|
|
JSON.stringify(event, null, 4),
|
|
],
|
|
},
|
|
];
|
|
|
|
render(
|
|
<EventDetail items={items} />,
|
|
document.body,
|
|
);
|