diff --git a/.gitignore b/.gitignore index 4629fc827..83a8c01d5 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ node_modules/\.yarn-integrity # Typescript build artifacts build/src/dist/ build/src/.temp-transfer/ +packages/*/tsconfig.tsbuildinfo # Common packages/*/node_modules/ diff --git a/package.json b/package.json index 1448fbc0b..9925b69fe 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "nodemon": "^3.0.2", "rimraf": "^3.0.2", "ts-node": "^10.9.2", - "typescript": "^5.3.3" + "typescript": "^5.5.4" }, "packageManager": "yarn@4.4.0" } diff --git a/packages/admin-ui/src/App.tsx b/packages/admin-ui/src/App.tsx index 90a4febf2..647329dcf 100644 --- a/packages/admin-ui/src/App.tsx +++ b/packages/admin-ui/src/App.tsx @@ -22,9 +22,9 @@ export const AppContext = React.createContext({ theme: "light", stakersModuleStatus: "enabled", rollupsModuleStatus: "disabled", - toggleTheme: () => { }, - toggleStakersModuleStatus: () => { }, - toggleRollupsModuleStatus: () => { } + toggleTheme: () => {}, + toggleStakersModuleStatus: () => {}, + toggleRollupsModuleStatus: () => {} }); const useLocalStorage = ( @@ -169,16 +169,16 @@ export default function App() { // Keep retrying if there is a loggin error, probably due a network error useEffect(() => { - if (isError) { - let timeToNext = 500; - let timeout: unknown; - const recursiveTimeout = () => { - onFetchLoginStatus(); - timeout = setTimeout(recursiveTimeout, (timeToNext *= 2)); - }; - recursiveTimeout(); - return () => clearTimeout(timeout as number); - } + if (!isError) return; + + let timeToNext = 500; + let timeout: unknown; + const recursiveTimeout = () => { + onFetchLoginStatus(); + timeout = setTimeout(recursiveTimeout, (timeToNext *= 2)); + }; + recursiveTimeout(); + return () => clearTimeout(timeout as number); }, [isError, onFetchLoginStatus]); if (!loginStatus) { diff --git a/packages/admin-ui/src/__mock-backend__/index.ts b/packages/admin-ui/src/__mock-backend__/index.ts index 58e7988cb..1af534bba 100644 --- a/packages/admin-ui/src/__mock-backend__/index.ts +++ b/packages/admin-ui/src/__mock-backend__/index.ts @@ -127,7 +127,7 @@ export const otherCalls: Omit = { dnpName: "dnp.prysm.eth" } ], - dappnodeWebNameSet: async ({ dappnodeWebName }) => {}, + dappnodeWebNameSet: async () => {}, statsCpuGet: async () => ({ usedPercentage: 88, numberOfCores: 4, @@ -256,7 +256,7 @@ export const otherCalls: Omit = { ipfsClientTarget: IpfsClientTarget.remote, ipfsGateway: "https://gateway.ipfs.dappnode.io" }), - enableEthicalMetrics: async ({ mail }) => {}, + enableEthicalMetrics: async () => {}, getEthicalMetricsConfig: async () => ({ mail: "@example.com", enabled: true, diff --git a/packages/admin-ui/src/api/index.ts b/packages/admin-ui/src/api/index.ts index 6d56b060b..835f5a9c7 100644 --- a/packages/admin-ui/src/api/index.ts +++ b/packages/admin-ui/src/api/index.ts @@ -100,7 +100,7 @@ async function callRoute(method: string, params: any[]): Promise { */ export const api: Routes = mapValues( routesData, - (data, route) => (...args: any[]) => callRoute(route, args) + (_data, route) => (...args: any[]) => callRoute(route, args) ); /** @@ -111,7 +111,7 @@ export const useApi: { [K in keyof Routes]: ( ...args: Parameters ) => responseInterface, Error>; -} = mapValues(routesData, (data, route) => { +} = mapValues(routesData, (_data, route) => { return function(...args: any[]) { const argsKey = args.length > 0 ? JSON.stringify(args) : ""; const fetcher = (...args: any[]) => callRoute(route, args); @@ -166,7 +166,7 @@ export const useSubscription: { [K in keyof Subscriptions]: ( callback: (...args: Parameters) => void ) => void; -} = mapValues(subscriptionsData, (data, route) => { +} = mapValues(subscriptionsData, (_data, route) => { return function(callback: (...args: any) => void) { useSubscribe(route as keyof Subscriptions, callback); }; diff --git a/packages/admin-ui/src/api/mock/auth.ts b/packages/admin-ui/src/api/mock/auth.ts index 97905a649..2c0f7d0d3 100644 --- a/packages/admin-ui/src/api/mock/auth.ts +++ b/packages/admin-ui/src/api/mock/auth.ts @@ -5,7 +5,7 @@ export const apiAuth: IApiAuth = { return { status: "logged-in", username: "admin" }; }, - async login(data) { + async login() { return { ok: true }; }, @@ -13,15 +13,15 @@ export const apiAuth: IApiAuth = { window.location.reload(); }, - async register(data) { + async register() { return { recoveryToken: "TEST_TOKEN" }; }, - async changePass(data) { + async changePass() { return { ok: true }; }, - async recoverPass(data) { + async recoverPass() { return { ok: true }; } }; diff --git a/packages/admin-ui/src/api/mock/rpc.ts b/packages/admin-ui/src/api/mock/rpc.ts index bd60580d6..3fbe5f9b5 100644 --- a/packages/admin-ui/src/api/mock/rpc.ts +++ b/packages/admin-ui/src/api/mock/rpc.ts @@ -14,7 +14,7 @@ export const apiRpc: IApiRpc = { return { result }; }, - start(apiEventBridge, onConnect) { + start(_, onConnect) { onConnect(); } }; diff --git a/packages/admin-ui/src/api/routes/index.ts b/packages/admin-ui/src/api/routes/index.ts index 3dcd100a9..52d9cf9f5 100644 --- a/packages/admin-ui/src/api/routes/index.ts +++ b/packages/admin-ui/src/api/routes/index.ts @@ -44,7 +44,7 @@ export const apiRoutes: IApiRoutes = { }); // Define what happens in case of error - xhr.addEventListener("error", e => reject(Error("Error loading file"))); + xhr.addEventListener("error", _e => reject(Error("Error loading file"))); if (xhr.upload) xhr.upload.addEventListener("progress", onProgress, false); diff --git a/packages/admin-ui/src/components/Loading.tsx b/packages/admin-ui/src/components/Loading.tsx index 36ee7f179..f10e793cb 100644 --- a/packages/admin-ui/src/components/Loading.tsx +++ b/packages/admin-ui/src/components/Loading.tsx @@ -2,13 +2,7 @@ import React, { useState, useEffect } from "react"; import logoAnimated from "img/dappNodeAnimation.gif"; import "./loading.scss"; -export default function Loading({ - size = 200, - steps -}: { - size?: number; - steps: string[]; -}) { +export default function Loading({ steps }: { steps: string[] }) { const [index, setIndex] = useState(0); useEffect(() => { const interval = setInterval(() => setIndex(i => i + 1), 3000); diff --git a/packages/admin-ui/src/components/welcome/features/EnableEthicalMetrics.tsx b/packages/admin-ui/src/components/welcome/features/EnableEthicalMetrics.tsx index a4df701d0..00fa64b99 100644 --- a/packages/admin-ui/src/components/welcome/features/EnableEthicalMetrics.tsx +++ b/packages/admin-ui/src/components/welcome/features/EnableEthicalMetrics.tsx @@ -77,12 +77,12 @@ export default function EnableEthicalMetrics({ // clear the success message after 5 seconds useEffect(() => { - if (validationMessage === "Ethical metrics enabled successfully.") { - const timer = setTimeout(() => { - setValidationMessage(""); - }, 5000); - return () => clearTimeout(timer); - } + if (validationMessage !== "Ethical metrics enabled successfully.") return; + + const timer = setTimeout(() => { + setValidationMessage(""); + }, 5000); + return () => clearTimeout(timer); }, [validationMessage]); function toggleEthicalSwitch() { diff --git a/packages/admin-ui/src/index.tsx b/packages/admin-ui/src/index.tsx index 17a541b49..f58f120ed 100755 --- a/packages/admin-ui/src/index.tsx +++ b/packages/admin-ui/src/index.tsx @@ -1,5 +1,4 @@ import React from "react"; -import ReactDOM from "react-dom"; import { createRoot } from "react-dom/client"; import { Provider } from "react-redux"; import { BrowserRouter as Router } from "react-router-dom"; diff --git a/packages/admin-ui/src/pages/installer/components/dappnodeDappstore/InstallerDnp.tsx b/packages/admin-ui/src/pages/installer/components/dappnodeDappstore/InstallerDnp.tsx index 943b6efb3..e18f29523 100644 --- a/packages/admin-ui/src/pages/installer/components/dappnodeDappstore/InstallerDnp.tsx +++ b/packages/admin-ui/src/pages/installer/components/dappnodeDappstore/InstallerDnp.tsx @@ -28,7 +28,7 @@ import { getEthClientWarning } from "services/dappnodeStatus/selectors"; import { confirmPromise } from "components/ConfirmDialog"; import { stakehouseLsdUrl } from "params"; -export const InstallerDnp: React.FC = routeProps => { +export const InstallerDnp: React.FC = () => { const navigate = useNavigate(); const directory = useSelector(getDnpDirectory); @@ -49,7 +49,7 @@ export const InstallerDnp: React.FC = routeProps => { // Limit the number of requests [TESTED] const fetchQueryThrottled = useMemo( () => - throttle((query: string) => { + throttle((_query: string) => { // #### TODO: provide feedback to the user if the query is found }, 500), [] diff --git a/packages/admin-ui/src/pages/installer/components/publicDappstore/InstallerPublic.tsx b/packages/admin-ui/src/pages/installer/components/publicDappstore/InstallerPublic.tsx index 8206c0b6a..d9836e4b0 100644 --- a/packages/admin-ui/src/pages/installer/components/publicDappstore/InstallerPublic.tsx +++ b/packages/admin-ui/src/pages/installer/components/publicDappstore/InstallerPublic.tsx @@ -27,7 +27,7 @@ import { activateFallbackPath } from "pages/system/data"; import { getEthClientWarning } from "services/dappnodeStatus/selectors"; import { fetchDnpRegistry } from "services/dnpRegistry/actions"; -export const InstallerPublic: React.FC = routeProps => { +export const InstallerPublic: React.FC = () => { const navigate = useNavigate(); const registry = useSelector(getDnpRegistry); @@ -42,13 +42,13 @@ export const InstallerPublic: React.FC = routeProps => { const [showErrorDnps, setShowErrorDnps] = useState(false); useEffect(() => { - dispatch(fetchDnpRegistry({})); + dispatch(fetchDnpRegistry()); }, [dispatch]); // Limit the number of requests [TESTED] const fetchQueryThrottled = useMemo( () => - throttle((query: string) => { + throttle((_query: string) => { // #### TODO: provide feedback to the user if the query is found }, 500), [] diff --git a/packages/admin-ui/src/pages/repository/components/Eth.tsx b/packages/admin-ui/src/pages/repository/components/Eth.tsx index be5386638..c5a26d973 100644 --- a/packages/admin-ui/src/pages/repository/components/Eth.tsx +++ b/packages/admin-ui/src/pages/repository/components/Eth.tsx @@ -69,24 +69,28 @@ export default function Eth() { * "Alert!" your target is OFF, go to remote or install it again */ function renderEthMultiClientWarning() { - if (ethClientStatus && !ethClientStatus.ok) - switch (ethClientStatus.code) { - case "NOT_RUNNING": - return ( - - Selected client is not running. Please, restart the client or - select remote - - ); - case "NOT_INSTALLED": - case "UNINSTALLED": - return ( - - Selected client is not installed. Please, re-install the client or - select remote - - ); - } + if (!ethClientStatus) return null; + if (ethClientStatus.ok) return null; + + switch (ethClientStatus.code) { + case "NOT_RUNNING": + return ( + + Selected client is not running. Please, restart the client or select + remote + + ); + case "NOT_INSTALLED": + case "UNINSTALLED": + return ( + + Selected client is not installed. Please, re-install the client or + select remote + + ); + default: + return null; + } } return ( diff --git a/packages/admin-ui/src/pages/system/actions.ts b/packages/admin-ui/src/pages/system/actions.ts index 65301c616..411e4c460 100644 --- a/packages/admin-ui/src/pages/system/actions.ts +++ b/packages/admin-ui/src/pages/system/actions.ts @@ -164,7 +164,7 @@ export const passwordChange = ( dispatch(fetchPasswordIsSecure()); }; -export const volumeRemove = (name: string): AppThunk => async dispatch => { +export const volumeRemove = (name: string): AppThunk => async () => { // Display a dialog to confirm the password change await new Promise(resolve => confirm({ diff --git a/packages/admin-ui/src/services/dnpRegistry/actions.ts b/packages/admin-ui/src/services/dnpRegistry/actions.ts index 6a6d8f186..c8e520917 100644 --- a/packages/admin-ui/src/services/dnpRegistry/actions.ts +++ b/packages/admin-ui/src/services/dnpRegistry/actions.ts @@ -17,11 +17,7 @@ export const updateStatus = createAction( // Redux-thunk actions -export const fetchDnpRegistry = ({ - addressOrEnsName -}: { - addressOrEnsName?: string; -}): AppThunk => async dispatch => { +export const fetchDnpRegistry = (): AppThunk => async dispatch => { try { dispatch(updateStatus({ loading: true })); const registry = await api.fetchRegistry(); diff --git a/packages/daemons/src/natRenewal/getLocalIp.ts b/packages/daemons/src/natRenewal/getLocalIp.ts index e73ef0784..573c9ec33 100644 --- a/packages/daemons/src/natRenewal/getLocalIp.ts +++ b/packages/daemons/src/natRenewal/getLocalIp.ts @@ -17,5 +17,6 @@ export async function getLocalIp(options?: { return isIp(internalIp) ? internalIp : undefined; } catch (e) { if (!silent) logs.error(`Error getting internal IP: ${e.message}`); + return undefined; } } diff --git a/packages/dappmanager/src/api/auth/sessionAuth.ts b/packages/dappmanager/src/api/auth/sessionAuth.ts index 6524e07b8..494651419 100644 --- a/packages/dappmanager/src/api/auth/sessionAuth.ts +++ b/packages/dappmanager/src/api/auth/sessionAuth.ts @@ -194,7 +194,7 @@ export class AuthPasswordSession { /** * Middleware to protect routes only for admin sessions */ - onlyAdmin = wrapHandler((req, res, next) => { + onlyAdmin = wrapHandler((req, _, next) => { this.assertOnlyAdmin(req); next(); }); diff --git a/packages/dappmanager/src/api/middlewares/viewsCounter/index.ts b/packages/dappmanager/src/api/middlewares/viewsCounter/index.ts index bc7c13739..5fd5d2580 100644 --- a/packages/dappmanager/src/api/middlewares/viewsCounter/index.ts +++ b/packages/dappmanager/src/api/middlewares/viewsCounter/index.ts @@ -4,7 +4,7 @@ import * as db from "@dappnode/db"; let counter = 0; export function getViewsCounterMiddleware(): express.RequestHandler { - return (req, res, next): void => { + return (req, _, next): void => { try { // Only count views for the main page and login status // Other requests are not from the UI but for other API calls diff --git a/packages/dappmanager/src/api/routes/downloadUserActionLogs.ts b/packages/dappmanager/src/api/routes/downloadUserActionLogs.ts index 039c6cb69..8330760e4 100644 --- a/packages/dappmanager/src/api/routes/downloadUserActionLogs.ts +++ b/packages/dappmanager/src/api/routes/downloadUserActionLogs.ts @@ -4,7 +4,7 @@ import { wrapHandlerHtml } from "../utils.js"; /** * Endpoint to download user action logs. */ -export const downloadUserActionLogs = wrapHandlerHtml(async (req, res) => { +export const downloadUserActionLogs = wrapHandlerHtml(async (_, res) => { const logs = logUserAction.get(); const filename = `dappnode-user-action-logs_${new Date().toISOString()}.json`; diff --git a/packages/dappmanager/src/api/routes/fileDownload.ts b/packages/dappmanager/src/api/routes/fileDownload.ts index c2e0bf970..748693b79 100644 --- a/packages/dappmanager/src/api/routes/fileDownload.ts +++ b/packages/dappmanager/src/api/routes/fileDownload.ts @@ -28,7 +28,7 @@ export const fileDownload = wrapHandlerHtml(async (req, res) => { throw e; } - const filetype = await dockerGetPathType(containerNameOrId, filepath); + const filetype = await dockerGetPathType(filepath); const isSingleFile = filetype === "file"; // Download single file as same mimetype, directory as .tar diff --git a/packages/dappmanager/src/api/routes/metrics.ts b/packages/dappmanager/src/api/routes/metrics.ts index 3ce2f362a..44ae97faf 100644 --- a/packages/dappmanager/src/api/routes/metrics.ts +++ b/packages/dappmanager/src/api/routes/metrics.ts @@ -19,7 +19,7 @@ import { mevBoost, execution, consensus } from "../../index.js"; * - Dappnode graffiti or other * - User sessions */ -export const metrics = wrapHandler(async (req, res) => { +export const metrics = wrapHandler(async (_, res) => { // Return all metrics the Prometheus exposition format res.setHeader("Content-Type", register.contentType); res.end(await register.metrics()); diff --git a/packages/dappmanager/src/api/routes/packageManifest.ts b/packages/dappmanager/src/api/routes/packageManifest.ts index 76e6e72dd..d8b38b9d5 100644 --- a/packages/dappmanager/src/api/routes/packageManifest.ts +++ b/packages/dappmanager/src/api/routes/packageManifest.ts @@ -58,4 +58,5 @@ export const packageManifest = wrapHandler(async (req, res) => { ]); res.status(200).send(filteredManifest); + return; }); diff --git a/packages/dappmanager/src/api/routes/upload.ts b/packages/dappmanager/src/api/routes/upload.ts index 33269a348..9984eeb19 100644 --- a/packages/dappmanager/src/api/routes/upload.ts +++ b/packages/dappmanager/src/api/routes/upload.ts @@ -38,5 +38,7 @@ export const upload = wrapHandler(async (req, res) => { if (errFs) logs.error(`Error deleting file: ${errFs.message}`); }); }, 15 * 60 * 1000); + return; }); + return; }); diff --git a/packages/dappmanager/src/api/startHttpApi.ts b/packages/dappmanager/src/api/startHttpApi.ts index c43ce9fed..a0bc097fb 100644 --- a/packages/dappmanager/src/api/startHttpApi.ts +++ b/packages/dappmanager/src/api/startHttpApi.ts @@ -195,7 +195,7 @@ export function startHttpApi({ // Serve UI. React-router, index.html at all routes // prettier-ignore - app.get("*", (req, res) => res.sendFile(path.resolve(params.UI_FILES_PATH, "index.html"))); + app.get("*", (_, res) => res.sendFile(path.resolve(params.UI_FILES_PATH, "index.html"))); server.listen(params.HTTP_API_PORT, () => logs.info(`HTTP API ${params.HTTP_API_PORT}`) diff --git a/packages/dappmanager/src/api/startTestApi.ts b/packages/dappmanager/src/api/startTestApi.ts index 11efc50df..23b40fec4 100644 --- a/packages/dappmanager/src/api/startTestApi.ts +++ b/packages/dappmanager/src/api/startTestApi.ts @@ -68,11 +68,11 @@ export function startTestApi(): http.Server { } // Health check - app.get("/ping", (req, res) => { + app.get("/ping", (_, res) => { res.send("OK"); }); - app.use((req, res) => { + app.use((_, res) => { res.status(404).send("Not found"); }); diff --git a/packages/dappmanager/src/api/vpnApiClient.ts b/packages/dappmanager/src/api/vpnApiClient.ts index f7ab97823..b6b8d621f 100644 --- a/packages/dappmanager/src/api/vpnApiClient.ts +++ b/packages/dappmanager/src/api/vpnApiClient.ts @@ -33,7 +33,7 @@ export function getVpnApiClient(params: VpnApiClientParams): VpnApiClient { // eslint-disable-next-line @typescript-eslint/no-explicit-any return mapValues( vpnApiRoutesData, - (data, route) => + (_, route) => // eslint-disable-next-line @typescript-eslint/no-explicit-any (...args: Args): any => vpnRpcCall(params, route, ...args) diff --git a/packages/dappmanager/src/calls/ethicalMetrics.ts b/packages/dappmanager/src/calls/ethicalMetrics.ts index d4790661b..28847b148 100644 --- a/packages/dappmanager/src/calls/ethicalMetrics.ts +++ b/packages/dappmanager/src/calls/ethicalMetrics.ts @@ -1,7 +1,6 @@ import { EthicalMetricsConfig } from "@dappnode/types"; import { eventBus } from "@dappnode/eventbus"; import { listPackageNoThrow } from "@dappnode/dockerapi"; -import { packageRestart } from "./packageRestart.js"; import * as db from "@dappnode/db"; import { packageInstall } from "./packageInstall.js"; import { logs } from "@dappnode/logger"; diff --git a/packages/dappmanager/src/index.ts b/packages/dappmanager/src/index.ts index bcd6b3975..62e9de2d3 100644 --- a/packages/dappmanager/src/index.ts +++ b/packages/dappmanager/src/index.ts @@ -43,7 +43,7 @@ initializeDb() .then(() => logs.info("Initialized Database")) .catch(e => logs.error("Error inititializing Database", e)); -const ethUrl = await getEthUrl().catch(e => { +await getEthUrl().catch(e => { logs.error( `Error getting ethUrl, using default ${params.ETH_MAINNET_RPC_URL_REMOTE}`, e @@ -59,9 +59,12 @@ try { } // Required db to be initialized -export const dappnodeInstaller = new DappnodeInstaller(ipfsUrl, await getEthersProvider()); +export const dappnodeInstaller = new DappnodeInstaller( + ipfsUrl, + await getEthersProvider() +); -export const publicRegistry = new DappNodeRegistry(await getEthersProvider(), "public"); +export const publicRegistry = new DappNodeRegistry("public"); // TODO: find a way to move the velow constants to the api itself const vpnApiClient = getVpnApiClient(params); diff --git a/packages/db/src/notification.ts b/packages/db/src/notification.ts index 50ec16585..cff35f313 100644 --- a/packages/db/src/notification.ts +++ b/packages/db/src/notification.ts @@ -29,6 +29,6 @@ export const notificationLastEmitVersion = dbCache.indexedByKey( rootKey: NOTIFICATION_LAST_EMITTED_VERSION, getKey: (dnpName) => stripDots(dnpName), validate: (dnpName, lastEmittedVersion) => - typeof lastEmittedVersion === "string", + Boolean(dnpName) && typeof lastEmittedVersion === "string", } ); diff --git a/packages/dockerApi/src/fileTransfer.ts b/packages/dockerApi/src/fileTransfer.ts index d4f53e2aa..c01cad8eb 100644 --- a/packages/dockerApi/src/fileTransfer.ts +++ b/packages/dockerApi/src/fileTransfer.ts @@ -37,7 +37,6 @@ export async function dockerGetFileOrDirBasedOnExtension( type FileType = "file" | "directory"; export async function dockerGetPathType( - containerNameOrId: string, filePathAbsolute: string ): Promise { if (path.parse(filePathAbsolute).ext) { diff --git a/packages/dockerCompose/src/labelsDb.ts b/packages/dockerCompose/src/labelsDb.ts index 32ff3023c..c4308e444 100644 --- a/packages/dockerCompose/src/labelsDb.ts +++ b/packages/dockerCompose/src/labelsDb.ts @@ -22,12 +22,13 @@ const parseNumber = (value: string | undefined): number | undefined => const parseBool = (value: string | undefined): boolean | undefined => typeof value === "string" ? (value === "true" ? true : false) : undefined; const parseJsonSafe = (value: string | undefined): T | undefined => { - if (value) - try { - return JSON.parse(value); - } catch { - return; - } + if (!value) return undefined; + + try { + return JSON.parse(value); + } catch (e) { + return undefined; + } }; const writeString = (data: string | undefined): string | undefined => data; diff --git a/packages/dockerCompose/src/userSettings.ts b/packages/dockerCompose/src/userSettings.ts index 759274267..c8d989195 100644 --- a/packages/dockerCompose/src/userSettings.ts +++ b/packages/dockerCompose/src/userSettings.ts @@ -1,14 +1,5 @@ import path from "path"; -import { - mapValues, - pick, - omitBy, - isObject, - merge, - mergeWith, - isArray, - union, -} from "lodash-es"; +import { mapValues, pick, omitBy, isObject, mergeWith, union } from "lodash-es"; import { parsePortMappings, stringifyPortMappings, diff --git a/packages/installer/src/ethClient/clientStatus.ts b/packages/installer/src/ethClient/clientStatus.ts index 34cdd8ffc..94fbe47b6 100644 --- a/packages/installer/src/ethClient/clientStatus.ts +++ b/packages/installer/src/ethClient/clientStatus.ts @@ -1,4 +1,3 @@ -import { ethers } from "ethers"; import * as db from "@dappnode/db"; import { EthClientStatus } from "@dappnode/types"; import { listPackageNoThrow } from "@dappnode/dockerapi"; @@ -178,7 +177,9 @@ async function isSyncedWithRemoteExecution(localUrl: string): Promise { .send("eth_blockNumber", []) .then(parseEthersBlock); - const latestRemoteBlock = await (await getEthersProvider(params.ETH_MAINNET_RPC_URL_REMOTE)) + const latestRemoteBlock = await ( + await getEthersProvider(params.ETH_MAINNET_RPC_URL_REMOTE) + ) .send("eth_blockNumber", []) .then(parseEthersBlock); @@ -248,6 +249,7 @@ async function isSyncedWithConsensus( ); // TODO: do better type checking const consBlockHeadersResponseParsed = + // eslint-disable-next-line @typescript-eslint/no-explicit-any (await execBlockHeadersResponse.json()) as any; const consBlockNumber = consBlockHeadersResponseParsed.data.message.body.execution_payload diff --git a/packages/installer/src/ethClient/localFallbackVersions.ts b/packages/installer/src/ethClient/localFallbackVersions.ts index f3de5a2fe..f001833a2 100644 --- a/packages/installer/src/ethClient/localFallbackVersions.ts +++ b/packages/installer/src/ethClient/localFallbackVersions.ts @@ -32,6 +32,7 @@ export function loadContentHashes(filepath: string): ContentHashes | undefined { return parseContentHashFile(packagesContentHashData); } catch (e) { if (!isNotFoundError(e)) throw e; + return undefined; } } diff --git a/packages/stakers/src/consensus.ts b/packages/stakers/src/consensus.ts index 4ddf933dc..52cc77f13 100644 --- a/packages/stakers/src/consensus.ts +++ b/packages/stakers/src/consensus.ts @@ -1,5 +1,4 @@ import { - ComposeServiceNetworksObj, ConsensusClientGnosis, ConsensusClientHolesky, ConsensusClientLukso, @@ -8,7 +7,6 @@ import { Network, StakerItem, UserSettings, - UserSettingsAllDnps, } from "@dappnode/types"; import { StakerComponent } from "./stakerComponent.js"; import { DappnodeInstaller } from "@dappnode/installer"; @@ -123,9 +121,7 @@ export class Consensus extends StakerComponent { userSettings: newConsensusDnpName ? this.getUserSettings( newConsensusDnpName, - !Boolean( - await listPackageNoThrow({ dnpName: newConsensusDnpName }) - ), + !(await listPackageNoThrow({ dnpName: newConsensusDnpName })), network ) : {}, diff --git a/packages/stakers/src/signer.ts b/packages/stakers/src/signer.ts index 445ff4b6e..e4761cb9b 100644 --- a/packages/stakers/src/signer.ts +++ b/packages/stakers/src/signer.ts @@ -1,5 +1,4 @@ import { - ComposeServiceNetworksObj, Network, SignerGnosis, SignerHolesky, diff --git a/packages/toolkit/src/directory/params.ts b/packages/toolkit/src/directory/params.ts index 776a72e5a..9ff0bb0c5 100644 --- a/packages/toolkit/src/directory/params.ts +++ b/packages/toolkit/src/directory/params.ts @@ -1,5 +1,3 @@ -import { Abi } from "../types.js"; - export const fromBlock = 5254499; export const directoryContractName = "directory"; export const directoryAddress = "0xf19F629642C6697Af77d8316BeF8DE0de3A27a70"; diff --git a/packages/toolkit/src/registry/registry.ts b/packages/toolkit/src/registry/registry.ts index a9570b24b..508140ad2 100644 --- a/packages/toolkit/src/registry/registry.ts +++ b/packages/toolkit/src/registry/registry.ts @@ -1,12 +1,8 @@ -import { ethers } from "ethers"; import { DNPRegistryEntry, PublicRegistryEntry, Registry } from "./types.js"; import { request, gql } from "graphql-request"; import { - registryDnpAddress, dnpRegistryGraphEndpoint, - registryPublicAddress, publicRegistryGraphEndpoint, - registryAbi, } from "./params.js"; // TODO: Consider adding scanning functions for events @@ -15,31 +11,19 @@ import { * DappNodeRegistry is a class to interact with the DAppNode Registry Contract. */ export class DappNodeRegistry { - private contractAddress: string; private registry: Registry; private graphEndpoint: string; private nameSuffix: string; - private registryContract: ethers.Contract; /** * Class constructor * @param ethUrl - The URL of the Ethereum node to connect to. * @param registry - The type of the registry (DNP or Public). */ - constructor(ethersProvider: ethers.AbstractProvider, registry: Registry) { + constructor(registry: Registry) { this.registry = registry; - if (registry === "dnp") { - this.contractAddress = registryDnpAddress; - this.graphEndpoint = dnpRegistryGraphEndpoint; - } else { - this.contractAddress = registryPublicAddress; - this.graphEndpoint = publicRegistryGraphEndpoint; - } - this.registryContract = new ethers.Contract( - this.contractAddress, - registryAbi, - ethersProvider - ); + if (registry === "dnp") this.graphEndpoint = dnpRegistryGraphEndpoint; + else this.graphEndpoint = publicRegistryGraphEndpoint; this.nameSuffix = this.registry === "dnp" ? ".dnp.dappnode.eth" : ".public.dappnode.eth"; diff --git a/packages/utils/src/plainTextFileDb.ts b/packages/utils/src/plainTextFileDb.ts index 0b3d1eda1..3f7a2fc73 100644 --- a/packages/utils/src/plainTextFileDb.ts +++ b/packages/utils/src/plainTextFileDb.ts @@ -13,6 +13,7 @@ export class PlainTextFileDb { return fs.readFileSync(this.filepath, "utf8").trim(); } catch (e) { if (e.code !== "ENOENT") throw e; + return undefined; } } diff --git a/packages/utils/src/shellSafe.ts b/packages/utils/src/shellSafe.ts index 95024f6e5..a83ade5da 100644 --- a/packages/utils/src/shellSafe.ts +++ b/packages/utils/src/shellSafe.ts @@ -1,11 +1,13 @@ import { shell } from "./shell.js"; function ignoreErrors(fn: (arg: A) => R) { - return async function(arg: A): Promise { + return async function (arg: A): Promise { try { return await fn(arg); } catch (e) { - // Ignore + // Print and ignore + console.error(e); + return undefined; } }; } diff --git a/tsconfig.base.json b/tsconfig.base.json deleted file mode 100644 index 4b57b2a7c..000000000 --- a/tsconfig.base.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", // Use the latest ECMAScript target - "module": "ESNext", // Use the latest ECMAScript module - "moduleResolution": "node", // Use Node.js module resolution - "strict": true, // Enable all strict type-checking options - "esModuleInterop": true, // Enable interoperability between CommonJS and ES Modules - "forceConsistentCasingInFileNames": true, // Disallow inconsistently-cased references to the same file - "skipLibCheck": true, // Skip type checking of all declaration files (*.d.ts) - "resolveJsonModule": true, // Include modules imported with `.json` extension - "noImplicitAny": true, // Raise error on expressions and declarations with an implied 'any' type - "noUnusedLocals": true, // Report errors on unused locals - "noUnusedParameters": true, // Report errors on unused parameters - "noImplicitReturns": true, // Report errors on fallthrough cases in switch statements - "noFallthroughCasesInSwitch": true, // Report errors on fallthrough cases in switch statements - "allowSyntheticDefaultImports": true, // Allow default imports from modules with no default export - "incremental": true, // Enable incremental compilation - "isolatedModules": true, // Transpile each file as a separate module (for `ts-loader` and `babel`) - "strictNullChecks": true, // Enable strict null checks - "strictFunctionTypes": true, // Enable strict checking of function types - "strictBindCallApply": true, // Enable strict checking of `bind`, `call`, and `apply` methods - "strictPropertyInitialization": true, // Ensure non-undefined class properties are initialized in the constructor - "lib": ["ESNext"], // Include the latest ECMAScript library - "types": ["node"], // Include type definitions for Node.js - "declaration": true, - "declarationMap": true - } -} diff --git a/tsconfig.json b/tsconfig.json index ddff7d740..ba2711da3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,14 @@ "allowUnreachableCode": false, "strict": true, "useUnknownInCatchVariables": false, + "forceConsistentCasingInFileNames": true, // Disallow inconsistently-cased references to the same file + "noUnusedLocals": true, // Report errors on unused locals + "noUnusedParameters": true, // Report errors on unused parameters + "noImplicitReturns": true, // Report errors on fallthrough cases in switch statements + "noFallthroughCasesInSwitch": true, // Report errors on fallthrough cases in switch statements + "strictNullChecks": true, // Enable strict null checks + "strictFunctionTypes": true, // Enable strict checking of function types + "strictPropertyInitialization": true, // Ensure non-undefined class properties are initialized in the constructor /* Modules */ "module": "NodeNext", @@ -23,6 +31,8 @@ /* Language and Environment */ "target": "ESNext" /* TODO: Review if we can use a defined target like ES2020 */, + "lib": ["ESNext"], // Include the latest ECMAScript library + "types": ["node"], // Include type definitions for Node.js /* Completeness */ "skipLibCheck": true /* TODO: Should be removed when code is fixed */, @@ -30,9 +40,7 @@ // We want to speed up the CI run for all tests, which require us to use the // `transpileOnly` mode for the `ts-node`. This change requires to treat types for each module // independently, which is done by setting the `isolatedModules` flag to `true`. - "isolatedModules": true - }, - "ts-node": { - "transpileOnly": true + "isolatedModules": true, + "incremental": true // Enable incremental compilation } } diff --git a/yarn.lock b/yarn.lock index 995c6f58d..24222545f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2436,7 +2436,7 @@ __metadata: nodemon: "npm:^3.0.2" rimraf: "npm:^3.0.2" ts-node: "npm:^10.9.2" - typescript: "npm:^5.3.3" + typescript: "npm:^5.5.4" languageName: unknown linkType: soft @@ -18771,13 +18771,13 @@ __metadata: languageName: node linkType: hard -"typescript@npm:^5.3.3": - version: 5.3.3 - resolution: "typescript@npm:5.3.3" +"typescript@npm:^5.5.4": + version: 5.5.4 + resolution: "typescript@npm:5.5.4" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/e33cef99d82573624fc0f854a2980322714986bc35b9cb4d1ce736ed182aeab78e2cb32b385efa493b2a976ef52c53e20d6c6918312353a91850e2b76f1ea44f + checksum: 10c0/422be60f89e661eab29ac488c974b6cc0a660fb2228003b297c3d10c32c90f3bcffc1009b43876a082515a3c376b1eefcce823d6e78982e6878408b9a923199c languageName: node linkType: hard @@ -18791,13 +18791,13 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@npm%3A^5.3.3#optional!builtin": - version: 5.3.3 - resolution: "typescript@patch:typescript@npm%3A5.3.3#optional!builtin::version=5.3.3&hash=e012d7" +"typescript@patch:typescript@npm%3A^5.5.4#optional!builtin": + version: 5.5.4 + resolution: "typescript@patch:typescript@npm%3A5.5.4#optional!builtin::version=5.5.4&hash=379a07" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/1d0a5f4ce496c42caa9a30e659c467c5686eae15d54b027ee7866744952547f1be1262f2d40de911618c242b510029d51d43ff605dba8fb740ec85ca2d3f9500 + checksum: 10c0/73409d7b9196a5a1217b3aaad929bf76294d3ce7d6e9766dd880ece296ee91cf7d7db6b16c6c6c630ee5096eccde726c0ef17c7dfa52b01a243e57ae1f09ef07 languageName: node linkType: hard