From 170b6cfe6970324086c159ee9551e952505dbec3 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 27 Aug 2025 21:09:21 -0400 Subject: [PATCH] Moves test assets to resources to make it work with kmp --- benchmark/build.gradle | 2 +- .../amethyst/benchmark/MetaTagsParserBenchmark.kt | 6 ++---- .../quartz/benchmark/BaseLargeCacheBenchmark.kt | 3 +-- .../quartz/benchmark/CacheBenchmark.kt | 3 +-- .../quartz/benchmark/HintIndexerBenchmark.kt | 6 ++---- commons/proguard-rules.pro | 4 +++- quartz/proguard-rules.pro | 3 ++- .../vitorpamplona/quartz/LargeDBSignatureCheck.kt | 5 ++--- .../quartz/nip01Core/store/sqlite/LargeDBTests.kt | 3 +-- .../quartz/nip06KeyDerivation/Bip39MnemonicsTest.kt | 8 +------- .../com/vitorpamplona/quartz/nip17Dm/AESGCMTest.kt | 9 ++++----- .../quartz/nip19Bech32/NIP19EmbedTests.kt | 11 ++--------- .../quartz/nip44Encryption/Nip44v2Test.kt | 3 +-- .../quartz/nip59GiftWraps/GiftWrapEventTest.kt | 2 +- .../{assets => resources}/bip39.vectors.json | 0 .../{assets => resources}/github_amethyst.html | 0 .../{assets => resources}/nip44.vectors.json | 0 .../{assets => resources}/nostr_vitor_short.json | 0 .../nostr_vitor_startup_data.json | Bin .../{assets => resources}/ovxxk2vz.jpg | Bin .../{assets => resources}/relayDB.txt | 0 .../{assets => resources}/trouble_video | Bin .../quartz/nip59Giftwrap/seals/SealedRumorEvent.kt | 7 +++---- .../quartz/nip59Giftwrap/wraps/GiftWrapEvent.kt | 7 +++---- 24 files changed, 30 insertions(+), 52 deletions(-) rename quartz/src/androidDeviceTest/{assets => resources}/bip39.vectors.json (100%) rename quartz/src/androidDeviceTest/{assets => resources}/github_amethyst.html (100%) rename quartz/src/androidDeviceTest/{assets => resources}/nip44.vectors.json (100%) rename quartz/src/androidDeviceTest/{assets => resources}/nostr_vitor_short.json (100%) rename quartz/src/androidDeviceTest/{assets => resources}/nostr_vitor_startup_data.json (100%) rename quartz/src/androidDeviceTest/{assets => resources}/ovxxk2vz.jpg (100%) rename quartz/src/androidDeviceTest/{assets => resources}/relayDB.txt (100%) rename quartz/src/androidDeviceTest/{assets => resources}/trouble_video (100%) diff --git a/benchmark/build.gradle b/benchmark/build.gradle index 866d4e71b..d008883b7 100644 --- a/benchmark/build.gradle +++ b/benchmark/build.gradle @@ -24,7 +24,7 @@ android { targetCompatibility JavaVersion.VERSION_21 } - sourceSets.androidTest.assets.srcDirs += ["../quartz/src/androidTest/assets"] + sourceSets.androidTest.resources.srcDirs += ["../quartz/src/androidDeviceTest/resources"] testBuildType = "benchmark" buildTypes { diff --git a/benchmark/src/androidTest/java/com/vitorpamplona/amethyst/benchmark/MetaTagsParserBenchmark.kt b/benchmark/src/androidTest/java/com/vitorpamplona/amethyst/benchmark/MetaTagsParserBenchmark.kt index 6b6aea7d2..7159ec9a1 100644 --- a/benchmark/src/androidTest/java/com/vitorpamplona/amethyst/benchmark/MetaTagsParserBenchmark.kt +++ b/benchmark/src/androidTest/java/com/vitorpamplona/amethyst/benchmark/MetaTagsParserBenchmark.kt @@ -23,7 +23,6 @@ package com.vitorpamplona.amethyst.benchmark import androidx.benchmark.junit4.BenchmarkRule import androidx.benchmark.junit4.measureRepeated import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation import com.vitorpamplona.amethyst.commons.preview.MetaTagsParser import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull @@ -35,9 +34,8 @@ import java.nio.charset.Charset @RunWith(AndroidJUnit4::class) class MetaTagsParserBenchmark { private val html = - getInstrumentation() - .context.assets - .open("github_amethyst.html") + javaClass.classLoader!! + .getResourceAsStream("github_amethyst.html") .readBytes() .toString(Charset.forName("utf-8")) diff --git a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/BaseLargeCacheBenchmark.kt b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/BaseLargeCacheBenchmark.kt index 3f502cb4d..b64308936 100644 --- a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/BaseLargeCacheBenchmark.kt +++ b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/BaseLargeCacheBenchmark.kt @@ -20,7 +20,6 @@ */ package com.vitorpamplona.quartz.benchmark -import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation import com.fasterxml.jackson.module.kotlin.readValue import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey @@ -34,7 +33,7 @@ open class BaseLargeCacheBenchmark { companion object { fun getEventDB(): List { // This file includes duplicates - val fullDBInputStream = getInstrumentation().context.assets.open("nostr_vitor_startup_data.json") + val fullDBInputStream = javaClass.classLoader?.getResourceAsStream("nostr_vitor_startup_data.json") return JsonMapper.mapper.readValue>( GZIPInputStream(fullDBInputStream), diff --git a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/CacheBenchmark.kt b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/CacheBenchmark.kt index 2e0bf231a..2fbe69d92 100644 --- a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/CacheBenchmark.kt +++ b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/CacheBenchmark.kt @@ -23,7 +23,6 @@ package com.vitorpamplona.quartz.benchmark import androidx.benchmark.junit4.BenchmarkRule import androidx.benchmark.junit4.measureRepeated import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation import com.fasterxml.jackson.module.kotlin.readValue import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey @@ -42,7 +41,7 @@ import java.util.zip.GZIPInputStream open class BaseCacheBenchmark { fun getEventDB(): List { // This file includes duplicates - val fullDBInputStream = getInstrumentation().context.assets.open("nostr_vitor_startup_data.json") + val fullDBInputStream = javaClass.classLoader?.getResourceAsStream("nostr_vitor_startup_data.json") return JsonMapper.mapper.readValue>( GZIPInputStream(fullDBInputStream), diff --git a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/HintIndexerBenchmark.kt b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/HintIndexerBenchmark.kt index 80c16fdfe..28ea473b6 100644 --- a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/HintIndexerBenchmark.kt +++ b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/HintIndexerBenchmark.kt @@ -23,7 +23,6 @@ package com.vitorpamplona.quartz.benchmark import androidx.benchmark.junit4.BenchmarkRule import androidx.benchmark.junit4.measureRepeated import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.hints.HintIndexer @@ -47,9 +46,8 @@ class HintIndexerBenchmark { } val relays = - getInstrumentation() - .context.assets - .open("relayDB.txt") + javaClass.classLoader + ?.getResourceAsStream("relayDB.txt")!! .readBytes() .toString(Charset.forName("utf-8")) .split("\n") diff --git a/commons/proguard-rules.pro b/commons/proguard-rules.pro index 0c1559397..283e8b07f 100644 --- a/commons/proguard-rules.pro +++ b/commons/proguard-rules.pro @@ -20,4 +20,6 @@ # hide the original source file name. #-renamesourcefileattribute SourceFile --keep class com.vitorpamplona.amethyst.commons.** { *; } \ No newline at end of file +-keep class com.vitorpamplona.quartz.** { *; } +-keep class com.vitorpamplona.amethyst.** { *; } +-keep class com.vitorpamplona.ammolite.** { *; } \ No newline at end of file diff --git a/quartz/proguard-rules.pro b/quartz/proguard-rules.pro index 5dc1d419e..4d9f471e2 100644 --- a/quartz/proguard-rules.pro +++ b/quartz/proguard-rules.pro @@ -58,4 +58,5 @@ } # JSON parsing --keep class com.vitorpamplona.quartz.** { *; } \ No newline at end of file +-keep class com.vitorpamplona.quartz.** { *; } + diff --git a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/LargeDBSignatureCheck.kt b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/LargeDBSignatureCheck.kt index b40314fd7..ed5257c58 100644 --- a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/LargeDBSignatureCheck.kt +++ b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/LargeDBSignatureCheck.kt @@ -21,7 +21,6 @@ package com.vitorpamplona.quartz import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation import com.fasterxml.jackson.module.kotlin.readValue import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.jackson.JsonMapper @@ -39,7 +38,7 @@ class LargeDBSignatureCheck { @Test fun insertDatabaseSample() = runBlocking { - val fullDBInputStream = getInstrumentation().context.assets.open("nostr_vitor_short.json") + val fullDBInputStream = javaClass.classLoader?.getResourceAsStream("nostr_vitor_short.json") val eventArray = JsonMapper.mapper.readValue>( @@ -59,7 +58,7 @@ class LargeDBSignatureCheck { fun insertStartupDatabase() = runBlocking { // This file includes duplicates - val fullDBInputStream = getInstrumentation().context.assets.open("nostr_vitor_startup_data.json") + val fullDBInputStream = javaClass.classLoader?.getResourceAsStream("nostr_vitor_startup_data.json") val eventArray = JsonMapper.mapper.readValue>( diff --git a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/LargeDBTests.kt b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/LargeDBTests.kt index ac62d9ff3..8b4d1a276 100644 --- a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/LargeDBTests.kt +++ b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/LargeDBTests.kt @@ -25,7 +25,6 @@ import android.database.sqlite.SQLiteException import android.util.Log import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation import com.fasterxml.jackson.module.kotlin.readValue import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.jackson.JsonMapper @@ -42,7 +41,7 @@ class LargeDBTests { companion object { fun getEventDB(): List { // This file includes duplicates - val fullDBInputStream = getInstrumentation().context.assets.open("nostr_vitor_startup_data.json") + val fullDBInputStream = javaClass.classLoader?.getResourceAsStream("nostr_vitor_startup_data.json") return JsonMapper.mapper.readValue>( GZIPInputStream(fullDBInputStream), diff --git a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip06KeyDerivation/Bip39MnemonicsTest.kt b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip06KeyDerivation/Bip39MnemonicsTest.kt index ebdafca34..7b0dd25bd 100644 --- a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip06KeyDerivation/Bip39MnemonicsTest.kt +++ b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip06KeyDerivation/Bip39MnemonicsTest.kt @@ -21,7 +21,6 @@ package com.vitorpamplona.quartz.nip06KeyDerivation import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.utils.Hex @@ -36,12 +35,7 @@ import org.junit.runner.RunWith class Bip39MnemonicsTest { private val tests = jacksonObjectMapper() - .readTree( - InstrumentationRegistry - .getInstrumentation() - .context.assets - .open("bip39.vectors.json"), - ) + .readTree(javaClass.classLoader?.getResourceAsStream("bip39.vectors.json")) @Test fun toSeed() { diff --git a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip17Dm/AESGCMTest.kt b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip17Dm/AESGCMTest.kt index 2d3eb66c1..94cae9112 100644 --- a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip17Dm/AESGCMTest.kt +++ b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip17Dm/AESGCMTest.kt @@ -21,7 +21,6 @@ package com.vitorpamplona.quartz.nip17Dm import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation import com.vitorpamplona.quartz.nip01Core.core.hexToByteArray import com.vitorpamplona.quartz.nip17Dm.files.encryption.AESGCM import junit.framework.TestCase.assertEquals @@ -46,9 +45,9 @@ class AESGCMTest { @Test fun imageTest() { val image = - getInstrumentation().context.assets.open("ovxxk2vz.jpg").use { + javaClass.classLoader?.getResourceAsStream("ovxxk2vz.jpg")?.use { it.readAllBytes() - } + }!! val decrypted = cipher.decrypt(image) @@ -64,9 +63,9 @@ class AESGCMTest { ) val encrypted = - getInstrumentation().context.assets.open("trouble_video").use { + javaClass.classLoader?.getResourceAsStream("trouble_video")?.use { it.readAllBytes() - } + }!! val decrypted = myCipher.decrypt(encrypted) diff --git a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip19Bech32/NIP19EmbedTests.kt b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip19Bech32/NIP19EmbedTests.kt index 347ecf81f..f6c574544 100644 --- a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip19Bech32/NIP19EmbedTests.kt +++ b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip19Bech32/NIP19EmbedTests.kt @@ -33,11 +33,8 @@ import junit.framework.TestCase.assertEquals import junit.framework.TestCase.assertNotNull import junit.framework.TestCase.assertTrue import kotlinx.coroutines.runBlocking -import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import java.util.concurrent.CountDownLatch -import java.util.concurrent.TimeUnit @RunWith(AndroidJUnit4::class) class NIP19EmbedTests { @@ -57,7 +54,7 @@ class NIP19EmbedTests { assertNotNull(textNote) - val bech32 = NEmbed.create(textNote!!) + val bech32 = NEmbed.create(textNote) println(bech32) @@ -65,7 +62,7 @@ class NIP19EmbedTests { assertTrue(decodedNote.verify()) - assertEquals(textNote!!.toJson(), decodedNote.toJson()) + assertEquals(textNote.toJson(), decodedNote.toJson()) } @Test @@ -101,15 +98,11 @@ class NIP19EmbedTests { KeyPair(Hex.decode("e8e7197ccc53c9ed4cf9b1c8dce085475fa1ffdd71f2c14e44fe23d0bdf77598")), ) - val countDownLatch = CountDownLatch(1) - val eyeglassesPrescriptionEvent = runBlocking { signer.sign(FhirResourceEvent.build(visionPrescriptionBundle)) } - Assert.assertTrue(countDownLatch.await(1, TimeUnit.SECONDS)) - assertNotNull(eyeglassesPrescriptionEvent) val bech32 = NEmbed.create(eyeglassesPrescriptionEvent) diff --git a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip44Encryption/Nip44v2Test.kt b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip44Encryption/Nip44v2Test.kt index e0dcddbfe..bf87b85cf 100644 --- a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip44Encryption/Nip44v2Test.kt +++ b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip44Encryption/Nip44v2Test.kt @@ -21,7 +21,6 @@ package com.vitorpamplona.quartz.nip44Encryption import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.vitorpamplona.quartz.nip01Core.core.hexToByteArray import com.vitorpamplona.quartz.nip01Core.core.toHexKey @@ -41,7 +40,7 @@ class Nip44v2Test { private val vectors: VectorFile = jacksonObjectMapper() .readValue( - getInstrumentation().context.assets.open("nip44.vectors.json"), + javaClass.classLoader?.getResourceAsStream("nip44.vectors.json"), VectorFile::class.java, ) diff --git a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip59GiftWraps/GiftWrapEventTest.kt b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip59GiftWraps/GiftWrapEventTest.kt index 1b244a2b3..aa21965ee 100644 --- a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip59GiftWraps/GiftWrapEventTest.kt +++ b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip59GiftWraps/GiftWrapEventTest.kt @@ -237,7 +237,7 @@ class GiftWrapEventTest { fail("Should not be able to decrypt msg for the receiver decrypted by the sender") } - giftWrapToReceiver.unwrapOrNull(receiver)?.let { _ -> + giftWrapToSender.unwrapOrNull(receiver)?.let { _ -> fail("Should not be able to decrypt msg for the sender decrypted by the receiver") } diff --git a/quartz/src/androidDeviceTest/assets/bip39.vectors.json b/quartz/src/androidDeviceTest/resources/bip39.vectors.json similarity index 100% rename from quartz/src/androidDeviceTest/assets/bip39.vectors.json rename to quartz/src/androidDeviceTest/resources/bip39.vectors.json diff --git a/quartz/src/androidDeviceTest/assets/github_amethyst.html b/quartz/src/androidDeviceTest/resources/github_amethyst.html similarity index 100% rename from quartz/src/androidDeviceTest/assets/github_amethyst.html rename to quartz/src/androidDeviceTest/resources/github_amethyst.html diff --git a/quartz/src/androidDeviceTest/assets/nip44.vectors.json b/quartz/src/androidDeviceTest/resources/nip44.vectors.json similarity index 100% rename from quartz/src/androidDeviceTest/assets/nip44.vectors.json rename to quartz/src/androidDeviceTest/resources/nip44.vectors.json diff --git a/quartz/src/androidDeviceTest/assets/nostr_vitor_short.json b/quartz/src/androidDeviceTest/resources/nostr_vitor_short.json similarity index 100% rename from quartz/src/androidDeviceTest/assets/nostr_vitor_short.json rename to quartz/src/androidDeviceTest/resources/nostr_vitor_short.json diff --git a/quartz/src/androidDeviceTest/assets/nostr_vitor_startup_data.json b/quartz/src/androidDeviceTest/resources/nostr_vitor_startup_data.json similarity index 100% rename from quartz/src/androidDeviceTest/assets/nostr_vitor_startup_data.json rename to quartz/src/androidDeviceTest/resources/nostr_vitor_startup_data.json diff --git a/quartz/src/androidDeviceTest/assets/ovxxk2vz.jpg b/quartz/src/androidDeviceTest/resources/ovxxk2vz.jpg similarity index 100% rename from quartz/src/androidDeviceTest/assets/ovxxk2vz.jpg rename to quartz/src/androidDeviceTest/resources/ovxxk2vz.jpg diff --git a/quartz/src/androidDeviceTest/assets/relayDB.txt b/quartz/src/androidDeviceTest/resources/relayDB.txt similarity index 100% rename from quartz/src/androidDeviceTest/assets/relayDB.txt rename to quartz/src/androidDeviceTest/resources/relayDB.txt diff --git a/quartz/src/androidDeviceTest/assets/trouble_video b/quartz/src/androidDeviceTest/resources/trouble_video similarity index 100% rename from quartz/src/androidDeviceTest/assets/trouble_video rename to quartz/src/androidDeviceTest/resources/trouble_video diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/seals/SealedRumorEvent.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/seals/SealedRumorEvent.kt index c65005c19..9d79f9d7c 100644 --- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/seals/SealedRumorEvent.kt +++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/seals/SealedRumorEvent.kt @@ -78,14 +78,13 @@ class SealedRumorEvent( return event } - suspend fun unsealOrNull(signer: NostrSigner): Event? { - return try { - return unsealThrowing(signer) + suspend fun unsealOrNull(signer: NostrSigner): Event? = + try { + unsealThrowing(signer) } catch (e: Exception) { Log.w("RumorEvent", "Fail to decrypt or parse Rumor", e) null } - } private suspend fun plainContent(signer: NostrSigner): String { if (content.isEmpty()) return "" diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/wraps/GiftWrapEvent.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/wraps/GiftWrapEvent.kt index 9b8fd9313..0608a06ef 100644 --- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/wraps/GiftWrapEvent.kt +++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/wraps/GiftWrapEvent.kt @@ -80,14 +80,13 @@ class GiftWrapEvent( return gift } - suspend fun unwrapOrNull(signer: NostrSigner): Event? { + suspend fun unwrapOrNull(signer: NostrSigner): Event? = try { - return unwrapThrowing(signer) + unwrapThrowing(signer) } catch (_: Exception) { Log.w("GiftWrapEvent", "Couldn't Decrypt the content " + this.toNostrUri()) - return null + null } - } private suspend fun plainContent(signer: NostrSigner): String { if (content.isEmpty()) return ""