mirror of
https://github.com/pezkuwichain/pezkuwi-wallet-android.git
synced 2026-11-20 01:26:11 +00:00
Log Wallet Connect init failures; give empty errors a text; retranslate Kurmanji (#33)
* Log Wallet Connect init failures; give empty network errors a text - Wallet Connect core and Web3Wallet initialization errors were swallowed silently; log them. A retry is not added: initialization fails only on bad configuration, and the relay connects later on demand. - NovaException.networkError carried an empty message; it now uses the existing translated connection error text. The unused NovaException.unexpectedError is removed. - BaseException.unexpectedError fell back to an empty message when the exception had none; HttpExceptionHandler now passes the translated common error text as the fallback. - Remove the unused AccountRepository.getMyAccounts stub. * Retranslate the Kurmanji strings The values-ku file was word-by-word machine output that mixed English and Kurmanji (1709 of 2080 strings had English left in, 620 were English verbatim). Rebuild it from the English source with a fixed wallet glossary: every translatable string and plural is translated, 18 strings that were missing are added, and strings marked translatable="false" or no longer in the English source are dropped. * Skip commented-out strings in the Kurmanji file Two English strings have an older, commented-out copy; reading the comments emitted each of them twice and failed resource merging.
This commit is contained in:
1 parent
de826acc70
commit
58ef588261
8 files changed
+1951
-2625
No files matched your search
@@ -3,6 +3,7 @@ package io.novafoundation.nova.app
|
|||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
|
import android.util.Log
|
||||||
import com.walletconnect.android.Core
|
import com.walletconnect.android.Core
|
||||||
import com.walletconnect.android.CoreClient
|
import com.walletconnect.android.CoreClient
|
||||||
import com.walletconnect.android.relay.ConnectionType
|
import com.walletconnect.android.relay.ConnectionType
|
||||||
@@ -14,6 +15,7 @@ import io.novafoundation.nova.common.di.CommonApi
|
|||||||
import io.novafoundation.nova.common.di.FeatureContainer
|
import io.novafoundation.nova.common.di.FeatureContainer
|
||||||
import io.novafoundation.nova.common.resources.ContextManager
|
import io.novafoundation.nova.common.resources.ContextManager
|
||||||
import io.novafoundation.nova.common.resources.LanguagesHolder
|
import io.novafoundation.nova.common.resources.LanguagesHolder
|
||||||
|
import io.novafoundation.nova.common.utils.LOG_TAG
|
||||||
import io.novafoundation.nova.common.utils.coroutines.RootScope
|
import io.novafoundation.nova.common.utils.coroutines.RootScope
|
||||||
import io.novafoundation.nova.feature_wallet_connect_impl.BuildConfig
|
import io.novafoundation.nova.feature_wallet_connect_impl.BuildConfig
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@@ -85,13 +87,15 @@ open class App : Application(), FeatureContainer {
|
|||||||
)
|
)
|
||||||
|
|
||||||
CoreClient.initialize(relayServerUrl = serverUrl, connectionType = connectionType, application = this, metaData = appMetaData) { error ->
|
CoreClient.initialize(relayServerUrl = serverUrl, connectionType = connectionType, application = this, metaData = appMetaData) { error ->
|
||||||
// TODO maybe re-initialize client
|
// Initialization fails only on bad configuration (project id, metadata), which a retry would not fix.
|
||||||
|
// The relay itself connects later, on demand, in RealWalletConnectService
|
||||||
|
Log.e(LOG_TAG, "Failed to initialize Wallet Connect core", error.throwable)
|
||||||
}
|
}
|
||||||
|
|
||||||
val initParams = Wallet.Params.Init(core = CoreClient)
|
val initParams = Wallet.Params.Init(core = CoreClient)
|
||||||
|
|
||||||
Web3Wallet.initialize(initParams) { error ->
|
Web3Wallet.initialize(initParams) { error ->
|
||||||
// TODO maybe re-initialize client
|
Log.e(LOG_TAG, "Failed to initialize Web3Wallet", error.throwable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,8 +29,8 @@ class BaseException(
|
|||||||
return BaseException(Kind.NETWORK, message, exception)
|
return BaseException(Kind.NETWORK, message, exception)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun unexpectedError(exception: Throwable): BaseException {
|
fun unexpectedError(fallbackMessage: String, exception: Throwable): BaseException {
|
||||||
return BaseException(Kind.UNEXPECTED, exception.message ?: "", exception)
|
return BaseException(Kind.UNEXPECTED, exception.message ?: fallbackMessage, exception)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.novafoundation.nova.common.base.errors
|
package io.novafoundation.nova.common.base.errors
|
||||||
|
|
||||||
|
import io.novafoundation.nova.common.R
|
||||||
import io.novafoundation.nova.common.resources.ResourceManager
|
import io.novafoundation.nova.common.resources.ResourceManager
|
||||||
|
|
||||||
class NovaException(
|
class NovaException(
|
||||||
@@ -16,11 +17,7 @@ class NovaException(
|
|||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun networkError(resourceManager: ResourceManager, throwable: Throwable): NovaException {
|
fun networkError(resourceManager: ResourceManager, throwable: Throwable): NovaException {
|
||||||
return NovaException(Kind.NETWORK, "", throwable) // TODO: add common error text to resources
|
return NovaException(Kind.NETWORK, resourceManager.getString(R.string.connection_error_message_v2_2_0), throwable)
|
||||||
}
|
|
||||||
|
|
||||||
fun unexpectedError(exception: Throwable): NovaException {
|
|
||||||
return NovaException(Kind.UNEXPECTED, exception.message ?: "", exception) // TODO: add common error text to resources
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -28,7 +28,7 @@ class HttpExceptionHandler(
|
|||||||
BaseException.httpError(errorCode, resourceManager.getString(R.string.common_undefined_error_message))
|
BaseException.httpError(errorCode, resourceManager.getString(R.string.common_undefined_error_message))
|
||||||
}
|
}
|
||||||
is IOException -> BaseException.networkError(resourceManager.getString(R.string.connection_error_message_v2_2_0), exception)
|
is IOException -> BaseException.networkError(resourceManager.getString(R.string.connection_error_message_v2_2_0), exception)
|
||||||
else -> BaseException.unexpectedError(exception)
|
else -> BaseException.unexpectedError(resourceManager.getString(R.string.common_undefined_error_message), exception)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1894
-2603
File diff suppressed because it is too large.
Load diff
+46
@@ -0,0 +1,46 @@
|
|||||||
|
package io.novafoundation.nova.common.data.network
|
||||||
|
|
||||||
|
import io.novafoundation.nova.common.R
|
||||||
|
import io.novafoundation.nova.common.base.BaseException
|
||||||
|
import io.novafoundation.nova.common.base.errors.NovaException
|
||||||
|
import io.novafoundation.nova.common.resources.ResourceManager
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Test
|
||||||
|
import org.mockito.Mockito
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
class HttpExceptionHandlerTest {
|
||||||
|
|
||||||
|
private val resourceManager = Mockito.mock(ResourceManager::class.java).also {
|
||||||
|
Mockito.`when`(it.getString(R.string.common_undefined_error_message)).thenReturn(UNDEFINED)
|
||||||
|
Mockito.`when`(it.getString(R.string.connection_error_message_v2_2_0)).thenReturn(CONNECTION)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val handler = HttpExceptionHandler(resourceManager)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `an unexpected error without a message gets the common error text`() {
|
||||||
|
val error = handler.transformException(IllegalStateException())
|
||||||
|
|
||||||
|
assertEquals(BaseException.Kind.UNEXPECTED, error.kind)
|
||||||
|
assertEquals(UNDEFINED, error.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `an unexpected error keeps its own message`() {
|
||||||
|
assertEquals("boom", handler.transformException(IllegalStateException("boom")).message)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `a socket network error carries the connection error text`() {
|
||||||
|
val error = NovaException.networkError(resourceManager, IOException())
|
||||||
|
|
||||||
|
assertEquals(NovaException.Kind.NETWORK, error.kind)
|
||||||
|
assertEquals(CONNECTION, error.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
const val UNDEFINED = "undefined"
|
||||||
|
const val CONNECTION = "connection"
|
||||||
|
}
|
||||||
|
}
|
||||||
-2
@@ -68,8 +68,6 @@ interface AccountRepository {
|
|||||||
|
|
||||||
suspend fun getAccountOrNull(address: String): Account?
|
suspend fun getAccountOrNull(address: String): Account?
|
||||||
|
|
||||||
suspend fun getMyAccounts(query: String, chainId: String): Set<Account>
|
|
||||||
|
|
||||||
suspend fun isCodeSet(): Boolean
|
suspend fun isCodeSet(): Boolean
|
||||||
|
|
||||||
suspend fun savePinCode(code: String)
|
suspend fun savePinCode(code: String)
|
||||||
|
|||||||
-10
@@ -193,16 +193,6 @@ class AccountRepositoryImpl(
|
|||||||
return accountDao.getAccount(address)?.let { mapAccountLocalToAccount(it) }
|
return accountDao.getAccount(address)?.let { mapAccountLocalToAccount(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getMyAccounts(query: String, chainId: String): Set<Account> {
|
|
||||||
// return withContext(Dispatchers.Default) {
|
|
||||||
// accountDao.getAccounts(query, networkType)
|
|
||||||
// .map { mapAccountLocalToAccount(it) }
|
|
||||||
// .toSet()
|
|
||||||
// }
|
|
||||||
|
|
||||||
return emptySet() // TODO wallet
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun isCodeSet(): Boolean {
|
override suspend fun isCodeSet(): Boolean {
|
||||||
return accountDataSource.getPinCode() != null
|
return accountDataSource.getPinCode() != null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user