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")
|
||||
|
|
|
|||
|
|
@ -260,6 +260,38 @@
|
|||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/hederaMemoContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/tilHederaMemo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/send_extras_hint_memo"
|
||||
style="@style/SecondaryTextInputLayout"
|
||||
app:errorIconDrawable="@null">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/etHederaMemo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/background_secondary"
|
||||
android:textColor="@color/text_primary_1"
|
||||
android:ellipsize="end"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:singleLine="true"
|
||||
android:textSize="16sp"
|
||||
tools:text="Hedera memo" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import com.squareup.moshi.JsonClass
|
|||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class CreateUserNetworkAccountResponse(
|
||||
@Json(name = "status") val status: String,
|
||||
@Json(name = "status") val status: Boolean,
|
||||
@Json(name = "data") val data: AccountCreated,
|
||||
) {
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ fun getActiveIconResByNetworkId(networkId: String): Int {
|
|||
"aptos", "aptos/test" -> R.drawable.img_aptos_22
|
||||
"shibarium", "shibarium/test" -> R.drawable.img_shibarium_22
|
||||
"algorand", "algorand/test" -> R.drawable.img_algorand_22
|
||||
"hedera", "hedera/test" -> R.drawable.img_hedera_22
|
||||
"hedera-hashgraph", "hedera/test" -> R.drawable.img_hedera_22
|
||||
else -> R.drawable.ic_alert_24
|
||||
}
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ fun getActiveIconResByCoinId(coinId: String): Int {
|
|||
"aptos" -> R.drawable.img_aptos_22
|
||||
"shibarium" -> R.drawable.img_shibarium_22
|
||||
"algorand" -> R.drawable.img_algorand_22
|
||||
"hedera" -> R.drawable.img_hedera_22
|
||||
"hedera-hashgraph" -> R.drawable.img_hedera_22
|
||||
else -> R.drawable.ic_alert_24
|
||||
}
|
||||
}
|
||||
|
|
@ -260,7 +260,7 @@ fun getGreyedOutIconResByNetworkId(networkId: String): Int {
|
|||
"aptos", "aptos/test" -> R.drawable.ic_aptos_22
|
||||
"shibarium", "shibarium/test" -> R.drawable.ic_shibarium_22
|
||||
"algorand", "algorand/test" -> R.drawable.ic_algorand_22
|
||||
"hedera", "hedera/test" -> R.drawable.ic_hedera_22
|
||||
"hedera-hashgraph", "hedera/test" -> R.drawable.ic_hedera_22
|
||||
else -> R.drawable.ic_alert_24
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.tangem.data.transaction
|
|||
import androidx.core.text.isDigitsOnly
|
||||
import com.tangem.blockchain.blockchains.binance.BinanceTransactionExtras
|
||||
import com.tangem.blockchain.blockchains.cosmos.CosmosTransactionExtras
|
||||
import com.tangem.blockchain.blockchains.hedera.HederaTransactionBuilder
|
||||
import com.tangem.blockchain.blockchains.stellar.StellarMemo
|
||||
import com.tangem.blockchain.blockchains.stellar.StellarTransactionExtras
|
||||
import com.tangem.blockchain.blockchains.ton.TonTransactionExtras
|
||||
|
|
@ -71,6 +72,7 @@ internal class DefaultTransactionRepository(
|
|||
Blockchain.XRP -> memo.toLongOrNull()?.let { XrpTransactionBuilder.XrpTransactionExtras(it) }
|
||||
Blockchain.Cosmos -> CosmosTransactionExtras(memo)
|
||||
Blockchain.TON -> TonTransactionExtras(memo)
|
||||
Blockchain.Hedera -> HederaTransactionBuilder.HederaTransactionExtras(memo)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ internal class SendRecipientMemoFieldConverter(
|
|||
Blockchain.TerraV1.id,
|
||||
Blockchain.TerraV2.id,
|
||||
Blockchain.Stellar.id,
|
||||
Blockchain.Hedera.id,
|
||||
-> convert(R.string.send_extras_hint_memo)
|
||||
else -> null
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue