Skip to content

Commit f8012fd

Browse files
authored
Merge pull request #314 from dappnode/v0.2.25
v0.2.25 Release
2 parents dbc3be0 + 75d3438 commit f8012fd

File tree

204 files changed

+8256
-5326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

204 files changed

+8256
-5326
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ test_build/
1111
.nyc_output
1212
build_*
1313
uploader
14+
# This project uses yarn
15+
build/src/package-lock.json
1416

1517
# Test artifacts
1618
test_build/

build/Dockerfile

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Layer 1: Build the dependencies
1+
# Layer 0: Common base so it's cached
22
#####################################
3-
FROM node:10.15.3-alpine as build-deps
3+
FROM node:10.15.3-alpine as build-base
44

55
RUN apk add --no-cache git python build-base bind-tools docker bash jq
66

@@ -9,7 +9,19 @@ WORKDIR /usr/src/app
99
# Install app dependencies to use docker's layer cache
1010
COPY build/src/package.json ./
1111
COPY build/src/yarn.lock ./
12-
RUN yarn install --production
12+
RUN yarn install --production --link-duplicates
13+
# --link-duplicates: hardlinks for repeated modules. 193964 => 175592
14+
15+
16+
17+
# Layer 1: Build the dependencies
18+
#####################################
19+
FROM build-base as build-deps
20+
21+
# Apply patch-package
22+
COPY build/src/patches patches
23+
RUN yarn add -D patch-package --production --frozen-lockfile --skip-integrity-check
24+
RUN yarn prepare
1325

1426
# Get this DNP version and git hash. Results in /usr/src/app/.version.json
1527
COPY .git .git
@@ -20,16 +32,9 @@ RUN ./getVersionData.sh
2032

2133
# Layer 2: Build the source .ts files
2234
#####################################
23-
FROM node:10.15.3-alpine as build-src
35+
FROM build-base as build-src
2436

25-
RUN apk add --no-cache git python build-base bind-tools docker bash jq
26-
27-
WORKDIR /usr/src/app
28-
29-
# Add source
30-
COPY build/src/package.json ./
31-
COPY build/src/yarn.lock ./
32-
RUN yarn add -D typescript
37+
RUN yarn install --frozen-lockfile
3338
COPY build/src .
3439
RUN yarn build
3540

build/src/.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Ignore image assets
2+
*.png
3+
4+
# Ignore test assets
5+
*.tar.xz
6+
*.sh

build/src/.prettierrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": false,
7+
"quoteProps": "as-needed",
8+
"jsxSingleQuote": false,
9+
"trailingComma": "none",
10+
"bracketSpacing": true,
11+
"jsxBracketSameLine": false,
12+
"arrowParens": "avoid"
13+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
#
3+
# Script to migrate a docker volume.
4+
# It's original purpose is to migrate ETHCHAIN volumes to multi-client model.
5+
6+
# Exit on error
7+
set -e
8+
9+
FROM_VOLUME_NAME=$1
10+
TO_VOLUME_NAME=$2
11+
12+
DOCKER_ROOT_DIR=$(docker info -f '{{ .DockerRootDir }}')
13+
14+
if [[ -z "${FROM_VOLUME_NAME}" ]]; then
15+
echo "arg 1 FROM_VOLUME_NAME is empty"
16+
exit 1
17+
fi
18+
19+
if [[ -z "${TO_VOLUME_NAME}" ]]; then
20+
echo "arg 2 TO_VOLUME_NAME is empty"
21+
exit 1
22+
fi
23+
24+
if [[ -z "${DOCKER_ROOT_DIR}" ]]; then
25+
echo "DOCKER_ROOT_DIR is empty"
26+
exit 1
27+
fi
28+
29+
FROM_PATH=${DOCKER_ROOT_DIR}/volumes/${FROM_VOLUME_NAME}
30+
TO_PATH=${DOCKER_ROOT_DIR}/volumes/${TO_VOLUME_NAME}
31+
32+
if [[ -d "${TO_PATH}" ]]; then
33+
echo "Error: ${TO_PATH} already exists."
34+
exit 1
35+
fi
36+
37+
mv "${FROM_PATH}" "${TO_PATH}"

