Skip to content

Commit

Permalink
update utils import
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomendezroyo committed Sep 19, 2023
1 parent 7f9a8f7 commit 32aeb84
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 51 deletions.
2 changes: 2 additions & 0 deletions packages/dappmanager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
},
"license": "GPL-3.0",
"dependencies": {
"@dappnode/params": "^0.1.0",
"@dappnode/utils": "^0.1.0",
"@dappnode/common": "^0.1.0",
"@dappnode/schemas": "^0.1.7",
"@dappnode/toolkit": "^0.1.19",
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/api/auth/adminPasswordDb.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import bcrypt from "bcryptjs";
import { JsonFileDb } from "../../utils/fileDb.js";
import { JsonFileDb } from "@dappnode/utils";
import { getRandomAlphanumericToken } from "../../utils/token.js";

export enum AdminPasswordDbError {
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/api/auth/sessionAuth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Request } from "express";
import { PlainTextFileDb } from "../../utils/fileDb.js";
import { PlainTextFileDb } from "@dappnode/utils";
import { getRandomAlphanumericToken } from "../../utils/token.js";
import { wrapHandler } from "../utils.js";
import { SessionData, SessionsManager } from "../sessions/index.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/api/sessions/secret.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import crypto from "crypto";
import { PlainTextFileDb } from "../../utils/fileDb.js";
import { PlainTextFileDb } from "@dappnode/utils";

export class SessionsSecretDb {
private filedb: PlainTextFileDb;
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/db/dbFactory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as validate from "../utils/validate.js";
import { logs } from "../logs.js";
import { JsonFileDb } from "../utils/fileDb.js";
import { JsonFileDb } from "@dappnode/utils";
import params from "../params.js";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/logUserAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { eventBus } from "./eventBus.js";
import params from "./params.js";
import { UserActionLog } from "@dappnode/common";
import { logSafeObjects } from "./utils/logs.js";
import { JsonFileDb } from "./utils/fileDb.js";
import { JsonFileDb } from "@dappnode/utils";
import { logs } from "./logs.js";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { mapValues, toPairs, sortBy, fromPairs, pick } from "lodash-es";
import params, { getContainerName } from "../../params.js";
import { getContainerName } from "@dappnode/utils";
import { params } from "@dappnode/params";
import { getIsCore } from "../manifest/getIsCore.js";
import { cleanCompose } from "./clean.js";
import { parseEnvironment } from "./environment.js";
Expand Down
8 changes: 6 additions & 2 deletions packages/dappmanager/src/modules/compose/verify.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { maxPortNumber } from "../../params.js";
import { Compose } from "@dappnode/types";
import { applyRecursivelyToStringValues } from "../../utils/objects.js";
import { applyRecursivelyToStringValues } from "@dappnode/utils";
import { parsePortMappings } from "./ports.js";

// Docker params
// Max port number (included) Otherwise it fails with
// Cannot create container for service ipfs.dnp.dappnode.eth: invalid port specification: "65536"
const maxPortNumber = 65535;

export function verifyCompose(compose: Compose): void {
for (const serviceName in compose.services) {
const service = compose.services[serviceName];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,25 @@ import { listPackageNoThrow } from "../docker/list/index.js";
import { logs } from "../../logs.js";
import { EthClientTarget } from "@dappnode/common";
import { packageGet } from "../../calls/index.js";
import { ethClientData } from "../../params.js";
import { EthClientTargetPackage, UserSettings } from "@dappnode/common";

/**
* Link between an ethClientTarget keyword and its pacakge information
* Declared above to use stronger typings
*/
const ethClientData: {
[P in EthClientTargetPackage]: {
dnpName: string; // "geth.dnp.dappnode.eth"
url?: string; // Only provide a URL if it's not "http://geth.dappnode:8545"
version?: string;
userSettings?: UserSettings;
};
} = {
geth: { dnpName: "geth.dnp.dappnode.eth" },
nethermind: { dnpName: "nethermind.public.dappnode.eth" },
besu: { dnpName: "besu.public.dappnode.eth" },
erigon: { dnpName: "erigon.dnp.dappnode.eth" }
};

/**
* Switches ethClientTarget in the following preference order: geth > nethermind > remote
Expand Down
42 changes: 0 additions & 42 deletions packages/dappmanager/src/params.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import path from "path";
import { EthClientTargetPackage, UserSettings } from "@dappnode/common";
import { getContainerDomain } from "@dappnode/types";

const devMode = process.env.LOG_LEVEL === "DEV_MODE";

Expand Down Expand Up @@ -342,43 +340,3 @@ if (devMode) {
}

export default params;

// Docker params
// Max port number (included) Otherwise it fails with
// Cannot create container for service ipfs.dnp.dappnode.eth: invalid port specification: "65536"
export const maxPortNumber = 65535;

/**
* Link between an ethClientTarget keyword and its pacakge information
* Declared above to use stronger typings
*/
export const ethClientData: {
[P in EthClientTargetPackage]: {
dnpName: string; // "geth.dnp.dappnode.eth"
url?: string; // Only provide a URL if it's not "http://geth.dappnode:8545"
version?: string;
userSettings?: UserSettings;
};
} = {
geth: { dnpName: "geth.dnp.dappnode.eth" },
nethermind: { dnpName: "nethermind.public.dappnode.eth" },
besu: { dnpName: "besu.public.dappnode.eth" },
erigon: { dnpName: "erigon.dnp.dappnode.eth" }
};

// Naming

export const getContainerName = ({
dnpName,
serviceName,
isCore
}: {
dnpName: string;
serviceName: string;
isCore: boolean;
}): string =>
// Note: _PREFIX variables already end with the character "-"
[
isCore ? params.CONTAINER_CORE_NAME_PREFIX : params.CONTAINER_NAME_PREFIX,
getContainerDomain({ dnpName, serviceName })
].join("");
22 changes: 22 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,11 @@
resolved "https://registry.yarnpkg.com/@dappnode/types/-/types-0.1.25.tgz#b9b08abfbf839e2c03b3407064d10cf52c7a2d6e"
integrity sha512-+5gdP5IAtv7hpesZWmHDFGJlH39ZmAfhm/Yi+oXJ7hSpVPJJCWjsm5uRPtZ5TVXemEhKO2qwn9mhXOs71yDqWw==

"@dappnode/types@^0.1.26":
version "0.1.26"
resolved "https://registry.yarnpkg.com/@dappnode/types/-/types-0.1.26.tgz#c75fc25cb831f2026a5f9f928f51ba6f71451ce1"
integrity sha512-SzKAXzXrdEDy8SEoy2e7aENH/kobzW4HM749823pQ4Dgrht2tH4Rg3nBWYz3w37uzj6hAj+mIcAKMTe6yMEuig==

"@emotion/is-prop-valid@^0.8.1":
version "0.8.8"
resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz#db28b1c4368a259b60a97311d6a952d4fd01ac1a"
Expand Down Expand Up @@ -3534,6 +3539,13 @@
dependencies:
"@types/lodash" "*"

"@types/lodash-es@^4.17.9":
version "4.17.9"
resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.9.tgz#49dbe5112e23c54f2b387d860b7d03028ce170c2"
integrity sha512-ZTcmhiI3NNU7dEvWLZJkzG6ao49zOIjEgIE0RgV7wbPxU0f2xT3VSAHw2gmst8swH6V0YkLRGp4qPlX/6I90MQ==
dependencies:
"@types/lodash" "*"

"@types/lodash@*":
version "4.14.196"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.196.tgz#a7c3d6fc52d8d71328b764e28e080b4169ec7a95"
Expand Down Expand Up @@ -3639,6 +3651,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.17.1.tgz#84c32903bf3a09f7878c391d31ff08f6fe7d8335"
integrity sha512-xlR1jahfizdplZYRU59JlUx9uzF1ARa8jbhM11ccpCJya8kvos5jwdm2ZAgxSCwOl0fq21svP18EVwPBXMQudw==

"@types/node@^20.6.2":
version "20.6.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.6.2.tgz#a065925409f59657022e9063275cd0b9bd7e1b12"
integrity sha512-Y+/1vGBHV/cYk6OI1Na/LHzwnlNCAfU3ZNGrc1LdRe/LAIbdDPTTv/HU3M7yXN448aTVDq3eKRm2cg7iKLb8gw==

"@types/normalize-package-data@^2.4.0":
version "2.4.1"
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"
Expand Down Expand Up @@ -16373,6 +16390,11 @@ typescript@^5.1.6:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==

typescript@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78"
integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==

typescript@~4.8.2:
version "4.8.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6"
Expand Down

0 comments on commit 32aeb84

Please sign in to comment.