Updated on 2026-08-14
This commit is contained in:
commit
e2e4b1a347
5 changed files with 69 additions and 72 deletions
|
|
@ -76,7 +76,7 @@ dependencies {
|
|||
implementation 'com.google.android.play:core-ktx:1.8.1'
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
|
||||
|
||||
implementation 'com.tangem:blockchain:develop-46'
|
||||
implementation 'com.tangem:blockchain:develop-47'
|
||||
implementation 'com.tangem.tangem-sdk-kotlin:core:develop-95'
|
||||
implementation 'com.tangem.tangem-sdk-kotlin:android:develop-95'
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import com.tangem.tap.network.coinmarketcap.CoinMarketCapService
|
|||
import com.tangem.tap.store
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import timber.log.Timber
|
||||
import java.math.BigDecimal
|
||||
|
||||
|
||||
|
|
@ -55,7 +54,6 @@ class TapWalletManager {
|
|||
}
|
||||
|
||||
suspend fun loadFiatRate(fiatCurrency: FiatCurrencyName, wallet: Wallet) {
|
||||
Timber.d(wallet.getTokens().toString())
|
||||
val currencies = wallet.getTokens()
|
||||
.map { Currency.Token(it) }
|
||||
.plus(Currency.Blockchain(wallet.blockchain))
|
||||
|
|
@ -121,7 +119,6 @@ class TapWalletManager {
|
|||
return@withContext
|
||||
}
|
||||
|
||||
val config = store.state.globalState.configManager?.config ?: return@withContext
|
||||
val blockchain = data.getBlockchain()
|
||||
val primaryWalletManager = walletManagerFactory.makePrimaryWalletManager(data)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import com.tangem.blockchain.common.AmountType
|
|||
import com.tangem.blockchain.common.Wallet
|
||||
import com.tangem.tap.common.extensions.scaleToFiat
|
||||
import com.tangem.tap.common.extensions.stripZeroPlainString
|
||||
import com.tangem.tap.domain.getFirstToken
|
||||
import com.tangem.tap.features.send.redux.ReceiptAction.RefreshReceipt
|
||||
import com.tangem.tap.features.send.redux.SendScreenAction
|
||||
import com.tangem.tap.features.send.redux.states.*
|
||||
|
|
@ -40,15 +39,15 @@ class ReceiptReducer : SendInternalReducer {
|
|||
val wallet = sendState.walletManager?.wallet ?: return sendState
|
||||
|
||||
val layoutType = determineLayoutType(amountState.mainCurrency.type, amountState.typeOfAmount)
|
||||
val symbols = determineSymbols(wallet)
|
||||
val symbols = determineSymbols(wallet, amountState.typeOfAmount)
|
||||
val showBlank = !SendState.isReadyToSend()
|
||||
val result = state.copy(
|
||||
visibleTypeOfReceipt = layoutType,
|
||||
mainCurrency = amountState.mainCurrency,
|
||||
fiat = createFiatType(symbols, showBlank),
|
||||
crypto = createCryptoType(symbols, showBlank),
|
||||
tokenFiat = createTokenFiatType(symbols, showBlank),
|
||||
tokenCrypto = createTokenCryptoType(symbols, showBlank)
|
||||
visibleTypeOfReceipt = layoutType,
|
||||
mainCurrency = amountState.mainCurrency,
|
||||
fiat = createFiatType(symbols, showBlank),
|
||||
crypto = createCryptoType(symbols, showBlank),
|
||||
tokenFiat = createTokenFiatType(symbols, showBlank),
|
||||
tokenCrypto = createTokenCryptoType(symbols, showBlank)
|
||||
)
|
||||
return updateLastState(sendState.copy(receiptState = result), result)
|
||||
}
|
||||
|
|
@ -65,22 +64,22 @@ class ReceiptReducer : SendInternalReducer {
|
|||
val amountFiat = convertToFiatPrecision(amountState.amountToSendCrypto.minus(feeCrypto))
|
||||
val totalFiat = convertToFiatPrecision(amountState.amountToSendCrypto)
|
||||
ReceiptFiat(
|
||||
amountFiat = amountFiat,
|
||||
feeFiat = feeFiat,
|
||||
totalFiat = totalFiat,
|
||||
willSentCrypto = amountState.amountToSendCrypto.stripZeroPlainString(),
|
||||
symbols = symbols
|
||||
amountFiat = amountFiat,
|
||||
feeFiat = feeFiat,
|
||||
totalFiat = totalFiat,
|
||||
willSentCrypto = amountState.amountToSendCrypto.stripZeroPlainString(),
|
||||
symbols = symbols
|
||||
)
|
||||
} else {
|
||||
val totalAmountCrypto = amountState.amountToSendCrypto.plus(feeCrypto)
|
||||
val amountFiat = convertToFiatPrecision(amountState.amountToSendCrypto)
|
||||
val totalFiat = convertToFiatPrecision(totalAmountCrypto)
|
||||
ReceiptFiat(
|
||||
amountFiat = amountFiat,
|
||||
feeFiat = feeFiat,
|
||||
totalFiat = totalFiat,
|
||||
willSentCrypto = totalAmountCrypto.stripZeroPlainString(),
|
||||
symbols = symbols
|
||||
amountFiat = amountFiat,
|
||||
feeFiat = feeFiat,
|
||||
totalFiat = totalFiat,
|
||||
willSentCrypto = totalAmountCrypto.stripZeroPlainString(),
|
||||
symbols = symbols
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -94,22 +93,22 @@ class ReceiptReducer : SendInternalReducer {
|
|||
|
||||
if (feeState.feeIsIncluded) {
|
||||
return ReceiptCrypto(
|
||||
amountCrypto = amountState.amountToSendCrypto.minus(feeCrypto).stripZeroPlainString(),
|
||||
feeCrypto = feeCrypto.stripZeroPlainString(),
|
||||
totalCrypto = amountState.amountToSendCrypto.stripZeroPlainString(),
|
||||
feeFiat = feeFiat,
|
||||
willSentFiat = convertToFiatPrecision(amountState.amountToSendCrypto),
|
||||
symbols = symbols
|
||||
amountCrypto = amountState.amountToSendCrypto.minus(feeCrypto).stripZeroPlainString(),
|
||||
feeCrypto = feeCrypto.stripZeroPlainString(),
|
||||
totalCrypto = amountState.amountToSendCrypto.stripZeroPlainString(),
|
||||
feeFiat = feeFiat,
|
||||
willSentFiat = convertToFiatPrecision(amountState.amountToSendCrypto),
|
||||
symbols = symbols
|
||||
)
|
||||
} else {
|
||||
val totalCrypto = amountState.amountToSendCrypto.plus(feeCrypto)
|
||||
return ReceiptCrypto(
|
||||
amountCrypto = amountState.amountToSendCrypto.stripZeroPlainString(),
|
||||
feeCrypto = feeCrypto.stripZeroPlainString(),
|
||||
totalCrypto = totalCrypto.stripZeroPlainString(),
|
||||
feeFiat = feeFiat,
|
||||
willSentFiat = convertToFiatPrecision(totalCrypto),
|
||||
symbols = symbols
|
||||
amountCrypto = amountState.amountToSendCrypto.stripZeroPlainString(),
|
||||
feeCrypto = feeCrypto.stripZeroPlainString(),
|
||||
totalCrypto = totalCrypto.stripZeroPlainString(),
|
||||
feeFiat = feeFiat,
|
||||
willSentFiat = convertToFiatPrecision(totalCrypto),
|
||||
symbols = symbols
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -128,21 +127,21 @@ class ReceiptReducer : SendInternalReducer {
|
|||
val amountFiat = sendState.tokenConverter!!.toFiatUnscaled(tokensToSend)
|
||||
val totalFiat = amountFiat.plus(feeFiat)
|
||||
ReceiptTokenFiat(
|
||||
amountFiat = amountFiat.scaleToFiat(true).stripZeroPlainString(),
|
||||
feeFiat = feeFiat.scaleToFiat(true).stripZeroPlainString(),
|
||||
totalFiat = totalFiat.scaleToFiat(true).stripZeroPlainString(),
|
||||
willSentToken = tokensToSend.stripZeroPlainString(),
|
||||
willSentFeeCoin = feeCoin.stripZeroPlainString(),
|
||||
symbols = symbols
|
||||
amountFiat = amountFiat.scaleToFiat(true).stripZeroPlainString(),
|
||||
feeFiat = feeFiat.scaleToFiat(true).stripZeroPlainString(),
|
||||
totalFiat = totalFiat.scaleToFiat(true).stripZeroPlainString(),
|
||||
willSentToken = tokensToSend.stripZeroPlainString(),
|
||||
willSentFeeCoin = feeCoin.stripZeroPlainString(),
|
||||
symbols = symbols
|
||||
)
|
||||
} else {
|
||||
ReceiptTokenFiat(
|
||||
amountFiat = EMPTY,
|
||||
feeFiat = EMPTY,
|
||||
totalFiat = EMPTY,
|
||||
willSentToken = tokensToSend.stripZeroPlainString(),
|
||||
willSentFeeCoin = feeCoin.stripZeroPlainString(),
|
||||
symbols = symbols
|
||||
amountFiat = EMPTY,
|
||||
feeFiat = EMPTY,
|
||||
totalFiat = EMPTY,
|
||||
willSentToken = tokensToSend.stripZeroPlainString(),
|
||||
willSentFeeCoin = feeCoin.stripZeroPlainString(),
|
||||
symbols = symbols
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -160,27 +159,30 @@ class ReceiptReducer : SendInternalReducer {
|
|||
val totalFiat = tokenFiat.plus(feeFiat)
|
||||
|
||||
ReceiptTokenCrypto(
|
||||
amountToken = tokensToSend.stripZeroPlainString(),
|
||||
feeCoin = feeCoin.stripZeroPlainString(),
|
||||
totalFiat = totalFiat.scaleToFiat(true).stripZeroPlainString(),
|
||||
symbols = symbols
|
||||
amountToken = tokensToSend.stripZeroPlainString(),
|
||||
feeCoin = feeCoin.stripZeroPlainString(),
|
||||
totalFiat = totalFiat.scaleToFiat(true).stripZeroPlainString(),
|
||||
symbols = symbols
|
||||
)
|
||||
} else {
|
||||
ReceiptTokenCrypto(
|
||||
amountToken = tokensToSend.stripZeroPlainString(),
|
||||
feeCoin = feeCoin.stripZeroPlainString(),
|
||||
totalFiat = EMPTY,
|
||||
symbols = symbols
|
||||
amountToken = tokensToSend.stripZeroPlainString(),
|
||||
feeCoin = feeCoin.stripZeroPlainString(),
|
||||
totalFiat = EMPTY,
|
||||
symbols = symbols
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun determineSymbols(wallet: Wallet): ReceiptSymbols {
|
||||
private fun determineSymbols(wallet: Wallet, amountType: AmountType): ReceiptSymbols {
|
||||
return ReceiptSymbols(
|
||||
fiat = store.state.globalState.appCurrency,
|
||||
crypto = wallet.blockchain.currency,
|
||||
token = wallet.getFirstToken()?.symbol
|
||||
fiat = store.state.globalState.appCurrency,
|
||||
crypto = wallet.blockchain.currency,
|
||||
token = when (amountType) {
|
||||
is AmountType.Token -> amountType.token.symbol
|
||||
else -> null
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,18 +31,18 @@ class OnWalletLoadedReducer {
|
|||
val fiatCurrencySymbol = store.state.globalState.appCurrency
|
||||
val moonpayStatus = store.state.globalState.moonpayStatus
|
||||
|
||||
val amount = wallet.amounts[AmountType.Coin]?.value
|
||||
val coinAmountValue = wallet.amounts[AmountType.Coin]?.value
|
||||
if (walletState.getWalletData(wallet.blockchain) == null) {
|
||||
return walletState
|
||||
}
|
||||
val formattedAmount = amount?.toFormattedCurrencyString(
|
||||
val formattedAmount = coinAmountValue?.toFormattedCurrencyString(
|
||||
wallet.blockchain.decimals(),
|
||||
wallet.blockchain.currency)
|
||||
|
||||
val pendingTransactions = wallet.recentTransactions
|
||||
.toPendingTransactions(wallet.address)
|
||||
|
||||
val sendButtonEnabled = amount?.isZero() == false && pendingTransactions.isEmpty()
|
||||
val coinSendButton = coinAmountValue?.isZero() == false && pendingTransactions.isEmpty()
|
||||
val balanceStatus = if (pendingTransactions.isNotEmpty()) {
|
||||
BalanceStatus.TransactionInProgress
|
||||
} else {
|
||||
|
|
@ -50,7 +50,7 @@ class OnWalletLoadedReducer {
|
|||
}
|
||||
val walletData = walletState.getWalletData(wallet.blockchain)
|
||||
|
||||
val fiatAmount = walletData?.fiatRate?.let { amount?.toFiatValue(it) }
|
||||
val fiatAmount = walletData?.fiatRate?.let { coinAmountValue?.toFiatValue(it) }
|
||||
val newWalletData = walletData?.copy(
|
||||
currencyData = walletData.currencyData.copy(
|
||||
status = balanceStatus, currency = wallet.blockchain.fullName,
|
||||
|
|
@ -60,7 +60,7 @@ class OnWalletLoadedReducer {
|
|||
fiatAmountFormatted = fiatAmount?.toFormattedFiatValue(fiatCurrencySymbol)
|
||||
),
|
||||
pendingTransactions = pendingTransactions.removeUnknownTransactions(),
|
||||
mainButton = WalletMainButton.SendButton(sendButtonEnabled),
|
||||
mainButton = WalletMainButton.SendButton(coinSendButton),
|
||||
currency = Currency.Blockchain(wallet.blockchain),
|
||||
tradeCryptoState = TradeCryptoState.from(moonpayStatus, walletData)
|
||||
)
|
||||
|
|
@ -73,22 +73,20 @@ class OnWalletLoadedReducer {
|
|||
pendingTransactions.isNotEmpty() -> BalanceStatus.SameCurrencyTransactionInProgress
|
||||
else -> BalanceStatus.VerifiedOnline
|
||||
}
|
||||
val tokenFiatAmount = tokenWalletData?.fiatRate?.let { rate ->
|
||||
wallet.getTokenAmount(token)?.value?.toFiatValue(rate)
|
||||
}
|
||||
val tokenAmountValue = wallet.getTokenAmount(token)?.value
|
||||
val tokenFiatAmount = tokenWalletData?.fiatRate?.let { rate -> tokenAmountValue?.toFiatValue(rate)}
|
||||
|
||||
val tokenSendButton = tokenAmountValue?.isZero() == false && tokenPendingTransactions.isEmpty()
|
||||
tokenWalletData?.copy(
|
||||
currencyData = tokenWalletData.currencyData.copy(
|
||||
status = tokenBalanceStatus,
|
||||
amount = wallet.getTokenAmount(token)?.value?.toFormattedCurrencyString(
|
||||
token.decimals, token.symbol
|
||||
),
|
||||
amount = tokenAmountValue?.toFormattedCurrencyString(token.decimals, token.symbol),
|
||||
fiatAmount = tokenFiatAmount,
|
||||
fiatAmountFormatted = tokenFiatAmount?.toFormattedFiatValue(fiatCurrencySymbol)
|
||||
),
|
||||
pendingTransactions = tokenPendingTransactions.removeUnknownTransactions(),
|
||||
mainButton = WalletMainButton.SendButton(sendButtonEnabled),
|
||||
mainButton = WalletMainButton.SendButton(tokenSendButton),
|
||||
tradeCryptoState = TradeCryptoState.from(moonpayStatus, tokenWalletData)
|
||||
|
||||
)
|
||||
}
|
||||
val newWallets = (tokens + newWalletData).mapNotNull { it }
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
android:layout_height="?attr/actionBarSize"
|
||||
app:menu="@menu/popular_tokens"
|
||||
app:navigationIcon="@drawable/ic_baseline_arrow_back_24"
|
||||
app:title="Add Currencies" />
|
||||
app:title="Add tokens" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue