Updated on 2026-08-14
This commit is contained in:
parent
a6e6ffab96
commit
ff22469cde
20 changed files with 12 additions and 630 deletions
|
|
@ -222,7 +222,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
|
||||
if (!engineCoin.checkAmountValue(card, txAmount, txFee, minFeeInInternalUnits, isIncludeFee)) {
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.not_enough_funds_or_incorrect_amount))
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.not_enough_funds_on_your_card))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
|
|
@ -344,7 +344,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
override fun onInfuraFail(method: String, message: String) {
|
||||
when (method) {
|
||||
ServerApiHelper.INFURA_ETH_GAS_PRICE -> {
|
||||
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_obtain_data_from_blockchain))
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
|
|
|||
|
|
@ -57,9 +57,6 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
if (PINStorage.needInit())
|
||||
PINStorage.Init(context)
|
||||
|
||||
if (LastSignStorage.needInit())
|
||||
LastSignStorage.Init(context)
|
||||
|
||||
if (Issuer.needInit())
|
||||
Issuer.Init(context)
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import com.tangem.data.network.request.ElectrumRequest
|
|||
import com.tangem.domain.cardReader.NfcManager
|
||||
import com.tangem.domain.wallet.Blockchain
|
||||
import com.tangem.domain.wallet.CoinEngineFactory
|
||||
import com.tangem.domain.wallet.LastSignStorage
|
||||
import com.tangem.domain.wallet.TangemCard
|
||||
import com.tangem.wallet.R
|
||||
import org.json.JSONException
|
||||
|
|
@ -70,13 +69,9 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback
|
|||
var hashTX = it.resultString
|
||||
|
||||
try {
|
||||
LastSignStorage.setLastMessage(card!!.wallet, hashTX)
|
||||
if (hashTX.startsWith("0x") || hashTX.startsWith("0X")) {
|
||||
hashTX = hashTX.substring(2)
|
||||
}
|
||||
val bigInt = BigInteger(hashTX, 16) //TODO: очень плохой способ
|
||||
LastSignStorage.setTxWasSend(card!!.wallet)
|
||||
LastSignStorage.setLastMessage(card!!.wallet, "")
|
||||
Log.e("TX_RESULT", hashTX)
|
||||
finishWithSuccess()
|
||||
} catch (e: Exception) {
|
||||
|
|
@ -104,20 +99,12 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback
|
|||
val tmp = infuraResponse.result
|
||||
hashTX = tmp
|
||||
} catch (e: JSONException) {
|
||||
// val msg = request.getAnswer()
|
||||
// val err = msg!!.getJSONObject("error")
|
||||
// hashTX = err.getString("message")
|
||||
// LastSignStorage.setLastMessage(card!!.wallet, hashTX)
|
||||
return
|
||||
}
|
||||
|
||||
if (hashTX.startsWith("0x") || hashTX.startsWith("0X")) {
|
||||
hashTX = hashTX.substring(2)
|
||||
}
|
||||
val bigInt = BigInteger(hashTX, 16) //TODO: очень плохой способ
|
||||
LastSignStorage.setTxWasSend(card!!.wallet)
|
||||
LastSignStorage.setLastMessage(card!!.wallet, "")
|
||||
// Log.e("TX_RESULT", hashTX)
|
||||
|
||||
|
||||
val nonce = card!!.confirmedTXCount
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
} else if (!engine.isBalanceNotZero(card))
|
||||
showSingleToast(R.string.wallet_empty)
|
||||
else if (!engine.isBalanceAlterNotZero(card))
|
||||
showSingleToast(R.string.not_enough_funds_or_incorrect_amount)
|
||||
showSingleToast(R.string.not_enough_eth_for_gas)
|
||||
else if (engine.awaitingConfirmation(card))
|
||||
showSingleToast(R.string.please_wait_while_previous)
|
||||
else if (!engine.checkUnspentTransaction(card))
|
||||
|
|
@ -263,7 +263,6 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
val height = jsUnspent.getInt("height")
|
||||
val hash = jsUnspent.getString("tx_hash")
|
||||
if (height != -1) {
|
||||
requestElectrum(card!!, ElectrumRequest.getHeader(walletAddress, height.toString()))
|
||||
requestElectrum(card!!, ElectrumRequest.getTransaction(walletAddress, hash))
|
||||
}
|
||||
}
|
||||
|
|
@ -272,20 +271,6 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
}
|
||||
|
||||
if (it.isMethod(ElectrumRequest.METHOD_GetHeader)) {
|
||||
try {
|
||||
val jsHeader = it.result
|
||||
try {
|
||||
card!!.haedersInfo
|
||||
card!!.UpdateHeaderInfo(TangemCard.HeaderInfo(jsHeader.getInt("block_height"), jsHeader.getInt("timestamp")))
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
if (it.isMethod(ElectrumRequest.METHOD_GetTransaction)) {
|
||||
try {
|
||||
val txHash = it.txHash
|
||||
|
|
@ -295,47 +280,13 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
if (tx.txID == txHash)
|
||||
tx.Raw = raw
|
||||
}
|
||||
val listHTx = card!!.historyTransactions
|
||||
for (tx in listHTx) {
|
||||
if (tx.txID == txHash) {
|
||||
tx.Raw = raw
|
||||
try {
|
||||
val prevHashes = BTCUtils.getPrevTX(raw)
|
||||
var isOur = false
|
||||
for (hash in prevHashes) {
|
||||
val checkID = BTCUtils.toHex(hash)
|
||||
for (txForCheck in listHTx) {
|
||||
if (txForCheck.txID == checkID)
|
||||
isOur = true
|
||||
}
|
||||
}
|
||||
tx.isInput = !isOur
|
||||
} catch (e: BitcoinException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
if (it.isMethod(ElectrumRequest.METHOD_SendTransaction)) {
|
||||
try {
|
||||
var hashTX = it.resultString
|
||||
try {
|
||||
LastSignStorage.setLastMessage(card!!.wallet, hashTX)
|
||||
if (hashTX.startsWith("0x") || hashTX.startsWith("0X"))
|
||||
hashTX = hashTX.substring(2)
|
||||
val bigInt = BigInteger(hashTX, 16) //TODO: очень плохой способ
|
||||
LastSignStorage.setTxWasSend(card!!.wallet)
|
||||
LastSignStorage.setLastMessage(card!!.wallet, "")
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (requestCounter == 0) updateViews()
|
||||
|
|
@ -384,11 +335,12 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
// request rate info listener
|
||||
serverApiHelper!!.setRateInfoData {
|
||||
|
||||
requestCounter--
|
||||
val rate = it.priceUsd.toFloat()
|
||||
card!!.rate = rate
|
||||
card!!.rateAlter = rate
|
||||
|
||||
requestCounter--
|
||||
if (requestCounter == 0) {
|
||||
srlLoadedWallet!!.isRefreshing = false
|
||||
updateViews()
|
||||
|
|
@ -484,9 +436,6 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
if (hashTX.startsWith("0x") || hashTX.startsWith("0X")) {
|
||||
hashTX = hashTX.substring(2)
|
||||
}
|
||||
val bigInt = BigInteger(hashTX, 16) //TODO: очень плохой способ
|
||||
LastSignStorage.setTxWasSend(card!!.wallet)
|
||||
LastSignStorage.setLastMessage(card!!.wallet, "")
|
||||
|
||||
Log.e("$TAG TX_RESULT", hashTX)
|
||||
|
||||
|
|
@ -532,7 +481,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
private fun requestInfura(method: String, contract: String) {
|
||||
requestCounter++
|
||||
serverApiHelper!!.infura(method, 67, card!!.wallet, contract, LastSignStorage.getTxForSend(card!!.wallet))
|
||||
serverApiHelper!!.infura(method, 67, card!!.wallet, contract, "")
|
||||
}
|
||||
|
||||
private fun requestCardVerify() {
|
||||
|
|
|
|||
|
|
@ -290,12 +290,6 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
tvBlockchain.text = card!!.blockchainName
|
||||
tvValidationNode.text = card!!.validationNodeDescription
|
||||
|
||||
when {
|
||||
card!!.lastInputDescription.contains("awaiting") -> tvInputs.setTextColor(ContextCompat.getColor(context!!, R.color.not_confirmed))
|
||||
card!!.lastInputDescription.contains("None") -> tvInputs.setTextColor(ContextCompat.getColor(context!!, R.color.primary_dark))
|
||||
else -> tvInputs.setTextColor(ContextCompat.getColor(context!!, R.color.confirmed))
|
||||
}
|
||||
|
||||
ivBlockchain.setImageResource(card!!.blockchain.getLogoImageResource(card!!.blockchainID, card!!.tokenSymbol))
|
||||
|
||||
if (card!!.isReusable!!)
|
||||
|
|
@ -307,7 +301,6 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
|
||||
if (card!!.status == TangemCard.Status.Loaded || card!!.status == TangemCard.Status.Purged) {
|
||||
|
||||
tvLastSigned.text = card!!.lastSignedDescription
|
||||
when {
|
||||
card!!.remainingSignatures == 0 -> {
|
||||
tvRemainingSignatures.setTextColor(ContextCompat.getColor(context!!, R.color.not_confirmed))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue