Skip to content

Commit

Permalink
Merge pull request #1030 from novasamatech/develop
Browse files Browse the repository at this point in the history
v7.10.1
  • Loading branch information
ERussel committed Apr 3, 2024
2 parents 17dcd4a + 2f6b271 commit de47ab7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class CrossChainTransferPresenter {
locale: selectedLocale
),

dataValidatingFactory.notViolatingMinBalanceBeforePayingDeliveryFee(
dataValidatingFactory.notViolatingMinBalanceWhenDeliveryFeeEnabled(
for: .init(
amount: isOriginUtilityTransfer ? sendingAmount : 0,
originNetworkFee: networkFee?.amountForCurrentAccount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protocol TransferDataValidatorFactoryProtocol: BaseDataValidatingFactoryProtocol
locale: Locale
) -> DataValidating

func notViolatingMinBalanceBeforePayingDeliveryFee(
func notViolatingMinBalanceWhenDeliveryFeeEnabled(
for params: CrossChainValidationAtLeastEdForDeliveryFee,
locale: Locale
) -> DataValidating
Expand Down Expand Up @@ -289,13 +289,15 @@ final class TransferDataValidatorFactory: TransferDataValidatorFactoryProtocol {
})
}

func notViolatingMinBalanceBeforePayingDeliveryFee(
func notViolatingMinBalanceWhenDeliveryFeeEnabled(
for params: CrossChainValidationAtLeastEdForDeliveryFee,
locale: Locale
) -> DataValidating {
let assetInfo = utilityAssetInfo
let networkFeeAmountInPlank = params.originNetworkFee ?? 0
let networkFeeDecimal = networkFeeAmountInPlank.decimal(assetInfo: assetInfo)
let deliveryFeeInPlank = params.originDeliveryFee ?? 0
let deliveryFeeDecimal = deliveryFeeInPlank.decimal(assetInfo: assetInfo)
let balanceDecimal = params.totalBalance?.decimal(assetInfo: assetInfo) ?? 0
let minBalanceDecimal = params.minBalance?.decimal(assetInfo: assetInfo) ?? 0
let crosschainHoldingDecimal = params.crosschainHolding?.decimal(assetInfo: assetInfo) ?? 0
Expand All @@ -308,7 +310,7 @@ final class TransferDataValidatorFactory: TransferDataValidatorFactoryProtocol {

let tokenFormatter = AssetBalanceFormatterFactory().createTokenFormatter(for: assetInfo)

let feeAndEd = networkFeeDecimal + minBalanceDecimal + crosschainHoldingDecimal
let feeAndEd = networkFeeDecimal + deliveryFeeDecimal + minBalanceDecimal + crosschainHoldingDecimal
let availableDecimal = balanceDecimal >= feeAndEd ? balanceDecimal - feeAndEd : 0

let availableString = tokenFormatter.value(for: locale).stringFromDecimal(availableDecimal) ?? ""
Expand All @@ -324,7 +326,7 @@ final class TransferDataValidatorFactory: TransferDataValidatorFactoryProtocol {
return true
}

return networkFeeDecimal + sendingDecimal + minBalanceDecimal <= balanceDecimal
return networkFeeDecimal + deliveryFeeDecimal + sendingDecimal + minBalanceDecimal <= balanceDecimal
})
}

Expand Down

0 comments on commit de47ab7

Please sign in to comment.