From 832b1b436a6587c8f73f116558f45d222c0db084 Mon Sep 17 00:00:00 2001 From: Jean Neiverth Date: Mon, 28 Oct 2024 15:12:47 -0300 Subject: [PATCH 1/2] fix: nitpicks --- apps/create-vesting/src/app/page.tsx | 2 +- packages/cow-hooks-ui/src/ui/Checkbox.tsx | 2 +- packages/cow-hooks-ui/src/ui/SignaturesSteps.tsx | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/create-vesting/src/app/page.tsx b/apps/create-vesting/src/app/page.tsx index db479de..01e9a6d 100644 --- a/apps/create-vesting/src/app/page.tsx +++ b/apps/create-vesting/src/app/page.tsx @@ -151,7 +151,7 @@ export default function Page() { amountPreviewFullDecimals={amountPreviewFullDecimals} formattedUserBalance={formattedUserBalance} userBalanceFloat={userBalanceFloat} - shouldEnableMaxSelector={vestUserInput} + shouldEnableMaxSelector={vestUserInput && amount !== userBalanceFloat} />
diff --git a/packages/cow-hooks-ui/src/ui/Checkbox.tsx b/packages/cow-hooks-ui/src/ui/Checkbox.tsx index 7671b7d..bc52a9c 100644 --- a/packages/cow-hooks-ui/src/ui/Checkbox.tsx +++ b/packages/cow-hooks-ui/src/ui/Checkbox.tsx @@ -78,7 +78,7 @@ export const Checkbox = ({ {label} {isSelected && isSelectedMessage && ( - + {isSelectedMessage} diff --git a/packages/cow-hooks-ui/src/ui/SignaturesSteps.tsx b/packages/cow-hooks-ui/src/ui/SignaturesSteps.tsx index 5c1c94a..9117009 100644 --- a/packages/cow-hooks-ui/src/ui/SignaturesSteps.tsx +++ b/packages/cow-hooks-ui/src/ui/SignaturesSteps.tsx @@ -37,14 +37,18 @@ function SignatureStep({ }) { return (
-
+
{stepIndex + 1}
- {step.label} - {stepIndex < currentStepIndex && ( - - )} +
+ {step.label} +
+
+ {stepIndex < currentStepIndex && ( + + )} +
{stepIndex !== lastIndex &&
}
From e55e2d5128aa3c86f9eeba9e8e9efa7bff510f9d Mon Sep 17 00:00:00 2001 From: Jean Neiverth Date: Mon, 28 Oct 2024 15:34:11 -0300 Subject: [PATCH 2/2] fix: do not display approx and warnings anymore for buy orders --- apps/create-vesting/package.json | 2 +- apps/create-vesting/src/components/AmountInput.tsx | 8 +++++++- .../src/components/VestAllFromAccountCheckbox.tsx | 10 ++++++++-- .../src/components/VestAllFromSwapCheckbox.tsx | 10 ++++++++-- packages/cow-hooks-ui/src/ui/TokenAmountInput.tsx | 5 ++++- pnpm-lock.yaml | 11 +++++++++-- 6 files changed, 37 insertions(+), 9 deletions(-) diff --git a/apps/create-vesting/package.json b/apps/create-vesting/package.json index 57a33e7..700d91d 100644 --- a/apps/create-vesting/package.json +++ b/apps/create-vesting/package.json @@ -14,7 +14,7 @@ "@bleu/ui": "0.1.131", "@bleu/utils": "workspace:*", "@cowprotocol/cow-sdk": "^5.5.1", - "@cowprotocol/hook-dapp-lib": "1.1.0-RC0", + "@cowprotocol/hook-dapp-lib": "1.2.0", "@hookform/resolvers": "3.9.0", "@radix-ui/react-icons": "1.3.0", "@uniswap/sdk-core": "5.4.0", diff --git a/apps/create-vesting/src/components/AmountInput.tsx b/apps/create-vesting/src/components/AmountInput.tsx index cc1027d..3c88e83 100644 --- a/apps/create-vesting/src/components/AmountInput.tsx +++ b/apps/create-vesting/src/components/AmountInput.tsx @@ -1,4 +1,4 @@ -import { TokenAmountInput } from "@bleu/cow-hooks-ui"; +import { TokenAmountInput, useIFrameContext } from "@bleu/cow-hooks-ui"; import type { Token } from "@uniswap/sdk-core"; export const AmountInput = ({ @@ -20,6 +20,8 @@ export const AmountInput = ({ userBalanceFloat: number | undefined; shouldEnableMaxSelector: boolean; }) => { + const { context } = useIFrameContext(); + return ( (v === "" ? undefined : Number(v)), required: !(vestAllFromAccount || vestAllFromSwap), diff --git a/apps/create-vesting/src/components/VestAllFromAccountCheckbox.tsx b/apps/create-vesting/src/components/VestAllFromAccountCheckbox.tsx index 19c24d4..2811c2f 100644 --- a/apps/create-vesting/src/components/VestAllFromAccountCheckbox.tsx +++ b/apps/create-vesting/src/components/VestAllFromAccountCheckbox.tsx @@ -1,14 +1,20 @@ -import { Checkbox } from "@bleu/cow-hooks-ui"; +import { Checkbox, useIFrameContext } from "@bleu/cow-hooks-ui"; import { useFormContext } from "react-hook-form"; export const VestAllFromAccountCheckbox = () => { const { setValue } = useFormContext(); + const { context } = useIFrameContext(); return ( { setValue("amount", undefined); setValue("vestUserInput", false); diff --git a/apps/create-vesting/src/components/VestAllFromSwapCheckbox.tsx b/apps/create-vesting/src/components/VestAllFromSwapCheckbox.tsx index 8e088ce..bb2beb4 100644 --- a/apps/create-vesting/src/components/VestAllFromSwapCheckbox.tsx +++ b/apps/create-vesting/src/components/VestAllFromSwapCheckbox.tsx @@ -1,14 +1,20 @@ -import { Checkbox } from "@bleu/cow-hooks-ui"; +import { Checkbox, useIFrameContext } from "@bleu/cow-hooks-ui"; import { useFormContext } from "react-hook-form"; export const VestAllFromSwapCheckbox = () => { const { setValue } = useFormContext(); + const { context } = useIFrameContext(); return ( { setValue("amount", undefined); setValue("vestUserInput", false); diff --git a/packages/cow-hooks-ui/src/ui/TokenAmountInput.tsx b/packages/cow-hooks-ui/src/ui/TokenAmountInput.tsx index e1db298..5cef01e 100644 --- a/packages/cow-hooks-ui/src/ui/TokenAmountInput.tsx +++ b/packages/cow-hooks-ui/src/ui/TokenAmountInput.tsx @@ -25,6 +25,7 @@ export interface ITokenAmountInput userBalance?: string | undefined; userBalanceFullDecimals?: string | undefined; shouldEnableMaxSelector?: boolean; + shouldDisplayApprox?: boolean; } export function TokenAmountInput({ @@ -42,6 +43,7 @@ export function TokenAmountInput({ userBalance, userBalanceFullDecimals, shouldEnableMaxSelector, + shouldDisplayApprox, ...props }: ITokenAmountInput) { const { register, control, setValue } = useFormContext(); @@ -77,7 +79,8 @@ export function TokenAmountInput({ title={disabledValueFullDecimals} className="outline-none text-right p-0 m-0 border-none text-xl text-color-text-paper bg-inherit placeholder:opacity-70 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none cursor-default" > - ≈ {disabledValue} + {shouldDisplayApprox && "≈ "} + {disabledValue} ) : (