Updated on 2026-08-14
This commit is contained in:
parent
e1aa83f8b7
commit
e15683a79b
10 changed files with 102 additions and 43 deletions
|
|
@ -0,0 +1,23 @@
|
|||
package com.tangem.datasource.di
|
||||
|
||||
import com.tangem.datasource.local.datastore.RuntimeDataStore
|
||||
import com.tangem.datasource.local.swaptx.DefaultSwapTransactionStatusStore
|
||||
import com.tangem.datasource.local.swaptx.SwapTransactionStatusStore
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
object SwapTransactionStatusStoreModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideSwapTransactionStatusStore(): SwapTransactionStatusStore {
|
||||
return DefaultSwapTransactionStatusStore(
|
||||
dataStore = RuntimeDataStore(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.tangem.datasource.local.swaptx
|
||||
|
||||
import com.tangem.datasource.local.datastore.core.StringKeyDataStore
|
||||
|
||||
internal class DefaultSwapTransactionStatusStore(
|
||||
private val dataStore: StringKeyDataStore<ExchangeAnalyticsStatus>,
|
||||
) : SwapTransactionStatusStore, StringKeyDataStore<ExchangeAnalyticsStatus> by dataStore {
|
||||
|
||||
override suspend fun getTransactionStatus(txId: String) = getSyncOrNull(txId)
|
||||
|
||||
override suspend fun setTransactionStatus(txId: String, status: ExchangeAnalyticsStatus) = store(txId, status)
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.tangem.datasource.local.swaptx
|
||||
|
||||
/**
|
||||
* Runtime cache for storing swap transactions statuses sent to analytics
|
||||
*/
|
||||
interface SwapTransactionStatusStore {
|
||||
suspend fun getTransactionStatus(txId: String): ExchangeAnalyticsStatus?
|
||||
|
||||
suspend fun setTransactionStatus(txId: String, status: ExchangeAnalyticsStatus)
|
||||
}
|
||||
|
||||
enum class ExchangeAnalyticsStatus(val value: String) {
|
||||
InProgress("In Progress"),
|
||||
Done("Done"),
|
||||
Fail("Fail"),
|
||||
KYC("KYC"),
|
||||
Refunded("Refunded"),
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue