EnoughTotalToStayAboveEDValidationFactory.validate( ) { validate(create(fee, balance, chainWithAsset, error)) } - -fun
ValidationSystemBuilder
.enoughBalanceToStayAboveEDValidation( - assetSourceRegistry: AssetSourceRegistry, - fee: AmountProducer
, - balance: AmountProducer
,
- chainWithAsset: (P) -> ChainWithAsset,
- error: (P, BigDecimal) -> E
-) {
- validate(
- EnoughBalanceToStayAboveEDValidation(
- assetSourceRegistry = assetSourceRegistry,
- fee = fee,
- balance = balance,
- chainWithAsset = chainWithAsset,
- error = error
- )
- )
-}
diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/domain/validation/ExistentialDepositValidation.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/domain/validation/ExistentialDepositValidation.kt
index 0fda3f833c..95eaeef657 100644
--- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/domain/validation/ExistentialDepositValidation.kt
+++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/domain/validation/ExistentialDepositValidation.kt
@@ -9,7 +9,7 @@ import java.math.BigDecimal
typealias ExistentialDepositError (
- private val totalBalanceProducer: AmountProducer ,
+ private val countableTowardsEdBalance: AmountProducer ,
private val feeProducer: AmountProducer ,
private val extraAmountProducer: AmountProducer ,
private val errorProducer: ExistentialDepositError (
override suspend fun validate(value: P): ValidationStatus (
}
fun ValidationSystemBuilder .doNotCrossExistentialDeposit(
- totalBalance: AmountProducer ,
+ countableTowardsEdBalance: AmountProducer ,
fee: AmountProducer = { BigDecimal.ZERO },
extraAmount: AmountProducer = { BigDecimal.ZERO },
existentialDeposit: AmountProducer ,
error: ExistentialDepositError (
private val assetSourceRegistry: AssetSourceRegistry,
private val chainExtractor: (P) -> Chain,
private val assetExtractor: (P) -> Chain.Asset,
- private val balanceExtractor: (P) -> Balance,
+ private val balanceCountedTowardsEdExtractor: (P) -> Balance,
private val feeExtractor: (P) -> Balance,
private val amountExtractor: (P) -> Balance,
private val error: (P, existentialDeposit: Balance) -> E
@@ -30,7 +30,7 @@ class SufficientBalanceConsideringConsumersValidation (
return if (totalCanDropBelowMinimumBalance) {
valid()
} else {
- val balance = balanceExtractor(value)
+ val balance = balanceCountedTowardsEdExtractor(value)
val amount = amountExtractor(value)
val fee = feeExtractor(value)
@@ -44,7 +44,7 @@ fun ValidationSystemBuilder .sufficientBalanceConsideringConsumersVa
assetSourceRegistry: AssetSourceRegistry,
chainExtractor: (P) -> Chain,
assetExtractor: (P) -> Chain.Asset,
- balanceExtractor: (P) -> Balance,
+ balanceCountedTowardsEdExtractor: (P) -> Balance,
feeExtractor: (P) -> Balance,
amountExtractor: (P) -> Balance,
error: (P, existentialDeposit: Balance) -> E
@@ -53,7 +53,7 @@ fun ValidationSystemBuilder .sufficientBalanceConsideringConsumersVa
assetSourceRegistry,
chainExtractor,
assetExtractor,
- balanceExtractor,
+ balanceCountedTowardsEdExtractor,
feeExtractor,
amountExtractor,
error,
diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/BalancesView.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/BalancesView.kt
index 5d97cba141..7990928799 100644
--- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/BalancesView.kt
+++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/BalancesView.kt
@@ -53,8 +53,8 @@ abstract class BalancesView @JvmOverloads constructor(
val item = TableCellView(context).apply {
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
- valueSecondary.setTextColorRes(R.color.text_tertiary)
- title.setTextColorRes(R.color.text_tertiary)
+ valueSecondary.setTextColorRes(R.color.text_secondary)
+ title.setTextColorRes(R.color.text_secondary)
setTitle(titleRes)
}
diff --git a/feature-wallet-api/src/main/res/layout/item_asset_selector.xml b/feature-wallet-api/src/main/res/layout/item_asset_selector.xml
index 8e25af5557..55d9d464a9 100644
--- a/feature-wallet-api/src/main/res/layout/item_asset_selector.xml
+++ b/feature-wallet-api/src/main/res/layout/item_asset_selector.xml
@@ -50,7 +50,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:includeFontPadding="false"
- android:textColor="@color/text_tertiary"
+ android:textColor="@color/text_secondary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@id/itemAssetSelectorTokenName"
app:layout_constraintTop_toBottomOf="@id/itemAssetSelectorTokenName"
diff --git a/feature-wallet-api/src/main/res/layout/section_price.xml b/feature-wallet-api/src/main/res/layout/section_price.xml
index 70201c7780..e9b76a006c 100644
--- a/feature-wallet-api/src/main/res/layout/section_price.xml
+++ b/feature-wallet-api/src/main/res/layout/section_price.xml
@@ -15,7 +15,7 @@
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="@string/common_price"
- android:textColor="@color/text_tertiary"
+ android:textColor="@color/text_secondary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@@ -41,7 +41,7 @@
android:layout_marginBottom="16dp"
android:ellipsize="end"
android:singleLine="true"
- android:textColor="@color/text_tertiary"
+ android:textColor="@color/text_secondary"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
diff --git a/feature-wallet-api/src/main/res/layout/view_asset_selector.xml b/feature-wallet-api/src/main/res/layout/view_asset_selector.xml
index bc595959c4..85c0c7ba8f 100644
--- a/feature-wallet-api/src/main/res/layout/view_asset_selector.xml
+++ b/feature-wallet-api/src/main/res/layout/view_asset_selector.xml
@@ -46,7 +46,7 @@
style="@style/TextAppearance.NovaFoundation.Regular.Footnote"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textColor="@color/text_tertiary"
+ android:textColor="@color/text_secondary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@id/assetSelectorTokenName"
app:layout_constraintTop_toBottomOf="@id/assetSelectorTokenName"
diff --git a/feature-wallet-api/src/main/res/layout/view_balances.xml b/feature-wallet-api/src/main/res/layout/view_balances.xml
index 9b2c001576..0e566383b7 100644
--- a/feature-wallet-api/src/main/res/layout/view_balances.xml
+++ b/feature-wallet-api/src/main/res/layout/view_balances.xml
@@ -11,7 +11,7 @@
style="@style/TextAppearance.NovaFoundation.Regular.SubHeadline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textColor="@color/text_tertiary"
+ android:textColor="@color/text_secondary"
android:layout_marginBottom="14dp"
android:includeFontPadding="false"
app:layout_constraintStart_toStartOf="parent"
diff --git a/feature-wallet-api/src/main/res/layout/view_choose_amount.xml b/feature-wallet-api/src/main/res/layout/view_choose_amount.xml
index d8db2848bb..5a49a9eb3e 100644
--- a/feature-wallet-api/src/main/res/layout/view_choose_amount.xml
+++ b/feature-wallet-api/src/main/res/layout/view_choose_amount.xml
@@ -14,7 +14,7 @@
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:text="@string/common_amount"
- android:textColor="@color/text_tertiary"
+ android:textColor="@color/text_secondary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@@ -34,7 +34,7 @@
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:includeFontPadding="false"
- android:textColor="@color/text_tertiary"
+ android:textColor="@color/text_secondary"
app:layout_constraintEnd_toStartOf="@+id/chooseAmountBalance"
app:layout_constraintTop_toTopOf="parent"
tools:text="Transferable:" />
diff --git a/feature-wallet-api/src/main/res/layout/view_choose_amount_input.xml b/feature-wallet-api/src/main/res/layout/view_choose_amount_input.xml
index b9837aa665..21f3a8396f 100644
--- a/feature-wallet-api/src/main/res/layout/view_choose_amount_input.xml
+++ b/feature-wallet-api/src/main/res/layout/view_choose_amount_input.xml
@@ -66,7 +66,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="9dp"
android:singleLine="true"
- android:textColor="@color/text_tertiary"
+ android:textColor="@color/text_secondary"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/chooseAmountInputField"
diff --git a/feature-wallet-api/src/main/res/layout/view_max_amount.xml b/feature-wallet-api/src/main/res/layout/view_max_amount.xml
index 6681e89c07..ddaa526f11 100644
--- a/feature-wallet-api/src/main/res/layout/view_max_amount.xml
+++ b/feature-wallet-api/src/main/res/layout/view_max_amount.xml
@@ -21,7 +21,7 @@
style="@style/TextAppearance.NovaFoundation.Regular.Footnote.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textColor="@color/text_secondary"
+ android:textColor="@color/text_primary"
tools:text="105.79 USDT" />
\ No newline at end of file
diff --git a/feature-wallet-api/src/main/res/layout/view_primary_amount.xml b/feature-wallet-api/src/main/res/layout/view_primary_amount.xml
index 3dc100943c..258d90541c 100644
--- a/feature-wallet-api/src/main/res/layout/view_primary_amount.xml
+++ b/feature-wallet-api/src/main/res/layout/view_primary_amount.xml
@@ -30,6 +30,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
- android:textColor="@color/text_tertiary"
+ android:textColor="@color/text_secondary"
tools:text="$1,524.11" />
\ No newline at end of file
diff --git a/feature-wallet-api/src/main/res/layout/view_total_amount.xml b/feature-wallet-api/src/main/res/layout/view_total_amount.xml
index 8468a40e9b..af8e6b75ae 100644
--- a/feature-wallet-api/src/main/res/layout/view_total_amount.xml
+++ b/feature-wallet-api/src/main/res/layout/view_total_amount.xml
@@ -16,7 +16,7 @@
android:layout_marginHorizontal="16dp"
android:layout_marginTop="21dp"
android:text="@string/common_total"
- android:textColor="@color/text_tertiary" />
+ android:textColor="@color/text_secondary" />
>
+
+ fun pairingAccountsByMetaIdFlow(metaId: Long): Flow
>
+
+ suspend fun removeAllPairingsOtherThan(activePairingTopics: List
> {
+ return dao.allPairingsFlow().mapList(::mapSessionFromLocal)
+ }
+
+ override fun pairingAccountsByMetaIdFlow(metaId: Long): Flow
> {
+ return dao.pairingsByMetaIdFlow(metaId).mapList(::mapSessionFromLocal)
+ }
+
+ override suspend fun removeAllPairingsOtherThan(activePairingTopics: List
>
- fun allSessionAccountsFlow(): Flow
>
+ fun sessionFlow(sessionTopic: String): Flow
>
+ suspend fun addSession(session: Session)
- fun numberOfSessionAccountsFlow(): Flow
>()
- override suspend fun deleteSessionAccount(sessionTopic: String) {
- dao.deleteSession(sessionTopic)
+ override suspend fun setSessions(sessions: List
> {
- return dao.allSessionsFlow().mapList(::mapSessionFromLocal)
+ override suspend fun getSession(sessionTopic: String): Session? {
+ return state.first().find { it.topic == sessionTopic }
}
- override fun sessionAccountsByMetaIdFlow(metaId: Long): Flow
> {
- return dao.sessionsByMetaIdFlow(metaId).mapList(::mapSessionFromLocal)
+ override fun allSessionsFlow(): Flow
> {
+ return state
}
- override fun numberOfSessionAccountsFlow(): Flow
> {
- return walletConnectSessionRepository.allSessionAccountsFlow().map { sessionAccounts ->
- val activeSessions = Web3Wallet.getListOfActiveSessions()
+ return combine(
+ walletConnectSessionRepository.allSessionsFlow(),
+ walletConnectPairingRepository.allPairingAccountsFlow()
+ ) { activeSessions, pairingAccounts ->
val metaAccounts = if (metaId == null) {
accountRepository.allMetaAccounts()
} else {
listOf(accountRepository.getMetaAccount(metaId))
}
- createWalletSessions(activeSessions, metaAccounts, sessionAccounts)
+ createWalletSessions(activeSessions, metaAccounts, pairingAccounts)
}
}
override fun activeSessionFlow(sessionTopic: String): Flow
>
diff --git a/feature-wallet-connect-impl/src/main/java/io/novafoundation/nova/feature_wallet_connect_impl/presentation/service/RealWalletConnectService.kt b/feature-wallet-connect-impl/src/main/java/io/novafoundation/nova/feature_wallet_connect_impl/presentation/service/RealWalletConnectService.kt
index d43314fad6..bccf4aa3e8 100644
--- a/feature-wallet-connect-impl/src/main/java/io/novafoundation/nova/feature_wallet_connect_impl/presentation/service/RealWalletConnectService.kt
+++ b/feature-wallet-connect-impl/src/main/java/io/novafoundation/nova/feature_wallet_connect_impl/presentation/service/RealWalletConnectService.kt
@@ -77,8 +77,8 @@ internal class RealWalletConnectService(
}
private suspend fun handleSessionRequest(sessionRequest: Wallet.Model.SessionRequest) {
- val sdkSession = Web3Wallet.getActiveSessionByTopic(sessionRequest.topic) ?: run { respondNoSession(sessionRequest); return }
- val appSession = interactor.getSessionAccount(sessionRequest.topic) ?: run { respondNoSession(sessionRequest); return }
+ val sdkSession = interactor.getSession(sessionRequest.topic) ?: run { respondNoSession(sessionRequest); return }
+ val appPairing = interactor.getPairingAccount(sdkSession.pairingTopic) ?: run { respondNoSession(sessionRequest); return }
val walletConnectRequest = interactor.parseSessionRequest(sessionRequest)
.onFailure { error ->
@@ -94,7 +94,7 @@ internal class RealWalletConnectService(
ExternalSignPayload(
signRequest = walletConnectRequest.toExternalSignRequest(),
dappMetadata = mapWalletConnectSessionToSignDAppMetadata(sdkSession),
- wallet = ExternalSignWallet.WithId(appSession.metaId)
+ wallet = ExternalSignWallet.WithId(appPairing.metaId)
)
)
}
diff --git a/feature-wallet-connect-impl/src/main/java/io/novafoundation/nova/feature_wallet_connect_impl/presentation/sessions/approve/WalletConnectApproveSessionViewModel.kt b/feature-wallet-connect-impl/src/main/java/io/novafoundation/nova/feature_wallet_connect_impl/presentation/sessions/approve/WalletConnectApproveSessionViewModel.kt
index 7cd284276e..20a86760e9 100644
--- a/feature-wallet-connect-impl/src/main/java/io/novafoundation/nova/feature_wallet_connect_impl/presentation/sessions/approve/WalletConnectApproveSessionViewModel.kt
+++ b/feature-wallet-connect-impl/src/main/java/io/novafoundation/nova/feature_wallet_connect_impl/presentation/sessions/approve/WalletConnectApproveSessionViewModel.kt
@@ -50,12 +50,17 @@ class WalletConnectApproveSessionViewModel(
private val selectWalletMixinFactory: SelectWalletMixin.Factory
) : BaseViewModel() {
- val selectWalletMixin = selectWalletMixinFactory.create(this)
+ private val proposal = responder.requireLastInput()
+
+ val selectWalletMixin = selectWalletMixinFactory.create(
+ coroutineScope = this,
+ selectionParams = ::walletSelectionParams
+ )
private val processState = MutableStateFlow(ProgressState.IDLE)
private val sessionProposalFlow = flowOf {
- interactor.resolveSessionProposal(responder.requireLastInput())
+ interactor.resolveSessionProposal(proposal)
}.shareInBackground()
val sessionMetadata = sessionProposalFlow.map { it.dappMetadata }
@@ -118,6 +123,22 @@ class WalletConnectApproveSessionViewModel(
_showNetworksBottomSheet.value = networksListFlow.first().event()
}
+ private suspend fun walletSelectionParams(): SelectWalletMixin.SelectionParams {
+ val pairingAccount = interactor.getPairingAccount(proposal.pairingTopic)
+
+ return if (pairingAccount != null) {
+ SelectWalletMixin.SelectionParams(
+ selectionAllowed = false,
+ initialSelection = SelectWalletMixin.InitialSelection.SpecificWallet(pairingAccount.metaId)
+ )
+ } else {
+ SelectWalletMixin.SelectionParams(
+ selectionAllowed = true,
+ initialSelection = SelectWalletMixin.InitialSelection.ActiveWallet
+ )
+ }
+ }
+
private fun constructSessionAlerts(metaAccount: MetaAccount, sessionProposal: WalletConnectSessionProposal): SessionAlerts {
val chains = sessionProposal.resolvedChains
diff --git a/feature-wallet-connect-impl/src/main/res/layout/fragment_wc_session_approve.xml b/feature-wallet-connect-impl/src/main/res/layout/fragment_wc_session_approve.xml
index e542cf4779..dc117e8cc8 100644
--- a/feature-wallet-connect-impl/src/main/res/layout/fragment_wc_session_approve.xml
+++ b/feature-wallet-connect-impl/src/main/res/layout/fragment_wc_session_approve.xml
@@ -87,7 +87,7 @@
android:layout_marginEnd="16dp"
android:gravity="center_horizontal"
android:text="@string/dapp_confirm_authorize_subtitle"
- android:textColor="@color/text_tertiary"
+ android:textColor="@color/text_secondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/wcApproveSessionTitle" />
diff --git a/feature-wallet-connect-impl/src/main/res/layout/item_bottom_sheet_wc_networks_label.xml b/feature-wallet-connect-impl/src/main/res/layout/item_bottom_sheet_wc_networks_label.xml
index 24e5ca7e19..eef1ed6159 100644
--- a/feature-wallet-connect-impl/src/main/res/layout/item_bottom_sheet_wc_networks_label.xml
+++ b/feature-wallet-connect-impl/src/main/res/layout/item_bottom_sheet_wc_networks_label.xml
@@ -3,7 +3,7 @@
android:layout_width="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:background="@color/secondary_screen_background"
- android:textColor="@color/text_tertiary"
+ android:textColor="@color/text_secondary"
tools:text="@string/common_required"
android:layout_marginStart="16dp"
style="@style/TextAppearance.NovaFoundation.Regular.Footnote"
diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/mappers/AssetMappers.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/mappers/AssetMappers.kt
index cffbbc9b1c..d6c904091a 100644
--- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/mappers/AssetMappers.kt
+++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/mappers/AssetMappers.kt
@@ -1,12 +1,17 @@
package io.novafoundation.nova.feature_wallet_impl.data.mappers
import io.novafoundation.nova.common.utils.orZero
+import io.novafoundation.nova.core_db.model.AssetLocal
+import io.novafoundation.nova.core_db.model.AssetLocal.EDCountingModeLocal
+import io.novafoundation.nova.core_db.model.AssetLocal.TransferableModeLocal
import io.novafoundation.nova.core_db.model.AssetWithToken
import io.novafoundation.nova.core_db.model.CurrencyLocal
import io.novafoundation.nova.core_db.model.TokenLocal
import io.novafoundation.nova.core_db.model.TokenWithCurrency
import io.novafoundation.nova.feature_currency_api.presentation.mapper.mapCurrencyFromLocal
import io.novafoundation.nova.feature_wallet_api.domain.model.Asset
+import io.novafoundation.nova.feature_wallet_api.domain.model.Asset.EDCountingMode
+import io.novafoundation.nova.feature_wallet_api.domain.model.Asset.TransferableMode
import io.novafoundation.nova.feature_wallet_api.domain.model.CoinRateChange
import io.novafoundation.nova.feature_wallet_api.domain.model.Token
import io.novafoundation.nova.runtime.multiNetwork.chain.model.Chain
@@ -46,7 +51,23 @@ fun mapAssetLocalToAsset(
reservedInPlanks = asset?.reservedInPlanks.orZero(),
bondedInPlanks = asset?.bondedInPlanks.orZero(),
unbondingInPlanks = asset?.unbondingInPlanks.orZero(),
- redeemableInPlanks = asset?.redeemableInPlanks.orZero()
+ redeemableInPlanks = asset?.redeemableInPlanks.orZero(),
+ transferableMode = mapTransferableModeFromLocal(asset?.transferableMode),
+ edCountingMode = mapEdCountingModeFromLocal(asset?.edCountingMode)
)
}
}
+
+private fun mapTransferableModeFromLocal(modeLocal: TransferableModeLocal?): TransferableMode {
+ return when (modeLocal ?: AssetLocal.defaultTransferableMode()) {
+ TransferableModeLocal.REGULAR -> TransferableMode.REGULAR
+ TransferableModeLocal.HOLDS_AND_FREEZES -> TransferableMode.HOLDS_AND_FREEZES
+ }
+}
+
+private fun mapEdCountingModeFromLocal(modeLocal: EDCountingModeLocal?): EDCountingMode {
+ return when (modeLocal ?: AssetLocal.defaultEdCountingMode()) {
+ EDCountingModeLocal.TOTAL -> EDCountingMode.TOTAL
+ EDCountingModeLocal.FREE -> EDCountingMode.FREE
+ }
+}
diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/equilibrium/EquilibriumAssetBalance.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/equilibrium/EquilibriumAssetBalance.kt
index ed3cacfe27..4c3601be46 100644
--- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/equilibrium/EquilibriumAssetBalance.kt
+++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/equilibrium/EquilibriumAssetBalance.kt
@@ -24,6 +24,8 @@ import io.novafoundation.nova.core.updater.SharedRequestsBuilder
import io.novafoundation.nova.core_db.dao.AssetDao
import io.novafoundation.nova.core_db.dao.LockDao
import io.novafoundation.nova.core_db.model.AssetLocal
+import io.novafoundation.nova.core_db.model.AssetLocal.EDCountingModeLocal
+import io.novafoundation.nova.core_db.model.AssetLocal.TransferableModeLocal
import io.novafoundation.nova.feature_account_api.domain.model.MetaAccount
import io.novafoundation.nova.feature_wallet_api.data.cache.AssetCache
import io.novafoundation.nova.feature_wallet_api.data.network.blockhain.assets.balances.AssetBalance
@@ -140,16 +142,18 @@ class EquilibriumAssetBalance(
val reservedByAssetId = reservedBalancesWithBlocks.associateBy { it.assetId }
val diff = assetCache.updateAssetsByChain(metaAccount, chain) { asset: Chain.Asset ->
- val free = freeByAssetId[asset.id]?.balance
- val reserved = reservedByAssetId[asset.id]?.reservedBalance
- val locks = if (asset.isUtilityAsset) assetBalances.lock else BigInteger.ZERO
+ val free = freeByAssetId[asset.id]?.balance.orZero()
+ val reserved = reservedByAssetId[asset.id]?.reservedBalance.orZero()
+ val locks = if (asset.isUtilityAsset) assetBalances.lock.orZero() else BigInteger.ZERO
AssetLocal(
assetId = asset.id,
chainId = asset.chainId,
metaId = metaAccount.id,
- freeInPlanks = free.orZero(),
- reservedInPlanks = reserved.orZero(),
- frozenInPlanks = locks.orZero(),
+ freeInPlanks = free,
+ reservedInPlanks = reserved,
+ frozenInPlanks = locks,
+ transferableMode = TransferableModeLocal.REGULAR,
+ edCountingMode = EDCountingModeLocal.TOTAL,
redeemableInPlanks = BigInteger.ZERO,
bondedInPlanks = BigInteger.ZERO,
unbondingInPlanks = BigInteger.ZERO
diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/evnNative/EvmNativeAssetBalance.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/evmNative/EvmNativeAssetBalance.kt
similarity index 99%
rename from feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/evnNative/EvmNativeAssetBalance.kt
rename to feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/evmNative/EvmNativeAssetBalance.kt
index 92fe919a4b..42d1ea7702 100644
--- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/evnNative/EvmNativeAssetBalance.kt
+++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/evmNative/EvmNativeAssetBalance.kt
@@ -1,4 +1,4 @@
-package io.novafoundation.nova.feature_wallet_impl.data.network.blockchain.assets.balances.evnNative
+package io.novafoundation.nova.feature_wallet_impl.data.network.blockchain.assets.balances.evmNative
import io.novafoundation.nova.core.ethereum.Web3Api
import io.novafoundation.nova.core.updater.SharedRequestsBuilder
diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/orml/OrmlAssetBalance.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/orml/OrmlAssetBalance.kt
index edf66c756f..86dc8c1aa9 100644
--- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/orml/OrmlAssetBalance.kt
+++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/orml/OrmlAssetBalance.kt
@@ -4,6 +4,8 @@ import io.novafoundation.nova.common.utils.decodeValue
import io.novafoundation.nova.common.utils.tokens
import io.novafoundation.nova.core.updater.SharedRequestsBuilder
import io.novafoundation.nova.core_db.dao.LockDao
+import io.novafoundation.nova.core_db.model.AssetLocal.EDCountingModeLocal
+import io.novafoundation.nova.core_db.model.AssetLocal.TransferableModeLocal
import io.novafoundation.nova.feature_account_api.domain.model.MetaAccount
import io.novafoundation.nova.feature_wallet_api.data.cache.AssetCache
import io.novafoundation.nova.feature_wallet_api.data.network.blockhain.assets.balances.AssetBalance
@@ -96,12 +98,16 @@ class OrmlAssetBalance(
metaId: Long,
chainAsset: Chain.Asset,
ormlAccountData: OrmlAccountData
- ) = assetCache.updateAsset(metaId, chainAsset) {
- it.copy(
- frozenInPlanks = ormlAccountData.frozen,
- freeInPlanks = ormlAccountData.free,
- reservedInPlanks = ormlAccountData.reserved
- )
+ ) = assetCache.updateAsset(metaId, chainAsset) { local ->
+ with(ormlAccountData) {
+ local.copy(
+ frozenInPlanks = frozen,
+ freeInPlanks = free,
+ reservedInPlanks = reserved,
+ transferableMode = TransferableModeLocal.REGULAR,
+ edCountingMode = EDCountingModeLocal.TOTAL,
+ )
+ }
}
private fun RuntimeSnapshot.ormlBalanceKey(accountId: AccountId, chainAsset: Chain.Asset): String {
diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/statemine/StatemineAssetBalance.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/statemine/StatemineAssetBalance.kt
index 3ae2bc1229..0f8382c3e7 100644
--- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/statemine/StatemineAssetBalance.kt
+++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/balances/statemine/StatemineAssetBalance.kt
@@ -3,6 +3,8 @@ package io.novafoundation.nova.feature_wallet_impl.data.network.blockchain.asset
import io.novafoundation.nova.common.utils.decodeValue
import io.novafoundation.nova.core.storage.StorageCache
import io.novafoundation.nova.core.updater.SharedRequestsBuilder
+import io.novafoundation.nova.core_db.model.AssetLocal.EDCountingModeLocal
+import io.novafoundation.nova.core_db.model.AssetLocal.TransferableModeLocal
import io.novafoundation.nova.feature_account_api.domain.model.MetaAccount
import io.novafoundation.nova.feature_wallet_api.data.cache.AssetCache
import io.novafoundation.nova.feature_wallet_api.data.network.blockhain.assets.balances.AssetBalance
@@ -136,10 +138,13 @@ class StatemineAssetBalance(
} else {
BigInteger.ZERO
}
+ val freeBalance = assetAccount.balance
it.copy(
frozenInPlanks = frozenBalance,
- freeInPlanks = assetAccount.balance
+ freeInPlanks = freeBalance,
+ transferableMode = TransferableModeLocal.REGULAR,
+ edCountingMode = EDCountingModeLocal.TOTAL,
)
}
}
diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/transfers/validations/Common.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/transfers/validations/Common.kt
index 922adf097e..cc7ae9474b 100644
--- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/transfers/validations/Common.kt
+++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/transfers/validations/Common.kt
@@ -10,6 +10,7 @@ import io.novafoundation.nova.feature_wallet_api.data.network.blockhain.assets.t
import io.novafoundation.nova.feature_wallet_api.data.network.blockhain.assets.tranfers.AssetTransfersValidationSystemBuilder
import io.novafoundation.nova.feature_wallet_api.data.network.blockhain.assets.tranfers.recipientOrNull
import io.novafoundation.nova.feature_wallet_api.data.network.blockhain.assets.tranfers.sendingAmountInCommissionAsset
+import io.novafoundation.nova.feature_wallet_api.domain.model.balanceCountedTowardsED
import io.novafoundation.nova.feature_wallet_api.domain.validation.AmountProducer
import io.novafoundation.nova.feature_wallet_api.domain.validation.EnoughTotalToStayAboveEDValidationFactory
import io.novafoundation.nova.feature_wallet_api.domain.validation.PhishingValidationFactory
@@ -51,7 +52,7 @@ fun AssetTransfersValidationSystemBuilder.sufficientCommissionBalanceToStayAbove
) {
enoughTotalToStayAboveEDValidationFactory.validate(
fee = { it.originFee },
- balance = { it.originCommissionAsset.total },
+ balance = { it.originCommissionAsset.balanceCountedTowardsED() },
chainWithAsset = { ChainWithAsset(it.transfer.originChain, it.transfer.originChain.commissionAsset) },
error = { payload, _ -> AssetTransferValidationFailure.NotEnoughFunds.ToStayAboveED(payload.transfer.originChain.commissionAsset) }
)
@@ -74,7 +75,7 @@ fun AssetTransfersValidationSystemBuilder.doNotCrossExistentialDeposit(
fee: AmountProducer