From 6e22fe26cf14194b7d81aab67ff0bc8ffe903373 Mon Sep 17 00:00:00 2001 From: brown Date: Fri, 13 Dec 2024 12:25:14 -0500 Subject: [PATCH 1/2] feat(hub): add small improvements to vp for configuration --- .../components/general-settings.tsx | 46 ++++++++++++++----- .../components/validator-configuration.tsx | 37 +++++++++------ 2 files changed, 57 insertions(+), 26 deletions(-) diff --git a/apps/hub/src/app/validators/components/general-settings.tsx b/apps/hub/src/app/validators/components/general-settings.tsx index 5150753f8..1e6681c6a 100644 --- a/apps/hub/src/app/validators/components/general-settings.tsx +++ b/apps/hub/src/app/validators/components/general-settings.tsx @@ -6,14 +6,14 @@ import { useValidatorOperatorAddress, useValidatorQueuedOperatorAddress, } from "@bera/berajs"; -import { depositContractAddress } from "@bera/config"; +import { blockExplorerUrl, depositContractAddress } from "@bera/config"; import { useTxn } from "@bera/shared-ui"; import { Button } from "@bera/ui/button"; import { Card, CardContent, CardFooter } from "@bera/ui/card"; import { Checkbox } from "@bera/ui/checkbox"; import { Icons } from "@bera/ui/icons"; import { Input } from "@bera/ui/input"; -import { Address, zeroAddress } from "viem"; +import { Address, isAddress, zeroAddress } from "viem"; export const GeneralSettings = ({ validatorPublicKey, @@ -107,6 +107,10 @@ export const GeneralSettings = ({ }); }, [validatorPublicKey]); + const isValidAddress = useMemo(() => { + return operatorInput ? isAddress(operatorInput) : true; + }, [operatorInput]); + return (
{isQueuedOperatorAddress && ( @@ -119,13 +123,22 @@ export const GeneralSettings = ({ ? "Confirm Operator Address Change" : "Queued Operator Address Change"}
- - {`Operator Address is currently queued to change to ${ - queuedOperatorAddress?.[1] - }. You'll be able to apply the change at ${new Date( - timeRemaining, - ).toLocaleString()}`} - +
+ + {"Operator Address is currently queued to change to "} + + {queuedOperatorAddress?.[1]} + + {`. You'll be able to apply the change at ${new Date( + timeRemaining, + ).toLocaleString()}`} + +
); }; From eebe3f85cceb04fa2c75950d44a3f47283aed874 Mon Sep 17 00:00:00 2001 From: brown Date: Fri, 13 Dec 2024 13:07:13 -0500 Subject: [PATCH 2/2] fix(hub): updates to vp configuration nit --- .../components/general-settings.tsx | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/apps/hub/src/app/validators/components/general-settings.tsx b/apps/hub/src/app/validators/components/general-settings.tsx index 1e6681c6a..e1dce8b65 100644 --- a/apps/hub/src/app/validators/components/general-settings.tsx +++ b/apps/hub/src/app/validators/components/general-settings.tsx @@ -2,6 +2,7 @@ import { useCallback, useMemo, useState } from "react"; import { TransactionActionType, beaconDepositAbi, + truncateHash, useBeraJs, useValidatorOperatorAddress, useValidatorQueuedOperatorAddress, @@ -12,7 +13,7 @@ import { Button } from "@bera/ui/button"; import { Card, CardContent, CardFooter } from "@bera/ui/card"; import { Checkbox } from "@bera/ui/checkbox"; import { Icons } from "@bera/ui/icons"; -import { Input } from "@bera/ui/input"; +import { InputWithLabel } from "@bera/ui/input"; import { Address, isAddress, zeroAddress } from "viem"; export const GeneralSettings = ({ @@ -32,7 +33,7 @@ export const GeneralSettings = ({ isLoading: isQueuedOperatorAddressLoading, refresh: refreshQueuedOperatorAddress, } = useValidatorQueuedOperatorAddress(validatorPublicKey); - const [operatorInput, setOperatorInput] = useState(account || ""); + const [operatorInput, setOperatorInput] = useState(""); const isQueuedOperatorAddress = useMemo(() => { if ( @@ -107,9 +108,13 @@ export const GeneralSettings = ({ }); }, [validatorPublicKey]); - const isValidAddress = useMemo(() => { - return operatorInput ? isAddress(operatorInput) : true; - }, [operatorInput]); + const isValidAddress = useMemo( + () => + isAddress(operatorInput) && + operatorInput !== zeroAddress && + operatorInput !== account, + [operatorInput], + ); return (
@@ -170,17 +175,12 @@ export const GeneralSettings = ({ Configure your operator address Operator Address - setOperatorInput(e.target.value)} + className="w-[300px]" + error={!isValidAddress ? "Please enter a valid address" : undefined} /> @@ -202,6 +202,15 @@ export const GeneralSettings = ({