Updated on 2026-08-14
This commit is contained in:
parent
f2fc3e9886
commit
e122ccd0eb
20 changed files with 615 additions and 472 deletions
|
|
@ -2,14 +2,10 @@ package com.tangem.domain.wallet;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class EthData extends CoinData
|
||||
{
|
||||
private CoinEngine.InternalAmount balance=null;
|
||||
private CoinEngine.InternalAmount balanceAlter=null;
|
||||
public class EthData extends CoinData {
|
||||
private CoinEngine.InternalAmount balance = null;
|
||||
|
||||
private BigInteger countConfirmedTX = null;
|
||||
private BigInteger countUnconfirmedTX = BigInteger.valueOf(0);
|
||||
|
|
@ -46,48 +42,24 @@ public class EthData extends CoinData
|
|||
public void clearInfo() {
|
||||
super.clearInfo();
|
||||
balance = null;
|
||||
balanceAlter = null;
|
||||
}
|
||||
|
||||
public CoinEngine.InternalAmount getBalanceInInternalUnits() {
|
||||
return balance;
|
||||
|
||||
}
|
||||
public CoinEngine.InternalAmount getBalanceAlterInInternalUnits() {
|
||||
return balanceAlter;
|
||||
|
||||
}
|
||||
|
||||
public void setBalanceInInternalUnits(CoinEngine.InternalAmount value) {
|
||||
balance = value;
|
||||
}
|
||||
|
||||
public void setBalanceAlterInInternalUnits(CoinEngine.InternalAmount value) {
|
||||
balanceAlter = value;
|
||||
}
|
||||
|
||||
public Long getBalanceETH() {
|
||||
|
||||
BigDecimal b = null;
|
||||
if (balance != null) {
|
||||
b = balance; // Returns ETH / token balance
|
||||
} else if (balanceAlter != null) {
|
||||
b = balanceAlter; // or ETH balance if there're no tokens on Token card
|
||||
}
|
||||
|
||||
if (b != null) {
|
||||
return b.longValue(); // Will leave only lower 64 bits for ETH and Tokens
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFromBundle(Bundle B) {
|
||||
super.loadFromBundle(B);
|
||||
|
||||
balance = new CoinEngine.InternalAmount(B.getString("BalanceDecimal"));
|
||||
balanceAlter =new CoinEngine.InternalAmount(B.getString("BalanceDecimalAlter"));
|
||||
String currency = B.getString("BalanceCurrency");
|
||||
balance = new CoinEngine.InternalAmount(B.getString("BalanceDecimal"), currency);
|
||||
|
||||
if (B.containsKey("confirmTx"))
|
||||
countConfirmedTX = new BigInteger(B.getString("confirmTx"), 16);
|
||||
|
|
@ -97,9 +69,10 @@ public class EthData extends CoinData
|
|||
|
||||
@Override
|
||||
public void saveToBundle(Bundle B) {
|
||||
super.saveToBundle(B);
|
||||
try {
|
||||
B.putString("BalanceCurrency", balance.getCurrency());
|
||||
B.putString("BalanceDecimal", balance.toString());
|
||||
B.putString("BalanceDecimalAlter", balance.toString());
|
||||
|
||||
B.putString("confirmTx", getConfirmedTXCount().toString(16));
|
||||
B.putString("unconfirmTx", getUnconfirmedTXCount().toString(16));
|
||||
|
|
@ -110,5 +83,4 @@ public class EthData extends CoinData
|
|||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue