Updated on 2026-08-14
This commit is contained in:
parent
9a9c365735
commit
3ed4ba95cd
20 changed files with 78 additions and 15 deletions
|
|
@ -186,6 +186,7 @@ internal class DefaultNetworksRepository(
|
|||
is UpdateWalletManagerResult.NoAccount,
|
||||
-> Unit
|
||||
is UpdateWalletManagerResult.Unreachable,
|
||||
is UpdateWalletManagerResult.UnreachableWithoutAddresses,
|
||||
is UpdateWalletManagerResult.MissedDerivation,
|
||||
-> {
|
||||
Timber.w(
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@ internal class NetworkStatusFactory {
|
|||
network = network,
|
||||
value = when (result) {
|
||||
is UpdateWalletManagerResult.MissedDerivation -> NetworkStatus.MissedDerivation
|
||||
is UpdateWalletManagerResult.Unreachable -> NetworkStatus.Unreachable
|
||||
is UpdateWalletManagerResult.UnreachableWithoutAddresses -> NetworkStatus.UnreachableWithoutAddresses
|
||||
is UpdateWalletManagerResult.Unreachable -> NetworkStatus.Unreachable(
|
||||
address = getNetworkAddress(result.selectedAddress, result.addresses),
|
||||
)
|
||||
is UpdateWalletManagerResult.NoAccount -> NetworkStatus.NoAccount(
|
||||
address = getNetworkAddress(result.selectedAddress, result.addresses),
|
||||
amountToCreateAccount = result.amountToCreateAccount,
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class DefaultWalletManagersFacade(
|
|||
val walletManager = getOrCreateWalletManager(userWalletId, blockchain, derivationPath)
|
||||
if (walletManager == null || blockchain == Blockchain.Unknown) {
|
||||
Timber.w("Unable to get a wallet manager for blockchain: $blockchain")
|
||||
return UpdateWalletManagerResult.Unreachable
|
||||
return UpdateWalletManagerResult.UnreachableWithoutAddresses
|
||||
}
|
||||
|
||||
return getLastWalletManagerResult(walletManager)
|
||||
|
|
@ -248,7 +248,7 @@ class DefaultWalletManagersFacade(
|
|||
)
|
||||
if (walletManager == null || blockchain == Blockchain.Unknown) {
|
||||
Timber.w("Unable to get a wallet manager for blockchain: $blockchain")
|
||||
return UpdateWalletManagerResult.Unreachable
|
||||
return UpdateWalletManagerResult.UnreachableWithoutAddresses
|
||||
}
|
||||
|
||||
updateWalletManagerTokensIfNeeded(walletManager, extraTokens)
|
||||
|
|
@ -281,7 +281,7 @@ class DefaultWalletManagersFacade(
|
|||
} catch (e: Throwable) {
|
||||
Timber.w(e, "Unable to update a wallet manager for: ${walletManager.wallet.blockchain}")
|
||||
|
||||
UpdateWalletManagerResult.Unreachable
|
||||
resultFactory.getUnreachableResult(walletManager)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -293,7 +293,7 @@ class DefaultWalletManagersFacade(
|
|||
} catch (e: Throwable) {
|
||||
Timber.w(e, "Unable to update a wallet manager for: ${walletManager.wallet.blockchain}")
|
||||
|
||||
UpdateWalletManagerResult.Unreachable
|
||||
resultFactory.getUnreachableResult(walletManager)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,12 @@ sealed class UpdateWalletManagerResult {
|
|||
|
||||
object MissedDerivation : UpdateWalletManagerResult()
|
||||
|
||||
object Unreachable : UpdateWalletManagerResult()
|
||||
object UnreachableWithoutAddresses : UpdateWalletManagerResult()
|
||||
|
||||
data class Unreachable(
|
||||
val selectedAddress: String,
|
||||
val addresses: Set<Address>,
|
||||
) : UpdateWalletManagerResult()
|
||||
|
||||
data class Verified(
|
||||
val selectedAddress: String,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,10 @@ internal class UpdateWalletManagerResultFactory {
|
|||
|
||||
return if (amountToCreateAccount == null) {
|
||||
Timber.w("Unable to get required amount to create account for: $blockchain")
|
||||
UpdateWalletManagerResult.Unreachable
|
||||
UpdateWalletManagerResult.Unreachable(
|
||||
selectedAddress = wallet.address,
|
||||
addresses = getAvailableAddresses(wallet.addresses),
|
||||
)
|
||||
} else {
|
||||
UpdateWalletManagerResult.NoAccount(
|
||||
selectedAddress = wallet.address,
|
||||
|
|
@ -57,6 +60,15 @@ internal class UpdateWalletManagerResultFactory {
|
|||
}
|
||||
}
|
||||
|
||||
fun getUnreachableResult(walletManager: WalletManager): UpdateWalletManagerResult {
|
||||
val wallet = walletManager.wallet
|
||||
|
||||
return UpdateWalletManagerResult.Unreachable(
|
||||
selectedAddress = wallet.address,
|
||||
addresses = getAvailableAddresses(wallet.addresses),
|
||||
)
|
||||
}
|
||||
|
||||
private fun getTokensAmounts(amounts: Set<Amount>): Set<CryptoCurrencyAmount> {
|
||||
return amounts.mapNotNullTo(hashSetOf(), ::createCurrencyAmount)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,10 +50,19 @@ data class CryptoCurrencyStatus(
|
|||
/** Represents the Loading state of a cryptocurrency, typically while fetching its details. */
|
||||
object Loading : Status(isError = false)
|
||||
|
||||
/** Represents a state where the cryptocurrency is not reachable. */
|
||||
object UnreachableWithoutAddresses : Status(isError = true)
|
||||
|
||||
/**
|
||||
* Represents a state where the cryptocurrency is not reachable.
|
||||
*
|
||||
* @property priceChange The change in price of the cryptocurrency.
|
||||
* @property fiatRate The exchange rate used for converting the cryptocurrency amount to fiat.
|
||||
* @property networkAddress The network address
|
||||
*/
|
||||
data class Unreachable(
|
||||
override val priceChange: BigDecimal?,
|
||||
override val fiatRate: BigDecimal?,
|
||||
override val networkAddress: NetworkAddress,
|
||||
) : Status(isError = true)
|
||||
|
||||
/** Represents a state where the cryptocurrency's network amount not found. */
|
||||
|
|
|
|||
|
|
@ -21,10 +21,14 @@ data class NetworkStatus(
|
|||
*/
|
||||
sealed class Status
|
||||
|
||||
object UnreachableWithoutAddresses : Status()
|
||||
|
||||
/**
|
||||
* Represents the state where the network is unreachable.
|
||||
*
|
||||
* @property address Network addresses.
|
||||
*/
|
||||
object Unreachable : Status()
|
||||
data class Unreachable(val address: NetworkAddress) : Status()
|
||||
|
||||
/**
|
||||
* Represents the state where a derivation has been missed.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ internal class CurrencyStatusOperations(
|
|||
return when (val status = networkStatus?.value) {
|
||||
null -> CryptoCurrencyStatus.Loading
|
||||
is NetworkStatus.MissedDerivation -> createMissedDerivationStatus()
|
||||
is NetworkStatus.Unreachable -> createUnreachableStatus()
|
||||
is NetworkStatus.UnreachableWithoutAddresses -> CryptoCurrencyStatus.UnreachableWithoutAddresses
|
||||
is NetworkStatus.Unreachable -> createUnreachableStatus(status)
|
||||
is NetworkStatus.NoAccount -> createNoAccountStatus(status)
|
||||
is NetworkStatus.Verified -> createStatus(status)
|
||||
}
|
||||
|
|
@ -25,8 +26,13 @@ internal class CurrencyStatusOperations(
|
|||
private fun createMissedDerivationStatus(): CryptoCurrencyStatus.MissedDerivation =
|
||||
CryptoCurrencyStatus.MissedDerivation(priceChange = quote?.priceChange, fiatRate = quote?.fiatRate)
|
||||
|
||||
private fun createUnreachableStatus(): CryptoCurrencyStatus.Unreachable =
|
||||
CryptoCurrencyStatus.Unreachable(priceChange = quote?.priceChange, fiatRate = quote?.fiatRate)
|
||||
private fun createUnreachableStatus(status: NetworkStatus.Unreachable): CryptoCurrencyStatus.Unreachable {
|
||||
return CryptoCurrencyStatus.Unreachable(
|
||||
priceChange = quote?.priceChange,
|
||||
fiatRate = quote?.fiatRate,
|
||||
networkAddress = status.address,
|
||||
)
|
||||
}
|
||||
|
||||
private fun createNoAccountStatus(status: NetworkStatus.NoAccount): CryptoCurrencyStatus.NoAccount =
|
||||
CryptoCurrencyStatus.NoAccount(
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ internal class TokenListFiatBalanceOperations(
|
|||
}
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.UnreachableWithoutAddresses,
|
||||
is CryptoCurrencyStatus.NoAmount,
|
||||
is CryptoCurrencyStatus.NoQuote,
|
||||
-> {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ internal object MockNetworks {
|
|||
|
||||
val networkStatus1 = NetworkStatus(
|
||||
network = network1,
|
||||
value = NetworkStatus.Unreachable,
|
||||
value = NetworkStatus.UnreachableWithoutAddresses,
|
||||
)
|
||||
|
||||
val networkStatus2 = NetworkStatus(
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ internal object MockTokensStates {
|
|||
value = CryptoCurrencyStatus.Unreachable(
|
||||
priceChange = MockQuotes.quote1.priceChange,
|
||||
fiatRate = MockQuotes.quote1.fiatRate,
|
||||
networkAddress = NetworkAddress.Single(
|
||||
defaultAddress = NetworkAddress.Address(value = "mock", NetworkAddress.Address.Type.Primary),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -23,6 +26,9 @@ internal object MockTokensStates {
|
|||
value = CryptoCurrencyStatus.Unreachable(
|
||||
priceChange = MockQuotes.quote2.priceChange,
|
||||
fiatRate = MockQuotes.quote2.fiatRate,
|
||||
networkAddress = NetworkAddress.Single(
|
||||
defaultAddress = NetworkAddress.Address(value = "mock", NetworkAddress.Address.Type.Primary),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -31,6 +37,9 @@ internal object MockTokensStates {
|
|||
value = CryptoCurrencyStatus.Unreachable(
|
||||
priceChange = MockQuotes.quote3.priceChange,
|
||||
fiatRate = MockQuotes.quote3.fiatRate,
|
||||
networkAddress = NetworkAddress.Single(
|
||||
defaultAddress = NetworkAddress.Address(value = "mock", NetworkAddress.Address.Type.Primary),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ internal class TokenDetailsLoadedBalanceConverter(
|
|||
is CryptoCurrencyStatus.Loading -> TokenDetailsBalanceBlockState.Loading(currentState.actionButtons)
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.UnreachableWithoutAddresses,
|
||||
is CryptoCurrencyStatus.NoAmount,
|
||||
-> TokenDetailsBalanceBlockState.Error(currentState.actionButtons)
|
||||
}
|
||||
|
|
@ -101,6 +102,7 @@ internal class TokenDetailsLoadedBalanceConverter(
|
|||
is CryptoCurrencyStatus.Custom,
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.UnreachableWithoutAddresses,
|
||||
is CryptoCurrencyStatus.NoAmount,
|
||||
-> status.toContentConfig(currencySymbol)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ internal class WalletSingleCurrencyLoadedBalanceConverter(
|
|||
is CryptoCurrencyStatus.Custom,
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.UnreachableWithoutAddresses,
|
||||
is CryptoCurrencyStatus.NoQuote,
|
||||
-> MarketPriceBlockState.Error(currencySymbol)
|
||||
}
|
||||
|
|
@ -116,6 +117,7 @@ internal class WalletSingleCurrencyLoadedBalanceConverter(
|
|||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.Custom,
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.UnreachableWithoutAddresses,
|
||||
-> {
|
||||
WalletCardState.Error(
|
||||
id = selectedWallet.id,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ internal class SingleWalletCardStateConverter(
|
|||
is CryptoCurrencyStatus.Custom,
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.UnreachableWithoutAddresses,
|
||||
-> value.toErrorState()
|
||||
is CryptoCurrencyStatus.NoQuote,
|
||||
is CryptoCurrencyStatus.Loaded,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ internal class SingleWalletMarketPriceConverter(
|
|||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.NoQuote,
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.UnreachableWithoutAddresses,
|
||||
-> MarketPriceBlockState.Error(value.currencySymbol)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ internal class TokenItemStateConverter(
|
|||
-> value.mapToTokenItemState()
|
||||
is CryptoCurrencyStatus.MissedDerivation -> value.mapToNoAddressTokenItemState()
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.UnreachableWithoutAddresses,
|
||||
is CryptoCurrencyStatus.NoAmount,
|
||||
-> value.mapToUnreachableTokenItemState()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ internal class VisaWalletCardStateConverter(
|
|||
is CryptoCurrencyStatus.Custom,
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.UnreachableWithoutAddresses,
|
||||
-> value.toErrorState()
|
||||
is CryptoCurrencyStatus.NoQuote,
|
||||
is CryptoCurrencyStatus.Loaded,
|
||||
|
|
|
|||
|
|
@ -72,7 +72,9 @@ internal class PrimaryCurrencySubscriber(
|
|||
is CryptoCurrencyStatus.NoAmount,
|
||||
-> createCardBalanceState(fiatAmount)
|
||||
is CryptoCurrencyStatus.NoQuote -> AnalyticsParam.CardBalanceState.NoRate
|
||||
is CryptoCurrencyStatus.Unreachable -> AnalyticsParam.CardBalanceState.BlockchainError
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.UnreachableWithoutAddresses,
|
||||
-> AnalyticsParam.CardBalanceState.BlockchainError
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.Loading,
|
||||
is CryptoCurrencyStatus.Custom,
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ internal class CryptoCurrencyStatusToTokenItemConverter(
|
|||
-> value.mapToTokenItemState()
|
||||
is CryptoCurrencyStatus.MissedDerivation -> value.mapToNoAddressTokenItemState()
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.UnreachableWithoutAddresses,
|
||||
is CryptoCurrencyStatus.NoAmount,
|
||||
-> value.mapToUnreachableTokenItemState()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1222,7 +1222,9 @@ internal class WalletViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
is CryptoCurrencyStatus.NoQuote -> AnalyticsParam.CardBalanceState.NoRate
|
||||
is CryptoCurrencyStatus.Unreachable -> AnalyticsParam.CardBalanceState.BlockchainError
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.UnreachableWithoutAddresses,
|
||||
-> AnalyticsParam.CardBalanceState.BlockchainError
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.Loading,
|
||||
is CryptoCurrencyStatus.Custom,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue