Updated on 2026-08-14
This commit is contained in:
parent
5006ccd343
commit
f4755463b0
9 changed files with 42 additions and 19 deletions
|
|
@ -1,12 +1,17 @@
|
|||
package com.tangem.tap.network.auth
|
||||
|
||||
import com.tangem.datasource.local.preferences.AppPreferencesStore
|
||||
import com.tangem.datasource.local.preferences.PreferencesKeys
|
||||
import com.tangem.datasource.local.preferences.utils.getSyncOrDefault
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.lib.auth.ExpressAuthProvider
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
internal class DefaultExpressAuthProvider(
|
||||
private val userWalletsStore: UserWalletsStore,
|
||||
private val appPreferencesStore: AppPreferencesStore,
|
||||
) : ExpressAuthProvider {
|
||||
|
||||
private var uuid = AtomicReference(UUID.randomUUID())
|
||||
|
|
@ -18,4 +23,18 @@ internal class DefaultExpressAuthProvider(
|
|||
override fun getSessionId(): String {
|
||||
return uuid.get().toString()
|
||||
}
|
||||
|
||||
override fun getRefCode(): String {
|
||||
val addedWalletsWithRings = runBlocking {
|
||||
appPreferencesStore.getSyncOrDefault(
|
||||
key = PreferencesKeys.ADDED_WALLETS_WITH_RING_KEY,
|
||||
default = emptySet(),
|
||||
)
|
||||
}
|
||||
|
||||
val userWalletId = userWalletsStore.selectedUserWalletOrNull?.walletId?.stringValue
|
||||
?: error("No user id provided")
|
||||
|
||||
return if (addedWalletsWithRings.contains(userWalletId)) "ring" else ""
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.tangem.tap.network.auth.di
|
|||
|
||||
import com.tangem.datasource.api.common.AuthProvider
|
||||
import com.tangem.datasource.config.ConfigManager
|
||||
import com.tangem.datasource.local.preferences.AppPreferencesStore
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.lib.auth.ExpressAuthProvider
|
||||
import com.tangem.lib.auth.StakeKitAuthProvider
|
||||
|
|
@ -29,8 +30,14 @@ class AuthModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideExpressAuthProvider(userWalletsStore: UserWalletsStore): ExpressAuthProvider {
|
||||
return DefaultExpressAuthProvider(userWalletsStore = userWalletsStore)
|
||||
fun provideExpressAuthProvider(
|
||||
userWalletsStore: UserWalletsStore,
|
||||
appPreferencesStore: AppPreferencesStore,
|
||||
): ExpressAuthProvider {
|
||||
return DefaultExpressAuthProvider(
|
||||
userWalletsStore = userWalletsStore,
|
||||
appPreferencesStore = appPreferencesStore,
|
||||
)
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue