Merge branch 'master' into intl

pull/5370/head
drafish 2 years ago
commit 30e7f1b637
  1. 8
      apps/remix-ide-e2e/src/tests/remixd.test.ts
  2. 8
      apps/remix-ide/src/app/files/foundry-handle.js
  3. 8
      apps/remix-ide/src/app/files/git-handle.js
  4. 8
      apps/remix-ide/src/app/files/hardhat-handle.js
  5. 8
      apps/remix-ide/src/app/files/slither-handle.js
  6. 9
      apps/remix-ide/src/app/files/truffle-handle.js
  7. 72
      apps/remix-ide/src/app/plugins/remixd-handle.tsx
  8. 1
      libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx
  9. 3
      libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx
  10. 8
      libs/remixd/src/services/foundryClient.ts
  11. 9
      libs/remixd/src/services/hardhatClient.ts
  12. 6
      libs/remixd/src/services/truffleClient.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)) writeFileSync('./apps/remix-ide/contracts/hardhat/artifacts/contracts/Lock.sol/Lock.dbg.json', JSON.stringify(hardhat_compilation_Lock_dbg))
done() 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') browser.clickLaunchIcon('filePanel')
.openFile('contracts') .openFile('contracts')
@ -186,7 +186,7 @@ module.exports = {
console.log('working directory', process.cwd()) console.log('working directory', process.cwd())
connectRemixd(browser, done) 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') browser.clickLaunchIcon('filePanel')
.openFile('contracts') .openFile('contracts')
@ -210,7 +210,7 @@ module.exports = {
writeFileSync('./apps/remix-ide/contracts/foundry/out/Counter.sol/Counter.json', JSON.stringify(foundryCompilation)) writeFileSync('./apps/remix-ide/contracts/foundry/out/Counter.sol/Counter.json', JSON.stringify(foundryCompilation))
done() 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 let contractAaddress
browser.clickLaunchIcon('filePanel') browser.clickLaunchIcon('filePanel')
@ -245,7 +245,7 @@ module.exports = {
writeFileSync('./apps/remix-ide/contracts/truffle/build/contracts/Migrations.json', JSON.stringify(truffle_compilation)) writeFileSync('./apps/remix-ide/contracts/truffle/build/contracts/Migrations.json', JSON.stringify(truffle_compilation))
done() 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') browser.clickLaunchIcon('filePanel')
.openFile('contracts') .openFile('contracts')

@ -15,4 +15,12 @@ export class FoundryHandle extends WebsocketPlugin {
constructor () { constructor () {
super(profile) 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)
}
} }

@ -15,4 +15,12 @@ export class GitHandle extends WebsocketPlugin {
constructor () { constructor () {
super(profile) 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)
}
} }

@ -15,4 +15,12 @@ export class HardhatHandle extends WebsocketPlugin {
constructor () { constructor () {
super(profile) 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)
}
} }

@ -16,4 +16,12 @@ export class SlitherHandle extends WebsocketPlugin {
constructor () { constructor () {
super(profile) 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)
}
} }

@ -15,4 +15,13 @@ export class TruffleHandle extends WebsocketPlugin {
constructor () { constructor () {
super(profile) 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)
}
} }

