Skip to content

Commit

Permalink
updated changes from quartz
Browse files Browse the repository at this point in the history
  • Loading branch information
greenart7c3 committed Nov 29, 2023
1 parent ee68da9 commit 2949461
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ open class AmberEvent(
@SerializedName("pubkey") val pubKey: HexKey,
@SerializedName("created_at") val createdAt: Long,
val kind: Int,
val tags: List<List<String>>,
val tags: Array<Array<String>>,
val content: String,
val sig: HexKey
) : AmberEventInterface {
Expand All @@ -48,7 +48,7 @@ open class AmberEvent(
return "event"
}

override fun tags(): List<List<String>> = tags
override fun tags(): Array<Array<String>> = tags

override fun content(): String = content

Expand Down Expand Up @@ -244,8 +244,8 @@ open class AmberEvent(
createdAt = jsonObject.get("created_at")?.asLong ?: TimeUtils.now(),
kind = jsonObject.get("kind").asInt,
tags = jsonObject.get("tags")?.asJsonArray?.map {
it.asJsonArray.mapNotNull { s -> if (s.isJsonNull) null else s.asString }
} ?: emptyList(),
it.asJsonArray.mapNotNull { s -> if (s.isJsonNull) null else s.asString }.toTypedArray()
}?.toTypedArray() ?: emptyArray(),
content = jsonObject.get("content").asString,
sig = jsonObject.get("sig")?.asString ?: ""
)
Expand Down Expand Up @@ -434,7 +434,7 @@ open class AmberEvent(
)
}

fun generateId(pubKey: HexKey, createdAt: Long, kind: Int, tags: List<List<String>>, content: String): ByteArray {
fun generateId(pubKey: HexKey, createdAt: Long, kind: Int, tags: Array<Array<String>>, content: String): ByteArray {
val rawEvent = listOf(
0,
pubKey,
Expand Down Expand Up @@ -466,7 +466,7 @@ open class AmberEvent(
return event
}

fun create(privateKey: ByteArray, kind: Int, tags: List<List<String>> = emptyList(), content: String = "", createdAt: Long = TimeUtils.now()): AmberEvent {
fun create(privateKey: ByteArray, kind: Int, tags: Array<Array<String>> = emptyArray(), content: String = "", createdAt: Long = TimeUtils.now()): AmberEvent {
val pubKey = CryptoUtils.pubkeyCreate(privateKey).toHexKey()
val id = generateId(pubKey, createdAt, kind, tags, content)
val sig = CryptoUtils.sign(id, privateKey).toHexKey()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface AmberEventInterface {

fun description(): String

fun tags(): List<List<String>>
fun tags(): Array<Array<String>>

fun content(): String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import com.greenart7c3.nostrsigner.ui.theme.NostrSignerTheme
@Preview(device = "id:Nexus S")
@Composable
fun EventDataPreview() {
val event = AmberEvent("123", "7579076d9aff0a4cfdefa7e2045f2486c7e5d8bc63bfc6b45397233e1bbfcb19", TimeUtils.now(), 1, listOf(), "This is a test 123 123 123 123 123 123", "")
val event = AmberEvent("123", "7579076d9aff0a4cfdefa7e2045f2486c7e5d8bc63bfc6b45397233e1bbfcb19", TimeUtils.now(), 1, arrayOf(), "This is a test 123 123 123 123 123 123", "")
val data = event.toJson()
val remember = remember { mutableStateOf(false) }

Expand Down

0 comments on commit 2949461

Please sign in to comment.