From f35bff70fc795787283ec005cbcce350748f72b4 Mon Sep 17 00:00:00 2001 From: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com> Date: Wed, 20 Nov 2024 17:30:46 +0100 Subject: [PATCH] Fix get exit validators (#407) --- .../apiServers/ui/calls/exitValidators.ts | 18 +++++++++++------- .../src/modules/apiServers/ui/calls/index.ts | 6 ++++-- .../src/modules/apiServers/ui/calls/types.ts | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/brain/src/modules/apiServers/ui/calls/exitValidators.ts b/packages/brain/src/modules/apiServers/ui/calls/exitValidators.ts index 15e5e0f7..0035750b 100644 --- a/packages/brain/src/modules/apiServers/ui/calls/exitValidators.ts +++ b/packages/brain/src/modules/apiServers/ui/calls/exitValidators.ts @@ -20,7 +20,7 @@ export async function getExitValidators({ signerApi: Web3SignerApi; pubkeys: string[]; }): Promise { - const validatorsExit = await _getExitValidators(beaconchainApi, signerApi, pubkeys); + const validatorsExit = await _getExitValidators({ beaconchainApi, signerApi, pubkeys }); logger.debug(validatorsExit); return validatorsExit; } @@ -39,7 +39,7 @@ export async function exitValidators({ beaconchainApi: BeaconchainApi; pubkeys: string[]; }): Promise { - const validatorsToExit = await _getExitValidators(beaconchainApi, signerApi, pubkeys); + const validatorsToExit = await _getExitValidators({ beaconchainApi, signerApi, pubkeys }); const exitValidatorsResponses: ValidatorExitExecute[] = []; for (const validatorToExit of validatorsToExit) { try { @@ -78,11 +78,15 @@ export async function exitValidators({ * @param pubkeys The public keys of the validators to exit * @returns The exit validators info signed */ -async function _getExitValidators( - beaconchainApi: BeaconchainApi, - signerApi: Web3SignerApi, - pubkeys: string[] -): Promise { +async function _getExitValidators({ + beaconchainApi, + signerApi, + pubkeys +}: { + beaconchainApi: BeaconchainApi; + signerApi: Web3SignerApi; + pubkeys: string[]; +}): Promise { // Get the current epoch from the beaconchain API to exit the validators const currentEpoch = await beaconchainApi.getEpochHeader({ blockId: "head" }); diff --git a/packages/brain/src/modules/apiServers/ui/calls/index.ts b/packages/brain/src/modules/apiServers/ui/calls/index.ts index 225cad95..f74dd24d 100644 --- a/packages/brain/src/modules/apiServers/ui/calls/index.ts +++ b/packages/brain/src/modules/apiServers/ui/calls/index.ts @@ -50,8 +50,10 @@ export const createRpcMethods = ({ await beaconchaFetchValidatorsInfo({ blockExplorerApi, pubkeys }), deleteValidators: async (deleteRequest: Web3signerDeleteRequest) => await deleteValidators({ brainDb, reloadValidatorsCronTask, validatorApi, signerApi, deleteRequest }), - exitValidators: async (pubkeys: string[]) => await exitValidators({ pubkeys, beaconchainApi, signerApi }), - getExitValidators: async (pubkeys: string[]) => await getExitValidators({ beaconchainApi, signerApi, pubkeys }), + exitValidators: async ({ pubkeys }: { pubkeys: string[] }) => + await exitValidators({ pubkeys, beaconchainApi, signerApi }), + getExitValidators: async ({ pubkeys }: { pubkeys: string[] }) => + await getExitValidators({ beaconchainApi, signerApi, pubkeys }), importValidators: async (postRequest: CustomImportRequest) => await importValidators({ postRequest, diff --git a/packages/brain/src/modules/apiServers/ui/calls/types.ts b/packages/brain/src/modules/apiServers/ui/calls/types.ts index 43c904cd..3c966c3f 100644 --- a/packages/brain/src/modules/apiServers/ui/calls/types.ts +++ b/packages/brain/src/modules/apiServers/ui/calls/types.ts @@ -16,8 +16,8 @@ export interface RpcMethods { beaconchaFetchAllValidatorsInfo: (pubkeys: string[]) => Promise; beaconchaFetchValidatorsInfo: (pubkeys: string[]) => Promise; deleteValidators: (deleteRequest: Web3signerDeleteRequest) => Promise; - exitValidators: (pubkeys: string[]) => Promise; - getExitValidators: (pubkeys: string[]) => Promise; + exitValidators: ({ pubkeys }: { pubkeys: string[] }) => Promise; + getExitValidators: ({ pubkeys }: { pubkeys: string[] }) => Promise; importValidators: (postRequest: CustomImportRequest) => Promise; updateValidators: ( customValidatorUpdateRequest: CustomValidatorUpdateRequest[],