diff --git a/src/app/modules/shared_modules/wallet_connect/controller.nim b/src/app/modules/shared_modules/wallet_connect/controller.nim index ee76af38c8..7dd28f1d5e 100644 --- a/src/app/modules/shared_modules/wallet_connect/controller.nim +++ b/src/app/modules/shared_modules/wallet_connect/controller.nim @@ -71,5 +71,5 @@ QtObject: proc sendTransaction*(self: Controller, address: string, chainId: int, password: string, txJson: string): string {.slot.} = return self.service.sendTransaction(address, chainId, password, txJson) - proc getEstimatedTimeMinutesInterval(self: Controller, chainId: int, maxFeePerGas: string): int {.slot.} = - return self.service.getEstimatedTimeMinutesInterval(chainId, maxFeePerGas).int \ No newline at end of file + proc getEstimatedTime(self: Controller, chainId: int, maxFeePerGasHex: string): int {.slot.} = + return self.service.getEstimatedTime(chainId, maxFeePerGasHex).int diff --git a/src/app_service/service/wallet_connect/service.nim b/src/app_service/service/wallet_connect/service.nim index b9efdb67b4..d2d47dae96 100644 --- a/src/app_service/service/wallet_connect/service.nim +++ b/src/app_service/service/wallet_connect/service.nim @@ -208,6 +208,20 @@ QtObject: return txResponse.getStr - proc getEstimatedTimeMinutesInterval*(self: Service, chainId: int, maxFeePerGas: string): EstimatedTime = - let maxFeePerGasInt = parseHexInt(maxFeePerGas) - return self.transactions.getEstimatedTime(chainId, $(maxFeePerGasInt.float)) + # empty maxFeePerGasHex will fetch the current chain's maxFeePerGas + proc getEstimatedTime*(self: Service, chainId: int, maxFeePerGasHex: string): EstimatedTime = + 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)) diff --git a/ui/app/AppLayouts/Wallet/services/dapps/DAppsRequestHandler.qml b/ui/app/AppLayouts/Wallet/services/dapps/DAppsRequestHandler.qml index d44ba74c09..e645c18cbd 100644 --- a/ui/app/AppLayouts/Wallet/services/dapps/DAppsRequestHandler.qml +++ b/ui/app/AppLayouts/Wallet/services/dapps/DAppsRequestHandler.qml @@ -337,15 +337,13 @@ QObject { tx = SessionRequest.methods.sendTransaction.getTxObjFromData(data) } + // Empty string instructs getEstimatedTime to fetch the blockchain value var maxFeePerGas = "" if (!!tx.maxFeePerGas) { maxFeePerGas = tx.maxFeePerGas } else if (!!tx.gasPrice) { maxFeePerGas = tx.gasPrice } - if (!maxFeePerGas) { - return "" - } return root.store.getEstimatedTime(chainId, maxFeePerGas) } diff --git a/ui/imports/shared/stores/DAppsStore.qml b/ui/imports/shared/stores/DAppsStore.qml index cc0770b23d..d2a3bb977a 100644 --- a/ui/imports/shared/stores/DAppsStore.qml +++ b/ui/imports/shared/stores/DAppsStore.qml @@ -64,9 +64,10 @@ QObject { return tx } + // Empty maxFeePerGas will fetch the current chain's maxFeePerGas // Returns ui/imports/utils -> Constants.TransactionEstimatedTime values - function getEstimatedTime(chainId, maxFeePerGas) { - return controller.getEstimatedTime(chainId, maxFeePerGas) + function getEstimatedTime(chainId, maxFeePerGasHex) { + return controller.getEstimatedTime(chainId, maxFeePerGasHex) } // Returns the hex encoded signature of the transaction or empty string if error