Updated on 2026-08-14
This commit is contained in:
parent
fc1591532c
commit
3a4ce4d24b
10 changed files with 99 additions and 7 deletions
|
|
@ -59,26 +59,36 @@ sealed class TransactionExtrasAction : SendScreenActionUi {
|
|||
|
||||
object Release : TransactionExtrasAction()
|
||||
|
||||
@Deprecated("Only in legacy send screen")
|
||||
sealed class XlmMemo : TransactionExtrasAction() {
|
||||
// data class ChangeSelectedMemo(val memoType: XlmMemoType) : XlmMemo()
|
||||
data class HandleUserInput(val data: String) : XlmMemo()
|
||||
}
|
||||
|
||||
@Deprecated("Only in legacy send screen")
|
||||
sealed class BinanceMemo : TransactionExtrasAction() {
|
||||
data class HandleUserInput(val data: String) : BinanceMemo()
|
||||
}
|
||||
|
||||
@Deprecated("Only in legacy send screen")
|
||||
sealed class XrpDestinationTag : TransactionExtrasAction() {
|
||||
data class HandleUserInput(val data: String) : XrpDestinationTag()
|
||||
}
|
||||
|
||||
@Deprecated("Only in legacy send screen")
|
||||
sealed class TonMemo : TransactionExtrasAction() {
|
||||
data class HandleUserInput(val data: String) : TonMemo()
|
||||
}
|
||||
|
||||
@Deprecated("Only in legacy send screen")
|
||||
sealed class CosmosMemo : TransactionExtrasAction() {
|
||||
data class HandleUserInput(val data: String) : CosmosMemo()
|
||||
}
|
||||
|
||||
@Deprecated("Only in legacy send screen")
|
||||
sealed class HederaMemo : TransactionExtrasAction() {
|
||||
data class HandleUserInput(val data: String) : HederaMemo()
|
||||
}
|
||||
}
|
||||
|
||||
sealed class AddressVerifyAction : SendScreenAction {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class TransactionExtrasReducer : SendInternalReducer {
|
|||
is XrpDestinationTag -> handleXrpTag(action, sendState, sendState.transactionExtrasState)
|
||||
is TonMemo -> handleTonMemo(action, sendState, sendState.transactionExtrasState)
|
||||
is CosmosMemo -> handleCosmosMemo(action, sendState, sendState.transactionExtrasState)
|
||||
is HederaMemo -> handleHederaMemo(action, sendState, sendState.transactionExtrasState)
|
||||
else -> sendState
|
||||
}
|
||||
}
|
||||
|
|
@ -52,6 +53,7 @@ class TransactionExtrasReducer : SendInternalReducer {
|
|||
Blockchain.TerraV1,
|
||||
Blockchain.TerraV2,
|
||||
-> TransactionExtrasState(cosmosMemoState = CosmosMemoState())
|
||||
Blockchain.Hedera, Blockchain.HederaTestnet -> TransactionExtrasState(hederaMemoState = HederaMemoState())
|
||||
else -> emptyResult
|
||||
}
|
||||
return updateLastState(sendState.copy(transactionExtrasState = result), result)
|
||||
|
|
@ -162,4 +164,19 @@ class TransactionExtrasReducer : SendInternalReducer {
|
|||
}
|
||||
return updateLastState(sendState.copy(transactionExtrasState = result), result)
|
||||
}
|
||||
|
||||
private fun handleHederaMemo(
|
||||
action: HederaMemo,
|
||||
sendState: SendState,
|
||||
infoState: TransactionExtrasState,
|
||||
): SendState {
|
||||
val result = when (action) {
|
||||
is HederaMemo.HandleUserInput -> {
|
||||
val memo = action.data
|
||||
val input = InputViewValue(memo, true)
|
||||
infoState.copy(hederaMemoState = HederaMemoState(input, memo))
|
||||
}
|
||||
}
|
||||
return updateLastState(sendState.copy(transactionExtrasState = result), result)
|
||||
}
|
||||
}
|
||||
|
|
@ -23,18 +23,20 @@ data class AddressState(
|
|||
fun isReady(): Boolean = error == null && destinationWalletAddress?.isNotEmpty() ?: false
|
||||
}
|
||||
|
||||
@Deprecated("Legacy")
|
||||
data class TransactionExtrasState(
|
||||
val xlmMemo: XlmMemoState? = null,
|
||||
val binanceMemo: BinanceMemoState? = null,
|
||||
val xrpDestinationTag: XrpDestinationTagState? = null,
|
||||
val tonMemoState: TonMemoState? = null,
|
||||
val cosmosMemoState: CosmosMemoState? = null,
|
||||
val hederaMemoState: HederaMemoState? = null,
|
||||
) : IdStateHolder {
|
||||
override val stateId: StateId = StateId.TRANSACTION_EXTRAS
|
||||
|
||||
fun isNull(): Boolean {
|
||||
return xlmMemo == null && binanceMemo == null && xrpDestinationTag == null && tonMemoState == null &&
|
||||
cosmosMemoState == null
|
||||
cosmosMemoState == null && hederaMemoState == null
|
||||
}
|
||||
|
||||
fun isEmpty(): Boolean {
|
||||
|
|
@ -43,8 +45,9 @@ data class TransactionExtrasState(
|
|||
val isXrpEmpty = xrpDestinationTag?.viewFieldValue?.value?.isEmpty() ?: false
|
||||
val isTonEmpty = tonMemoState?.viewFieldValue?.value?.isEmpty() ?: false
|
||||
val isCosmosEmpty = cosmosMemoState?.viewFieldValue?.value?.isEmpty() ?: false
|
||||
val isHederaEmpty = hederaMemoState?.viewFieldValue?.value?.isEmpty() ?: false
|
||||
|
||||
return isXlmEmpty || isBinanceEmpty || isXrpEmpty || isTonEmpty || isCosmosEmpty
|
||||
return isXlmEmpty || isBinanceEmpty || isXrpEmpty || isTonEmpty || isCosmosEmpty || isHederaEmpty
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -120,6 +123,12 @@ data class CosmosMemoState(
|
|||
val error: TransactionExtraError? = null,
|
||||
)
|
||||
|
||||
data class HederaMemoState(
|
||||
val viewFieldValue: InputViewValue = InputViewValue(""),
|
||||
val memo: String? = null,
|
||||
val error: TransactionExtraError? = null,
|
||||
)
|
||||
|
||||
enum class TransactionExtraError {
|
||||
INVALID_DESTINATION_TAG,
|
||||
INVALID_XLM_MEMO,
|
||||
|
|
|
|||
|
|
@ -234,6 +234,15 @@ class SendFragment : BaseStoreFragment(R.layout.fragment_send) {
|
|||
}
|
||||
.onEach { store.dispatch(TransactionExtrasAction.CosmosMemo.HandleUserInput(it)) }
|
||||
.launchIn(mainScope)
|
||||
|
||||
etHederaMemo.inputtedTextAsFlow()
|
||||
.debounce(EDIT_TEXT_INPUT_DEBOUNCE)
|
||||
.filter {
|
||||
val info = store.state.sendState.transactionExtrasState
|
||||
info.hederaMemoState?.viewFieldValue?.value != it
|
||||
}
|
||||
.onEach { store.dispatch(TransactionExtrasAction.HederaMemo.HandleUserInput(it)) }
|
||||
.launchIn(mainScope)
|
||||
}
|
||||
|
||||
private fun onCodeScanned(scannedCode: String) {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@ internal class SendStateSubscriber(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("ComplexMethod")
|
||||
@Deprecated("Legacy")
|
||||
@Suppress("ComplexMethod", "LongMethod")
|
||||
private fun handleTransactionExtrasState(fg: SendFragment, infoState: TransactionExtrasState) =
|
||||
with(fg.binding.lSendAddress) {
|
||||
fun showView(view: View, info: Any?) {
|
||||
|
|
@ -73,6 +74,7 @@ internal class SendStateSubscriber(
|
|||
showView(binanceMemoContainer, infoState.binanceMemo)
|
||||
showView(tonMemoContainer, infoState.tonMemoState)
|
||||
showView(cosmosMemoContainer, infoState.cosmosMemoState)
|
||||
showView(hederaMemoContainer, infoState.hederaMemoState)
|
||||
|
||||
infoState.xlmMemo?.let {
|
||||
if (!it.viewFieldValue.isFromUserInput) etXlmMemo.setText(it.viewFieldValue.value)
|
||||
|
|
@ -129,6 +131,16 @@ internal class SendStateSubscriber(
|
|||
etCosmosMemo.setText(it.viewFieldValue.value)
|
||||
}
|
||||
}
|
||||
infoState.hederaMemoState?.let {
|
||||
if (infoState.hederaMemoState.error != null) {
|
||||
tilHederaMemo.error = fg.getText(R.string.send_extras_error_invalid_memo)
|
||||
} else {
|
||||
tilHederaMemo.error = null
|
||||
}
|
||||
if (!it.viewFieldValue.isFromUserInput) {
|
||||
etHederaMemo.setText(it.viewFieldValue.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("ComplexMethod")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue