configt button

pull/5324/head
bunsenstraat 1 month ago
parent 12a51ef958
commit 462d7883b1
  1. 116
      apps/remix-ide-e2e/src/tests/script-runner.test.ts
  2. 1
      apps/remix-ide/src/app/tabs/locales/en/remixUiTabs.json
  3. 2
      libs/remix-ui/scriptrunner/src/lib/script-runner-ui.tsx
  4. 34
      libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx

@ -0,0 +1,116 @@
'use strict'
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://127.0.0.1:8080', false)
},
'Should load default script runner': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('scriptRunnerBridge')
.waitForElementVisible('[data-id="sr-loaded-default"]')
.waitForElementVisible('[data-id="dependency-ethers-^5"]')
.waitForElementVisible('[data-id="sr-toggle-ethers6"]')
},
'Should load script runner ethers6': function (browser: NightwatchBrowser) {
browser
.click('[data-id="sr-toggle-ethers6"]')
.waitForElementVisible('[data-id="sr-loaded-ethers6"]')
.waitForElementPresent('[data-id="dependency-ethers-^6"]')
},
'Should have config file in .remix/script.config.json': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('filePanel')
.waitForElementVisible('[data-path=".remix"]')
.waitForElementVisible('[data-id="treeViewDivDraggableItem.remix/script.config.json"]')
.openFile('.remix/script.config.json')
},
'check config file content': function (browser: NightwatchBrowser) {
browser
.getEditorValue((content) => {
console.log(JSON.parse(content))
const parsed = JSON.parse(content)
browser.assert.ok(parsed.defaultConfig === 'ethers6', 'config file content is correct')
})
},
'execute ethers6 script': function (browser: NightwatchBrowser) {
browser
.click('*[data-id="treeViewUltreeViewMenu"]') // make sure we create the file at the root folder
.addFile('deployWithEthersJs.js', { content: deployWithEthersJs })
.pause(1000)
.click('[data-id="treeViewDivtreeViewItemcontracts"]')
.openFile('contracts/2_Owner.sol')
.clickLaunchIcon('solidity')
.click('*[data-id="compilerContainerCompileBtn"]')
.executeScriptInTerminal('remix.execute(\'deployWithEthersJs.js\')')
.waitForElementContainsText('*[data-id="terminalJournal"]', '0xd9145CCE52D386f254917e481eB44e9943F39138', 60000)
},
'switch workspace it should be default again': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('filePanel')
.pause(2000)
.waitForElementVisible('*[data-id="workspacesMenuDropdown"]')
.click('*[data-id="workspacesMenuDropdown"]')
.click('*[data-id="workspacecreate"]')
.waitForElementPresent('*[data-id="create-semaphore"]')
.scrollAndClick('*[data-id="create-semaphore"]')
.modalFooterOKClick('TemplatesSelection')
.clickLaunchIcon('scriptRunnerBridge')
.waitForElementVisible('[data-id="sr-loaded-default"]')
.waitForElementVisible('[data-id="dependency-ethers-^5"]')
.waitForElementVisible('[data-id="sr-toggle-ethers6"]')
},
'switch to default workspace that should be on ethers6': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('filePanel')
.switchWorkspace('default_workspace')
.clickLaunchIcon('scriptRunnerBridge')
.waitForElementVisible('[data-id="sr-loaded-ethers6"]')
.waitForElementPresent('[data-id="dependency-ethers-^6"]')
}
}
const deployWithEthersJs = `
import { ethers } from 'ethers'
/**
* Deploy the given contract
* @param {string} contractName name of the contract to deploy
* @param {Array<any>} args list of constructor' parameters
* @param {Number} accountIndex account index from the exposed account
* @return {Contract} deployed contract
*
*/
const deploy = async (contractName: string, args: Array<any>, accountIndex?: number): Promise<ethers.Contract> => {
console.log(\`deploying \${contractName}\`)
// Note that the script needs the ABI which is generated from the compilation artifact.
// Make sure contract is compiled and artifacts are generated
const artifactsPath = \`contracts/artifacts/\${contractName}.json\` // Change this for different path
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath))
// 'web3Provider' is a remix global variable object
const signer = await (new ethers.BrowserProvider(web3Provider)).getSigner(accountIndex)
const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
const contract = await factory.deploy(...args)
// The contract is NOT deployed yet; we must wait until it is mined
await contract.waitForDeployment()
return contract
}
(async () => {
try {
const contract = await deploy('Owner', [])
console.log(\`address: \${await contract.getAddress()}\`)
} catch (e) {
console.log(e.message)
}
})()`

