From c6e013bdd7a0cd099678c7c602dd2cb7d817f54b Mon Sep 17 00:00:00 2001 From: micbakos-rdx Date: Fri, 20 Dec 2024 19:34:06 +0200 Subject: [PATCH 1/3] Fix error being returned to dApp --- .../babylon/wallet/android/domain/RadixWalletException.kt | 8 ++++---- .../transaction/TransactionReviewViewModel.kt | 4 ++-- .../transaction/analysis/TransactionAnalysisDelegate.kt | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/babylon/wallet/android/domain/RadixWalletException.kt b/app/src/main/java/com/babylon/wallet/android/domain/RadixWalletException.kt index 87c1aa472f..8cf4d60125 100644 --- a/app/src/main/java/com/babylon/wallet/android/domain/RadixWalletException.kt +++ b/app/src/main/java/com/babylon/wallet/android/domain/RadixWalletException.kt @@ -43,7 +43,7 @@ sealed class RadixWalletException(cause: Throwable? = null) : Throwable(cause = data object GetEpoch : DappRequestException() data object RejectedByUser : DappRequestException() data object InvalidRequest : DappRequestException() - data object UnacceptableManifest : DappRequestException() + data class UnacceptableManifest(override val cause: Throwable) : DappRequestException(cause = cause) data object InvalidPersona : DappRequestException() data object InvalidPersonaOrAccounts : DappRequestException() data object InvalidRequestChallenge : DappRequestException() @@ -74,7 +74,7 @@ sealed class RadixWalletException(cause: Throwable? = null) : Throwable(cause = InvalidRequestChallenge -> DappWalletInteractionErrorType.FAILED_TO_SIGN_AUTH_CHALLENGE NotPossibleToAuthenticateAutomatically -> DappWalletInteractionErrorType.INVALID_REQUEST RejectedByUser -> DappWalletInteractionErrorType.REJECTED_BY_USER - UnacceptableManifest -> DappWalletInteractionErrorType.INVALID_REQUEST + is UnacceptableManifest -> DappWalletInteractionErrorType.INVALID_REQUEST is WrongNetwork -> DappWalletInteractionErrorType.WRONG_NETWORK is PreviewError -> DappWalletInteractionErrorType.FAILED_TO_PREPARE_TRANSACTION InvalidPersonaOrAccounts -> DappWalletInteractionErrorType.INVALID_PERSONA_OR_ACCOUNTS @@ -292,7 +292,7 @@ fun RadixWalletException.DappRequestException.toUserFriendlyMessage(context: Con R.string.dAppRequest_validationOutcome_invalidRequestMessage ) - RadixWalletException.DappRequestException.UnacceptableManifest -> context.getString( + is RadixWalletException.DappRequestException.UnacceptableManifest -> context.getString( R.string.transactionReview_unacceptableManifest_rejected ) @@ -471,7 +471,7 @@ fun Throwable.getDappMessage(): String? { "Wallet is using network ID: $currentNetworkId, request sent specified network ID: $requestNetworkId" } - else -> message + else -> message ?: cause?.message } } diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/transaction/TransactionReviewViewModel.kt b/app/src/main/java/com/babylon/wallet/android/presentation/transaction/TransactionReviewViewModel.kt index c5b8743720..849dfe79c7 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/transaction/TransactionReviewViewModel.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/transaction/TransactionReviewViewModel.kt @@ -268,8 +268,6 @@ class TransactionReviewViewModel @Inject constructor( } fun dismissTerminalErrorDialog() { - _state.update { it.copy(error = null) } - viewModelScope.launch { val error = state.value.error?.error if (error is DappRequestException) { @@ -279,6 +277,8 @@ class TransactionReviewViewModel @Inject constructor( sendEvent(Event.Dismiss) } } + + _state.update { it.copy(error = null) } } fun onAcknowledgeRawTransactionWarning() { diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/transaction/analysis/TransactionAnalysisDelegate.kt b/app/src/main/java/com/babylon/wallet/android/presentation/transaction/analysis/TransactionAnalysisDelegate.kt index 856a19965f..a0f6956607 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/transaction/analysis/TransactionAnalysisDelegate.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/transaction/analysis/TransactionAnalysisDelegate.kt @@ -144,7 +144,7 @@ class TransactionAnalysisDelegate @Inject constructor( private fun mapPreviewError(error: Throwable): RadixWalletException { return when (error) { is CommonException.ReservedInstructionsNotAllowedInManifest -> { - RadixWalletException.DappRequestException.UnacceptableManifest + RadixWalletException.DappRequestException.UnacceptableManifest(cause = error) } is CommonException.OneOfReceivingAccountsDoesNotAllowDeposits -> { RadixWalletException.PrepareTransactionException.ReceivingAccountDoesNotAllowDeposits From 24ef9409580b3b1a3ed53095c3e5b4fa18085697 Mon Sep 17 00:00:00 2001 From: micbakos-rdx Date: Fri, 20 Dec 2024 19:53:12 +0200 Subject: [PATCH 2/3] Fix guaranteed amount --- .../transaction/submit/TransactionSubmitDelegate.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/transaction/submit/TransactionSubmitDelegate.kt b/app/src/main/java/com/babylon/wallet/android/presentation/transaction/submit/TransactionSubmitDelegate.kt index 25a61cd6f6..1fafb41e9d 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/transaction/submit/TransactionSubmitDelegate.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/transaction/submit/TransactionSubmitDelegate.kt @@ -326,7 +326,7 @@ class TransactionSubmitDelegateImpl @Inject constructor( val fungibleAsset = (transferable.asset as? Asset.Fungible) ?: return@mapNotNull null TransactionGuarantee( - amount = amount.estimated, + amount = amount.guaranteed, instructionIndex = amount.instructionIndex.toULong(), resourceAddress = fungibleAsset.resource.address, resourceDivisibility = fungibleAsset.resource.divisibility?.value, From 621c4f02375c00762d348b3d19d386d9d9920bbe Mon Sep 17 00:00:00 2001 From: "giannis.tsepas" Date: Fri, 20 Dec 2024 20:59:47 +0200 Subject: [PATCH 3/3] null error in viewmodelscope --- .../presentation/transaction/TransactionReviewViewModel.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/transaction/TransactionReviewViewModel.kt b/app/src/main/java/com/babylon/wallet/android/presentation/transaction/TransactionReviewViewModel.kt index 849dfe79c7..3f07bd1efc 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/transaction/TransactionReviewViewModel.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/transaction/TransactionReviewViewModel.kt @@ -276,9 +276,8 @@ class TransactionReviewViewModel @Inject constructor( incomingRequestRepository.requestHandled(args.interactionId) sendEvent(Event.Dismiss) } + _state.update { it.copy(error = null) } } - - _state.update { it.copy(error = null) } } fun onAcknowledgeRawTransactionWarning() {