Updated on 2026-08-14
This commit is contained in:
parent
6eee63c0d4
commit
ccb17a8867
6 changed files with 25 additions and 18 deletions
|
|
@ -129,8 +129,7 @@ internal class AddressPayIdMiddleware {
|
|||
private fun extractAddressFromShareUri(shareUri: String): String {
|
||||
val sharePrefix = listOf("bitcoin:", "ethereum:", "ripple:")
|
||||
val prefixes = sharePrefix.filter { shareUri.contains(it) }
|
||||
return if (prefixes.isEmpty()) shareUri
|
||||
else shareUri.replace(prefixes[0], "")
|
||||
return if (prefixes.isEmpty()) shareUri else shareUri.replace(prefixes[0], "")
|
||||
}
|
||||
|
||||
private fun verifyClipboard(input: String?, appState: AppState?, dispatch: DispatchFunction) {
|
||||
|
|
|
|||
|
|
@ -39,8 +39,11 @@ class AmountMiddleware {
|
|||
}
|
||||
if (inputValue.isZero() && amountState.amountToSendCrypto.isZero()) return
|
||||
|
||||
val inputValueCrypto = if (amountState.mainCurrency.type == MainCurrencyType.CRYPTO) inputValue
|
||||
else sendState.convertFiatToExtractCrypto(inputValue)
|
||||
val inputValueCrypto = if (amountState.mainCurrency.type == MainCurrencyType.CRYPTO) {
|
||||
inputValue
|
||||
} else {
|
||||
sendState.convertFiatToExtractCrypto(inputValue)
|
||||
}
|
||||
|
||||
dispatch(AmountAction.SetAmount(inputValueCrypto, true))
|
||||
dispatch(AmountActionUi.CheckAmountToSend)
|
||||
|
|
@ -92,8 +95,11 @@ class AmountMiddleware {
|
|||
val amountState = appState?.sendState?.amountState ?: return
|
||||
if (!appState.sendState.coinIsConvertible()) return
|
||||
|
||||
val type = if (amountState.mainCurrency.type == MainCurrencyType.FIAT) MainCurrencyType.CRYPTO
|
||||
else MainCurrencyType.FIAT
|
||||
val type = if (amountState.mainCurrency.type == MainCurrencyType.FIAT) {
|
||||
MainCurrencyType.CRYPTO
|
||||
} else {
|
||||
MainCurrencyType.FIAT
|
||||
}
|
||||
|
||||
dispatch(AmountActionUi.SetMainCurrency(type))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@ class AddressPayIdReducer : SendInternalReducer {
|
|||
is AddressPayIdActionUi.HandleUserInput -> state
|
||||
is AddressPayIdActionUi.SetTruncateHandler -> state.copy(truncateHandler = action.handler)
|
||||
is AddressPayIdActionUi.TruncateOrRestore -> {
|
||||
val value = if (action.truncate) state.truncatedFieldValue ?: ""
|
||||
else state.normalFieldValue ?: ""
|
||||
val value = if (action.truncate) state.truncatedFieldValue ?: "" else state.normalFieldValue ?: ""
|
||||
state.copy(viewFieldValue = state.viewFieldValue.copy(value = value))
|
||||
}
|
||||
is AddressPayIdActionUi.PasteAddressPayId -> return sendState
|
||||
|
|
|
|||
|
|
@ -29,8 +29,11 @@ class AmountReducer : SendInternalReducer {
|
|||
|
||||
when (val currency = if (currencyCanBeSwitched) action.mainCurrency else MainCurrencyType.CRYPTO) {
|
||||
MainCurrencyType.FIAT -> {
|
||||
val fiatToSend = if (state.amountToSendCrypto.isZero()) BigDecimal.ZERO
|
||||
else sendState.convertExtractCryptoToFiat(state.amountToSendCrypto)
|
||||
val fiatToSend = if (state.amountToSendCrypto.isZero()) {
|
||||
BigDecimal.ZERO
|
||||
} else {
|
||||
sendState.convertExtractCryptoToFiat(state.amountToSendCrypto)
|
||||
}
|
||||
val rescaledBalance = sendState.convertExtractCryptoToFiat(state.balanceCrypto, true)
|
||||
state.copy(
|
||||
viewAmountValue = InputViewValue(fiatToSend.stripZeroPlainString()),
|
||||
|
|
@ -60,8 +63,11 @@ class AmountReducer : SendInternalReducer {
|
|||
private fun handleAction(action: AmountAction, sendState: SendState, state: AmountState): SendState {
|
||||
val result = when (action) {
|
||||
is AmountAction.SetAmount -> {
|
||||
val amount = if (state.mainCurrency.type == MainCurrencyType.CRYPTO) action.amountCrypto
|
||||
else sendState.convertExtractCryptoToFiat(action.amountCrypto, true)
|
||||
val amount = if (state.mainCurrency.type == MainCurrencyType.CRYPTO) {
|
||||
action.amountCrypto
|
||||
} else {
|
||||
sendState.convertExtractCryptoToFiat(action.amountCrypto, true)
|
||||
}
|
||||
state.copy(
|
||||
viewAmountValue = InputViewValue(amount.stripZeroPlainString(), action.isUserInput),
|
||||
amountToSendCrypto = action.amountCrypto,
|
||||
|
|
|
|||
|
|
@ -52,13 +52,11 @@ data class SendState(
|
|||
}
|
||||
|
||||
fun convertFiatToCoin(value: BigDecimal): BigDecimal {
|
||||
return if (!this.coinIsConvertible()) value
|
||||
else coinConverter!!.toCrypto(value)
|
||||
return if (!this.coinIsConvertible()) value else coinConverter!!.toCrypto(value)
|
||||
}
|
||||
|
||||
fun convertFiatToToken(value: BigDecimal): BigDecimal {
|
||||
return if (!this.tokenIsConvertible()) value
|
||||
else tokenConverter!!.toCrypto(value)
|
||||
return if (!this.tokenIsConvertible()) value else tokenConverter!!.toCrypto(value)
|
||||
}
|
||||
|
||||
fun convertCoinToFiat(value: BigDecimal, scaleWithPrecision: Boolean = false): BigDecimal {
|
||||
|
|
|
|||
|
|
@ -75,8 +75,7 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber
|
|||
Error.ADDRESS_SAME_AS_WALLET -> R.string.error_address_same_as_wallet
|
||||
else -> null
|
||||
}
|
||||
return if (resId == null) null
|
||||
else context.getString(resId)
|
||||
return if (resId == null) null else context.getString(resId)
|
||||
}
|
||||
fg.imvPaste.isEnabled = state.pasteIsEnabled
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue