- Removes compose bom from Quartz to avoid unnecessary dependencies.
- Removes old datetime dependencies from Quartz - Moves compose.runtime dependencies to compose.runtime.annotation - Adds dependency on coroutines directly (instead of through compose runtime) - Removes old secp256 target dependencies - Adds Default scope for NostrClient and Relay Authenticator - Updates readme
This commit is contained in:
+6
-12
@@ -95,10 +95,13 @@ kotlin {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation(libs.kotlin.stdlib)
|
||||
implementation(project.dependencies.platform(libs.androidx.compose.bom))
|
||||
implementation(libs.kotlinx.coroutines.core)
|
||||
|
||||
// For LruCache
|
||||
implementation(libs.androidx.collection)
|
||||
|
||||
// @Immutable and @Stable
|
||||
implementation(libs.androidx.compose.runtime)
|
||||
implementation(libs.androidx.compose.runtime.annotation)
|
||||
|
||||
// Bitcoin secp256k1 bindings
|
||||
api(libs.secp256k1.kmp.common)
|
||||
@@ -106,9 +109,6 @@ kotlin {
|
||||
// Kotlin serialization for the times where we need the Json tree and performance is not that important.
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
|
||||
// in your shared module's dependencies block
|
||||
// implementation( libs.kotlinx.datetime)
|
||||
|
||||
// immutable collections to avoid recomposition
|
||||
implementation(libs.kotlinx.collections.immutable)
|
||||
}
|
||||
@@ -126,9 +126,6 @@ kotlin {
|
||||
dependsOn(commonMain.get())
|
||||
|
||||
dependencies {
|
||||
// For LruCache
|
||||
implementation(libs.androidx.collection.jvm)
|
||||
|
||||
// Normalizes URLs
|
||||
api(libs.rfc3986.normalizer)
|
||||
|
||||
@@ -157,7 +154,7 @@ kotlin {
|
||||
dependsOn(jvmAndroid)
|
||||
dependencies {
|
||||
// Bitcoin secp256k1 bindings
|
||||
api(libs.secp256k1.kmp.jni.jvm)
|
||||
implementation (libs.secp256k1.kmp.jni.jvm)
|
||||
|
||||
// LibSodium for ChaCha encryption (NIP-44)
|
||||
implementation (libs.lazysodium.java)
|
||||
@@ -178,9 +175,6 @@ kotlin {
|
||||
dependencies {
|
||||
implementation(libs.androidx.core.ktx)
|
||||
|
||||
// @Immutable and @Stable
|
||||
implementation(libs.androidx.compose.runtime)
|
||||
|
||||
// Bitcoin secp256k1 bindings to Android
|
||||
api(libs.secp256k1.kmp.jni.android)
|
||||
|
||||
|
||||
+4
-1
@@ -37,7 +37,10 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.sockets.WebsocketBuilder
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
import kotlinx.coroutines.IO
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.combine
|
||||
@@ -74,7 +77,7 @@ import kotlinx.coroutines.launch
|
||||
*/
|
||||
class NostrClient(
|
||||
private val websocketBuilder: WebsocketBuilder,
|
||||
private val scope: CoroutineScope,
|
||||
private val scope: CoroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob()),
|
||||
) : INostrClient,
|
||||
IRelayClientListener {
|
||||
private val relayPool: RelayPool = RelayPool(websocketBuilder, this)
|
||||
|
||||
+4
-1
@@ -32,6 +32,9 @@ import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
|
||||
import com.vitorpamplona.quartz.nip42RelayAuth.RelayAuthEvent
|
||||
import com.vitorpamplona.quartz.utils.Log
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.IO
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
interface IAuthStatus {
|
||||
@@ -44,7 +47,7 @@ object EmptyIAuthStatus : IAuthStatus {
|
||||
|
||||
class RelayAuthenticator(
|
||||
val client: INostrClient,
|
||||
val scope: CoroutineScope,
|
||||
val scope: CoroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob()),
|
||||
val signWithAllLoggedInUsers: suspend (EventTemplate<RelayAuthEvent>) -> List<RelayAuthEvent>,
|
||||
) : IAuthStatus {
|
||||
private val authStatus = mutableMapOf<NormalizedRelayUrl, RelayAuthStatus>()
|
||||
|
||||
+4
@@ -28,6 +28,8 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
||||
import com.vitorpamplona.quartz.utils.Log
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.flow.debounce
|
||||
@@ -43,6 +45,7 @@ class NostrClientSubscriptionAsFlowTest : BaseNostrClientTest() {
|
||||
return joinToString { (it.createdAt - starting).toString() }
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@Test
|
||||
fun testNostrClientSubscriptionAsFlow() =
|
||||
runTest {
|
||||
@@ -81,6 +84,7 @@ class NostrClientSubscriptionAsFlowTest : BaseNostrClientTest() {
|
||||
assertEquals(10, feedStates.size)
|
||||
}
|
||||
|
||||
@OptIn(FlowPreview::class, ExperimentalCoroutinesApi::class)
|
||||
@Test
|
||||
fun testNostrClientSubscriptionAsFlowDebouncing() =
|
||||
runTest {
|
||||
|
||||
Reference in New Issue
Block a user