Updated on 2026-08-14
This commit is contained in:
parent
6bfb453c6d
commit
6250f5319c
13 changed files with 217 additions and 193 deletions
|
|
@ -14,8 +14,9 @@ import android.view.KeyEvent
|
|||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import com.tangem.data.network.ElectrumRequest
|
||||
import com.tangem.data.network.ServerApiHelper
|
||||
import com.tangem.data.network.ServerApiHelperElectrum
|
||||
import com.tangem.data.network.ServerApiCommon
|
||||
import com.tangem.data.network.ServerApiElectrum
|
||||
import com.tangem.data.network.ServerApiInfura
|
||||
import com.tangem.data.network.model.InfuraResponse
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
import com.tangem.domain.wallet.*
|
||||
|
|
@ -38,8 +39,9 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
private var nfcManager: NfcManager? = null
|
||||
|
||||
private var serverApiHelper: ServerApiHelper = ServerApiHelper()
|
||||
private var serverApiHelperElectrum: ServerApiHelperElectrum = ServerApiHelperElectrum()
|
||||
private var serverApiCommon: ServerApiCommon = ServerApiCommon()
|
||||
private var serverApiInfura: ServerApiInfura = ServerApiInfura()
|
||||
private var serverApiElectrum: ServerApiElectrum = ServerApiElectrum()
|
||||
|
||||
private lateinit var ctx: TangemContext
|
||||
private lateinit var amount: CoinEngine.Amount
|
||||
|
|
@ -98,7 +100,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
if (ctx.blockchain == Blockchain.Ethereum || ctx.blockchain == Blockchain.EthereumTestNet || ctx.blockchain == Blockchain.Token) {
|
||||
rgFee.isEnabled = false
|
||||
|
||||
requestInfura(ServerApiHelper.INFURA_ETH_GAS_PRICE)
|
||||
requestInfura(ServerApiInfura.INFURA_ETH_GAS_PRICE)
|
||||
|
||||
} else {
|
||||
rgFee.isEnabled = true
|
||||
|
|
@ -195,7 +197,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
|
||||
// request electrum listener
|
||||
val electrumBodyListener: ServerApiHelperElectrum.ElectrumRequestDataListener = object : ServerApiHelperElectrum.ElectrumRequestDataListener {
|
||||
val electrumBodyListener: ServerApiElectrum.ElectrumRequestDataListener = object : ServerApiElectrum.ElectrumRequestDataListener {
|
||||
override fun onSuccess(electrumRequest: ElectrumRequest?) {
|
||||
if (electrumRequest!!.isMethod(ElectrumRequest.METHOD_GetBalance)) {
|
||||
try {
|
||||
|
|
@ -226,13 +228,13 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
|
||||
}
|
||||
serverApiHelperElectrum.setElectrumRequestData(electrumBodyListener)
|
||||
serverApiElectrum.setElectrumRequestData(electrumBodyListener)
|
||||
|
||||
// request infura eth gasPrice listener
|
||||
val infuraBodyListener: ServerApiHelper.InfuraBodyListener = object : ServerApiHelper.InfuraBodyListener {
|
||||
val infuraBodyListener: ServerApiInfura.InfuraBodyListener = object : ServerApiInfura.InfuraBodyListener {
|
||||
override fun onSuccess(method: String, infuraResponse: InfuraResponse) {
|
||||
when (method) {
|
||||
ServerApiHelper.INFURA_ETH_GAS_PRICE -> {
|
||||
ServerApiInfura.INFURA_ETH_GAS_PRICE -> {
|
||||
var gasPrice = infuraResponse.result
|
||||
gasPrice = gasPrice.substring(2)
|
||||
//TODO - remove Gwei
|
||||
|
|
@ -261,16 +263,16 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
override fun onFail(method: String, message: String) {
|
||||
when (method) {
|
||||
ServerApiHelper.INFURA_ETH_GAS_PRICE -> {
|
||||
ServerApiInfura.INFURA_ETH_GAS_PRICE -> {
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_obtain_data_from_blockchain))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
serverApiHelper.setInfuraResponse(infuraBodyListener)
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener)
|
||||
|
||||
// request estimate fee listener
|
||||
val estimateFeeListener: ServerApiHelper.EstimateFeeListener = object : ServerApiHelper.EstimateFeeListener {
|
||||
val estimateFeeListener: ServerApiCommon.EstimateFeeListener = object : ServerApiCommon.EstimateFeeListener {
|
||||
override fun onSuccess(blockCount: Int, estimateFeeResponse: String?) {
|
||||
var fee: BigDecimal?
|
||||
fee = BigDecimal(estimateFeeResponse) // BTC per 1 kb
|
||||
|
|
@ -291,17 +293,17 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
fee = fee!!.setScale(8, RoundingMode.DOWN)
|
||||
|
||||
when (blockCount) {
|
||||
ServerApiHelper.ESTIMATE_FEE_MINIMAL -> {
|
||||
ServerApiCommon.ESTIMATE_FEE_MINIMAL -> {
|
||||
minFee = CoinEngine.Amount(fee, engine.feeCurrency)
|
||||
if (rgFee.checkedRadioButtonId == R.id.rbMinimalFee) doSetFee(rgFee.checkedRadioButtonId)
|
||||
}
|
||||
|
||||
ServerApiHelper.ESTIMATE_FEE_NORMAL -> {
|
||||
ServerApiCommon.ESTIMATE_FEE_NORMAL -> {
|
||||
normalFee = CoinEngine.Amount(fee, engine.feeCurrency)
|
||||
if (rgFee.checkedRadioButtonId == R.id.rbNormalFee) doSetFee(rgFee.checkedRadioButtonId)
|
||||
}
|
||||
|
||||
ServerApiHelper.ESTIMATE_FEE_PRIORITY -> {
|
||||
ServerApiCommon.ESTIMATE_FEE_PRIORITY -> {
|
||||
maxFee = CoinEngine.Amount(fee, engine.feeCurrency)
|
||||
if (rgFee.checkedRadioButtonId == R.id.rbMaximumFee) doSetFee(rgFee.checkedRadioButtonId)
|
||||
}
|
||||
|
|
@ -318,7 +320,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_calculate_fee_wrong_data_received_from_node))
|
||||
}
|
||||
}
|
||||
serverApiHelper.setEstimateFee(estimateFeeListener)
|
||||
serverApiCommon.setEstimateFee(estimateFeeListener)
|
||||
}
|
||||
|
||||
public override fun onResume() {
|
||||
|
|
@ -460,22 +462,22 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
private fun requestElectrum(card: TangemCard, electrumRequest: ElectrumRequest) {
|
||||
if (UtilHelper.isOnline(this)) {
|
||||
serverApiHelperElectrum.electrumRequestData(card, electrumRequest)
|
||||
serverApiElectrum.electrumRequestData(card, electrumRequest)
|
||||
} else
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_obtain_data_from_blockchain))
|
||||
}
|
||||
|
||||
private fun requestInfura(method: String) {
|
||||
if (UtilHelper.isOnline(this)) {
|
||||
serverApiHelper.infura(method, 67, ctx.card!!.wallet, "", "")
|
||||
serverApiInfura.infura(method, 67, ctx.card!!.wallet, "", "")
|
||||
} else
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_obtain_data_from_blockchain))
|
||||
}
|
||||
|
||||
private fun requestEstimateFee() {
|
||||
serverApiHelper.estimateFee(ServerApiHelper.ESTIMATE_FEE_PRIORITY)
|
||||
serverApiHelper.estimateFee(ServerApiHelper.ESTIMATE_FEE_NORMAL)
|
||||
serverApiHelper.estimateFee(ServerApiHelper.ESTIMATE_FEE_MINIMAL)
|
||||
serverApiCommon.estimateFee(ServerApiCommon.ESTIMATE_FEE_PRIORITY)
|
||||
serverApiCommon.estimateFee(ServerApiCommon.ESTIMATE_FEE_NORMAL)
|
||||
serverApiCommon.estimateFee(ServerApiCommon.ESTIMATE_FEE_MINIMAL)
|
||||
}
|
||||
|
||||
private fun doSetFee(checkedRadioButtonId: Int) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import android.annotation.SuppressLint
|
|||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import com.tangem.data.network.ServerApiHelperElectrum
|
||||
import com.tangem.data.network.ServerApiElectrum
|
||||
import com.tangem.wallet.BuildConfig
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_logo.*
|
||||
|
|
@ -18,7 +18,7 @@ class LogoActivity : AppCompatActivity() {
|
|||
const val MILLIS_AUTO_HIDE = 1000
|
||||
}
|
||||
|
||||
private var serverApiHelperElectrum: ServerApiHelperElectrum = ServerApiHelperElectrum()
|
||||
private var serverApiElectrum: ServerApiElectrum = ServerApiElectrum()
|
||||
|
||||
private val hideRunnable = Runnable { this.hide() }
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import android.widget.Toast
|
|||
import com.scottyab.rootbeer.RootBeer
|
||||
import com.tangem.data.Logger
|
||||
import com.tangem.data.db.PINStorage
|
||||
import com.tangem.data.network.ServerApiHelper
|
||||
import com.tangem.data.network.ServerApiCommon
|
||||
import com.tangem.data.nfc.DeviceNFCAntennaLocation
|
||||
import com.tangem.data.nfc.ReadCardInfoTask
|
||||
import com.tangem.domain.cardReader.CardProtocol
|
||||
|
|
@ -153,7 +153,7 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
fab.setOnClickListener { showMenu(it) }
|
||||
|
||||
|
||||
val apiHelper = ServerApiHelper()
|
||||
val apiHelper = ServerApiCommon()
|
||||
apiHelper.setLastVersionListener { response ->
|
||||
try {
|
||||
if (response.isNullOrEmpty()) return@setLastVersionListener
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import android.nfc.Tag
|
|||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.view.View
|
||||
import com.tangem.data.network.Cryptonit_OtherAPI
|
||||
import com.tangem.data.network.CryptonitOtherApi
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
import com.tangem.domain.wallet.Blockchain
|
||||
import com.tangem.domain.wallet.CoinEngineFactory
|
||||
|
|
@ -30,7 +30,7 @@ class PrepareCryptonitOtherAPIWithdrawalActivity : AppCompatActivity(), NfcAdapt
|
|||
|
||||
private lateinit var ctx: TangemContext
|
||||
private var nfcManager: NfcManager? = null
|
||||
private var cryptonit: Cryptonit_OtherAPI? = null
|
||||
private var cryptonit: CryptonitOtherApi? = null
|
||||
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
|
|
@ -44,7 +44,7 @@ class PrepareCryptonitOtherAPIWithdrawalActivity : AppCompatActivity(), NfcAdapt
|
|||
|
||||
ctx = TangemContext.loadFromBundle(this, intent.extras)
|
||||
|
||||
cryptonit = Cryptonit_OtherAPI(this)
|
||||
cryptonit = CryptonitOtherApi(this)
|
||||
|
||||
tvKey.text = cryptonit!!.key
|
||||
tvUserID.text = cryptonit!!.userId
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import android.support.v7.app.AppCompatActivity
|
|||
import android.view.KeyEvent
|
||||
import android.widget.Toast
|
||||
import com.tangem.data.network.ElectrumRequest
|
||||
import com.tangem.data.network.ServerApiHelper
|
||||
import com.tangem.data.network.ServerApiHelperElectrum
|
||||
import com.tangem.data.network.ServerApiElectrum
|
||||
import com.tangem.data.network.ServerApiInfura
|
||||
import com.tangem.data.network.model.InfuraResponse
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
import com.tangem.domain.wallet.*
|
||||
|
|
@ -25,8 +25,8 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
const val EXTRA_TX: String = "TX"
|
||||
}
|
||||
|
||||
private var serverApiHelper: ServerApiHelper = ServerApiHelper()
|
||||
private var serverApiHelperElectrum: ServerApiHelperElectrum = ServerApiHelperElectrum()
|
||||
private var serverApiInfura: ServerApiInfura = ServerApiInfura()
|
||||
private var serverApiElectrum: ServerApiElectrum = ServerApiElectrum()
|
||||
|
||||
private lateinit var ctx: TangemContext
|
||||
private var tx: String? = null
|
||||
|
|
@ -46,14 +46,14 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
val engine = CoinEngineFactory.create(ctx)
|
||||
|
||||
if (ctx.blockchain == Blockchain.Ethereum || ctx.blockchain == Blockchain.EthereumTestNet || ctx.blockchain == Blockchain.Token)
|
||||
requestInfura(ServerApiHelper.INFURA_ETH_SEND_RAW_TRANSACTION, "")
|
||||
requestInfura(ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION, "")
|
||||
else if (ctx.blockchain == Blockchain.Bitcoin || ctx.blockchain == Blockchain.BitcoinTestNet)
|
||||
requestElectrum(ctx.card!!, ElectrumRequest.broadcast(ctx.card!!.wallet, tx))
|
||||
else if (ctx.blockchain == Blockchain.BitcoinCash || ctx.blockchain == Blockchain.BitcoinCashTestNet)
|
||||
requestElectrum(ctx.card!!, ElectrumRequest.broadcast(ctx.card!!.wallet, tx))
|
||||
|
||||
// request electrum listener
|
||||
val electrumBodyListener: ServerApiHelperElectrum.ElectrumRequestDataListener = object : ServerApiHelperElectrum.ElectrumRequestDataListener {
|
||||
val electrumBodyListener: ServerApiElectrum.ElectrumRequestDataListener = object : ServerApiElectrum.ElectrumRequestDataListener {
|
||||
override fun onSuccess(electrumRequest: ElectrumRequest?) {
|
||||
if (electrumRequest!!.isMethod(ElectrumRequest.METHOD_SendTransaction)) {
|
||||
if (electrumRequest.resultString.isEmpty())
|
||||
|
|
@ -67,13 +67,13 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
finishWithError(message!!)
|
||||
}
|
||||
}
|
||||
serverApiHelperElectrum.setElectrumRequestData(electrumBodyListener)
|
||||
serverApiElectrum.setElectrumRequestData(electrumBodyListener)
|
||||
|
||||
// request infura listener
|
||||
val infuraBodyListener: ServerApiHelper.InfuraBodyListener = object : ServerApiHelper.InfuraBodyListener {
|
||||
val infuraBodyListener: ServerApiInfura.InfuraBodyListener = object : ServerApiInfura.InfuraBodyListener {
|
||||
override fun onSuccess(method: String, infuraResponse: InfuraResponse) {
|
||||
when (method) {
|
||||
ServerApiHelper.INFURA_ETH_SEND_RAW_TRANSACTION -> {
|
||||
ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION -> {
|
||||
if (infuraResponse.result.isEmpty())
|
||||
finishWithError("Rejected by node: " + infuraResponse.error)
|
||||
else {
|
||||
|
|
@ -88,13 +88,13 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
override fun onFail(method: String, message: String) {
|
||||
when (method) {
|
||||
ServerApiHelper.INFURA_ETH_SEND_RAW_TRANSACTION -> {
|
||||
ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION -> {
|
||||
finishWithError(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
serverApiHelper.setInfuraResponse(infuraBodyListener)
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener)
|
||||
}
|
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
|
|
@ -132,14 +132,14 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
private fun requestInfura(method: String, contract: String) {
|
||||
if (UtilHelper.isOnline(this)) {
|
||||
serverApiHelper.infura(method, 67, ctx.card!!.wallet, contract, tx)
|
||||
serverApiInfura.infura(method, 67, ctx.card!!.wallet, contract, tx)
|
||||
} else
|
||||
finishWithError(getString(R.string.no_connection))
|
||||
}
|
||||
|
||||
private fun requestElectrum(card: TangemCard, electrumRequest: ElectrumRequest) {
|
||||
if (UtilHelper.isOnline(this)) {
|
||||
serverApiHelperElectrum.electrumRequestData(card, electrumRequest)
|
||||
serverApiElectrum.electrumRequestData(card, electrumRequest)
|
||||
} else
|
||||
finishWithError(getString(R.string.no_connection))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,9 @@ import android.widget.Toast
|
|||
import com.tangem.data.db.LocalStorage
|
||||
import com.tangem.data.db.PINStorage
|
||||
import com.tangem.data.network.ElectrumRequest
|
||||
import com.tangem.data.network.ServerApiHelper
|
||||
import com.tangem.data.network.ServerApiHelperElectrum
|
||||
import com.tangem.data.network.ServerApiCommon
|
||||
import com.tangem.data.network.ServerApiElectrum
|
||||
import com.tangem.data.network.ServerApiInfura
|
||||
import com.tangem.data.network.model.CardVerifyAndGetInfo
|
||||
import com.tangem.data.network.model.InfuraResponse
|
||||
import com.tangem.data.nfc.VerifyCardTask
|
||||
|
|
@ -64,8 +65,9 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
private var nfcManager: NfcManager? = null
|
||||
|
||||
private var serverApiHelper: ServerApiHelper = ServerApiHelper()
|
||||
private var serverApiHelperElectrum: ServerApiHelperElectrum = ServerApiHelperElectrum()
|
||||
private var serverApiCommon: ServerApiCommon = ServerApiCommon()
|
||||
private var serverApiInfura: ServerApiInfura = ServerApiInfura()
|
||||
private var serverApiElectrum: ServerApiElectrum = ServerApiElectrum()
|
||||
|
||||
private var singleToast: Toast? = null
|
||||
//private var card: TangemCard? = null
|
||||
|
|
@ -126,7 +128,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
// set listeners
|
||||
srl!!.setOnRefreshListener { refresh() }
|
||||
btnLookup.setOnClickListener {
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, engine!!.shareWalletUriExplorer)
|
||||
startActivity(browserIntent)
|
||||
}
|
||||
|
|
@ -219,7 +221,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
|
||||
// request electrum listener
|
||||
val electrumBodyListener: ServerApiHelperElectrum.ElectrumRequestDataListener = object : ServerApiHelperElectrum.ElectrumRequestDataListener {
|
||||
val electrumBodyListener: ServerApiElectrum.ElectrumRequestDataListener = object : ServerApiElectrum.ElectrumRequestDataListener {
|
||||
override fun onSuccess(electrumRequest: ElectrumRequest?) {
|
||||
if (electrumRequest!!.isMethod(ElectrumRequest.METHOD_GetBalance)) {
|
||||
try {
|
||||
|
|
@ -229,7 +231,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
ctx.coinData!!.isBalanceReceived = true
|
||||
(ctx.coinData!! as BtcData).setBalanceConfirmed(confBalance)
|
||||
(ctx.coinData!! as BtcData).balanceUnconfirmed = unconfirmedBalance
|
||||
(ctx.coinData!! as BtcData).validationNodeDescription = serverApiHelperElectrum.validationNodeDescription
|
||||
(ctx.coinData!! as BtcData).validationNodeDescription = serverApiElectrum.validationNodeDescription
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
Log.e(TAG, "FAIL METHOD_GetBalance JSONException")
|
||||
|
|
@ -293,13 +295,13 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
}
|
||||
}
|
||||
serverApiHelperElectrum.setElectrumRequestData(electrumBodyListener)
|
||||
serverApiElectrum.setElectrumRequestData(electrumBodyListener)
|
||||
|
||||
// request infura listener
|
||||
val infuraBodyListener: ServerApiHelper.InfuraBodyListener = object : ServerApiHelper.InfuraBodyListener {
|
||||
val infuraBodyListener: ServerApiInfura.InfuraBodyListener = object : ServerApiInfura.InfuraBodyListener {
|
||||
override fun onSuccess(method: String, infuraResponse: InfuraResponse) {
|
||||
when (method) {
|
||||
ServerApiHelper.INFURA_ETH_GET_BALANCE -> {
|
||||
ServerApiInfura.INFURA_ETH_GET_BALANCE -> {
|
||||
var balanceCap = infuraResponse.result
|
||||
balanceCap = balanceCap.substring(2)
|
||||
val l = BigInteger(balanceCap, 16)
|
||||
|
|
@ -320,7 +322,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
// Log.i("$TAG eth_get_balance", balanceCap)
|
||||
}
|
||||
|
||||
ServerApiHelper.INFURA_ETH_GET_TRANSACTION_COUNT -> {
|
||||
ServerApiInfura.INFURA_ETH_GET_TRANSACTION_COUNT -> {
|
||||
var nonce = infuraResponse.result
|
||||
nonce = nonce.substring(2)
|
||||
val count = BigInteger(nonce, 16)
|
||||
|
|
@ -330,7 +332,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
// Log.i("$TAG eth_getTransCount", nonce)
|
||||
}
|
||||
|
||||
ServerApiHelper.INFURA_ETH_GET_PENDING_COUNT -> {
|
||||
ServerApiInfura.INFURA_ETH_GET_PENDING_COUNT -> {
|
||||
var pending = infuraResponse.result
|
||||
pending = pending.substring(2)
|
||||
val count = BigInteger(pending, 16)
|
||||
|
|
@ -339,7 +341,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
// Log.i("$TAG eth_getPendingTxCount", pending)
|
||||
}
|
||||
|
||||
ServerApiHelper.INFURA_ETH_CALL -> {
|
||||
ServerApiInfura.INFURA_ETH_CALL -> {
|
||||
try {
|
||||
var balanceCap = infuraResponse.result
|
||||
balanceCap = balanceCap.substring(2)
|
||||
|
|
@ -355,18 +357,18 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
// requestCounter--
|
||||
// if (requestCounter == 0) srl!!.isRefreshing = false
|
||||
//
|
||||
// requestInfura(ServerApiHelper.INFURA_ETH_GET_BALANCE, "")
|
||||
// requestInfura(ServerApiHelper.INFURA_ETH_GET_TRANSACTION_COUNT, "")
|
||||
// requestInfura(ServerApiHelper.INFURA_ETH_GET_PENDING_COUNT, "")
|
||||
// requestInfura(ServerApiCommon.INFURA_ETH_GET_BALANCE, "")
|
||||
// requestInfura(ServerApiCommon.INFURA_ETH_GET_TRANSACTION_COUNT, "")
|
||||
// requestInfura(ServerApiCommon.INFURA_ETH_GET_PENDING_COUNT, "")
|
||||
// return
|
||||
// }
|
||||
(ctx.coinData!! as EthData).balanceInInternalUnits = CoinEngine.InternalAmount(l.toBigDecimal(), ctx.card.tokenSymbol)
|
||||
|
||||
// Log.i("$TAG eth_call", balanceCap)
|
||||
|
||||
requestInfura(ServerApiHelper.INFURA_ETH_GET_BALANCE, "")
|
||||
requestInfura(ServerApiHelper.INFURA_ETH_GET_TRANSACTION_COUNT, "")
|
||||
requestInfura(ServerApiHelper.INFURA_ETH_GET_PENDING_COUNT, "")
|
||||
requestInfura(ServerApiInfura.INFURA_ETH_GET_BALANCE, "")
|
||||
requestInfura(ServerApiInfura.INFURA_ETH_GET_TRANSACTION_COUNT, "")
|
||||
requestInfura(ServerApiInfura.INFURA_ETH_GET_PENDING_COUNT, "")
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
} catch (e: NumberFormatException) {
|
||||
|
|
@ -376,7 +378,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
}
|
||||
|
||||
ServerApiHelper.INFURA_ETH_SEND_RAW_TRANSACTION -> {
|
||||
ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION -> {
|
||||
try {
|
||||
var hashTX: String
|
||||
try {
|
||||
|
|
@ -411,10 +413,10 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
}
|
||||
}
|
||||
serverApiHelper.setInfuraResponse(infuraBodyListener)
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener)
|
||||
|
||||
// request card verify and get info listener
|
||||
val cardVerifyAndGetInfoListener: ServerApiHelper.CardVerifyAndGetInfoListener = object : ServerApiHelper.CardVerifyAndGetInfoListener {
|
||||
val cardVerifyAndGetInfoListener: ServerApiCommon.CardVerifyAndGetInfoListener = object : ServerApiCommon.CardVerifyAndGetInfoListener {
|
||||
override fun onSuccess(cardVerifyAndGetArtworkResponse: CardVerifyAndGetInfo.Response?) {
|
||||
val result = cardVerifyAndGetArtworkResponse?.results!![0]
|
||||
if (result.error != null) {
|
||||
|
|
@ -440,7 +442,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
if (result.artwork != null && localStorage.checkNeedUpdateArtwork(result.artwork)) {
|
||||
Log.w(TAG, "Artwork '${result.artwork!!.id}' updated, need download")
|
||||
serverApiHelper.requestArtwork(result.artwork!!.id, result.artwork!!.getUpdateDate(), ctx.card!!)
|
||||
serverApiCommon.requestArtwork(result.artwork!!.id, result.artwork!!.getUpdateDate(), ctx.card!!)
|
||||
updateViews()
|
||||
}
|
||||
// Log.i(TAG, "setCardVerify " + it.results!![0].passed)
|
||||
|
|
@ -450,10 +452,10 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
}
|
||||
}
|
||||
serverApiHelper.setCardVerifyAndGetInfoListener(cardVerifyAndGetInfoListener)
|
||||
serverApiCommon.setCardVerifyAndGetInfoListener(cardVerifyAndGetInfoListener)
|
||||
|
||||
// request artwork listener
|
||||
val artworkListener: ServerApiHelper.ArtworkListener = object : ServerApiHelper.ArtworkListener {
|
||||
val artworkListener: ServerApiCommon.ArtworkListener = object : ServerApiCommon.ArtworkListener {
|
||||
override fun onSuccess(artworkId: String?, inputStream: InputStream?, updateDate: Date?) {
|
||||
localStorage.updateArtwork(artworkId!!, inputStream!!, updateDate!!)
|
||||
ivTangemCard.setImageBitmap(localStorage.getCardArtworkBitmap(ctx.card!!))
|
||||
|
|
@ -463,10 +465,10 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
}
|
||||
}
|
||||
serverApiHelper.setArtworkListener(artworkListener)
|
||||
serverApiCommon.setArtworkListener(artworkListener)
|
||||
|
||||
// request rate info listener
|
||||
serverApiHelper.setRateInfoData {
|
||||
serverApiCommon.setRateInfoData {
|
||||
val rate = it.priceUsd.toFloat()
|
||||
ctx.coinData!!.rate = rate
|
||||
ctx.coinData!!.rateAlter = rate
|
||||
|
|
@ -836,16 +838,16 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
// Ethereum
|
||||
else if (ctx.blockchain == Blockchain.Ethereum || ctx.blockchain == Blockchain.EthereumTestNet) {
|
||||
requestInfura(ServerApiHelper.INFURA_ETH_GET_BALANCE, "")
|
||||
requestInfura(ServerApiHelper.INFURA_ETH_GET_TRANSACTION_COUNT, "")
|
||||
requestInfura(ServerApiHelper.INFURA_ETH_GET_PENDING_COUNT, "")
|
||||
requestInfura(ServerApiInfura.INFURA_ETH_GET_BALANCE, "")
|
||||
requestInfura(ServerApiInfura.INFURA_ETH_GET_TRANSACTION_COUNT, "")
|
||||
requestInfura(ServerApiInfura.INFURA_ETH_GET_PENDING_COUNT, "")
|
||||
requestRateInfo("ethereum")
|
||||
}
|
||||
|
||||
// Token
|
||||
else if (ctx.blockchain == Blockchain.Token) {
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
requestInfura(ServerApiHelper.INFURA_ETH_CALL, (engine as TokenEngine).getContractAddress(ctx.card))
|
||||
requestInfura(ServerApiInfura.INFURA_ETH_CALL, (engine as TokenEngine).getContractAddress(ctx.card))
|
||||
requestRateInfo("ethereum")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
|
@ -856,7 +858,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
private fun requestElectrum(electrumRequest: ElectrumRequest) {
|
||||
if (UtilHelper.isOnline(activity!!)) {
|
||||
requestCounter++
|
||||
serverApiHelperElectrum.electrumRequestData(ctx.card, electrumRequest)
|
||||
serverApiElectrum.electrumRequestData(ctx.card, electrumRequest)
|
||||
} else {
|
||||
Toast.makeText(activity!!, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
srl!!.isRefreshing = false
|
||||
|
|
@ -866,7 +868,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
private fun requestInfura(method: String, contract: String) {
|
||||
if (UtilHelper.isOnline(activity)) {
|
||||
requestCounter++
|
||||
serverApiHelper.infura(method, 67, ctx.card!!.wallet, contract, "")
|
||||
serverApiInfura.infura(method, 67, ctx.card!!.wallet, contract, "")
|
||||
} else {
|
||||
Toast.makeText(activity, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
srl!!.isRefreshing = false
|
||||
|
|
@ -876,7 +878,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
private fun requestVerifyAndGetInfo() {
|
||||
if (UtilHelper.isOnline(activity)) {
|
||||
if ((ctx.card!!.isOnlineVerified == null || !ctx.card!!.isOnlineVerified)) {
|
||||
serverApiHelper.cardVerifyAndGetInfo(ctx.card)
|
||||
serverApiCommon.cardVerifyAndGetInfo(ctx.card)
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(activity, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
|
|
@ -886,7 +888,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
private fun requestRateInfo(cryptoId: String) {
|
||||
if (UtilHelper.isOnline(activity)) {
|
||||
serverApiHelper.rateInfoData(cryptoId)
|
||||
serverApiCommon.rateInfoData(cryptoId)
|
||||
} else {
|
||||
Toast.makeText(activity, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
srl!!.isRefreshing = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue