Updated on 2026-08-14

This commit is contained in:
Tangem 2018-09-06 18:34:50 +03:00
parent 4caba0bc8a
commit 3444442645
8 changed files with 107 additions and 60 deletions

View file

@ -105,7 +105,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
if (card!!.blockchain == Blockchain.Ethereum || card!!.blockchain == Blockchain.EthereumTestNet || card!!.blockchain == Blockchain.Token) {
rgFee!!.isEnabled = false
serverApiHelper!!.infuraEthGasPrice("eth_gasPrice", 67)
serverApiHelper!!.infura(ServerApiHelper.INFURA_ETH_GAS_PRICE, 67, card!!.wallet)
} else {
rgFee!!.isEnabled = true
@ -223,29 +223,31 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
}
// request eth gas price listener
serverApiHelper!!.setInfuraEthGasPrice {
var gasPrice = it.result
gasPrice = gasPrice.substring(2)
var l = BigInteger(gasPrice, 16)
serverApiHelper!!.setInfura { method, infuraResponse ->
if (method == ServerApiHelper.INFURA_ETH_GAS_PRICE) {
var gasPrice = infuraResponse.result
gasPrice = gasPrice.substring(2)
var l = BigInteger(gasPrice, 16)
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 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())
minFee = minFeeInGwei
normalFee = normalFeeInGwei
maxFee = maxFeeInGwei
etFee!!.setText(normalFeeInGwei)
etFee!!.error = null
btnSend!!.visibility = View.VISIBLE
feeRequestSuccess = true
balanceRequestSuccess = true
dtVerified = Date()
minFeeInInternalUnits = card!!.internalUnitsFromString(normalFeeInGwei)
minFee = minFeeInGwei
normalFee = normalFeeInGwei
maxFee = maxFeeInGwei
etFee!!.setText(normalFeeInGwei)
etFee!!.error = null
btnSend!!.visibility = View.VISIBLE
feeRequestSuccess = true
balanceRequestSuccess = true
dtVerified = Date()
minFeeInInternalUnits = card!!.internalUnitsFromString(normalFeeInGwei)
// Log.i("eth_gas_price", feeInGwei)
// Log.i("eth_gas_price", gasPrice)
}
}
// request estimate fee listener

View file

@ -40,6 +40,7 @@ import com.tangem.util.UtilHelper
import com.tangem.wallet.BuildConfig
import com.tangem.wallet.R
import kotlinx.android.synthetic.main.fr_loaded_wallet.*
import java.math.BigInteger
import java.util.*
class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notifications, SharedPreferences.OnSharedPreferenceChangeListener {
@ -237,6 +238,18 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
// Log.i(TAG, "setRateInfoData $rate")
}
// request eth get balance listener
serverApiHelper!!.setInfura { method, infuraResponse ->
if (method == ServerApiHelper.INFURA_ETH_GET_BALANCE) {
// Log.i("eth_get_balance", gasPrice)
}
}
}
private fun requestInfura(method: String) {
serverApiHelper!!.infura(method, 67, card!!.wallet)
}
private fun requestCardVerify() {
@ -613,9 +626,9 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
val nodeAddress = engine!!.getNextNode(card)
val nodePort = engine.getNextNodePort(card)
Log.i(TAG, nodeAddress)
Log.i(TAG, nodePort.toString())
Log.i(TAG, i.toString())
// Log.i(TAG, nodeAddress)
// Log.i(TAG, nodePort.toString())
// Log.i(TAG, i.toString())
// check balance
val connectTaskEx = UpdateWalletInfoTask(this@LoadedWallet, nodeAddress, nodePort, data)
@ -655,6 +668,9 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
// Ethereum
else if (card!!.blockchain == Blockchain.Ethereum || card!!.blockchain == Blockchain.EthereumTestNet) {
// requestInfura(ServerApiHelper.INFURA_ETH_GET_BALANCE)
val updateETH = ETHRequestTask(this@LoadedWallet, card!!.blockchain)
val reqETH = InfuraRequest.GetBalance(card!!.wallet)
reqETH.id = 67
@ -690,6 +706,10 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
if (needResendTX)
sendTransaction(LastSignStorage.getTxForSend(card!!.wallet))
// requestInfura(ServerApiHelper.INFURA_ETH_GET_BALANCE)
}
fun prepareResultIntent(): Intent {