Updated on 2026-08-14
This commit is contained in:
parent
e6fcb9e2fe
commit
40c37826bf
198 changed files with 791 additions and 704 deletions
|
|
@ -6,12 +6,17 @@ import com.tangem.common.services.Result
|
|||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.domain.PayIdManager
|
||||
import com.tangem.tap.domain.isPayIdSupported
|
||||
import com.tangem.tap.features.send.redux.*
|
||||
import com.tangem.tap.features.send.redux.AddressPayIdActionUi
|
||||
import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction
|
||||
import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction.AddressVerification.SetAddressError
|
||||
import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction.AddressVerification.SetWalletAddress
|
||||
import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction.Error
|
||||
import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction.PayIdVerification.SetPayIdError
|
||||
import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction.PayIdVerification.SetPayIdWalletAddress
|
||||
import com.tangem.tap.features.send.redux.AmountAction
|
||||
import com.tangem.tap.features.send.redux.AmountActionUi
|
||||
import com.tangem.tap.features.send.redux.FeeAction
|
||||
import com.tangem.tap.features.send.redux.TransactionExtrasAction
|
||||
import com.tangem.tap.scope
|
||||
import com.tangem.tap.store
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
|
@ -129,7 +134,7 @@ internal class AddressPayIdMiddleware {
|
|||
}
|
||||
}
|
||||
|
||||
val supposedAddress = noSchemeAddress.removeShareUriQuery() //TODO: parse query?
|
||||
val supposedAddress = noSchemeAddress.removeShareUriQuery() // TODO: parse query?
|
||||
|
||||
val failReason = isValidBlockchainAddressAndNotTheSameAsWallet(wallet, supposedAddress)
|
||||
if (failReason == null) {
|
||||
|
|
@ -167,7 +172,6 @@ internal class AddressPayIdMiddleware {
|
|||
val addressPayId = input ?: return
|
||||
val wallet = appState?.sendState?.walletManager?.wallet ?: return
|
||||
|
||||
|
||||
val internalDispatcher: (Action) -> Unit = {
|
||||
when (it) {
|
||||
is SetWalletAddress, is SetPayIdWalletAddress -> {
|
||||
|
|
@ -193,7 +197,7 @@ internal class AddressPayIdMiddleware {
|
|||
|
||||
fun String.splitToMap(firstDelimiter: String, secondDelimiter: String): Map<String, String> {
|
||||
return this.split(firstDelimiter)
|
||||
.map { it.split(secondDelimiter) }
|
||||
.map { it.first() to it.last().toString() }
|
||||
.toMap()
|
||||
.map { it.split(secondDelimiter) }
|
||||
.map { it.first() to it.last().toString() }
|
||||
.toMap()
|
||||
}
|
||||
|
|
@ -83,7 +83,8 @@ class SendMiddleware {
|
|||
if (transactionData != null) {
|
||||
store.dispatchOnMain(
|
||||
AddressPayIdVerifyAction.AddressVerification.SetWalletAddress(
|
||||
transactionData.destinationAddress, false,
|
||||
address = transactionData.destinationAddress,
|
||||
isUserInput = false,
|
||||
),
|
||||
)
|
||||
store.dispatchOnMain(AmountActionUi.SetMainCurrency(MainCurrencyType.CRYPTO))
|
||||
|
|
@ -104,7 +105,9 @@ class SendMiddleware {
|
|||
}
|
||||
|
||||
private fun verifyAndSendTransaction(
|
||||
action: SendActionUi.SendAmountToRecipient, appState: AppState?, dispatch: (Action) -> Unit,
|
||||
action: SendActionUi.SendAmountToRecipient,
|
||||
appState: AppState?,
|
||||
dispatch: (Action) -> Unit,
|
||||
) {
|
||||
val sendState = appState?.sendState ?: return
|
||||
val walletManager = sendState.walletManager ?: return
|
||||
|
|
|
|||
|
|
@ -37,21 +37,21 @@ class AmountReducer : SendInternalReducer {
|
|||
val rescaledBalance = sendState.convertExtractCryptoToFiat(state.balanceCrypto, true)
|
||||
val viewValue = state.restoreDecimalSeparator(fiatToSend.stripZeroPlainString())
|
||||
state.copy(
|
||||
viewAmountValue = InputViewValue(viewValue),
|
||||
viewBalanceValue = rescaledBalance.stripZeroPlainString(),
|
||||
mainCurrency = state.createMainCurrency(currency, currencyCanBeSwitched),
|
||||
maxLengthOfAmount = sendState.getDecimals(currency),
|
||||
cursorAtTheSamePosition = false
|
||||
viewAmountValue = InputViewValue(viewValue),
|
||||
viewBalanceValue = rescaledBalance.stripZeroPlainString(),
|
||||
mainCurrency = state.createMainCurrency(currency, currencyCanBeSwitched),
|
||||
maxLengthOfAmount = sendState.getDecimals(currency),
|
||||
cursorAtTheSamePosition = false
|
||||
)
|
||||
}
|
||||
MainCurrencyType.CRYPTO -> {
|
||||
val viewValue = state.restoreDecimalSeparator(state.amountToSendCrypto.stripZeroPlainString())
|
||||
state.copy(
|
||||
viewAmountValue = InputViewValue(viewValue),
|
||||
viewBalanceValue = state.balanceCrypto.stripZeroPlainString(),
|
||||
mainCurrency = state.createMainCurrency(currency, currencyCanBeSwitched),
|
||||
maxLengthOfAmount = sendState.getDecimals(currency),
|
||||
cursorAtTheSamePosition = false
|
||||
viewAmountValue = InputViewValue(viewValue),
|
||||
viewBalanceValue = state.balanceCrypto.stripZeroPlainString(),
|
||||
mainCurrency = state.createMainCurrency(currency, currencyCanBeSwitched),
|
||||
maxLengthOfAmount = sendState.getDecimals(currency),
|
||||
cursorAtTheSamePosition = false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -72,10 +72,10 @@ class AmountReducer : SendInternalReducer {
|
|||
}
|
||||
val viewValue = state.restoreDecimalSeparator(amount.stripZeroPlainString())
|
||||
state.copy(
|
||||
viewAmountValue = InputViewValue(viewValue, action.isUserInput),
|
||||
amountToSendCrypto = action.amountCrypto,
|
||||
cursorAtTheSamePosition = true,
|
||||
error = null
|
||||
viewAmountValue = InputViewValue(viewValue, action.isUserInput),
|
||||
amountToSendCrypto = action.amountCrypto,
|
||||
cursorAtTheSamePosition = true,
|
||||
error = null
|
||||
)
|
||||
}
|
||||
is AmountAction.SetAmountError -> state.copy(error = action.error)
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ private class SendReducer : SendInternalReducer {
|
|||
}
|
||||
|
||||
private fun handleSendSpecificTransactionAction(
|
||||
action: SendAction.SendSpecificTransaction, state: SendState,
|
||||
action: SendAction.SendSpecificTransaction,
|
||||
state: SendState,
|
||||
): SendState {
|
||||
return state.copy(
|
||||
externalTransactionData =
|
||||
|
|
@ -116,4 +117,4 @@ private class PrepareSendScreenStatesReducer : SendInternalReducer {
|
|||
internal fun updateLastState(sendState: SendState, lastChangedState: IdStateHolder): SendState {
|
||||
sendState.lastChangedStates.add(lastChangedState.stateId)
|
||||
return sendState
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,8 @@ class TransactionExtrasReducer : SendInternalReducer {
|
|||
} else {
|
||||
TransactionExtrasState(
|
||||
xrpDestinationTag = XrpDestinationTagState(
|
||||
InputViewValue("$tag", false), tag,
|
||||
viewFieldValue = InputViewValue("$tag", false),
|
||||
tag = tag,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,51 +6,51 @@ enum class ReceiptLayoutType {
|
|||
}
|
||||
|
||||
data class ReceiptState(
|
||||
val visibleTypeOfReceipt: ReceiptLayoutType? = null,
|
||||
val fiat: ReceiptFiat? = null,
|
||||
val crypto: ReceiptCrypto? = null,
|
||||
val tokenFiat: ReceiptTokenFiat? = null,
|
||||
val tokenCrypto: ReceiptTokenCrypto? = null,
|
||||
val mainCurrency: MainCurrency? = null
|
||||
val visibleTypeOfReceipt: ReceiptLayoutType? = null,
|
||||
val fiat: ReceiptFiat? = null,
|
||||
val crypto: ReceiptCrypto? = null,
|
||||
val tokenFiat: ReceiptTokenFiat? = null,
|
||||
val tokenCrypto: ReceiptTokenCrypto? = null,
|
||||
val mainCurrency: MainCurrency? = null
|
||||
) : SendScreenState {
|
||||
override val stateId: StateId = StateId.RECEIPT
|
||||
}
|
||||
|
||||
data class ReceiptSymbols(
|
||||
val fiat: String,
|
||||
val crypto: String,
|
||||
val token: String? = null
|
||||
val fiat: String,
|
||||
val crypto: String,
|
||||
val token: String? = null
|
||||
)
|
||||
|
||||
data class ReceiptFiat(
|
||||
val amountFiat: String,
|
||||
val feeFiat: String,
|
||||
val totalFiat: String,
|
||||
val willSentCrypto: String,
|
||||
val symbols: ReceiptSymbols
|
||||
val amountFiat: String,
|
||||
val feeFiat: String,
|
||||
val totalFiat: String,
|
||||
val willSentCrypto: String,
|
||||
val symbols: ReceiptSymbols
|
||||
)
|
||||
|
||||
data class ReceiptCrypto(
|
||||
val amountCrypto: String,
|
||||
val feeCrypto: String,
|
||||
val totalCrypto: String,
|
||||
val feeFiat: String,
|
||||
val willSentFiat: String,
|
||||
val symbols: ReceiptSymbols
|
||||
val amountCrypto: String,
|
||||
val feeCrypto: String,
|
||||
val totalCrypto: String,
|
||||
val feeFiat: String,
|
||||
val willSentFiat: String,
|
||||
val symbols: ReceiptSymbols
|
||||
)
|
||||
|
||||
data class ReceiptTokenCrypto(
|
||||
val amountToken: String,
|
||||
val feeCoin: String,
|
||||
val totalFiat: String,
|
||||
val symbols: ReceiptSymbols
|
||||
val amountToken: String,
|
||||
val feeCoin: String,
|
||||
val totalFiat: String,
|
||||
val symbols: ReceiptSymbols
|
||||
)
|
||||
|
||||
data class ReceiptTokenFiat(
|
||||
val amountFiat: String,
|
||||
val feeFiat: String,
|
||||
val totalFiat: String,
|
||||
val willSentToken: String,
|
||||
val willSentFeeCoin: String,
|
||||
val symbols: ReceiptSymbols
|
||||
val amountFiat: String,
|
||||
val feeFiat: String,
|
||||
val totalFiat: String,
|
||||
val willSentToken: String,
|
||||
val willSentFeeCoin: String,
|
||||
val symbols: ReceiptSymbols
|
||||
)
|
||||
|
|
@ -72,7 +72,6 @@ class SendStateSubscriber(fragment: BaseStoreFragment) :
|
|||
@Suppress("ComplexMethod")
|
||||
private fun handleTransactionExtrasState(fg: SendFragment, infoState: TransactionExtrasState) =
|
||||
with(fg.binding.lSendAddressPayid) {
|
||||
|
||||
fun showView(view: View, info: Any?) {
|
||||
view.show(info != null)
|
||||
}
|
||||
|
|
@ -298,7 +297,6 @@ class SendStateSubscriber(fragment: BaseStoreFragment) :
|
|||
else -> {}
|
||||
}
|
||||
|
||||
|
||||
when (state.visibleTypeOfReceipt) {
|
||||
ReceiptLayoutType.FIAT -> {
|
||||
val receipt = state.fiat ?: return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue