From ba09213a49fcd1afa2cf92c6b14750ed7608605e Mon Sep 17 00:00:00 2001 From: truemiller <mlxndrj@gmail.com> Date: Wed, 17 Jul 2024 23:55:06 +0100 Subject: [PATCH] chore: Update file paths for consistency --- .eslintrc.json | 62 ------------------- .../constants/{appSizes.js => appSizes.mjs} | 0 electron/constants/{env.js => env.mjs} | 0 electron/constants/{errors.js => errors.mjs} | 0 electron/constants/{os.js => os.mjs} | 0 electron/constants/{paths.js => paths.mjs} | 2 +- electron/constants/{ports.js => ports.mjs} | 0 electron/{install.js => install.mjs} | 2 +- electron/{main.js => main.mjs} | 27 ++++---- electron/preload.js | 2 +- electron/{store.js => store.mjs} | 2 +- electron/{update.js => update.mjs} | 4 +- electron/utils/{icons.js => icons.mjs} | 0 electron/utils/{logger.js => logger.mjs} | 2 +- electron/utils/{ports.js => ports.mjs} | 2 +- .../utils/{processes.js => processes.mjs} | 4 +- frontend/constants/providers.ts | 6 ++ frontend/{next.config.mjs => next.config.js} | 4 +- package.json | 4 +- yarn.lock | 23 ++++++- 20 files changed, 54 insertions(+), 92 deletions(-) delete mode 100644 .eslintrc.json rename electron/constants/{appSizes.js => appSizes.mjs} (100%) rename electron/constants/{env.js => env.mjs} (100%) rename electron/constants/{errors.js => errors.mjs} (100%) rename electron/constants/{os.js => os.mjs} (100%) rename electron/constants/{paths.js => paths.mjs} (94%) rename electron/constants/{ports.js => ports.mjs} (100%) rename electron/{install.js => install.mjs} (99%) rename electron/{main.js => main.mjs} (96%) rename electron/{store.js => store.mjs} (97%) rename electron/{update.js => update.mjs} (74%) rename electron/utils/{icons.js => icons.mjs} (100%) rename electron/utils/{logger.js => logger.mjs} (97%) rename electron/utils/{ports.js => ports.mjs} (96%) rename electron/utils/{processes.js => processes.mjs} (93%) rename frontend/{next.config.mjs => next.config.js} (94%) diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index eab7ed2da..000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "overrides": [ - { - // Next Frontend - "excludedFiles": ["frontend/node_modules/*", "frontend/.next"], - "extends": [ - "plugin:@typescript-eslint/recommended", - "next/core-web-vitals" - ], - "files": ["frontend/**/*.ts", "frontend/**/*.tsx"], - "globals": { - "JSX": true, - "React": true - }, - "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint", "unused-imports", "simple-import-sort"], - "rules": { - "prettier/prettier": [ - "error", - { - "endOfLine": "auto", - "semi": true, - "singleQuote": true - } - ] - }, - "settings": { - "next": { - "rootDir": "frontend" - } - } - }, - { - // Electron - "excludedFiles": [ - "electron/node_modules/*", - "electron/.next", - "eslint/preload.mjs" - ], - "extends": ["plugin:@typescript-eslint/recommended"], - "files": ["electron/**/*.js"], - "parser": "@typescript-eslint/parser", - "plugins": [ - "@typescript-eslint", - "unused-imports", - "simple-import-sort", - "prettier" - ], - "rules": { - "prettier/prettier": [ - "error", - { - "endOfLine": "auto", - "semi": true, - "singleQuote": true - } - ] - } - } - ], - "root": true -} diff --git a/electron/constants/appSizes.js b/electron/constants/appSizes.mjs similarity index 100% rename from electron/constants/appSizes.js rename to electron/constants/appSizes.mjs diff --git a/electron/constants/env.js b/electron/constants/env.mjs similarity index 100% rename from electron/constants/env.js rename to electron/constants/env.mjs diff --git a/electron/constants/errors.js b/electron/constants/errors.mjs similarity index 100% rename from electron/constants/errors.js rename to electron/constants/errors.mjs diff --git a/electron/constants/os.js b/electron/constants/os.mjs similarity index 100% rename from electron/constants/os.js rename to electron/constants/os.mjs diff --git a/electron/constants/paths.js b/electron/constants/paths.mjs similarity index 94% rename from electron/constants/paths.js rename to electron/constants/paths.mjs index c7d13697a..88106513f 100644 --- a/electron/constants/paths.js +++ b/electron/constants/paths.mjs @@ -2,7 +2,7 @@ import os from 'os'; import path from 'path'; -import { isProd } from './env.js'; +import { isProd } from './env.mjs'; // Paths const dotOperateDirectory = isProd diff --git a/electron/constants/ports.js b/electron/constants/ports.mjs similarity index 100% rename from electron/constants/ports.js rename to electron/constants/ports.mjs diff --git a/electron/install.js b/electron/install.mjs similarity index 99% rename from electron/install.js rename to electron/install.mjs index 2c543a714..ba029e1f0 100644 --- a/electron/install.js +++ b/electron/install.mjs @@ -6,7 +6,7 @@ import os from 'os'; import process from 'process'; import sudo from 'sudo-prompt'; -import { paths } from './constants/paths.js'; +import { paths } from './constants/paths.mjs'; /** * current version of the pearl release diff --git a/electron/main.js b/electron/main.mjs similarity index 96% rename from electron/main.js rename to electron/main.mjs index 5b01bd5e1..0da202e13 100644 --- a/electron/main.js +++ b/electron/main.mjs @@ -16,18 +16,18 @@ import next from 'next'; import os from 'os'; import path from 'path'; -import { APP_HEIGHT, APP_WIDTH } from './constants/appSizes.js'; -import { isDev } from './constants/env.js'; -import { isMac, isWindows } from './constants/os.js'; -import { paths } from './constants/paths.js'; -import { PORT_RANGE } from './constants/ports.js'; -import { Env } from './install.js'; -import { setupStoreIpc } from './store.js'; -import { macUpdater } from './update.js'; -import { TRAY_ICONS, TRAY_ICONS_PATHS } from './utils/icons.js'; -import { logger } from './utils/logger.js'; -import { findAvailablePort, isPortAvailable } from './utils/ports.js'; -import { killProcesses } from './utils/processes.js'; +import { APP_HEIGHT, APP_WIDTH } from './constants/appSizes.mjs'; +import { isDev } from './constants/env.mjs'; +import { isMac, isWindows } from './constants/os.mjs'; +import { paths } from './constants/paths.mjs'; +import { PORT_RANGE } from './constants/ports.mjs'; +import { Env } from './install.mjs'; +import { setupStoreIpc } from './store.mjs'; +import { macUpdater } from './update.mjs'; +import { TRAY_ICONS, TRAY_ICONS_PATHS } from './utils/icons.mjs'; +import { logger } from './utils/logger.mjs'; +import { findAvailablePort, isPortAvailable } from './utils/ports.mjs'; +import { killProcesses } from './utils/processes.mjs'; // Attempt to acquire the single instance lock const singleInstanceLock = app.requestSingleInstanceLock(); @@ -202,8 +202,7 @@ const createMainWindow = async () => { webPreferences: { nodeIntegration: false, contextIsolation: true, - enableRemoteModule: true, - preload: path.join(import.meta.dirname, 'preload.mjs'), + preload: path.join(import.meta.dirname, 'preload.js'), }, }); diff --git a/electron/preload.js b/electron/preload.js index d036bd6a1..b64eb3234 100644 --- a/electron/preload.js +++ b/electron/preload.js @@ -1,5 +1,5 @@ // This file is loaded in the renderer process before other scripts -import { contextBridge, ipcRenderer } from 'electron/renderer'; +const { contextBridge, ipcRenderer } = require('electron/renderer'); contextBridge.exposeInMainWorld('electronAPI', { // App controls diff --git a/electron/store.js b/electron/store.mjs similarity index 97% rename from electron/store.js rename to electron/store.mjs index b3b23aa8e..00d0ea065 100644 --- a/electron/store.js +++ b/electron/store.mjs @@ -1,4 +1,4 @@ -import { logger } from './utils/logger.js'; +import { logger } from './utils/logger.mjs'; const defaultSchema = { version: { type: 'string', default: '' }, diff --git a/electron/update.js b/electron/update.mjs similarity index 74% rename from electron/update.js rename to electron/update.mjs index e8d9df126..381532037 100644 --- a/electron/update.js +++ b/electron/update.mjs @@ -1,8 +1,8 @@ // @ts-check import { MacUpdater } from 'electron-updater'; -import { isDev } from './constants/env.js'; -import { logger } from './utils/logger.js'; +import { isDev } from './constants/env.mjs'; +import { logger } from './utils/logger.mjs'; const macUpdater = new MacUpdater(); diff --git a/electron/utils/icons.js b/electron/utils/icons.mjs similarity index 100% rename from electron/utils/icons.js rename to electron/utils/icons.mjs diff --git a/electron/utils/logger.js b/electron/utils/logger.mjs similarity index 97% rename from electron/utils/logger.js rename to electron/utils/logger.mjs index 2a46461f0..0a32b4a77 100644 --- a/electron/utils/logger.js +++ b/electron/utils/logger.mjs @@ -2,7 +2,7 @@ import { format } from 'logform'; import winston from 'winston'; -import { paths } from '../constants/paths.js'; +import { paths } from '../constants/paths.mjs'; const { combine, timestamp, printf } = format; diff --git a/electron/utils/ports.js b/electron/utils/ports.mjs similarity index 96% rename from electron/utils/ports.js rename to electron/utils/ports.mjs index 9846a0467..45e6696f5 100644 --- a/electron/utils/ports.js +++ b/electron/utils/ports.mjs @@ -1,6 +1,6 @@ import net from 'net'; -import { ERROR_ADDRESS_IN_USE } from '../constants/errors.js'; +import { ERROR_ADDRESS_IN_USE } from '../constants/errors.mjs'; export function findAvailablePort({ startPort, endPort, excludePorts = [] }) { return new Promise((resolve, reject) => { diff --git a/electron/utils/processes.js b/electron/utils/processes.mjs similarity index 93% rename from electron/utils/processes.js rename to electron/utils/processes.mjs index 0c1f8cff4..49a803d1e 100644 --- a/electron/utils/processes.js +++ b/electron/utils/processes.mjs @@ -1,8 +1,8 @@ import { exec } from 'child_process'; import psTree from 'ps-tree'; -import { isWindows } from '../constants/os.js'; -import { logger } from './logger.js'; +import { isWindows } from '../constants/os.mjs'; +import { logger } from './logger.mjs'; const unixKillCommand = 'kill -9'; const windowsKillCommand = 'taskkill /F /PID'; diff --git a/frontend/constants/providers.ts b/frontend/constants/providers.ts index 61e79a3dd..997aa6945 100644 --- a/frontend/constants/providers.ts +++ b/frontend/constants/providers.ts @@ -10,3 +10,9 @@ export const provider = new ethers.providers.StaticJsonRpcProvider( ); export const multicallProvider = new Provider(provider, 100); + +try { + multicallProvider.init(); +} catch (e) { + console.error('Error initializing multicall provider', e); +} \ No newline at end of file diff --git a/frontend/next.config.mjs b/frontend/next.config.js similarity index 94% rename from frontend/next.config.mjs rename to frontend/next.config.js index c580dc550..241abb4f1 100644 --- a/frontend/next.config.mjs +++ b/frontend/next.config.js @@ -1,5 +1,5 @@ /** @type {import('next').NextConfig} */ -const nextConfig = { +module.exports = { images: { remotePatterns: [ { @@ -38,5 +38,3 @@ const nextConfig = { : process.env.DEV_RPC, }, }; - -export default nextConfig; diff --git a/package.json b/package.json index 5089bb689..08653419b 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "prettier": "^3.2.5", "typescript": "~5.4" }, - "main": "electron/main.js", + "main": "electron/main.mjs", "name": "olas-operate-app", "productName": "Pearl", "scripts": { @@ -68,4 +68,4 @@ "test:frontend": "cd frontend && yarn test" }, "version": "0.1.0-rc72" -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index 50b24e317..541551c7d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -54,6 +54,15 @@ resize-observer-polyfill "^1.5.1" throttle-debounce "^5.0.0" +"@babel/eslint-parser@^7.24.8": + version "7.24.8" + resolved "https://registry.yarnpkg.com/@babel/eslint-parser/-/eslint-parser-7.24.8.tgz#bc655255fa4ded3694cc10ef3dbea6d69639c831" + integrity sha512-nYAikI4XTGokU2QX7Jx+v4rxZKhKivaQaREZjuW3mrJrbdWJ5yUfohnoUULge+zEEaKjPYNxhoRgUKktjXtbwA== + dependencies: + "@nicolo-ribaudo/eslint-scope-5-internals" "5.1.1-v1" + eslint-visitor-keys "^2.1.0" + semver "^6.3.1" + "@babel/runtime@^7.10.1", "@babel/runtime@^7.10.4", "@babel/runtime@^7.11.1", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.7", "@babel/runtime@^7.18.0", "@babel/runtime@^7.18.3", "@babel/runtime@^7.20.0", "@babel/runtime@^7.20.7", "@babel/runtime@^7.21.0", "@babel/runtime@^7.22.5", "@babel/runtime@^7.23.2", "@babel/runtime@^7.23.6", "@babel/runtime@^7.23.9", "@babel/runtime@^7.24.4", "@babel/runtime@^7.24.7": version "7.24.7" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.24.7.tgz#f4f0d5530e8dbdf59b3451b9b3e594b6ba082e12" @@ -666,6 +675,13 @@ resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.5.tgz#ed199a920efb510cfe941cd75ed38a7be21e756f" integrity sha512-tEQ7oinq1/CjSG9uSTerca3v4AZ+dFa+4Yu6ihaG8Ud8ddqLQgFGcnwYls13H5X5CPDPZJdYxyeMui6muOLd4g== +"@nicolo-ribaudo/eslint-scope-5-internals@5.1.1-v1": + version "5.1.1-v1" + resolved "https://registry.yarnpkg.com/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz#dbf733a965ca47b1973177dc0bb6c889edcfb129" + integrity sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg== + dependencies: + eslint-scope "5.1.1" + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -2561,7 +2577,7 @@ eslint-rule-composer@^0.3.0: resolved "https://registry.yarnpkg.com/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz#79320c927b0c5c0d3d3d2b76c8b4a488f25bbaf9" integrity sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg== -eslint-scope@^5.1.1: +eslint-scope@5.1.1, eslint-scope@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== @@ -2577,6 +2593,11 @@ eslint-scope@^7.2.2: esrecurse "^4.3.0" estraverse "^5.2.0" +eslint-visitor-keys@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" + integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== + eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4.3: version "3.4.3" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800"