Skip to content

Commit

Permalink
chore: remove comments
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Sep 9, 2023
1 parent bf70d88 commit 97dfcfc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 18 deletions.
1 change: 0 additions & 1 deletion packages/api/src/beacon/client/beacon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Api, ReqTypes>(routesData, reqSerializers, returnTypes, httpClient);
const client = generateGenericJsonClient<Api, ReqTypes>(routesData, reqSerializers, returnTypes, httpClient);
const fetchOptsSerializer = getFetchOptsSerializers<Api, ReqTypes>(routesData, reqSerializers);

Expand Down
7 changes: 1 addition & 6 deletions packages/api/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ export type ResponseFormat = "json" | "ssz";
export type APIClientHandler = (...args: any) => PromiseLike<ApiClientResponse>;
export type APIServerHandler = (...args: any) => PromiseLike<unknown>;

export type ApiClientSuccessResponse<S extends keyof any, R> = {
ok: true;
status: S;
response: R;
error?: never;
};
export type ApiClientSuccessResponse<S extends keyof any, T> = {ok: true; status: S; response: T; error?: never};
export type ApiClientErrorResponse<S extends Exclude<HttpStatusCode, HttpSuccessCodes>> = {
ok: false;
status: S;
Expand Down
7 changes: 2 additions & 5 deletions packages/api/src/utils/client/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any, unknown> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static assert(res: ApiClientResponse, message?: string): asserts res is ApiClientSuccessResponse<any, unknown> {
if (!res.ok) {
throw new ApiError([message, res.error.message].join(" - "), res.error.code, res.error.operationId);
}
Expand Down
8 changes: 2 additions & 6 deletions packages/beacon-node/src/api/impl/beacon/blocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 97dfcfc

Please sign in to comment.