Updated on 2026-08-14
This commit is contained in:
parent
f893da0fb9
commit
9a02d6a58a
11 changed files with 36 additions and 19 deletions
|
|
@ -26,6 +26,7 @@ internal class NetworkStatusFactory {
|
|||
is UpdateWalletManagerResult.NoAccount -> NetworkStatus.NoAccount(
|
||||
address = getNetworkAddress(result.defaultAddress, result.addresses),
|
||||
amountToCreateAccount = result.amountToCreateAccount,
|
||||
errorMessage = result.errorMessage,
|
||||
)
|
||||
is UpdateWalletManagerResult.Verified -> NetworkStatus.Verified(
|
||||
address = getNetworkAddress(result.defaultAddress, result.addresses),
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ class DefaultWalletManagersFacade(
|
|||
|
||||
resultFactory.getResult(walletManager)
|
||||
} catch (e: BlockchainSdkError.AccountNotFound) {
|
||||
resultFactory.getNoAccountResult(walletManager)
|
||||
resultFactory.getNoAccountResult(walletManager = walletManager, customMessage = e.customMessage)
|
||||
} catch (e: Throwable) {
|
||||
Timber.w(e, "Unable to update a wallet manager for: ${walletManager.wallet.blockchain}")
|
||||
|
||||
|
|
|
|||
|
|
@ -19,5 +19,6 @@ sealed class UpdateWalletManagerResult {
|
|||
val defaultAddress: String,
|
||||
val addresses: Set<String>,
|
||||
val amountToCreateAccount: BigDecimal,
|
||||
val errorMessage: String,
|
||||
) : UpdateWalletManagerResult()
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ internal class UpdateWalletManagerResultFactory {
|
|||
)
|
||||
}
|
||||
|
||||
fun getNoAccountResult(walletManager: WalletManager): UpdateWalletManagerResult {
|
||||
fun getNoAccountResult(walletManager: WalletManager, customMessage: String): UpdateWalletManagerResult {
|
||||
val wallet = walletManager.wallet
|
||||
val blockchain = wallet.blockchain
|
||||
val firstWalletToken = wallet.getTokens().firstOrNull()
|
||||
|
|
@ -51,6 +51,7 @@ internal class UpdateWalletManagerResultFactory {
|
|||
defaultAddress = wallet.address,
|
||||
addresses = getAvailableAddresses(wallet.addresses),
|
||||
amountToCreateAccount = amountToCreateAccount,
|
||||
errorMessage = customMessage,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,8 +59,18 @@ data class CryptoCurrencyStatus(
|
|||
/** Represents a state where the cryptocurrency's derivation is missed. */
|
||||
object MissedDerivation : Status(isError = true)
|
||||
|
||||
/** Represents a state where there is no account associated with the cryptocurrency. */
|
||||
object NoAccount : Status(isError = false)
|
||||
/**
|
||||
* Represents a state where there is no account associated with the cryptocurrency
|
||||
*
|
||||
* @property errorMessage error message
|
||||
*/
|
||||
data class NoAccount(val errorMessage: String) : Status(isError = false) {
|
||||
|
||||
override val amount: BigDecimal = BigDecimal.ZERO
|
||||
override val fiatAmount: BigDecimal = BigDecimal.ZERO
|
||||
override val fiatRate: BigDecimal = BigDecimal.ZERO
|
||||
override val priceChange: BigDecimal = BigDecimal.ZERO
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Loaded state of a cryptocurrency with complete information.
|
||||
|
|
|
|||
|
|
@ -51,9 +51,11 @@ data class NetworkStatus(
|
|||
*
|
||||
* @property address Network addresses.
|
||||
* @property amountToCreateAccount The amount required to create an account within the network.
|
||||
* @property errorMessage error message
|
||||
*/
|
||||
data class NoAccount(
|
||||
val address: NetworkAddress,
|
||||
val amountToCreateAccount: BigDecimal,
|
||||
val errorMessage: String,
|
||||
) : Status()
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ internal class CurrencyStatusOperations(
|
|||
null -> CryptoCurrencyStatus.Loading
|
||||
is NetworkStatus.MissedDerivation -> CryptoCurrencyStatus.MissedDerivation
|
||||
is NetworkStatus.Unreachable -> CryptoCurrencyStatus.Unreachable
|
||||
is NetworkStatus.NoAccount -> CryptoCurrencyStatus.NoAccount
|
||||
is NetworkStatus.NoAccount -> CryptoCurrencyStatus.NoAccount(errorMessage = status.errorMessage)
|
||||
is NetworkStatus.Verified -> createStatus(status)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ internal object MockNetworks {
|
|||
value = NetworkStatus.NoAccount(
|
||||
amountToCreateAccount = amountToCreateAccount,
|
||||
address = NetworkAddress.Single(defaultAddress = "mock"),
|
||||
errorMessage = "",
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -39,22 +39,22 @@ internal object MockTokensStates {
|
|||
|
||||
val tokenState7 = CryptoCurrencyStatus(
|
||||
currency = MockTokens.token7,
|
||||
value = CryptoCurrencyStatus.NoAccount,
|
||||
value = CryptoCurrencyStatus.NoAccount(errorMessage = ""),
|
||||
)
|
||||
|
||||
val tokenState8 = CryptoCurrencyStatus(
|
||||
currency = MockTokens.token8,
|
||||
value = CryptoCurrencyStatus.NoAccount,
|
||||
value = CryptoCurrencyStatus.NoAccount(errorMessage = ""),
|
||||
)
|
||||
|
||||
val tokenState9 = CryptoCurrencyStatus(
|
||||
currency = MockTokens.token9,
|
||||
value = CryptoCurrencyStatus.NoAccount,
|
||||
value = CryptoCurrencyStatus.NoAccount(errorMessage = ""),
|
||||
)
|
||||
|
||||
val tokenState10 = CryptoCurrencyStatus(
|
||||
currency = MockTokens.token10,
|
||||
value = CryptoCurrencyStatus.NoAccount,
|
||||
value = CryptoCurrencyStatus.NoAccount(errorMessage = ""),
|
||||
)
|
||||
|
||||
val failedTokenStates = nonEmptyListOf(
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ internal class CryptoCurrencyStatusToTokenItemConverter(
|
|||
is CryptoCurrencyStatus.Loaded,
|
||||
is CryptoCurrencyStatus.Custom,
|
||||
is CryptoCurrencyStatus.NoQuote,
|
||||
is CryptoCurrencyStatus.NoAccount,
|
||||
-> value.mapToTokenItemState()
|
||||
// TODO: Add other token item states, currently not designed
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.NoAccount,
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.NoAmount,
|
||||
-> value.mapToUnreachableTokenItemState()
|
||||
|
|
|
|||
|
|
@ -159,13 +159,10 @@ internal class WalletNotificationsListFactory(
|
|||
condition = cryptoCurrencyList.hasUnreachableNetworks(),
|
||||
)
|
||||
|
||||
// TODO: [REDACTED_JIRA]
|
||||
addIf(
|
||||
element = WalletNotification.Warning.TopUpNote(
|
||||
errorMessage = "To activate card top up it with at least 1 XLM",
|
||||
),
|
||||
condition = cryptoCurrencyList.hasNoAccountStatus(),
|
||||
)
|
||||
val errorMessage = cryptoCurrencyList.geNoAccountStatusMessage()
|
||||
if (errorMessage != null) {
|
||||
add(element = WalletNotification.Warning.TopUpNote(errorMessage = errorMessage))
|
||||
}
|
||||
|
||||
addIf(
|
||||
element = WalletNotification.Warning.NumberOfSignedHashesIncorrect,
|
||||
|
|
@ -182,8 +179,12 @@ internal class WalletNotificationsListFactory(
|
|||
return any { it.value is CryptoCurrencyStatus.Unreachable }
|
||||
}
|
||||
|
||||
private fun List<CryptoCurrencyStatus>.hasNoAccountStatus(): Boolean {
|
||||
return any { it.value is CryptoCurrencyStatus.NoAccount }
|
||||
private fun List<CryptoCurrencyStatus>.geNoAccountStatusMessage(): String? {
|
||||
return this
|
||||
.map(CryptoCurrencyStatus::value)
|
||||
.filterIsInstance<CryptoCurrencyStatus.NoAccount>()
|
||||
.firstOrNull()
|
||||
?.errorMessage
|
||||
}
|
||||
|
||||
private fun checkSignedHashes(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue