diff --git a/apps/remix-ide-e2e/src/tests/remixd.test.ts b/apps/remix-ide-e2e/src/tests/remixd.test.ts index eafa9d870c..fb881e28e9 100644 --- a/apps/remix-ide-e2e/src/tests/remixd.test.ts +++ b/apps/remix-ide-e2e/src/tests/remixd.test.ts @@ -158,7 +158,7 @@ module.exports = { writeFileSync('./apps/remix-ide/contracts/hardhat/artifacts/contracts/Lock.sol/Lock.dbg.json', JSON.stringify(hardhat_compilation_Lock_dbg)) done() }) - .expect.element('*[data-id="terminalJournal"]').text.to.contain('receiving compilation result from hardhat').before(60000) + .expect.element('*[data-id="terminalJournal"]').text.to.contain('receiving compilation result from Hardhat').before(60000) browser.clickLaunchIcon('filePanel') .openFile('contracts') @@ -186,7 +186,7 @@ module.exports = { console.log('working directory', process.cwd()) connectRemixd(browser, done) }) - .expect.element('*[data-id="terminalJournal"]').text.to.contain('receiving compilation result from hardhat').before(60000) + .expect.element('*[data-id="terminalJournal"]').text.to.contain('receiving compilation result from Hardhat').before(60000) browser.clickLaunchIcon('filePanel') .openFile('contracts') @@ -210,7 +210,7 @@ module.exports = { writeFileSync('./apps/remix-ide/contracts/foundry/out/Counter.sol/Counter.json', JSON.stringify(foundryCompilation)) done() }) - .expect.element('*[data-id="terminalJournal"]').text.to.contain('receiving compilation result from foundry').before(60000) + .expect.element('*[data-id="terminalJournal"]').text.to.contain('receiving compilation result from Foundry').before(60000) let contractAaddress browser.clickLaunchIcon('filePanel') @@ -245,7 +245,7 @@ module.exports = { writeFileSync('./apps/remix-ide/contracts/truffle/build/contracts/Migrations.json', JSON.stringify(truffle_compilation)) done() }) - .expect.element('*[data-id="terminalJournal"]').text.to.contain('receiving compilation result from truffle').before(60000) + .expect.element('*[data-id="terminalJournal"]').text.to.contain('receiving compilation result from Truffle').before(60000) browser.clickLaunchIcon('filePanel') .openFile('contracts') diff --git a/apps/remix-ide/src/app/files/foundry-handle.js b/apps/remix-ide/src/app/files/foundry-handle.js index cf20f03e79..94efd7b04b 100644 --- a/apps/remix-ide/src/app/files/foundry-handle.js +++ b/apps/remix-ide/src/app/files/foundry-handle.js @@ -15,4 +15,12 @@ export class FoundryHandle extends WebsocketPlugin { constructor () { super(profile) } + + callPluginMethod(key, payload = []) { + if (this.socket.readyState !== this.socket.OPEN) { + console.log(`${this.profile.name} connection is not opened.`) + return false + } + return super.callPluginMethod(key, payload) + } } diff --git a/apps/remix-ide/src/app/files/git-handle.js b/apps/remix-ide/src/app/files/git-handle.js index a935068679..596bf77015 100644 --- a/apps/remix-ide/src/app/files/git-handle.js +++ b/apps/remix-ide/src/app/files/git-handle.js @@ -15,4 +15,12 @@ export class GitHandle extends WebsocketPlugin { constructor () { super(profile) } + + callPluginMethod(key, payload = []) { + if (this.socket.readyState !== this.socket.OPEN) { + console.log(`${this.profile.name} connection is not opened.`) + return false + } + return super.callPluginMethod(key, payload) + } } diff --git a/apps/remix-ide/src/app/files/hardhat-handle.js b/apps/remix-ide/src/app/files/hardhat-handle.js index 7b64f489dc..84a2c1d28a 100644 --- a/apps/remix-ide/src/app/files/hardhat-handle.js +++ b/apps/remix-ide/src/app/files/hardhat-handle.js @@ -15,4 +15,12 @@ export class HardhatHandle extends WebsocketPlugin { constructor () { super(profile) } + + callPluginMethod(key, payload = []) { + if (this.socket.readyState !== this.socket.OPEN) { + console.log(`${this.profile.name} connection is not opened.`) + return false + } + return super.callPluginMethod(key, payload) + } } diff --git a/apps/remix-ide/src/app/files/slither-handle.js b/apps/remix-ide/src/app/files/slither-handle.js index 9604202d7e..27c7b3cbd8 100644 --- a/apps/remix-ide/src/app/files/slither-handle.js +++ b/apps/remix-ide/src/app/files/slither-handle.js @@ -16,4 +16,12 @@ export class SlitherHandle extends WebsocketPlugin { constructor () { super(profile) } + + callPluginMethod(key, payload = []) { + if (this.socket.readyState !== this.socket.OPEN) { + console.log(`${this.profile.name} connection is not opened.`) + return false + } + return super.callPluginMethod(key, payload) + } } diff --git a/apps/remix-ide/src/app/files/truffle-handle.js b/apps/remix-ide/src/app/files/truffle-handle.js index bdeed78592..1111cba60d 100644 --- a/apps/remix-ide/src/app/files/truffle-handle.js +++ b/apps/remix-ide/src/app/files/truffle-handle.js @@ -15,4 +15,13 @@ export class TruffleHandle extends WebsocketPlugin { constructor () { super(profile) } + + callPluginMethod(key, payload = []) { + if (this.socket.readyState !== this.socket.OPEN) { + console.log(`${this.profile.name} connection is not opened.`) + return false + } + return super.callPluginMethod(key, payload) + } + } diff --git a/apps/remix-ide/src/app/plugins/remixd-handle.tsx b/apps/remix-ide/src/app/plugins/remixd-handle.tsx index 2798427185..35353d774d 100644 --- a/apps/remix-ide/src/app/plugins/remixd-handle.tsx +++ b/apps/remix-ide/src/app/plugins/remixd-handle.tsx @@ -35,16 +35,18 @@ export class RemixdHandle extends WebsocketPlugin { localhostProvider: any appManager: PluginManager dependentPlugins: Array - constructor (localhostProvider, appManager) { + constructor(localhostProvider, appManager) { super(profile) this.localhostProvider = localhostProvider this.appManager = appManager this.dependentPlugins = ['hardhat', 'truffle', 'slither', 'foundry'] } - async deactivate () { + async deactivate() { for (const plugin of this.dependentPlugins) { - await this.appManager.deactivatePlugin(plugin) + if (await this.appManager.isActive(plugin)) { + await this.appManager.deactivatePlugin(plugin) + } } if (super.socket) super.deactivate() // this.appManager.deactivatePlugin('git') // plugin call doesn't work.. see issue https://github.com/ethereum/remix-plugin/issues/342 @@ -53,16 +55,28 @@ export class RemixdHandle extends WebsocketPlugin { }) } - async activate () { + async activate() { this.connectToLocalhost() return true } - async canceled () { + async canceled() { for (const plugin of this.dependentPlugins) { - await this.appManager.deactivatePlugin(plugin) + if (await this.appManager.isActive(plugin)) { + await this.appManager.deactivatePlugin(plugin) + } } + await this.appManager.deactivatePlugin('remixd') + + } + + async callPluginMethod(key: string, payload?: any[]) { + if (this.socket.readyState !== this.socket.OPEN) { + console.log(`${this.profile.name} connection is not opened.`) + return false + } + return super.callPluginMethod(key, payload) } /** @@ -71,11 +85,11 @@ export class RemixdHandle extends WebsocketPlugin { * * @param {String} txHash - hash of the transaction */ - async connectToLocalhost () { - const connection = async (error?:any) => { + async connectToLocalhost() { + const connection = async (error?: any) => { if (error) { console.log(error) - const alert:AlertModal = { + const alert: AlertModal = { id: 'connectionAlert', message: 'Cannot connect to the remixd daemon. Please make sure you have the remixd running in the background.' } @@ -85,7 +99,7 @@ export class RemixdHandle extends WebsocketPlugin { const intervalId = setInterval(() => { if (!this.socket || (this.socket && this.socket.readyState === 3)) { // 3 means connection closed clearInterval(intervalId) - const alert:AlertModal = { + const alert: AlertModal = { id: 'connectionAlert', message: 'Connection to remixd terminated. Please make sure remixd is still running in the background.' } @@ -105,28 +119,28 @@ export class RemixdHandle extends WebsocketPlugin { this.deactivate() } else if (!isElectron()) { // warn the user only if he/she is in the browser context - const mod:AppModal = { + const mod: AppModal = { id: 'remixdConnect', title: 'Connect to localhost', message: remixdDialog(), okLabel: 'Connect', cancelLabel: 'Cancel', } - const result = await this.call('notification', 'modal', mod) - if(result) { - try { - this.localhostProvider.preInit() - super.activate() - setTimeout(() => { - if (!this.socket || (this.socket && this.socket.readyState === 3)) { // 3 means connection closed - connection(new Error('Connection with daemon failed.')) - } else { - connection() - } - }, 3000) - } catch (error) { - connection(error) - } + const result = await this.call('notification', 'modal', mod) + if (result) { + try { + this.localhostProvider.preInit() + super.activate() + setTimeout(() => { + if (!this.socket || (this.socket && this.socket.readyState === 3)) { // 3 means connection closed + connection(new Error('Connection with daemon failed.')) + } else { + connection() + } + }, 3000) + } catch (error) { + connection(error) + } } else { await this.canceled() @@ -142,7 +156,7 @@ export class RemixdHandle extends WebsocketPlugin { } } -function remixdDialog () { +function remixdDialog() { const commandText = 'remixd' const fullCommandText = 'remixd -s -u ' return (<> @@ -155,13 +169,13 @@ function remixdDialog () {
The remixd command is: -
{commandText} +
{commandText}
The remixd command without options uses the terminal's current directory as the shared directory and the shared Remix domain can only be https://remix.ethereum.org, https://remix-alpha.ethereum.org, or https://remix-beta.ethereum.org
- Example command with flags:
+ Example command with flags:
{fullCommandText}
diff --git a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx index c61e965df9..0ef62ae190 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx @@ -254,7 +254,6 @@ export function ContractDropdownUI (props: ContractDropdownProps) { }>
diff --git a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx index 4bca319f0e..07f66efff3 100644 --- a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx +++ b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx @@ -5,6 +5,7 @@ import React, { useState, useRef, useEffect, useReducer } from 'react' // eslint import { OverlayTrigger, Tooltip } from 'react-bootstrap' // eslint-disable-line import { Tab, Tabs, TabList, TabPanel } from 'react-tabs' import './remix-ui-tabs.css' +const _paq = window._paq = window._paq || [] /* eslint-disable-next-line */ export interface TabsUIProps { @@ -152,8 +153,10 @@ export const TabsUI = (props: TabsUIProps) => { const content = await props.plugin.call('fileManager', "readFile", path) if (tabsState.currentExt === 'js' || tabsState.currentExt === 'ts') { await props.plugin.call('scriptRunner', 'execute', content) + _paq.push(['trackEvent', 'editor', 'clickRunFromEditor', tabsState.currentExt]) } else if (tabsState.currentExt === 'sol' || tabsState.currentExt === 'yul') { await props.plugin.call('solidity', 'compile', path) + _paq.push(['trackEvent', 'editor', 'clickRunFromEditor', tabsState.currentExt]) } }} > diff --git a/libs/remixd/src/services/foundryClient.ts b/libs/remixd/src/services/foundryClient.ts index 153b9709ec..3eb55803e1 100644 --- a/libs/remixd/src/services/foundryClient.ts +++ b/libs/remixd/src/services/foundryClient.ts @@ -36,7 +36,7 @@ export class FoundryClient extends PluginClient { compile (configPath: string) { return new Promise((resolve, reject) => { if (this.readOnly) { - const errMsg = '[Hardhat Compilation]: Cannot compile in read-only mode' + const errMsg = '[Foundry Compilation]: Cannot compile in read-only mode' return reject(new Error(errMsg)) } const cmd = `forge build` @@ -79,7 +79,7 @@ export class FoundryClient extends PluginClient { } if (!this.warnlog) { // @ts-ignore - this.call('terminal', 'log', 'receiving compilation result from foundry') + this.call('terminal', 'log', 'receiving compilation result from Foundry') this.warnlog = true } } @@ -145,9 +145,9 @@ export class FoundryClient extends PluginClient { } async sync () { - console.log('syncing from foundry') + console.log('syncing from Foundry') this.processArtifact() // @ts-ignore - this.call('terminal', 'log', 'synced with foundry') + this.call('terminal', 'log', 'synced with Foundry') } } diff --git a/libs/remixd/src/services/hardhatClient.ts b/libs/remixd/src/services/hardhatClient.ts index 9b8f8900ee..5468700dcb 100644 --- a/libs/remixd/src/services/hardhatClient.ts +++ b/libs/remixd/src/services/hardhatClient.ts @@ -68,7 +68,6 @@ export class HardhatClient extends PluginClient { const contractFilePath = join(this.buildPath, file) const stat = await fs.stat(contractFilePath) if (!stat.isDirectory()) continue - console.log('pp ', contractFilePath) const files = await fs.readdir(contractFilePath) const compilationResult = { input: {}, @@ -89,7 +88,7 @@ export class HardhatClient extends PluginClient { compilationResult.target = jsonStd.sourceName // this is the full compilation result - console.log('processing hardhat artifact', file) + console.log('Processing Hardhat artifact for file: ', file) const path = join(contractFilePath, jsonDbg.buildInfo) const content = await fs.readFile(path, { encoding: 'utf-8' }) @@ -102,7 +101,7 @@ export class HardhatClient extends PluginClient { } if (!this.warnLog) { // @ts-ignore - this.call('terminal', 'log', 'receiving compilation result from hardhat') + this.call('terminal', 'log', 'receiving compilation result from Hardhat') this.warnLog = true } } @@ -121,10 +120,10 @@ export class HardhatClient extends PluginClient { } async sync () { - console.log('syncing from hardhat') + console.log('syncing from Hardhat') this.processArtifact() // @ts-ignore - this.call('terminal', 'log', 'synced with hardhat') + this.call('terminal', 'log', 'synced with Hardhat') } async feedContractArtifactFile (artifactContent, compilationResultPart) { diff --git a/libs/remixd/src/services/truffleClient.ts b/libs/remixd/src/services/truffleClient.ts index e315763876..794aac13c6 100644 --- a/libs/remixd/src/services/truffleClient.ts +++ b/libs/remixd/src/services/truffleClient.ts @@ -82,7 +82,7 @@ export class TruffleClient extends PluginClient { } if (!this.warnLog) { // @ts-ignore - this.call('terminal', 'log', 'receiving compilation result from truffle') + this.call('terminal', 'log', 'receiving compilation result from Truffle') this.warnLog = true } } @@ -137,9 +137,9 @@ export class TruffleClient extends PluginClient { } async sync () { - console.log('syncing from truffle') + console.log('syncing from Truffle') this.processArtifact() // @ts-ignore - this.call('terminal', 'log', 'synced with truffle') + this.call('terminal', 'log', 'synced with Truffle') } }