Updated on 2026-08-14

This commit is contained in:
Tangem 2018-10-02 13:25:59 +03:00
commit 781d032856
12 changed files with 182 additions and 152 deletions

View file

@ -253,13 +253,13 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
ServerApiHelper.INFURA_ETH_GAS_PRICE -> {
var gasPrice = infuraResponse.result
gasPrice = gasPrice.substring(2)
var l = BigInteger(gasPrice, 16)
// Rounding gas price to integer gweis
var l = BigInteger(gasPrice, 16).divide(BigInteger.valueOf(1000000000L)).multiply(BigInteger.valueOf(1000000000L))
val m = if (card!!.blockchain == Blockchain.Token) BigInteger.valueOf(60000) else BigInteger.valueOf(21000)
l = l.multiply(m)
val minFeeInGwei = card!!.getAmountInGwei(l.toString())
val normalFeeInGwei = card!!.getAmountInGwei(l.multiply(BigInteger.valueOf(12)).divide(BigInteger.valueOf(10)).toString())
val maxFeeInGwei = card!!.getAmountInGwei(l.multiply(BigInteger.valueOf(15)).divide(BigInteger.valueOf(10)).toString())
val minFeeInGwei = card!!.getAmountInGwei(l.multiply(m).toString())
val normalFeeInGwei = card!!.getAmountInGwei(l.multiply(BigInteger.valueOf(12)).divide(BigInteger.valueOf(10)).multiply(m).toString())
val maxFeeInGwei = card!!.getAmountInGwei(l.multiply(BigInteger.valueOf(15)).divide(BigInteger.valueOf(10)).multiply(m).toString())
minFee = minFeeInGwei
normalFee = normalFeeInGwei

View file

@ -99,9 +99,9 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback
Log.e("TX_RESULT", hashTX)
val nonce = card!!.GetConfirmTXCount()
val nonce = card!!.getConfirmedTXCount()
nonce.add(BigInteger.valueOf(1))
card!!.setConfirmTXCount(nonce)
card!!.setConfirmedTXCount(nonce)
Log.e("TX_RESULT", hashTX)
finishWithSuccess()

View file

@ -41,6 +41,7 @@ import com.tangem.wallet.R
import kotlinx.android.synthetic.main.fr_loaded_wallet.*
import org.json.JSONException
import java.math.BigInteger
import java.time.Instant
import java.util.*
class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notifications, SharedPreferences.OnSharedPreferenceChangeListener {
@ -71,7 +72,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
private var newPIN2 = ""
private var cardProtocol: CardProtocol? = null
private var sp: SharedPreferences? = null
private val inactiveColor: ColorStateList by lazy { resources.getColorStateList(R.color.primary) }
private val inactiveColor: ColorStateList by lazy { resources.getColorStateList(R.color.btn_dark) }
private val activeColor: ColorStateList by lazy { resources.getColorStateList(R.color.colorAccent) }
private var timerRepeatRefresh: Timer? = null
@ -284,6 +285,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
card!!.setBalanceConfirmed(balance)
card!!.balanceUnconfirmed = 0L
card!!.isBalanceReceived = true
if (card!!.blockchain != Blockchain.Token)
card!!.decimalBalance = l.toString(10)
card!!.decimalBalanceAlter = l.toString(10)
@ -295,11 +297,20 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
var nonce = infuraResponse.result
nonce = nonce.substring(2)
val count = BigInteger(nonce, 16)
card!!.setConfirmTXCount(count)
card!!.setConfirmedTXCount(count)
Log.i("$TAG eth_getTransCount", nonce)
}
ServerApiHelper.INFURA_ETH_GET_PENDING_COUNT -> {
var pending = infuraResponse.result
pending = pending.substring(2)
val count = BigInteger(pending, 16)
card!!.setUnconfirmedTXCount(count)
Log.i("$TAG eth_getPendingTxCount", pending)
}
ServerApiHelper.INFURA_ETH_CALL -> {
try {
var balanceCap = infuraResponse.result
@ -314,6 +325,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
// refresh()
requestInfura(ServerApiHelper.INFURA_ETH_GET_BALANCE, "")
requestInfura(ServerApiHelper.INFURA_ETH_GET_TRANSACTION_COUNT, "")
requestInfura(ServerApiHelper.INFURA_ETH_GET_PENDING_COUNT, "")
return@onInfuraSuccess
}
card!!.setBalanceConfirmed(balance)
@ -324,6 +336,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
requestInfura(ServerApiHelper.INFURA_ETH_GET_BALANCE, "")
requestInfura(ServerApiHelper.INFURA_ETH_GET_TRANSACTION_COUNT, "")
requestInfura(ServerApiHelper.INFURA_ETH_GET_PENDING_COUNT, "")
} catch (e: JSONException) {
e.printStackTrace()
} catch (e: NumberFormatException) {
@ -356,9 +369,9 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
Log.e("$TAG TX_RESULT", hashTX)
val nonce = card!!.GetConfirmTXCount()
val nonce = card!!.getConfirmedTXCount()
nonce.add(BigInteger.valueOf(1))
card!!.setConfirmTXCount(nonce)
card!!.setConfirmedTXCount(nonce)
Log.e("$TAG TX_RESULT", hashTX)
@ -695,13 +708,11 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
val engine = CoinEngineFactory.create(card!!.blockchain)
if (card!!.blockchain == Blockchain.Bitcoin || card!!.blockchain == Blockchain.BitcoinTestNet) {
val validator = BalanceValidator()
validator.Check(card)
tvBalanceLine1.text = validator.firstLine
tvBalanceLine2.text = validator.secondLine
tvBalanceLine1.setTextColor(ContextCompat.getColor(context!!, validator.color))
}
val validator = BalanceValidator()
validator.Check(card, false)
tvBalanceLine1.text = validator.firstLine
tvBalanceLine2.text = validator.getSecondLine(false)
tvBalanceLine1.setTextColor(ContextCompat.getColor(context!!, validator.color))
if (engine!!.hasBalanceInfo(card) || card!!.offlineBalance == null) {
if (card!!.blockchain == Blockchain.Token) {
@ -722,7 +733,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
tvBlockchain.text = card!!.blockchainName
if (card!!.hasBalanceInfo()) {
if (card!!.hasBalanceInfo() && (card!!.balance != 0L) ) {
btnExtract.isEnabled = true
btnExtract.backgroundTintList = activeColor
} else {
@ -818,6 +829,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
requestInfura(ServerApiHelper.INFURA_ETH_GET_BALANCE, "")
requestInfura(ServerApiHelper.INFURA_ETH_GET_TRANSACTION_COUNT, "")
requestInfura(ServerApiHelper.INFURA_ETH_GET_PENDING_COUNT, "")
requestRateInfo("ethereum")
}
@ -964,12 +976,15 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
startActivityForResult(intent, REQUEST_CODE_SWAP_PIN)
}
var showTime: Date= Date()
private fun showSingleToast(text: Int) {
if (singleToast == null || !singleToast!!.view.isShown) {
if (singleToast == null || !singleToast!!.view.isShown || showTime.time+2000<Date().time ) {
if (singleToast != null)
singleToast!!.cancel()
singleToast = Toast.makeText(context, text, Toast.LENGTH_LONG)
singleToast!!.show()
showTime=Date()
}
}