Updated on 2026-08-14
This commit is contained in:
parent
edbeb5f3bd
commit
72ef6051fb
2 changed files with 20 additions and 31 deletions
|
|
@ -1,28 +1,16 @@
|
|||
package com.tangem.data.network;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Server {
|
||||
|
||||
public static Map<String, String> getHeader() {
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Content-Type", "application/json");
|
||||
return headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://tangem-webapp.appspot.com/
|
||||
* https://tangem-services.appspot.com/
|
||||
*/
|
||||
public static class ApiTangem {
|
||||
public static final String URL_TANGEM = ServerURL.API_TANGEM;
|
||||
|
||||
public static class Method {
|
||||
public static final String INFO_VERIFY = URL_TANGEM + "info/version";
|
||||
public static final String CARD_VERIFY = URL_TANGEM + "card/verify";
|
||||
public static final String VERIFY = URL_TANGEM + "verify";
|
||||
public static final String CARD_VALIDATE = URL_TANGEM + "card/validate";
|
||||
public static final String CARD_ACTIVATE = URL_TANGEM + "card/activate";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,8 @@ import android.widget.Toast
|
|||
import com.google.zxing.WriterException
|
||||
import com.tangem.data.network.ServerApiHelper
|
||||
import com.tangem.data.network.request.ElectrumRequest
|
||||
import com.tangem.data.network.request.ExchangeRequest
|
||||
import com.tangem.data.network.request.InfuraRequest
|
||||
import com.tangem.data.network.task.loaded_wallet.ETHRequestTask
|
||||
import com.tangem.data.network.task.loaded_wallet.RateInfoTask
|
||||
import com.tangem.data.network.task.loaded_wallet.UpdateWalletInfoTask
|
||||
import com.tangem.data.nfc.VerifyCardTask
|
||||
import com.tangem.domain.cardReader.CardProtocol
|
||||
|
|
@ -179,8 +177,19 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
serverApiHelper!!.setCardVerify {
|
||||
card!!.isOnlineVerified = it.results!![0].passed
|
||||
srlLoadedWallet!!.isRefreshing = false
|
||||
|
||||
// Log.i(TAG, "setCardVerify " + it.results!![0].passed)
|
||||
}
|
||||
|
||||
// request rate info listener
|
||||
serverApiHelper!!.setRateInfoData {
|
||||
val rate = it.priceUsd.toFloat()
|
||||
card!!.rate = rate
|
||||
card!!.rateAlter = rate
|
||||
srlLoadedWallet!!.isRefreshing = false
|
||||
|
||||
// Log.i(TAG, "setRateInfoData $rate")
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestCardVerify() {
|
||||
|
|
@ -188,6 +197,10 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
serverApiHelper!!.cardVerify(card)
|
||||
}
|
||||
|
||||
private fun requestRateInfo(cryptoId: String) {
|
||||
serverApiHelper!!.rateInfoData(cryptoId)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
nfcManager!!.onResume()
|
||||
|
|
@ -544,10 +557,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
updateWalletInfoTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ElectrumRequest.listUnspent(card!!.wallet))
|
||||
}
|
||||
|
||||
// course request
|
||||
val taskRate = RateInfoTask(this@LoadedWallet)
|
||||
val rate = ExchangeRequest.GetRate(card!!.wallet, "bitcoin", "bitcoin")
|
||||
taskRate.execute(rate)
|
||||
requestRateInfo("bitcoin")
|
||||
}
|
||||
|
||||
// BitcoinCash
|
||||
|
|
@ -571,10 +581,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
val updateWalletInfoTask = UpdateWalletInfoTask(this@LoadedWallet, nodeAddress, nodePort, data)
|
||||
updateWalletInfoTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ElectrumRequest.listUnspent(card!!.wallet))
|
||||
|
||||
// course request
|
||||
val taskRate = RateInfoTask(this@LoadedWallet)
|
||||
val rate = ExchangeRequest.GetRate(card!!.wallet, "bitcoin-cash", "bitcoin-cash")
|
||||
taskRate.execute(rate)
|
||||
requestRateInfo("bitcoin-cash")
|
||||
}
|
||||
|
||||
// Ethereum
|
||||
|
|
@ -590,10 +597,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
updateETH.execute(reqETH, reqNonce)
|
||||
|
||||
// course request
|
||||
val taskRate = RateInfoTask(this@LoadedWallet)
|
||||
val rate = ExchangeRequest.GetRate(card!!.wallet, "ethereum", "ethereum")
|
||||
taskRate.execute(rate)
|
||||
requestRateInfo("ethereum")
|
||||
}
|
||||
|
||||
// Token
|
||||
|
|
@ -612,10 +616,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
reqNonce.setBlockchain(card!!.blockchain)
|
||||
updateETH.execute(reqETH, reqNonce, reqBalance)
|
||||
|
||||
// course request
|
||||
val taskRate = RateInfoTask(this@LoadedWallet)
|
||||
val rate = ExchangeRequest.GetRate(card!!.wallet, "ethereum", "ethereum")
|
||||
taskRate.execute(rate)
|
||||
requestRateInfo("ethereum")
|
||||
}
|
||||
|
||||
if (needResendTX)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue