Updated on 2026-08-14

This commit is contained in:
Tangem 2021-01-21 16:32:05 +00:00
commit 4587cb4bf7
2 changed files with 20 additions and 3 deletions

View file

@ -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.128.0'
implementation 'com.tangem:blockchain:1.130.0'
implementation 'com.tangem:core:1.92.0'
implementation 'com.tangem:sdk:1.92.0'

View file

@ -110,7 +110,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) {
@ -141,7 +158,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