Updated on 2026-08-14
This commit is contained in:
parent
ee69207d9c
commit
87d1885b58
8 changed files with 51 additions and 37 deletions
|
|
@ -46,7 +46,7 @@ interface YieldSupplyRepository {
|
|||
* May throw on network/backend errors or if required chain id cannot be resolved.
|
||||
*/
|
||||
@Throws
|
||||
suspend fun activateProtocol(cryptoCurrencyToken: CryptoCurrency.Token): Boolean
|
||||
suspend fun activateProtocol(cryptoCurrencyToken: CryptoCurrency.Token, address: String): Boolean
|
||||
|
||||
/**
|
||||
* Deactivate yield protocol for the specified token.
|
||||
|
|
@ -56,7 +56,7 @@ interface YieldSupplyRepository {
|
|||
* network/backend errors or if required chain id cannot be resolved.
|
||||
*/
|
||||
@Throws
|
||||
suspend fun deactivateProtocol(cryptoCurrencyToken: CryptoCurrency.Token): Boolean
|
||||
suspend fun deactivateProtocol(cryptoCurrencyToken: CryptoCurrency.Token, address: String): Boolean
|
||||
|
||||
/**
|
||||
* Save the last user-initiated yield protocol action for the given currency.
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@ class YieldSupplyActivateUseCase(
|
|||
private val yieldSupplyRepository: YieldSupplyRepository,
|
||||
) {
|
||||
|
||||
suspend operator fun invoke(cryptoCurrency: CryptoCurrency): Either<Throwable, Boolean> = Either.catch {
|
||||
val token = cryptoCurrency as? CryptoCurrency.Token ?: error("Token expected")
|
||||
yieldSupplyRepository.activateProtocol(token)
|
||||
}
|
||||
suspend operator fun invoke(cryptoCurrency: CryptoCurrency, address: String): Either<Throwable, Boolean> =
|
||||
Either.catch {
|
||||
val token = cryptoCurrency as? CryptoCurrency.Token ?: error("Token expected")
|
||||
yieldSupplyRepository.activateProtocol(token, address)
|
||||
}
|
||||
}
|
||||
|
|
@ -8,8 +8,9 @@ class YieldSupplyDeactivateUseCase(
|
|||
private val yieldSupplyRepository: YieldSupplyRepository,
|
||||
) {
|
||||
|
||||
suspend operator fun invoke(cryptoCurrency: CryptoCurrency): Either<Throwable, Boolean> = Either.catch {
|
||||
val token = cryptoCurrency as? CryptoCurrency.Token ?: error("Token expected")
|
||||
yieldSupplyRepository.deactivateProtocol(token)
|
||||
}
|
||||
suspend operator fun invoke(cryptoCurrency: CryptoCurrency, address: String): Either<Throwable, Boolean> =
|
||||
Either.catch {
|
||||
val token = cryptoCurrency as? CryptoCurrency.Token ?: error("Token expected")
|
||||
yieldSupplyRepository.deactivateProtocol(token, address)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue