From f21f66099c573382a622ece5c667e2adf9348dc3 Mon Sep 17 00:00:00 2001 From: dlipicar Date: Fri, 9 Aug 2024 12:00:58 -0300 Subject: [PATCH] feat(@desktop/wallet): handle Paraswap price impact error (#16045) 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 7e646cd38a0..0ae59029c70 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 bb369c552d4..eb379a24b89 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 sTr("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 5424bcac84f..eb306ee6fc0 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 f4d79548b5a..05d0c3dd204 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -1111,6 +1111,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 { @@ -1451,11 +1452,13 @@ QtObject { readonly property string paraswapSwapContractAddress: "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57" readonly property string paraswapTermsAndConditionUrl: "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 f45dbb30677..720c0c1058f 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit f45dbb30677a478dc9578238c97900994fcd4147 +Subproject commit 720c0c1058f52f551271d0c09dba17bfc3adbada