Updated on 2026-08-14

This commit is contained in:
Tangem 2023-07-25 12:15:26 +03:00
parent 6016933480
commit ef19a3697d
10 changed files with 202 additions and 72 deletions

View file

@ -4,6 +4,7 @@ import com.squareup.moshi.Moshi
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
import com.tangem.datasource.files.FileReader
import com.tangem.datasource.local.datastore.FileDataStore
import com.tangem.domain.wallets.models.UserWalletId
import kotlinx.coroutines.flow.Flow
internal class FileUserTokensStore(fileReader: FileReader, moshi: Moshi) : UserTokensStore {
@ -14,15 +15,15 @@ internal class FileUserTokensStore(fileReader: FileReader, moshi: Moshi) : UserT
adapter = moshi.adapter(UserTokensResponse::class.java),
)
override fun get(userWalletId: String): Flow<UserTokensResponse> {
return store.get(userWalletId)
override fun get(userWalletId: UserWalletId): Flow<UserTokensResponse> {
return store.get(userWalletId.stringValue)
}
override suspend fun getSyncOrNull(userWalletId: String): UserTokensResponse? {
return store.getSyncOrNull(userWalletId)
override suspend fun getSyncOrNull(userWalletId: UserWalletId): UserTokensResponse? {
return store.getSyncOrNull(userWalletId.stringValue)
}
override suspend fun store(userWalletId: String, tokens: UserTokensResponse) {
store.store(userWalletId, tokens)
override suspend fun store(userWalletId: UserWalletId, tokens: UserTokensResponse) {
store.store(userWalletId.stringValue, tokens)
}
}

View file

@ -1,13 +1,14 @@
package com.tangem.datasource.local.token
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
import com.tangem.domain.wallets.models.UserWalletId
import kotlinx.coroutines.flow.Flow
interface UserTokensStore {
fun get(userWalletId: String): Flow<UserTokensResponse>
fun get(userWalletId: UserWalletId): Flow<UserTokensResponse>
suspend fun getSyncOrNull(userWalletId: String): UserTokensResponse?
suspend fun getSyncOrNull(userWalletId: UserWalletId): UserTokensResponse?
suspend fun store(userWalletId: String, tokens: UserTokensResponse)
suspend fun store(userWalletId: UserWalletId, tokens: UserTokensResponse)
}