diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/Nip05NostrAddressVerifier.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/Nip05NostrAddressVerifier.kt index 35fb7b90d..5ad6597e8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/Nip05NostrAddressVerifier.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/Nip05NostrAddressVerifier.kt @@ -28,15 +28,13 @@ import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.coroutines.executeAsync -class Nip05NostrAddressVerifier { +object Nip05NostrAddressVerifier { suspend fun fetchNip05Json( nip05: String, okHttpClient: (String) -> OkHttpClient, onSuccess: suspend (String) -> Unit, onError: (String) -> Unit, ) = withContext(Dispatchers.IO) { - checkNotInMainThread() - val url = Nip05().assembleUrl(nip05) if (url == null) { @@ -73,15 +71,10 @@ class Nip05NostrAddressVerifier { onSuccess: suspend (String) -> Unit, onError: (String) -> Unit, ) { - // check fails on tests - checkNotInMainThread() - fetchNip05Json( nip05, okHttpClient, onSuccess = { - checkNotInMainThread() - Nip05().parseHexKeyFor(nip05, it.lowercase()).fold( onSuccess = { hexKey -> if (hexKey == null) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt index c96851b95..c969c26e4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt @@ -214,7 +214,7 @@ class AccountStateViewModel : ViewModel() { loginSync(newKey, transientAccount, loginWithExternalSigner, packageName, onError) } } else if (EMAIL_PATTERN.matcher(key).matches()) { - Nip05NostrAddressVerifier().verifyNip05( + Nip05NostrAddressVerifier.verifyNip05( key, okHttpClient = { Amethyst.instance.okHttpClients.getHttpClient(false) }, onSuccess = { publicKey -> diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 006e2cf70..9c983e475 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -941,7 +941,7 @@ class AccountViewModel( val nip05 = userMetadata.nip05?.ifBlank { null } ?: return viewModelScope.launch(Dispatchers.IO) { - Nip05NostrAddressVerifier() + Nip05NostrAddressVerifier .verifyNip05( nip05, okHttpClient = httpClientBuilder::okHttpClientForNip05,