Updated on 2026-08-14

This commit is contained in:
Tangem 2020-07-20 17:41:20 +03:00
parent 9e2c2aa3de
commit 5343873ad4
3 changed files with 42 additions and 14 deletions

View file

@ -2,8 +2,6 @@ package com.tangem.data;
import com.tangem.tangem_sdk.R;
import java.util.EnumSet;
/**
* Created by dvol on 06.08.2017.
*/
@ -38,8 +36,6 @@ public enum Blockchain {
FlowDemo("FLOW/demo", "", 1.0, R.drawable.tangem2, "Flow demo"),
TokenEmv("TTW", "ETH", 1.0, R.drawable.ic_logo_ethereum, "Ethereum");
static private EnumSet<Blockchain> payIdSupported = EnumSet.of(Blockchain.Ripple, Blockchain.Ethereum, Blockchain.Bitcoin, Blockchain.Token);
Blockchain(String ID, String currency, double multiplier, int imageResource, String officialName) {
mID = ID;
mCurrency = currency;
@ -129,9 +125,4 @@ public enum Blockchain {
}
return scheme;
}
public Boolean isPayIdSupported() {
return payIdSupported.contains(this);
}
}

View file

@ -0,0 +1,37 @@
package com.tangem.data
import java.util.*
private val payIdSupported = EnumSet.of(
Blockchain.Ripple,
Blockchain.Ethereum,
Blockchain.Bitcoin,
Blockchain.Token,
Blockchain.Litecoin,
Blockchain.Stellar,
Blockchain.StellarAsset,
Blockchain.Binance,
Blockchain.Cardano,
Blockchain.Ducatus,
Blockchain.BitcoinCash,
Blockchain.Binance,
Blockchain.BinanceAsset,
Blockchain.Rootstock,
Blockchain.RootstockToken,
Blockchain.Tezos,
Blockchain.Eos,
Blockchain.Matic
)
fun Blockchain.isPayIdSupported(): Boolean {
return payIdSupported.contains(this)
}
fun Blockchain.getPayIdNetwork(): String {
return when (this) {
Blockchain.Ripple -> "XRPL"
Blockchain.Rootstock, Blockchain.RootstockToken -> "RSK"
else -> this.currency
}
}

View file

@ -25,6 +25,8 @@ import com.tangem.App
import com.tangem.Constant
import com.tangem.data.Blockchain
import com.tangem.data.dp.PrefsManager
import com.tangem.data.getPayIdNetwork
import com.tangem.data.isPayIdSupported
import com.tangem.server_android.Result
import com.tangem.server_android.ServerApiTangem
import com.tangem.server_android.model.CardVerifyAndGetInfo
@ -156,7 +158,7 @@ class LoadedWalletFragment : BaseFragment(), NavigationResultListener, NfcAdapte
getString(R.string.loaded_wallet_load_via_qr)
)
if (ctx.blockchain.isPayIdSupported && !ctx.card.isStart2CoinCard()) {
if (ctx.blockchain.isPayIdSupported() && !ctx.card.isStart2CoinCard()) {
ivPayId.visibility = View.VISIBLE
ivPayId.imageAlpha = 100
ivPayId.setOnClickListener { createPayIdDialog() }
@ -326,7 +328,7 @@ class LoadedWalletFragment : BaseFragment(), NavigationResultListener, NfcAdapte
}
private fun getPayIdIfApplicable() {
if (ctx.blockchain.isPayIdSupported && !ctx.card.isStart2CoinCard()) {
if (ctx.blockchain.isPayIdSupported() && !ctx.card.isStart2CoinCard()) {
viewModel.getPayId(
Util.byteArrayToHexString(ctx.card.cid!!),
Util.byteArrayToHexString(ctx.card.cardPublicKey!!))
@ -376,13 +378,11 @@ class LoadedWalletFragment : BaseFragment(), NavigationResultListener, NfcAdapte
}
private fun createPayId(payId: String) {
val network = if (ctx.blockchain == Blockchain.Ripple) "XRPL" else ctx.blockchain.currency
viewModel.setPayId(
Util.byteArrayToHexString(ctx.card.cid!!),
Util.byteArrayToHexString(ctx.card.cardPublicKey!!),
payId,
ctx.coinData.wallet,
network
ctx.coinData.wallet, ctx.blockchain.getPayIdNetwork()
)
.observe(viewLifecycleOwner, Observer { result ->
when (result) {