Updated on 2026-08-14
This commit is contained in:
parent
e074377533
commit
21997b5e9b
29 changed files with 262 additions and 119 deletions
|
|
@ -147,7 +147,7 @@ class TapApplication : Application(), ImageLoaderFactory {
|
|||
}
|
||||
|
||||
data class LogConfig(
|
||||
val coil: Boolean = BuildConfig.DEBUG,
|
||||
val coil: Boolean = false,
|
||||
val storeAction: Boolean = BuildConfig.DEBUG,
|
||||
val zendesk: Boolean = BuildConfig.DEBUG,
|
||||
)
|
||||
|
|
@ -64,6 +64,7 @@ sealed class TapSdkError(override val messageResId: Int?) : Throwable(), TangemE
|
|||
|
||||
object CardForDifferentApp : TapSdkError(R.string.alert_unsupported_card)
|
||||
object CardNotSupportedByRelease : TapSdkError(R.string.error_update_app)
|
||||
object ScanPrimaryCard : TapSdkError(R.string.saltpay_backup_warning)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ class TapWalletManager {
|
|||
val primaryWalletManager = walletManagerFactory.makePrimaryWalletManager(data)
|
||||
|
||||
if (blockchain != Blockchain.Unknown && primaryWalletManager != null) {
|
||||
val blockchainNetwork = BlockchainNetwork.fromWalletManager(primaryWalletManager)
|
||||
val primaryToken = data.getPrimaryToken()
|
||||
|
||||
dispatchOnMain(WalletAction.MultiWallet.SetPrimaryBlockchain(blockchain))
|
||||
|
|
@ -169,9 +170,9 @@ class TapWalletManager {
|
|||
}
|
||||
dispatchOnMain(
|
||||
WalletAction.MultiWallet.AddBlockchains(
|
||||
listOf(BlockchainNetwork.fromWalletManager(primaryWalletManager)),
|
||||
listOf(primaryWalletManager)
|
||||
)
|
||||
listOf(blockchainNetwork),
|
||||
listOf(primaryWalletManager),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.tangem.common.card.EllipticCurve
|
|||
import com.tangem.common.card.FirmwareVersion
|
||||
import com.tangem.common.extensions.toHexString
|
||||
import com.tangem.common.services.Result
|
||||
import com.tangem.domain.common.TapWorkarounds.isSaltPay
|
||||
import com.tangem.domain.common.TapWorkarounds.isStart2Coin
|
||||
import com.tangem.domain.common.TapWorkarounds.isTangemNote
|
||||
import com.tangem.domain.common.TwinCardNumber
|
||||
|
|
@ -23,11 +24,14 @@ val Card.isWalletDataSupported: Boolean
|
|||
|
||||
val Card.isMultiwalletAllowed: Boolean
|
||||
get() {
|
||||
return !isTangemTwin() && !isStart2Coin && !isTangemNote()
|
||||
return !isTangemTwin() && !isStart2Coin && !isTangemNote() && !isSaltPay
|
||||
&& (firmwareVersion >= FirmwareVersion.MultiWalletAvailable ||
|
||||
getSingleWallet()?.curve == EllipticCurve.Secp256k1)
|
||||
}
|
||||
|
||||
val Card.isHdWalletAllowedByApp: Boolean
|
||||
get() = settings.isHDWalletAllowed && !isSaltPay
|
||||
|
||||
fun Card.getSingleWallet(): CardWallet? {
|
||||
return wallets.firstOrNull()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
package com.tangem.tap.domain.extensions
|
||||
|
||||
import com.tangem.blockchain.common.*
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.DerivationParams
|
||||
import com.tangem.blockchain.common.DerivationStyle
|
||||
import com.tangem.blockchain.common.WalletManager
|
||||
import com.tangem.blockchain.common.WalletManagerFactory
|
||||
import com.tangem.common.card.Card
|
||||
import com.tangem.common.card.CardWallet
|
||||
import com.tangem.common.card.EllipticCurve
|
||||
|
|
@ -35,10 +39,10 @@ fun WalletManagerFactory.makeWalletManagerForApp(
|
|||
walletPublicKey = wallet.publicKey,
|
||||
pairPublicKey = scanResponse.secondTwinPublicKey!!.hexToBytes(),
|
||||
blockchain = environmentBlockchain,
|
||||
curve = wallet.curve
|
||||
curve = wallet.curve,
|
||||
)
|
||||
}
|
||||
seedKey != null && derivationParams != null -> {
|
||||
scanResponse.card.isHdWalletAllowedByApp && (seedKey != null && derivationParams != null) -> {
|
||||
val derivedKeys = scanResponse.derivedKeys[wallet.publicKey.toMapKey()]
|
||||
val derivationPath = when (derivationParams) {
|
||||
is DerivationParams.Default -> blockchain.derivationPath(derivationParams.style)
|
||||
|
|
@ -51,7 +55,7 @@ fun WalletManagerFactory.makeWalletManagerForApp(
|
|||
blockchain = environmentBlockchain,
|
||||
seedKey = wallet.publicKey,
|
||||
derivedKey = derivedKey,
|
||||
derivation = derivationParams
|
||||
derivation = derivationParams,
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import com.tangem.blockchain.common.Blockchain
|
|||
import com.tangem.common.CompletionResult
|
||||
import com.tangem.common.card.Card
|
||||
import com.tangem.common.card.EllipticCurve
|
||||
import com.tangem.common.card.FirmwareVersion
|
||||
import com.tangem.common.core.CardSession
|
||||
import com.tangem.common.core.CardSessionRunnable
|
||||
import com.tangem.common.core.TangemError
|
||||
|
|
@ -18,10 +17,11 @@ import com.tangem.domain.common.ProductType
|
|||
import com.tangem.domain.common.ScanResponse
|
||||
import com.tangem.domain.common.TapWorkarounds.isExcluded
|
||||
import com.tangem.domain.common.TapWorkarounds.isNotSupportedInThatRelease
|
||||
import com.tangem.domain.common.TapWorkarounds.isTangemNote
|
||||
import com.tangem.domain.common.TapWorkarounds.isSaltPay
|
||||
import com.tangem.domain.common.TapWorkarounds.useOldStyleDerivation
|
||||
import com.tangem.domain.common.TwinsHelper
|
||||
import com.tangem.domain.common.isTangemTwins
|
||||
import com.tangem.domain.common.productType
|
||||
import com.tangem.operations.PreflightReadMode
|
||||
import com.tangem.operations.PreflightReadTask
|
||||
import com.tangem.operations.ScanTask
|
||||
|
|
@ -32,6 +32,9 @@ import com.tangem.operations.issuerAndUserData.ReadIssuerDataCommand
|
|||
import com.tangem.tap.domain.TapSdkError
|
||||
import com.tangem.tap.domain.extensions.getPrimaryCurve
|
||||
import com.tangem.tap.domain.extensions.getSingleWallet
|
||||
import com.tangem.tap.domain.extensions.hasNoWallets
|
||||
import com.tangem.tap.domain.extensions.isHdWalletAllowedByApp
|
||||
import com.tangem.tap.domain.extensions.isMultiwalletAllowed
|
||||
import com.tangem.tap.domain.tokens.CurrenciesRepository
|
||||
import com.tangem.tap.domain.tokens.models.BlockchainNetwork
|
||||
import com.tangem.tap.preferencesStorage
|
||||
|
|
@ -60,7 +63,6 @@ class ScanProductTask(
|
|||
}
|
||||
|
||||
val commandProcessor = when {
|
||||
card.isTangemNote() -> ScanNoteProcessor()
|
||||
card.isTangemTwins() -> ScanTwinProcessor()
|
||||
else -> ScanWalletProcessor(currenciesRepository, additionalBlockchainsToDerive)
|
||||
}
|
||||
|
|
@ -87,29 +89,11 @@ class ScanProductTask(
|
|||
private fun getErrorIfExcludedCard(card: Card): TangemError? {
|
||||
if (card.isExcluded()) return TapSdkError.CardForDifferentApp
|
||||
if (card.isNotSupportedInThatRelease()) return TapSdkError.CardNotSupportedByRelease
|
||||
|
||||
if (card.isSaltPay && card.hasNoWallets()) return TapSdkError.ScanPrimaryCard
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
private class ScanNoteProcessor : ProductCommandProcessor<ScanResponse> {
|
||||
override fun proceed(
|
||||
card: Card,
|
||||
session: CardSession,
|
||||
callback: (result: CompletionResult<ScanResponse>) -> Unit
|
||||
) {
|
||||
callback(
|
||||
CompletionResult.Success(
|
||||
ScanResponse(
|
||||
card = card,
|
||||
productType = ProductType.Note,
|
||||
walletData = session.environment.walletData,
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private class ScanWalletProcessor(
|
||||
private val currenciesRepository: CurrenciesRepository?,
|
||||
private val additionalBlockchainsToDerive: Collection<Blockchain>? = null
|
||||
|
|
@ -123,12 +107,13 @@ private class ScanWalletProcessor(
|
|||
) {
|
||||
createMissingWalletsIfNeeded(card, session, callback)
|
||||
}
|
||||
|
||||
private fun createMissingWalletsIfNeeded(
|
||||
card: Card,
|
||||
session: CardSession,
|
||||
callback: (result: CompletionResult<ScanResponse>) -> Unit,
|
||||
) {
|
||||
if (card.wallets.isEmpty() || card.firmwareVersion < FirmwareVersion.MultiWalletAvailable) {
|
||||
if (card.wallets.isEmpty() || !card.isMultiwalletAllowed) {
|
||||
startLinkingForBackupIfNeeded(card, session, callback)
|
||||
return
|
||||
}
|
||||
|
|
@ -186,16 +171,16 @@ private class ScanWalletProcessor(
|
|||
) {
|
||||
scope.launch {
|
||||
val derivations = collectDerivations(card)
|
||||
if (derivations.isEmpty() || !card.settings.isHDWalletAllowed) {
|
||||
if (derivations.isEmpty() || !card.isHdWalletAllowedByApp) {
|
||||
callback(
|
||||
CompletionResult.Success(
|
||||
ScanResponse(
|
||||
card = card,
|
||||
productType = ProductType.Wallet,
|
||||
productType = card.productType,
|
||||
walletData = session.environment.walletData,
|
||||
primaryCard = primaryCard
|
||||
)
|
||||
)
|
||||
primaryCard = primaryCard,
|
||||
),
|
||||
),
|
||||
)
|
||||
return@launch
|
||||
}
|
||||
|
|
@ -205,10 +190,10 @@ private class ScanWalletProcessor(
|
|||
is CompletionResult.Success -> {
|
||||
val response = ScanResponse(
|
||||
card = card,
|
||||
productType = ProductType.Wallet,
|
||||
productType = card.productType,
|
||||
walletData = session.environment.walletData,
|
||||
derivedKeys = result.data.entries,
|
||||
primaryCard = primaryCard
|
||||
primaryCard = primaryCard,
|
||||
)
|
||||
callback(CompletionResult.Success(response))
|
||||
}
|
||||
|
|
@ -222,7 +207,7 @@ private class ScanWalletProcessor(
|
|||
val currenciesRepository = currenciesRepository ?: return emptyList()
|
||||
|
||||
val cardCurrencies = currenciesRepository
|
||||
.loadSavedCurrencies(card.cardId, card.settings.isHDWalletAllowed).toMutableList()
|
||||
.loadSavedCurrencies(card.cardId, card.isHdWalletAllowedByApp).toMutableList()
|
||||
|
||||
val blockchainsToDerive = cardCurrencies.ifEmpty {
|
||||
mutableListOf(
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ private fun prepareSecurityOptions(card: Card): ManageSecurityState {
|
|||
}
|
||||
}
|
||||
val allowedSecurityOptions = when {
|
||||
card.isStart2Coin || card.isTangemNote() -> {
|
||||
card.isStart2Coin || card.isTangemNote() || card.isSaltPay -> {
|
||||
EnumSet.of(SecurityOption.LongTap)
|
||||
}
|
||||
card.settings.isBackupAllowed -> {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.tangem.tap.features.onboarding
|
|||
|
||||
import com.tangem.domain.common.ProductType
|
||||
import com.tangem.domain.common.ScanResponse
|
||||
import com.tangem.domain.common.TapWorkarounds.isSaltPay
|
||||
import com.tangem.tap.common.redux.navigation.AppScreen
|
||||
import com.tangem.tap.domain.extensions.hasWallets
|
||||
import com.tangem.tap.preferencesStorage
|
||||
|
|
@ -15,6 +16,10 @@ class OnboardingHelper {
|
|||
fun isOnboardingCase(response: ScanResponse): Boolean {
|
||||
val cardInfoStorage = preferencesStorage.usedCardsPrefStorage
|
||||
return when {
|
||||
response.card.isSaltPay -> {
|
||||
// response.card.backupStatus?.isActive != true //TODO: restore after presentation
|
||||
false
|
||||
}
|
||||
response.productType == ProductType.Twins -> {
|
||||
if (!response.twinsIsTwinned()) {
|
||||
true
|
||||
|
|
@ -38,6 +43,7 @@ class OnboardingHelper {
|
|||
AppScreen.OnboardingOther
|
||||
}
|
||||
ProductType.Twins -> AppScreen.OnboardingTwins
|
||||
ProductType.SaltPay -> AppScreen.OnboardingWallet
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ sealed class OnboardingWalletAction : Action {
|
|||
object Done : OnboardingWalletAction()
|
||||
object FinishOnboarding : OnboardingWalletAction()
|
||||
|
||||
object ProceedBackup : OnboardingWalletAction()
|
||||
data class ProceedBackup(val isSaltPay: Boolean = false) : OnboardingWalletAction()
|
||||
|
||||
object LoadArtwork : OnboardingWalletAction()
|
||||
class SetArtworkUrl(val artworkUrl: String?) : OnboardingWalletAction()
|
||||
|
|
@ -21,7 +21,7 @@ sealed class OnboardingWalletAction : Action {
|
|||
sealed class BackupAction : Action {
|
||||
|
||||
object DetermineBackupStep : BackupAction()
|
||||
object IntroduceBackup : BackupAction()
|
||||
data class IntroduceBackup(val isSaltPay: Boolean = false) : BackupAction()
|
||||
object StartBackup : BackupAction()
|
||||
object DismissBackup : BackupAction()
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.tangem.blockchain.common.Blockchain
|
|||
import com.tangem.common.CompletionResult
|
||||
import com.tangem.common.card.Card
|
||||
import com.tangem.domain.common.ScanResponse
|
||||
import com.tangem.domain.common.TapWorkarounds.isSaltPay
|
||||
import com.tangem.domain.common.extensions.withMainContext
|
||||
import com.tangem.operations.backup.BackupService
|
||||
import com.tangem.tap.*
|
||||
|
|
@ -51,10 +52,10 @@ private fun handleWalletAction(action: Action) {
|
|||
OnboardingWalletAction.Init -> {
|
||||
val action = when {
|
||||
card == null -> {
|
||||
OnboardingWalletAction.ProceedBackup
|
||||
OnboardingWalletAction.ProceedBackup()
|
||||
}
|
||||
card.hasWallets() && card.backupStatus == Card.BackupStatus.NoBackup ->
|
||||
OnboardingWalletAction.ProceedBackup
|
||||
OnboardingWalletAction.ProceedBackup(card.isSaltPay)
|
||||
card.hasWallets() && card.backupStatus?.isActive == true ->
|
||||
BackupAction.FinishBackup
|
||||
else -> OnboardingWalletAction.GetToCreateWalletStep
|
||||
|
|
@ -98,7 +99,7 @@ private fun handleWalletAction(action: Action) {
|
|||
)
|
||||
)
|
||||
onboardingManager.activationStarted(updatedResponse.card.cardId)
|
||||
store.dispatch(OnboardingWalletAction.ProceedBackup)
|
||||
store.dispatch(OnboardingWalletAction.ProceedBackup())
|
||||
}
|
||||
is CompletionResult.Failure -> {
|
||||
// do nothing
|
||||
|
|
@ -120,7 +121,7 @@ private fun handleWalletAction(action: Action) {
|
|||
store.dispatchOnMain(NavigationAction.NavigateTo(AppScreen.Wallet))
|
||||
}
|
||||
}
|
||||
OnboardingWalletAction.ProceedBackup -> {
|
||||
is OnboardingWalletAction.ProceedBackup -> {
|
||||
val newAction = when (val backupState = backupService.currentState) {
|
||||
BackupService.State.FinalizingPrimaryCard -> BackupAction.PrepareToWritePrimaryCard
|
||||
is BackupService.State.FinalizingBackupCard -> BackupAction.PrepareToWriteBackupCard(backupState.index)
|
||||
|
|
@ -128,7 +129,7 @@ private fun handleWalletAction(action: Action) {
|
|||
if (walletState.backupState.backupStep == BackupStep.InitBackup ||
|
||||
walletState.backupState.backupStep == BackupStep.Finished
|
||||
) {
|
||||
BackupAction.IntroduceBackup
|
||||
BackupAction.IntroduceBackup(action.isSaltPay)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
|
@ -319,7 +320,7 @@ private fun handleBackupAction(appState: () -> AppState?, action: BackupAction)
|
|||
}
|
||||
is BackupAction.ResumeBackup -> {
|
||||
store.dispatch(GlobalAction.Onboarding.Start(null, true))
|
||||
store.dispatch(OnboardingWalletAction.ProceedBackup)
|
||||
store.dispatch(OnboardingWalletAction.ProceedBackup())
|
||||
store.dispatch(NavigationAction.NavigateTo(AppScreen.OnboardingWallet))
|
||||
}
|
||||
is BackupAction.DismissBackup -> {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ class BackupReducer {
|
|||
is BackupAction.IntroduceBackup -> BackupState(
|
||||
backupStep = BackupStep.InitBackup,
|
||||
canSkipBackup = state.canSkipBackup,
|
||||
isSaltPay = action.isSaltPay,
|
||||
)
|
||||
BackupAction.StartAddingPrimaryCard -> state.copy(backupStep = BackupStep.ScanOriginCard)
|
||||
BackupAction.StartAddingBackupCards -> {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ data class BackupState(
|
|||
val backupStep: BackupStep = BackupStep.InitBackup,
|
||||
val maxBackupCards: Int = 2,
|
||||
val canSkipBackup: Boolean = true,
|
||||
val isSaltPay: Boolean = false,
|
||||
)
|
||||
|
||||
enum class AccessCodeError {
|
||||
|
|
|
|||
|
|
@ -181,6 +181,8 @@ class OnboardingWalletFragment : Fragment(R.layout.fragment_onboarding_wallet),
|
|||
btnAlternativeAction.show(state.canSkipBackup)
|
||||
btnMainAction.setOnClickListener { store.dispatch(BackupAction.StartBackup) }
|
||||
btnAlternativeAction.setOnClickListener { store.dispatch(BackupAction.DismissBackup) }
|
||||
|
||||
btnAlternativeAction.show(!state.isSaltPay)
|
||||
}
|
||||
|
||||
startPostponedEnterTransition()
|
||||
|
|
@ -232,9 +234,9 @@ class OnboardingWalletFragment : Fragment(R.layout.fragment_onboarding_wallet),
|
|||
|
||||
when (state.backupCardsNumber) {
|
||||
0 -> {
|
||||
cardsWidget.toFan() {
|
||||
cardsWidget.getFirstBackupCardView().animate().alpha(0.6f).setDuration(200)
|
||||
cardsWidget.getSecondBackupCardView().animate().alpha(0.2f).setDuration(200)
|
||||
cardsWidget.toFan {
|
||||
cardsWidget.getFirstBackupCardView().animate().alpha(0.6f).duration = 200
|
||||
cardsWidget.getSecondBackupCardView().animate().alpha(0.2f).duration = 200
|
||||
}
|
||||
tvHeader.text = getText(R.string.onboarding_title_no_backup_cards)
|
||||
tvBody.text = getText(R.string.onboarding_subtitle_no_backup_cards)
|
||||
|
|
@ -244,7 +246,7 @@ class OnboardingWalletFragment : Fragment(R.layout.fragment_onboarding_wallet),
|
|||
tvBody.text = getText(R.string.onboarding_subtitle_one_backup_card)
|
||||
|
||||
cardsWidget.toFan(false)
|
||||
cardsWidget.getFirstBackupCardView().animate().alpha(1f).setDuration(400)
|
||||
cardsWidget.getFirstBackupCardView().animate().alpha(1f).duration = 400
|
||||
cardsWidget.getSecondBackupCardView().alpha = 0.2f
|
||||
}
|
||||
2 -> {
|
||||
|
|
@ -253,7 +255,7 @@ class OnboardingWalletFragment : Fragment(R.layout.fragment_onboarding_wallet),
|
|||
|
||||
cardsWidget.toFan(false)
|
||||
cardsWidget.getFirstBackupCardView().alpha = 1f
|
||||
cardsWidget.getSecondBackupCardView().animate().alpha(1f).setDuration(400)
|
||||
cardsWidget.getSecondBackupCardView().animate().alpha(1f).duration = 400
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -296,7 +298,7 @@ class OnboardingWalletFragment : Fragment(R.layout.fragment_onboarding_wallet),
|
|||
prepareViewForFinalizeStep()
|
||||
cardsWidget.getSecondBackupCardView().show(state.backupCardsNumber == 2)
|
||||
|
||||
cardsWidget.toLeapfrog() {
|
||||
cardsWidget.toLeapfrog {
|
||||
cardsWidget.getFirstBackupCardView().alpha = 0.6f
|
||||
cardsWidget.getSecondBackupCardView().alpha = 0.2f
|
||||
}
|
||||
|
|
@ -335,12 +337,12 @@ class OnboardingWalletFragment : Fragment(R.layout.fragment_onboarding_wallet),
|
|||
|
||||
val cardNumber = (state.backupStep as? BackupStep.WriteBackupCard)?.cardNumber ?: 1
|
||||
when (cardNumber) {
|
||||
1 -> cardsWidget.leapfrogWidget.leap() {
|
||||
1 -> cardsWidget.leapfrogWidget.leap {
|
||||
cardsWidget.getOriginCardView().alpha = 0.4f
|
||||
cardsWidget.getFirstBackupCardView().alpha = 0.2f
|
||||
cardsWidget.getSecondBackupCardView().alpha = 1f
|
||||
}
|
||||
2 -> cardsWidget.leapfrogWidget.leap() {
|
||||
2 -> cardsWidget.leapfrogWidget.leap {
|
||||
cardsWidget.getOriginCardView().alpha = 0.4f
|
||||
cardsWidget.getFirstBackupCardView().alpha = 0.2f
|
||||
cardsWidget.getSecondBackupCardView().alpha = 1f
|
||||
|
|
@ -389,8 +391,7 @@ class OnboardingWalletFragment : Fragment(R.layout.fragment_onboarding_wallet),
|
|||
imvSuccess.show()
|
||||
|
||||
imvSuccess.animate()
|
||||
?.alpha(1f)
|
||||
?.setDuration(400)
|
||||
?.alpha(1f)?.duration = 400
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -132,7 +132,19 @@ class WalletMiddleware {
|
|||
.plus(Currency.Blockchain(wallet.blockchain, wallet.publicKey.derivationPath?.rawPath))
|
||||
}
|
||||
action.coinsList != null -> action.coinsList
|
||||
else -> walletState.walletsData.map { it.currency }
|
||||
else -> {
|
||||
if (walletState.isMultiwalletAllowed) {
|
||||
walletState.walletsData.map { it.currency }
|
||||
} else {
|
||||
val derivationPath = walletState.primaryWallet?.currency?.derivationPath
|
||||
val primaryBlockchain = walletState.primaryBlockchain
|
||||
val primaryToken = walletState.primaryToken
|
||||
listOfNotNull(
|
||||
primaryBlockchain?.let { Currency.Blockchain(it, derivationPath) },
|
||||
primaryToken?.let { Currency.Token(it, primaryBlockchain!!, derivationPath) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
val ratesResult = globalState.tapWalletManager.rates.loadFiatRate(
|
||||
currencyId = appCurrencyId,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.tangem.tap.features.wallet.ui.BalanceStatus
|
|||
import com.tangem.tap.features.wallet.ui.BalanceWidgetData
|
||||
import com.tangem.tap.features.wallet.ui.TokenData
|
||||
import com.tangem.tap.store
|
||||
import java.math.BigDecimal
|
||||
|
||||
class OnWalletLoadedReducer {
|
||||
|
||||
|
|
@ -124,10 +125,12 @@ class OnWalletLoadedReducer {
|
|||
val tokenFiatAmount =
|
||||
tokenFiatRate?.let { tokenAmount.value?.toFiatString(it, fiatCurrencyName) }
|
||||
TokenData(
|
||||
tokenAmount.value?.toFormattedCurrencyString(
|
||||
token.decimals, token.symbol
|
||||
amount = tokenAmount.value ?: BigDecimal.ZERO,
|
||||
tokenSymbol = tokenAmount.currencySymbol, fiatAmountFormatted = tokenFiatAmount,
|
||||
fiatAmount = tokenFiatRate?.let { tokenAmount.value?.toFiatValue(tokenFiatRate) },
|
||||
amountFormatted = tokenAmount.value?.toFormattedCurrencyString(
|
||||
token.decimals, token.symbol,
|
||||
) ?: "",
|
||||
tokenAmount.currencySymbol, tokenFiatAmount
|
||||
)
|
||||
} else {
|
||||
null
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import com.tangem.tap.features.wallet.redux.WalletStore
|
|||
import com.tangem.tap.features.wallet.ui.BalanceStatus
|
||||
import com.tangem.tap.features.wallet.ui.BalanceWidgetData
|
||||
import org.rekotlin.Action
|
||||
import timber.log.Timber
|
||||
import java.math.BigDecimal
|
||||
|
||||
class WalletReducer {
|
||||
|
|
@ -386,16 +387,11 @@ private fun setNewFiatRate(
|
|||
state = state
|
||||
)
|
||||
} else {
|
||||
val fiatRate = fiatRates.entries.firstOrNull()
|
||||
val currency = fiatRate?.key ?: return state
|
||||
val rate = fiatRate.value ?: return state
|
||||
|
||||
setSingleWalletFiatRate(
|
||||
rate = rate,
|
||||
rateFormatted = rateFormatter(rate),
|
||||
currency = currency,
|
||||
setSingleWalletFiatRates(
|
||||
fiatRates = fiatRates.mapNotNullValues { it.value },
|
||||
rateFormatter = rateFormatter,
|
||||
appCurrency = appCurrency,
|
||||
state = state
|
||||
state = state,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -426,10 +422,10 @@ private fun setMultiWalletFiatRate(
|
|||
walletData.copy(
|
||||
currencyData = currencyData.copy(
|
||||
fiatAmountFormatted = fiatAmountFormatted,
|
||||
fiatAmount = fiatAmount
|
||||
fiatAmount = fiatAmount,
|
||||
),
|
||||
fiatRate = rate,
|
||||
fiatRateString = rateFormatter(rate)
|
||||
fiatRateString = rateFormatter(rate),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -437,15 +433,52 @@ private fun setMultiWalletFiatRate(
|
|||
.updateWalletsData(newWalletsData)
|
||||
}
|
||||
|
||||
private fun setSingleWalletFiatRates(
|
||||
fiatRates: Map<Currency, BigDecimal>,
|
||||
appCurrency: FiatCurrency,
|
||||
rateFormatter: (BigDecimal) -> String,
|
||||
state: WalletState,
|
||||
):
|
||||
WalletState {
|
||||
val blockchainFiatRate = fiatRates.entries.firstOrNull { it.key.isBlockchain() }
|
||||
val tokenFiatRate = fiatRates.entries.firstOrNull { it.key.isToken() }
|
||||
Timber.e("Token Fiat Rate is ${tokenFiatRate ?: "NULL"}")
|
||||
val updatedState = updateStateWithFiatRate(blockchainFiatRate?.toPair(), appCurrency, rateFormatter, state)
|
||||
return updateStateWithFiatRate(tokenFiatRate?.toPair(), appCurrency, rateFormatter, updatedState)
|
||||
}
|
||||
|
||||
private fun updateStateWithFiatRate(
|
||||
fiatRate: Pair<Currency, BigDecimal>?,
|
||||
appCurrency: FiatCurrency,
|
||||
rateFormatter: (BigDecimal) -> String,
|
||||
state: WalletState,
|
||||
): WalletState {
|
||||
return if (fiatRate != null) {
|
||||
val currency = fiatRate.first
|
||||
val rate = fiatRate.second
|
||||
|
||||
setSingleWalletFiatRate(
|
||||
rate = rate,
|
||||
rateFormatted = rateFormatter(rate),
|
||||
currency = currency,
|
||||
appCurrency = appCurrency,
|
||||
state = state,
|
||||
)
|
||||
} else {
|
||||
state
|
||||
}
|
||||
}
|
||||
|
||||
private fun setSingleWalletFiatRate(
|
||||
rate: BigDecimal,
|
||||
rateFormatted: String,
|
||||
currency: Currency,
|
||||
appCurrency: FiatCurrency,
|
||||
state: WalletState
|
||||
state: WalletState,
|
||||
): WalletState {
|
||||
val wallet = state.primaryWalletManager?.wallet ?: return state
|
||||
val token = wallet.getFirstToken()
|
||||
Timber.e("Working with currency: ${currency.currencyName}")
|
||||
|
||||
if (currency == state.primaryWallet?.currency) {
|
||||
val fiatAmount = wallet.amounts[AmountType.Coin]?.value
|
||||
|
|
@ -456,23 +489,38 @@ private fun setSingleWalletFiatRate(
|
|||
fiatRateString = rateFormatted
|
||||
)
|
||||
return state.updateWalletData(walletData)
|
||||
|
||||
} else if (currency is Currency.Token && currency.token == token) {
|
||||
Timber.e("Working with token fiat rate")
|
||||
|
||||
val tokenFiatAmount = wallet.getTokenAmount(token)
|
||||
?.value
|
||||
?.toFiatString(rate, appCurrency.code)
|
||||
val tokenAmountFormatted = tokenFiatAmount?.toFiatString(rate, appCurrency.code)
|
||||
|
||||
val tokenData = state.primaryWallet?.currencyData?.token?.copy(
|
||||
fiatAmountFormatted = tokenAmountFormatted,
|
||||
fiatAmount = tokenFiatAmount,
|
||||
fiatRate = rate,
|
||||
fiatRateString = rateFormatted
|
||||
fiatRateString = rateFormatted,
|
||||
)
|
||||
// ?: TokenData(
|
||||
// fiatAmountFormatted = tokenAmountFormatted,
|
||||
// fiatAmount = tokenFiatAmount,
|
||||
// fiatRate = rate,
|
||||
// fiatRateString = rateFormatted,
|
||||
// amount = "",
|
||||
// tokenSymbol = currency.currencySymbol
|
||||
// )
|
||||
|
||||
Timber.e("Token Data is ${tokenData ?: "NULL"}")
|
||||
|
||||
val walletData = state.primaryWallet?.copy(
|
||||
currencyData = state.primaryWallet.currencyData.copy(
|
||||
token = tokenData
|
||||
)
|
||||
token = tokenData,
|
||||
),
|
||||
)
|
||||
val wallets = walletData?.let { listOf(walletData) } ?: emptyList()
|
||||
return state.updateWalletsData(wallets)
|
||||
Timber.e("Wallet Data is ${walletData ?: "NULL"}")
|
||||
return state.updateWalletData(walletData)
|
||||
}
|
||||
return state
|
||||
}
|
||||
|
|
@ -34,9 +34,11 @@ data class BalanceWidgetData(
|
|||
)
|
||||
|
||||
data class TokenData(
|
||||
val amount: String,
|
||||
val amountFormatted: String,
|
||||
val amount: BigDecimal? = null,
|
||||
val tokenSymbol: String,
|
||||
val fiatAmount: String? = null,
|
||||
val fiatAmountFormatted: String? = null,
|
||||
val fiatAmount: BigDecimal? = null,
|
||||
val fiatRateString: String? = null,
|
||||
val fiatRate: BigDecimal? = null,
|
||||
)
|
||||
|
|
@ -151,11 +153,11 @@ class BalanceWidget(
|
|||
groupBaseCurrency.show()
|
||||
tvCurrency.text = data.token?.tokenSymbol
|
||||
tvBaseCurrency.text = data.currency
|
||||
tvAmount.text = if (showAmount) data.token?.amount else ""
|
||||
tvAmount.text = if (showAmount) data.token?.amountFormatted else ""
|
||||
tvBaseAmount.text = if (showAmount) data.amountFormatted else ""
|
||||
if (showAmount) {
|
||||
tvFiatAmount.show()
|
||||
tvFiatAmount.text = data.token?.fiatAmount
|
||||
tvFiatAmount.text = data.token?.fiatAmountFormatted
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber<Walle
|
|||
walletView = MultiWalletView()
|
||||
walletView.changeWalletView(this, binding)
|
||||
}
|
||||
!state.isMultiwalletAllowed && walletView !is SingleWalletView -> {
|
||||
!state.isMultiwalletAllowed && !isSaltPay && walletView !is SingleWalletView -> {
|
||||
walletView = SingleWalletView()
|
||||
walletView.changeWalletView(this, binding)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@ package com.tangem.tap.features.wallet.ui.wallet
|
|||
|
||||
import com.tangem.tap.common.extensions.hide
|
||||
import com.tangem.tap.common.extensions.show
|
||||
import com.tangem.tap.features.wallet.redux.WalletData
|
||||
import com.tangem.tap.features.wallet.redux.WalletState
|
||||
import com.tangem.tap.features.wallet.ui.TokenData
|
||||
import com.tangem.tap.features.wallet.ui.WalletFragment
|
||||
import com.tangem.tap.store
|
||||
import com.tangem.wallet.databinding.FragmentWalletBinding
|
||||
import timber.log.Timber
|
||||
|
||||
class SaltPaySingleWalletView : WalletView() {
|
||||
override fun changeWalletView(fragment: WalletFragment, binding: FragmentWalletBinding) {
|
||||
|
|
@ -18,6 +19,7 @@ class SaltPaySingleWalletView : WalletView() {
|
|||
private fun showSingleWalletView(binding: FragmentWalletBinding) = with(binding) {
|
||||
rvMultiwallet.hide()
|
||||
btnAddToken.hide()
|
||||
rowButtons.hide()
|
||||
rvPendingTransaction.hide()
|
||||
tvTwinCardNumber.hide()
|
||||
lCardBalance.root.hide()
|
||||
|
|
@ -30,20 +32,21 @@ class SaltPaySingleWalletView : WalletView() {
|
|||
|
||||
override fun onNewState(state: WalletState) {
|
||||
val binding = binding ?: return
|
||||
state.primaryWallet ?: return
|
||||
val tokenData = state.primaryWallet?.currencyData?.token ?: return
|
||||
|
||||
setupBalance(state, state.primaryWallet, binding)
|
||||
setupBalance(state, tokenData, binding)
|
||||
}
|
||||
|
||||
private fun setupBalance(state: WalletState, primaryWallet: WalletData, binding: FragmentWalletBinding) {
|
||||
private fun setupBalance(state: WalletState, tokenData: TokenData, binding: FragmentWalletBinding) {
|
||||
binding.lSingleWalletBalance.root.show()
|
||||
Timber.e("Current address is ${state.primaryWalletManager?.wallet?.address}")
|
||||
SaltPayBalanceWidget(
|
||||
binding = binding.lSingleWalletBalance,
|
||||
data = SaltPayBalanceWidgetData(
|
||||
state = state.state,
|
||||
currencySymbol = primaryWallet.currencyData.currencySymbol,
|
||||
currency = primaryWallet.currencyData.amountFormatted,
|
||||
fiatAmount = primaryWallet.currencyData.fiatAmount,
|
||||
currencySymbol = tokenData.tokenSymbol,
|
||||
currency = tokenData.amountFormatted,
|
||||
fiatAmount = tokenData.amount, // TODO: show fiatAmount
|
||||
fiatCurrency = store.state.globalState.appCurrency,
|
||||
),
|
||||
).setup()
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@
|
|||
android:adjustViewBounds="true"
|
||||
android:contentDescription="@null"
|
||||
android:elevation="3dp"
|
||||
android:maxHeight="215dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@drawable/card_placeholder_black" />
|
||||
|
|
|
|||
|
|
@ -4,15 +4,16 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/card_balance"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="12dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="18dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="18dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<TextView
|
||||
|
|
@ -20,9 +21,10 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="@string/main_page_balance"
|
||||
android:textColor="@color/iconGray"
|
||||
android:text="@string/onboarding_balance_title"
|
||||
android:textColor="@color/text_tertiary"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toStartOf="@id/tv_currency_name"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
|
@ -50,8 +52,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:minWidth="152dp"
|
||||
android:textColor="@color/darkGray6"
|
||||
android:textSize="26sp"
|
||||
android:textColor="@color/text_primary_1"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="22 325.40 $" />
|
||||
|
||||
|
|
@ -104,10 +106,12 @@
|
|||
android:id="@+id/tv_currency_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/darkGray1"
|
||||
android:textSize="16sp"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@color/text_tertiary"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:drawableEndCompat="@drawable/ic_arrow_angle_down"
|
||||
app:drawableTint="@color/darkGray1"
|
||||
app:drawableTint="@color/text_tertiary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="USD" />
|
||||
|
|
|
|||
|
|
@ -87,4 +87,6 @@
|
|||
<string name="card_settings_reset_card_to_factory_footer">Factory Reset will completely delete the wallet from the selected card. You will not be able to restore the current wallet or use the card to recover the access code.</string>
|
||||
<string name="wallet_connect_select_network">Select network</string>
|
||||
<string name="warning_existential_deposit_message">%s network has a concept of Existential Deposit. If your account drops below %s %s it will be deactivated and any remaining funds will be destroyed.</string>
|
||||
|
||||
<string name="saltpay_backup_warning" translatable="false">To start working with the card scan the first card and make a backup</string>
|
||||
</resources>
|
||||
|
|
@ -87,4 +87,6 @@
|
|||
<string name="card_settings_reset_card_to_factory_footer">Factory Reset will completely delete the wallet from the selected card. You will not be able to restore the current wallet or use the card to recover the access code.</string>
|
||||
<string name="wallet_connect_select_network">Select network</string>
|
||||
<string name="warning_existential_deposit_message">%s network has a concept of Existential Deposit. If your account drops below %s %s it will be deactivated and any remaining funds will be destroyed.</string>
|
||||
|
||||
<string name="saltpay_backup_warning" translatable="false">To start working with the card scan the first card and make a backup</string>
|
||||
</resources>
|
||||
|
|
@ -87,4 +87,6 @@
|
|||
<string name="card_settings_reset_card_to_factory_footer">Factory Reset will completely delete the wallet from the selected card. You will not be able to restore the current wallet or use the card to recover the access code.</string>
|
||||
<string name="wallet_connect_select_network">Select network</string>
|
||||
<string name="warning_existential_deposit_message">%s network has a concept of Existential Deposit. If your account drops below %s %s it will be deactivated and any remaining funds will be destroyed.</string>
|
||||
|
||||
<string name="saltpay_backup_warning" translatable="false">To start working with the card scan the first card and make a backup</string>
|
||||
</resources>
|
||||
|
|
@ -98,4 +98,6 @@
|
|||
<string name="card_settings_reset_card_to_factory_footer">Сброс к заводским настройкам приведет к полному удалению кошелька с выбранной карты. Вы не сможете восстановить текущий кошелек или использовать эту карту для восстановления кода доступа.</string>
|
||||
<string name="wallet_connect_select_network">Выберите сеть</string>
|
||||
<string name="warning_existential_deposit_message">Сеть %s использует концепцию экзистенциального депозита. Если баланс вашего счета опустится ниже %s %s, он будет деактивирован, а все оставшиеся средства будут уничтожены.</string>
|
||||
|
||||
<string name="saltpay_backup_warning" translatable="false">Для начала работы с картой сначала отсканируйте первую карту и сделайте бэкап</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -100,4 +100,6 @@
|
|||
<string name="card_settings_reset_card_to_factory_footer">Factory Reset will completely delete the wallet from the selected card. You will not be able to restore the current wallet or use the card to recover the access code.</string>
|
||||
<string name="wallet_connect_select_network">Select network</string>
|
||||
<string name="warning_existential_deposit_message">%s network has a concept of Existential Deposit. If your account drops below %s %s it will be deactivated and any remaining funds will be destroyed.</string>
|
||||
|
||||
<string name="saltpay_backup_warning" translatable="false">To start working with the card scan the first card and make a backup</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@ import com.tangem.common.card.WalletData
|
|||
import com.tangem.common.extensions.ByteArrayKey
|
||||
import com.tangem.common.extensions.toMapKey
|
||||
import com.tangem.common.hdWallet.DerivationPath
|
||||
import com.tangem.domain.common.TapWorkarounds.getSaltPayBlockchain
|
||||
import com.tangem.domain.common.TapWorkarounds.getTangemNoteBlockchain
|
||||
import com.tangem.domain.common.TapWorkarounds.isSaltPay
|
||||
import com.tangem.domain.common.TapWorkarounds.isTangemNote
|
||||
import com.tangem.domain.common.TapWorkarounds.isTestCard
|
||||
import com.tangem.operations.CommandResponse
|
||||
import com.tangem.operations.backup.PrimaryCard
|
||||
|
|
@ -23,17 +26,26 @@ data class ScanResponse(
|
|||
val walletData: WalletData?,
|
||||
val secondTwinPublicKey: String? = null,
|
||||
val derivedKeys: Map<KeyWalletPublicKey, ExtendedPublicKeysMap> = mapOf(),
|
||||
val primaryCard: PrimaryCard? = null
|
||||
val primaryCard: PrimaryCard? = null,
|
||||
) : CommandResponse {
|
||||
|
||||
fun getBlockchain(): Blockchain {
|
||||
if (productType == ProductType.Note) return card.getTangemNoteBlockchain()
|
||||
?: return Blockchain.Unknown
|
||||
val blockchainName: String = walletData?.blockchain ?: return Blockchain.Unknown
|
||||
return Blockchain.fromId(blockchainName)
|
||||
return when (productType) {
|
||||
ProductType.SaltPay -> {
|
||||
card.getSaltPayBlockchain()
|
||||
}
|
||||
ProductType.Note -> {
|
||||
card.getTangemNoteBlockchain() ?: Blockchain.Unknown
|
||||
}
|
||||
else -> {
|
||||
val blockchainName: String = walletData?.blockchain ?: return Blockchain.Unknown
|
||||
Blockchain.fromId(blockchainName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getPrimaryToken(): Token? {
|
||||
if (card.isSaltPay) return TapWorkarounds.saltPayToken
|
||||
|
||||
val cardToken = walletData?.token ?: return null
|
||||
return Token(
|
||||
cardToken.name,
|
||||
|
|
@ -46,10 +58,8 @@ data class ScanResponse(
|
|||
fun isTangemNote(): Boolean = productType == ProductType.Note
|
||||
fun isTangemWallet(): Boolean = productType == ProductType.Wallet
|
||||
fun isTangemTwins(): Boolean = productType == ProductType.Twins
|
||||
|
||||
fun supportsHdWallet(): Boolean = card.settings.isHDWalletAllowed
|
||||
fun supportsBackup(): Boolean = card.settings.isBackupAllowed
|
||||
|
||||
fun twinsIsTwinned(): Boolean =
|
||||
card.isTangemTwins() && walletData != null && secondTwinPublicKey != null
|
||||
|
||||
|
|
@ -73,18 +83,24 @@ data class ScanResponse(
|
|||
fun hasDerivation(curve: EllipticCurve, derivationPath: DerivationPath): Boolean {
|
||||
val foundWallet = card.wallets.firstOrNull { it.curve == curve }
|
||||
?: return false
|
||||
|
||||
val extendedPublicKeysMap = derivedKeys[foundWallet.publicKey.toMapKey()] ?: return false
|
||||
|
||||
val extendedPublicKey = extendedPublicKeysMap[derivationPath]
|
||||
return extendedPublicKey != null
|
||||
}
|
||||
}
|
||||
|
||||
enum class ProductType {
|
||||
Note, Twins, Wallet
|
||||
Note, Twins, Wallet, SaltPay
|
||||
}
|
||||
|
||||
val Card.productType: ProductType
|
||||
get() = when {
|
||||
isTangemTwins() -> ProductType.Twins
|
||||
isTangemNote() -> ProductType.Note
|
||||
isSaltPay -> ProductType.SaltPay
|
||||
else -> ProductType.Wallet
|
||||
}
|
||||
|
||||
typealias KeyWalletPublicKey = ByteArrayKey
|
||||
|
||||
fun Card.isTangemTwins(): Boolean = TwinsHelper.getTwinCardNumber(cardId) != null
|
||||
|
|
@ -2,6 +2,7 @@ package com.tangem.domain.common
|
|||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.DerivationStyle
|
||||
import com.tangem.blockchain.common.Token
|
||||
import com.tangem.common.card.Card
|
||||
import java.util.*
|
||||
|
||||
|
|
@ -16,7 +17,8 @@ object TapWorkarounds {
|
|||
val Card.isStart2Coin: Boolean
|
||||
get() = isStart2CoinIssuer(issuer.name)
|
||||
val Card.isSaltPay: Boolean
|
||||
get() = false //TODO fix when we know which cards are SaltPay cards
|
||||
get() = saltPayCardIds.contains(cardId) || saltPayBatches.contains(batchId)
|
||||
|
||||
val Card.isTestCard: Boolean
|
||||
get() = batchId == TEST_CARD_BATCH && cardId.startsWith(TEST_CARD_ID_STARTS_WITH)
|
||||
val Card.useOldStyleDerivation: Boolean
|
||||
|
|
@ -40,10 +42,12 @@ object TapWorkarounds {
|
|||
return false
|
||||
}
|
||||
|
||||
fun Card.isTangemNote(): Boolean = tangemNoteBatches.contains(batchId) || isSaltPay
|
||||
fun Card.isTangemNote(): Boolean = tangemNoteBatches.contains(batchId)
|
||||
fun isTangemWalletBatch(card: Card): Boolean = tangemWalletBatches.contains(card.batchId)
|
||||
fun Card.getTangemNoteBlockchain(): Blockchain? =
|
||||
tangemNoteBatches[batchId] ?: if (isSaltPay) Blockchain.Gnosis else null
|
||||
tangemNoteBatches[batchId] ?: null
|
||||
|
||||
fun Card.getSaltPayBlockchain(): Blockchain = Blockchain.SaltPay
|
||||
|
||||
private const val START_2_COIN_ISSUER = "start2coin"
|
||||
private const val TEST_CARD_BATCH = "99FF"
|
||||
|
|
@ -77,6 +81,41 @@ object TapWorkarounds {
|
|||
)
|
||||
|
||||
private val tangemWalletBatchesWithStandardDerivationType = listOf(
|
||||
"AC01", "AC02", "CB95"
|
||||
"AC01", "AC02", "CB95",
|
||||
)
|
||||
|
||||
private val saltPayCardIds = listOf(
|
||||
"AE02000000000194",
|
||||
"AC03000000076195",
|
||||
"AC79000000000012", // TODO: remove my testing CIDs
|
||||
"AC79000000000004",// TODO: remove my testing CIDs
|
||||
"AC03000000076070",
|
||||
"AC03000000076088",
|
||||
"AC03000000076096",
|
||||
"AC03000000076104",
|
||||
"AC03000000076112",
|
||||
"AC03000000076120",
|
||||
"AC03000000076138",
|
||||
"AC03000000076146",
|
||||
"AC03000000076153",
|
||||
"AC03000000076161",
|
||||
"AC03000000076179",
|
||||
"AC03000000076187",
|
||||
"AC03000000076195",
|
||||
"AC03000000076203",
|
||||
"AC03000000076211",
|
||||
"AC03000000076229",
|
||||
// TODO: add cids
|
||||
)
|
||||
|
||||
private val saltPayBatches = listOf("AE02")
|
||||
|
||||
val saltPayToken: Token // TODO: Add real token
|
||||
get() = Token(
|
||||
name = "Wrapped xDAI",
|
||||
"WxDAI",
|
||||
"0x4346186e7461cB4DF06bCFCB4cD591423022e417",
|
||||
18,
|
||||
id = "xdai",
|
||||
)
|
||||
}
|
||||
|
|
@ -86,6 +86,7 @@ fun Blockchain.toNetworkId(): String {
|
|||
Blockchain.Polkadot -> "polkadot"
|
||||
Blockchain.PolkadotTestnet -> "polkadot/test"
|
||||
Blockchain.Kusama -> "kusama"
|
||||
Blockchain.SaltPay -> "xdai"//TODO
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +114,7 @@ fun Blockchain.toCoinId(): String {
|
|||
Blockchain.Dogecoin -> "dogecoin"
|
||||
Blockchain.Gnosis -> "xdai"
|
||||
Blockchain.Kusama -> "kusama"
|
||||
Blockchain.SaltPay -> "xdai" //TODO
|
||||
Blockchain.Unknown -> "unknown"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue