From 3d877e9347ea174f2b8fce9402eabb41c33ba824 Mon Sep 17 00:00:00 2001 From: angrybayblade Date: Tue, 4 Jun 2024 11:52:26 +0530 Subject: [PATCH 1/3] fix: disable brew updates when installing a package --- electron/install.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/electron/install.js b/electron/install.js index 944ceac50..412c0f3c5 100644 --- a/electron/install.js +++ b/electron/install.js @@ -22,6 +22,7 @@ const OperateCmd = `${os.homedir()}/.operate/venv/bin/operate`; const Env = { ...process.env, PATH: `${process.env.PATH}:/opt/homebrew/bin:/usr/local/bin`, + HOMEBREW_NO_AUTO_UPDATE: "1", }; const SudoOptions = { name: 'Pearl', @@ -63,11 +64,7 @@ function appendLog(log) { } function runCmdUnix(command, options) { - fs.appendFileSync( - OperateInstallationLog, - `Runninng ${command} with options ${JSON.stringify(options)}`, - { encoding: 'utf-8' }, - ); + console.log(appendLog(`Runninng ${command} with options ${JSON.stringify(options)}`)); let bin = getBinPath(command); if (!bin) { throw new Error(`Command ${command} not found; Path : ${Env.PATH}`); From 0f6900f7913d8e87b51e7d3d85dee056eb468096 Mon Sep 17 00:00:00 2001 From: joshmlxn Date: Tue, 4 Jun 2024 10:44:03 +0100 Subject: [PATCH 2/3] lint & bump for release --- electron/install.js | 60 +++++++++++++++++++++++++-------------------- package.json | 2 +- pyproject.toml | 2 +- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/electron/install.js b/electron/install.js index 412c0f3c5..29691a4da 100644 --- a/electron/install.js +++ b/electron/install.js @@ -6,12 +6,12 @@ const fs = require('fs'); const os = require('os'); const sudo = require('sudo-prompt'); const process = require('process'); -const axios = require("axios") +const axios = require('axios'); const Docker = require('dockerode'); const { spawnSync } = require('child_process'); -const Version = '0.1.0rc34'; +const Version = '0.1.0rc35'; const OperateDirectory = `${os.homedir()}/.operate`; const VenvDir = `${OperateDirectory}/venv`; const TempDir = `${OperateDirectory}/temp`; @@ -22,7 +22,7 @@ const OperateCmd = `${os.homedir()}/.operate/venv/bin/operate`; const Env = { ...process.env, PATH: `${process.env.PATH}:/opt/homebrew/bin:/usr/local/bin`, - HOMEBREW_NO_AUTO_UPDATE: "1", + HOMEBREW_NO_AUTO_UPDATE: '1', }; const SudoOptions = { name: 'Pearl', @@ -30,18 +30,21 @@ const SudoOptions = { }; const TendermintUrls = { darwin: { - x64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_darwin_amd64.tar.gz", - arm64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_darwin_arm64.tar.gz", + x64: 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_darwin_amd64.tar.gz', + arm64: + 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_darwin_arm64.tar.gz', }, linux: { - x64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_linux_amd64.tar.gz", - arm64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_linux_arm64.tar.gz", + x64: 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_linux_amd64.tar.gz', + arm64: + 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_linux_arm64.tar.gz', }, win32: { - x64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_amd64.tar.gz", - arm64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_arm64.tar.gz" - } -} + x64: 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_amd64.tar.gz', + arm64: + 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_arm64.tar.gz', + }, +}; function getBinPath(command) { return spawnSync('/usr/bin/which', [command], { env: Env }) @@ -64,7 +67,9 @@ function appendLog(log) { } function runCmdUnix(command, options) { - console.log(appendLog(`Runninng ${command} with options ${JSON.stringify(options)}`)); + console.log( + appendLog(`Runninng ${command} with options ${JSON.stringify(options)}`), + ); let bin = getBinPath(command); if (!bin) { throw new Error(`Command ${command} not found; Path : ${Env.PATH}`); @@ -130,7 +135,7 @@ async function downloadFile(url, dest) { const response = await axios({ url, method: 'GET', - responseType: 'stream' + responseType: 'stream', }); response.data.pipe(writer); return new Promise((resolve, reject) => { @@ -138,28 +143,29 @@ async function downloadFile(url, dest) { writer.on('error', reject); }); } catch (err) { - fs.unlink(dest, () => { }); // Delete the file if there is an error + fs.unlink(dest, () => {}); // Delete the file if there is an error console.error('Error downloading the file:', err.message); } } async function installTendermintUnix() { - const cwd = process.cwd() - process.chdir(TempDir) + const cwd = process.cwd(); + process.chdir(TempDir); - console.log(appendLog(`Installing tendermint for ${os.platform()}-${process.arch}`)) - const url = TendermintUrls[os.platform()][process.arch] + console.log( + appendLog(`Installing tendermint for ${os.platform()}-${process.arch}`), + ); + const url = TendermintUrls[os.platform()][process.arch]; - console.log(appendLog(`Downloading ${url}, might take a while...`)) - await downloadFile(url, `${TempDir}/tendermint.tar.gz`) + console.log(appendLog(`Downloading ${url}, might take a while...`)); + await downloadFile(url, `${TempDir}/tendermint.tar.gz`); - console.log(appendLog(`Installing tendermint binary`)) - await runCmdUnix("tar", ["-xvf", "tendermint.tar.gz"]) - await runSudoUnix("install", "tendermint /usr/local/bin") - process.chdir(cwd) + console.log(appendLog(`Installing tendermint binary`)); + await runCmdUnix('tar', ['-xvf', 'tendermint.tar.gz']); + await runSudoUnix('install', 'tendermint /usr/local/bin'); + process.chdir(cwd); } - function isDockerInstalledDarwin() { return Boolean(getBinPath('docker')); } @@ -307,7 +313,7 @@ async function setupDarwin(ipcChannel) { if (!isTendermintInstalledUnix()) { ipcChannel.send('response', 'Installing Pearl Daemon'); console.log(appendLog('Installing tendermint')); - await installTendermintUnix() + await installTendermintUnix(); } if (!fs.existsSync(VenvDir)) { @@ -361,7 +367,7 @@ async function setupUbuntu(ipcChannel) { if (!isTendermintInstalledUnix()) { ipcChannel.send('response', 'Installing Pearl Daemon'); console.log(appendLog('Installing tendermint')); - await installTendermintUnix() + await installTendermintUnix(); } if (!fs.existsSync(VenvDir)) { diff --git a/package.json b/package.json index d866e9081..e3478c173 100644 --- a/package.json +++ b/package.json @@ -55,5 +55,5 @@ "start": "electron .", "build": "rm -rf dist/ && electron-builder build" }, - "version": "0.1.0-rc34" + "version": "0.1.0-rc35" } diff --git a/pyproject.toml b/pyproject.toml index fe6eee3e6..ff4e5a05f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc34" +version = "0.1.0-rc35" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From c1dfe334f0305342a596b7b0361a82c5cf1f47bc Mon Sep 17 00:00:00 2001 From: angrybayblade Date: Wed, 5 Jun 2024 09:28:30 +0530 Subject: [PATCH 3/3] fix: unstaking logic --- operate/services/manage.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/operate/services/manage.py b/operate/services/manage.py index 803ee8527..cfbda1d96 100644 --- a/operate/services/manage.py +++ b/operate/services/manage.py @@ -758,13 +758,8 @@ def unstake_service_on_chain_from_safe(self, hash: str) -> None: service_id=service.chain_data.token, staking_contract=STAKING[service.ledger_config.chain], ) - ).add( - sftxb.get_staking_data( - service_id=service.chain_data.token, - staking_contract=STAKING[service.ledger_config.chain], - ) ).settle() - service.chain_data.staked = True + service.chain_data.staked = False service.store() def fund_service( # pylint: disable=too-many-arguments