build/src/package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@
1717
"test:all": "npm run test && npm run test:int",
1818
"coverage": "./node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls",
1919
"lint": "./node_modules/.bin/eslint . --ext .ts --fix",
20+
"prettier": "prettier --write 'src/**/*.*' 'test/**/*.*'",
2021
"pre-commit": "npm run build && npm run test",
21-
"clean": "rm -rf DNCORE/ dnp_repo/ .temp-transfer/ cache/ dist/"
22+
"clean": "rm -rf DNCORE/ dnp_repo/ .temp-transfer/ cache/ dist/",
23+
"prepare": "node_modules/.bin/patch-package"
2224
},
2325
"author": "dappLion",
2426
"license": "ISC",
2527
"dependencies": {
26-
"@parity/api": "^2.1.22",
2728
"@types/memoizee": "^0.4.3",
2829
"ajv": "^6.10.2",
2930
"async": "^2.6.1",
3031
"autobahn": "^18.3.2",
3132
"bitcoin-core": "^2.0.0",
33+
"cids": "^0.8.0",
3234
"cors": "^2.8.5",
3335
"data-uri-to-buffer": "^2.0.0",
3436
"datauri": "^1.1.0",
@@ -38,17 +40,18 @@
3840
"dotenv": "^8.2.0",
3941
"eth-crypto": "^1.4.0",
4042
"ethers": "^4.0.38",
41-
"ethjs-provider-http": "^0.1.6",
42-
"ethjs-rpc": "^0.2.0",
4343
"express": "^4.17.1",
4444
"express-fileupload": "^1.1.5",
45+
"http-proxy": "^1.18.0",
4546
"ipfs-http-client": "^30.1.1",
4647
"is-ip": "^3.0.0",
4748
"js-yaml": "^3.11.0",
4849
"lodash": "^4.17.15",
4950
"lowdb": "^1.0.0",
5051
"memoizee": "^0.4.14",
5152
"monero-rpc": "^0.5.0",
53+
"multicodec": "^1.0.1",
54+
"multihashes": "^0.4.18",
5255
"node-docker-api": "^1.1.22",
5356
"node-fetch": "^2.6.0",
5457
"pretty-bytes": "^5.3.0",
@@ -66,10 +69,12 @@
6669
"@types/dockerode": "^2.5.20",
6770
"@types/express": "^4.17.0",
6871
"@types/express-fileupload": "^1.1.0",
72+
"@types/http-proxy": "^1.17.4",
6973
"@types/js-yaml": "^3.12.1",
7074
"@types/lodash": "^4.14.137",
7175
"@types/lowdb": "^1.0.9",
7276
"@types/mocha": "^5.2.7",
77+
"@types/multicodec": "^1.0.0",
7378
"@types/node": "^12.7.1",
7479
"@types/node-fetch": "^2.5.1",
7580
"@types/semver": "^6.0.1",
@@ -86,6 +91,7 @@
8691
"husky": "^2.3.0",
8792
"mocha": "^6.2.2",
8893
"nyc": "^11.8.0",
94+
"patch-package": "^6.2.1",
8995
"prettier": "^1.16.4",
9096
"rewiremock": "^3.13.7",
9197
"sinon": "^5.0.10",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/node_modules/ethers/utils/web.js b/node_modules/ethers/utils/web.js
2+
index 05406b4..ad016c2 100644
3+
--- a/node_modules/ethers/utils/web.js
4+
+++ b/node_modules/ethers/utils/web.js
5+
@@ -81,7 +81,9 @@ function fetchJson(connection, json, processFunc) {
6+
if (request.status != 200) {
7+
cancelTimeout();
8+
// @TODO: not any!
9+
- var error = new Error('invalid response - ' + request.status);
10+
+ var error = request.responseText
11+
+ ? new Error(request.responseText.split("\n")[0])
12+
+ : new Error('invalid response - ' + request.status);
13+
error.statusCode = request.status;
14+
if (request.responseText) {
15+
error.responseText = request.responseText;

build/src/src/calls/autoUpdateDataGet.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import { ReturnData } from "../route-types/autoUpdateDataGet";
12
import semver from "semver";
2-
import params from "../params";
33
import { listContainers } from "../modules/docker/listContainers";
44
import { getCoreVersionId } from "../utils/coreVersionId";
55
import * as autoUpdateHelper from "../utils/autoUpdateHelper";
66
import { shortNameCapitalized } from "../utils/format";
77
import {
88
RpcHandlerReturnWithResult,
9-
AutoUpdateDataView,
10-
AutoUpdateDataDnpView
9+
AutoUpdateDataDnpView,
10+
PackageContainer
1111
} from "../types";
1212

1313
const { MY_PACKAGES, SYSTEM_PACKAGES } = autoUpdateHelper;
@@ -19,7 +19,7 @@ const { MY_PACKAGES, SYSTEM_PACKAGES } = autoUpdateHelper;
1919
* - pending: Pending auto-update per DNP, can be already executed
2020
* - dnpsToShow: Parsed data to be shown in the UI
2121
*
22-
* @returns {object} result = {
22+
* @returns result = {
2323
* settings: {
2424
* "system-packages": { enabled: true }
2525
* "my-packages": { enabled: true }
@@ -49,7 +49,7 @@ const { MY_PACKAGES, SYSTEM_PACKAGES } = autoUpdateHelper;
4949
* }
5050
*/
5151
export default async function autoUpdateDataGet(): RpcHandlerReturnWithResult<
52-
AutoUpdateDataView
52+
ReturnData
5353
> {
5454
const settings = autoUpdateHelper.getSettings();
5555
const registry = autoUpdateHelper.getRegistry();
@@ -77,7 +77,7 @@ export default async function autoUpdateDataGet(): RpcHandlerReturnWithResult<
7777
];
7878

7979
if (autoUpdateHelper.isDnpUpdateEnabled()) {
80-
const singleDnpsToShow = [];
80+
const singleDnpsToShow: PackageContainer[] = [];
8181
for (const dnp of dnpList) {
8282
const storedDnp = singleDnpsToShow.find(_dnp => _dnp.name === dnp.name);
8383
const storedVersion = storedDnp ? storedDnp.version : "";
@@ -87,8 +87,6 @@ export default async function autoUpdateDataGet(): RpcHandlerReturnWithResult<
8787
dnp.isDnp &&
8888
// Ignore wierd versions
8989
semver.valid(dnp.version) &&
90-
// MUST come from the APM
91-
(!dnp.origin || params.AUTO_UPDATE_INCLUDE_IPFS_VERSIONS) &&
9290
// Ensure there are no duplicates
9391
(!storedVersion || semver.gt(storedVersion, dnp.version))
9492
)

build/src/src/calls/autoUpdateSettingsEdit.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { RequestData } from "../route-types/autoUpdateSettingsEdit";
12
import {
23
MY_PACKAGES, // "my-packages"
34
SYSTEM_PACKAGES, // "system-packages"
@@ -9,16 +10,13 @@ import { RpcHandlerReturn } from "../types";
910
/**
1011
* Edits the auto-update settings
1112
*
12-
* @param {string} id = "my-packages", "system-packages" or "bitcoin.dnp.dappnode.eth"
13-
* @param {bool} enabled Auto update is enabled for ID
13+
* @param id = "my-packages", "system-packages" or "bitcoin.dnp.dappnode.eth"
14+
* @param enabled Auto update is enabled for ID
1415
*/
1516
export default async function autoUpdateSettingsEdit({
1617
id,
1718
enabled
18-
}: {
19-
id: string;
20-
enabled: boolean;
21-
}): RpcHandlerReturn {
19+
}: RequestData): RpcHandlerReturn {
2220
if (!id)
2321
throw Error(`Argument id is required or generalSettings must be true`);
2422

build/src/src/calls/diagnose.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
1+
import { ReturnData } from "../route-types/diagnose";
12
import shellExec from "../utils/shell";
23
import { RpcHandlerReturnWithResult } from "../types";
34

4-
type ReturnData = {
5-
name: string;
6-
result?: string;
7-
error?: string;
8-
}[];
9-
105
/**
116
* Returns a list of checks done as a diagnose
12-
*
13-
* @returns {object} diagnoses object, by diagnose id
14-
* diagnoses = {
15-
* "dockerVersion": {
16-
* name: "docker version",
17-
* result: "Docker version 18.06.1-ce, build e68fc7a"
18-
* error: "sh: docker: not found"
19-
* } // either "result" or "error" prop will exist
20-
* }
217
*/
228
export default async function diagnose(): RpcHandlerReturnWithResult<
239
ReturnData
2410
> {
25-
// Get docker version
11+
// Get docker version: "Docker version 18.06.1-ce, build e68fc7a"
2612
const dockerVersion = {
2713
name: "docker version",
2814
...(await shellExecFormated(`docker -v`))

0 commit comments

Comments
 (0)