Updated on 2026-08-14
This commit is contained in:
parent
85ea643f3b
commit
fa6b338401
6 changed files with 21 additions and 20 deletions
|
|
@ -6,6 +6,7 @@ import com.tangem.blockchain.common.TransactionSender
|
|||
import com.tangem.blockchain.common.TransactionSigner
|
||||
import com.tangem.blockchain.common.WalletManager
|
||||
import com.tangem.blockchain.common.toBlockchainSdkError
|
||||
import com.tangem.blockchain.common.transaction.Fee
|
||||
import com.tangem.blockchain.common.transaction.TransactionFee
|
||||
import com.tangem.blockchain.extensions.Result
|
||||
import com.tangem.blockchain.extensions.SimpleResult
|
||||
|
|
@ -89,9 +90,9 @@ class DemoTransactionSender(private val walletManager: WalletManager) : Transact
|
|||
val blockchain = walletManager.wallet.blockchain
|
||||
return Result.Success(
|
||||
TransactionFee.Choosable(
|
||||
minimum = Amount(minimumFee, blockchain),
|
||||
normal = Amount(normalFee, blockchain),
|
||||
priority = Amount(priorityFee, blockchain)
|
||||
minimum = Fee(Amount(minimumFee, blockchain)),
|
||||
normal = Fee(Amount(normalFee, blockchain)),
|
||||
priority = Fee(Amount(priorityFee, blockchain))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ class GnosisRegistrator(
|
|||
}
|
||||
is TransactionFee.Choosable -> {
|
||||
val normalFee = (data as TransactionFee.Choosable).normal
|
||||
Result.Success(normalFee)
|
||||
Result.Success(normalFee.amount)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class RequestFeeMiddleware {
|
|||
dispatch(FeeAction.FeeCalculation.SetFeeResult(result))
|
||||
when(result) {
|
||||
is TransactionFee.Single -> {
|
||||
val fee = result.normal.value ?: BigDecimal.ZERO
|
||||
val fee = result.normal.amount.value ?: BigDecimal.ZERO
|
||||
if (fee.isZero()) {
|
||||
dispatch(FeeAction.ChangeLayoutVisibility(main = false))
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -102,14 +102,14 @@ class FeeReducer : SendInternalReducer {
|
|||
private fun createValueOfFeeAmount(feeType: FeeType, transactionFee: TransactionFee): Amount {
|
||||
return when (transactionFee) {
|
||||
is TransactionFee.Single -> {
|
||||
transactionFee.normal
|
||||
transactionFee.normal.amount
|
||||
}
|
||||
is TransactionFee.Choosable -> {
|
||||
when (feeType) {
|
||||
FeeType.SINGLE -> transactionFee.normal
|
||||
FeeType.LOW -> transactionFee.minimum
|
||||
FeeType.NORMAL -> transactionFee.normal
|
||||
FeeType.PRIORITY -> transactionFee.priority
|
||||
FeeType.SINGLE -> transactionFee.normal.amount
|
||||
FeeType.LOW -> transactionFee.minimum.amount
|
||||
FeeType.NORMAL -> transactionFee.normal.amount
|
||||
FeeType.PRIORITY -> transactionFee.priority.amount
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ suspend fun CurrencyExchangeManager.buyErc20TestnetTokens(
|
|||
amountToSend,
|
||||
destinationAddress,
|
||||
) as? Result.Success ?: return
|
||||
val fee = feeResult.data.minimum
|
||||
val fee = feeResult.data.minimum.amount
|
||||
|
||||
val coinValue = walletManager.wallet.amounts[AmountType.Coin]?.value ?: BigDecimal.ZERO
|
||||
if (coinValue < fee.value) return
|
||||
|
|
|
|||
|
|
@ -200,10 +200,10 @@ class TransactionManagerImpl(
|
|||
// for not EVM blockchains set gasLimit ZERO for now
|
||||
when (fee.data) {
|
||||
is TransactionFee.Single -> {
|
||||
val amount = (fee.data as TransactionFee.Single).normal
|
||||
val fee = (fee.data as TransactionFee.Single).normal
|
||||
val singleFee = ProxyFee(
|
||||
gasLimit = BigInteger.ZERO,
|
||||
fee = convertToProxyAmount(amount = amount),
|
||||
fee = convertToProxyAmount(amount = fee.amount),
|
||||
)
|
||||
ProxyFees(
|
||||
minFee = singleFee,
|
||||
|
|
@ -212,19 +212,19 @@ class TransactionManagerImpl(
|
|||
)
|
||||
}
|
||||
is TransactionFee.Choosable -> {
|
||||
val setOfThree = fee.data as TransactionFee.Choosable
|
||||
val choosableFee = fee.data as TransactionFee.Choosable
|
||||
ProxyFees(
|
||||
minFee = ProxyFee(
|
||||
gasLimit = BigInteger.ZERO,
|
||||
fee = convertToProxyAmount(amount = setOfThree.minimum),
|
||||
fee = convertToProxyAmount(amount = choosableFee.minimum.amount),
|
||||
),
|
||||
normalFee = ProxyFee(
|
||||
gasLimit = BigInteger.ZERO,
|
||||
fee = convertToProxyAmount(amount = setOfThree.normal),
|
||||
fee = convertToProxyAmount(amount = choosableFee.normal.amount),
|
||||
),
|
||||
priorityFee = ProxyFee(
|
||||
gasLimit = BigInteger.ZERO,
|
||||
fee = convertToProxyAmount(amount = setOfThree.priority),
|
||||
fee = convertToProxyAmount(amount = choosableFee.priority.amount),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
@ -282,15 +282,15 @@ class TransactionManagerImpl(
|
|||
|
||||
val minProxyFee = ProxyFee(
|
||||
gasLimit = walletManager.gasLimit ?: BigInteger.ZERO,
|
||||
fee = convertToProxyAmount(amount = choosableFee.minimum),
|
||||
fee = convertToProxyAmount(amount = choosableFee.minimum.amount),
|
||||
)
|
||||
val normalProxyFee = ProxyFee(
|
||||
gasLimit = walletManager.gasLimit ?: BigInteger.ZERO,
|
||||
fee = convertToProxyAmount(amount = choosableFee.normal),
|
||||
fee = convertToProxyAmount(amount = choosableFee.normal.amount),
|
||||
)
|
||||
val priorityProxyFee = ProxyFee(
|
||||
gasLimit = walletManager.gasLimit ?: BigInteger.ZERO,
|
||||
fee = convertToProxyAmount(amount = choosableFee.priority),
|
||||
fee = convertToProxyAmount(amount = choosableFee.priority.amount),
|
||||
)
|
||||
|
||||
ProxyFees(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue