Updated on 2026-08-14

This commit is contained in:
Tangem 2021-07-13 01:13:00 +03:00
parent ff341704d1
commit 8495cdbeda
6 changed files with 31 additions and 14 deletions

View file

@ -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-33'
implementation 'com.tangem:blockchain:develop-34'
implementation 'com.tangem:core:fixes_for_app_release-44'
implementation 'com.tangem:sdk:fixes_for_app_release-44'

View file

@ -15,7 +15,7 @@ fun Card.getToken(): Token? {
val decimals = cardData?.tokenDecimal ?: return null
val blockchain = cardData?.blockchainName?.let { Blockchain.fromId(it) } ?: return null
if (symbol.isBlank() || contractAddress.isBlank()) return null
return Token(symbol, symbol, contractAddress, decimals, blockchain) // TODO: change to constructor without tokenName
return Token(symbol, contractAddress, decimals, blockchain)
}
fun Card.getBlockchain(): Blockchain? {

View file

@ -111,10 +111,16 @@ class CurrenciesRepository(val context: Application) {
if (isTestNet) ETHEREUM_TESTNET_TOKENS_FILE_NAME else ETHEREUM_TOKENS_FILE_NAME
val bscTokensFileName =
if (isTestNet) BSC_TESTNET_TOKENS_FILE_NAME else BSC_TOKENS_FILE_NAME
val binanceTokensFileName =
if (isTestNet) BINANCE_TESTNET_TOKENS_FILE_NAME else BINANCE_TOKENS_FILE_NAME
val ethereumTokensJson = context.assets.readJsonFileToString(ethereumTokensFileName)
val bscTokensJson = context.assets.readJsonFileToString(bscTokensFileName)
val binanceTokensJson = context.assets.readJsonFileToString(binanceTokensFileName)
return tokensAdapter.fromJson(ethereumTokensJson)!!.map { it.toToken() } +
tokensAdapter.fromJson(bscTokensJson)!!.map { it.toToken() }
tokensAdapter.fromJson(bscTokensJson)!!.map { it.toToken() } +
tokensAdapter.fromJson(binanceTokensJson)!!.map { it.toToken() }
}
fun getBlockchains(
@ -133,6 +139,8 @@ class CurrenciesRepository(val context: Application) {
private const val ETHEREUM_TESTNET_TOKENS_FILE_NAME = "ethereum_tokens_testnet"
private const val BSC_TOKENS_FILE_NAME = "bsc_tokens"
private const val BSC_TESTNET_TOKENS_FILE_NAME = "bsc_tokens_testnet"
private const val BINANCE_TOKENS_FILE_NAME = "binance_tokens"
private const val BINANCE_TESTNET_TOKENS_FILE_NAME = "binance_tokens_testnet"
private const val FILE_NAME_PREFIX_TOKENS = "tokens"
private const val FILE_NAME_PREFIX_BLOCKCHAINS = "blockchains"

View file

@ -10,7 +10,10 @@ import androidx.recyclerview.widget.RecyclerView
import com.squareup.picasso.Picasso
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.Token
import com.tangem.tap.common.extensions.*
import com.tangem.tap.common.extensions.getString
import com.tangem.tap.common.extensions.hide
import com.tangem.tap.common.extensions.loadCurrenciesIcon
import com.tangem.tap.common.extensions.show
import com.tangem.tap.domain.tokens.CardCurrencies
import com.tangem.tap.features.wallet.redux.WalletAction
import com.tangem.tap.store
@ -83,17 +86,18 @@ class CurrenciesAdapter : ListAdapter<CurrencyListItem, RecyclerView.ViewHolder>
when (element) {
is CurrencyListItem.BlockchainListItem -> {
element.blockchain.currency.toLowerCase(Locale.US)
.contains(queryNormalized)
|| element.blockchain.fullName.toLowerCase(Locale.US)
.contains(queryNormalized)
.contains(queryNormalized) ||
element.blockchain.fullName.toLowerCase(Locale.US)
.contains(queryNormalized)
}
is CurrencyListItem.TokenListItem -> {
element.token.name.toLowerCase(Locale.US).contains(queryNormalized)
|| element.token.symbol.toLowerCase(Locale.US)
.contains(queryNormalized)
element.token.name.toLowerCase(Locale.US)
.contains(queryNormalized) ||
element.token.symbol.toLowerCase(Locale.US)
.contains(queryNormalized)
}
else -> false
is CurrencyListItem.TitleListItem -> true
}
})
} else {
@ -142,7 +146,7 @@ class CurrenciesAdapter : ListAdapter<CurrencyListItem, RecyclerView.ViewHolder>
Picasso.get().loadCurrenciesIcon(
imageView = view.iv_currency,
textView = view.tv_token_letter,
token = token, blockchain = Blockchain.Ethereum
token = token, blockchain = token.blockchain
)
view.btn_add_token.setOnClickListener {
store.dispatch(WalletAction.MultiWallet.AddToken(token))
@ -176,15 +180,19 @@ sealed class CurrencyListItem {
val blockchainsTitle = R.string.add_tokens_subtitle_blockchains
val ethereumTokensTitle = R.string.add_tokens_subtitle_ethereum_tokens
val bscTokensTitle = R.string.add_tokens_subtitle_bsc_tokens
val binanceTokensTitle = R.string.add_tokens_subtitle_binance_tokens
val ethereumTokens = tokens.filter { it.blockchain == Blockchain.Ethereum }
val bscTokens = tokens.filter { it.blockchain == Blockchain.BSC }
val binanceTokens = tokens.filter { it.blockchain == Blockchain.Binance }
return listOf(TitleListItem(blockchainsTitle)) +
blockchains.map { BlockchainListItem(it) } +
listOf(TitleListItem(ethereumTokensTitle)) +
ethereumTokens.map { TokenListItem(it) } +
listOf(TitleListItem(bscTokensTitle)) +
bscTokens.map { TokenListItem(it) }
bscTokens.map { TokenListItem(it) } +
listOf(TitleListItem(binanceTokensTitle)) +
binanceTokens.map { TokenListItem(it) }
}
}
}

View file

@ -160,7 +160,7 @@ class MultiWalletMiddleware {
val walletManager = walletState?.getWalletManager(token)
?: globalState.tapWalletManager.walletManagerFactory.makeWalletManagerForApp(
card = card,
blockchain = Blockchain.Ethereum
blockchain = token.blockchain
)?.also { walletManager ->
store.dispatch(WalletAction.MultiWallet.AddWalletManagers(walletManager))
store.dispatch(WalletAction.MultiWallet.AddBlockchain(walletManager.wallet.blockchain))

View file

@ -95,6 +95,7 @@ this wallet.
<string name="add_tokens_subtitle_blockchains" translatable="false">Blockchains</string>
<string name="add_tokens_subtitle_ethereum_tokens" translatable="false">Ethereum tokens</string>
<string name="add_tokens_subtitle_bsc_tokens" translatable="false">Binance Smart Chain tokens</string>
<string name="add_tokens_subtitle_binance_tokens" translatable="false">Binance Chain tokens</string>
<string name="wallet_address_button_copy" translatable="false">Copy</string>
<string name="wallet_address_button_share" translatable="false">Share</string>
<string name="wallet_button_add_tokens" translatable="false">+ Add tokens</string>