Updated on 2026-08-14

This commit is contained in:
Tangem 2021-02-10 14:05:53 +03:00
parent 2b47775c78
commit 4f4b8a1757
4 changed files with 31 additions and 5 deletions

View file

@ -68,7 +68,8 @@ class TransactionExtrasReducer : SendInternalReducer {
// }
is XlmMemo.HandleUserInput -> {
val inputViewValue = InputViewValue(action.data, true)
var memo = infoState.xlmMemo?.copy(viewFieldValue = inputViewValue) ?: XlmMemoState(inputViewValue)
var memo = infoState.xlmMemo?.copy(viewFieldValue = inputViewValue)
?: XlmMemoState(inputViewValue)
memo = clearMemo(memo)
memo = when (infoState.xlmMemo?.selectedMemoType) {
XlmMemoType.TEXT -> memo.copy(text = StellarMemo.Text(action.data))
@ -93,7 +94,12 @@ class TransactionExtrasReducer : SendInternalReducer {
is XrpDestinationTag.HandleUserInput -> {
val tag = action.data.toLongOrNull()
if (tag != null) {
val tagState = XrpDestinationTagState(InputViewValue(action.data, true), tag)
val input = InputViewValue(action.data, true)
val tagState = if (tag <= XrpDestinationTagState.MAX_NUMBER){
XrpDestinationTagState(input, tag)
} else {
XrpDestinationTagState(input, error = XrpDestinationTagError.INVALID_TAG)
}
infoState.copy(xrpDestinationTag = tagState)
} else {
infoState

View file

@ -50,5 +50,14 @@ data class XlmMemoState(
// tag must contains only digits
data class XrpDestinationTagState(
val viewFieldValue: InputViewValue = InputViewValue(""),
val tag: Long? = null
)
val tag: Long? = null,
val error: XrpDestinationTagError? = null
) {
companion object {
const val MAX_NUMBER: Long = 4294967295
}
}
enum class XrpDestinationTagError {
INVALID_TAG
}

View file

@ -72,7 +72,16 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber
if (!it.viewFieldValue.isFromUserInput) fg.etMemo.setText(it.viewFieldValue.value)
}
infoState.xrpDestinationTag?.let {
if (!it.viewFieldValue.isFromUserInput) fg.etDestinationTag.setText(it.viewFieldValue.value)
if (infoState.xrpDestinationTag.error != null) {
if (infoState.xrpDestinationTag.error == XrpDestinationTagError.INVALID_TAG) {
fg.tilDestinationTag.error = fg.getText(R.string.send_error_invalid_destination_tag)
}
} else {
fg.tilDestinationTag.error = null
}
if (!it.viewFieldValue.isFromUserInput) {
fg.etDestinationTag.setText(it.viewFieldValue.value)
}
}
}

View file

@ -35,5 +35,7 @@ this wallet.
<string name="send_extras_hint_memo" translatable="false">Memo</string>
<string name="send_extras_hint_destination_tag" translatable="false">Destination tag</string>
<string name="send_error_invalid_destination_tag" translatable="false">Invalid destination tag. It won\'t be added to the transaction</string>
</resources>