Init SnortDeck

This commit is contained in:
2023-09-07 15:54:25 +01:00
parent 5960a5bf5f
commit a31e30979d
30 changed files with 903 additions and 436 deletions

View File

@ -22,6 +22,22 @@ export function linkToEventTag(link: NostrLink) {
}
}
export function tagToNostrLink(tag: Array<string>) {
switch(tag[0]) {
case "e": {
return createNostrLink(NostrPrefix.Event, tag[1], tag.slice(2));
}
case "p": {
return createNostrLink(NostrPrefix.Profile, tag[1], tag.slice(2));
}
case "a": {
const [kind, author, dTag] = tag[1].split(":");
return createNostrLink(NostrPrefix.Address, dTag, tag.slice(2), Number(kind), author);
}
}
throw new Error(`Unknown tag kind ${tag[0]}`);
}
export function createNostrLinkToEvent(ev: TaggedNostrEvent | NostrEvent) {
const relays = "relays" in ev ? ev.relays : undefined;