From 9b18600df8d76d28803bc0aec351e068cc1ac55c Mon Sep 17 00:00:00 2001 From: Harsh Date: Tue, 27 Feb 2024 16:42:25 +0530 Subject: [PATCH] fix(ui-ux): increased custom slippage range to 0 to 1000 --- .../__snapshots__/PinTextInput.test.tsx.snap | 2 +- .../components/SlippageTolerance.tsx | 27 ++++++++++--------- .../dex/swap/swap_instant_non_dfi.spec.ts | 18 ++++++------- shared/translations/languages/de.json | 2 +- shared/translations/languages/es.json | 2 +- shared/translations/languages/fr.json | 2 +- shared/translations/languages/it.json | 2 +- shared/translations/languages/zh-Hans.json | 2 +- shared/translations/languages/zh-Hant.json | 2 +- 9 files changed, 30 insertions(+), 29 deletions(-) diff --git a/mobile-app/app/components/__snapshots__/PinTextInput.test.tsx.snap b/mobile-app/app/components/__snapshots__/PinTextInput.test.tsx.snap index 533f83c45d..3fe3dc5f20 100644 --- a/mobile-app/app/components/__snapshots__/PinTextInput.test.tsx.snap +++ b/mobile-app/app/components/__snapshots__/PinTextInput.test.tsx.snap @@ -232,7 +232,7 @@ exports[`Pin text input should match snapshot 1`] = ` "bottom": 0, "fontSize": 1, "left": 0, - "opacity": 0.01, + "opacity": 0.015, "position": "absolute", "right": 0, "top": 0, diff --git a/mobile-app/app/screens/AppNavigator/screens/Dex/CompositeSwap/components/SlippageTolerance.tsx b/mobile-app/app/screens/AppNavigator/screens/Dex/CompositeSwap/components/SlippageTolerance.tsx index de7df5b03c..9a0f900d91 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Dex/CompositeSwap/components/SlippageTolerance.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Dex/CompositeSwap/components/SlippageTolerance.tsx @@ -53,12 +53,12 @@ export function SlippageTolerance({ const checkIfCustomSlippage = (slippage: string) => { return !Object.values(SlippageAmountButtonTypes).some((buttonAmount) => - new BigNumber(new BigNumber(buttonAmount).toFixed(8)).isEqualTo(slippage) + new BigNumber(new BigNumber(buttonAmount).toFixed(8)).isEqualTo(slippage), ); }; const [isCustomAmount, setIsCustomAmount] = useState( - checkIfCustomSlippage(slippage.toFixed(8)) + checkIfCustomSlippage(slippage.toFixed(8)), ); const isSlippageValid = (): boolean => { @@ -70,13 +70,13 @@ export function SlippageTolerance({ if (value === undefined || value === "") { return; } else if ( - !(new BigNumber(value).gte(0) && new BigNumber(value).lte(100)) + !(new BigNumber(value).gte(0) && new BigNumber(value).lte(1000)) ) { setSlippageError({ type: "error", text: translate( "screens/SlippageTolerance", - "Slippage rate must range from 0-100%" + "Slippage rate must range from 0-1000%", ), }); return; @@ -88,7 +88,7 @@ export function SlippageTolerance({ validateSlippage(selectedSlippage); setIsRiskWarningDisplayed( new BigNumber(selectedSlippage).gte(20) && - new BigNumber(selectedSlippage).lte(100) + new BigNumber(selectedSlippage).lte(1000), ); }, [selectedSlippage]); @@ -167,7 +167,7 @@ export function SlippageTolerance({ "p-2.5 justify-center items-center flex-grow rounded-full z-10", { "opacity-30": !isSlippageValid(), - } + }, )} onPress={() => { setIsEditing(false); @@ -180,7 +180,7 @@ export function SlippageTolerance({ setIsCustomAmount(true); updateSlippage( new BigNumber(selectedSlippage).toFixed(2), - true + true, ); } }} @@ -203,7 +203,7 @@ export function SlippageTolerance({ light={tailwind("bg-mono-light-v2-00")} dark={tailwind("bg-mono-dark-v2-00")} style={tailwind( - "flex flex-row justify-around items-center rounded-full" + "flex flex-row justify-around items-center rounded-full", )} > {Object.values(SlippageAmountButtonTypes).map((type) => { @@ -218,7 +218,7 @@ export function SlippageTolerance({ isSelected={ !isCustomAmount && new BigNumber(selectedSlippage).isEqualTo( - new BigNumber(type).toFixed(2) + new BigNumber(type).toFixed(2), ) } /> @@ -242,7 +242,7 @@ export function SlippageTolerance({ > {translate( "screens/SlippageTolerance", - "Set high tolerance at your own risk" + "Set high tolerance at your own risk", )} )} @@ -266,7 +266,7 @@ function PercentageAmountButton({ light={tailwind({ "bg-mono-light-v2-900": isSelected })} dark={tailwind({ "bg-mono-dark-v2-900": isSelected })} style={tailwind( - "w-3/12 items-center rounded-full justify-center self-stretch h-9" + "w-3/12 items-center rounded-full justify-center self-stretch h-9", )} onPress={onPress} testID={`slippage_${percentageAmount}%`} @@ -315,7 +315,7 @@ function CustomAmountButton({ light={tailwind("text-mono-light-v2-500")} dark={tailwind("text-mono-dark-v2-500")} style={tailwind( - "font-semibold-v2 text-xs px-4 py-2.5 flex-row items-center h-9" + "font-semibold-v2 text-xs px-4 py-2.5 flex-row items-center h-9", )} > @@ -337,7 +338,7 @@ function CustomAmountButton({ {isCustomAmount && ( { cy.getByTestID("tokenB_displaySymbol").contains("dLTC"); cy.getByTestID("button_confirm_submit").should( "have.attr", - "aria-disabled" + "aria-disabled", ); cy.getByTestID("text_input_tokenA").clear().type("15").blur().wait(500); cy.getByTestID("transaction_details_hint_text").should( "have.text", - "By continuing, the required amount of DFI will be converted" + "By continuing, the required amount of DFI will be converted", ); cy.getByTestID("button_confirm_submit").should("not.have.attr", "disabled"); cy.getByTestID("text_input_tokenA").clear().type("0").blur().wait(100); cy.getByTestID("button_confirm_submit").should( "have.attr", - "aria-disabled" + "aria-disabled", ); }); @@ -78,7 +78,7 @@ context("Wallet - DEX - Instant Swap (non-DFI)", () => { setCustomSlippage("22"); cy.getByTestID("slippage_warning").should( "have.text", - "Set high tolerance at your own risk" + "Set high tolerance at your own risk", ); cy.getByTestID("slippage_custom").click(); cy.getByTestID("slippage_input").clear().click().type("5"); @@ -88,12 +88,12 @@ context("Wallet - DEX - Instant Swap (non-DFI)", () => { cy.getByTestID("slippage_input") .clear() .click() - .type("101") + .type("1001") .blur() .wait(100); cy.getByTestID("slippage_input_error").should( "have.text", - "Slippage rate must range from 0-100%" + "Slippage rate must range from 0-1000%", ); cy.getByTestID("slippage_input").clear(); cy.getByTestID("slippage_input") @@ -104,7 +104,7 @@ context("Wallet - DEX - Instant Swap (non-DFI)", () => { .wait(100); cy.getByTestID("slippage_input_error").should( "have.text", - "Slippage rate must range from 0-100%" + "Slippage rate must range from 0-1000%", ); cy.getByTestID("slippage_input") .clear() @@ -114,11 +114,11 @@ context("Wallet - DEX - Instant Swap (non-DFI)", () => { .wait(100); cy.getByTestID("slippage_input_error").should( "have.text", - "Slippage rate must range from 0-100%" + "Slippage rate must range from 0-1000%", ); cy.getByTestID("button_confirm_submit").should( "have.attr", - "aria-disabled" + "aria-disabled", ); }); diff --git a/shared/translations/languages/de.json b/shared/translations/languages/de.json index 9e67a4973e..b8ea3da71e 100644 --- a/shared/translations/languages/de.json +++ b/shared/translations/languages/de.json @@ -1038,7 +1038,7 @@ "Custom": "Anpassen", "USE THIS SLIPPAGE TOLERANCE": "SLIPPAGE-TOLERANZ VERWENDEN", "Required field is missing": "Erforderliches Feld fehlt", - "Slippage rate must range from 0-100%": "Die Slippage-Toleranz muss zwischen 0 und 100 % liegen.", + "Slippage rate must range from 0-1000%": "Die Slippage-Toleranz muss zwischen 0 und 1000 % liegen.", "Proceed at your own risk": "Handeln auf eigenes Risiko" }, "screens/PoolSwapScreen": { diff --git a/shared/translations/languages/es.json b/shared/translations/languages/es.json index d2347a6578..136cacbe8c 100644 --- a/shared/translations/languages/es.json +++ b/shared/translations/languages/es.json @@ -1053,7 +1053,7 @@ "Custom": "Personalizado", "USE THIS SLIPPAGE TOLERANCE": "USA ESTA TOLERANCIA DE FLUCTUACION.", "Required field is missing": "Falta la información requerida", - "Slippage rate must range from 0-100%": "La tasa de fluctuación debe cubrir desde 0-100%.", + "Slippage rate must range from 0-1000%": "La tasa de fluctuación debe cubrir desde 0-1000%.", "Proceed at your own risk": "Continúa a tu propio riesgo" }, "screens/PoolSwapScreen": { diff --git a/shared/translations/languages/fr.json b/shared/translations/languages/fr.json index 17ee987574..f82a5f4974 100644 --- a/shared/translations/languages/fr.json +++ b/shared/translations/languages/fr.json @@ -1046,7 +1046,7 @@ "Custom": "Personnaliser", "USE THIS SLIPPAGE TOLERANCE": "CHOISIR CETTE TOLÉRANCE DE GLISSEMENT.", "Required field is missing": "Le champ requis est manquant", - "Slippage rate must range from 0-100%": "Le taux de glissement doit être compris entre 0 et 100 %.", + "Slippage rate must range from 0-1000%": "Le taux de glissement doit être compris entre 0 et 1000 %.", "Proceed at your own risk": "Procédez à vos propres risques" }, "screens/PoolSwapScreen": { diff --git a/shared/translations/languages/it.json b/shared/translations/languages/it.json index dd805eae3e..ea29d76a2e 100644 --- a/shared/translations/languages/it.json +++ b/shared/translations/languages/it.json @@ -1052,7 +1052,7 @@ "Custom": "Personalizza", "USE THIS SLIPPAGE TOLERANCE": "UTILIZZA QUESTA TOLLERANZA DI SLIPPAGE.", "Required field is missing": "Il campo richiesto è mancante", - "Slippage rate must range from 0-100%": "Il tasso di slippage deve essere compreso tra lo 0 e il 100%.", + "Slippage rate must range from 0-1000%": "Il tasso di slippage deve essere compreso tra lo 0 e il 1000%.", "Proceed at your own risk": "Procedere a proprio rischio" }, "screens/PoolSwapScreen": { diff --git a/shared/translations/languages/zh-Hans.json b/shared/translations/languages/zh-Hans.json index 0c89e0ef8a..9811c60461 100644 --- a/shared/translations/languages/zh-Hans.json +++ b/shared/translations/languages/zh-Hans.json @@ -1038,7 +1038,7 @@ "Custom": "自订", "USE THIS SLIPPAGE TOLERANCE": "使用此滑点限制范围", "Required field is missing": "缺少必要填入的字栏", - "Slippage rate must range from 0-100%": "滑点率选择百分比必须在 0 - 100%", + "Slippage rate must range from 0-1000%": "滑点率选择百分比必须在 0 - 1000%", "Proceed at your own risk": "继续进行并自我承担风险" }, "screens/PoolSwapScreen": { diff --git a/shared/translations/languages/zh-Hant.json b/shared/translations/languages/zh-Hant.json index 0d2e70a70f..2cb6a469e6 100644 --- a/shared/translations/languages/zh-Hant.json +++ b/shared/translations/languages/zh-Hant.json @@ -1038,7 +1038,7 @@ "Custom": "自訂", "USE THIS SLIPPAGE TOLERANCE": "使用此滑點限制範圍", "Required field is missing": "缺少必要填入的字欄", - "Slippage rate must range from 0-100%": "滑點率選擇百分比必須在 0 - 100%", + "Slippage rate must range from 0-1000%": "滑點率選擇百分比必須在 0 - 1000%", "Proceed at your own risk": "繼續進行並自我承擔風險" }, "screens/PoolSwapScreen": {