From fe1bae0a3adedc3f687217d2f26ca83ee9af5f5d Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Fri, 14 Feb 2025 22:44:33 +0100 Subject: [PATCH] feat(wallet): estimated time added to transaction settings --- .../wallet_section/send_new/controller.nim | 3 + .../wallet_section/send_new/io_interface.nim | 3 + .../main/wallet_section/send_new/module.nim | 8 +- .../wallet_section/send_new/path_item.nim | 80 +++++++++++++++++-- .../wallet_section/send_new/path_model.nim | 12 +++ .../main/wallet_section/send_new/view.nim | 5 +- src/app_service/service/transaction/dtoV2.nim | 6 ++ .../service/transaction/service.nim | 12 +++ src/backend/backend.nim | 5 ++ .../qmlTests/tests/tst_SendSignModal.qml | 4 + ui/app/AppLayouts/Wallet/WalletUtils.qml | 7 ++ .../popups/simpleSend/SendSignModal.qml | 10 ++- .../Wallet/stores/TransactionStoreNew.qml | 4 + .../Wallet/views/TransactionSettings.qml | 13 ++- ui/app/mainui/SendModalHandler.qml | 14 +++- vendor/status-go | 2 +- 16 files changed, 167 insertions(+), 21 deletions(-) diff --git a/src/app/modules/main/wallet_section/send_new/controller.nim b/src/app/modules/main/wallet_section/send_new/controller.nim index f6e4077895..c1e98662a4 100644 --- a/src/app/modules/main/wallet_section/send_new/controller.nim +++ b/src/app/modules/main/wallet_section/send_new/controller.nim @@ -116,6 +116,9 @@ proc setCustomTxDetails*(self: Controller, nonce: int, gasAmount: int, maxFeesPe return self.transactionService.setCustomTxDetails(nonce, gasAmount, maxFeesPerGas, priorityFee, routerInputParamsUuid, pathName, chainId, isApprovalTx, communityId) +proc getEstimatedTime*(self: Controller, chainId: int, maxFeesPerGas: string, priorityFee: string): int = + self.transactionService.getEstimatedTimeV2(chainId, maxFeesPerGas, priorityFee) + proc getCurrentNetworks*(self: Controller): seq[NetworkItem] = return self.networkService.getCurrentNetworks() diff --git a/src/app/modules/main/wallet_section/send_new/io_interface.nim b/src/app/modules/main/wallet_section/send_new/io_interface.nim index 2155e0442a..b5d524ae72 100644 --- a/src/app/modules/main/wallet_section/send_new/io_interface.nim +++ b/src/app/modules/main/wallet_section/send_new/io_interface.nim @@ -52,6 +52,9 @@ method setCustomTxDetails*(self: AccessInterface, nonce: int, gasAmount: int, ma routerInputParamsUuid: string, pathName: string, chainId: int, isApprovalTx: bool, communityId: string) {.base.} = raise newException(ValueError, "No implementation available") +method getEstimatedTime*(self: AccessInterface, chainId: int, maxFeesPerGas: string, priorityFee: string): int {.base.} = + raise newException(ValueError, "No implementation available") + method transactionWasSent*(self: AccessInterface, uuid: string, chainId: int = 0, approvalTx: bool = false, txHash: string = "", error: string = "") {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/wallet_section/send_new/module.nim b/src/app/modules/main/wallet_section/send_new/module.nim index a9ce12d5db..96537ec2d4 100644 --- a/src/app/modules/main/wallet_section/send_new/module.nim +++ b/src/app/modules/main/wallet_section/send_new/module.nim @@ -118,10 +118,13 @@ proc convertTransactionPathDtoV2ToPathItem(self: Module, txPath: TransactionPath amountOut = $txPath.amountOut, suggestedMaxFeesPerGasLowLevel = $txPath.suggestedLevelsForMaxFeesPerGas.low, suggestedPriorityFeePerGasLowLevel = $txPath.suggestedLevelsForMaxFeesPerGas.lowPriority, + suggestedEstimatedTimeLowLevel = txPath.suggestedLevelsForMaxFeesPerGas.lowEstimatedTime, suggestedMaxFeesPerGasMediumLevel = $txPath.suggestedLevelsForMaxFeesPerGas.medium, suggestedPriorityFeePerGasMediumLevel = $txPath.suggestedLevelsForMaxFeesPerGas.mediumPriority, + suggestedEstimatedTimeMediumLevel = txPath.suggestedLevelsForMaxFeesPerGas.mediumEstimatedTime, suggestedMaxFeesPerGasHighLevel = $txPath.suggestedLevelsForMaxFeesPerGas.high, suggestedPriorityFeePerGasHighLevel = $txPath.suggestedLevelsForMaxFeesPerGas.highPriority, + suggestedEstimatedTimeHighLevel = txPath.suggestedLevelsForMaxFeesPerGas.highEstimatedTime, suggestedMinPriorityFee = $txPath.suggestedMinPriorityFee, suggestedMaxPriorityFee = $txPath.suggestedMaxPriorityFee, currentBaseFee = $txPath.currentBaseFee, @@ -341,4 +344,7 @@ method setCustomTxDetails*(self: Module, nonce: int, gasAmount: int, maxFeesPerG if err.len > 0: # TODO: translate this, or find a better way to display error at this step (maybe within the popup) var data = NotificationArgs(title: "Setting custom fee", message: err) - self.events.emit(SIGNAL_DISPLAY_APP_NOTIFICATION, data) \ No newline at end of file + self.events.emit(SIGNAL_DISPLAY_APP_NOTIFICATION, data) + +method getEstimatedTime*(self: Module, chainId: int, maxFeesPerGas: string, priorityFee: string): int = + return self.controller.getEstimatedTime(chainId, maxFeesPerGas, priorityFee) \ No newline at end of file diff --git a/src/app/modules/main/wallet_section/send_new/path_item.nim b/src/app/modules/main/wallet_section/send_new/path_item.nim index 938a70d834..98bbed9fed 100644 --- a/src/app/modules/main/wallet_section/send_new/path_item.nim +++ b/src/app/modules/main/wallet_section/send_new/path_item.nim @@ -14,10 +14,13 @@ QtObject: amountOut: string suggestedMaxFeesPerGasLowLevel: string suggestedPriorityFeePerGasLowLevel: string + suggestedEstimatedTimeLowLevel: int suggestedMaxFeesPerGasMediumLevel: string suggestedPriorityFeePerGasMediumLevel: string + suggestedEstimatedTimeMediumLevel: int suggestedMaxFeesPerGasHighLevel: string suggestedPriorityFeePerGasHighLevel: string + suggestedEstimatedTimeHighLevel: int suggestedMinPriorityFee: string suggestedMaxPriorityFee: string currentBaseFee: string @@ -61,10 +64,13 @@ QtObject: amountOut: string, suggestedMaxFeesPerGasLowLevel: string, suggestedPriorityFeePerGasLowLevel: string, + suggestedEstimatedTimeLowLevel: int, suggestedMaxFeesPerGasMediumLevel: string, suggestedPriorityFeePerGasMediumLevel: string, + suggestedEstimatedTimeMediumLevel: int, suggestedMaxFeesPerGasHighLevel: string, suggestedPriorityFeePerGasHighLevel: string, + suggestedEstimatedTimeHighLevel: int, suggestedMinPriorityFee: string, suggestedMaxPriorityFee: string, currentBaseFee: string, @@ -108,10 +114,13 @@ QtObject: self.amountOut = amountOut self.suggestedMaxFeesPerGasLowLevel = suggestedMaxFeesPerGasLowLevel self.suggestedPriorityFeePerGasLowLevel = suggestedPriorityFeePerGasLowLevel + self.suggestedEstimatedTimeLowLevel = suggestedEstimatedTimeLowLevel self.suggestedMaxFeesPerGasMediumLevel = suggestedMaxFeesPerGasMediumLevel self.suggestedPriorityFeePerGasMediumLevel = suggestedPriorityFeePerGasMediumLevel + self.suggestedEstimatedTimeMediumLevel = suggestedEstimatedTimeMediumLevel self.suggestedMaxFeesPerGasHighLevel = suggestedMaxFeesPerGasHighLevel self.suggestedPriorityFeePerGasHighLevel = suggestedPriorityFeePerGasHighLevel + self.suggestedEstimatedTimeHighLevel = suggestedEstimatedTimeHighLevel self.suggestedMinPriorityFee = suggestedMinPriorityFee self.suggestedMaxPriorityFee = suggestedMaxPriorityFee self.currentBaseFee = currentBaseFee @@ -158,10 +167,13 @@ QtObject: amountOut: string, suggestedMaxFeesPerGasLowLevel: string, suggestedPriorityFeePerGasLowLevel: string, + suggestedEstimatedTimeLowLevel: int, suggestedMaxFeesPerGasMediumLevel: string, suggestedPriorityFeePerGasMediumLevel: string, + suggestedEstimatedTimeMediumLevel: int, suggestedMaxFeesPerGasHighLevel: string, suggestedPriorityFeePerGasHighLevel: string, + suggestedEstimatedTimeHighLevel: int, suggestedMinPriorityFee: string, suggestedMaxPriorityFee: string, currentBaseFee: string, @@ -195,14 +207,54 @@ QtObject: approvalL1Fee: string ): PathItem = new(result, delete) - result.setup(processorName, fromChain, toChain, fromToken, toToken, amountIn, amountInLocked, amountOut, - suggestedMaxFeesPerGasLowLevel, suggestedPriorityFeePerGasLowLevel, suggestedMaxFeesPerGasMediumLevel, - suggestedPriorityFeePerGasMediumLevel, suggestedMaxFeesPerGasHighLevel, suggestedPriorityFeePerGasHighLevel, - suggestedMinPriorityFee, suggestedMaxPriorityFee, currentBaseFee, suggestedTxNonce, suggestedTxGasAmount, - suggestedApprovalTxNonce, suggestedApprovalGasAmount, txNonce, txGasFeeMode, txMaxFeesPerGas, txBaseFee, - txPriorityFee, txGasAmount, txBonderFees, txTokenFees, txEstimatedTime, txFee, txL1Fee, txTotalFee, - approvalRequired, approvalAmountRequired, approvalContractAddress, approvalTxNonce, approvalGasFeeMode, - approvalMaxFeesPerGas, approvalBaseFee, approvalPriorityFee, approvalGasAmount, approvalEstimatedTime, approvalFee, + result.setup( + processorName, + fromChain, + toChain, + fromToken, + toToken, + amountIn, + amountInLocked, + amountOut, + suggestedMaxFeesPerGasLowLevel, + suggestedPriorityFeePerGasLowLevel, + suggestedEstimatedTimeLowLevel, + suggestedMaxFeesPerGasMediumLevel, + suggestedPriorityFeePerGasMediumLevel, + suggestedEstimatedTimeMediumLevel, + suggestedMaxFeesPerGasHighLevel, + suggestedPriorityFeePerGasHighLevel, + suggestedEstimatedTimeHighLevel, + suggestedMinPriorityFee, + suggestedMaxPriorityFee, + currentBaseFee, + suggestedTxNonce, + suggestedTxGasAmount, + suggestedApprovalTxNonce, + suggestedApprovalGasAmount, + txNonce, + txGasFeeMode, + txMaxFeesPerGas, + txBaseFee, + txPriorityFee, + txGasAmount, + txBonderFees, + txTokenFees, + txEstimatedTime, + txFee, + txL1Fee, + txTotalFee, + approvalRequired, + approvalAmountRequired, + approvalContractAddress, + approvalTxNonce, + approvalGasFeeMode, + approvalMaxFeesPerGas, + approvalBaseFee, + approvalPriorityFee, + approvalGasAmount, + approvalEstimatedTime, + approvalFee, approvalL1Fee) proc `$`*(self: PathItem): string = @@ -217,10 +269,13 @@ QtObject: result &= "\namountOut: " & $self.amountOut result &= "\nsuggestedMaxFeesPerGasLowLevel: " & $self.suggestedMaxFeesPerGasLowLevel result &= "\nsuggestedPriorityFeePerGasLowLevel: " & $self.suggestedPriorityFeePerGasLowLevel + result &= "\nsuggestedEstimatedTimeLowLevel: " & $self.suggestedEstimatedTimeLowLevel result &= "\nsuggestedMaxFeesPerGasMediumLevel: " & $self.suggestedMaxFeesPerGasMediumLevel result &= "\nsuggestedPriorityFeePerGasMediumLevel: " & $self.suggestedPriorityFeePerGasMediumLevel + result &= "\nsuggestedEstimatedTimeMediumLevel: " & $self.suggestedEstimatedTimeMediumLevel result &= "\nsuggestedMaxFeesPerGasHighLevel: " & $self.suggestedMaxFeesPerGasHighLevel result &= "\nsuggestedPriorityFeePerGasHighLevel: " & $self.suggestedPriorityFeePerGasHighLevel + result &= "\nsuggestedEstimatedTimeHighLevel: " & $self.suggestedEstimatedTimeHighLevel result &= "\nsuggestedMinPriorityFee: " & $self.suggestedMinPriorityFee result &= "\nsuggestedMaxPriorityFee: " & $self.suggestedMaxPriorityFee result &= "\ncurrentBaseFee: " & $self.currentBaseFee @@ -284,18 +339,27 @@ QtObject: proc suggestedPriorityFeePerGasLowLevel*(self: PathItem): string = return self.suggestedPriorityFeePerGasLowLevel + proc suggestedEstimatedTimeLowLevel*(self: PathItem): int = + return self.suggestedEstimatedTimeLowLevel + proc suggestedMaxFeesPerGasMediumLevel*(self: PathItem): string = return self.suggestedMaxFeesPerGasMediumLevel proc suggestedPriorityFeePerGasMediumLevel*(self: PathItem): string = return self.suggestedPriorityFeePerGasMediumLevel + proc suggestedEstimatedTimeMediumLevel*(self: PathItem): int = + return self.suggestedEstimatedTimeMediumLevel + proc suggestedMaxFeesPerGasHighLevel*(self: PathItem): string = return self.suggestedMaxFeesPerGasHighLevel proc suggestedPriorityFeePerGasHighLevel*(self: PathItem): string = return self.suggestedPriorityFeePerGasHighLevel + proc suggestedEstimatedTimeHighLevel*(self: PathItem): int = + return self.suggestedEstimatedTimeHighLevel + proc suggestedMinPriorityFee*(self: PathItem): string = return self.suggestedMinPriorityFee diff --git a/src/app/modules/main/wallet_section/send_new/path_model.nim b/src/app/modules/main/wallet_section/send_new/path_model.nim index 4846493d91..4ef9c759e4 100644 --- a/src/app/modules/main/wallet_section/send_new/path_model.nim +++ b/src/app/modules/main/wallet_section/send_new/path_model.nim @@ -17,10 +17,13 @@ type AmountOut, SuggestedMaxFeesPerGasLowLevel, SuggestedPriorityFeePerGasLowLevel, + SuggestedEstimatedTimeLowLevel, SuggestedMaxFeesPerGasMediumLevel, SuggestedPriorityFeePerGasMediumLevel, + SuggestedEstimatedTimeMediumLevel, SuggestedMaxFeesPerGasHighLevel, SuggestedPriorityFeePerGasHighLevel, + SuggestedEstimatedTimeHighLevel, SuggestedMinPriorityFee, SuggestedMaxPriorityFee, CurrentBaseFee, @@ -90,10 +93,13 @@ QtObject: ModelRole.AmountOut.int: "amountOut", ModelRole.SuggestedMaxFeesPerGasLowLevel.int: "suggestedMaxFeesPerGasLowLevel", ModelRole.SuggestedPriorityFeePerGasLowLevel.int: "suggestedPriorityFeePerGasLowLevel", + ModelRole.SuggestedEstimatedTimeLowLevel.int: "suggestedEstimatedTimeLowLevel", ModelRole.SuggestedMaxFeesPerGasMediumLevel.int: "suggestedMaxFeesPerGasMediumLevel", ModelRole.SuggestedPriorityFeePerGasMediumLevel.int: "suggestedPriorityFeePerGasMediumLevel", + ModelRole.SuggestedEstimatedTimeMediumLevel.int: "suggestedEstimatedTimeMediumLevel", ModelRole.SuggestedMaxFeesPerGasHighLevel.int: "suggestedMaxFeesPerGasHighLevel", ModelRole.SuggestedPriorityFeePerGasHighLevel.int: "suggestedPriorityFeePerGasHighLevel", + ModelRole.SuggestedEstimatedTimeHighLevel.int: "suggestedEstimatedTimeHighLevel", ModelRole.SuggestedMinPriorityFee.int: "suggestedMinPriorityFee", ModelRole.SuggestedMaxPriorityFee.int: "suggestedMaxPriorityFee", ModelRole.CurrentBaseFee.int: "currentBaseFee", @@ -166,14 +172,20 @@ QtObject: result = newQVariant(item.suggestedMaxFeesPerGasLowLevel) of ModelRole.SuggestedPriorityFeePerGasLowLevel: result = newQVariant(item.suggestedPriorityFeePerGasLowLevel) + of ModelRole.SuggestedEstimatedTimeLowLevel: + result = newQVariant(item.suggestedEstimatedTimeLowLevel) of ModelRole.SuggestedMaxFeesPerGasMediumLevel: result = newQVariant(item.suggestedMaxFeesPerGasMediumLevel) of ModelRole.SuggestedPriorityFeePerGasMediumLevel: result = newQVariant(item.suggestedPriorityFeePerGasMediumLevel) + of ModelRole.SuggestedEstimatedTimeMediumLevel: + result = newQVariant(item.suggestedEstimatedTimeMediumLevel) of ModelRole.SuggestedMaxFeesPerGasHighLevel: result = newQVariant(item.suggestedMaxFeesPerGasHighLevel) of ModelRole.SuggestedPriorityFeePerGasHighLevel: result = newQVariant(item.suggestedPriorityFeePerGasHighLevel) + of ModelRole.SuggestedEstimatedTimeHighLevel: + result = newQVariant(item.suggestedEstimatedTimeHighLevel) of ModelRole.SuggestedMinPriorityFee: result = newQVariant(item.suggestedMinPriorityFee) of ModelRole.SuggestedMaxPriorityFee: diff --git a/src/app/modules/main/wallet_section/send_new/view.nim b/src/app/modules/main/wallet_section/send_new/view.nim index e9b8164b94..6e84ab827f 100644 --- a/src/app/modules/main/wallet_section/send_new/view.nim +++ b/src/app/modules/main/wallet_section/send_new/view.nim @@ -99,4 +99,7 @@ QtObject: proc setCustomTxDetails*(self: View, nonce: int, gasAmount: int, maxFeesPerGas: string, priorityFee: string, routerInputParamsUuid: string, pathName: string, chainId: int, isApprovalTx: bool, communityId: string) {.slot.} = self.delegate.setCustomTxDetails(nonce, gasAmount, maxFeesPerGas, priorityFee, routerInputParamsUuid, pathName, - chainId, isApprovalTx, communityId) \ No newline at end of file + chainId, isApprovalTx, communityId) + + proc getEstimatedTime*(self: View, chainId: int, maxFeesPerGas: string, priorityFee: string): int {.slot.} = + return self.delegate.getEstimatedTime(chainId, maxFeesPerGas, priorityFee) \ No newline at end of file diff --git a/src/app_service/service/transaction/dtoV2.nim b/src/app_service/service/transaction/dtoV2.nim index 6268f76cee..fdbcf36406 100644 --- a/src/app_service/service/transaction/dtoV2.nim +++ b/src/app_service/service/transaction/dtoV2.nim @@ -17,10 +17,13 @@ type SuggestedLevelsForMaxFeesPerGasDto* = ref object low*: UInt256 lowPriority*: UInt256 + lowEstimatedTime*: int medium*: UInt256 mediumPriority*: UInt256 + mediumEstimatedTime*: int high*: UInt256 highPriority*: UInt256 + highEstimatedTime*: int type TransactionPathDtoV2* = ref object @@ -81,14 +84,17 @@ proc toSuggestedLevelsForMaxFeesPerGasDto*(jsonObj: JsonNode): SuggestedLevelsFo result.low = stint.fromHex(UInt256, $value) if jsonObj.getProp("lowPriority", value): result.lowPriority = stint.fromHex(UInt256, $value) + discard jsonObj.getProp("lowEstimatedTime", result.lowEstimatedTime) if jsonObj.getProp("medium", value): result.medium = stint.fromHex(UInt256, $value) if jsonObj.getProp("mediumPriority", value): result.mediumPriority = stint.fromHex(UInt256, $value) + discard jsonObj.getProp("mediumEstimatedTime", result.mediumEstimatedTime) if jsonObj.getProp("high", value): result.high = stint.fromHex(UInt256, $value) if jsonObj.getProp("highPriority", value): result.highPriority = stint.fromHex(UInt256, $value) + discard jsonObj.getProp("highEstimatedTime", result.highEstimatedTime) proc toTransactionPathDtoV2*(jsonObj: JsonNode): TransactionPathDtoV2 = result = TransactionPathDtoV2() diff --git a/src/app_service/service/transaction/service.nim b/src/app_service/service/transaction/service.nim index 3523cdf110..fc5f104069 100644 --- a/src/app_service/service/transaction/service.nim +++ b/src/app_service/service/transaction/service.nim @@ -519,6 +519,18 @@ QtObject: error "Error estimating transaction time", message = e.msg return EstimatedTime.Unknown + proc getEstimatedTimeV2*(self: Service, chainId: int, maxFeePerGas: string, priorityFee: string): int = + try: + let + bigMaxFeePerGas = common_utils.stringToUint256(maxFeePerGas) + bigPriorityFee = common_utils.stringToUint256(priorityFee) + maxFeePerGasHex = "0x" & eth_utils.stripLeadingZeros(bigMaxFeePerGas.toHex) + priorityFeeHex = "0x" & eth_utils.stripLeadingZeros(bigPriorityFee.toHex) + return backend.getTransactionEstimatedTimeV2(chainId, maxFeePerGasHex, priorityFeeHex).result.getInt + except Exception as e: + error "Error estimating transaction time", message = e.msg + return 0 + proc getLatestBlockNumber*(self: Service, chainId: int): string = try: let response = eth.getBlockByNumber(chainId, "latest") diff --git a/src/backend/backend.nim b/src/backend/backend.nim index b0daf31365..c36f501ddc 100644 --- a/src/backend/backend.nim +++ b/src/backend/backend.nim @@ -114,6 +114,11 @@ rpc(getTransactionEstimatedTime, "wallet"): chainId: int maxFeePerGas: string +rpc(getTransactionEstimatedTimeV2, "wallet"): + chainId: int + maxFeePerGas: string + maxPriorityFeePerGas: string + rpc(fetchPrices, "wallet"): symbols: seq[string] currencies: seq[string] diff --git a/storybook/qmlTests/tests/tst_SendSignModal.qml b/storybook/qmlTests/tests/tst_SendSignModal.qml index 4feba13484..c95febdcea 100644 --- a/storybook/qmlTests/tests/tst_SendSignModal.qml +++ b/storybook/qmlTests/tests/tst_SendSignModal.qml @@ -75,6 +75,10 @@ Item { return "0.25 USD" } + fnGetEstimatedTime: function(feeInWei) { + return 0 + } + fiatFees: "1.54 EUR" cryptoFees: "0.001 ETH" estimatedTime: qsTr("> 5 minutes") diff --git a/ui/app/AppLayouts/Wallet/WalletUtils.qml b/ui/app/AppLayouts/Wallet/WalletUtils.qml index d020f7dce3..87c913117f 100644 --- a/ui/app/AppLayouts/Wallet/WalletUtils.qml +++ b/ui/app/AppLayouts/Wallet/WalletUtils.qml @@ -77,6 +77,13 @@ QtObject { } } + function formatEstimatedTime(estimatedTime) { + if (estimatedTime == 0 || estimatedTime >= 60) { + return qsTr(">60s") + } + return qsTr("~%1").arg(estimatedTime) + } + function getRouterErrorBasedOnCode(code) { if (code === "") { return "" diff --git a/ui/app/AppLayouts/Wallet/popups/simpleSend/SendSignModal.qml b/ui/app/AppLayouts/Wallet/popups/simpleSend/SendSignModal.qml index 552df3212b..e71902040c 100644 --- a/ui/app/AppLayouts/Wallet/popups/simpleSend/SendSignModal.qml +++ b/ui/app/AppLayouts/Wallet/popups/simpleSend/SendSignModal.qml @@ -11,6 +11,7 @@ import StatusQ.Components 0.1 import AppLayouts.Wallet.panels 1.0 import AppLayouts.Wallet.views 1.0 import AppLayouts.Wallet.popups 1.0 +import AppLayouts.Wallet 1.0 import utils 1.0 @@ -113,6 +114,8 @@ SignTransactionModalBase { /** required function which receives fee in wei and recalculate it currency selected currency and format to locale string **/ required property var fnGetPriceInCurrencyForFee + /** required function which receives base fee and priority fee in wei and returns estimated time in seconds **/ + required property var fnGetEstimatedTime /** Signal to updated tx settings **/ signal updateTxSettings(int selectedFeeMode, string customNonce, string customGasAmount, string maxFeesPerGas, string priorityFee) @@ -234,6 +237,7 @@ SignTransactionModalBase { property Component internalPopup: TransactionSettings { fnGetPriceInCurrencyForFee: root.fnGetPriceInCurrencyForFee + fnGetEstimatedTime: root.fnGetEstimatedTime selectedFeeMode: root.selectedFeeMode @@ -244,11 +248,11 @@ SignTransactionModalBase { currentNonce: root.currentNonce normalPrice: root.normalPrice - normalTime: root.normalTime + normalTime: WalletUtils.formatEstimatedTime(root.normalTime) fastPrice: root.fastPrice - fastTime: root.fastTime + fastTime: WalletUtils.formatEstimatedTime(root.fastTime) urgentPrice: root.urgentPrice - urgentTime: root.urgentTime + urgentTime: WalletUtils.formatEstimatedTime(root.urgentTime) function updateCustomFields() { // by default custom follows normal fee option diff --git a/ui/app/AppLayouts/Wallet/stores/TransactionStoreNew.qml b/ui/app/AppLayouts/Wallet/stores/TransactionStoreNew.qml index 2b87199ef8..a7e4e5597d 100644 --- a/ui/app/AppLayouts/Wallet/stores/TransactionStoreNew.qml +++ b/ui/app/AppLayouts/Wallet/stores/TransactionStoreNew.qml @@ -33,6 +33,10 @@ QtObject { _walletSectionSendInst.setCustomTxDetails(nonce, gasAmount, maxFeesPerGas, priorityFee, routerInputParamsUuid, pathName, chainId, isApprovalTx, communityId) } + function getEstimatedTime(chainId, baseFeeInWei, priorityFeeInWei) { + return _walletSectionSendInst.getEstimatedTime(chainId, baseFeeInWei, priorityFeeInWei) + } + Component.onCompleted: { _walletSectionSendInst.suggestedRoutesReady.connect(suggestedRoutesReady) _walletSectionSendInst.transactionSent.connect(transactionSent) diff --git a/ui/app/AppLayouts/Wallet/views/TransactionSettings.qml b/ui/app/AppLayouts/Wallet/views/TransactionSettings.qml index 4419e6ab4f..c3b9c874ff 100644 --- a/ui/app/AppLayouts/Wallet/views/TransactionSettings.qml +++ b/ui/app/AppLayouts/Wallet/views/TransactionSettings.qml @@ -8,6 +8,8 @@ import StatusQ.Controls.Validators 0.1 import StatusQ.Core.Utils 0.1 as SQUtils import StatusQ.Core.Theme 0.1 +import AppLayouts.Wallet 1.0 + import shared.controls 1.0 import shared.popups 1.0 import utils 1.0 @@ -42,6 +44,7 @@ Rectangle { required property int selectedFeeMode required property var fnGetPriceInCurrencyForFee + required property var fnGetEstimatedTime signal confirmClicked() signal cancelClicked() @@ -106,7 +109,9 @@ Rectangle { const priorityFeeWei = Utils.gweiToWei(customPriorityFeeInput.text) const totalFee = SQUtils.AmountsArithmetic.sum(baseFeeWei, priorityFeeWei) const feeInWei = SQUtils.AmountsArithmetic.times(totalFee, SQUtils.AmountsArithmetic.fromString(customGasAmountInput.text)).toFixed() + const estimatedTime = root.fnGetEstimatedTime(totalFee.toFixed(), priorityFeeWei.toFixed()) optionCustom.subText = root.fnGetPriceInCurrencyForFee(feeInWei) + optionCustom.additionalText = WalletUtils.formatEstimatedTime(estimatedTime) } } @@ -174,7 +179,7 @@ Rectangle { type: StatusFeeOption.Type.Normal selected: root.selectedFeeMode === StatusFeeOption.Type.Normal showSubText: true -// showAdditionalText: true // TODO: temoporary disabled until we figure out how to estimate time more granularly + showAdditionalText: true onClicked: root.selectedFeeMode = StatusFeeOption.Type.Normal } @@ -184,7 +189,7 @@ Rectangle { type: StatusFeeOption.Type.Fast selected: root.selectedFeeMode === StatusFeeOption.Type.Fast showSubText: true -// showAdditionalText: true // TODO: temoporary disabled until we figure out how to estimate time more granularly + showAdditionalText: true onClicked: root.selectedFeeMode = StatusFeeOption.Type.Fast } @@ -194,7 +199,7 @@ Rectangle { type: StatusFeeOption.Type.Urgent selected: root.selectedFeeMode === StatusFeeOption.Type.Urgent showSubText: true -// showAdditionalText: true // TODO: temoporary disabled until we figure out how to estimate time more granularly + showAdditionalText: true onClicked: root.selectedFeeMode = StatusFeeOption.Type.Urgent } @@ -204,7 +209,7 @@ Rectangle { type: StatusFeeOption.Type.Custom selected: root.selectedFeeMode === StatusFeeOption.Type.Custom showSubText: !!selected -// showAdditionalText: !!selected // TODO: temoporary disabled until we figure out how to estimate time more granularly + showAdditionalText: !!selected unselectedText: "Set your own fees & nonce" onClicked: root.selectedFeeMode = StatusFeeOption.Type.Custom diff --git a/ui/app/mainui/SendModalHandler.qml b/ui/app/mainui/SendModalHandler.qml index 271171e0e1..7d5f36aa11 100644 --- a/ui/app/mainui/SendModalHandler.qml +++ b/ui/app/mainui/SendModalHandler.qml @@ -863,6 +863,14 @@ QtObject { return root.fnFormatCurrencyAmount(ethFiatValue*feesEth, root.currentCurrency).toString() } + fnGetEstimatedTime: function(baseFeeInWei, priorityFeeInWei) { + if (!txPathUnderReviewEntry.item) { + return "" + } + const chainId = txPathUnderReviewEntry.item.fromChain + return root.transactionStoreNew.getEstimatedTime(chainId, baseFeeInWei, priorityFeeInWei) + } + normalPrice: { if (!!txPathUnderReviewEntry.item) { if (handler.reviewApprovalForTxPathUnderReview) { @@ -883,7 +891,7 @@ QtObject { SQUtils.AmountsArithmetic.fromString(txPathUnderReviewEntry.item.suggestedPriorityFeePerGasLowLevel)).toFixed() : "" normalPriorityFee: !!txPathUnderReviewEntry.item? txPathUnderReviewEntry.item.suggestedPriorityFeePerGasLowLevel : "" - normalTime: "~60s" // TODO: update this when we figure out how to estimate time more granularly + normalTime: !!txPathUnderReviewEntry.item? txPathUnderReviewEntry.item.suggestedEstimatedTimeLowLevel : "" fastPrice: { if (!!txPathUnderReviewEntry.item) { @@ -905,7 +913,7 @@ QtObject { SQUtils.AmountsArithmetic.fromString(txPathUnderReviewEntry.item.suggestedPriorityFeePerGasMediumLevel)).toFixed() : "" fastPriorityFee: !!txPathUnderReviewEntry.item? txPathUnderReviewEntry.item.suggestedPriorityFeePerGasMediumLevel : "" - fastTime: "~40s" // TODO: update this when we figure out how to estimate time more granularly + fastTime: !!txPathUnderReviewEntry.item? txPathUnderReviewEntry.item.suggestedEstimatedTimeMediumLevel : "" urgentPrice: { if (!!txPathUnderReviewEntry.item) { @@ -927,7 +935,7 @@ QtObject { SQUtils.AmountsArithmetic.fromString(txPathUnderReviewEntry.item.suggestedPriorityFeePerGasHighLevel)).toFixed() : "" urgentPriorityFee: !!txPathUnderReviewEntry.item? txPathUnderReviewEntry.item.suggestedPriorityFeePerGasHighLevel : "" - urgentTime: "~15s" // TODO: update this when we figure out how to estimate time more granularly + urgentTime: !!txPathUnderReviewEntry.item? txPathUnderReviewEntry.item.suggestedEstimatedTimeHighLevel : "" customBaseFee: { if (!!txPathUnderReviewEntry.item) { diff --git a/vendor/status-go b/vendor/status-go index 1bfb0cef02..0bf6048801 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit 1bfb0cef022afc1484a410cb3e0097e7523bb705 +Subproject commit 0bf60488017885b840615533bd475b94e4072f8a