Skip to content

Commit

Permalink
Merge branch 'devnet' of https://github.com/gbayasgalan/ethereum-node
Browse files Browse the repository at this point in the history
…into pr/2014
  • Loading branch information
MaxTheGeeek committed Sep 4, 2024
2 parents 44e91c8 + 7cc45bc commit b037e4a
Show file tree
Hide file tree
Showing 333 changed files with 1,606 additions and 4,435 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/code_quality_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Code Quality Check

on:
pull_request:
branches: [main]

workflow_dispatch:

jobs:
prettier:
name: Prettier
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm install
working-directory: ./launcher
- run: npm run format:check
working-directory: ./launcher
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"vue3snippets.enable-compile-vue-file-on-did-save-code": true,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false
Expand Down
9 changes: 9 additions & 0 deletions launcher/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**/.git
**/.svn
**/.hg
**/node_modules
**/coverage
**/dist
**/dist_electron
package-lock.json
public/output.css
4 changes: 2 additions & 2 deletions launcher/.prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"printWidth": 120,
"printWidth": 140,
"useTabs": false
}
}
17 changes: 6 additions & 11 deletions launcher/customsign.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
'use strict';
"use strict";

// custom sign script calling digicerts keytool from out of the electron-builder
exports.default = async function(configuration) {

if(configuration.path){

require("child_process").execSync(
`smctl sign --keypair-alias=${process.env.KEYPAIR_ALIAS} --input "${String(configuration.path)}"`
);

}
};
exports.default = async function (configuration) {
if (configuration.path) {
require("child_process").execSync(`smctl sign --keypair-alias=${process.env.KEYPAIR_ALIAS} --input "${String(configuration.path)}"`);
}
};
3 changes: 2 additions & 1 deletion launcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"lint:fix": "eslint --ext .js,.vue --ignore-path ../.gitignore --fix src",
"stereum": "concurrently \"npm:electron:serve\" \"npm:watch:css\"",
"backend:watch": "nodemon --watch 'src/backend' --exec 'npm run electron:serve'",
"format": "prettier . --write"
"format": "prettier . --write",
"format:check": "prettier . --check"
},
"dependencies": {
"@headlessui/vue": "^1.7.16",
Expand Down
4 changes: 2 additions & 2 deletions launcher/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<body>
<noscript>
<strong
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please
enable it to continue.</strong
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to
continue.</strong
>
</noscript>
<div id="app"></div>
Expand Down
132 changes: 69 additions & 63 deletions launcher/src/StereumUpdater.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,84 @@
import { autoUpdater } from "electron-updater";
import { app, BrowserWindow } from "electron";


export class StereumUpdater {
constructor(logger, createWindow) {
this.updater = autoUpdater
this.updateWindow = null
this.logger = logger
this.createWindow = createWindow
}
constructor(logger, createWindow) {
this.updater = autoUpdater;
this.updateWindow = null;
this.logger = logger;
this.createWindow = createWindow;
}

checkForUpdates() {
app.showExitPrompt = true;
this.updater.checkForUpdates()
}
checkForUpdates() {
app.showExitPrompt = true;
this.updater.checkForUpdates();
}

initUpdater() {
this.updater.logger = this.logger;
this.updater.logger.transports.file.level = "debug";
initUpdater() {
this.updater.logger = this.logger;
this.updater.logger.transports.file.level = "debug";

this.updater.on("checking-for-update", () => {
this.logger.info("Stereum is checking for updates.");
});
this.updater.on("checking-for-update", () => {
this.logger.info("Stereum is checking for updates.");
});

this.updater.on("update-available", async () => {
this.updateWindow = await this.createWindow("update")
if (this.updateWindow)
this.updateWindow.webContents.send('UpdateEvents', { message: "Update available.", type: "available" })
this.logger.info("Update available.");
});
this.updater.on("update-available", async () => {
this.updateWindow = await this.createWindow("update");
if (this.updateWindow) this.updateWindow.webContents.send("UpdateEvents", { message: "Update available.", type: "available" });
this.logger.info("Update available.");
});

this.updater.on("update-not-available", () => {
app.showExitPrompt = false;
this.createWindow();
this.logger.info("No updates available. Stereum is Up-to-date.");
});
this.updater.on("update-not-available", () => {
app.showExitPrompt = false;
this.createWindow();
this.logger.info("No updates available. Stereum is Up-to-date.");
});

this.updater.on("download-progress", (data) => {
if (this.updateWindow)
this.updateWindow.webContents.send('UpdateEvents', { message: "Downloading update...", type: "downloading", data: { percent: data.percent, MBps: data.bytesPerSecond / 1000000 } })
this.logger.info("Update progress", data);
this.updater.on("download-progress", (data) => {
if (this.updateWindow)
this.updateWindow.webContents.send("UpdateEvents", {
message: "Downloading update...",
type: "downloading",
data: { percent: data.percent, MBps: data.bytesPerSecond / 1000000 },
});
this.logger.info("Update progress", data);
});

this.updater.on("update-downloaded", async (data) => {
app.showExitPrompt = false
if (this.updateWindow)
this.updateWindow.webContents.send('UpdateEvents', { message: "Update downloaded. " + data.version, type: "downloaded" })
this.updater.quitAndInstall()
this.logger.info("Update downloaded.", data);
});
this.updater.on("update-downloaded", async (data) => {
app.showExitPrompt = false;
if (this.updateWindow)
this.updateWindow.webContents.send("UpdateEvents", { message: "Update downloaded. " + data.version, type: "downloaded" });
this.updater.quitAndInstall();
this.logger.info("Update downloaded.", data);
});

this.updater.on("error", async (error) => {
app.showExitPrompt = false;
const allWindows = await BrowserWindow.getAllWindows();
for (const win of allWindows) {
await win.close()
}
this.createWindow();
this.logger.error("Error: ", error)
});
}
this.updater.on("error", async (error) => {
app.showExitPrompt = false;
const allWindows = await BrowserWindow.getAllWindows();
for (const win of allWindows) {
await win.close();
}
this.createWindow();
this.logger.error("Error: ", error);
});
}

async runDebug() {
async function Sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
this.updateWindow = await this.createWindow("update");
await Sleep(5000)
for (let i = 0; i < 10; i++) {
this.updateWindow.webContents.send('UpdateEvents', { message: "Downloading update...", type: "downloading", data: { percent: i * 10, MBps: i * 10.11 } })
await Sleep(1000)
}
this.updateWindow.webContents.send('UpdateEvents', { message: "Update downloaded. " + "2.0.0-rc.20", type: "downloaded" })
await Sleep(1000)
this.updateWindow.close()
async runDebug() {
async function Sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
this.updateWindow = await this.createWindow("update");
await Sleep(5000);
for (let i = 0; i < 10; i++) {
this.updateWindow.webContents.send("UpdateEvents", {
message: "Downloading update...",
type: "downloading",
data: { percent: i * 10, MBps: i * 10.11 },
});
await Sleep(1000);
}
}
this.updateWindow.webContents.send("UpdateEvents", { message: "Update downloaded. " + "2.0.0-rc.20", type: "downloaded" });
await Sleep(1000);
this.updateWindow.close();
}
}
20 changes: 10 additions & 10 deletions launcher/src/backend/AuthenticationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ export class AuthenticationService {

outputArray.push(
outputString[
outputString.findIndex(function (item) {
return item.indexOf("https") !== -1;
})
outputString.findIndex(function (item) {
return item.indexOf("https") !== -1;
})
]
);
outputArray.push(
outputString[
outputString.findIndex(function (item) {
return item.indexOf("secret key") !== -1;
})
outputString.findIndex(function (item) {
return item.indexOf("secret key") !== -1;
})
]
);
win.send("2FAEvents", outputArray);
Expand Down Expand Up @@ -96,9 +96,9 @@ export class AuthenticationService {

outputArray.push(
outputString[
outputString.findIndex(function (item) {
return item.indexOf("https") !== -1;
})
outputString.findIndex(function (item) {
return item.indexOf("https") !== -1;
})
]
);

Expand Down Expand Up @@ -165,7 +165,7 @@ export class AuthenticationService {

async create2FAQRCode(type, name, ip, secret) {
let otpauth = `otpauth://${type}/${ip}@${name}?secret=${secret}&issuer=${name}`;
const url = await QRCode.toDataURL(otpauth)
const url = await QRCode.toDataURL(otpauth);
return url;
}
}
15 changes: 3 additions & 12 deletions launcher/src/backend/ConfigManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ export class ConfigManager {
this.nodeConnection = nodeConnection;
this.serviceManager = null;
this.multiSetupPath = "/etc/stereum/multisetup.yaml";
this.commonServices = [
"PrometheusService",
"GrafanaService",
"PrometheusNodeExporterService",
"NotificationService",
];
this.commonServices = ["PrometheusService", "GrafanaService", "PrometheusNodeExporterService", "NotificationService"];
}
setServiceManager(serviceManager) {
this.serviceManager = serviceManager;
Expand Down Expand Up @@ -56,9 +51,7 @@ export class ConfigManager {
* @returns {Promise<Object>} Resolves with command execution result, indicating file existence.
*/
async checkFileExistence() {
const fileExistResult = await this.nodeConnection.sshService.exec(
`test -f ${this.multiSetupPath} && echo "exist" || echo "notExist"`
);
const fileExistResult = await this.nodeConnection.sshService.exec(`test -f ${this.multiSetupPath} && echo "exist" || echo "notExist"`);
return fileExistResult;
}

Expand Down Expand Up @@ -166,9 +159,7 @@ export class ConfigManager {
}

if (commonServices.length > 0) {
commonServicesObj[setupId].services = commonServicesObj[setupId].services.concat(
commonServices.map((service) => service.id)
);
commonServicesObj[setupId].services = commonServicesObj[setupId].services.concat(commonServices.map((service) => service.id));
}
return commonServicesObj;
}
Expand Down
Loading

0 comments on commit b037e4a

Please sign in to comment.