diff --git a/packages/brain/src/calls/validators.ts b/packages/brain/src/calls/validators.ts index ba799a7a..28562619 100644 --- a/packages/brain/src/calls/validators.ts +++ b/packages/brain/src/calls/validators.ts @@ -16,6 +16,9 @@ import { Network, isFeeRecipientEditable, NonEditableFeeRecipientTag, + WithdrawalCredentialsFormat, + isValidEcdsaPubkey, + isValidBlsPubkey, } from "@stakingbrain/common"; import { beaconchainApi, @@ -319,17 +322,41 @@ export async function getValidators(): Promise { }); const validators: CustomValidatorGetResponse[] = []; - for (const [pubkey, { tag, feeRecipient }] of Object.entries(data)) + for (const [pubkey, { tag, feeRecipient }] of Object.entries(data)) { + let format: WithdrawalCredentialsFormat, + withdrawalAddress = ""; + try { + withdrawalAddress = ( + await beaconchainApi.getValidatorFromState({ + state: "head", + pubkey, + }) + ).data.validator.withdrawal_credentials; + format = isValidEcdsaPubkey(withdrawalAddress) + ? "ecdsa" + : isValidBlsPubkey(pubkey) + ? "bls" + : "unknown"; + } catch (e) { + logger.error(e); + format = "error"; + } + validators.push({ pubkey, tag, feeRecipient, + withdrawalCredentials: { + address: withdrawalAddress, + format, + }, validatorImported: validatorPubkeys.includes(pubkey), signerImported: signerPubkeys.includes(pubkey), validatorFeeRecipientCorrect: validatorsFeeRecipients.some( (feeRecipient) => feeRecipient === feeRecipient ), }); + } return validators; } diff --git a/packages/common/src/types/customValidators/types.ts b/packages/common/src/types/customValidators/types.ts index 8cb7cf78..aea2d44c 100644 --- a/packages/common/src/types/customValidators/types.ts +++ b/packages/common/src/types/customValidators/types.ts @@ -16,10 +16,16 @@ export interface CustomValidatorUpdateRequest { pubkey: string; feeRecipient: string; } + +export type WithdrawalCredentialsFormat = "ecdsa" | "bls" | "unknown" | "error"; export interface CustomValidatorGetResponse { pubkey: string; tag: Tag; feeRecipient: string; + withdrawalCredentials: { + format: WithdrawalCredentialsFormat; + address: string; + }; signerImported?: boolean; validatorImported?: boolean; validatorFeeRecipientCorrect?: boolean; diff --git a/packages/ui/src/components/ValidatorList/KeystoresDataGrid.tsx b/packages/ui/src/components/ValidatorList/KeystoresDataGrid.tsx index 1b899709..54c41953 100644 --- a/packages/ui/src/components/ValidatorList/KeystoresDataGrid.tsx +++ b/packages/ui/src/components/ValidatorList/KeystoresDataGrid.tsx @@ -120,6 +120,7 @@ export default function KeystoresDataGrid({ : "", feeRecipient: row.feeRecipient, tag: row.tag, + withdrawalCredentials: row.withdrawalCredentials, pubkeyInValidator: row.validatorImported, pubkeyInSigner: row.signerImported, feeRecipientImported: row.validatorFeeRecipientCorrect, @@ -138,8 +139,7 @@ export default function KeystoresDataGrid({ sortable: false, align: "center", headerAlign: "center", - // eslint-disable-next-line @typescript-eslint/no-explicit-any - renderCell: (rowData: any) => ( + renderCell: (rowData) => ( ( +
+ {rowData.row.withdrawalCredentials.format === "ecdsa" ? ( + + ) : rowData.row.withdrawalCredentials.format === "bls" ? ( + + ) : ( + + )} +
+ ), + headerClassName: "tableHeader", + width: 120, + }, { field: "pubkeyInSigner", headerName: "Pubkey In Signer", @@ -228,7 +252,6 @@ export default function KeystoresDataGrid({ } ); - async function getValidatorSummaryURL() { if (!beaconchaApiParamsMap?.get(network)) { setValidatorSummaryURL("");