Updated on 2026-08-14
This commit is contained in:
parent
746e915137
commit
4e378e2e3d
7 changed files with 184 additions and 8 deletions
|
|
@ -40,7 +40,6 @@ object CoinEngineFactory {
|
|||
}
|
||||
|
||||
fun create(context: TangemContext): CoinEngine? {
|
||||
|
||||
var result: CoinEngine?
|
||||
try {
|
||||
result = if (Blockchain.BitcoinCash == context.blockchain)
|
||||
|
|
@ -71,4 +70,17 @@ object CoinEngineFactory {
|
|||
return result
|
||||
}
|
||||
|
||||
fun createCardano(context: TangemContext): CoinEngine? {
|
||||
var result: CoinEngine?
|
||||
try {
|
||||
result = CardanoEngine(context)
|
||||
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
result = null
|
||||
Log.e(TAG, "Can't create Cardano CoinEngine!")
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,171 +0,0 @@
|
|||
package com.tangem.domain.wallet;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.tangem.Constant;
|
||||
import com.tangem.data.Blockchain;
|
||||
import com.tangem.card_android.data.TangemCardExtensionsKt;
|
||||
import com.tangem.card_common.data.TangemCard;
|
||||
|
||||
public class TangemContext {
|
||||
// public static final String EXTRA_BLOCKCHAIN_DATA = "BLOCKCHAIN_DATA";
|
||||
private Context context;
|
||||
private TangemCard card;
|
||||
private CoinData coinData;
|
||||
private String error;
|
||||
private String message;
|
||||
|
||||
public TangemContext() {
|
||||
|
||||
}
|
||||
|
||||
public TangemContext(TangemCard card) {
|
||||
this.card = card;
|
||||
}
|
||||
|
||||
public Blockchain getBlockchain() {
|
||||
if (card == null) return Blockchain.Unknown;
|
||||
Blockchain blockchain = Blockchain.fromId(card.getBlockchainID());
|
||||
if ((blockchain == Blockchain.Ethereum || blockchain == Blockchain.EthereumTestNet) && card.isToken()) {
|
||||
if (card.getTokenSymbol().startsWith("NFT:")) {
|
||||
return Blockchain.NftToken;
|
||||
} else {
|
||||
return Blockchain.Token;
|
||||
}
|
||||
}
|
||||
if ((blockchain == Blockchain.Rootstock) && card.isToken()) {
|
||||
return Blockchain.RootstockToken;
|
||||
}
|
||||
return blockchain;
|
||||
}
|
||||
|
||||
// public void setBlockchain(Blockchain blockchain) {
|
||||
// if (card == null) return;
|
||||
// card.setBlockchainID(blockchain.getID());
|
||||
// }
|
||||
|
||||
// private String blockchainName = "";
|
||||
|
||||
public String getBlockchainName() {
|
||||
Blockchain blockchain = getBlockchain();
|
||||
if (blockchain == Blockchain.Token || blockchain == Blockchain.RootstockToken) {
|
||||
String token = card.getTokenSymbol();
|
||||
return token + " <br><small><small> " + getBlockchain().getOfficialName() + " smart contract token</small></small>";
|
||||
}
|
||||
if (blockchain == Blockchain.NftToken) {
|
||||
return card.getTokenSymbol().substring(4) + " <br><small><small> " + getBlockchain().getOfficialName() + " NFT token</small></small>";
|
||||
}
|
||||
return blockchain.getOfficialName();
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public void setContext(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public TangemCard getCard() {
|
||||
return card;
|
||||
}
|
||||
|
||||
public void setCard(TangemCard card) {
|
||||
this.card = card;
|
||||
}
|
||||
|
||||
public CoinData getCoinData() {
|
||||
return coinData;
|
||||
}
|
||||
|
||||
public void setCoinData(CoinData coinData) {
|
||||
this.coinData = coinData;
|
||||
}
|
||||
|
||||
public void setError(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public void setError(int valueId) {
|
||||
this.error = getString(valueId);
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public boolean hasError() {
|
||||
return error != null && !error.isEmpty();
|
||||
}
|
||||
|
||||
public void setMessage(String value) {
|
||||
this.message = value;
|
||||
}
|
||||
|
||||
public void setMessage(int valueId) {
|
||||
this.message = getString(valueId);
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
public static TangemContext loadFromBundle(Context context, Bundle bundle) {
|
||||
TangemContext tangemContext = new TangemContext();
|
||||
tangemContext.setContext(context);
|
||||
|
||||
if (bundle.containsKey(TangemCardExtensionsKt.EXTRA_TANGEM_CARD_UID)) {
|
||||
tangemContext.card = new TangemCard(bundle.getString(TangemCardExtensionsKt.EXTRA_TANGEM_CARD_UID));
|
||||
TangemCardExtensionsKt.loadFromBundle(tangemContext.card, bundle.getBundle(TangemCardExtensionsKt.EXTRA_TANGEM_CARD));
|
||||
}
|
||||
|
||||
if (tangemContext.getBlockchain() != null) {
|
||||
if (bundle.containsKey(Constant.EXTRA_BLOCKCHAIN_DATA)) {
|
||||
tangemContext.coinData = CoinData.fromBundle(tangemContext.getBlockchain(), bundle.getBundle(Constant.EXTRA_BLOCKCHAIN_DATA));
|
||||
} else {
|
||||
tangemContext.coinData = CoinEngineFactory.INSTANCE.create(tangemContext).createCoinData();
|
||||
}
|
||||
}
|
||||
tangemContext.error = bundle.getString("Error");
|
||||
tangemContext.message = bundle.getString("Message");
|
||||
|
||||
return tangemContext;
|
||||
}
|
||||
|
||||
public void saveToIntent(Intent intent) {
|
||||
|
||||
if (card != null) {
|
||||
intent.putExtra(TangemCardExtensionsKt.EXTRA_TANGEM_CARD_UID, card.getUID());
|
||||
intent.putExtra(TangemCardExtensionsKt.EXTRA_TANGEM_CARD, TangemCardExtensionsKt.getAsBundle(card));
|
||||
}
|
||||
|
||||
if (coinData != null) {
|
||||
intent.putExtra(Constant.EXTRA_BLOCKCHAIN_DATA, coinData.asBundle());
|
||||
}
|
||||
|
||||
intent.putExtra("Error", error);
|
||||
intent.putExtra("Message", message);
|
||||
|
||||
}
|
||||
|
||||
public String getString(int stringId) {
|
||||
if (context != null) return getContext().getResources().getString(stringId);
|
||||
return "context.resources.string[" + stringId + "]";
|
||||
}
|
||||
|
||||
public void setDenomination(byte[] denomination) {
|
||||
try {
|
||||
CoinEngine engine = CoinEngineFactory.INSTANCE.create(getBlockchain());
|
||||
CoinEngine.InternalAmount internalAmount = engine.convertToInternalAmount(denomination);
|
||||
CoinEngine.Amount amount = engine.convertToAmount(internalAmount);
|
||||
card.setDenomination(denomination, amount.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
card.setDenomination(denomination, "N/A");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -12,7 +12,6 @@ import com.tangem.card_common.util.Util;
|
|||
import com.tangem.data.Blockchain;
|
||||
import com.tangem.data.local.PendingTransactionsStorage;
|
||||
import com.tangem.data.network.ElectrumRequest;
|
||||
import com.tangem.data.network.ServerApiCommon;
|
||||
import com.tangem.data.network.ServerApiElectrum;
|
||||
import com.tangem.domain.wallet.BTCUtils;
|
||||
import com.tangem.domain.wallet.BalanceValidator;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import com.tangem.card_common.data.TangemCard
|
|||
import com.tangem.card_common.reader.CardProtocol
|
||||
import com.tangem.card_common.tasks.VerifyCardTask
|
||||
import com.tangem.card_common.util.Util
|
||||
import com.tangem.util.LOG
|
||||
import com.tangem.util.UtilHelper
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_empty_wallet.*
|
||||
|
|
|
|||
|
|
@ -2,13 +2,10 @@ package com.tangem.ui.activity
|
|||
|
||||
import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Color
|
||||
import android.net.Uri
|
||||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.nfc.tech.IsoDep
|
||||
|
|
@ -21,7 +18,6 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.scottyab.rootbeer.RootBeer
|
||||
import com.tangem.App
|
||||
import com.tangem.Constant
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import com.tangem.card_android.data.asBundle
|
|||
import com.tangem.card_common.reader.CardProtocol
|
||||
import com.tangem.card_common.tasks.PurgeTask
|
||||
import com.tangem.card_common.util.Util
|
||||
import com.tangem.util.LOG
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_purge.*
|
||||
import kotlinx.android.synthetic.main.layout_touch_card.*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue