Updated on 2026-08-14
This commit is contained in:
commit
19df6fefae
194 changed files with 5193 additions and 1945 deletions
|
|
@ -137,6 +137,8 @@ private fun iconSetOf(blockchain: Blockchain): IconSet? = when (blockchain) {
|
|||
-> IconSet(active = R.drawable.img_flare_22, greyedOut = R.drawable.ic_flare_22)
|
||||
Blockchain.Gnosis,
|
||||
-> IconSet(active = R.drawable.img_gnosis_22, greyedOut = R.drawable.ic_gnosis_22)
|
||||
Blockchain.Gonka,
|
||||
-> IconSet(active = R.drawable.img_gonka_22, greyedOut = R.drawable.ic_gonka_22)
|
||||
Blockchain.Hedera,
|
||||
Blockchain.HederaTestnet,
|
||||
-> IconSet(active = R.drawable.img_hedera_22, greyedOut = R.drawable.ic_hedera_22)
|
||||
|
|
|
|||
|
|
@ -179,11 +179,15 @@ sealed class NotificationUM(val config: NotificationConfig) {
|
|||
subtitle = resourceReference(id = R.string.send_notification_invalid_reserve_amount_text),
|
||||
)
|
||||
|
||||
data class NetworkAccountNotFunded(val coinName: String) : Error(
|
||||
data class NetworkAccountNotFunded(
|
||||
val coinName: String,
|
||||
val reserveAmount: String,
|
||||
val reserveSymbol: String,
|
||||
) : Error(
|
||||
title = resourceReference(R.string.alert_failed_to_send_transaction_title),
|
||||
subtitle = resourceReference(
|
||||
id = R.string.no_account_generic,
|
||||
formatArgs = wrappedList(coinName),
|
||||
formatArgs = wrappedList(coinName, reserveAmount, reserveSymbol),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -191,6 +195,11 @@ sealed class NotificationUM(val config: NotificationConfig) {
|
|||
title = resourceReference(id = R.string.send_validation_destination_tag_required_title),
|
||||
subtitle = resourceReference(id = R.string.send_validation_destination_tag_required_description),
|
||||
)
|
||||
|
||||
data object RequiredTrustline : Error(
|
||||
title = resourceReference(id = R.string.common_error),
|
||||
subtitle = resourceReference(id = R.string.no_trustline_xlm_asset),
|
||||
)
|
||||
}
|
||||
|
||||
open class Warning(
|
||||
|
|
|
|||
|
|
@ -120,40 +120,66 @@ object NotificationsFactory {
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
fun MutableList<NotificationUM>.addReserveAmountErrorNotification(
|
||||
reserveAmount: BigDecimal?,
|
||||
sendingAmount: BigDecimal,
|
||||
cryptoCurrency: CryptoCurrency,
|
||||
feeCryptoCurrency: CryptoCurrency?,
|
||||
isAccountFunded: Boolean,
|
||||
hasRequiredTrustline: Boolean,
|
||||
) {
|
||||
val sendingCoinAmount = when (cryptoCurrency) {
|
||||
is CryptoCurrency.Coin -> sendingAmount
|
||||
is CryptoCurrency.Token -> BigDecimal.ZERO
|
||||
}
|
||||
|
||||
if (feeCryptoCurrency == null && cryptoCurrency is CryptoCurrency.Token) {
|
||||
when {
|
||||
// No need to show reserve amount warning if fee currency is unknown for token transfer
|
||||
return
|
||||
} else if (!isAccountFunded && reserveAmount != null && reserveAmount > sendingCoinAmount) {
|
||||
feeCryptoCurrency == null && cryptoCurrency is CryptoCurrency.Token -> Unit
|
||||
// account not funded, sending coin amount < reserve (send coin with less amount OR send any token)
|
||||
!isAccountFunded && reserveAmount != null && reserveAmount > sendingCoinAmount ->
|
||||
addAccountNotFundedNotification(
|
||||
reserveAmount = reserveAmount,
|
||||
cryptoCurrency = cryptoCurrency,
|
||||
feeCryptoCurrency = feeCryptoCurrency,
|
||||
)
|
||||
hasRequiredTrustline -> addTrustlineRequiredNotification()
|
||||
}
|
||||
}
|
||||
|
||||
if (cryptoCurrency is CryptoCurrency.Coin) {
|
||||
// Try to send coin amount less than reserve amount (e.g. less than 1 XLM in Stellar)
|
||||
private fun MutableList<NotificationUM>.addAccountNotFundedNotification(
|
||||
reserveAmount: BigDecimal,
|
||||
cryptoCurrency: CryptoCurrency,
|
||||
feeCryptoCurrency: CryptoCurrency?,
|
||||
) {
|
||||
when (cryptoCurrency) {
|
||||
// Try to send coin amount less than reserve amount (e.g. less than 1 XLM in Stellar)
|
||||
is CryptoCurrency.Coin -> add(
|
||||
NotificationUM.Error.ReserveAmount(
|
||||
reserveAmount.format {
|
||||
crypto(feeCryptoCurrency ?: cryptoCurrency)
|
||||
},
|
||||
),
|
||||
)
|
||||
// Try to send any token (e.g. USDC in Stellar, but account not funded -> user must send XLM at first)
|
||||
is CryptoCurrency.Token -> {
|
||||
checkNotNull(feeCryptoCurrency)
|
||||
add(
|
||||
NotificationUM.Error.ReserveAmount(
|
||||
reserveAmount.format {
|
||||
crypto(feeCryptoCurrency ?: cryptoCurrency)
|
||||
NotificationUM.Error.NetworkAccountNotFunded(
|
||||
coinName = feeCryptoCurrency.name,
|
||||
reserveAmount = reserveAmount.format {
|
||||
crypto(symbol = "", decimals = feeCryptoCurrency.decimals)
|
||||
},
|
||||
reserveSymbol = feeCryptoCurrency.symbol,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
checkNotNull(feeCryptoCurrency)
|
||||
// Try to send any token (e.g. USDC in Stellar, but account not funded -> user must send XLM at first)
|
||||
add(NotificationUM.Error.NetworkAccountNotFunded(coinName = feeCryptoCurrency.name))
|
||||
}
|
||||
}
|
||||
// TODO: check the RECEIVER account trustline before sending
|
||||
}
|
||||
|
||||
private fun MutableList<NotificationUM>.addTrustlineRequiredNotification() {
|
||||
add(NotificationUM.Error.RequiredTrustline)
|
||||
}
|
||||
|
||||
fun MutableList<NotificationUM>.addMinimumAmountErrorNotification(
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ internal class BlockchainIconsTest {
|
|||
Blockchain.Filecoin -> R.drawable.img_filecoin_22
|
||||
Blockchain.Flare, Blockchain.FlareTestnet -> R.drawable.img_flare_22
|
||||
Blockchain.Gnosis -> R.drawable.img_gnosis_22
|
||||
Blockchain.Gonka -> R.drawable.img_gonka_22
|
||||
Blockchain.Hedera, Blockchain.HederaTestnet -> R.drawable.img_hedera_22
|
||||
Blockchain.Hyperliquid, Blockchain.HyperliquidTestnet -> R.drawable.img_hyperliquid_22
|
||||
Blockchain.InternetComputer -> R.drawable.img_icp_22
|
||||
|
|
@ -198,6 +199,7 @@ internal class BlockchainIconsTest {
|
|||
Blockchain.Filecoin -> R.drawable.ic_filecoin_22
|
||||
Blockchain.Flare, Blockchain.FlareTestnet -> R.drawable.ic_flare_22
|
||||
Blockchain.Gnosis -> R.drawable.ic_gnosis_22
|
||||
Blockchain.Gonka -> R.drawable.ic_gonka_22
|
||||
Blockchain.Hedera, Blockchain.HederaTestnet -> R.drawable.ic_hedera_22
|
||||
Blockchain.Hyperliquid, Blockchain.HyperliquidTestnet -> R.drawable.ic_hyperliquid_22
|
||||
Blockchain.InternetComputer -> R.drawable.ic_icp_22
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue