Zip321 scan error handling
This commit is contained in:
parent
c134bc986f
commit
5c9854dc00
|
@ -2,6 +2,7 @@ package co.electriccoin.zcash.ui.common.usecase
|
|||
|
||||
import co.electriccoin.zcash.ui.NavigationRouter
|
||||
import co.electriccoin.zcash.ui.common.datasource.AccountDataSource
|
||||
import co.electriccoin.zcash.ui.common.datasource.TransactionProposalNotCreatedException
|
||||
import co.electriccoin.zcash.ui.common.model.KeystoneAccount
|
||||
import co.electriccoin.zcash.ui.common.model.ZashiAccount
|
||||
import co.electriccoin.zcash.ui.common.repository.KeystoneProposalRepository
|
||||
|
@ -77,6 +78,11 @@ class OnZip321ScannedUseCase(
|
|||
)
|
||||
)
|
||||
navigationRouter.replace(Send(), ReviewTransaction)
|
||||
} catch (e: TransactionProposalNotCreatedException) {
|
||||
prefillSend.requestFromZip321(zip321.payment)
|
||||
navigationRouter.replace(Send())
|
||||
zashiProposalRepository.clear()
|
||||
keystoneProposalRepository.clear()
|
||||
} catch (e: Exception) {
|
||||
navigateToErrorUseCase(ErrorArgs.General(e))
|
||||
zashiProposalRepository.clear()
|
||||
|
@ -113,6 +119,11 @@ class OnZip321ScannedUseCase(
|
|||
)
|
||||
)
|
||||
navigationRouter.forward(ReviewTransaction)
|
||||
} catch (e: TransactionProposalNotCreatedException) {
|
||||
prefillSend.requestFromZip321(zip321.payment)
|
||||
navigationRouter.back()
|
||||
zashiProposalRepository.clear()
|
||||
keystoneProposalRepository.clear()
|
||||
} catch (e: Exception) {
|
||||
navigateToErrorUseCase(ErrorArgs.General(e))
|
||||
zashiProposalRepository.clear()
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package co.electriccoin.zcash.ui.common.usecase
|
||||
|
||||
import PaymentRequest
|
||||
import cash.z.ecc.android.sdk.ext.convertZecToZatoshi
|
||||
import cash.z.ecc.android.sdk.model.Zatoshi
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -15,7 +17,7 @@ class PrefillSendUseCase {
|
|||
|
||||
operator fun invoke() = bus.receiveAsFlow()
|
||||
|
||||
fun request(value: DetailedTransactionData) =
|
||||
fun requestFromTransactionDetail(value: DetailedTransactionData) =
|
||||
scope.launch {
|
||||
bus.send(
|
||||
PrefillSendData.All(
|
||||
|
@ -27,10 +29,20 @@ class PrefillSendUseCase {
|
|||
)
|
||||
}
|
||||
|
||||
fun request(value: PrefillSendData) =
|
||||
fun requestFromZip321(value: PaymentRequest) =
|
||||
scope.launch {
|
||||
bus.send(value)
|
||||
val request = value.payments.firstOrNull()
|
||||
bus.send(
|
||||
PrefillSendData.All(
|
||||
amount = request?.nonNegativeAmount?.value?.convertZecToZatoshi() ?: Zatoshi(0),
|
||||
address = request?.recipientAddress?.value,
|
||||
fee = null,
|
||||
memos = request?.message?.let { listOf(it) }
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun request(value: PrefillSendData) = scope.launch { bus.send(value) }
|
||||
}
|
||||
|
||||
sealed interface PrefillSendData {
|
||||
|
|
|
@ -8,7 +8,7 @@ class SendTransactionAgainUseCase(
|
|||
private val navigationRouter: NavigationRouter
|
||||
) {
|
||||
operator fun invoke(value: DetailedTransactionData) {
|
||||
prefillSendUseCase.request(value)
|
||||
prefillSendUseCase.requestFromTransactionDetail(value)
|
||||
navigationRouter.forward(
|
||||
Send(
|
||||
isScanZip321Enabled = false
|
||||
|
|
Loading…
Reference in New Issue