Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes on responding to dApp and assertions #1290

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
)

Expand Down Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some errors carry a cause from the CommonException coming from sargon. This message can be passed back to the CE logs.

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,6 @@ class TransactionReviewViewModel @Inject constructor(
}

fun dismissTerminalErrorDialog() {
_state.update { it.copy(error = null) }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error was consumed here, before having the chance to be sent to dApp.


viewModelScope.launch {
val error = state.value.error?.error
if (error is DappRequestException) {
Expand All @@ -278,6 +276,7 @@ class TransactionReviewViewModel @Inject constructor(
incomingRequestRepository.requestHandled(args.interactionId)
sendEvent(Event.Dismiss)
}
_state.update { it.copy(error = null) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The amount in the builder is for guaranteed amounts and not for predicted.

instructionIndex = amount.instructionIndex.toULong(),
resourceAddress = fungibleAsset.resource.address,
resourceDivisibility = fungibleAsset.resource.divisibility?.value,
Expand Down
Loading