diff --git a/apps/remix-ide/src/app/tabs/compileTab/compileTab.js b/apps/remix-ide/src/app/tabs/compileTab/compileTab.js index 1e5de9d5c7..33deec9dc7 100644 --- a/apps/remix-ide/src/app/tabs/compileTab/compileTab.js +++ b/apps/remix-ide/src/app/tabs/compileTab/compileTab.js @@ -97,19 +97,25 @@ class CompileTab extends Plugin { try { if (this.fileManager.mode === 'localhost' && hhCompilation) { const { currentVersion, optimize, runs } = this.compiler.state - const fileContent = `module.exports = { - solidity: '${currentVersion.substring(0, currentVersion.indexOf('+commit'))}', - settings: { - optimizer: { - enabled: ${optimize}, - runs: ${runs} + if (currentVersion) { + const fileContent = `module.exports = { + solidity: '${currentVersion.substring(0, currentVersion.indexOf('+commit'))}', + settings: { + optimizer: { + enabled: ${optimize}, + runs: ${runs} + } } } + ` + const configFilePath = 'remix-compiler.config.js' + this.fileManager.setFileContent(configFilePath, fileContent) + this.call('hardhat', 'compile', configFilePath).then((result) => { + this.call('terminal', 'log', { type: 'info', value: result }) + }).catch((error) => { + this.call('terminal', 'log', { type: 'error', value: error }) + }) } - ` - const configFilePath = 'remix-compiler.config.js' - this.fileManager.setFileContent(configFilePath, fileContent) - this.call('hardhat', 'compile', configFilePath) } this.fileManager.saveCurrentFile() this.call('editor', 'clearAnnotations') diff --git a/libs/remixd/src/bin/remixd.ts b/libs/remixd/src/bin/remixd.ts index 8d2ebe9bb2..913c7ec05a 100644 --- a/libs/remixd/src/bin/remixd.ts +++ b/libs/remixd/src/bin/remixd.ts @@ -4,7 +4,7 @@ import * as semver from 'semver' import WebSocket from '../websocket' import * as servicesList from '../serviceList' import * as WS from 'ws' // eslint-disable-line -import { getDomain } from '../utils' +import { getDomain, absolutePath } from '../utils' import Axios from 'axios' import * as fs from 'fs-extra' import * as path from 'path' @@ -28,6 +28,7 @@ const services = { folder: (readOnly: boolean) => new servicesList.Sharedfolder(readOnly) } +// Similar object is also defined in websocket.ts const ports = { git: 65521, hardhat: 65522, @@ -80,10 +81,15 @@ function startService (service: S, callb sharedFolderClient.setupNotifications(program.sharedFolder) sharedFolderClient.sharedFolder(program.sharedFolder) }) - startService('hardhat', (ws: WS, sharedFolderClient: servicesList.Sharedfolder) => { - sharedFolderClient.setWebSocket(ws) - sharedFolderClient.sharedFolder(program.sharedFolder) - }) + // Run hardhat service if a hardhat project is shared as folder + const hardhatConfigFilePath = absolutePath('./', program.sharedFolder) + '/hardhat.config.js' + const isHardhatProject = fs.existsSync(hardhatConfigFilePath) + if (isHardhatProject) { + startService('hardhat', (ws: WS, sharedFolderClient: servicesList.Sharedfolder) => { + sharedFolderClient.setWebSocket(ws) + sharedFolderClient.sharedFolder(program.sharedFolder) + }) + } /* startService('git', (ws: WS, sharedFolderClient: servicesList.Sharedfolder) => { sharedFolderClient.setWebSocket(ws) diff --git a/libs/remixd/src/services/hardhatClient.ts b/libs/remixd/src/services/hardhatClient.ts index 7c2efd463a..217a934e2d 100644 --- a/libs/remixd/src/services/hardhatClient.ts +++ b/libs/remixd/src/services/hardhatClient.ts @@ -24,7 +24,6 @@ export class HardhatClient extends PluginClient { return new Promise((resolve, reject) => { if (this.readOnly) { const errMsg = '[Hardhat Compilation]: Cannot compile in read-only mode' - console.log('\x1b[31m%s\x1b[0m', `${errMsg}`) return reject(new Error(errMsg)) } const cmd = `npx hardhat compile --config ${configPath}` @@ -33,12 +32,12 @@ export class HardhatClient extends PluginClient { let result = '' let error = '' child.stdout.on('data', (data) => { - console.log('\x1b[32m%s\x1b[0m', `[Hardhat Compilation]: ${data.toString()}`) - result += data.toString() + const msg = `[Hardhat Compilation]: ${data.toString()}` + console.log('\x1b[32m%s\x1b[0m', msg) + result += msg + '\n' }) child.stderr.on('data', (err) => { - console.log('\x1b[31m%s\x1b[0m', `[Hardhat Compilation]: ${err.toString()}`) - error += err.toString() + error += `[Hardhat Compilation]: ${err.toString()}` }) child.on('close', () => { if (error) reject(error) diff --git a/libs/remixd/src/websocket.ts b/libs/remixd/src/websocket.ts index dd9cc4f511..cc3ca7b197 100644 --- a/libs/remixd/src/websocket.ts +++ b/libs/remixd/src/websocket.ts @@ -16,9 +16,13 @@ export default class WebSocket { response.end() }) const loopback = '127.0.0.1' - + const listeners = { + 65520: 'remixd', + 65521: 'git', + 65522: 'hardhat' + } this.server.listen(this.port, loopback, () => { - console.log(`${new Date()} remixd is listening on ${loopback}:${this.port}`) + console.log('\x1b[32m%s\x1b[0m', `[INFO] ${new Date()} ${listeners[this.port]} is listening on ${loopback}:${this.port}`) }) this.wsServer = new WS.Server({ server: this.server, diff --git a/package-lock.json b/package-lock.json index d74204bd8f..d3f785626b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7638,53 +7638,112 @@ "integrity": "sha512-tVkIU9JQw5fYPxLQgok/a7I6J1eEZ79svwQGpe2mb3jlVsPADOleefOnQBiS/takK7jQuNeswCUicMH1VWVziA==" }, "@remixproject/engine": { - "version": "0.3.11", - "resolved": "https://registry.npmjs.org/@remixproject/engine/-/engine-0.3.11.tgz", - "integrity": "sha512-gRTOM4WolVuECOxeMcTD30iCZ4TJTZE+osYyNFnypgHQECcMtibATnulFc0zx+RtGm17KPEk5dW865fG01q+IA==", + "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@remixproject/engine/-/engine-0.3.16.tgz", + "integrity": "sha512-UI8Hg4l8oxaaBYNMcUI59C2terQL2Of4Bf9/AVETy67EFxwi3U8dHqSjkVJHz+rRYBSMSVnjcw3jaO1+0C3K4g==", "requires": { - "@remixproject/plugin-api": "0.3.11", - "@remixproject/plugin-utils": "0.3.11" + "@remixproject/plugin-api": "0.3.16", + "@remixproject/plugin-utils": "0.3.16" + }, + "dependencies": { + "@remixproject/plugin-api": { + "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@remixproject/plugin-api/-/plugin-api-0.3.16.tgz", + "integrity": "sha512-PuSo6GGjKXwCZr3KjCrqGxLF2sZJFpueb9cjwLeAi1y9C4VoPRjWFIC6bESn1EVL9DyqcET7a8IwuqhHVGOGSQ==", + "requires": { + "@remixproject/plugin-utils": "0.3.16" + } + }, + "@remixproject/plugin-utils": { + "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@remixproject/plugin-utils/-/plugin-utils-0.3.16.tgz", + "integrity": "sha512-3zV1zdpkdgT4/fa4s4a3KdcZFpHR0a2ye5BMDRZZr0fZeGBaL9B7Lh52wvQuRJ384E60xwqjMytZLmi3qvL5SA==", + "requires": { + "tslib": "2.0.1" + } + }, + "tslib": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", + "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==" + } } }, "@remixproject/engine-web": { - "version": "0.3.11", - "resolved": "https://registry.npmjs.org/@remixproject/engine-web/-/engine-web-0.3.11.tgz", - "integrity": "sha512-oM4kRKQ6R5ZWT6Ih542XtvFBLx9E5kUHU7H1t0DlI2A/w6arP4cC7WQwNK8TsnysVSjoJ5kveHb6tVntxhBGSg==", + "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@remixproject/engine-web/-/engine-web-0.3.16.tgz", + "integrity": "sha512-eZPs/cofoyZQWMcr4ukhn36IWi52m24LIj+GqUEfdcVpdXO4wkM0ATt4Wrk1WeOcNhlld3G27VfSS2jn2k0BnA==", "requires": { - "@remixproject/engine": "0.3.11", - "@remixproject/plugin-api": "0.3.11", - "@remixproject/plugin-utils": "0.3.11" + "@remixproject/engine": "0.3.16", + "@remixproject/plugin-api": "0.3.16", + "@remixproject/plugin-utils": "0.3.16" } }, "@remixproject/plugin": { - "version": "0.3.11", - "resolved": "https://registry.npmjs.org/@remixproject/plugin/-/plugin-0.3.11.tgz", - "integrity": "sha512-GbZV9KjZoALYUCEXDIhDWQFR3hi3m3R03WDm/i/XSIaJRkyya2WU6IzmqkvCT7TuTR+VfdJoWnflZTQWesLB1A==", + "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@remixproject/plugin/-/plugin-0.3.16.tgz", + "integrity": "sha512-UAtv3Te/jCZ4V30QSSNbudLhMS45zA97XIzcg894milJZm7E+rg+YUP2RQn88sqSBPbETPFF5LT93KgP1+IIzw==", "requires": { - "@remixproject/plugin-api": "0.3.11", - "@remixproject/plugin-utils": "0.3.11", + "@remixproject/plugin-api": "0.3.16", + "@remixproject/plugin-utils": "0.3.16", "events": "3.2.0" }, "dependencies": { + "@remixproject/plugin-api": { + "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@remixproject/plugin-api/-/plugin-api-0.3.16.tgz", + "integrity": "sha512-PuSo6GGjKXwCZr3KjCrqGxLF2sZJFpueb9cjwLeAi1y9C4VoPRjWFIC6bESn1EVL9DyqcET7a8IwuqhHVGOGSQ==", + "requires": { + "@remixproject/plugin-utils": "0.3.16" + } + }, + "@remixproject/plugin-utils": { + "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@remixproject/plugin-utils/-/plugin-utils-0.3.16.tgz", + "integrity": "sha512-3zV1zdpkdgT4/fa4s4a3KdcZFpHR0a2ye5BMDRZZr0fZeGBaL9B7Lh52wvQuRJ384E60xwqjMytZLmi3qvL5SA==", + "requires": { + "tslib": "2.0.1" + } + }, "events": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/events/-/events-3.2.0.tgz", "integrity": "sha512-/46HWwbfCX2xTawVfkKLGxMifJYQBWMwY1mjywRtb4c9x8l5NP3KoJtnIOiL1hfdRkIuYhETxQlo62IF8tcnlg==" + }, + "tslib": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", + "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==" } } }, "@remixproject/plugin-api": { - "version": "0.3.11", - "resolved": "https://registry.npmjs.org/@remixproject/plugin-api/-/plugin-api-0.3.11.tgz", - "integrity": "sha512-hH9XJVkpqWAST4iVbm5erWOW6pxt70fbhY/kkcC6DuGO4wmcN16bwhIUDenMEOyTQiuHIM98kEZMiacKtPKmzg==", + "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@remixproject/plugin-api/-/plugin-api-0.3.16.tgz", + "integrity": "sha512-PuSo6GGjKXwCZr3KjCrqGxLF2sZJFpueb9cjwLeAi1y9C4VoPRjWFIC6bESn1EVL9DyqcET7a8IwuqhHVGOGSQ==", "requires": { - "@remixproject/plugin-utils": "0.3.11" + "@remixproject/plugin-utils": "0.3.16" + }, + "dependencies": { + "@remixproject/plugin-utils": { + "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@remixproject/plugin-utils/-/plugin-utils-0.3.16.tgz", + "integrity": "sha512-3zV1zdpkdgT4/fa4s4a3KdcZFpHR0a2ye5BMDRZZr0fZeGBaL9B7Lh52wvQuRJ384E60xwqjMytZLmi3qvL5SA==", + "requires": { + "tslib": "2.0.1" + } + }, + "tslib": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", + "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==" + } } }, "@remixproject/plugin-utils": { - "version": "0.3.11", - "resolved": "https://registry.npmjs.org/@remixproject/plugin-utils/-/plugin-utils-0.3.11.tgz", - "integrity": "sha512-dSO/WV1zJOXsbGiY99Hx8ewh5Whhul+Z2KyI2xFPCJTKkYLXntgFv7CuHvY2c7X2SBLDenqp6dh3yDGQcTlbxQ==", + "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@remixproject/plugin-utils/-/plugin-utils-0.3.16.tgz", + "integrity": "sha512-3zV1zdpkdgT4/fa4s4a3KdcZFpHR0a2ye5BMDRZZr0fZeGBaL9B7Lh52wvQuRJ384E60xwqjMytZLmi3qvL5SA==", "requires": { "tslib": "2.0.1" }, @@ -7697,23 +7756,39 @@ } }, "@remixproject/plugin-webview": { - "version": "0.3.11", - "resolved": "https://registry.npmjs.org/@remixproject/plugin-webview/-/plugin-webview-0.3.11.tgz", - "integrity": "sha512-lrZNtH1MCshF3wMU997Xn6UNWkIgmmZaXhxgxlB7S2S01IWlWd+5z6fZBmXcWGJwld424gRzbNm3IkPwAml9yw==", + "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@remixproject/plugin-webview/-/plugin-webview-0.3.16.tgz", + "integrity": "sha512-k//rLFsmDTiDCWzXsxGFBXE+KFDMdZtITQMCsf6sARfSc1SWLZ8+iwFCg9zve10lUEyc0CASdzpaWfITxw2ajQ==", "requires": { - "@remixproject/plugin": "0.3.11", - "@remixproject/plugin-api": "0.3.11", - "@remixproject/plugin-utils": "0.3.11" + "@remixproject/plugin": "0.3.16", + "@remixproject/plugin-api": "0.3.16", + "@remixproject/plugin-utils": "0.3.16", + "axios": "^0.21.1" + }, + "dependencies": { + "@remixproject/plugin-utils": { + "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@remixproject/plugin-utils/-/plugin-utils-0.3.16.tgz", + "integrity": "sha512-3zV1zdpkdgT4/fa4s4a3KdcZFpHR0a2ye5BMDRZZr0fZeGBaL9B7Lh52wvQuRJ384E60xwqjMytZLmi3qvL5SA==", + "requires": { + "tslib": "2.0.1" + } + }, + "tslib": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", + "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==" + } } }, "@remixproject/plugin-ws": { - "version": "0.3.11", - "resolved": "https://registry.npmjs.org/@remixproject/plugin-ws/-/plugin-ws-0.3.11.tgz", - "integrity": "sha512-0b4tDisv8zBRS1vdTsr2Jm04xIXeofmCB63iknLa7nf9oG9SizQbxP6V3AhVnVTU91r+YvoBI7B6a3KP7G1UuQ==", + "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@remixproject/plugin-ws/-/plugin-ws-0.3.16.tgz", + "integrity": "sha512-J8B21v5rRIGCY/KjuJzYQEtMUSCQhWDVlUrqWlqIAIJp+4+E8lNuPycMXhOXSCEJfgVaGvjxb/AmJMH4Jmqw/w==", "requires": { - "@remixproject/plugin": "0.3.11", - "@remixproject/plugin-api": "0.3.11", - "@remixproject/plugin-utils": "0.3.11" + "@remixproject/plugin": "0.3.16", + "@remixproject/plugin-api": "0.3.16", + "@remixproject/plugin-utils": "0.3.16" } }, "@restart/context": { diff --git a/package.json b/package.json index 0e3b262c5e..63d6f0aac1 100644 --- a/package.json +++ b/package.json @@ -134,13 +134,13 @@ "@ethereumjs/common": "^2.2.0", "@ethereumjs/tx": "^3.1.3", "@ethereumjs/vm": "^5.3.2", - "@remixproject/engine": "^0.3.11", - "@remixproject/engine-web": "^0.3.11", - "@remixproject/plugin": "^0.3.11", - "@remixproject/plugin-api": "^0.3.11", - "@remixproject/plugin-utils": "^0.3.11", - "@remixproject/plugin-webview": "^0.3.11", - "@remixproject/plugin-ws": "^0.3.11", + "@remixproject/engine": "^0.3.16", + "@remixproject/engine-web": "^0.3.16", + "@remixproject/plugin": "^0.3.16", + "@remixproject/plugin-api": "^0.3.16", + "@remixproject/plugin-utils": "^0.3.16", + "@remixproject/plugin-webview": "^0.3.16", + "@remixproject/plugin-ws": "^0.3.16", "ansi-gray": "^0.1.1", "async": "^2.6.2", "axios": ">=0.21.1", @@ -159,7 +159,6 @@ "isbinaryfile": "^3.0.2", "jquery": "^3.3.1", "jszip": "^3.6.0", - "lodash": "^4.17.21", "latest-version": "^5.1.0", "lodash": "^4.17.21", "merge": "^1.2.0",