From 992e3cecd1afe80a8064c39e15ecc06766389726 Mon Sep 17 00:00:00 2001 From: Benjamin Schulte Date: Wed, 7 Jun 2023 16:20:10 +0200 Subject: [PATCH] Hint message when ergoauth request scanned from send funds --- android/src/main/res/values/strings.xml | 2 ++ .../org/ergoplatform/uilogic/StringResources.kt | 1 + .../uilogic/transactions/SendFundsUiLogic.kt | 13 ++++++++----- ios/resources/i18n/strings.properties | 2 ++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/android/src/main/res/values/strings.xml b/android/src/main/res/values/strings.xml index 4dcf60ab..45843dd2 100644 --- a/android/src/main/res/values/strings.xml +++ b/android/src/main/res/values/strings.xml @@ -67,6 +67,8 @@ You scanned a signing request, but the wallet is set up as read only. Please restore with your mnemonic. The scanned QR code was not of a known format. + It looks like you scanned an auth request, but this is for sending funds. + Please scan auth requests from the main screen or wallet details screen. Add wallet diff --git a/common-jvm/src/main/java/org/ergoplatform/uilogic/StringResources.kt b/common-jvm/src/main/java/org/ergoplatform/uilogic/StringResources.kt index 45cd612f..b49ccf75 100644 --- a/common-jvm/src/main/java/org/ergoplatform/uilogic/StringResources.kt +++ b/common-jvm/src/main/java/org/ergoplatform/uilogic/StringResources.kt @@ -215,6 +215,7 @@ const val STRING_GENERIC_ERROR_USER_CANCELED = "generic_error_user_canceled" const val STRING_HIDE_BOTTOM_VIEW_ON_SCROLL_BEHAVIOR = "hide_bottom_view_on_scroll_behavior" const val STRING_HINT_AMOUNT_CURRENCY = "hint_amount_currency" const val STRING_HINT_APP_URL = "hint_app_url" +const val STRING_HINT_AUTH_REQUEST = "hint_auth_request" const val STRING_HINT_DESKTOP_KYA = "hint_desktop_kya" const val STRING_HINT_NO_WEBCAM = "hint_no_webcam" const val STRING_HINT_PASSWORD = "hint_password" diff --git a/common-jvm/src/main/java/org/ergoplatform/uilogic/transactions/SendFundsUiLogic.kt b/common-jvm/src/main/java/org/ergoplatform/uilogic/transactions/SendFundsUiLogic.kt index 180d93bf..89725cb9 100644 --- a/common-jvm/src/main/java/org/ergoplatform/uilogic/transactions/SendFundsUiLogic.kt +++ b/common-jvm/src/main/java/org/ergoplatform/uilogic/transactions/SendFundsUiLogic.kt @@ -8,6 +8,7 @@ import org.ergoplatform.* import org.ergoplatform.appkit.Address import org.ergoplatform.appkit.ErgoToken import org.ergoplatform.appkit.Parameters +import org.ergoplatform.ergoauth.isErgoAuthRequestUri import org.ergoplatform.persistance.IAppDatabase import org.ergoplatform.persistance.PreferencesProvider import org.ergoplatform.persistance.TokenInformation @@ -514,18 +515,20 @@ abstract class SendFundsUiLogic : SubmitTransactionUiLogic(), FilterTokenListUiL ) } else { val content = parsePaymentRequest(qrCodeData) - content?.let { + if (content != null) { setPaymentRequestDataToUi.invoke( content.address, content.amount.let { amount -> if (amount.nanoErgs > 0) amount else null }, if (content.description.isNotBlank()) content.description else null ) addTokensFromPaymentRequest(content.tokens) - } ?: showErrorMessage( - stringProvider.getString( - STRING_ERROR_QR_CODE_CONTENT_UNKNOWN + } else if (isErgoAuthRequestChunk(qrCodeData) || isErgoAuthRequestUri(qrCodeData)) { + showErrorMessage(stringProvider.getString(STRING_HINT_AUTH_REQUEST)) + } else { + showErrorMessage( + stringProvider.getString(STRING_ERROR_QR_CODE_CONTENT_UNKNOWN) ) - ) + } } } diff --git a/ios/resources/i18n/strings.properties b/ios/resources/i18n/strings.properties index 8a76a9d8..5b900db8 100644 --- a/ios/resources/i18n/strings.properties +++ b/ios/resources/i18n/strings.properties @@ -242,6 +242,8 @@ generic_error_user_canceled=Authentication canceled by user. hide_bottom_view_on_scroll_behavior=com.google.android.material.behavior.HideBottomViewOnScrollBehavior hint_amount_currency=Amount ({0}) hint_app_url=App URL +hint_auth_request=It looks like you scanned an auth request, but this is for sending funds. \ +Please scan auth requests from the main screen or wallet details screen. hint_desktop_kya=Please read and understand our KYA \ regarding storing your secrets. For best security, use a cold wallet. \