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
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@
"devDependencies": {
"@chainsafe/eslint-plugin-node": "^11.2.3",
"@dapplion/benchmark": "^0.2.2",
"@types/chai": "^4.3.3",
"@types/chai": "^4.3.4",
"@types/chai-as-promised": "^7.1.5",
"@types/mocha": "^10.0.0",
"@types/node": "^18.11.9",
"@types/mocha": "^10.0.1",
"@types/node": "^18.15.11",
"@types/sinon": "^10.0.13",
"@types/sinon-chai": "^3.2.8",
"@typescript-eslint/eslint-plugin": "5.26.0",
"@typescript-eslint/parser": "5.26.0",
"chai": "^4.3.6",
"@types/sinon-chai": "^3.2.9",
"@typescript-eslint/eslint-plugin": "5.57.1",
"@typescript-eslint/parser": "5.57.1",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"codecov": "^3.8.3",
"crypto-browserify": "^3.12.0",
"electron": "^21.0.1",
"eslint": "^8.16.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint": "^8.37.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-chai-expect": "^3.0.0",
"eslint-plugin-mocha": "^10.1.0",
"https-browserify": "^1.0.0",
Expand All @@ -61,26 +61,26 @@
"karma-electron": "^7.3.0",
"karma-firefox-launcher": "^2.1.2",
"karma-mocha": "^2.0.1",
"karma-spec-reporter": "^0.0.34",
"karma-spec-reporter": "^0.0.36",
"karma-webpack": "^5.0.0",
"lerna": "^5.5.2",
"mocha": "^10.0.0",
"node-gyp": "^9.0.0",
"mocha": "^10.2.0",
"node-gyp": "^9.3.1",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"path-browserify": "^1.0.1",
"prettier": "^2.0.5",
"prettier": "^2.8.7",
"process": "^0.11.10",
"resolve-typescript-plugin": "^1.2.0",
"sinon": "^14.0.0",
"resolve-typescript-plugin": "^2.0.1",
"sinon": "^15.0.3",
"sinon-chai": "^3.7.0",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"supertest": "^6.2.4",
"ts-loader": "^9.3.1",
"supertest": "^6.3.3",
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"typescript": "4.9.3",
"typescript-docs-verifier": "^2.3.0",
"webpack": "^5.74.0"
"typescript": "^5.0.3",
"typescript-docs-verifier": "^2.4.0",
"webpack": "^5.77.0"
}
}
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"qs": "^6.11.1"
},
"devDependencies": {
"@types/eventsource": "^1.1.5",
"@types/eventsource": "^1.1.11",
"@types/qs": "^6.9.7",
"ajv": "^8.11.0",
"fastify": "3.29.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/beacon/client/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function getClient(config: ChainForkConfig, baseUrl: string): Api {
// `eventSource.onerror` events are informative but don't indicate the EventSource closed
// The only way to abort the connection from the client is via eventSource.close()
eventSource.onerror = function onerror(err) {
const errEs = (err as unknown) as EventSourceError;
const errEs = err as unknown as EventSourceError;
// Consider 400 and 500 status errors unrecoverable, close the eventsource
if (errEs.status === 400) {
reject(Error(`400 Invalid topics: ${errEs.message}`));
Expand Down
36 changes: 10 additions & 26 deletions packages/api/src/beacon/routes/beacon/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ export type Api = {
* @param blockId Block identifier.
* Can be one of: "head" (canonical head in node's view), "genesis", "finalized", \<slot\>, \<hex encoded blockRoot with 0x prefix\>.
*/
getBlockV2(
blockId: BlockId
): Promise<
getBlockV2(blockId: BlockId): Promise<
ApiClientResponse<
{
[HttpStatusCode.OK]: {
Expand All @@ -74,9 +72,7 @@ export type Api = {
* @param blockId Block identifier.
* Can be one of: "head" (canonical head in node's view), "genesis", "finalized", \<slot\>, \<hex encoded blockRoot with 0x prefix\>.
*/
getBlockAttestations(
blockId: BlockId
): Promise<
getBlockAttestations(blockId: BlockId): Promise<
ApiClientResponse<
{
[HttpStatusCode.OK]: {
Expand All @@ -94,9 +90,7 @@ export type Api = {
* @param blockId Block identifier.
* Can be one of: "head" (canonical head in node's view), "genesis", "finalized", \<slot\>, \<hex encoded blockRoot with 0x prefix\>.
*/
getBlockHeader(
blockId: BlockId
): Promise<
getBlockHeader(blockId: BlockId): Promise<
ApiClientResponse<
{
[HttpStatusCode.OK]: {
Expand All @@ -114,9 +108,7 @@ export type Api = {
* @param slot
* @param parentRoot
*/
getBlockHeaders(
filters: Partial<{slot: Slot; parentRoot: string}>
): Promise<
getBlockHeaders(filters: Partial<{slot: Slot; parentRoot: string}>): Promise<
ApiClientResponse<
{
[HttpStatusCode.OK]: {
Expand All @@ -134,9 +126,7 @@ export type Api = {
* @param blockId Block identifier.
* Can be one of: "head" (canonical head in node's view), "genesis", "finalized", \<slot\>, \<hex encoded blockRoot with 0x prefix\>.
*/
getBlockRoot(
blockId: BlockId
): Promise<
getBlockRoot(blockId: BlockId): Promise<
ApiClientResponse<
{
[HttpStatusCode.OK]: {
Expand All @@ -160,9 +150,7 @@ export type Api = {
* @param requestBody The `SignedBeaconBlock` object composed of `BeaconBlock` object (produced by beacon node) and validator signature.
* @returns any The block was validated successfully and has been broadcast. It has also been integrated into the beacon node's database.
*/
publishBlock(
block: allForks.SignedBeaconBlock
): Promise<
publishBlock(block: allForks.SignedBeaconBlock): Promise<
ApiClientResponse<
{
[HttpStatusCode.OK]: void;
Expand All @@ -175,9 +163,7 @@ export type Api = {
* Publish a signed blinded block by submitting it to the mev relay and patching in the block
* transactions beacon node gets in response.
*/
publishBlindedBlock(
block: allForks.SignedBlindedBeaconBlock
): Promise<
publishBlindedBlock(block: allForks.SignedBlindedBeaconBlock): Promise<
ApiClientResponse<
{
[HttpStatusCode.OK]: void;
Expand All @@ -192,9 +178,7 @@ export type Api = {
* @param blockId Block identifier.
* Can be one of: "head" (canonical head in node's view), "genesis", "finalized", \<slot\>, \<hex encoded blockRoot with 0x prefix\>.
*/
getBlobsSidecar(
blockId: BlockId
): Promise<
getBlobsSidecar(blockId: BlockId): Promise<
ApiClientResponse<{
[HttpStatusCode.OK]: {executionOptimistic: ExecutionOptimistic; data: deneb.BlobsSidecar};
}>
Expand Down Expand Up @@ -245,7 +229,7 @@ export function getReqSerializers(config: ChainForkConfig): ReqSerializers<Api,

const AllForksSignedBeaconBlock: TypeJson<allForks.SignedBeaconBlock> = {
toJson: (data) => getSignedBeaconBlockType(data).toJson(data),
fromJson: (data) => getSignedBeaconBlockType((data as unknown) as allForks.SignedBeaconBlock).fromJson(data),
fromJson: (data) => getSignedBeaconBlockType(data as unknown as allForks.SignedBeaconBlock).fromJson(data),
};

const getSignedBlindedBeaconBlockType = (
Expand All @@ -256,7 +240,7 @@ export function getReqSerializers(config: ChainForkConfig): ReqSerializers<Api,
const AllForksSignedBlindedBeaconBlock: TypeJson<allForks.SignedBlindedBeaconBlock> = {
toJson: (data) => getSignedBlindedBeaconBlockType(data).toJson(data),
fromJson: (data) =>
getSignedBlindedBeaconBlockType((data as unknown) as allForks.SignedBlindedBeaconBlock).fromJson(data),
getSignedBlindedBeaconBlockType(data as unknown as allForks.SignedBlindedBeaconBlock).fromJson(data),
};

return {
Expand Down
12 changes: 6 additions & 6 deletions packages/api/src/beacon/routes/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,35 +193,35 @@ export function getTypeByEvent(config: ChainForkConfig): {[K in EventType]: Type

[EventType.lightClientOptimisticUpdate]: {
toJson: (data) =>
getLightClientTypeFromHeader(((data as unknown) as allForks.LightClientOptimisticUpdate).attestedHeader)[
getLightClientTypeFromHeader((data as unknown as allForks.LightClientOptimisticUpdate).attestedHeader)[
"LightClientOptimisticUpdate"
].toJson(data),
fromJson: (data) =>
getLightClientTypeFromHeader(
// eslint-disable-next-line @typescript-eslint/naming-convention
((data as unknown) as {attested_header: allForks.LightClientHeader}).attested_header
(data as unknown as {attested_header: allForks.LightClientHeader}).attested_header
)["LightClientOptimisticUpdate"].fromJson(data),
},
[EventType.lightClientFinalityUpdate]: {
toJson: (data) =>
getLightClientTypeFromHeader(((data as unknown) as allForks.LightClientFinalityUpdate).attestedHeader)[
getLightClientTypeFromHeader((data as unknown as allForks.LightClientFinalityUpdate).attestedHeader)[
"LightClientFinalityUpdate"
].toJson(data),
fromJson: (data) =>
getLightClientTypeFromHeader(
// eslint-disable-next-line @typescript-eslint/naming-convention
((data as unknown) as {attested_header: allForks.LightClientHeader}).attested_header
(data as unknown as {attested_header: allForks.LightClientHeader}).attested_header
)["LightClientFinalityUpdate"].fromJson(data),
},
[EventType.lightClientUpdate]: {
toJson: (data) =>
getLightClientTypeFromHeader(((data as unknown) as allForks.LightClientUpdate).attestedHeader)[
getLightClientTypeFromHeader((data as unknown as allForks.LightClientUpdate).attestedHeader)[
"LightClientUpdate"
].toJson(data),
fromJson: (data) =>
getLightClientTypeFromHeader(
// eslint-disable-next-line @typescript-eslint/naming-convention
((data as unknown) as {attested_header: allForks.LightClientHeader}).attested_header
(data as unknown as {attested_header: allForks.LightClientHeader}).attested_header
)["LightClientUpdate"].fromJson(data),
},
};
Expand Down
4 changes: 1 addition & 3 deletions packages/api/src/beacon/routes/lightclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ export type Api = {
* The trusted block root should be fetched with similar means to a weak subjectivity checkpoint.
* Only block roots for checkpoints are guaranteed to be available.
*/
getBootstrap(
blockRoot: string
): Promise<
getBootstrap(blockRoot: string): Promise<
ApiClientResponse<{
[HttpStatusCode.OK]: {
version: ForkName;
Expand Down
4 changes: 1 addition & 3 deletions packages/api/src/keymanager/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ export type Api = {
*
* https://github.com/ethereum/keymanager-APIs/blob/0c975dae2ac6053c8245ebdb6a9f27c2f114f407/keymanager-oapi.yaml
*/
deleteKeys(
pubkeysHex: string[]
): Promise<
deleteKeys(pubkeysHex: string[]): Promise<
ApiClientResponse<{
[HttpStatusCode.OK]: {data: ResponseStatus<DeletionStatus>[]; slashingProtection: SlashingProtectionData};
}>
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/utils/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function generateGenericJsonClient<
returnTypes: ReturnTypes<Api>,
fetchFn: IHttpClient
): Api {
return (mapValues(routesData, (routeDef, routeId) => {
return mapValues(routesData, (routeDef, routeId) => {
const fetchOptsSerializer = getFetchOptsSerializer(routeDef, reqSerializers[routeId], routeId as string);
const returnType = returnTypes[routeId as keyof ReturnTypes<Api>] as TypeJson<any> | null;

Expand Down Expand Up @@ -94,5 +94,5 @@ export function generateGenericJsonClient<
throw err;
}
};
}) as unknown) as Api;
}) as unknown as Api;
}
2 changes: 1 addition & 1 deletion packages/api/src/utils/client/eventSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export async function getEventSource(): Promise<typeof EventSource> {
if (globalThis.EventSource) {
return EventSource;
} else {
return ((await import("eventsource")).default as unknown) as typeof EventSource;
return (await import("eventsource")).default as unknown as typeof EventSource;
}
}
14 changes: 7 additions & 7 deletions packages/api/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ export const reqOnlyBody = <T>(
/** SSZ factory helper + typed. limit = 1e6 as a big enough random number */
export function ArrayOf<T>(elementType: Type<T>): ArrayType<Type<T>, unknown, unknown> {
if (isCompositeType(elementType)) {
return (new ListCompositeType(elementType, Infinity) as unknown) as ArrayType<Type<T>, unknown, unknown>;
return new ListCompositeType(elementType, Infinity) as unknown as ArrayType<Type<T>, unknown, unknown>;
} else if (isBasicType(elementType)) {
return (new ListBasicType(elementType, Infinity) as unknown) as ArrayType<Type<T>, unknown, unknown>;
return new ListBasicType(elementType, Infinity) as unknown as ArrayType<Type<T>, unknown, unknown>;
} else {
throw Error(`Unknown type ${elementType.typeName}`);
}
Expand Down Expand Up @@ -142,15 +142,15 @@ export function ContainerDataExecutionOptimistic<T>(
export function WithVersion<T>(getType: (fork: ForkName) => TypeJson<T>): TypeJson<{data: T; version: ForkName}> {
return {
toJson: ({data, version}) => ({
data: getType(version || ForkName.phase0).toJson(data),
data: getType(version ?? ForkName.phase0).toJson(data),
version,
}),
fromJson: ({data, version}: {data: unknown; version: string}) => {
// Teku returns fork as UPPERCASE
version = version.toLowerCase();

// Un-safe external data, validate version is known ForkName value
if (!ForkName[version as ForkName]) throw Error(`Invalid version ${version}`);
if (!(version in ForkName)) throw Error(`Invalid version ${version}`);

return {
data: getType(version as ForkName).fromJson(data),
Expand All @@ -168,7 +168,7 @@ export function WithExecutionOptimistic<T extends {data: unknown}>(
): TypeJson<T & {executionOptimistic: boolean}> {
return {
toJson: ({executionOptimistic, ...data}) => ({
...(type.toJson((data as unknown) as T) as Record<string, unknown>),
...(type.toJson(data as unknown as T) as Record<string, unknown>),
execution_optimistic: executionOptimistic,
}),
fromJson: ({execution_optimistic, ...data}: T & {execution_optimistic: boolean}) => ({
Expand All @@ -184,7 +184,7 @@ export function WithExecutionOptimistic<T extends {data: unknown}>(
export function WithBlockValue<T extends {data: unknown}>(type: TypeJson<T>): TypeJson<T & {blockValue: bigint}> {
return {
toJson: ({blockValue, ...data}) => ({
...(type.toJson((data as unknown) as T) as Record<string, unknown>),
...(type.toJson(data as unknown as T) as Record<string, unknown>),
block_value: blockValue.toString(),
}),
fromJson: ({block_value, ...data}: T & {block_value: string}) => ({
Expand All @@ -211,7 +211,7 @@ export function jsonType<T extends Record<string, unknown> | Record<string, unkn
export function sameType<T>(): TypeJson<T> {
return {
toJson: (val) => val as unknown,
fromJson: (json) => (json as unknown) as T,
fromJson: (json) => json as unknown as T,
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
},
"devDependencies": {
"@types/bl": "^5.0.1",
"@types/eventsource": "^1.1.5",
"@types/eventsource": "^1.1.11",
"@types/leveldown": "^4.0.2",
"@types/prometheus-gc-stats": "^0.6.1",
"@types/qs": "^6.9.7",
Expand Down
Loading