mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-21 02:58:55 +00:00
feat(dapps): fetch max fees per gas from blockchain if not provided
Updates: #15192
This commit is contained in:
parent
4deea3461f
commit
fae3d14d50
@ -71,5 +71,5 @@ QtObject:
|
|||||||
proc sendTransaction*(self: Controller, address: string, chainId: int, password: string, txJson: string): string {.slot.} =
|
proc sendTransaction*(self: Controller, address: string, chainId: int, password: string, txJson: string): string {.slot.} =
|
||||||
return self.service.sendTransaction(address, chainId, password, txJson)
|
return self.service.sendTransaction(address, chainId, password, txJson)
|
||||||
|
|
||||||
proc getEstimatedTimeMinutesInterval(self: Controller, chainId: int, maxFeePerGas: string): int {.slot.} =
|
proc getEstimatedTime(self: Controller, chainId: int, maxFeePerGasHex: string): int {.slot.} =
|
||||||
return self.service.getEstimatedTimeMinutesInterval(chainId, maxFeePerGas).int
|
return self.service.getEstimatedTime(chainId, maxFeePerGasHex).int
|
||||||
|
@ -208,6 +208,20 @@ QtObject:
|
|||||||
|
|
||||||
return txResponse.getStr
|
return txResponse.getStr
|
||||||
|
|
||||||
proc getEstimatedTimeMinutesInterval*(self: Service, chainId: int, maxFeePerGas: string): EstimatedTime =
|
# empty maxFeePerGasHex will fetch the current chain's maxFeePerGas
|
||||||
let maxFeePerGasInt = parseHexInt(maxFeePerGas)
|
proc getEstimatedTime*(self: Service, chainId: int, maxFeePerGasHex: string): EstimatedTime =
|
||||||
return self.transactions.getEstimatedTime(chainId, $(maxFeePerGasInt.float))
|
var maxFeePerGas: float64
|
||||||
|
if maxFeePerGasHex.isEmptyOrWhitespace:
|
||||||
|
let chainFees = self.transactions.suggestedFees(chainId)
|
||||||
|
if chainFees.isNil:
|
||||||
|
return EstimatedTime.Unknown
|
||||||
|
|
||||||
|
# For non-EIP-1559 chains, we use the high fee
|
||||||
|
if chainFees.eip1559Enabled:
|
||||||
|
maxFeePerGas = chainFees.maxFeePerGasM
|
||||||
|
else:
|
||||||
|
maxFeePerGas = chainFees.maxFeePerGasL
|
||||||
|
else:
|
||||||
|
let maxFeePerGasInt = parseHexInt(maxFeePerGasHex)
|
||||||
|
maxFeePerGas = maxFeePerGasInt.float
|
||||||
|
return self.transactions.getEstimatedTime(chainId, $(maxFeePerGas))
|
||||||
|
@ -337,15 +337,13 @@ QObject {
|
|||||||
tx = SessionRequest.methods.sendTransaction.getTxObjFromData(data)
|
tx = SessionRequest.methods.sendTransaction.getTxObjFromData(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Empty string instructs getEstimatedTime to fetch the blockchain value
|
||||||
var maxFeePerGas = ""
|
var maxFeePerGas = ""
|
||||||
if (!!tx.maxFeePerGas) {
|
if (!!tx.maxFeePerGas) {
|
||||||
maxFeePerGas = tx.maxFeePerGas
|
maxFeePerGas = tx.maxFeePerGas
|
||||||
} else if (!!tx.gasPrice) {
|
} else if (!!tx.gasPrice) {
|
||||||
maxFeePerGas = tx.gasPrice
|
maxFeePerGas = tx.gasPrice
|
||||||
}
|
}
|
||||||
if (!maxFeePerGas) {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
return root.store.getEstimatedTime(chainId, maxFeePerGas)
|
return root.store.getEstimatedTime(chainId, maxFeePerGas)
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,10 @@ QObject {
|
|||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Empty maxFeePerGas will fetch the current chain's maxFeePerGas
|
||||||
// Returns ui/imports/utils -> Constants.TransactionEstimatedTime values
|
// Returns ui/imports/utils -> Constants.TransactionEstimatedTime values
|
||||||
function getEstimatedTime(chainId, maxFeePerGas) {
|
function getEstimatedTime(chainId, maxFeePerGasHex) {
|
||||||
return controller.getEstimatedTime(chainId, maxFeePerGas)
|
return controller.getEstimatedTime(chainId, maxFeePerGasHex)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the hex encoded signature of the transaction or empty string if error
|
// Returns the hex encoded signature of the transaction or empty string if error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user