Updated on 2026-08-14
This commit is contained in:
parent
1d1c641e6b
commit
6f34188038
3 changed files with 16 additions and 16 deletions
|
|
@ -50,7 +50,7 @@ internal class AddressPayIdHandler {
|
|||
verifyPayId(data, walletManager)
|
||||
} else {
|
||||
val supposedAddress = extractAddressFromShareUri(data)
|
||||
store.dispatch(PayIdVerification.Failed(supposedAddress, FailReason.IS_NOT_PAY_ID))
|
||||
store.dispatch(PayIdVerification.SetError(supposedAddress, FailReason.IS_NOT_PAY_ID))
|
||||
verifyAddress(walletManager, supposedAddress)
|
||||
}
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ internal class AddressPayIdHandler {
|
|||
private fun verifyPayId(payId: String, walletManager: WalletManager) {
|
||||
val blockchain = walletManager.wallet.blockchain
|
||||
if (!blockchain.isPayIdSupported()) {
|
||||
store.dispatch(PayIdVerification.Failed(payId, FailReason.PAY_ID_UNSUPPORTED_BY_BLOCKCHAIN))
|
||||
store.dispatch(PayIdVerification.SetError(payId, FailReason.PAY_ID_UNSUPPORTED_BY_BLOCKCHAIN))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -69,17 +69,17 @@ internal class AddressPayIdHandler {
|
|||
is Result.Success -> {
|
||||
val address = result.data.getAddress()
|
||||
if (address == null) {
|
||||
store.dispatch(PayIdVerification.Failed(payId, FailReason.PAY_ID_NOT_REGISTERED))
|
||||
store.dispatch(PayIdVerification.SetError(payId, FailReason.PAY_ID_NOT_REGISTERED))
|
||||
return@withContext
|
||||
}
|
||||
val failReason = isValidBlockchainAddressAndNotTheSameAsWallet(walletManager.wallet, address)
|
||||
|
||||
val actionToSend = if (failReason == FailReason.NONE) PayIdVerification.Success(payId, address)
|
||||
else AddressVerification.Failed(payId, failReason)
|
||||
val actionToSend = if (failReason == FailReason.NONE) PayIdVerification.SetPayIdWalletAddress(payId, address)
|
||||
else AddressVerification.SetError(payId, failReason)
|
||||
store.dispatch(actionToSend)
|
||||
}
|
||||
is Result.Failure -> {
|
||||
store.dispatch(PayIdVerification.Failed(payId, FailReason.PAY_ID_REQUEST_FAILED))
|
||||
store.dispatch(PayIdVerification.SetError(payId, FailReason.PAY_ID_REQUEST_FAILED))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -89,8 +89,8 @@ internal class AddressPayIdHandler {
|
|||
|
||||
private fun verifyAddress(walletManager: WalletManager, supposedAddress: String) {
|
||||
val failReason = isValidBlockchainAddressAndNotTheSameAsWallet(walletManager.wallet, supposedAddress)
|
||||
val actionToSend = if (failReason == FailReason.NONE) AddressVerification.Success(supposedAddress)
|
||||
else AddressVerification.Failed(supposedAddress, failReason)
|
||||
val actionToSend = if (failReason == FailReason.NONE) AddressVerification.SetWalletAddress(supposedAddress)
|
||||
else AddressVerification.SetError(supposedAddress, failReason)
|
||||
|
||||
store.dispatch(actionToSend)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,10 +57,10 @@ private fun handleAddressPayIdAction(
|
|||
state: AddressPayIDState
|
||||
): SendState {
|
||||
val result = when (action) {
|
||||
is PayIdVerification.Success -> state.copyPayIdWalletAddress(action.payId, action.payIdWalletAddress)
|
||||
is PayIdVerification.Failed -> state.copyPaiIdError(action.payId, action.reason)
|
||||
is AddressVerification.Success -> state.copyWalletAddress(action.address)
|
||||
is AddressVerification.Failed -> state.copyError(action.address, action.reason)
|
||||
is PayIdVerification.SetPayIdWalletAddress -> state.copyPayIdWalletAddress(action.payId, action.payIdWalletAddress)
|
||||
is PayIdVerification.SetError -> state.copyPaiIdError(action.payId, action.reason)
|
||||
is AddressVerification.SetWalletAddress -> state.copyWalletAddress(action.address)
|
||||
is AddressVerification.SetError -> state.copyError(action.address, action.reason)
|
||||
}
|
||||
return updateLastState(sendState.copy(addressPayIDState = result), result)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@ sealed class AddressPayIdVerifyAction : SendScreenAction {
|
|||
}
|
||||
|
||||
sealed class PayIdVerification : AddressPayIdVerifyAction() {
|
||||
data class Failed(val payId: String, val reason: FailReason) : PayIdVerification()
|
||||
data class Success(val payId: String, val payIdWalletAddress: String) : PayIdVerification()
|
||||
data class SetError(val payId: String, val reason: FailReason) : PayIdVerification()
|
||||
data class SetPayIdWalletAddress(val payId: String, val payIdWalletAddress: String) : PayIdVerification()
|
||||
}
|
||||
|
||||
sealed class AddressVerification : AddressPayIdVerifyAction() {
|
||||
data class Failed(val address: String, val reason: FailReason) : AddressVerification()
|
||||
data class Success(val address: String) : AddressVerification()
|
||||
data class SetError(val address: String, val reason: FailReason) : AddressVerification()
|
||||
data class SetWalletAddress(val address: String) : AddressVerification()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue