Updated on 2026-08-14
This commit is contained in:
parent
677f3de3f9
commit
1c5c623221
7 changed files with 155 additions and 27 deletions
|
|
@ -0,0 +1,46 @@
|
|||
package com.tangem.tap.domain.statePrinter
|
||||
|
||||
import com.tangem.common.extensions.toHexString
|
||||
import com.tangem.common.json.MoshiJsonConverter
|
||||
import com.tangem.domain.redux.state.StringStateConverter
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.store
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class ScanResponseConverter : StringStateConverter<AppState> {
|
||||
private val converter = MoshiJsonConverter.INSTANCE
|
||||
|
||||
override fun convert(stateHolder: AppState): String {
|
||||
val scanResponse = stateHolder.globalState.scanResponse ?: return "NULL"
|
||||
|
||||
val scanResponseMap = mutableMapOf<String, Any?>()
|
||||
val derivedKeysMap = mutableMapOf<String, Any?>()
|
||||
scanResponse.derivedKeys.forEach { (keyWalletPubKey, mapExPubKeys) ->
|
||||
val exPubKeysMap = mapExPubKeys.entries.map { (derivationPath, exPubKey) ->
|
||||
mapOf(
|
||||
"derivationPath" to derivationPath.rawPath,
|
||||
"extendedPublicKey" to mapOf(
|
||||
"publicKey" to exPubKey.publicKey.toHexString(),
|
||||
"chainCode" to exPubKey.chainCode.toHexString(),
|
||||
),
|
||||
)
|
||||
}
|
||||
derivedKeysMap[keyWalletPubKey.bytes.toHexString()] = exPubKeysMap
|
||||
|
||||
}
|
||||
scanResponseMap["derivedKeys"] = derivedKeysMap
|
||||
|
||||
val json = converter.prettyPrint(scanResponseMap)
|
||||
|
||||
return json
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun printScanResponseState() {
|
||||
val stringState = ScanResponseConverter().convert(store.state)
|
||||
Timber.d(stringState)
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package com.tangem.tap.domain.statePrinter
|
||||
|
||||
import com.tangem.blockchain.common.Wallet
|
||||
import com.tangem.common.json.MoshiJsonConverter
|
||||
import com.tangem.domain.redux.state.StringStateConverter
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.store
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class WalletStateConverter : StringStateConverter<AppState> {
|
||||
private val converter = MoshiJsonConverter.INSTANCE
|
||||
|
||||
override fun convert(stateHolder: AppState): String {
|
||||
val walletState = stateHolder.walletState
|
||||
|
||||
val walletManagers = mutableListOf<Map<String, Any?>>()
|
||||
walletState.walletManagers.forEach {
|
||||
val wallet = it.wallet
|
||||
|
||||
val walletManagerMap = mutableMapOf<String, Any?>()
|
||||
walletManagerMap["walletManager"] = mapOf<String, Any>(
|
||||
"wallet" to convertWallet(it.wallet),
|
||||
)
|
||||
|
||||
walletManagers.add(walletManagerMap)
|
||||
}
|
||||
val json = converter.prettyPrint(walletManagers)
|
||||
return json
|
||||
}
|
||||
|
||||
private fun convertWallet(wallet: Wallet): MutableMap<String, Any> {
|
||||
val walletMap = mutableMapOf<String, Any>()
|
||||
val amounts = mutableMapOf<String, Any>()
|
||||
wallet.amounts.forEach { (type, amount) ->
|
||||
val amountMap = mapOf<String, Any?>(
|
||||
"value" to amount.value?.toPlainString(),
|
||||
"currencySymbol" to amount.currencySymbol,
|
||||
"decimals" to amount.decimals,
|
||||
"type" to amount.type::class.java.simpleName,
|
||||
)
|
||||
amounts[type::class.java.simpleName] = amountMap
|
||||
}
|
||||
|
||||
val publicKeyMap = mapOf(
|
||||
"seedKey" to wallet.publicKey.seedKey,
|
||||
"derivedKey" to wallet.publicKey.derivedKey,
|
||||
"derivationPath" to wallet.publicKey.derivationPath?.rawPath,
|
||||
"blockchainKey" to wallet.publicKey.blockchainKey,
|
||||
)
|
||||
|
||||
walletMap["address"] = wallet.address
|
||||
walletMap["blockchain"] = wallet.blockchain.name
|
||||
walletMap["curve"] = wallet.blockchain.getSupportedCurves()[0].curve
|
||||
walletMap["publicKey"] = publicKeyMap
|
||||
walletMap["amounts"] = amounts
|
||||
walletMap["addresses"] = wallet.addresses.toString()
|
||||
walletMap["cardId"] = wallet.cardId
|
||||
|
||||
return walletMap
|
||||
}
|
||||
}
|
||||
|
||||
fun printWalletState() {
|
||||
val stringState = WalletStateConverter().convert(store.state)
|
||||
Timber.d(stringState)
|
||||
}
|
||||
|
|
@ -20,6 +20,8 @@ import com.tangem.tap.common.redux.global.GlobalAction
|
|||
import com.tangem.tap.common.redux.navigation.AppScreen
|
||||
import com.tangem.tap.common.redux.navigation.NavigationAction
|
||||
import com.tangem.tap.domain.configurable.warningMessage.WarningMessage
|
||||
import com.tangem.tap.domain.statePrinter.printScanResponseState
|
||||
import com.tangem.tap.domain.statePrinter.printWalletState
|
||||
import com.tangem.tap.domain.termsOfUse.CardTou
|
||||
import com.tangem.tap.features.details.redux.DetailsAction
|
||||
import com.tangem.tap.features.wallet.redux.*
|
||||
|
|
@ -29,6 +31,7 @@ import com.tangem.tap.features.wallet.ui.wallet.MultiWalletView
|
|||
import com.tangem.tap.features.wallet.ui.wallet.SingleWalletView
|
||||
import com.tangem.tap.features.wallet.ui.wallet.WalletView
|
||||
import com.tangem.tap.store
|
||||
import com.tangem.wallet.BuildConfig
|
||||
import com.tangem.wallet.R
|
||||
import com.tangem.wallet.databinding.FragmentWalletBinding
|
||||
import org.rekotlin.StoreSubscriber
|
||||
|
|
@ -80,6 +83,16 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber<Walle
|
|||
}
|
||||
setupWarningsRecyclerView()
|
||||
walletView.changeWalletView(this, binding)
|
||||
// addCustomActionOnCard()
|
||||
}
|
||||
|
||||
private fun addCustomActionOnCard() {
|
||||
if (!BuildConfig.TEST_ACTION_ENABLED) return
|
||||
|
||||
binding.ivCard.setOnClickListener {
|
||||
printScanResponseState()
|
||||
printWalletState()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupWarningsRecyclerView() {
|
||||
|
|
@ -151,10 +164,10 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber<Walle
|
|||
|
||||
private fun setupCardImage(cardImage: Artwork?) {
|
||||
Picasso.get()
|
||||
.load(cardImage?.artworkId)
|
||||
.placeholder(R.drawable.card_placeholder_black)
|
||||
?.error(R.drawable.card_placeholder_black)
|
||||
?.into(binding.ivCard)
|
||||
.load(cardImage?.artworkId)
|
||||
.placeholder(R.drawable.card_placeholder_black)
|
||||
?.error(R.drawable.card_placeholder_black)
|
||||
?.into(binding.ivCard)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue