From 5e3d616b21460d632380f0bb0d8f4dd4152980ce Mon Sep 17 00:00:00 2001
From: valentunn <70131744+valentunn@users.noreply.github.com>
Date: Thu, 29 Feb 2024 12:12:41 +0300
Subject: [PATCH 1/2] Hotfixes (#1414)
* Improve delivery fee dusting validation
* Support HydraDx event renaming
---
common/src/main/res/values-ru/strings.xml | 2 +-
common/src/main/res/values/strings.xml | 2 +-
.../send/TransferAssetValidationFailureUi.kt | 3 ---
.../assets/tranfers/AssetTransferValidations.kt | 3 ---
.../substrate/hydraDx/HydraDxRouterSwapExtractor.kt | 1 +
...CannotDropBelowEdBeforePayingDeliveryFeeValidation.kt | 9 ++++-----
6 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/common/src/main/res/values-ru/strings.xml b/common/src/main/res/values-ru/strings.xml
index cf7b46725d..2347999966 100644
--- a/common/src/main/res/values-ru/strings.xml
+++ b/common/src/main/res/values-ru/strings.xml
@@ -1360,7 +1360,7 @@
Убедитесь, что адрес\nиз правильной сети
Неверный формат адреса.\nУбедитесь, что адрес \nсоответствует сети
Минимальный баланс
- Ваш доступный баланс %s, вам необходимо оставить минимум %s для доставки перевода и заплатить комиссию сети %s. Вы можете перевести не более %s
+ Из-за межсетевых ограничений вы можете перевести не более %s
У вас недостаточно токенов для оплаты межсетевой комиссии в размере %s.\nОстаток баланса после перевода: %s
Межсетевая комиссия добавляется к введенной сумме. Получатель может получить часть межсетевой комиссии
Подтвердить
diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml
index e9eab14a41..f16636cb3d 100644
--- a/common/src/main/res/values/strings.xml
+++ b/common/src/main/res/values/strings.xml
@@ -1,6 +1,6 @@
- Your available balance is %s, you need to leave at least %s for transfer delivery and pay network fee of %s. You can transfer not more than %s
+ Due to the cross-chain restrictions you can transfer not more than %s
Your balance is too small
You need to have at least %s to pay this transaction fee and stay above the minimum network balance. Your current balance is: %s. You need to add %s to your balance to perform this operation.
diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/send/TransferAssetValidationFailureUi.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/send/TransferAssetValidationFailureUi.kt
index cb9a9e1b26..34478860fb 100644
--- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/send/TransferAssetValidationFailureUi.kt
+++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/send/TransferAssetValidationFailureUi.kt
@@ -81,9 +81,6 @@ fun CoroutineScope.mapAssetTransferValidationFailureToUI(
resourceManager.getString(R.string.common_not_enough_funds_title) to
resourceManager.getString(
R.string.wallet_send_cannot_dust_before_delivery_fee_message,
- reason.balanceCountedTowardsEd.formatPlanks(reason.chainAsset),
- reason.existentialDeposit.formatPlanks(reason.chainAsset),
- reason.networkFee.formatPlanks(reason.chainAsset),
reason.maxPossibleTransferAmount.formatPlanks(reason.chainAsset)
)
)
diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/data/network/blockhain/assets/tranfers/AssetTransferValidations.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/data/network/blockhain/assets/tranfers/AssetTransferValidations.kt
index 6daeddb39d..2d54007863 100644
--- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/data/network/blockhain/assets/tranfers/AssetTransferValidations.kt
+++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/data/network/blockhain/assets/tranfers/AssetTransferValidations.kt
@@ -59,9 +59,6 @@ sealed class AssetTransferValidationFailure {
) : NotEnoughFunds()
class ToStayAboveEdBeforePayingDeliveryFees(
- val balanceCountedTowardsEd: Balance,
- val existentialDeposit: Balance,
- val networkFee: Balance,
val maxPossibleTransferAmount: Balance,
val chainAsset: Chain.Asset,
) : NotEnoughFunds()
diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/history/realtime/substrate/hydraDx/HydraDxRouterSwapExtractor.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/history/realtime/substrate/hydraDx/HydraDxRouterSwapExtractor.kt
index 0ced0b02f7..bff2feb1b4 100644
--- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/history/realtime/substrate/hydraDx/HydraDxRouterSwapExtractor.kt
+++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/blockchain/assets/history/realtime/substrate/hydraDx/HydraDxRouterSwapExtractor.kt
@@ -20,6 +20,7 @@ class HydraDxRouterSwapExtractor(
override fun ExtrinsicVisit.extractSwapArgs(): SwapArgs {
val swapExecutedEvent = events.findEvent(Modules.ROUTER, "RouteExecuted")
+ ?: events.findEvent(Modules.ROUTER, "Executed")
return when {
// successful swap, extract from event
diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/crosschain/validations/CannotDropBelowEdBeforePayingDeliveryFeeValidation.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/crosschain/validations/CannotDropBelowEdBeforePayingDeliveryFeeValidation.kt
index 36870c407e..20fe395f7e 100644
--- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/crosschain/validations/CannotDropBelowEdBeforePayingDeliveryFeeValidation.kt
+++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/network/crosschain/validations/CannotDropBelowEdBeforePayingDeliveryFeeValidation.kt
@@ -32,7 +32,9 @@ class CannotDropBelowEdBeforePayingDeliveryFeeValidation(
val paysDeliveryFee = deliveryFeePart.isPositive()
val networkFeePlanks = value.originFee.networkFeePart().networkFee.amountByRequestedAccount
- val sendingAmount = value.transfer.amountInPlanks + value.crossChainFee?.networkFee?.amountByRequestedAccount.orZero()
+ val crossChainFeePlanks = value.crossChainFee?.networkFee?.amountByRequestedAccount.orZero()
+
+ val sendingAmount = value.transfer.amountInPlanks + crossChainFeePlanks
val requiredAmountBeforePayingDeliveryFee = sendingAmount + networkFeePlanks + existentialDeposit
val balanceCountedTowardsEd = value.originUsedAsset.balanceCountedTowardsEDInPlanks
@@ -43,13 +45,10 @@ class CannotDropBelowEdBeforePayingDeliveryFeeValidation(
requiredAmountBeforePayingDeliveryFee <= balanceCountedTowardsEd -> valid()
else -> {
- val availableBalance = (balanceCountedTowardsEd - networkFeePlanks - existentialDeposit).atLeastZero()
+ val availableBalance = (balanceCountedTowardsEd - networkFeePlanks - crossChainFeePlanks - existentialDeposit).atLeastZero()
validationError(
ToStayAboveEdBeforePayingDeliveryFees(
- balanceCountedTowardsEd = balanceCountedTowardsEd,
- existentialDeposit = existentialDeposit,
- networkFee = networkFeePlanks,
maxPossibleTransferAmount = availableBalance,
chainAsset = value.transfer.originChainAsset
)
From b1be9ff16be6d131b53f5da0f6d191f2fee95597 Mon Sep 17 00:00:00 2001
From: Valentun
Date: Thu, 29 Feb 2024 12:13:50 +0300
Subject: [PATCH 2/2] Bump versions
---
build.gradle | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/build.gradle b/build.gradle
index dbf6fc721f..0124f638bc 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,8 +1,8 @@
buildscript {
ext {
// App version
- versionName = '7.9.3'
- versionCode = 121
+ versionName = '7.9.4'
+ versionCode = 122
applicationId = "io.novafoundation.nova"
releaseApplicationSuffix = "market"