mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-04-02 08:58:23 +02:00
Remove non-used imports in Nip19
This commit is contained in:
parent
91591abd14
commit
657f99a65a
@ -1,13 +1,9 @@
|
||||
package com.vitorpamplona.amethyst.service
|
||||
|
||||
import com.vitorpamplona.amethyst.model.toByteArray
|
||||
import com.vitorpamplona.amethyst.model.toHexKey
|
||||
import com.vitorpamplona.amethyst.service.model.ATag
|
||||
import nostr.postr.bechToBytes
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import nostr.postr.Bech32
|
||||
import nostr.postr.bechToBytes
|
||||
import nostr.postr.toByteArray
|
||||
|
||||
class Nip19 {
|
||||
|
||||
@ -37,7 +33,6 @@ class Nip19 {
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
println("Issue trying to Decode NIP19 ${uri}: ${e.message}")
|
||||
//e.printStackTrace()
|
||||
}
|
||||
|
||||
return null
|
||||
@ -52,8 +47,10 @@ class Nip19 {
|
||||
}
|
||||
|
||||
private fun nprofile(bytes: ByteArray): Return? {
|
||||
val tlv = parseTLV(bytes)
|
||||
val hex = tlv.get(NIP19TLVTypes.SPECIAL.id)?.get(0)?.toHexKey() ?: return null
|
||||
val hex = parseTLV(bytes)
|
||||
.get(NIP19TLVTypes.SPECIAL.id)
|
||||
?.get(0)
|
||||
?.toHexKey() ?: return null
|
||||
|
||||
return Return(Type.USER, hex)
|
||||
}
|
||||
@ -78,16 +75,29 @@ class Nip19 {
|
||||
|
||||
private fun naddr(bytes: ByteArray): Return? {
|
||||
val tlv = parseTLV(bytes)
|
||||
val d = tlv.get(NIP19TLVTypes.SPECIAL.id)?.get(0)?.toString(Charsets.UTF_8) ?: return null
|
||||
val relay = tlv.get(NIP19TLVTypes.RELAY.id)?.get(0)?.toString(Charsets.UTF_8)
|
||||
val author = tlv.get(NIP19TLVTypes.AUTHOR.id)?.get(0)?.toHexKey()
|
||||
val kind = tlv.get(NIP19TLVTypes.KIND.id)?.get(0)?.let { toInt32(it) }
|
||||
|
||||
val d = tlv.get(NIP19TLVTypes.SPECIAL.id)
|
||||
?.get(0)
|
||||
?.toString(Charsets.UTF_8) ?: return null
|
||||
|
||||
val relay = tlv.get(NIP19TLVTypes.RELAY.id)
|
||||
?.get(0)
|
||||
?.toString(Charsets.UTF_8)
|
||||
|
||||
val author = tlv.get(NIP19TLVTypes.AUTHOR.id)
|
||||
?.get(0)
|
||||
?.toHexKey()
|
||||
|
||||
val kind = tlv.get(NIP19TLVTypes.KIND.id)
|
||||
?.get(0)
|
||||
?.let { toInt32(it) }
|
||||
|
||||
return Return(Type.ADDRESS, "$kind:$author:$d")
|
||||
}
|
||||
}
|
||||
|
||||
enum class NIP19TLVTypes(val id: Byte) { //classes should start with an uppercase letter in kotlin
|
||||
// Classes should start with an uppercase letter in kotlin
|
||||
enum class NIP19TLVTypes(val id: Byte) {
|
||||
SPECIAL(0),
|
||||
RELAY(1),
|
||||
AUTHOR(2),
|
||||
|
@ -25,10 +25,10 @@ class Nip19Test {
|
||||
Assert.assertEquals(16909060, actual)
|
||||
}
|
||||
|
||||
@Ignore("Not implemented yet")
|
||||
@Ignore("Test not implemented yet")
|
||||
@Test()
|
||||
fun parse_TLV() {
|
||||
// TODO
|
||||
// TODO: I don't know how to test this (?)
|
||||
}
|
||||
|
||||
@Test()
|
||||
@ -69,7 +69,7 @@ class Nip19Test {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Not implemented yet")
|
||||
@Ignore("Test not implemented yet")
|
||||
@Test()
|
||||
fun uri_to_route_nprofile() {
|
||||
val actual = nip19.uriToRoute("nostr:nprofile")
|
||||
@ -78,7 +78,7 @@ class Nip19Test {
|
||||
Assert.assertEquals("*", actual?.hex)
|
||||
}
|
||||
|
||||
@Ignore("Not implemented yet")
|
||||
@Ignore("Test not implemented yet")
|
||||
@Test()
|
||||
fun uri_to_route_nevent() {
|
||||
val actual = nip19.uriToRoute("nostr:nevent")
|
||||
@ -87,7 +87,7 @@ class Nip19Test {
|
||||
Assert.assertEquals("*", actual?.hex)
|
||||
}
|
||||
|
||||
@Ignore("Not implemented yet")
|
||||
@Ignore("Test not implemented yet")
|
||||
@Test()
|
||||
fun uri_to_route_nrelay() {
|
||||
val actual = nip19.uriToRoute("nostr:nrelay")
|
||||
@ -96,7 +96,7 @@ class Nip19Test {
|
||||
Assert.assertEquals("*", actual?.hex)
|
||||
}
|
||||
|
||||
@Ignore("Not implemented yet")
|
||||
@Ignore("Test not implemented yet")
|
||||
@Test()
|
||||
fun uri_to_route_naddr() {
|
||||
val actual = nip19.uriToRoute("nostr:naddr")
|
||||
|
Loading…
x
Reference in New Issue
Block a user