fix: tx fails if the bonder fee is higher than the amount being sent
Closes #15922
This commit is contained in:
parent
74bc695f10
commit
0c4b7e92a0
|
@ -152,6 +152,7 @@ QtObject:
|
||||||
networkService: network_service.Service
|
networkService: network_service.Service
|
||||||
settingsService: settings_service.Service
|
settingsService: settings_service.Service
|
||||||
tokenService: token_service.Service
|
tokenService: token_service.Service
|
||||||
|
uuidOfTheLastRequestForSuggestedRoutes: string
|
||||||
|
|
||||||
## Forward declarations
|
## Forward declarations
|
||||||
proc suggestedRoutesV2Ready(self: Service, uuid: string, route: seq[TransactionPathDtoV2], routeRaw: string, errCode: string, errDescription: string)
|
proc suggestedRoutesV2Ready(self: Service, uuid: string, route: seq[TransactionPathDtoV2], routeRaw: string, errCode: string, errDescription: string)
|
||||||
|
@ -508,7 +509,7 @@ QtObject:
|
||||||
if not asset.isNil:
|
if not asset.isNil:
|
||||||
var foundAddress = false
|
var foundAddress = false
|
||||||
for addressPerChain in asset.addressPerChainId:
|
for addressPerChain in asset.addressPerChainId:
|
||||||
if addressPerChain.chainId == route.toNetwork.chainId:
|
if addressPerChain.chainId == route.fromNetwork.chainId:
|
||||||
toContractAddress = parseAddress(addressPerChain.address)
|
toContractAddress = parseAddress(addressPerChain.address)
|
||||||
foundAddress = true
|
foundAddress = true
|
||||||
break
|
break
|
||||||
|
@ -648,8 +649,10 @@ QtObject:
|
||||||
error "Error getting suggested fees", msg = e.msg
|
error "Error getting suggested fees", msg = e.msg
|
||||||
|
|
||||||
proc suggestedRoutesV2Ready(self: Service, uuid: string, route: seq[TransactionPathDtoV2], routeRaw: string, errCode: string, errDescription: string) =
|
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)
|
var oldRoute = convertToOldRoute(route)
|
||||||
|
|
||||||
let suggestedDto = SuggestedRoutesDto(
|
let suggestedDto = SuggestedRoutesDto(
|
||||||
|
@ -680,6 +683,8 @@ QtObject:
|
||||||
lockedInAmounts: Table[string, string] = initTable[string, string](),
|
lockedInAmounts: Table[string, string] = initTable[string, string](),
|
||||||
extraParamsTable: Table[string, string] = initTable[string, string]()) =
|
extraParamsTable: Table[string, string] = initTable[string, string]()) =
|
||||||
|
|
||||||
|
self.uuidOfTheLastRequestForSuggestedRoutes = uuid
|
||||||
|
|
||||||
let
|
let
|
||||||
bigAmountIn = common_utils.stringToUint256(amountIn)
|
bigAmountIn = common_utils.stringToUint256(amountIn)
|
||||||
bigAmountOut = common_utils.stringToUint256(amountOut)
|
bigAmountOut = common_utils.stringToUint256(amountOut)
|
||||||
|
|
|
@ -134,6 +134,10 @@ QtObject {
|
||||||
|
|
||||||
|
|
||||||
function getRouterErrorBasedOnCode(code) {
|
function getRouterErrorBasedOnCode(code) {
|
||||||
|
if (code === "") {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
switch(code) {
|
switch(code) {
|
||||||
case Constants.routerErrorCodes.processor.errFailedToParseBaseFee:
|
case Constants.routerErrorCodes.processor.errFailedToParseBaseFee:
|
||||||
case Constants.routerErrorCodes.processor.errFailedToParsePercentageFee:
|
case Constants.routerErrorCodes.processor.errFailedToParsePercentageFee:
|
||||||
|
@ -203,12 +207,18 @@ QtObject {
|
||||||
return qsTr("not enough token balance")
|
return qsTr("not enough token balance")
|
||||||
case Constants.routerErrorCodes.router.errNotEnoughNativeBalance:
|
case Constants.routerErrorCodes.router.errNotEnoughNativeBalance:
|
||||||
return qsTr("not enough ETH")
|
return qsTr("not enough ETH")
|
||||||
|
case Constants.routerErrorCodes.router.errLowAmountInForHopBridge:
|
||||||
|
return qsTr("amount in too low")
|
||||||
default:
|
default:
|
||||||
return qsTr("unknown processor error")
|
return qsTr("unknown processor error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRouterErrorDetailsOnCode(code, details) {
|
function getRouterErrorDetailsOnCode(code, details) {
|
||||||
|
if (code === "") {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
switch(code) {
|
switch(code) {
|
||||||
case Constants.routerErrorCodes.processor.errFailedToParseBaseFee:
|
case Constants.routerErrorCodes.processor.errFailedToParseBaseFee:
|
||||||
return qsTr("failed to parse base fee")
|
return qsTr("failed to parse base fee")
|
||||||
|
@ -346,7 +356,8 @@ QtObject {
|
||||||
catch (e) {
|
catch (e) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
case Constants.routerErrorCodes.router.errLowAmountInForHopBridge:
|
||||||
|
return qsTr("bonder fee greater than estimated received, a higher amount is needed to cover fees")
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -680,10 +680,8 @@ StatusDialog {
|
||||||
function onSuggestedRoutesReady(txRoutes, errCode, errDescription) {
|
function onSuggestedRoutesReady(txRoutes, errCode, errDescription) {
|
||||||
popup.bestRoutes = txRoutes.suggestedRoutes
|
popup.bestRoutes = txRoutes.suggestedRoutes
|
||||||
|
|
||||||
if (errCode !== "") {
|
d.routerError = WalletUtils.getRouterErrorBasedOnCode(errCode)
|
||||||
d.routerError = WalletUtils.getRouterErrorBasedOnCode(errCode)
|
d.routerErrorDetails = "%1 - %2".arg(errCode).arg(WalletUtils.getRouterErrorDetailsOnCode(errCode, errDescription))
|
||||||
d.routerErrorDetails = "%1 - %2".arg(errCode).arg(WalletUtils.getRouterErrorDetailsOnCode(errCode, errDescription))
|
|
||||||
}
|
|
||||||
|
|
||||||
let gasTimeEstimate = txRoutes.gasTimeEstimate
|
let gasTimeEstimate = txRoutes.gasTimeEstimate
|
||||||
d.totalTimeEstimate = WalletUtils.getLabelForEstimatedTxTime(gasTimeEstimate.totalTime)
|
d.totalTimeEstimate = WalletUtils.getLabelForEstimatedTxTime(gasTimeEstimate.totalTime)
|
||||||
|
|
|
@ -1125,6 +1125,7 @@ QtObject {
|
||||||
readonly property string errNoBestRouteFound : "WR-023"
|
readonly property string errNoBestRouteFound : "WR-023"
|
||||||
readonly property string errCannotCheckReceiverBalance : "WR-024"
|
readonly property string errCannotCheckReceiverBalance : "WR-024"
|
||||||
readonly property string errCannotCheckLockedAmounts : "WR-025"
|
readonly property string errCannotCheckLockedAmounts : "WR-025"
|
||||||
|
readonly property string errLowAmountInForHopBridge : "WR-026"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 791ff9a0edef77a1cac7e35580a2464bba7f3d51
|
Subproject commit 8787da1b899d25a65332b0aee2440b8453062343
|
Loading…
Reference in New Issue