From a708c91a86f4f82da42a5726d1c04f6d971f2113 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 20 Jan 2021 22:04:44 +0300 Subject: [PATCH] Updated on 2026-08-14 --- app/build.gradle | 2 +- .../middlewares/AddressPayIdMiddleware.kt | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e35b177dba..1d97ac961f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -71,7 +71,7 @@ dependencies { implementation 'com.google.android.material:material:1.2.1' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1' - implementation 'com.tangem:blockchain:1.123.0' + implementation 'com.tangem:blockchain:1.130.0' implementation 'com.tangem:core:1.90.0' implementation 'com.tangem:sdk:1.90.0' diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt index 4380bdbf49..4318957996 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt @@ -105,7 +105,24 @@ internal class AddressPayIdMiddleware { } private fun verifyAddress(address: String, wallet: Wallet, isUserInput: Boolean, dispatch: (Action) -> Unit) { - val supposedAddress = extractAddressFromShareUri(address).removeNonAddressData() + val addressSchemeSplit = address.split(":") + val noSchemeAddress = when (addressSchemeSplit.size) { + 1 -> address // no scheme + 2 -> { // scheme + if (wallet.blockchain.validateShareScheme(addressSchemeSplit[0])) { + addressSchemeSplit[1] + } else { + dispatch(SetAddressError(Error.ADDRESS_INVALID_OR_UNSUPPORTED_BY_BLOCKCHAIN)) + return + } + } + else -> { // invalid URI + dispatch(SetAddressError(Error.ADDRESS_INVALID_OR_UNSUPPORTED_BY_BLOCKCHAIN)) + return + } + } + + val supposedAddress = noSchemeAddress.removeShareUriQuery() //TODO: parse query? val failReason = isValidBlockchainAddressAndNotTheSameAsWallet(wallet, supposedAddress) if (failReason == null) { @@ -134,7 +151,7 @@ internal class AddressPayIdMiddleware { return if (prefixes.isEmpty()) shareUri else shareUri.replace(prefixes[0], "") } - private fun String.removeNonAddressData(): String = this.substringBefore("?") + private fun String.removeShareUriQuery(): String = this.substringBefore("?") private fun verifyClipboard(input: String?, appState: AppState?, dispatch: DispatchFunction) { val addressPayId = input ?: return