Updated on 2026-08-14
This commit is contained in:
parent
27e9400b2a
commit
b38ebb3995
16 changed files with 196 additions and 71 deletions
|
|
@ -59,7 +59,7 @@ import java.util.EnumSet
|
|||
import java.util.concurrent.ConcurrentHashMap
|
||||
import javax.inject.Inject
|
||||
|
||||
@Suppress("LargeClass", "TooManyFunctions")
|
||||
@Suppress("LargeClass", "TooManyFunctions", "LongParameterList")
|
||||
internal class DefaultWalletManagersFacade @Inject constructor(
|
||||
private val walletManagersStore: WalletManagersStore,
|
||||
private val userWalletsListRepository: UserWalletsListRepository,
|
||||
|
|
@ -85,6 +85,7 @@ internal class DefaultWalletManagersFacade @Inject constructor(
|
|||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
extraTokens: Set<CryptoCurrency.Token>,
|
||||
xpub: String?,
|
||||
): UpdateWalletManagerResult {
|
||||
val userWallet = getUserWallet(userWalletId)
|
||||
val blockchain = network.toBlockchain()
|
||||
|
|
@ -95,6 +96,7 @@ internal class DefaultWalletManagersFacade @Inject constructor(
|
|||
blockchain = blockchain,
|
||||
derivationPath = derivationPath,
|
||||
extraTokens = extraTokens,
|
||||
xpub = xpub,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -309,6 +311,7 @@ internal class DefaultWalletManagersFacade @Inject constructor(
|
|||
blockchain: Blockchain,
|
||||
derivationPath: String?,
|
||||
extraTokens: Set<CryptoCurrency.Token>,
|
||||
xpub: String? = null,
|
||||
): UpdateWalletManagerResult {
|
||||
if (derivationPath != null && !userWallet.hasDerivation(blockchain, derivationPath)) {
|
||||
TangemLogger.w("Derivation missed for: $blockchain")
|
||||
|
|
@ -326,6 +329,7 @@ internal class DefaultWalletManagersFacade @Inject constructor(
|
|||
}
|
||||
|
||||
val isUpdated = updateWalletManagerTokensIfNeeded(walletManager, extraTokens)
|
||||
if (xpub != null) restoreXpubModeIfNeeded(walletManager, xpub)
|
||||
|
||||
return try {
|
||||
if (userWallet is UserWallet.Cold && demoConfig.isDemoCardId(userWallet.scanResponse.card.cardId)) {
|
||||
|
|
@ -499,6 +503,17 @@ internal class DefaultWalletManagersFacade @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun restoreXpubModeIfNeeded(walletManager: WalletManager, xpub: String) {
|
||||
val dynamicAddressesManager = walletManager as? DynamicAddressesManager ?: return
|
||||
|
||||
try {
|
||||
dynamicAddressesManager.enableDynamicAddresses(xpub)
|
||||
TangemLogger.i("Restored XPUB mode for ${walletManager.wallet.blockchain}")
|
||||
} catch (e: Exception) {
|
||||
TangemLogger.e("Failed to restore XPUB mode: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
// endregion Dynamic Addresses
|
||||
|
||||
@Deprecated("Will be removed in future")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue