Updated on 2026-08-14
This commit is contained in:
parent
c153efaa88
commit
16bcc5c593
9 changed files with 130 additions and 6 deletions
|
|
@ -280,6 +280,8 @@ dependencies {
|
|||
implementation(tangemDeps.card.android) {
|
||||
exclude(module = "joda-time")
|
||||
}
|
||||
implementation(tangemDeps.hot.core)
|
||||
implementation(tangemDeps.hot.android)
|
||||
|
||||
/** DI */
|
||||
implementation(deps.hilt.android)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package com.tangem.tap.di.hot
|
||||
|
||||
import android.content.Context
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.tangem.hot.sdk.TangemHotSdk
|
||||
import com.tangem.hot.sdk.android.create
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.components.ActivityComponent
|
||||
import dagger.hilt.android.qualifiers.ActivityContext
|
||||
import dagger.hilt.android.scopes.ActivityScoped
|
||||
|
||||
@Module
|
||||
@InstallIn(ActivityComponent::class)
|
||||
internal object TangemHotSdkModule {
|
||||
|
||||
@Provides
|
||||
@ActivityScoped
|
||||
fun provideRootAppComponentContext(@ActivityContext context: Context): TangemHotSdk {
|
||||
return TangemHotSdk.create(context as AppCompatActivity)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.tangem.core.decompose.utils
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.arkivanov.essenty.instancekeeper.getOrCreateSimple
|
||||
import com.arkivanov.essenty.lifecycle.subscribe
|
||||
import com.tangem.core.decompose.context.AppComponentContext
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
class ActivityInstanceHolder<T : Any> {
|
||||
private var instance: T? = null
|
||||
|
||||
lateinit var instanceAccess: WeakReference<T>
|
||||
private set
|
||||
|
||||
fun set(instance: T) {
|
||||
this.instance = instance
|
||||
instanceAccess = WeakReference(instance)
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
instance = null
|
||||
instanceAccess.clear()
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified T : Any> AppComponentContext.getOrCreateActivityInstanceHolder(
|
||||
noinline factory: (AppCompatActivity) -> T,
|
||||
): ActivityInstanceHolder<T> {
|
||||
val holder = instanceKeeper.getOrCreateSimple {
|
||||
ActivityInstanceHolder<T>()
|
||||
}
|
||||
|
||||
lifecycle.subscribe(
|
||||
onCreate = {
|
||||
holder.set(factory(activity))
|
||||
},
|
||||
onDestroy = {
|
||||
holder.clear()
|
||||
},
|
||||
)
|
||||
|
||||
return holder
|
||||
}
|
||||
|
|
@ -26,6 +26,10 @@ dependencies {
|
|||
implementation(projects.core.navigation)
|
||||
implementation(projects.core.datasource)
|
||||
|
||||
/** Domain */
|
||||
implementation(projects.domain.wallets)
|
||||
implementation(projects.domain.wallets.models)
|
||||
|
||||
/** Common */
|
||||
implementation(projects.common.ui)
|
||||
implementation(projects.common.routing)
|
||||
|
|
@ -36,6 +40,8 @@ dependencies {
|
|||
implementation(tangemDeps.card.android) {
|
||||
exclude(module = "joda-time")
|
||||
}
|
||||
implementation(tangemDeps.hot.core)
|
||||
implementation(tangemDeps.hot.android)
|
||||
|
||||
/** AndroidX libraries */
|
||||
implementation(deps.androidx.core.ktx)
|
||||
|
|
|
|||
|
|
@ -2,19 +2,24 @@ package com.tangem.features.hotwallet.createmobilewallet
|
|||
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
import com.tangem.core.decompose.navigation.Router
|
||||
import com.tangem.features.hotwallet.createmobilewallet.entity.CreateMobileWalletUM
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
@ModelScoped
|
||||
internal class CreateMobileWalletModel @Inject constructor(
|
||||
override val dispatchers: CoroutineDispatcherProvider,
|
||||
private val router: Router,
|
||||
private val paramsContainer: ParamsContainer,
|
||||
) : Model() {
|
||||
|
||||
private val params = paramsContainer.require<DefaultCreateMobileWalletComponent.Params>()
|
||||
|
||||
internal val uiState: StateFlow<CreateMobileWalletUM>
|
||||
field = MutableStateFlow(
|
||||
CreateMobileWalletUM(
|
||||
|
|
@ -24,6 +29,16 @@ internal class CreateMobileWalletModel @Inject constructor(
|
|||
)
|
||||
|
||||
private fun onCreateClick() {
|
||||
// TODO create a wallet
|
||||
modelScope.launch {
|
||||
val tangemHotSdk = params.tangemHotSdk.instanceAccess.get() ?: return@launch
|
||||
// TODO
|
||||
// val hotWalletId = tangemHotSdk.generateWallet(HotAuth.NoAuth, mnemonicType = MnemonicType.Words12)
|
||||
// val hotUserWalletBuilder = hotUserWalletBuilderFactory.create(hotWalletId, tangemHotSdk)
|
||||
// saveUserWalletUseCase(
|
||||
// hotUserWalletBuilder.build(),
|
||||
// )
|
||||
|
||||
// router.push(AppRoute.Wallet)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,17 +6,28 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.tangem.core.decompose.context.AppComponentContext
|
||||
import com.tangem.core.decompose.model.getOrCreateModel
|
||||
import com.tangem.core.decompose.utils.ActivityInstanceHolder
|
||||
import com.tangem.core.decompose.utils.getOrCreateActivityInstanceHolder
|
||||
import com.tangem.features.hotwallet.CreateMobileWalletComponent
|
||||
import com.tangem.features.hotwallet.createmobilewallet.ui.CreateMobileWalletContent
|
||||
import com.tangem.hot.sdk.TangemHotSdk
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
|
||||
@Suppress("UnusedPrivateMember")
|
||||
internal class DefaultCreateMobileWalletComponent @AssistedInject constructor(
|
||||
@Assisted private val context: AppComponentContext,
|
||||
@Assisted private val params: Unit,
|
||||
private val tangemHotSdk: TangemHotSdk,
|
||||
) : CreateMobileWalletComponent, AppComponentContext by context {
|
||||
private val model: CreateMobileWalletModel = getOrCreateModel(params)
|
||||
|
||||
private val modelParams: Params =
|
||||
Params(
|
||||
tangemHotSdk = getOrCreateActivityInstanceHolder { tangemHotSdk },
|
||||
)
|
||||
|
||||
private val model: CreateMobileWalletModel = getOrCreateModel(modelParams)
|
||||
|
||||
@Composable
|
||||
override fun Content(modifier: Modifier) {
|
||||
|
|
@ -27,6 +38,10 @@ internal class DefaultCreateMobileWalletComponent @AssistedInject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
class Params(
|
||||
val tangemHotSdk: ActivityInstanceHolder<TangemHotSdk>,
|
||||
)
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory : CreateMobileWalletComponent.Factory {
|
||||
override fun create(context: AppComponentContext, params: Unit): DefaultCreateMobileWalletComponent
|
||||
|
|
|
|||
|
|
@ -7,24 +7,30 @@ import com.tangem.features.hotwallet.createmobilewallet.DefaultCreateMobileWalle
|
|||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.components.ActivityComponent
|
||||
import dagger.hilt.android.scopes.ActivityScoped
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import dagger.multibindings.ClassKey
|
||||
import dagger.multibindings.IntoMap
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
internal object CreateMobileWalletModule
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
internal interface CreateMobileWalletModuleBinds {
|
||||
@InstallIn(ActivityComponent::class)
|
||||
internal interface CreateMobileWalletModuleActivityBinds {
|
||||
|
||||
@Binds
|
||||
@Singleton
|
||||
@ActivityScoped
|
||||
fun bindCreateMobileWalletComponentFactory(
|
||||
impl: DefaultCreateMobileWalletComponent.Factory,
|
||||
): CreateMobileWalletComponent.Factory
|
||||
}
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
internal interface CreateMobileWalletModuleBinds {
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ tangemCardSdk = "develop-487"
|
|||
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^
|
||||
tangemVico = "2.0.0-alpha.25-tangem12"
|
||||
#tangemVico = "0.0.1" # Keep it! - used for local builds ^
|
||||
tangemHotSdk = "develop-438"
|
||||
#tangemHotSdk = "0.0.1" # Keep it! - used for local builds ^
|
||||
|
||||
|
||||
|
||||
|
|
@ -18,6 +20,8 @@ tangemVico = "2.0.0-alpha.25-tangem12"
|
|||
blockchain = { module = "com.tangem:blockchain", version.ref = "tangemBlockchainSdk" }
|
||||
card-android = { module = "com.tangem.tangem-sdk-kotlin:android", version.ref = "tangemCardSdk" }
|
||||
card-core = { module = "com.tangem.tangem-sdk-kotlin:core", version.ref = "tangemCardSdk" }
|
||||
hot-core = { module = "com.tangem.tangem-hot-sdk-kotlin:core", version.ref = "tangemHotSdk" }
|
||||
hot-android = { module = "com.tangem.tangem-hot-sdk-kotlin:android", version.ref = "tangemHotSdk" }
|
||||
|
||||
vico-compose = { group = "com.tangem.vico", name = "compose", version.ref = "tangemVico" }
|
||||
vico-compose-m3 = { group = "com.tangem.vico", name = "compose-m3", version.ref = "tangemVico" }
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ dependencyResolutionManagement {
|
|||
mavenLocal {
|
||||
content {
|
||||
includeGroupAndSubgroups("com.tangem.tangem-sdk-kotlin")
|
||||
includeGroupAndSubgroups("com.tangem.tangem-hot-sdk-kotlin")
|
||||
includeGroupAndSubgroups("com.tangem.vico")
|
||||
includeModule("com.tangem", "blstlib")
|
||||
includeModule("com.tangem", "blockchain")
|
||||
|
|
@ -54,6 +55,15 @@ dependencyResolutionManagement {
|
|||
}
|
||||
content { includeGroupAndSubgroups("com.tangem.tangem-sdk-kotlin") }
|
||||
}
|
||||
maven {
|
||||
// setting any repository from tangem project allows maven search all packages in the project
|
||||
url = uri("https://maven.pkg.github.com/tangem/tangem-hot-sdk-kotlin")
|
||||
credentials {
|
||||
username = properties.getProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR")
|
||||
password = properties.getProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
|
||||
}
|
||||
content { includeGroupAndSubgroups("com.tangem.tangem-hot-sdk-kotlin") }
|
||||
}
|
||||
maven {
|
||||
// setting any repository from tangem project allows maven search all packages in the project
|
||||
url = uri("https://maven.pkg.github.com/tangem/blst-android")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue