Skip to content

Commit

Permalink
Fix stopping ethereum-kit
Browse files Browse the repository at this point in the history
  • Loading branch information
abdrasulov committed Sep 30, 2024
1 parent 09b0c4a commit 459b73f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ class NftAdapterManager(

@Synchronized
private fun initAdapters(wallets: List<Wallet>) {
val currentAdapters = adaptersMap.toMap()
val currentAdapters = adaptersMap.toMutableMap()
adaptersMap.clear()

val nftKeys = wallets.map { NftKey(it.account, it.token.blockchainType) }.distinct()

for (nftKey in nftKeys) {
if (nftKey.blockchainType.supportedNftTypes.isEmpty()) continue

val adapter = currentAdapters[nftKey]
val adapter = currentAdapters.remove(nftKey)

if (adapter != null) {
adaptersMap[nftKey] = adapter
Expand All @@ -70,6 +70,10 @@ class NftAdapterManager(
}
}

currentAdapters.forEach { (nftKey, _) ->
evmBlockchainManager.getEvmKitManager(nftKey.blockchainType).unlink(nftKey.account)
}

_adaptersUpdatedFlow.update { adaptersMap.toMap() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,13 @@ private fun getFactory(nftUidString: String): SendNftModule.Factory? {

val evmNftRecord = (nftRecord as? EvmNftRecord) ?: return null

val evmKitWrapper = App.evmBlockchainManager
.getEvmKitManager(nftUid.blockchainType)
.getEvmKitWrapper(account, nftUid.blockchainType)

return SendNftModule.Factory(
evmNftRecord,
nftUid,
nftRecord.balance,
adapter,
SendEvmAddressService(),
App.nftMetadataManager,
evmKitWrapper
App.nftMetadataManager
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package io.horizontalsystems.bankwallet.modules.nft.send
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import io.horizontalsystems.bankwallet.core.adapters.nft.INftAdapter
import io.horizontalsystems.bankwallet.core.managers.EvmKitWrapper
import io.horizontalsystems.bankwallet.core.managers.NftMetadataManager
import io.horizontalsystems.bankwallet.core.utils.AddressUriParser
import io.horizontalsystems.bankwallet.entities.DataState
Expand All @@ -21,8 +20,7 @@ object SendNftModule {
val nftBalance: Int,
private val adapter: INftAdapter,
private val sendEvmAddressService: SendEvmAddressService,
private val nftMetadataManager: NftMetadataManager,
private val evmKitWrapper: EvmKitWrapper
private val nftMetadataManager: NftMetadataManager
) : ViewModelProvider.Factory {

override fun <T : ViewModel> create(modelClass: Class<T>): T {
Expand Down

0 comments on commit 459b73f

Please sign in to comment.