@ -35,16 +35,18 @@ export class RemixdHandle extends WebsocketPlugin {
localhostProvider: any localhostProvider: any
appManager: PluginManager appManager: PluginManager
dependentPlugins: Array<string> dependentPlugins: Array<string>
constructor (localhostProvider, appManager) { constructor(localhostProvider, appManager) {
super(profile) super(profile)
this.localhostProvider = localhostProvider this.localhostProvider = localhostProvider
this.appManager = appManager this.appManager = appManager
this.dependentPlugins = ['hardhat', 'truffle', 'slither', 'foundry'] this.dependentPlugins = ['hardhat', 'truffle', 'slither', 'foundry']
} }
async deactivate () { async deactivate() {
for (const plugin of this.dependentPlugins) { 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() if (super.socket) super.deactivate()
// this.appManager.deactivatePlugin('git') // plugin call doesn't work.. see issue https://github.com/ethereum/remix-plugin/issues/342 // 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() this.connectToLocalhost()
return true return true
} }
async canceled () { async canceled() {
for (const plugin of this.dependentPlugins) { 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') 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 * @param {String} txHash - hash of the transaction
*/ */
async connectToLocalhost () { async connectToLocalhost() {
const connection = async (error?:any) => { const connection = async (error?: any) => {
if (error) { if (error) {
console.log(error) console.log(error)
const alert:AlertModal = { const alert: AlertModal = {
id: 'connectionAlert', id: 'connectionAlert',
message: 'Cannot connect to the remixd daemon. Please make sure you have the remixd running in the background.' 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(() => { const intervalId = setInterval(() => {
if (!this.socket || (this.socket && this.socket.readyState === 3)) { // 3 means connection closed if (!this.socket || (this.socket && this.socket.readyState === 3)) { // 3 means connection closed
clearInterval(intervalId) clearInterval(intervalId)
const alert:AlertModal = { const alert: AlertModal = {
id: 'connectionAlert', id: 'connectionAlert',
message: 'Connection to remixd terminated. Please make sure remixd is still running in the background.' 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() this.deactivate()
} else if (!isElectron()) { } else if (!isElectron()) {
// warn the user only if he/she is in the browser context // warn the user only if he/she is in the browser context
const mod:AppModal = { const mod: AppModal = {
id: 'remixdConnect', id: 'remixdConnect',
title: 'Connect to localhost', title: 'Connect to localhost',
message: remixdDialog(), message: remixdDialog(),
okLabel: 'Connect', okLabel: 'Connect',
cancelLabel: 'Cancel', cancelLabel: 'Cancel',
} }
const result = await this.call('notification', 'modal', mod) const result = await this.call('notification', 'modal', mod)
if(result) { if (result) {
try { try {
this.localhostProvider.preInit() this.localhostProvider.preInit()
super.activate() super.activate()
setTimeout(() => { setTimeout(() => {
if (!this.socket || (this.socket && this.socket.readyState === 3)) { // 3 means connection closed if (!this.socket || (this.socket && this.socket.readyState === 3)) { // 3 means connection closed
connection(new Error('Connection with daemon failed.')) connection(new Error('Connection with daemon failed.'))
} else { } else {
connection() connection()
} }
}, 3000) }, 3000)
} catch (error) { } catch (error) {
connection(error) connection(error)
} }
} }
else { else {
await this.canceled() await this.canceled()
@ -142,7 +156,7 @@ export class RemixdHandle extends WebsocketPlugin {
} }
} }
function remixdDialog () { function remixdDialog() {
const commandText = 'remixd' const commandText = 'remixd'
const fullCommandText = 'remixd -s <path-to-the-shared-folder> -u <remix-ide-instance-URL>' const fullCommandText = 'remixd -s <path-to-the-shared-folder> -u <remix-ide-instance-URL>'
return (<> return (<>
@ -155,13 +169,13 @@ function remixdDialog () {
</div> </div>
<div className='mb-2 text-break'> <div className='mb-2 text-break'>
The remixd command is: The remixd command is:
<br/><b>{commandText}</b> <br /><b>{commandText}</b>
</div> </div>
<div className='mb-2 text-break'> <div className='mb-2 text-break'>
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 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
</div> </div>
<div className='mb-2 text-break'> <div className='mb-2 text-break'>
Example command with flags: <br/> Example command with flags: <br />
<b>{fullCommandText}</b> <b>{fullCommandText}</b>
</div> </div>
<div className='mb-2 text-break'> <div className='mb-2 text-break'>

@ -254,7 +254,6 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
}> }>
<button className="btn d-flex py-0" onClick={_ => props.syncContracts()}> <button className="btn d-flex py-0" onClick={_ => props.syncContracts()}>
<i style={{ cursor: 'pointer' }} className="fa fa-refresh mr-2 mt-2" aria-hidden="true"></i> <i style={{ cursor: 'pointer' }} className="fa fa-refresh mr-2 mt-2" aria-hidden="true"></i>
<label data-id="" className="mt-2">HardHat</label>
</button> </button>
</OverlayTrigger> </OverlayTrigger>
</div> </div>

@ -5,6 +5,7 @@ import React, { useState, useRef, useEffect, useReducer } from 'react' // eslint
import { OverlayTrigger, Tooltip } from 'react-bootstrap' // eslint-disable-line import { OverlayTrigger, Tooltip } from 'react-bootstrap' // eslint-disable-line
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs' import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'
import './remix-ui-tabs.css' import './remix-ui-tabs.css'
const _paq = window._paq = window._paq || []
/* eslint-disable-next-line */ /* eslint-disable-next-line */
export interface TabsUIProps { export interface TabsUIProps {
@ -152,8 +153,10 @@ export const TabsUI = (props: TabsUIProps) => {
const content = await props.plugin.call('fileManager', "readFile", path) const content = await props.plugin.call('fileManager', "readFile", path)
if (tabsState.currentExt === 'js' || tabsState.currentExt === 'ts') { if (tabsState.currentExt === 'js' || tabsState.currentExt === 'ts') {
await props.plugin.call('scriptRunner', 'execute', content) await props.plugin.call('scriptRunner', 'execute', content)
_paq.push(['trackEvent', 'editor', 'clickRunFromEditor', tabsState.currentExt])
} else if (tabsState.currentExt === 'sol' || tabsState.currentExt === 'yul') { } else if (tabsState.currentExt === 'sol' || tabsState.currentExt === 'yul') {
await props.plugin.call('solidity', 'compile', path) await props.plugin.call('solidity', 'compile', path)
_paq.push(['trackEvent', 'editor', 'clickRunFromEditor', tabsState.currentExt])
} }
}} }}
> >

@ -36,7 +36,7 @@ export class FoundryClient extends PluginClient {
compile (configPath: string) { compile (configPath: string) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.readOnly) { 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)) return reject(new Error(errMsg))
} }
const cmd = `forge build` const cmd = `forge build`
@ -79,7 +79,7 @@ export class FoundryClient extends PluginClient {
} }
if (!this.warnlog) { if (!this.warnlog) {
// @ts-ignore // @ts-ignore
this.call('terminal', 'log', 'receiving compilation result from foundry') this.call('terminal', 'log', 'receiving compilation result from Foundry')
this.warnlog = true this.warnlog = true
} }
} }
@ -145,9 +145,9 @@ export class FoundryClient extends PluginClient {
} }
async sync () { async sync () {
console.log('syncing from foundry') console.log('syncing from Foundry')
this.processArtifact() this.processArtifact()
// @ts-ignore // @ts-ignore
this.call('terminal', 'log', 'synced with foundry') this.call('terminal', 'log', 'synced with Foundry')
} }
} }

@ -68,7 +68,6 @@ export class HardhatClient extends PluginClient {
const contractFilePath = join(this.buildPath, file) const contractFilePath = join(this.buildPath, file)
const stat = await fs.stat(contractFilePath) const stat = await fs.stat(contractFilePath)
if (!stat.isDirectory()) continue if (!stat.isDirectory()) continue
console.log('pp ', contractFilePath)
const files = await fs.readdir(contractFilePath) const files = await fs.readdir(contractFilePath)
const compilationResult = { const compilationResult = {
input: {}, input: {},
@ -89,7 +88,7 @@ export class HardhatClient extends PluginClient {
compilationResult.target = jsonStd.sourceName compilationResult.target = jsonStd.sourceName
// this is the full compilation result // 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 path = join(contractFilePath, jsonDbg.buildInfo)
const content = await fs.readFile(path, { encoding: 'utf-8' }) const content = await fs.readFile(path, { encoding: 'utf-8' })
@ -102,7 +101,7 @@ export class HardhatClient extends PluginClient {
} }
if (!this.warnLog) { if (!this.warnLog) {
// @ts-ignore // @ts-ignore
this.call('terminal', 'log', 'receiving compilation result from hardhat') this.call('terminal', 'log', 'receiving compilation result from Hardhat')
this.warnLog = true this.warnLog = true
} }
} }
@ -121,10 +120,10 @@ export class HardhatClient extends PluginClient {
} }
async sync () { async sync () {
console.log('syncing from hardhat') console.log('syncing from Hardhat')
this.processArtifact() this.processArtifact()
// @ts-ignore // @ts-ignore
this.call('terminal', 'log', 'synced with hardhat') this.call('terminal', 'log', 'synced with Hardhat')
} }
async feedContractArtifactFile (artifactContent, compilationResultPart) { async feedContractArtifactFile (artifactContent, compilationResultPart) {

@ -82,7 +82,7 @@ export class TruffleClient extends PluginClient {
} }
if (!this.warnLog) { if (!this.warnLog) {
// @ts-ignore // @ts-ignore
this.call('terminal', 'log', 'receiving compilation result from truffle') this.call('terminal', 'log', 'receiving compilation result from Truffle')
this.warnLog = true this.warnLog = true
} }
} }
@ -137,9 +137,9 @@ export class TruffleClient extends PluginClient {
} }
async sync () { async sync () {
console.log('syncing from truffle') console.log('syncing from Truffle')
this.processArtifact() this.processArtifact()
// @ts-ignore // @ts-ignore
this.call('terminal', 'log', 'synced with truffle') this.call('terminal', 'log', 'synced with Truffle')
} }
} }

Loading…
Cancel
Save