Updated on 2026-08-14
This commit is contained in:
parent
55b6b57963
commit
60e697282b
2 changed files with 24 additions and 3 deletions
|
|
@ -59,14 +59,21 @@ class ManageCryptoCurrenciesUseCase(
|
|||
accountId: AccountId,
|
||||
add: CryptoCurrency? = null,
|
||||
remove: CryptoCurrency? = null,
|
||||
skipDerivationErrors: Boolean = true,
|
||||
): Either<Throwable, Unit> {
|
||||
return invoke(accountId = accountId, add = listOfNotNull(add), remove = listOfNotNull(remove))
|
||||
return invoke(
|
||||
accountId = accountId,
|
||||
add = listOfNotNull(add),
|
||||
remove = listOfNotNull(remove),
|
||||
skipDerivationErrors = skipDerivationErrors,
|
||||
)
|
||||
}
|
||||
|
||||
suspend operator fun invoke(
|
||||
accountId: AccountId,
|
||||
add: List<CryptoCurrency> = emptyList(),
|
||||
remove: List<CryptoCurrency> = emptyList(),
|
||||
skipDerivationErrors: Boolean = true,
|
||||
): Either<Throwable, Unit> = eitherOn(dispatchers.default) {
|
||||
if (add.isEmpty() && remove.isEmpty()) {
|
||||
Timber.d("No currencies to add or remove, skipping")
|
||||
|
|
@ -89,7 +96,7 @@ class ManageCryptoCurrenciesUseCase(
|
|||
account = accountStatus.account.copy(cryptoCurrencies = modifiedCurrencyList.total),
|
||||
)
|
||||
|
||||
derivePublicKeys(userWalletId = userWalletId, currencies = modifiedCurrencyList.added)
|
||||
val result = derivePublicKeys(userWalletId = userWalletId, currencies = modifiedCurrencyList.added)
|
||||
|
||||
parallelUpdatingScope.launch {
|
||||
syncTokens(userWalletId, modifiedCurrencyList)
|
||||
|
|
@ -98,6 +105,10 @@ class ManageCryptoCurrenciesUseCase(
|
|||
refreshExpress(userWalletId = userWalletId, currencies = modifiedCurrencyList.total)
|
||||
clearMetadata(userWalletId = userWalletId, currencies = modifiedCurrencyList.removed)
|
||||
}
|
||||
|
||||
if (!skipDerivationErrors) {
|
||||
result.bind()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,17 @@ internal class ReferralInteractorImpl(
|
|||
|
||||
when (portfolioId) {
|
||||
is PortfolioId.Account -> {
|
||||
manageCryptoCurrenciesUseCase(accountId = portfolioId.accountId, add = cryptoCurrency)
|
||||
manageCryptoCurrenciesUseCase(
|
||||
accountId = portfolioId.accountId,
|
||||
add = cryptoCurrency,
|
||||
skipDerivationErrors = false,
|
||||
).mapLeft {
|
||||
it.mapToDomainError()
|
||||
}.onLeft { error ->
|
||||
if (error is ReferralError.UserCancelledException) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
is PortfolioId.Wallet -> {
|
||||
derivePublicKeysUseCase(userWallet.walletId, listOf(cryptoCurrency)).getOrElse { throwable ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue