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")
|
||||
}
|
||||
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)
|
||||
if (cryptoCurrency is CryptoCurrency.Token) {
|
||||
// `address` parameter is used only if the contract address, encoded in the QR,
|
||||
// matches the contract address of the token.
|
||||
// Otherwise, the scanned string is likely malformed, and we stop the entire parsing routine
|
||||
if (cryptoCurrency.contractAddress.equals(address, ignoreCase = true)) {
|
||||
result.address = it.value
|
||||
} else {
|
||||
return QrResult()
|
||||
}
|
||||
// `address` parameter is used only if the contract address, encoded in the QR,
|
||||
// matches the contract address of the token.
|
||||
// Otherwise, the scanned string is likely malformed, and we stop the entire parsing routin
|
||||
if (tokenCurrency.contractAddress.equals(address, ignoreCase = true)) {
|
||||
result.address = it.value
|
||||
} else {
|
||||
return QrResult()
|
||||
}
|
||||
}
|
||||
Parameter.Value,
|
||||
|
|
|
|||
|
|
@ -232,11 +232,21 @@ internal class DefaultQrScanningEventsRepositoryTest {
|
|||
QrResult(address = address2, amount = BigDecimal("2300")),
|
||||
tokenCryptoCurrency,
|
||||
)
|
||||
positiveCase(
|
||||
"$address4?$addressParam=$addressParamValue",
|
||||
QrResult(address = addressParamValue),
|
||||
tokenCryptoCurrency,
|
||||
)
|
||||
negativeCase(
|
||||
"$address2?$someParam=$someParamValue&$amountParam=$amountParamValue",
|
||||
QrResult(address = address2, amount = BigDecimal("123.123"), memo = memoParamValueUtf8),
|
||||
tokenCryptoCurrency,
|
||||
)
|
||||
negativeCase(
|
||||
"$address4?$addressParam=$addressParamValue",
|
||||
QrResult(address = addressParamValue),
|
||||
cryptoCurrency,
|
||||
)
|
||||
}
|
||||
|
||||
private fun positiveCase(input: String, expected: QrResult, cryptoCurrency: CryptoCurrency) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue