diff --git a/CHANGELOG.md b/CHANGELOG.md index fb50ab0d..80d20f3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ directly impact users rather than highlighting other key architectural updates.* ### Changed - The color palette used across the app has been reworked to align with the updated design document +### Fixed +- An updated snapshot Zcash SDK version has been adopted to improve unstable lightwalletd communication +- Transaction submission has been slightly refactored to improve its stability + ## [1.1 (655)] - 2024-05-24 ### Added diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/WalletViewModel.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/WalletViewModel.kt index cb6649ed..1120b6a5 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/WalletViewModel.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/WalletViewModel.kt @@ -201,7 +201,11 @@ class WalletViewModel(application: Application) : AndroidViewModel(application) synchronizer .filterNotNull() .map { - WalletAddresses.new(it) + runCatching { + WalletAddresses.new(it) + }.onFailure { + Twig.warn { "Wait until the SDK starts providing the addresses" } + }.getOrNull() }.stateIn( viewModelScope, SharingStarted.WhileSubscribed(ANDROID_STATE_FLOW_TIMEOUT), diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/balances/AndroidBalances.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/balances/AndroidBalances.kt index fba38500..82574ba0 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/balances/AndroidBalances.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/balances/AndroidBalances.kt @@ -4,7 +4,6 @@ package co.electriccoin.zcash.ui.screen.balances import android.content.Context import android.widget.Toast -import androidx.activity.ComponentActivity import androidx.activity.viewModels import androidx.compose.material3.SnackbarHostState import androidx.compose.runtime.Composable @@ -14,11 +13,13 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.platform.LocalContext import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.lifecycleScope import cash.z.ecc.android.sdk.SdkSynchronizer import cash.z.ecc.android.sdk.Synchronizer import cash.z.ecc.android.sdk.model.UnifiedSpendingKey import cash.z.ecc.android.sdk.model.Zatoshi import co.electriccoin.zcash.spackle.Twig +import co.electriccoin.zcash.ui.MainActivity import co.electriccoin.zcash.ui.R import co.electriccoin.zcash.ui.common.compose.BalanceState import co.electriccoin.zcash.ui.common.model.WalletRestoringState @@ -43,7 +44,7 @@ import org.jetbrains.annotations.VisibleForTesting @Composable internal fun WrapBalances( - activity: ComponentActivity, + activity: MainActivity, goSettings: () -> Unit, goMultiTrxSubmissionFailure: () -> Unit, ) { @@ -74,6 +75,7 @@ internal fun WrapBalances( checkUpdateViewModel = checkUpdateViewModel, goSettings = goSettings, goMultiTrxSubmissionFailure = goMultiTrxSubmissionFailure, + lifecycleScope = activity.lifecycleScope, spendingKey = spendingKey, synchronizer = synchronizer, walletSnapshot = walletSnapshot, @@ -93,6 +95,7 @@ internal fun WrapBalances( createTransactionsViewModel: CreateTransactionsViewModel, goSettings: () -> Unit, goMultiTrxSubmissionFailure: () -> Unit, + lifecycleScope: CoroutineScope, spendingKey: UnifiedSpendingKey?, synchronizer: Synchronizer?, walletSnapshot: WalletSnapshot?, @@ -157,7 +160,7 @@ internal fun WrapBalances( hideStatusDialog = { showStatusDialog.value = null }, snackbarHostState = snackbarHostState, onShielding = { - scope.launch { + lifecycleScope.launch { setShieldState(ShieldState.Running) Twig.debug { "Shielding transparent funds" } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/home/AndroidHome.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/home/AndroidHome.kt index e5d17def..fe572e24 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/home/AndroidHome.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/home/AndroidHome.kt @@ -2,7 +2,6 @@ package co.electriccoin.zcash.ui.screen.home -import androidx.activity.ComponentActivity import androidx.activity.compose.BackHandler import androidx.activity.viewModels import androidx.compose.runtime.Composable @@ -104,7 +103,7 @@ internal fun MainActivity.WrapHome( @Suppress("LongParameterList", "LongMethod") @Composable internal fun WrapHome( - activity: ComponentActivity, + activity: MainActivity, goBack: () -> Unit, goSettings: () -> Unit, goMultiTrxSubmissionFailure: () -> Unit, diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/sendconfirmation/AndroidSendConfirmation.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/sendconfirmation/AndroidSendConfirmation.kt index 11e93b3f..e3546a97 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/sendconfirmation/AndroidSendConfirmation.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/sendconfirmation/AndroidSendConfirmation.kt @@ -16,6 +16,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.rememberSaveable import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.lifecycleScope import cash.z.ecc.android.sdk.SdkSynchronizer import cash.z.ecc.android.sdk.Synchronizer import cash.z.ecc.android.sdk.model.Proposal @@ -44,6 +45,7 @@ import co.electriccoin.zcash.ui.screen.support.viewmodel.SupportViewModel import co.electriccoin.zcash.ui.util.EmailUtil import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.toImmutableList +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.launch @@ -76,10 +78,11 @@ internal fun MainActivity.WrapSendConfirmation( activity = this, arguments = arguments, authenticationViewModel = authenticationViewModel, + createTransactionsViewModel = createTransactionsViewModel, goBack = goBack, goHome = goHome, goSupport = goSupport, - createTransactionsViewModel = createTransactionsViewModel, + lifecycleScope = this.lifecycleScope, spendingKey = spendingKey, supportMessage = supportMessage, synchronizer = synchronizer, @@ -94,10 +97,11 @@ internal fun WrapSendConfirmation( activity: MainActivity, arguments: SendConfirmationArguments, authenticationViewModel: AuthenticationViewModel, + createTransactionsViewModel: CreateTransactionsViewModel, goBack: (clearForm: Boolean) -> Unit, goHome: () -> Unit, goSupport: () -> Unit, - createTransactionsViewModel: CreateTransactionsViewModel, + lifecycleScope: CoroutineScope, spendingKey: UnifiedSpendingKey?, supportMessage: SupportInfo?, synchronizer: Synchronizer?, @@ -179,7 +183,7 @@ internal fun WrapSendConfirmation( }, onConfirmation = { // Check and trigger authentication if required, or just submit transactions otherwise - scope.launch { + lifecycleScope.launch { authenticationViewModel.isSendFundsAuthenticationRequired .filterNotNull() .collect { isProtected -> @@ -211,7 +215,7 @@ internal fun WrapSendConfirmation( goSupport() }, onSuccess = { - scope.launch { + lifecycleScope.launch { runSendFundsAction( createTransactionsViewModel = createTransactionsViewModel, goHome = goHome,