Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion packages/brain/src/calls/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import {
Network,
isFeeRecipientEditable,
NonEditableFeeRecipientTag,
WithdrawalCredentialsFormat,
isValidEcdsaPubkey,
isValidBlsPubkey,
} from "@stakingbrain/common";
import {
beaconchainApi,
Expand Down Expand Up @@ -319,17 +322,41 @@ export async function getValidators(): Promise<CustomValidatorGetResponse[]> {
});

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;
}
Expand Down
6 changes: 6 additions & 0 deletions packages/common/src/types/customValidators/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
29 changes: 26 additions & 3 deletions packages/ui/src/components/ValidatorList/KeystoresDataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) => (
<a
style={{ color: "grey" }}
href={rowData.row.beaconcha_url}
Expand All @@ -152,6 +152,30 @@ export default function KeystoresDataGrid({
headerClassName: "tableHeader",
width: 60,
},
{
field: "isWithdrawalEcdsa",
headerName: "WD is ECDSA",
description: "Weather the withdrawal address is ECDSA or not",
disableReorder: true,
disableColumnMenu: true,
disableExport: true,
sortable: false,
align: "center",
headerAlign: "center",
renderCell: (rowData) => (
<div>
{rowData.row.withdrawalCredentials.format === "ecdsa" ? (
<CheckCircleIcon style={{ color: "green" }} />
) : rowData.row.withdrawalCredentials.format === "bls" ? (
<CancelIcon style={{ color: "red" }} />
) : (
<HelpIcon style={{ color: "grey" }} />
)}
</div>
),
headerClassName: "tableHeader",
width: 120,
},
{
field: "pubkeyInSigner",
headerName: "Pubkey In Signer",
Expand Down Expand Up @@ -228,7 +252,6 @@ export default function KeystoresDataGrid({
}
);


async function getValidatorSummaryURL() {
if (!beaconchaApiParamsMap?.get(network)) {
setValidatorSummaryURL("");
Expand Down