From c0e5111fe57b1e5dfd48ed4cf540c79390988eae Mon Sep 17 00:00:00 2001 From: Dario Gabriel Lipicar Date: Mon, 29 Jul 2024 18:10:40 -0300 Subject: [PATCH] feat(@desktop/wallet): handle Paraswap price impact error Fixes #15542 --- storybook/pages/SwapModalPage.qml | 3 ++- ui/app/AppLayouts/Wallet/WalletUtils.qml | 3 +++ ui/app/AppLayouts/Wallet/popups/swap/SwapModalAdaptor.qml | 2 ++ ui/imports/utils/Constants.qml | 3 +++ vendor/status-go | 2 +- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/storybook/pages/SwapModalPage.qml b/storybook/pages/SwapModalPage.qml index 7e646cd38a..0ae59029c7 100644 --- a/storybook/pages/SwapModalPage.qml +++ b/storybook/pages/SwapModalPage.qml @@ -357,7 +357,8 @@ SplitView { {name: "errNotEnoughTokenBalance", value: Constants.swap.errorCodes.errNotEnoughTokenBalance}, {name: "errNotEnoughNativeBalance", value: Constants.swap.errorCodes.errNotEnoughNativeBalance}, {name: "errPriceTimeout", value: Constants.swap.errorCodes.errPriceTimeout}, - {name: "errNotEnoughLiquidity", value: Constants.swap.errorCodes.errNotEnoughLiquidity} + {name: "errNotEnoughLiquidity", value: Constants.swap.errorCodes.errNotEnoughLiquidity}, + {name: "errPriceImpactTooHigh", value: Constants.swap.errorCodes.errPriceImpactTooHigh} ] textRole: "name" valueRole: "value" diff --git a/ui/app/AppLayouts/Wallet/WalletUtils.qml b/ui/app/AppLayouts/Wallet/WalletUtils.qml index 64ac86ac65..645b0a6b8c 100644 --- a/ui/app/AppLayouts/Wallet/WalletUtils.qml +++ b/ui/app/AppLayouts/Wallet/WalletUtils.qml @@ -167,6 +167,7 @@ QtObject { case Constants.routerErrorCodes.processor.errContextDeadlineExceeded: case Constants.routerErrorCodes.processor.errPriceTimeout: case Constants.routerErrorCodes.processor.errNotEnoughLiquidity: + case Constants.routerErrorCodes.processor.errPriceImpactTooHigh: return qsTr("processor internal error") case Constants.routerErrorCodes.processor.errTransferCustomError: case Constants.routerErrorCodes.processor.errERC721TransferCustomError: @@ -276,6 +277,8 @@ QtObject { return qsTr("fetching price timeout") case Constants.routerErrorCodes.processor.errNotEnoughLiquidity: return qsTr("not enough liquidity") + case Constants.routerErrorCodes.processor.errPriceImpactTooHigh: + return qsTr("price impact too high") case Constants.routerErrorCodes.processor.errTransferCustomError: case Constants.routerErrorCodes.processor.errERC721TransferCustomError: diff --git a/ui/app/AppLayouts/Wallet/popups/swap/SwapModalAdaptor.qml b/ui/app/AppLayouts/Wallet/popups/swap/SwapModalAdaptor.qml index 5424bcac84..eb306ee6fc 100644 --- a/ui/app/AppLayouts/Wallet/popups/swap/SwapModalAdaptor.qml +++ b/ui/app/AppLayouts/Wallet/popups/swap/SwapModalAdaptor.qml @@ -191,6 +191,8 @@ QObject { return qsTr("Fetching the price took longer than expected. Please, try again later.") case Constants.swap.errorCodes.errNotEnoughLiquidity: return qsTr("Not enough liquidity. Lower token amount or try again later.") + case Constants.swap.errorCodes.errPriceImpactTooHigh: + return qsTr("Price impact too high. Lower token amount or try again later.") } return qsTr("Something went wrong. Change amount, token or try again later.") } diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 4251761065..f2a1070762 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -1084,6 +1084,7 @@ QtObject { readonly property string errContextDeadlineExceeded : "WPP-036" readonly property string errPriceTimeout : "WPP-037" readonly property string errNotEnoughLiquidity : "WPP-038" + readonly property string errPriceImpactTooHigh : "WPP-039" } readonly property QtObject router: QtObject { @@ -1416,11 +1417,13 @@ QtObject { readonly property string paraswapSwapContractAddress: "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57" readonly property string termsAndConditionParaswapUrl: "https://files.paraswap.io/tos_v4.pdf" + // TOOD #15874: Unify with WalletUtils router error code handling readonly property QtObject errorCodes: QtObject { readonly property string errNotEnoughTokenBalance: "WR-016" readonly property string errNotEnoughNativeBalance: "WR-017" readonly property string errPriceTimeout: "WPP-037" readonly property string errNotEnoughLiquidity: "WPP-038" + readonly property string errPriceImpactTooHigh: "WPP-039" } } diff --git a/vendor/status-go b/vendor/status-go index d5a78e784a..d7fcbd3444 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit d5a78e784aa1b8852efc3a82de1cf9a0a1c10eda +Subproject commit d7fcbd3444aac73a36f1cfeb7a1f11fa4dcd9533