fix(@desktop/communities): Fix computing balances for different chains during deployment
Fix #10308
This commit is contained in:
parent
114c4e7e31
commit
5ca5882a03
|
@ -220,13 +220,14 @@ QtObject:
|
|||
|
||||
proc onSuggestedFees*(self:Service, response: string) {.slot.} =
|
||||
let responseJson = response.parseJson()
|
||||
const ethSymbol = "ETH"
|
||||
|
||||
if responseJson{"error"}.kind != JNull and responseJson{"error"}.getStr != "":
|
||||
let errorMessage = responseJson["error"].getStr
|
||||
var errorCode = ComputeFeeErrorCode.Other
|
||||
if errorMessage.contains("403 Forbidden") or errorMessage.contains("exceed"):
|
||||
errorCode = ComputeFeeErrorCode.Infura
|
||||
let ethCurrency = newCurrencyAmount(0.0, "ETH", 1, false)
|
||||
let ethCurrency = newCurrencyAmount(0.0, ethSymbol, 1, false)
|
||||
let fiatCurrency = newCurrencyAmount(0.0, self.settingsService.getCurrency(), 1, false)
|
||||
let data = ComputeDeployFeeArgs(ethCurrency: ethCurrency, fiatCurrency: fiatCurrency, errorCode: errorCode)
|
||||
self.events.emit(SIGNAL_COMPUTE_DEPLOY_FEE, data)
|
||||
|
@ -237,17 +238,21 @@ QtObject:
|
|||
let maxFees = suggestedFees.maxFeePerGasM
|
||||
let gasPrice = if suggestedFees.eip1559Enabled: maxFees else: suggestedFees.gasPrice
|
||||
|
||||
const ethSymbol = "ETH"
|
||||
|
||||
let weiValue = gwei2Wei(gasPrice) * contractGasUnits.u256
|
||||
let ethValueStr = wei2Eth(weiValue)
|
||||
let ethValue = parseFloat(ethValueStr)
|
||||
let fiatValue = self.getFiatValue(ethValue, ethSymbol)
|
||||
|
||||
let wallet = self.walletAccountService.getAccountByAddress(self.tempAccountAddress)
|
||||
let balance = wallet.getCurrencyBalance(@[self.tempChainId], ethSymbol)
|
||||
|
||||
let ethCurrency = newCurrencyAmount(ethValue, "ETH", 4, false)
|
||||
var balance = 0.0
|
||||
let tokens = wallet.tokens
|
||||
for token in tokens:
|
||||
if token.symbol == ethSymbol:
|
||||
balance = token.balancesPerChain[self.tempChainId].balance
|
||||
break
|
||||
|
||||
let ethCurrency = newCurrencyAmount(ethValue, ethSymbol, 4, false)
|
||||
let fiatCurrency = newCurrencyAmount(fiatValue, self.settingsService.getCurrency(), 2, false)
|
||||
|
||||
let data = ComputeDeployFeeArgs(ethCurrency: ethCurrency, fiatCurrency: fiatCurrency,
|
||||
|
|
Loading…
Reference in New Issue