Updated on 2026-08-14
This commit is contained in:
parent
4b5adcd08a
commit
5ed381c263
56 changed files with 631 additions and 455 deletions
|
|
@ -54,7 +54,6 @@ internal class TokensListMigration(
|
|||
}
|
||||
is Either.Right -> {
|
||||
currentUserWallet = selectedWalletEither.value
|
||||
val derivationStyle = currentUserWallet.scanResponse.derivationStyleProvider.getDerivationStyle()
|
||||
|
||||
when (val currenciesEither = getCurrenciesUseCase(userWalletId = selectedWalletEither.value.walletId)) {
|
||||
is Either.Left -> {
|
||||
|
|
@ -65,7 +64,7 @@ internal class TokensListMigration(
|
|||
TokensListCryptoCurrencies(
|
||||
coins = currenciesEither.value
|
||||
.filterIsInstance<CryptoCurrency.Coin>()
|
||||
.filterNot { it.isCustomCurrency(derivationStyle) }
|
||||
.filterNot { it.isCustom }
|
||||
.also { currentNewCoins = it }
|
||||
.map { Blockchain.fromId(it.network.id.value) },
|
||||
tokens = currenciesEither.value
|
||||
|
|
@ -91,12 +90,6 @@ internal class TokensListMigration(
|
|||
}
|
||||
}
|
||||
|
||||
private fun CryptoCurrency.Coin.isCustomCurrency(derivationStyle: DerivationStyle?): Boolean {
|
||||
if (derivationPath == null || derivationStyle == null) return false
|
||||
|
||||
return derivationPath != Blockchain.fromId(network.id.value).derivationPath(derivationStyle)?.rawPath
|
||||
}
|
||||
|
||||
private fun getLegacyCryptoCurrencies(): TokensListCryptoCurrencies {
|
||||
val wallets = store.state.walletState.walletsDataFromStores
|
||||
val derivationStyle = store.state.globalState.scanResponse?.derivationStyleProvider?.getDerivationStyle()
|
||||
|
|
@ -157,12 +150,14 @@ internal class TokensListMigration(
|
|||
cryptoCurrencyFactory.createToken(
|
||||
sdkToken = it.token,
|
||||
blockchain = it.blockchain,
|
||||
extraDerivationPath = null,
|
||||
derivationStyleProvider = currentUserWallet.scanResponse.derivationStyleProvider,
|
||||
)
|
||||
},
|
||||
changedCoins = changedBlockchainList.mapNotNull {
|
||||
cryptoCurrencyFactory.createCoin(
|
||||
blockchain = it,
|
||||
extraDerivationPath = null,
|
||||
derivationStyleProvider = currentUserWallet.scanResponse.derivationStyleProvider,
|
||||
)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ object TokensMiddleware {
|
|||
|
||||
val customTokensCandidates = currencyList
|
||||
.filter { Blockchain.fromId(it.network.id.value).getSupportedCurves().contains(curve) }
|
||||
.mapNotNull(CryptoCurrency::derivationPath)
|
||||
.mapNotNull { it.network.derivationPath.value }
|
||||
.map(::DerivationPath)
|
||||
|
||||
val bothCandidates = (manageTokensCandidates + customTokensCandidates).distinct().toMutableList()
|
||||
|
|
@ -306,7 +306,7 @@ object TokensMiddleware {
|
|||
|
||||
currencyList.find { it is CryptoCurrency.Coin && Blockchain.fromId(it.network.id.value) == Blockchain.Cardano }
|
||||
?.let { currency ->
|
||||
currency.derivationPath?.let {
|
||||
currency.network.derivationPath.value?.let {
|
||||
bothCandidates.add(CardanoUtils.extendedDerivationPath(DerivationPath(it)))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ internal class CryptoCurrencyConverter : TwoWayConverter<Currency, CryptoCurrenc
|
|||
is Currency.Blockchain -> requireNotNull(
|
||||
cryptoCurrencyFactory.createCoin(
|
||||
blockchain = value.blockchain,
|
||||
extraDerivationPath = value.derivationPath,
|
||||
derivationStyleProvider = requireNotNull(
|
||||
store.state.globalState
|
||||
.userWalletsListManager
|
||||
|
|
@ -31,6 +32,7 @@ internal class CryptoCurrencyConverter : TwoWayConverter<Currency, CryptoCurrenc
|
|||
cryptoCurrencyFactory.createToken(
|
||||
sdkToken = value.token,
|
||||
blockchain = value.blockchain,
|
||||
extraDerivationPath = value.derivationPath,
|
||||
derivationStyleProvider = requireNotNull(
|
||||
store.state.globalState
|
||||
.userWalletsListManager
|
||||
|
|
@ -49,7 +51,7 @@ internal class CryptoCurrencyConverter : TwoWayConverter<Currency, CryptoCurrenc
|
|||
return when (value) {
|
||||
is CryptoCurrency.Coin -> Currency.Blockchain(
|
||||
blockchain = blockchain,
|
||||
derivationPath = value.derivationPath,
|
||||
derivationPath = value.network.derivationPath.value,
|
||||
)
|
||||
is CryptoCurrency.Token -> Currency.Token(
|
||||
token = Token(
|
||||
|
|
@ -60,7 +62,7 @@ internal class CryptoCurrencyConverter : TwoWayConverter<Currency, CryptoCurrenc
|
|||
id = value.id.value,
|
||||
),
|
||||
blockchain = blockchain,
|
||||
derivationPath = value.derivationPath,
|
||||
derivationPath = value.network.derivationPath.value,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import com.tangem.core.navigation.AppScreen
|
|||
import com.tangem.core.navigation.NavigationAction
|
||||
import com.tangem.domain.common.extensions.toCoinId
|
||||
import com.tangem.domain.common.extensions.toNetworkId
|
||||
import com.tangem.domain.common.util.derivationStyleProvider
|
||||
import com.tangem.domain.tokens.legacy.TradeCryptoAction
|
||||
import com.tangem.domain.tokens.models.CryptoCurrency
|
||||
import com.tangem.feature.swap.presentation.SwapFragment
|
||||
|
|
@ -128,9 +127,7 @@ class TradeCryptoMiddleware {
|
|||
.getOrCreateWalletManager(
|
||||
userWallet = action.userWallet,
|
||||
blockchain = blockchain,
|
||||
derivationPath = blockchain.derivationPath(
|
||||
style = action.userWallet.scanResponse.derivationStyleProvider.getDerivationStyle(),
|
||||
),
|
||||
derivationPath = currency.network.derivationPath.value,
|
||||
)
|
||||
|
||||
if (walletManager !is EthereumWalletManager) {
|
||||
|
|
@ -317,9 +314,7 @@ class TradeCryptoMiddleware {
|
|||
.getOrCreateWalletManager(
|
||||
userWallet = action.userWallet,
|
||||
blockchain = blockchain,
|
||||
derivationPath = blockchain.derivationPath(
|
||||
style = action.userWallet.scanResponse.derivationStyleProvider.getDerivationStyle(),
|
||||
),
|
||||
derivationPath = currency.network.derivationPath.value,
|
||||
)
|
||||
|
||||
if (walletManager == null) {
|
||||
|
|
@ -360,9 +355,7 @@ class TradeCryptoMiddleware {
|
|||
.getOrCreateWalletManager(
|
||||
userWallet = action.userWallet,
|
||||
blockchain = blockchain,
|
||||
derivationPath = blockchain.derivationPath(
|
||||
style = action.userWallet.scanResponse.derivationStyleProvider.getDerivationStyle(),
|
||||
),
|
||||
derivationPath = currency.network.derivationPath.value,
|
||||
)
|
||||
|
||||
if (walletManager == null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue