Updated on 2026-08-14
This commit is contained in:
parent
42f276c56f
commit
ca7088e2f5
14 changed files with 87 additions and 58 deletions
|
|
@ -268,6 +268,17 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
amountToSwap: String,
|
||||
selectedFee: FeeType,
|
||||
): Map<SwapProvider, SwapState> {
|
||||
Timber.i(
|
||||
"""
|
||||
Find the best quote
|
||||
|- fromToken: $fromToken
|
||||
|- toToken: $toToken
|
||||
|- providers: $providers
|
||||
|- amountToSwap: $amountToSwap
|
||||
|- selectedFee: $selectedFee
|
||||
""".trimIndent(),
|
||||
)
|
||||
|
||||
return providers.map { provider ->
|
||||
val amountDecimal = toBigDecimalOrNull(amountToSwap)
|
||||
if (amountDecimal == null || amountDecimal.signum() == 0) {
|
||||
|
|
@ -311,7 +322,7 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
amount: SwapAmount,
|
||||
isBalanceWithoutFeeEnough: Boolean,
|
||||
): Pair<SwapProvider, SwapState> {
|
||||
val quotes = repository.findBestQuote(
|
||||
val maybeQuotes = repository.findBestQuote(
|
||||
fromContractAddress = fromToken.currency.getContractAddress(),
|
||||
fromNetwork = fromToken.currency.network.backendId,
|
||||
toContractAddress = toToken.currency.getContractAddress(),
|
||||
|
|
@ -324,7 +335,7 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
)
|
||||
|
||||
val fromTokenAddress = getTokenAddress(fromToken.currency)
|
||||
val isAllowedToSpend = quotes.fold(
|
||||
val isAllowedToSpend = maybeQuotes.fold(
|
||||
ifRight = { quotes ->
|
||||
quotes.allowanceContract?.let {
|
||||
isAllowedToSpend(networkId, fromToken.currency, amount, it)
|
||||
|
|
@ -352,7 +363,7 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
} else {
|
||||
provider to getQuotesState(
|
||||
provider = provider,
|
||||
quoteDataModel = quotes,
|
||||
quoteDataModel = maybeQuotes,
|
||||
amount = amount,
|
||||
fromToken = fromToken,
|
||||
toToken = toToken,
|
||||
|
|
@ -573,6 +584,19 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
includeFeeInAmount: IncludeFeeInAmount,
|
||||
fee: TxFee,
|
||||
): SwapTransactionState {
|
||||
Timber.i(
|
||||
"""
|
||||
Swap
|
||||
|- swapProvider: $swapProvider
|
||||
|- swapData: $swapData
|
||||
|- currencyToSend: $currencyToSend
|
||||
|- currencyToGet: $currencyToGet
|
||||
|- amountToSwap: $amountToSwap
|
||||
|- includeFeeInAmount: $includeFeeInAmount
|
||||
|- fee: $fee
|
||||
""".trimIndent(),
|
||||
)
|
||||
|
||||
val cardId = getSelectedWallet()?.scanResponse?.card?.cardId ?: return SwapTransactionState.UnknownError
|
||||
if (isDemoCardUseCase(cardId)) return SwapTransactionState.DemoMode
|
||||
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ internal class SwapViewModel @Inject constructor(
|
|||
)
|
||||
}
|
||||
}.onFailure {
|
||||
Timber.tag(loggingTag).e(it)
|
||||
Timber.e(it)
|
||||
|
||||
applyInitialTokenChoice(
|
||||
state = TokensDataStateExpress.EMPTY,
|
||||
|
|
@ -1212,7 +1212,6 @@ internal class SwapViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private companion object {
|
||||
const val loggingTag = "SwapViewModel"
|
||||
const val INITIAL_AMOUNT = ""
|
||||
const val UPDATE_DELAY = 10000L
|
||||
const val DEBOUNCE_AMOUNT_DELAY = 1000L
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ internal class WalletsUpdateActionResolver @Inject constructor(
|
|||
getUpdateContentAction(currentState, wallets, selectedWallet)
|
||||
}
|
||||
|
||||
Timber.d("Resolved action: $action")
|
||||
Timber.i("Resolved action: $action")
|
||||
|
||||
return action
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue