Updated on 2026-08-14

This commit is contained in:
Tangem 2023-12-06 18:03:41 +03:00
parent e1aa83f8b7
commit e15683a79b
10 changed files with 102 additions and 43 deletions

View file

@ -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(),
)
}
}

View file

@ -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)
}

View file

@ -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"),
}