2023-09-09 18:06:41 +00:00
|
|
|
/** @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";
|
2023-09-10 17:56:37 +00:00
|
|
|
import { EventDetail, EventDetailItem } from "./event-detail.tsx";
|
|
|
|
import { NoteID } from "../lib/nostr-ts/nip19.ts";
|
2023-09-09 18:06:41 +00:00
|
|
|
|
|
|
|
const ctx = InMemoryAccountContext.New(PrivateKey.Generate());
|
|
|
|
const event = await prepareNormalNostrEvent(ctx, NostrKind.TEXT_NOTE, [["d", "nostr"]], "Pura Vida");
|
2023-09-10 17:56:37 +00:00
|
|
|
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),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
2023-09-09 18:06:41 +00:00
|
|
|
|
|
|
|
render(
|
2023-09-10 17:56:37 +00:00
|
|
|
<EventDetail items={items} />,
|
2023-09-09 18:06:41 +00:00
|
|
|
document.body,
|
|
|
|
);
|