Skip to content

Commit 25073fb

Browse files
authored
feat: added ssv client (#1519)
1 parent 12782ee commit 25073fb

File tree

2 files changed

+45
-16
lines changed

2 files changed

+45
-16
lines changed

src/app/routes/dashboard/operators/operator-settings/operator-metadata.tsx

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
FormField,
99
FormItem,
1010
FormLabel,
11-
FormMessage,
11+
FormMessage
1212
} from "@/components/ui/form";
1313
import { Input, inputVariants } from "@/components/ui/input";
1414
import { NavigateBackBtn } from "@/components/ui/navigate-back-btn";
@@ -22,7 +22,7 @@ import { useOperator } from "@/hooks/operator/use-operator";
2222
import {
2323
getMevRelaysOptions,
2424
SORTED_OPERATOR_METADATA_FIELDS,
25-
type OperatorMetadataFields,
25+
type OperatorMetadataFields
2626
} from "@/lib/utils/operator";
2727
import { cn } from "@/lib/utils/tw";
2828
import { dgkURLSchema, httpsURLSchema } from "@/lib/zod";
@@ -40,7 +40,7 @@ import { operatorLogoSchema } from "@/lib/zod/operator.ts";
4040
import ImgCropUpload from "@/components/ui/ImgCropUpload.tsx";
4141

4242
const sanitizedString = z.string().regex(/^[a-zA-Z0-9_!$#|\s]*$/, {
43-
message: "Only letters, numbers, and special characters are allowed.",
43+
message: "Only letters, numbers, and special characters are allowed."
4444
});
4545

4646
export const metadataScheme = z.object({
@@ -50,6 +50,7 @@ export const metadataScheme = z.object({
5050
.min(3, "Operator name must be at least 3 characters")
5151
.max(30, "Operator name must be at most 30 characters"),
5252
description: z.string().optional().default(""),
53+
ssv_client: sanitizedString.optional().default(""),
5354
eth1_node_client: sanitizedString.optional().default(""),
5455
eth2_node_client: sanitizedString.optional().default(""),
5556
location: z.string().optional().default(""),
@@ -58,13 +59,13 @@ export const metadataScheme = z.object({
5859
twitter_url: z.union([z.literal(""), httpsURLSchema]),
5960
website_url: z.union([z.literal(""), httpsURLSchema]),
6061
linkedin_url: z.union([z.literal(""), httpsURLSchema]),
61-
dkg_address: z.union([z.literal(""), dgkURLSchema]),
62+
dkg_address: z.union([z.literal(""), dgkURLSchema])
6263
}) satisfies z.ZodObject<Record<OperatorMetadataFields, z.ZodTypeAny>>;
6364

6465
export const OperatorMetadata: FC<ComponentPropsWithoutRef<"div">> = ({
65-
className,
66-
...props
67-
}) => {
66+
className,
67+
...props
68+
}) => {
6869
const navigate = useNavigate();
6970
const sign = useSignOperatorMetadata();
7071

@@ -78,15 +79,15 @@ export const OperatorMetadata: FC<ComponentPropsWithoutRef<"div">> = ({
7879
operator?.mev_relays
7980
?.split(",")
8081
.map((val) => val.trim())
81-
.filter(Boolean) ?? [],
82+
.filter(Boolean) ?? []
8283
};
8384

8485
const form = useForm<
8586
z.infer<typeof metadataScheme> & { mev_relays: string[] }
8687
>({
8788
mode: "all",
8889
defaultValues: defaults,
89-
resolver: zodResolver(metadataScheme),
90+
resolver: zodResolver(metadataScheme)
9091
});
9192

9293
const isChange = !isEqual(defaults, form.getValues());
@@ -107,7 +108,7 @@ export const OperatorMetadata: FC<ComponentPropsWithoutRef<"div">> = ({
107108
sign
108109
.submit(operator!.id.toString(), {
109110
message,
110-
metadata,
111+
metadata
111112
})
112113
.then(() => {
113114
navigate("..");
@@ -214,7 +215,7 @@ export const OperatorMetadata: FC<ComponentPropsWithoutRef<"div">> = ({
214215
placeholder="Select your server geolocation"
215216
options={(operatorLocations.data || []).map((country) => ({
216217
value: country.name,
217-
label: `${country.name} (${country["alpha-3"]})`,
218+
label: `${country.name} (${country["alpha-3"]})`
218219
}))}
219220
/>
220221
</FormControl>
@@ -223,6 +224,31 @@ export const OperatorMetadata: FC<ComponentPropsWithoutRef<"div">> = ({
223224
)}
224225
/>
225226

227+
<FormField
228+
control={form.control}
229+
name="ssv_client"
230+
render={({ field }) => (
231+
<FormItem>
232+
<FormLabel>SSV Client</FormLabel>
233+
<FormControl>
234+
<Combobox
235+
value={field.value}
236+
onChange={(value) => field.onChange(value)}
237+
placeholder="Add your SSV Client"
238+
options={["SSV Node", "Anchor"].map(
239+
(node) => ({
240+
value: node,
241+
label: node
242+
})
243+
)}
244+
className={inputVariants({ className: "text-base" })}
245+
/>
246+
</FormControl>
247+
<FormMessage />
248+
</FormItem>
249+
)}
250+
/>
251+
226252
<FormField
227253
control={form.control}
228254
name="eth1_node_client"
@@ -237,8 +263,8 @@ export const OperatorMetadata: FC<ComponentPropsWithoutRef<"div">> = ({
237263
options={["Erigon", "Besu", "Nethermind", "Geth"].map(
238264
(node) => ({
239265
value: node,
240-
label: node,
241-
}),
266+
label: node
267+
})
242268
)}
243269
className={inputVariants({ className: "text-base" })}
244270
/>
@@ -263,10 +289,10 @@ export const OperatorMetadata: FC<ComponentPropsWithoutRef<"div">> = ({
263289
"Nimbus",
264290
"Teku",
265291
"Lighthouse",
266-
"Prysm",
292+
"Prysm"
267293
].map((node) => ({
268294
value: node,
269-
label: node,
295+
label: node
270296
}))}
271297
className={inputVariants({ className: "text-base" })}
272298
/>

src/lib/utils/operator.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export type OperatorMetadataKeys = Extract<
6767
| "setup_provider"
6868
| "mev_relays"
6969
| "location"
70+
| "ssv_client"
7071
| "eth1_node_client"
7172
| "eth2_node_client"
7273
| "website_url"
@@ -82,6 +83,7 @@ export enum OperatorMetadataFields {
8283
SetupProvider = "setup_provider",
8384
MevRelays = "mev_relays",
8485
Location = "location",
86+
SSVClient = "ssv_client",
8587
ExecutionClient = "eth1_node_client",
8688
ConsensusClient = "eth2_node_client",
8789
WebsiteUrl = "website_url",
@@ -90,11 +92,12 @@ export enum OperatorMetadataFields {
9092
DkgAddress = "dkg_address",
9193
}
9294

93-
export const SORTED_OPERATOR_METADATA_FIELDS: OperatorMetadataKeys[] = [
95+
export const SORTED_OPERATOR_METADATA_FIELDS = [
9496
OperatorMetadataFields.OperatorName,
9597
OperatorMetadataFields.Description,
9698
OperatorMetadataFields.Location,
9799
OperatorMetadataFields.SetupProvider,
100+
OperatorMetadataFields.SSVClient,
98101
OperatorMetadataFields.ExecutionClient,
99102
OperatorMetadataFields.ConsensusClient,
100103
OperatorMetadataFields.MevRelays,

0 commit comments

Comments
 (0)