mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-17 00:56:39 +00:00
fix(@desktop/communities): Fix computing balances for different chains during deployment
Fix #10308
This commit is contained in:
parent
7055a77a96
commit
81f97157e6
@ -265,13 +265,14 @@ QtObject:
|
|||||||
|
|
||||||
proc onSuggestedFees*(self:Service, response: string) {.slot.} =
|
proc onSuggestedFees*(self:Service, response: string) {.slot.} =
|
||||||
let responseJson = response.parseJson()
|
let responseJson = response.parseJson()
|
||||||
|
const ethSymbol = "ETH"
|
||||||
|
|
||||||
if responseJson{"error"}.kind != JNull and responseJson{"error"}.getStr != "":
|
if responseJson{"error"}.kind != JNull and responseJson{"error"}.getStr != "":
|
||||||
let errorMessage = responseJson["error"].getStr
|
let errorMessage = responseJson["error"].getStr
|
||||||
var errorCode = ComputeFeeErrorCode.Other
|
var errorCode = ComputeFeeErrorCode.Other
|
||||||
if errorMessage.contains("403 Forbidden") or errorMessage.contains("exceed"):
|
if errorMessage.contains("403 Forbidden") or errorMessage.contains("exceed"):
|
||||||
errorCode = ComputeFeeErrorCode.Infura
|
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 fiatCurrency = newCurrencyAmount(0.0, self.settingsService.getCurrency(), 1, false)
|
||||||
let data = ComputeDeployFeeArgs(ethCurrency: ethCurrency, fiatCurrency: fiatCurrency, errorCode: errorCode)
|
let data = ComputeDeployFeeArgs(ethCurrency: ethCurrency, fiatCurrency: fiatCurrency, errorCode: errorCode)
|
||||||
self.events.emit(SIGNAL_COMPUTE_DEPLOY_FEE, data)
|
self.events.emit(SIGNAL_COMPUTE_DEPLOY_FEE, data)
|
||||||
@ -282,17 +283,21 @@ QtObject:
|
|||||||
let maxFees = suggestedFees.maxFeePerGasM
|
let maxFees = suggestedFees.maxFeePerGasM
|
||||||
let gasPrice = if suggestedFees.eip1559Enabled: maxFees else: suggestedFees.gasPrice
|
let gasPrice = if suggestedFees.eip1559Enabled: maxFees else: suggestedFees.gasPrice
|
||||||
|
|
||||||
const ethSymbol = "ETH"
|
|
||||||
|
|
||||||
let weiValue = gwei2Wei(gasPrice) * contractGasUnits.u256
|
let weiValue = gwei2Wei(gasPrice) * contractGasUnits.u256
|
||||||
let ethValueStr = wei2Eth(weiValue)
|
let ethValueStr = wei2Eth(weiValue)
|
||||||
let ethValue = parseFloat(ethValueStr)
|
let ethValue = parseFloat(ethValueStr)
|
||||||
let fiatValue = self.getFiatValue(ethValue, ethSymbol)
|
let fiatValue = self.getFiatValue(ethValue, ethSymbol)
|
||||||
|
|
||||||
let wallet = self.walletAccountService.getAccountByAddress(self.tempAccountAddress)
|
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 fiatCurrency = newCurrencyAmount(fiatValue, self.settingsService.getCurrency(), 2, false)
|
||||||
|
|
||||||
let data = ComputeDeployFeeArgs(ethCurrency: ethCurrency, fiatCurrency: fiatCurrency,
|
let data = ComputeDeployFeeArgs(ethCurrency: ethCurrency, fiatCurrency: fiatCurrency,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user