diff --git a/src/app_service/service/transaction/service.nim b/src/app_service/service/transaction/service.nim index 5cb540b42cb..c53484dfc01 100644 --- a/src/app_service/service/transaction/service.nim +++ b/src/app_service/service/transaction/service.nim @@ -152,6 +152,7 @@ QtObject: networkService: network_service.Service settingsService: settings_service.Service tokenService: token_service.Service + uuidOfTheLastRequestForSuggestedRoutes: string ## Forward declarations proc suggestedRoutesV2Ready(self: Service, uuid: string, route: seq[TransactionPathDtoV2], routeRaw: string, errCode: string, errDescription: string) @@ -508,7 +509,7 @@ QtObject: if not asset.isNil: var foundAddress = false for addressPerChain in asset.addressPerChainId: - if addressPerChain.chainId == route.toNetwork.chainId: + if addressPerChain.chainId == route.fromNetwork.chainId: toContractAddress = parseAddress(addressPerChain.address) foundAddress = true break @@ -648,8 +649,10 @@ QtObject: error "Error getting suggested fees", msg = e.msg proc suggestedRoutesV2Ready(self: Service, uuid: string, route: seq[TransactionPathDtoV2], routeRaw: string, errCode: string, errDescription: string) = - # TODO: refactor sending modal part of the app, but for now since we're integrating the router v2 just map params to the old dto + if self.uuidOfTheLastRequestForSuggestedRoutes != uuid: + return + # TODO: refactor sending modal part of the app, but for now since we're integrating the router v2 just map params to the old dto var oldRoute = convertToOldRoute(route) let suggestedDto = SuggestedRoutesDto( @@ -680,6 +683,8 @@ QtObject: lockedInAmounts: Table[string, string] = initTable[string, string](), extraParamsTable: Table[string, string] = initTable[string, string]()) = + self.uuidOfTheLastRequestForSuggestedRoutes = uuid + let bigAmountIn = common_utils.stringToUint256(amountIn) bigAmountOut = common_utils.stringToUint256(amountOut) diff --git a/ui/app/AppLayouts/Wallet/WalletUtils.qml b/ui/app/AppLayouts/Wallet/WalletUtils.qml index ee4a64548d7..bb369c552d4 100644 --- a/ui/app/AppLayouts/Wallet/WalletUtils.qml +++ b/ui/app/AppLayouts/Wallet/WalletUtils.qml @@ -134,6 +134,10 @@ QtObject { function getRouterErrorBasedOnCode(code) { + if (code === "") { + return "" + } + switch(code) { case Constants.routerErrorCodes.processor.errFailedToParseBaseFee: case Constants.routerErrorCodes.processor.errFailedToParsePercentageFee: @@ -203,12 +207,18 @@ QtObject { return qsTr("not enough token balance") case Constants.routerErrorCodes.router.errNotEnoughNativeBalance: return qsTr("not enough ETH") + case Constants.routerErrorCodes.router.errLowAmountInForHopBridge: + return qsTr("amount in too low") default: return qsTr("unknown processor error") } } function getRouterErrorDetailsOnCode(code, details) { + if (code === "") { + return "" + } + switch(code) { case Constants.routerErrorCodes.processor.errFailedToParseBaseFee: return qsTr("failed to parse base fee") @@ -346,7 +356,8 @@ QtObject { catch (e) { return "" } - + case Constants.routerErrorCodes.router.errLowAmountInForHopBridge: + return qsTr("bonder fee greater than estimated received, a higher amount is needed to cover fees") default: return "" } diff --git a/ui/imports/shared/popups/send/SendModal.qml b/ui/imports/shared/popups/send/SendModal.qml index 60d83535398..6fac884b62a 100644 --- a/ui/imports/shared/popups/send/SendModal.qml +++ b/ui/imports/shared/popups/send/SendModal.qml @@ -670,10 +670,8 @@ StatusDialog { function onSuggestedRoutesReady(txRoutes, errCode, errDescription) { popup.bestRoutes = txRoutes.suggestedRoutes - if (errCode !== "") { - d.routerError = WalletUtils.getRouterErrorBasedOnCode(errCode) - d.routerErrorDetails = "%1 - %2".arg(errCode).arg(WalletUtils.getRouterErrorDetailsOnCode(errCode, errDescription)) - } + d.routerError = WalletUtils.getRouterErrorBasedOnCode(errCode) + d.routerErrorDetails = "%1 - %2".arg(errCode).arg(WalletUtils.getRouterErrorDetailsOnCode(errCode, errDescription)) let gasTimeEstimate = txRoutes.gasTimeEstimate d.totalTimeEstimate = WalletUtils.getLabelForEstimatedTxTime(gasTimeEstimate.totalTime) diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index a00cb627483..f4d79548b5a 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -1139,6 +1139,7 @@ QtObject { readonly property string errNoBestRouteFound : "WR-023" readonly property string errCannotCheckReceiverBalance : "WR-024" readonly property string errCannotCheckLockedAmounts : "WR-025" + readonly property string errLowAmountInForHopBridge : "WR-026" } }