Updated on 2026-08-14
This commit is contained in:
parent
586f0b33e9
commit
bd6223010a
1 changed files with 35 additions and 30 deletions
|
|
@ -138,36 +138,7 @@ class TapWalletManager {
|
|||
private suspend fun loadMultiWalletData(
|
||||
scanResponse: ScanResponse,
|
||||
) {
|
||||
when (val tokensResult = userTokensRepository.getUserTokens(scanResponse.card)) {
|
||||
is Result.Success -> {
|
||||
withMainContext {
|
||||
val blockchainNetworks = tokensResult.data.toBlockchainNetworks()
|
||||
val walletManagers = walletManagerFactory.makeWalletManagersForApp(scanResponse, tokensResult.data)
|
||||
store.dispatch(
|
||||
WalletAction.MultiWallet.AddBlockchains(
|
||||
blockchains = blockchainNetworks,
|
||||
walletManagers = walletManagers,
|
||||
save = false,
|
||||
),
|
||||
)
|
||||
|
||||
blockchainNetworks.filter { it.tokens.isNotEmpty() }
|
||||
.map {
|
||||
store.dispatch(
|
||||
WalletAction.MultiWallet.AddTokens(
|
||||
tokens = it.tokens,
|
||||
blockchain = it,
|
||||
save = false,
|
||||
),
|
||||
)
|
||||
}
|
||||
checkIfDerivationsAreMissing(blockchainNetworks, scanResponse)
|
||||
}
|
||||
}
|
||||
is Result.Failure -> {
|
||||
return
|
||||
}
|
||||
}
|
||||
loadUserCurrencies(scanResponse, walletManagerFactory)
|
||||
}
|
||||
|
||||
private fun checkIfDerivationsAreMissing(blockchainNetworks: List<BlockchainNetwork>, scanResponse: ScanResponse) {
|
||||
|
|
@ -207,7 +178,41 @@ class TapWalletManager {
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun loadUserCurrencies(scanResponse: ScanResponse, walletManagerFactory: WalletManagerFactory) {
|
||||
when (val tokensResult = userTokensRepository.getUserTokens(scanResponse.card)) {
|
||||
is Result.Success -> {
|
||||
withMainContext {
|
||||
val blockchainNetworks = tokensResult.data.toBlockchainNetworks()
|
||||
val walletManagers = walletManagerFactory.makeWalletManagersForApp(scanResponse, tokensResult.data)
|
||||
store.dispatch(
|
||||
WalletAction.MultiWallet.AddBlockchains(
|
||||
blockchains = blockchainNetworks,
|
||||
walletManagers = walletManagers,
|
||||
save = false,
|
||||
),
|
||||
)
|
||||
|
||||
blockchainNetworks.filter { it.tokens.isNotEmpty() }
|
||||
.map {
|
||||
store.dispatch(
|
||||
WalletAction.MultiWallet.AddTokens(
|
||||
tokens = it.tokens,
|
||||
blockchain = it,
|
||||
save = false,
|
||||
),
|
||||
)
|
||||
}
|
||||
checkIfDerivationsAreMissing(blockchainNetworks, scanResponse)
|
||||
}
|
||||
}
|
||||
is Result.Failure -> {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun reloadData(data: ScanResponse) {
|
||||
loadUserCurrencies(data, walletManagerFactory)
|
||||
withContext(Dispatchers.Main) {
|
||||
getActionIfUnknownBlockchainOrEmptyWallet(data)?.let {
|
||||
store.dispatch(it)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue