Fully Deprecates note1, removing the last usages of the standard
This commit is contained in:
@@ -31,7 +31,7 @@ import com.vitorpamplona.ammolite.relays.BundledUpdate
|
|||||||
import com.vitorpamplona.quartz.encoders.ATag
|
import com.vitorpamplona.quartz.encoders.ATag
|
||||||
import com.vitorpamplona.quartz.encoders.Hex
|
import com.vitorpamplona.quartz.encoders.Hex
|
||||||
import com.vitorpamplona.quartz.encoders.HexKey
|
import com.vitorpamplona.quartz.encoders.HexKey
|
||||||
import com.vitorpamplona.quartz.encoders.toNote
|
import com.vitorpamplona.quartz.encoders.toNEvent
|
||||||
import com.vitorpamplona.quartz.events.ChannelCreateEvent
|
import com.vitorpamplona.quartz.events.ChannelCreateEvent
|
||||||
import com.vitorpamplona.quartz.events.LiveActivitiesEvent
|
import com.vitorpamplona.quartz.events.LiveActivitiesEvent
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -107,7 +107,7 @@ abstract class Channel(
|
|||||||
|
|
||||||
open fun id() = Hex.decode(idHex)
|
open fun id() = Hex.decode(idHex)
|
||||||
|
|
||||||
open fun idNote() = id().toNote()
|
open fun idNote() = id().toNEvent()
|
||||||
|
|
||||||
open fun idDisplayNote() = idNote().toShortenHex()
|
open fun idDisplayNote() = idNote().toShortenHex()
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ import com.vitorpamplona.quartz.encoders.Hex
|
|||||||
import com.vitorpamplona.quartz.encoders.HexKey
|
import com.vitorpamplona.quartz.encoders.HexKey
|
||||||
import com.vitorpamplona.quartz.encoders.LnInvoiceUtil
|
import com.vitorpamplona.quartz.encoders.LnInvoiceUtil
|
||||||
import com.vitorpamplona.quartz.encoders.Nip19Bech32
|
import com.vitorpamplona.quartz.encoders.Nip19Bech32
|
||||||
import com.vitorpamplona.quartz.encoders.toNote
|
|
||||||
import com.vitorpamplona.quartz.events.AddressableEvent
|
import com.vitorpamplona.quartz.events.AddressableEvent
|
||||||
import com.vitorpamplona.quartz.events.BaseTextNoteEvent
|
import com.vitorpamplona.quartz.events.BaseTextNoteEvent
|
||||||
import com.vitorpamplona.quartz.events.ChannelCreateEvent
|
import com.vitorpamplona.quartz.events.ChannelCreateEvent
|
||||||
@@ -80,9 +79,9 @@ import kotlin.coroutines.resume
|
|||||||
class AddressableNote(
|
class AddressableNote(
|
||||||
val address: ATag,
|
val address: ATag,
|
||||||
) : Note(address.toTag()) {
|
) : Note(address.toTag()) {
|
||||||
override fun idNote() = address.toNAddr()
|
override fun idNote() = address.toNAddr(relayHintUrl())
|
||||||
|
|
||||||
override fun toNEvent() = address.toNAddr()
|
override fun toNEvent() = address.toNAddr(relayHintUrl())
|
||||||
|
|
||||||
override fun idDisplayNote() = idNote().toShortenHex()
|
override fun idDisplayNote() = idNote().toShortenHex()
|
||||||
|
|
||||||
@@ -146,7 +145,7 @@ open class Note(
|
|||||||
|
|
||||||
fun id() = Hex.decode(idHex)
|
fun id() = Hex.decode(idHex)
|
||||||
|
|
||||||
open fun idNote() = id().toNote()
|
open fun idNote() = toNEvent()
|
||||||
|
|
||||||
open fun toNEvent(): String {
|
open fun toNEvent(): String {
|
||||||
val myEvent = event
|
val myEvent = event
|
||||||
|
|||||||
@@ -37,11 +37,9 @@ fun ClickableNoteTag(
|
|||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
val route = routeFor(baseNote, accountViewModel.userProfile())
|
|
||||||
|
|
||||||
ClickableText(
|
ClickableText(
|
||||||
text = AnnotatedString("@${baseNote.idNote().toShortenHex()}"),
|
text = AnnotatedString("@${baseNote.idNote().toShortenHex()}"),
|
||||||
onClick = { nav.nav("Note/${baseNote.idHex}") },
|
onClick = { routeFor(baseNote, accountViewModel.userProfile())?.let { nav.nav(it) } },
|
||||||
style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary),
|
style = LocalTextStyle.current.copy(color = MaterialTheme.colorScheme.primary),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,11 +56,11 @@ data class ATag(
|
|||||||
|
|
||||||
fun toQTagArray() = removeTrailingNullsAndEmptyOthers("q", toTag(), relay)
|
fun toQTagArray() = removeTrailingNullsAndEmptyOthers("q", toTag(), relay)
|
||||||
|
|
||||||
fun toNAddr(): String =
|
fun toNAddr(overrideRelay: String? = relay): String =
|
||||||
TlvBuilder()
|
TlvBuilder()
|
||||||
.apply {
|
.apply {
|
||||||
addString(Nip19Bech32.TlvTypes.SPECIAL, dTag)
|
addString(Nip19Bech32.TlvTypes.SPECIAL, dTag)
|
||||||
addStringIfNotNull(Nip19Bech32.TlvTypes.RELAY, relay)
|
addStringIfNotNull(Nip19Bech32.TlvTypes.RELAY, overrideRelay)
|
||||||
addHex(Nip19Bech32.TlvTypes.AUTHOR, pubKeyHex)
|
addHex(Nip19Bech32.TlvTypes.AUTHOR, pubKeyHex)
|
||||||
addInt(Nip19Bech32.TlvTypes.KIND, kind)
|
addInt(Nip19Bech32.TlvTypes.KIND, kind)
|
||||||
}.build()
|
}.build()
|
||||||
|
|||||||
@@ -45,8 +45,6 @@ data class ETag(
|
|||||||
|
|
||||||
fun toNEvent(): String = Nip19Bech32.createNEvent(eventId, authorPubKeyHex, null, relay)
|
fun toNEvent(): String = Nip19Bech32.createNEvent(eventId, authorPubKeyHex, null, relay)
|
||||||
|
|
||||||
fun toNote(): String = Nip19Bech32.createNote(eventId)
|
|
||||||
|
|
||||||
fun toETagArray() = removeTrailingNullsAndEmptyOthers("e", eventId, relay, authorPubKeyHex)
|
fun toETagArray() = removeTrailingNullsAndEmptyOthers("e", eventId, relay, authorPubKeyHex)
|
||||||
|
|
||||||
fun toQTagArray() = removeTrailingNullsAndEmptyOthers("q", eventId, relay, authorPubKeyHex)
|
fun toQTagArray() = removeTrailingNullsAndEmptyOthers("q", eventId, relay, authorPubKeyHex)
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ object Nip19Bech32 {
|
|||||||
}.build()
|
}.build()
|
||||||
.toNEvent()
|
.toNEvent()
|
||||||
|
|
||||||
|
@Deprecated("Use nevent instead")
|
||||||
fun createNote(eventId: HexKey): String = eventId.hexToByteArray().toNote()
|
fun createNote(eventId: HexKey): String = eventId.hexToByteArray().toNote()
|
||||||
|
|
||||||
fun createNPub(authorPubKeyHex: HexKey): String = authorPubKeyHex.hexToByteArray().toNpub()
|
fun createNPub(authorPubKeyHex: HexKey): String = authorPubKeyHex.hexToByteArray().toNpub()
|
||||||
@@ -303,6 +304,7 @@ fun ByteArray.toNsec() = Bech32.encodeBytes(hrp = "nsec", this, Bech32.Encoding.
|
|||||||
|
|
||||||
fun ByteArray.toNpub() = Bech32.encodeBytes(hrp = "npub", this, Bech32.Encoding.Bech32)
|
fun ByteArray.toNpub() = Bech32.encodeBytes(hrp = "npub", this, Bech32.Encoding.Bech32)
|
||||||
|
|
||||||
|
@Deprecated("Prefer nevent1 instead")
|
||||||
fun ByteArray.toNote() = Bech32.encodeBytes(hrp = "note", this, Bech32.Encoding.Bech32)
|
fun ByteArray.toNote() = Bech32.encodeBytes(hrp = "note", this, Bech32.Encoding.Bech32)
|
||||||
|
|
||||||
fun ByteArray.toNEvent() = Bech32.encodeBytes(hrp = "nevent", this, Bech32.Encoding.Bech32)
|
fun ByteArray.toNEvent() = Bech32.encodeBytes(hrp = "nevent", this, Bech32.Encoding.Bech32)
|
||||||
|
|||||||
Reference in New Issue
Block a user