Updated on 2026-08-14
This commit is contained in:
parent
f117e5a246
commit
6a984ed75d
2 changed files with 20 additions and 9 deletions
|
|
@ -52,16 +52,17 @@ internal class DefaultQrScanningEventsRepository : QrScanningEventsRepository {
|
||||||
result.memo = URLDecoder.decode(it.value, "UTF-8")
|
result.memo = URLDecoder.decode(it.value, "UTF-8")
|
||||||
}
|
}
|
||||||
Parameter.Address -> {
|
Parameter.Address -> {
|
||||||
|
// If 'address' parameter is exists, then currency must be TOKEN.
|
||||||
|
val tokenCurrency = cryptoCurrency as? CryptoCurrency.Token ?: return QrResult()
|
||||||
|
|
||||||
// Overrides destination address for token transfers (ERC-681)
|
// Overrides destination address for token transfers (ERC-681)
|
||||||
if (cryptoCurrency is CryptoCurrency.Token) {
|
// `address` parameter is used only if the contract address, encoded in the QR,
|
||||||
// `address` parameter is used only if the contract address, encoded in the QR,
|
// matches the contract address of the token.
|
||||||
// matches the contract address of the token.
|
// Otherwise, the scanned string is likely malformed, and we stop the entire parsing routin
|
||||||
// Otherwise, the scanned string is likely malformed, and we stop the entire parsing routine
|
if (tokenCurrency.contractAddress.equals(address, ignoreCase = true)) {
|
||||||
if (cryptoCurrency.contractAddress.equals(address, ignoreCase = true)) {
|
result.address = it.value
|
||||||
result.address = it.value
|
} else {
|
||||||
} else {
|
return QrResult()
|
||||||
return QrResult()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Parameter.Value,
|
Parameter.Value,
|
||||||
|
|
|
||||||
|
|
@ -232,11 +232,21 @@ internal class DefaultQrScanningEventsRepositoryTest {
|
||||||
QrResult(address = address2, amount = BigDecimal("2300")),
|
QrResult(address = address2, amount = BigDecimal("2300")),
|
||||||
tokenCryptoCurrency,
|
tokenCryptoCurrency,
|
||||||
)
|
)
|
||||||
|
positiveCase(
|
||||||
|
"$address4?$addressParam=$addressParamValue",
|
||||||
|
QrResult(address = addressParamValue),
|
||||||
|
tokenCryptoCurrency,
|
||||||
|
)
|
||||||
negativeCase(
|
negativeCase(
|
||||||
"$address2?$someParam=$someParamValue&$amountParam=$amountParamValue",
|
"$address2?$someParam=$someParamValue&$amountParam=$amountParamValue",
|
||||||
QrResult(address = address2, amount = BigDecimal("123.123"), memo = memoParamValueUtf8),
|
QrResult(address = address2, amount = BigDecimal("123.123"), memo = memoParamValueUtf8),
|
||||||
tokenCryptoCurrency,
|
tokenCryptoCurrency,
|
||||||
)
|
)
|
||||||
|
negativeCase(
|
||||||
|
"$address4?$addressParam=$addressParamValue",
|
||||||
|
QrResult(address = addressParamValue),
|
||||||
|
cryptoCurrency,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun positiveCase(input: String, expected: QrResult, cryptoCurrency: CryptoCurrency) {
|
private fun positiveCase(input: String, expected: QrResult, cryptoCurrency: CryptoCurrency) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue