diff --git a/packages/api/src/beacon/client/beacon.ts b/packages/api/src/beacon/client/beacon.ts index 246eaaa20e20..7a92afe15c6f 100644 --- a/packages/api/src/beacon/client/beacon.ts +++ b/packages/api/src/beacon/client/beacon.ts @@ -11,7 +11,6 @@ export function getClient(config: ChainForkConfig, httpClient: IHttpClient): Api const reqSerializers = getReqSerializers(config); const returnTypes = getReturnTypes(); // Some routes return JSON, use a client auto-generator - // return generateGenericJsonClient(routesData, reqSerializers, returnTypes, httpClient); const client = generateGenericJsonClient(routesData, reqSerializers, returnTypes, httpClient); const fetchOptsSerializer = getFetchOptsSerializers(routesData, reqSerializers); diff --git a/packages/api/src/interfaces.ts b/packages/api/src/interfaces.ts index 4862c886bd54..4d57bcbc8934 100644 --- a/packages/api/src/interfaces.ts +++ b/packages/api/src/interfaces.ts @@ -7,12 +7,7 @@ export type ResponseFormat = "json" | "ssz"; export type APIClientHandler = (...args: any) => PromiseLike; export type APIServerHandler = (...args: any) => PromiseLike; -export type ApiClientSuccessResponse = { - ok: true; - status: S; - response: R; - error?: never; -}; +export type ApiClientSuccessResponse = {ok: true; status: S; response: T; error?: never}; export type ApiClientErrorResponse> = { ok: false; status: S; diff --git a/packages/api/src/utils/client/httpClient.ts b/packages/api/src/utils/client/httpClient.ts index e16e473695b4..54a7ca8d4e42 100644 --- a/packages/api/src/utils/client/httpClient.ts +++ b/packages/api/src/utils/client/httpClient.ts @@ -38,11 +38,8 @@ export class ApiError extends Error { this.operationId = operationId; } - static assert( - res: ApiClientResponse, - message?: string - // eslint-disable-next-line @typescript-eslint/no-explicit-any - ): asserts res is ApiClientSuccessResponse { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + static assert(res: ApiClientResponse, message?: string): asserts res is ApiClientSuccessResponse { if (!res.ok) { throw new ApiError([message, res.error.message].join(" - "), res.error.code, res.error.operationId); } diff --git a/packages/beacon-node/src/api/impl/beacon/blocks/index.ts b/packages/beacon-node/src/api/impl/beacon/blocks/index.ts index 7cf732f7d511..11b96d29fa3b 100644 --- a/packages/beacon-node/src/api/impl/beacon/blocks/index.ts +++ b/packages/beacon-node/src/api/impl/beacon/blocks/index.ts @@ -246,9 +246,7 @@ export function getBeaconBlockApi({ async getBlock(blockId, format?: ResponseFormat) { const {block} = await resolveBlockId(chain, blockId); if (format === "ssz") { - // Casting to any otherwise Typescript doesn't like the multi-type return - // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-explicit-any - return config.getForkTypes(block.message.slot).SignedBeaconBlock.serialize(block) as any; + return config.getForkTypes(block.message.slot).SignedBeaconBlock.serialize(block); } return { data: block, @@ -258,9 +256,7 @@ export function getBeaconBlockApi({ async getBlockV2(blockId, format?: ResponseFormat) { const {block, executionOptimistic} = await resolveBlockId(chain, blockId); if (format === "ssz") { - // Casting to any otherwise Typescript doesn't like the multi-type return - // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-explicit-any - return config.getForkTypes(block.message.slot).SignedBeaconBlock.serialize(block) as any; + return config.getForkTypes(block.message.slot).SignedBeaconBlock.serialize(block); } return { executionOptimistic,