Updated on 2026-08-14
This commit is contained in:
parent
7571527c23
commit
a1e86cb6fc
8 changed files with 1731 additions and 34 deletions
|
|
@ -77,7 +77,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-57'
|
||||
implementation 'com.tangem:blockchain:develop-59'
|
||||
implementation 'com.tangem.tangem-sdk-kotlin:core:develop-127'
|
||||
implementation 'com.tangem.tangem-sdk-kotlin:android:develop-127'
|
||||
|
||||
|
|
|
|||
1637
app/src/main/assets/avalanche_tokens.json
Normal file
1637
app/src/main/assets/avalanche_tokens.json
Normal file
File diff suppressed because it is too large
Load diff
24
app/src/main/assets/avalanche_tokens_testnet.json
Normal file
24
app/src/main/assets/avalanche_tokens_testnet.json
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
[
|
||||
{
|
||||
"decimalCount": 6,
|
||||
"customIconUrl": "https://i.imgur.com/LPZDXoT.png",
|
||||
"symbol": "FUJISTABLE",
|
||||
"name": "The Fuji stablecoin",
|
||||
"contractAddress": "0x2058ec2791dD28b6f67DB836ddf87534F4Bbdf22",
|
||||
"blockchain": {
|
||||
"key": "avalanche",
|
||||
"testnet": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"decimalCount": 9,
|
||||
"customIconUrl": "https://i.imgur.com/jNTqyQA.png",
|
||||
"symbol": "FUJIMOON",
|
||||
"name": "To the Moon",
|
||||
"contractAddress": "0x97132C109c6816525F7f338DCb7435E1412A7668",
|
||||
"blockchain": {
|
||||
"key": "avalanche",
|
||||
"testnet": true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
"blockchain" : {
|
||||
"key" : "binance",
|
||||
"curve" : "secp256k1",
|
||||
"testnet" : false
|
||||
"testnet" : true
|
||||
},
|
||||
"customIconUrl" : "https://assets.trustwalletapp.com/blockchains/binance/assets/MATIC-84A/logo.png",
|
||||
"name" : "Hemster - 452"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,24 @@
|
|||
[
|
||||
{
|
||||
"decimalCount" : 9,
|
||||
"symbol" : "TCA",
|
||||
"name" : "Tangem Coin A",
|
||||
"contractAddress" : "22PTNbX31Zuztd6nD82fC8nQdT2hUfWv9XWXKuDkrFqR"
|
||||
"decimalCount": 9,
|
||||
"symbol": "TCA",
|
||||
"name": "Tangem Coin A",
|
||||
"contractAddress": "22PTNbX31Zuztd6nD82fC8nQdT2hUfWv9XWXKuDkrFqR",
|
||||
"blockchain": {
|
||||
"key": "solana",
|
||||
"curve": "ed25519",
|
||||
"testnet": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"decimalCount" : 9,
|
||||
"symbol" : "TCB",
|
||||
"name" : "Tangem Coin B",
|
||||
"contractAddress" : "HmSghNPg6KCk711YJA92aPejt8auyFkvmaED6jbHfUs4"
|
||||
"decimalCount": 9,
|
||||
"symbol": "TCB",
|
||||
"name": "Tangem Coin B",
|
||||
"contractAddress": "HmSghNPg6KCk711YJA92aPejt8auyFkvmaED6jbHfUs4",
|
||||
"blockchain": {
|
||||
"key": "solana",
|
||||
"curve": "ed25519",
|
||||
"testnet": true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -9,6 +9,7 @@ import com.squareup.moshi.Types
|
|||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.Token
|
||||
import com.tangem.common.card.FirmwareVersion
|
||||
import com.tangem.common.json.MoshiJsonConverter
|
||||
import com.tangem.tap.common.extensions.readJsonFileToString
|
||||
import com.tangem.tap.network.createMoshi
|
||||
|
||||
|
|
@ -113,24 +114,28 @@ class CurrenciesRepository(val context: Application) {
|
|||
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 avalancheTokensFileName =
|
||||
if (isTestNet) AVALANCHE_TESTNET_TOKENS_FILE_NAME else AVALANCHE_TOKENS_FILE_NAME
|
||||
|
||||
val ethereumTokensJson = context.assets.readJsonFileToString(ethereumTokensFileName)
|
||||
val bscTokensJson = context.assets.readJsonFileToString(bscTokensFileName)
|
||||
val binanceTokensJson = context.assets.readJsonFileToString(binanceTokensFileName)
|
||||
val avalancheTokensJson = context.assets.readJsonFileToString(avalancheTokensFileName)
|
||||
|
||||
return tokensAdapter.fromJson(ethereumTokensJson)!!.map { it.toToken() } +
|
||||
tokensAdapter.fromJson(bscTokensJson)!!.map { it.toToken() } +
|
||||
tokensAdapter.fromJson(binanceTokensJson)!!.mapNotNull {
|
||||
// temporary exclude Binance BEP-8 tokens
|
||||
if (it.type != null && it.type == BINANCE_TOKEN_TYPE_BEP8) null else it.toToken()
|
||||
}
|
||||
tokensAdapter.fromJson(bscTokensJson)!!.map { it.toToken() } +
|
||||
tokensAdapter.fromJson(binanceTokensJson)!!.mapNotNull {
|
||||
// temporary exclude Binance BEP-8 tokens
|
||||
if (it.type != null && it.type == BINANCE_TOKEN_TYPE_BEP8) null else it.toToken()
|
||||
} +
|
||||
tokensAdapter.fromJson(avalancheTokensJson)!!.map { it.toToken() }
|
||||
}
|
||||
|
||||
fun getBlockchains(
|
||||
cardFirmware: FirmwareVersion?,
|
||||
cardFirmware: FirmwareVersion,
|
||||
isTestNet: Boolean = false
|
||||
): List<Blockchain> {
|
||||
return if (cardFirmware == null || cardFirmware < FirmwareVersion.MultiWalletAvailable) {
|
||||
return if (cardFirmware < FirmwareVersion.MultiWalletAvailable) {
|
||||
Blockchain.secp256k1Blockchains(isTestNet)
|
||||
} else {
|
||||
Blockchain.secp256k1Blockchains(isTestNet) + Blockchain.ed25519OnlyBlockchains(isTestNet)
|
||||
|
|
@ -144,6 +149,9 @@ class CurrenciesRepository(val context: Application) {
|
|||
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 AVALANCHE_TOKENS_FILE_NAME = "avalanche_tokens"
|
||||
private const val AVALANCHE_TESTNET_TOKENS_FILE_NAME = "avalanche_tokens_testnet"
|
||||
|
||||
private const val FILE_NAME_PREFIX_TOKENS = "tokens"
|
||||
private const val FILE_NAME_PREFIX_BLOCKCHAINS = "blockchains"
|
||||
|
||||
|
|
@ -152,6 +160,18 @@ class CurrenciesRepository(val context: Application) {
|
|||
fun getFileNameForTokens(cardId: String): String = "${FILE_NAME_PREFIX_TOKENS}_$cardId"
|
||||
fun getFileNameForBlockchains(cardId: String): String =
|
||||
"${FILE_NAME_PREFIX_BLOCKCHAINS}_$cardId"
|
||||
|
||||
fun injectDaoBlockchain(context: Context, tokenFileName: String, blockchain: Blockchain): String? {
|
||||
val tokenJson = context.assets.readJsonFileToString(tokenFileName)
|
||||
val converter = MoshiJsonConverter.default()
|
||||
val rawTokensList = converter.fromJson<List<MutableMap<String, Any>>>(tokenJson) ?: return null
|
||||
|
||||
rawTokensList.forEach {
|
||||
it["blockchain"] = BlockchainDao.fromBlockchain(blockchain)
|
||||
}
|
||||
|
||||
return converter.toJson(rawTokensList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -205,8 +225,7 @@ data class BlockchainDao(
|
|||
companion object {
|
||||
fun fromBlockchain(blockchain: Blockchain): BlockchainDao {
|
||||
val name = blockchain.name.removeSuffix("Testnet").lowercase()
|
||||
val isTestnet = blockchain.name.endsWith("Testnet")
|
||||
return BlockchainDao(name, isTestnet)
|
||||
return BlockchainDao(name, blockchain.isTestnet())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,22 +23,28 @@ sealed class CurrencyListItem {
|
|||
blockchains: List<Blockchain>,
|
||||
tokens: List<Token>,
|
||||
): List<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
|
||||
return createBlockchainList(blockchains) +
|
||||
createTokensList(R.string.add_tokens_subtitle_ethereum_tokens, Blockchain.Ethereum, tokens) +
|
||||
createTokensList(R.string.add_tokens_subtitle_bsc_tokens, Blockchain.BSC, tokens) +
|
||||
createTokensList(R.string.add_tokens_subtitle_binance_tokens, Blockchain.Binance, tokens) +
|
||||
createTokensList(R.string.add_tokens_subtitle_avalanche_tokens, Blockchain.Avalanche, 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, blockchain = Blockchain.Ethereum)) +
|
||||
ethereumTokens.map { TokenListItem(it) } +
|
||||
listOf(TitleListItem(bscTokensTitle, blockchain = Blockchain.BSC)) +
|
||||
bscTokens.map { TokenListItem(it) } +
|
||||
listOf(TitleListItem(binanceTokensTitle, blockchain = Blockchain.Binance)) +
|
||||
binanceTokens.map { TokenListItem(it) }
|
||||
private fun createBlockchainList(blockchains: List<Blockchain>): List<CurrencyListItem> {
|
||||
val blockchainsTitle = R.string.add_tokens_subtitle_blockchains
|
||||
return listOf(TitleListItem(blockchainsTitle)) + blockchains.map { BlockchainListItem(it) }
|
||||
}
|
||||
|
||||
private fun createTokensList(
|
||||
@StringRes titleResId: Int,
|
||||
blockchain: Blockchain,
|
||||
tokens: List<Token>
|
||||
): List<CurrencyListItem> {
|
||||
val filteredTokens = tokens.filter {
|
||||
it.blockchain == blockchain || it.blockchain == blockchain.getTestnetVersion()
|
||||
}
|
||||
val tokensListItem = filteredTokens.map { TokenListItem(it) }
|
||||
return listOf(TitleListItem(titleResId, blockchain = blockchain)) + tokensListItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@
|
|||
<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="add_tokens_subtitle_avalanche_tokens" translatable="false">Avalanche C-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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue