mirror of
https://github.com/fiatjaf/nak.git
synced 2024-10-30 09:09:08 -04:00
print naddr when given an "a" tag.
This commit is contained in:
parent
fb9faf24ae
commit
4e5f7e6d21
|
@ -160,15 +160,20 @@ object Components {
|
||||||
def renderAddressPointer(
|
def renderAddressPointer(
|
||||||
store: Store,
|
store: Store,
|
||||||
addr: snow.AddressPointer
|
addr: snow.AddressPointer
|
||||||
): Resource[IO, HtmlDivElement[IO]] =
|
): Resource[IO, HtmlDivElement[IO]] = {
|
||||||
|
val nip33atag =
|
||||||
|
s"${addr.kind}:${addr.author.value.toHex}:${addr.d}"
|
||||||
|
|
||||||
div(
|
div(
|
||||||
cls := "text-md",
|
cls := "text-md",
|
||||||
entry("author (pubkey hex)", addr.author.value.toHex),
|
entry("author (pubkey hex)", addr.author.value.toHex),
|
||||||
entry("identifier (d tag)", addr.d),
|
entry("identifier (d tag)", addr.d),
|
||||||
entry("kind", addr.kind.toString),
|
entry("kind", addr.kind.toString),
|
||||||
relayHints(store, addr.relays),
|
relayHints(store, addr.relays),
|
||||||
nip19_21(store, "naddr", NIP19.encode(addr))
|
nip19_21(store, "naddr", NIP19.encode(addr)),
|
||||||
|
entry("nip33 'a' tag", nip33atag, Some(editable(store, nip33atag)))
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
def renderEvent(
|
def renderEvent(
|
||||||
store: Store,
|
store: Store,
|
||||||
|
@ -285,7 +290,7 @@ object Components {
|
||||||
div(
|
div(
|
||||||
cls := "flex items-center space-x-3",
|
cls := "flex items-center space-x-3",
|
||||||
span(cls := "font-bold", key + " "),
|
span(cls := "font-bold", key + " "),
|
||||||
span(Styles.mono, cls := "max-w-xl", value),
|
span(Styles.mono, cls := "max-w-xl break-all", value),
|
||||||
editLink
|
editLink
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,27 @@ object Parser {
|
||||||
.flatMap(b => Try(Right(ByteVector32(b))).toOption)
|
.flatMap(b => Try(Right(ByteVector32(b))).toOption)
|
||||||
.getOrElse(
|
.getOrElse(
|
||||||
NIP19.decode(input) match {
|
NIP19.decode(input) match {
|
||||||
case Right(pp: ProfilePointer) => Right(pp)
|
case Right(pp: ProfilePointer) => Right(pp)
|
||||||
case Right(evp: EventPointer) => Right(evp)
|
case Right(evp: EventPointer) => Right(evp)
|
||||||
case Right(sk: PrivateKey) => Right(sk)
|
case Right(sk: PrivateKey) => Right(sk)
|
||||||
case Right(addr: AddressPointer) => Right(addr)
|
case Right(addr: AddressPointer) => Right(addr)
|
||||||
|
case Left(_) if input.split(":").size == 3 =>
|
||||||
|
// parse "a" tag format, nip 33
|
||||||
|
val spl = input.split(":")
|
||||||
|
(
|
||||||
|
spl(0).toIntOption,
|
||||||
|
ByteVector.fromHex(spl(1)),
|
||||||
|
Some(spl(2))
|
||||||
|
).mapN((kind, author, identifier) =>
|
||||||
|
AddressPointer(
|
||||||
|
identifier,
|
||||||
|
kind,
|
||||||
|
scoin.XOnlyPublicKey(ByteVector32(author)),
|
||||||
|
relays = List.empty
|
||||||
|
)
|
||||||
|
).toRight("couldn't parse as a nip33 'a' tag")
|
||||||
case Left(_) =>
|
case Left(_) =>
|
||||||
|
// parse event json
|
||||||
parse(input) match {
|
parse(input) match {
|
||||||
case Left(err: io.circe.ParsingFailure) =>
|
case Left(err: io.circe.ParsingFailure) =>
|
||||||
Left("not valid JSON or NIP-19 code")
|
Left("not valid JSON or NIP-19 code")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user