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))
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')

@ -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)
}
}

@ -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)
}
}

@ -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)
}
}

@ -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)
}
}

@ -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)
}
}

@ -35,16 +35,18 @@ export class RemixdHandle extends WebsocketPlugin {
localhostProvider: any
appManager: PluginManager
dependentPlugins: Array<string>
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 <path-to-the-shared-folder> -u <remix-ide-instance-URL>'
return (<>
@ -155,13 +169,13 @@ function remixdDialog () {
</div>
<div className='mb-2 text-break'>
The remixd command is:
<br/><b>{commandText}</b>
<br /><b>{commandText}</b>
</div>
<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
</div>
<div className='mb-2 text-break'>
Example command with flags: <br/>
Example command with flags: <br />
<b>{fullCommandText}</b>
</div>
<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()}>
<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>
</OverlayTrigger>
</div>

@ -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])
}
}}
>

@ -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')
}
}

@ -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) {

@ -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')
}
}

Loading…
Cancel
Save