Updated on 2026-08-14

This commit is contained in:
Tangem 2019-01-18 16:38:17 +03:00
parent 0419482795
commit 3f743ec353
5 changed files with 19 additions and 31 deletions

View file

@ -45,7 +45,7 @@ public class EthEngine extends CoinEngine {
} else if (ctx.getCoinData() instanceof EthData) {
coinData = (EthData) ctx.getCoinData();
} else {
throw new Exception("Invalid type of Blockchain data for EthEngine");
throw new Exception("Invalid type of Blockchain data for " + this.getClass().getSimpleName());
}
}

View file

@ -28,15 +28,7 @@ public class RskEngine extends EthEngine {
private static final String TAG = RskEngine.class.getSimpleName();
public RskEngine(TangemContext ctx) throws Exception {
this.ctx = ctx;
if (ctx.getCoinData() == null) {
coinData = new EthData();
ctx.setCoinData(coinData);
} else if (ctx.getCoinData() instanceof EthData) {
coinData = (EthData) ctx.getCoinData();
} else {
throw new Exception("Invalid type of Blockchain data for RskEngine");
}
super(ctx);
}
public RskEngine() {
@ -58,10 +50,14 @@ public class RskEngine extends EthEngine {
}
@Override
public Uri getShareWalletUri() { return Uri.parse(ctx.getCoinData().getWallet()); }
public Uri getShareWalletUri() {
return Uri.parse(ctx.getCoinData().getWallet());
}
@Override
public Uri getShareWalletUriExplorer() { return Uri.parse("https://explorer.rsk.co/address/" + ctx.getCoinData().getWallet()); }
public Uri getShareWalletUriExplorer() {
return Uri.parse("https://explorer.rsk.co/address/" + ctx.getCoinData().getWallet());
}
@Override
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) {
@ -138,7 +134,7 @@ public class RskEngine extends EthEngine {
throw new Exception("Error in RskEngine - invalid v");
}
tx.signature.v = (byte) v;
Log.e(TAG, "RSK_v: " +String.valueOf(v));
Log.e(TAG, "RSK_v: " + String.valueOf(v));
byte[] txForSend = tx.getEncoded();
notifyOnNeedSendPayment(txForSend);
@ -272,7 +268,7 @@ public class RskEngine extends EthEngine {
blockchainRequestsCallbacks.onComplete(false);
} else {
BigInteger nonce = coinData.getConfirmedTXCount();
nonce=nonce.add(BigInteger.valueOf(1));
nonce = nonce.add(BigInteger.valueOf(1));
coinData.setConfirmedTXCount(nonce);
ctx.setError(null);
blockchainRequestsCallbacks.onComplete(true);

View file

@ -34,21 +34,6 @@ public class RskTokenEngine extends TokenEngine {
public RskTokenEngine(TangemContext ctx) throws Exception {
super(ctx);
if (ctx.getCoinData() == null) {
coinData = new TokenData();
ctx.setCoinData(coinData);
} else if (ctx.getCoinData() instanceof TokenData) {
coinData = (TokenData) ctx.getCoinData();
} else if (ctx.getCoinData() instanceof EthData) {
// special case with receive card data substitution from server at the moment
Bundle B=new Bundle();
ctx.getCoinData().saveToBundle(B);
coinData = new TokenData();
coinData.loadFromBundle(B);
ctx.setCoinData(coinData);
} else {
throw new Exception("Invalid type of Blockchain data for RskTokenEngine");
}
}
public RskTokenEngine() {

View file

@ -55,7 +55,7 @@ public class TokenEngine extends CoinEngine {
coinData.loadFromBundle(B);
ctx.setCoinData(coinData);
} else {
throw new Exception("Invalid type of Blockchain data for TokenEngine");
throw new Exception("Invalid type of Blockchain data for " + this.getClass().getSimpleName());
}
}

View file

@ -262,7 +262,14 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
val rateInfoDataListener: ServerApiCommon.RateInfoDataListener = object : ServerApiCommon.RateInfoDataListener {
override fun onSuccess(rateInfoResponse: RateInfoResponse?){
ctx.coinData!!.rate = rateInfoResponse!!.data!!.quote!!.usd!!.price!!
try {
ctx.coinData!!.rate = rateInfoResponse!!.data!!.quote!!.usd!!.price!!
}
catch (e : java.lang.Exception) {
e.printStackTrace()
ctx.error = "Unknown response from CoinMarketCap"
}
}
override fun onFail(message: String?){