@ -7,6 +7,7 @@
"remixUiTabs.tooltipText6": "Enable RemixAI Copilot [BETA]",
"remixUiTabs.tooltipText7": "Disable RemixAI Copilot [BETA]",
"remixUiTabs.tooltipText8": "Remix AI Tools Documentation",
"remixUiTabs.tooltipText9": "Configure scripting dependencies",
"remixUiTabs.tooltipTextDisabledCopilot": "To use RemixAI Copilot, choose a .sol file",
"remixUiTabs.zoomOut": "Zoom out",
"remixUiTabs.zoomIn": "Zoom in"

@ -96,7 +96,7 @@ export const ScriptRunnerUI = (props: ScriptRunnerUIProps) => {
<p><strong>Dependencies:</strong></p>
<ul>
{config.dependencies.map((dep, depIndex) => (
<li key={depIndex}>
<li data-id={`dependency-${dep.name}-${dep.version}`} key={depIndex}>
<strong>{dep.name}</strong> (v{dep.version})
</li>
))}

@ -1,7 +1,7 @@
import { fileDecoration, FileDecorationIcons } from '@remix-ui/file-decorators'
import { CustomTooltip } from '@remix-ui/helper'
import { Plugin } from '@remixproject/engine'
import React, {useState, useRef, useEffect, useReducer} from 'react' // eslint-disable-line
import React, { useState, useRef, useEffect, useReducer } from 'react' // eslint-disable-line
import { FormattedMessage } from 'react-intl'
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'
import './remix-ui-tabs.css'
@ -86,10 +86,10 @@ export const TabsUI = (props: TabsUIProps) => {
}
}, [tabsState.selectedIndex])
const getAI = async() => {
const getAI = async () => {
try {
return await props.plugin.call('settings', 'getCopilotSetting')
} catch (e){
} catch (e) {
return false
}
}
@ -226,14 +226,32 @@ export const TabsUI = (props: TabsUIProps) => {
<i className="fas fa-play"></i>
</button>
</CustomTooltip>
{(tabsState.currentExt === 'ts' || tabsState.currentExt === 'js')
<div className= "d-flex border-left ml-2 align-items-center" style={{ height: "3em" }}>
&& <CustomTooltip
placement="bottom"
tooltipId="overlay-tooltip-run-script-config"
tooltipText={
<span>
<FormattedMessage id="remixUiTabs.tooltipText9" />
</span>
}><button
data-id="script-config"
className="btn text-dark border-left ml-2 pr-0 py-0 d-flex"
onClick={async () => {
props.plugin.call('menuicons', 'select', 'scriptRunnerBridge')
}}
>
<i className="fas fa-cogs"></i>
</button></CustomTooltip>
}
<div className="d-flex border-left ml-2 align-items-center" style={{ height: "3em" }}>
<CustomTooltip
placement="bottom"
tooltipId="overlay-tooltip-explaination"
tooltipText={
<span>
{tabsState.currentExt === 'sol'? (
{tabsState.currentExt === 'sol' ? (
<FormattedMessage id="remixUiTabs.tooltipText5" />
) : (
<FormattedMessage id="remixUiTabs.tooltipText4" />
@ -265,7 +283,7 @@ export const TabsUI = (props: TabsUIProps) => {
tooltipId="overlay-tooltip-copilot"
tooltipText={
<span>
{ tabsState.currentExt === 'sol'? (
{tabsState.currentExt === 'sol' ? (
!ai_switch ? (
<FormattedMessage id="remixUiTabs.tooltipText6" />
) : (<FormattedMessage id="remixUiTabs.tooltipText7" />)
@ -279,7 +297,7 @@ export const TabsUI = (props: TabsUIProps) => {
data-id="remix_ai_switch"
id='remix_ai_switch'
className="btn ai-switch text-ai pl-2 pr-0 py-0"
disabled={!(tabsState.currentExt === 'sol' )}
disabled={!(tabsState.currentExt === 'sol')}
onClick={async () => {
await props.plugin.call('settings', 'updateCopilotChoice', !ai_switch)
setAI_switch(!ai_switch)
@ -291,7 +309,7 @@ export const TabsUI = (props: TabsUIProps) => {
</CustomTooltip>
</div>
<div className= "d-flex border-left ml-2 align-items-center" style={{ height: "3em" }}>
<div className="d-flex border-left ml-2 align-items-center" style={{ height: "3em" }}>
<CustomTooltip placement="bottom" tooltipId="overlay-tooltip-zoom-out" tooltipText={<FormattedMessage id="remixUiTabs.zoomOut" />}>
<span data-id="tabProxyZoomOut" className="btn fas fa-search-minus text-dark pl-2 pr-0 py-0 d-flex" onClick={() => props.onZoomOut()}></span>
</CustomTooltip>

Loading…
Cancel
Save