Commit 067837b0 authored by bunsenstraat's avatar bunsenstraat

Merge branch 'master' of https://github.com/ethereum/remix-project into github

parents de240862 ce60f2d6
...@@ -425,13 +425,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org ...@@ -425,13 +425,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
} }
// CONTENT VIEWS & DEFAULT PLUGINS // CONTENT VIEWS & DEFAULT PLUGINS
const compileTab = new CompileTab( const compileTab = new CompileTab(registry.get('config').api, registry.get('filemanager').api)
editor,
registry.get('config').api,
registry.get('fileproviders/browser').api,
registry.get('filemanager').api,
contentImport
)
const run = new RunTab( const run = new RunTab(
blockchain, blockchain,
registry.get('config').api, registry.get('config').api,
...@@ -456,7 +450,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org ...@@ -456,7 +450,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
engine.register([ engine.register([
compileTab, compileTab,
compileTab.compileTabLogic,
run, run,
debug, debug,
analysis, analysis,
......
...@@ -22,7 +22,7 @@ const profile = { ...@@ -22,7 +22,7 @@ const profile = {
icon: 'assets/img/fileManager.webp', icon: 'assets/img/fileManager.webp',
permission: true, permission: true,
version: packageJson.version, version: packageJson.version,
methods: ['closeAllFiles', 'closeFile', 'file', 'exists', 'open', 'writeFile', 'readFile', 'copyFile', 'copyDir', 'rename', 'mkdir', 'readdir', 'remove', 'getCurrentFile', 'getFile', 'getFolder', 'setFile', 'switchFile', 'refresh', 'getProviderOf', 'getProviderByName', 'getPathFromUrl', 'getUrlFromPath'], methods: ['closeAllFiles', 'closeFile', 'file', 'exists', 'open', 'writeFile', 'readFile', 'copyFile', 'copyDir', 'rename', 'mkdir', 'readdir', 'remove', 'getCurrentFile', 'getFile', 'getFolder', 'setFile', 'switchFile', 'refresh', 'getProviderOf', 'getProviderByName', 'getPathFromUrl', 'getUrlFromPath', 'saveCurrentFile'],
kind: 'file-system' kind: 'file-system'
} }
const errorMsg = { const errorMsg = {
...@@ -398,7 +398,7 @@ class FileManager extends Plugin { ...@@ -398,7 +398,7 @@ class FileManager extends Plugin {
} }
fileChangedEvent (path) { fileChangedEvent (path) {
this.emit('currentFileChanged', path) this.emit('fileChanged', path)
} }
fileRenamedEvent (oldName, newName, isFolder) { fileRenamedEvent (oldName, newName, isFolder) {
......
This diff is collapsed.
const csjs = require('csjs-inject') const csjs = require('csjs-inject')
const css = csjs` const css = csjs`
.title { .compilerTabView {
font-size: 1.1em; padding: 2%;
font-weight: bold;
margin-bottom: 1em;
}
.panicError {
color: red;
font-size: 20px;
}
.crow {
display: flex;
overflow: auto;
clear: both;
padding: .2em;
}
.checkboxText {
font-weight: normal;
}
.crow label {
cursor:pointer;
}
.crowNoFlex {
overflow: auto;
clear: both;
}
.info {
padding: 10px;
word-break: break-word;
}
.contract {
display: block;
margin: 3% 0;
}
.nightlyBuilds {
display: flex;
flex-direction: row;
align-items: center;
}
.autocompileContainer {
display: flex;
align-items: center;
}
.runs {
width: 40%;
}
.hideWarningsContainer {
display: flex;
align-items: center;
}
.autocompile {}
.autocompileTitle {
font-weight: bold;
margin: 1% 0;
}
.autocompileText {
margin: 1% 0;
font-size: 12px;
overflow: hidden;
word-break: normal;
line-height: initial;
}
.warnCompilationSlow {
margin-left: 1%;
}
.compilerConfig {
display: flex;
align-items: center;
}
.compilerConfig label {
margin: 0;
}
.compilerSection {
padding: 12px 24px 16px;
}
.compilerLabel {
margin-bottom: 2px;
font-size: 11px;
line-height: 12px;
text-transform: uppercase;
}
.copyButton {
padding: 6px;
font-weight: bold;
font-size: 11px;
line-height: 15px;
}
.name {
display: flex;
}
.size {
display: flex;
}
.checkboxes {
display: flex;
width: 100%;
justify-content: space-between;
flex-wrap: wrap;
}
.compileButton {
width: 100%;
margin: 15px 0 10px 0;
font-size: 12px;
}
.container {
margin: 0;
margin-bottom: 2%;
}
.optimizeContainer {
display: flex;
}
.noContractAlert {
display: flex;
justify-content: center;
align-items: center;
}
.contractHelperButtons {
margin-top: 6px;
display: flex;
align-items: center;
justify-content: space-between;
float: right;
}
.copyToClipboard {
font-size: 1rem;
}
.copyIcon {
margin-right: 5px;
}
.log {
display: flex;
flex-direction: column;
margin-bottom: 5%;
overflow: visible;
}
.key {
margin-right: 5px;
text-transform: uppercase;
width: 100%;
}
.value {
display: flex;
width: 100%;
margin-top: 1.5%;
}
.questionMark {
margin-left: 2%;
cursor: pointer;
}
.questionMark:hover {
}
.detailsJSON {
padding: 8px 0;
border: none;
}
.icon {
margin-right: 0.3em;
}
.errorBlobs {
padding-left: 5px;
padding-right: 5px;
word-break: break-word;
}
.storageLogo {
width: 20px;
height: 20px;
}
.spinningIcon {
display: inline-block;
position: relative;
animation: spin 2s infinite linear;
-moz-animation: spin 2s infinite linear;
-o-animation: spin 2s infinite linear;
-webkit-animation: spin 2s infinite linear;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@-webkit-keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@-moz-keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@-o-keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@-ms-keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.bouncingIcon {
display: inline-block;
position: relative;
-moz-animation: bounce 2s infinite linear;
-o-animation: bounce 2s infinite linear;
-webkit-animation: bounce 2s infinite linear;
animation: bounce 2s infinite linear;
}
@-webkit-keyframes bounce {
0% { top: 0; }
50% { top: -0.2em; }
70% { top: -0.3em; }
100% { top: 0; }
}
@-moz-keyframes bounce {
0% { top: 0; }
50% { top: -0.2em; }
70% { top: -0.3em; }
100% { top: 0; }
}
@-o-keyframes bounce {
0% { top: 0; }
50% { top: -0.2em; }
70% { top: -0.3em; }
100% { top: 0; }
}
@-ms-keyframes bounce {
0% { top: 0; }
50% { top: -0.2em; }
70% { top: -0.3em; }
100% { top: 0; }
}
@keyframes bounce {
0% { top: 0; }
50% { top: -0.2em; }
70% { top: -0.3em; }
100% { top: 0; }
} }
` `
......
{
"presets": ["@nrwl/react/babel"],
"plugins": []
}
# This file is used by:
# 1. autoprefixer to adjust CSS to support the below specified browsers
# 2. babel preset-env to adjust included polyfills
#
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
#
# If you need to support different browsers in production, you may tweak the list below.
last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major version
last 2 iOS major versions
Firefox ESR
not IE 9-11 # For IE 9-11 support, remove 'not'.
\ No newline at end of file
import React, { useState, useEffect } from 'react';
import { SolidityCompiler } from '@remix-ui/solidity-compiler' // eslint-disable-line
import { CompilerClientApi } from './compiler'
const remix = new CompilerClientApi()
export const App = () => {
return (
<div>
<SolidityCompiler api={remix} />
</div>
);
};
export default App;
This diff is collapsed.
import { PluginClient } from "@remixproject/plugin";
import { createClient } from "@remixproject/plugin-webview";
import { CompilerApiMixin } from './compiler-api'
import { ICompilerApi } from '@remix-project/remix-lib-ts'
import { CompileTabLogic } from '@remix-ui/solidity-compiler'
const profile = {
name: 'solidity',
displayName: 'Solidity compiler',
icon: 'assets/img/solidity.webp',
description: 'Compile solidity contracts',
kind: 'compiler',
permission: true,
location: 'sidePanel',
documentation: 'https://remix-ide.readthedocs.io/en/latest/solidity_editor.html',
version: '0.0.1',
methods: ['getCompilationResult', 'compile', 'compileWithParameters', 'setCompilerConfig', 'compileFile' ,'getCompilerState']
}
const defaultAppParameters = {
hideWarnings: false,
autoCompile: false,
includeNightlies: false
}
const defaultCompilerParameters = {
runs: '200',
optimize: false,
version: 'soljson-v0.8.7+commit.e28d00a7',
evmVersion: null, // compiler default
language: 'Solidity'
}
export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements ICompilerApi {
constructor () {
super()
createClient(this as any)
this.compileTabLogic = new CompileTabLogic(this, this.contentImport)
this.compiler = this.compileTabLogic.compiler
this.compileTabLogic.init()
this.initCompilerApi()
}
getCompilerParameters () {
const params = {
runs: localStorage.getItem('runs') || defaultCompilerParameters['runs'],
optimize: localStorage.getItem('optimize') === 'true' ? true : false,
version: localStorage.getItem('version') || defaultCompilerParameters['version'],
evmVersion: localStorage.getItem('evmVersion') || defaultCompilerParameters['evmVersion'], // default
language: localStorage.getItem('language') || defaultCompilerParameters['language']
}
return params
}
setCompilerParameters (params) {
for (const key of Object.keys(params)) {
localStorage.setItem(key, params[key])
}
}
getAppParameter (name) {
const param = localStorage.getItem(name) || defaultAppParameters[name]
if (param === 'true') return true
if (param === 'false') return false
return param
}
setAppParameter (name, value) {
localStorage.setItem(name, value)
}
getFileManagerMode () {
return 'browser'
}
}
# Ignore everything in this directory
*
# Except this file
!.gitignore
export const environment = {
production: true
};
// This file can be replaced during build by using the `fileReplacements` array.
// When building for production, this file is replaced with `environment.prod.ts`.
export const environment = {
production: false
};
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Solidity Compiler</title>
<base href="./" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous"/>
</head>
<body>
<div id="root"></div>
</body>
</html>
export * from './app/compiler-api';
import React from 'react';
import ReactDOM from 'react-dom';
import App from './app/app';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
/**
* Polyfill stable language features. These imports will be optimized by `@babel/preset-env`.
*
* See: https://github.com/zloirock/core-js#babel
*/
import 'core-js/stable';
import 'regenerator-runtime/runtime';
/* You can add global styles to this file, and also import other style files */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["node"]
},
"exclude": ["**/*.spec.ts", "**/*.spec.tsx"],
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
}
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"jsx": "react",
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"types": ["node", "jest"],
"resolveJsonModule": true
},
"files": [
"../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
"../../node_modules/@nrwl/react/typings/image.d.ts"
],
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
}
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"**/*.spec.ts",
"**/*.spec.tsx",
"**/*.spec.js",
"**/*.spec.jsx",
"**/*.d.ts"
]
}
const nxWebpack = require('@nrwl/react/plugins/webpack')
module.exports = config => {
const nxWebpackConfig = nxWebpack(config)
return {
...nxWebpackConfig,
node: {
fs: 'empty',
tls: 'empty',
readline: 'empty',
net: 'empty',
module: 'empty',
child_process: 'empty'
}
}
}
...@@ -18,36 +18,29 @@ import * as typeConversion from './execution/typeConversion' ...@@ -18,36 +18,29 @@ import * as typeConversion from './execution/typeConversion'
import { TxRunnerVM } from './execution/txRunnerVM' import { TxRunnerVM } from './execution/txRunnerVM'
import { TxRunnerWeb3 } from './execution/txRunnerWeb3' import { TxRunnerWeb3 } from './execution/txRunnerWeb3'
import * as txResultHelper from './helpers/txResultHelper' import * as txResultHelper from './helpers/txResultHelper'
export { ICompilerApi, ConfigurationSettings } from './types/ICompilerApi'
export = modules() const helpers = {
ui: uiHelper,
function modules () { compiler: compilerHelper,
return { txResultHelper
EventManager: EventManager, }
helpers: { const vm = {
ui: uiHelper, Web3Providers: Web3Providers,
compiler: compilerHelper, DummyProvider: DummyProvider,
txResultHelper Web3VMProvider: Web3VmProvider
}, }
vm: { const execution = {
Web3Providers: Web3Providers, EventsDecoder: EventsDecoder,
DummyProvider: DummyProvider, txExecution: txExecution,
Web3VMProvider: Web3VmProvider txHelper: txHelper,
}, txFormat: txFormat,
Storage: Storage, txListener: TxListener,
util: util, TxRunner: TxRunner,
execution: { TxRunnerWeb3: TxRunnerWeb3,
EventsDecoder: EventsDecoder, TxRunnerVM: TxRunnerVM,
txExecution: txExecution, typeConversion: typeConversion,
txHelper: txHelper, LogsManager,
txFormat: txFormat, forkAt
txListener: TxListener,
TxRunner: TxRunner,
TxRunnerWeb3: TxRunnerWeb3,
TxRunnerVM: TxRunnerVM,
typeConversion: typeConversion,
LogsManager,
forkAt
}
}
} }
export { EventManager, helpers, vm, Storage, util, execution }
export interface ICompilerApi {
currentFile: string
contractMap: {
file: string
} | Record<string, any>
compileErrors: any
compileTabLogic: any
contractsDetails: Record<string, any>
configurationSettings: ConfigurationSettings
getCompilerParameters: () => ConfigurationSettings
setCompilerParameters: (ConfigurationSettings?) => void
getAppParameter: (value: string) => string | boolean
setAppParameter: (name: string, value: string | boolean) => void
getFileManagerMode: () => string
setCompilerConfig: (settings: any) => void
getCompilationResult: () => any
onCurrentFileChanged: (fileName: string) => void
onResetResults: () => void,
onSetWorkspace: (workspace: any) => void
onNoFileSelected: () => void
onCompilationFinished: (contractsDetails: any, contractMap: any) => void
onSessionSwitched: () => void
onContentChanged: () => void
resolveContentAndSave: (url: string) => Promise<string>
fileExists: (file: string) => Promise<boolean>
writeFile: (file: string, content: string) => Promise<void>
readFile: (file: string) => Promise<string>
open: (file: string) => void
saveCurrentFile: () => void
logToTerminal: (log: terminalLog) => {}
compileWithHardhat: (configPath: string) => Promise<string>
}
export type terminalLog = {
type: 'info' | 'error' | 'warning'
value: string
}
export interface ConfigurationSettings {
version: string,
evmVersion: string,
language: string,
optimize: boolean,
runs: string
}
...@@ -144,8 +144,9 @@ export class Web3VmProvider { ...@@ -144,8 +144,9 @@ export class Web3VmProvider {
if (lastOp) { if (lastOp) {
lastOp.error = lastOp.op !== 'RETURN' && lastOp.op !== 'STOP' && lastOp.op !== 'DESTRUCT' lastOp.error = lastOp.op !== 'RETURN' && lastOp.op !== 'STOP' && lastOp.op !== 'DESTRUCT'
} }
this.vmTraces[this.processingHash].gas = '0x' + data.gasUsed.toString(16) const gasUsed = '0x' + data.gasUsed.toString(16)
this.vmTraces[this.processingHash].gas = gasUsed
this.txsReceipt[this.processingHash].gasUsed = gasUsed
const logs = [] const logs = []
for (const l in data.execResult.logs) { for (const l in data.execResult.logs) {
const log = data.execResult.logs[l] const log = data.execResult.logs[l]
......
...@@ -102,8 +102,8 @@ export class Transactions { ...@@ -102,8 +102,8 @@ export class Transactions {
transactionIndex: '0x00', transactionIndex: '0x00',
blockHash: '0x' + txBlock.hash().toString('hex'), blockHash: '0x' + txBlock.hash().toString('hex'),
blockNumber: '0x' + txBlock.header.number.toString('hex'), blockNumber: '0x' + txBlock.header.number.toString('hex'),
gasUsed: Web3.utils.toHex(receipt.gas), gasUsed: receipt.gasUsed,
cumulativeGasUsed: Web3.utils.toHex(receipt.gas), cumulativeGasUsed: receipt.gasUsed, // only 1 tx per block
contractAddress: receipt.contractAddress, contractAddress: receipt.contractAddress,
logs: receipt.logs, logs: receipt.logs,
status: receipt.status, status: receipt.status,
......
...@@ -22,6 +22,7 @@ export function urlFromVersion (version) { ...@@ -22,6 +22,7 @@ export function urlFromVersion (version) {
if (!location.endsWith('/')) location += '/' if (!location.endsWith('/')) location += '/'
url = `${location}soljson.js` url = `${location}soljson.js`
} else { } else {
version = version.replace('.Emscripten.clang', '')
if (!version.startsWith('soljson-v')) version = 'soljson-v' + version if (!version.startsWith('soljson-v')) version = 'soljson-v' + version
if (!version.endsWith('.js')) version = version + '.js' if (!version.endsWith('.js')) version = version + '.js'
url = `${pathToURL[version]}/${version}` url = `${pathToURL[version]}/${version}`
......
export * from './lib/debugger-ui' export * from './lib/debugger-ui'
export * from './lib/idebugger-api' export * from './lib/idebugger-api'
export * from './lib/idebugger-api'
...@@ -20,7 +20,8 @@ const initialState: FormStateProps = { ...@@ -20,7 +20,8 @@ const initialState: FormStateProps = {
type: 'iframe', type: 'iframe',
hash: '', hash: '',
methods: [], methods: [],
location: 'sidePanel' location: 'sidePanel',
canActivate: []
} }
const defaultProfile = { const defaultProfile = {
...@@ -48,10 +49,10 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor ...@@ -48,10 +49,10 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor
setName(storagePlugin.name) setName(storagePlugin.name)
setUrl(storagePlugin.url) setUrl(storagePlugin.url)
setLocation(storagePlugin.location as 'sidePanel' | 'mainPanel' | 'none') setLocation(storagePlugin.location as 'sidePanel' | 'mainPanel' | 'none')
setMethods(storagePlugin.methods) setMethods(Array.isArray(storagePlugin.methods) ? storagePlugin.methods.join(',') : storagePlugin.methods)
setType(storagePlugin.type) setType(storagePlugin.type)
setDisplayName(storagePlugin.displayName) setDisplayName(storagePlugin.displayName)
setCanactivate(storagePlugin.canActivate) setCanactivate(Array.isArray(storagePlugin.canActivate) ? storagePlugin.canActivate.join(',') : storagePlugin.canActivate)
}, []) }, [])
const handleModalOkClick = async () => { const handleModalOkClick = async () => {
......
...@@ -178,9 +178,9 @@ export interface FormStateProps { ...@@ -178,9 +178,9 @@ export interface FormStateProps {
url: string url: string
type: 'iframe' | 'ws' type: 'iframe' | 'ws'
hash: string hash: string
methods: any methods: string[]
location: string location: string
canActivate?: any canActivate: string[]
} }
export type PluginManagerProfile = Profile & { export type PluginManagerProfile = Profile & {
......
...@@ -29,7 +29,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { ...@@ -29,7 +29,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => {
modal(`Published ${contract.name}'s Metadata`, publishMessage(result.uploaded)) modal(`Published ${contract.name}'s Metadata`, publishMessage(result.uploaded))
// triggered each time there's a new verified publish (means hash correspond) // triggered each time there's a new verified publish (means hash correspond)
api.addExternalFile('swarm/' + result.item.hash, result.item.content) api.writeFile('swarm/' + result.item.hash, result.item.content)
} catch (err) { } catch (err) {
let parseError = err let parseError = err
try { try {
...@@ -43,7 +43,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { ...@@ -43,7 +43,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => {
modal(`Published ${contract.name}'s Metadata`, publishMessage(result.uploaded)) modal(`Published ${contract.name}'s Metadata`, publishMessage(result.uploaded))
// triggered each time there's a new verified publish (means hash correspond) // triggered each time there's a new verified publish (means hash correspond)
api.addExternalFile('ipfs/' + result.item.hash, result.item.content) api.writeFile('ipfs/' + result.item.hash, result.item.content)
} catch (err) { } catch (err) {
modal('IPFS Publish Failed', publishMessageFailed(storage, err)) modal('IPFS Publish Failed', publishMessageFailed(storage, err))
} }
......
...@@ -69,7 +69,7 @@ export const Renderer = ({ message, opt = {}, plugin }: RendererProps) => { ...@@ -69,7 +69,7 @@ export const Renderer = ({ message, opt = {}, plugin }: RendererProps) => {
} }
const addAnnotation = (file, error) => { const addAnnotation = (file, error) => {
if (file === plugin.getConfiguration('currentFile')) { if (file === plugin.getAppParameter('currentFile')) {
plugin.call('editor', 'addAnnotation', error, file) plugin.call('editor', 'addAnnotation', error, file)
} }
} }
...@@ -86,17 +86,12 @@ export const Renderer = ({ message, opt = {}, plugin }: RendererProps) => { ...@@ -86,17 +86,12 @@ export const Renderer = ({ message, opt = {}, plugin }: RendererProps) => {
setClose(true) setClose(true)
} }
const _errorClick = (errFile, errLine, errCol) => { const _errorClick = async (errFile, errLine, errCol) => {
if (errFile !== plugin.getConfiguration('currentFile')) { if (errFile !== plugin.getAppParameter('currentFile')) {
// TODO: refactor with this._components.contextView.jumpTo // TODO: refactor with this._components.contextView.jumpTo
const provider = plugin.fileProviderOf(errFile) if (await plugin.fileExists(errFile)) {
if (provider) { plugin.open(errFile)
provider.exists(errFile).then(() => { plugin.call('editor', 'gotoLine', errLine, errCol)
plugin.open(errFile)
plugin.call('editor', 'gotoLine', errLine, errCol)
}).catch(error => {
if (error) return console.log(error)
})
} }
} else { } else {
plugin.call('editor', 'gotoLine', errLine, errCol) plugin.call('editor', 'gotoLine', errLine, errCol)
......
import React from 'react' import React from 'react'
import { CompileTabLogic } from '../logic/compileTabLogic'
export const setEditorMode = (mode: string) => { export const setEditorMode = (mode: string) => {
return { return {
type: 'SET_EDITOR_MODE', type: 'SET_EDITOR_MODE',
...@@ -26,10 +26,10 @@ export const resetCompilerMode = () => (dispatch: React.Dispatch<any>) => { ...@@ -26,10 +26,10 @@ export const resetCompilerMode = () => (dispatch: React.Dispatch<any>) => {
}) })
} }
export const listenToEvents = (compileTabLogic, api) => (dispatch: React.Dispatch<any>) => { export const listenToEvents = (compileTabLogic: CompileTabLogic, api) => (dispatch: React.Dispatch<any>) => {
api.on('editor', 'sessionSwitched', () => { api.onSessionSwitched = () => {
dispatch(setEditorMode('sessionSwitched')) dispatch(setEditorMode('sessionSwitched'))
}) }
compileTabLogic.event.on('startingCompilation', () => { compileTabLogic.event.on('startingCompilation', () => {
dispatch(setCompilerMode('startingCompilation')) dispatch(setCompilerMode('startingCompilation'))
...@@ -39,9 +39,9 @@ export const listenToEvents = (compileTabLogic, api) => (dispatch: React.Dispatc ...@@ -39,9 +39,9 @@ export const listenToEvents = (compileTabLogic, api) => (dispatch: React.Dispatc
dispatch(setCompilerMode('compilationDuration', speed)) dispatch(setCompilerMode('compilationDuration', speed))
}) })
api.on('editor', 'contentChanged', () => { api.onContentChanged = () => {
dispatch(setEditorMode('contentChanged')) dispatch(setEditorMode('contentChanged'))
}) }
compileTabLogic.compiler.event.register('loadingCompiler', () => { compileTabLogic.compiler.event.register('loadingCompiler', () => {
dispatch(setCompilerMode('loadingCompiler')) dispatch(setCompilerMode('loadingCompiler'))
......
import React, { useEffect, useState, useRef, useReducer } from 'react' // eslint-disable-line import React, { useEffect, useState, useRef, useReducer } from 'react' // eslint-disable-line
import semver from 'semver' import semver from 'semver'
import { CompilerContainerProps, ConfigurationSettings } from './types' import { CompilerContainerProps } from './types'
import { ConfigurationSettings } from '@remix-project/remix-lib-ts'
import * as helper from '../../../../../apps/remix-ide/src/lib/helper' import * as helper from '../../../../../apps/remix-ide/src/lib/helper'
import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL, promisedMiniXhr } from '@remix-project/remix-solidity' import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL, promisedMiniXhr } from '@remix-project/remix-solidity'
import { compilerReducer, compilerInitialState } from './reducers/compiler' import { compilerReducer, compilerInitialState } from './reducers/compiler'
...@@ -18,22 +19,21 @@ declare global { ...@@ -18,22 +19,21 @@ declare global {
const _paq = window._paq = window._paq || [] //eslint-disable-line const _paq = window._paq = window._paq || [] //eslint-disable-line
export const CompilerContainer = (props: CompilerContainerProps) => { export const CompilerContainer = (props: CompilerContainerProps) => {
const { api, compileTabLogic, tooltip, modal, compiledFileName, updateCurrentVersion, configurationSettings } = props // eslint-disable-line const { api, compileTabLogic, tooltip, modal, compiledFileName, updateCurrentVersion, configurationSettings, isHardhatProject } = props // eslint-disable-line
const [state, setState] = useState({ const [state, setState] = useState({
hideWarnings: false, hideWarnings: false,
autoCompile: false, autoCompile: false,
optimise: false, optimize: false,
compileTimeout: null, compileTimeout: null,
timeout: 300, timeout: 300,
allversions: [], allversions: [],
customVersions: [], customVersions: [],
selectedVersion: null, selectedVersion: null,
defaultVersion: 'soljson-v0.8.7+commit.e28d00a7.js', // this default version is defined: in makeMockCompiler (for browser test) defaultVersion: 'soljson-v0.8.7+commit.e28d00a7.js', // this default version is defined: in makeMockCompiler (for browser test)
selectedLanguage: '',
runs: '', runs: '',
compiledFileName: '', compiledFileName: '',
includeNightlies: false, includeNightlies: false,
language: '', language: 'Solidity',
evmVersion: '' evmVersion: ''
}) })
const [disableCompileButton, setDisableCompileButton] = useState<boolean>(false) const [disableCompileButton, setDisableCompileButton] = useState<boolean>(false)
...@@ -56,7 +56,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -56,7 +56,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
_updateVersionSelector(selectedVersion) _updateVersionSelector(selectedVersion)
} }
}) })
const currentFileName = api.getConfiguration('currentFile') const currentFileName = api.currentFile
currentFile(currentFileName) currentFile(currentFileName)
listenToEvents(compileTabLogic, api)(dispatch) listenToEvents(compileTabLogic, api)(dispatch)
...@@ -65,19 +65,18 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -65,19 +65,18 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
useEffect(() => { useEffect(() => {
if (compileTabLogic && compileTabLogic.compiler) { if (compileTabLogic && compileTabLogic.compiler) {
setState(prevState => { setState(prevState => {
const params = api.getParameters() const params = api.getCompilerParameters()
const optimize = params.optimize === 'false' ? false : params.optimize === 'true' ? true : null const optimize = params.optimize
const runs = params.runs const runs = params.runs as string
const evmVersion = params.evmVersion const evmVersion = params.evmVersion
const autoCompile = params.autoCompile === 'false' ? false : params.autoCompile === 'true' ? true : null
return { return {
...prevState, ...prevState,
hideWarnings: api.getConfiguration('hideWarnings') || false, hideWarnings: api.getAppParameter('hideWarnings') as boolean || false,
autoCompile: typeof autoCompile === 'boolean' ? autoCompile : api.getConfiguration('autoCompile') || false, autoCompile: api.getAppParameter('autoCompile') as boolean || false,
includeNightlies: api.getConfiguration('includeNightlies') || false, includeNightlies: api.getAppParameter('includeNightlies') as boolean || false,
optimise: typeof optimize === 'boolean' ? optimize : api.getConfiguration('optimise') || false, optimize: optimize,
runs: (runs !== null) && (runs !== 'null') && (runs !== undefined) && (runs !== 'undefined') ? runs : 200, runs: runs,
evmVersion: (evmVersion !== null) && (evmVersion !== 'null') && (evmVersion !== undefined) && (evmVersion !== 'undefined') ? evmVersion : 'default' evmVersion: (evmVersion !== null) && (evmVersion !== 'null') && (evmVersion !== undefined) && (evmVersion !== 'undefined') ? evmVersion : 'default'
} }
}) })
...@@ -153,7 +152,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -153,7 +152,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
allVersions = [...allVersions, ...versions] allVersions = [...allVersions, ...versions]
selectedVersion = state.defaultVersion selectedVersion = state.defaultVersion
if (api.getParameters().version) selectedVersion = api.getParameters().version if (api.getCompilerParameters().version) selectedVersion = api.getCompilerParameters().version
// Check if version is a URL and corresponding filename starts with 'soljson' // Check if version is a URL and corresponding filename starts with 'soljson'
if (selectedVersion.startsWith('https://')) { if (selectedVersion.startsWith('https://')) {
const urlArr = selectedVersion.split('/') const urlArr = selectedVersion.split('/')
...@@ -228,8 +227,8 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -228,8 +227,8 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
}) })
} }
const isSolFileSelected = (currentFile = '') => { const isSolFileSelected = (currentFile: string = '') => {
if (!currentFile) currentFile = api.getConfiguration('currentFile') if (!currentFile) currentFile = api.currentFile
if (!currentFile) return false if (!currentFile) return false
const extention = currentFile.substr(currentFile.length - 3, currentFile.length) const extention = currentFile.substr(currentFile.length - 3, currentFile.length)
return extention.toLowerCase() === 'sol' || extention.toLowerCase() === 'yul' return extention.toLowerCase() === 'sol' || extention.toLowerCase() === 'yul'
...@@ -298,7 +297,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -298,7 +297,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
} }
const compile = () => { const compile = () => {
const currentFile = api.getConfiguration('currentFile') const currentFile = api.currentFile
if (!isSolFileSelected()) return if (!isSolFileSelected()) return
...@@ -322,7 +321,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -322,7 +321,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
}) })
} }
updateCurrentVersion(selectedVersion) updateCurrentVersion(selectedVersion)
api.setParameters({ version: selectedVersion }) api.setCompilerParameters({ version: selectedVersion })
let url let url
if (customUrl !== '') { if (customUrl !== '') {
...@@ -332,7 +331,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -332,7 +331,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
}) })
updateCurrentVersion(selectedVersion) updateCurrentVersion(selectedVersion)
url = customUrl url = customUrl
api.setParameters({ version: selectedVersion }) api.setCompilerParameters({ version: selectedVersion })
} else { } else {
if (helper.checkSpecialChars(selectedVersion)) { if (helper.checkSpecialChars(selectedVersion)) {
return console.log('loading ' + selectedVersion + ' not allowed, special chars not allowed.') return console.log('loading ' + selectedVersion + ' not allowed, special chars not allowed.')
...@@ -403,7 +402,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -403,7 +402,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const handleAutoCompile = (e) => { const handleAutoCompile = (e) => {
const checked = e.target.checked const checked = e.target.checked
api.setConfiguration('autoCompile', checked) api.setAppParameter('autoCompile', checked)
checked && compile() checked && compile()
setState(prevState => { setState(prevState => {
return { ...prevState, autoCompile: checked } return { ...prevState, autoCompile: checked }
...@@ -413,7 +412,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -413,7 +412,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const handleOptimizeChange = (value) => { const handleOptimizeChange = (value) => {
const checked = !!value const checked = !!value
api.setConfiguration('optimise', checked) api.setAppParameter('optimize', checked)
compileTabLogic.setOptimize(checked) compileTabLogic.setOptimize(checked)
if (compileTabLogic.optimize) { if (compileTabLogic.optimize) {
compileTabLogic.setRuns(parseInt(state.runs)) compileTabLogic.setRuns(parseInt(state.runs))
...@@ -422,7 +421,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -422,7 +421,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
} }
state.autoCompile && compile() state.autoCompile && compile()
setState(prevState => { setState(prevState => {
return { ...prevState, optimise: checked } return { ...prevState, optimize: checked }
}) })
} }
...@@ -439,7 +438,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -439,7 +438,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const handleHideWarningsChange = (e) => { const handleHideWarningsChange = (e) => {
const checked = e.target.checked const checked = e.target.checked
api.setConfiguration('hideWarnings', checked) api.setAppParameter('hideWarnings', checked)
state.autoCompile && compile() state.autoCompile && compile()
setState(prevState => { setState(prevState => {
return { ...prevState, hideWarnings: checked } return { ...prevState, hideWarnings: checked }
...@@ -450,7 +449,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -450,7 +449,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const checked = e.target.checked const checked = e.target.checked
if (!checked) handleLoadVersion(state.defaultVersion) if (!checked) handleLoadVersion(state.defaultVersion)
api.setConfiguration('includeNightlies', checked) api.setAppParameter('includeNightlies', checked)
setState(prevState => { setState(prevState => {
return { ...prevState, includeNightlies: checked } return { ...prevState, includeNightlies: checked }
}) })
...@@ -481,7 +480,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -481,7 +480,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const checked = event.target.checked const checked = event.target.checked
sethhCompilation(checked) sethhCompilation(checked)
api.setHardHatCompilation(checked) api.setAppParameter('hardhat-compilation', checked)
} }
/* /*
...@@ -552,7 +551,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -552,7 +551,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
</div> </div>
<div className="mt-2 remixui_compilerConfig custom-control custom-checkbox"> <div className="mt-2 remixui_compilerConfig custom-control custom-checkbox">
<div className="justify-content-between align-items-center d-flex"> <div className="justify-content-between align-items-center d-flex">
<input onChange={(e) => { handleOptimizeChange(e.target.checked) }} className="custom-control-input" id="optimize" type="checkbox" checked={state.optimise} /> <input onChange={(e) => { handleOptimizeChange(e.target.checked) }} className="custom-control-input" id="optimize" type="checkbox" checked={state.optimize} />
<label className="form-check-label custom-control-label" htmlFor="optimize">Enable optimization</label> <label className="form-check-label custom-control-label" htmlFor="optimize">Enable optimization</label>
<input <input
min="1" min="1"
...@@ -563,7 +562,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -563,7 +562,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
type="number" type="number"
title="Estimated number of times each opcode of the deployed code will be executed across the life-time of the contract." title="Estimated number of times each opcode of the deployed code will be executed across the life-time of the contract."
onChange={(e) => onChangeRuns(e.target.value)} onChange={(e) => onChangeRuns(e.target.value)}
disabled={!state.optimise} disabled={!state.optimize}
/> />
</div> </div>
</div> </div>
...@@ -573,7 +572,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ...@@ -573,7 +572,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
</div> </div>
</div> </div>
{ {
api.isHardHatProject && isHardhatProject &&
<div className="mt-3 remixui_compilerConfig custom-control custom-checkbox"> <div className="mt-3 remixui_compilerConfig custom-control custom-checkbox">
<input className="remixui_autocompile custom-control-input" onChange={updatehhCompilation} id="enableHardhat" type="checkbox" title="Enable Hardhat Compilation" checked={hhCompilation} /> <input className="remixui_autocompile custom-control-input" onChange={updatehhCompilation} id="enableHardhat" type="checkbox" title="Enable Hardhat Compilation" checked={hhCompilation} />
<label className="form-check-label custom-control-label" htmlFor="enableHardhat">Enable Hardhat Compilation</label> <label className="form-check-label custom-control-label" htmlFor="enableHardhat">Enable Hardhat Compilation</label>
......
...@@ -115,7 +115,7 @@ export const ContractSelection = (props: ContractSelectionProps) => { ...@@ -115,7 +115,7 @@ export const ContractSelection = (props: ContractSelectionProps) => {
let node let node
if (propertyName === 'web3Deploy' || propertyName === 'name' || propertyName === 'Assembly') { if (propertyName === 'web3Deploy' || propertyName === 'name' || propertyName === 'Assembly') {
node = <pre>{ details[propertyName] }</pre> node = <pre>{ details[propertyName] }</pre>
} else if (propertyName === 'abi' || propertyName === 'metadata') { } else if (details[propertyName] && (propertyName === 'abi' || propertyName === 'metadata')) {
if (details[propertyName] !== '') { if (details[propertyName] !== '') {
try { try {
node = <div> node = <div>
......
import { Plugin } from '@remixproject/engine' import { ICompilerApi } from '@remix-project/remix-lib-ts'
const packageJson = require('../../../../../../package.json')
const Compiler = require('@remix-project/remix-solidity').Compiler const Compiler = require('@remix-project/remix-solidity').Compiler
const EventEmitter = require('events') const EventEmitter = require('events')
const profile = {
name: 'solidity-logic',
displayName: 'Solidity compiler logic',
description: 'Compile solidity contracts - Logic',
methods: ['getCompilerState'],
version: packageJson.version
}
declare global { declare global {
interface Window { interface Window {
...@@ -18,7 +10,7 @@ declare global { ...@@ -18,7 +10,7 @@ declare global {
} }
const _paq = window._paq = window._paq || [] //eslint-disable-line const _paq = window._paq = window._paq || [] //eslint-disable-line
export class CompileTab extends Plugin { export class CompileTabLogic {
public compiler public compiler
public optimize public optimize
public runs public runs
...@@ -26,46 +18,44 @@ export class CompileTab extends Plugin { ...@@ -26,46 +18,44 @@ export class CompileTab extends Plugin {
public compilerImport public compilerImport
public event public event
constructor (public api, public contentImport) { constructor (public api: ICompilerApi, public contentImport) {
super(profile)
this.event = new EventEmitter() this.event = new EventEmitter()
this.compiler = new Compiler((url, cb) => this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message))) this.compiler = new Compiler((url, cb) => api.resolveContentAndSave(url).then((result) => cb(null, result)).catch((error) => cb(error.message)))
} }
init () { init () {
this.optimize = this.api.getParameters().optimize this.optimize = this.api.getCompilerParameters().optimize
this.optimize = this.optimize === 'true' this.api.setCompilerParameters({ optimize: this.optimize })
this.api.setParameters({ optimize: this.optimize })
this.compiler.set('optimize', this.optimize) this.compiler.set('optimize', this.optimize)
this.runs = this.api.getParameters().runs this.runs = this.api.getCompilerParameters().runs
this.runs = this.runs && this.runs !== 'undefined' ? this.runs : 200 this.runs = this.runs && this.runs !== 'undefined' ? this.runs : 200
this.api.setParameters({ runs: this.runs }) this.api.setCompilerParameters({ runs: this.runs })
this.compiler.set('runs', this.runs) this.compiler.set('runs', this.runs)
this.evmVersion = this.api.getParameters().evmVersion this.evmVersion = this.api.getCompilerParameters().evmVersion
if (this.evmVersion === 'undefined' || this.evmVersion === 'null' || !this.evmVersion) { if (this.evmVersion === 'undefined' || this.evmVersion === 'null' || !this.evmVersion) {
this.evmVersion = null this.evmVersion = null
} }
this.api.setParameters({ evmVersion: this.evmVersion }) this.api.setCompilerParameters({ evmVersion: this.evmVersion })
this.compiler.set('evmVersion', this.evmVersion) this.compiler.set('evmVersion', this.evmVersion)
} }
setOptimize (newOptimizeValue) { setOptimize (newOptimizeValue) {
this.optimize = newOptimizeValue this.optimize = newOptimizeValue
this.api.setParameters({ optimize: this.optimize }) this.api.setCompilerParameters({ optimize: this.optimize })
this.compiler.set('optimize', this.optimize) this.compiler.set('optimize', this.optimize)
} }
setRuns (runs) { setRuns (runs) {
this.runs = runs this.runs = runs
this.api.setParameters({ runs: this.runs }) this.api.setCompilerParameters({ runs: this.runs })
this.compiler.set('runs', this.runs) this.compiler.set('runs', this.runs)
} }
setEvmVersion (newEvmVersion) { setEvmVersion (newEvmVersion) {
this.evmVersion = newEvmVersion this.evmVersion = newEvmVersion
this.api.setParameters({ evmVersion: this.evmVersion }) this.api.setCompilerParameters({ evmVersion: this.evmVersion })
this.compiler.set('evmVersion', this.evmVersion) this.compiler.set('evmVersion', this.evmVersion)
} }
...@@ -87,15 +77,14 @@ export class CompileTab extends Plugin { ...@@ -87,15 +77,14 @@ export class CompileTab extends Plugin {
*/ */
compileFile (target) { compileFile (target) {
if (!target) throw new Error('No target provided for compiliation') if (!target) throw new Error('No target provided for compiliation')
const provider = this.api.fileProviderOf(target)
if (!provider) throw new Error(`cannot compile ${target}. Does not belong to any explorer`)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
provider.get(target, (error, content) => { this.api.readFile(target).then((content) => {
if (error) return reject(error)
const sources = { [target]: { content } } const sources = { [target]: { content } }
this.event.emit('startingCompilation') this.event.emit('startingCompilation')
// setTimeout fix the animation on chrome... (animation triggered by 'staringCompilation') // setTimeout fix the animation on chrome... (animation triggered by 'staringCompilation')
setTimeout(() => { this.compiler.compile(sources, target); resolve(true) }, 100) setTimeout(() => { this.compiler.compile(sources, target); resolve(true) }, 100)
}).catch((error) => {
reject(error)
}) })
}) })
} }
...@@ -124,16 +113,17 @@ export class CompileTab extends Plugin { ...@@ -124,16 +113,17 @@ export class CompileTab extends Plugin {
const configFilePath = 'remix-compiler.config.js' const configFilePath = 'remix-compiler.config.js'
this.api.writeFile(configFilePath, fileContent) this.api.writeFile(configFilePath, fileContent)
_paq.push(['trackEvent', 'compiler', 'compileWithHardhat']) _paq.push(['trackEvent', 'compiler', 'compileWithHardhat'])
this.call('hardhat', 'compile', configFilePath).then((result) => { this.api.compileWithHardhat(configFilePath).then((result) => {
this.call('terminal', 'log', { type: 'info', value: result }) this.api.logToTerminal({ type: 'info', value: result })
}).catch((error) => { }).catch((error) => {
this.call('terminal', 'log', { type: 'error', value: error }) this.api.logToTerminal({ type: 'error', value: error })
}) })
} }
} }
// TODO readd saving current file
this.api.saveCurrentFile() this.api.saveCurrentFile()
this.event.emit('removeAnnotations') this.event.emit('removeAnnotations')
var currentFile = this.api.getConfiguration('currentFile') var currentFile = this.api.currentFile
return this.compileFile(currentFile) return this.compileFile(currentFile)
} catch (err) { } catch (err) {
console.error(err) console.error(err)
......
'use strict' 'use strict'
import * as solcTranslate from 'solc/translate' import * as solcTranslate from 'solc/translate'
import * as remixLib from '@remix-project/remix-lib' import { execution } from '@remix-project/remix-lib'
const txHelper = remixLib.execution.txHelper const txHelper = execution.txHelper
export function parseContracts (contractName, contract, source) { export function parseContracts (contractName, contract, source) {
const detail: Record<string, any> = {} const detail: Record<string, any> = {}
......
...@@ -9,10 +9,12 @@ import { Renderer } from '@remix-ui/renderer' // eslint-disable-line ...@@ -9,10 +9,12 @@ import { Renderer } from '@remix-ui/renderer' // eslint-disable-line
import './css/style.css' import './css/style.css'
export const SolidityCompiler = (props: SolidityCompilerProps) => { export const SolidityCompiler = (props: SolidityCompilerProps) => {
const { plugin, plugin: { compileTabLogic, contractsDetails, contractMap, compileErrors, configurationSettings } } = props const { api, api: { currentFile, compileTabLogic, contractsDetails, contractMap, compileErrors, configurationSettings } } = props
const [state, setState] = useState({ const [state, setState] = useState({
isHardhatProject: false,
currentFile,
contractsDetails: {}, contractsDetails: {},
eventHandlers: {}, contractMap: {},
loading: false, loading: false,
compileTabLogic: null, compileTabLogic: null,
compiler: null, compiler: null,
...@@ -30,6 +32,37 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { ...@@ -30,6 +32,37 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
}) })
const [currentVersion, setCurrentVersion] = useState('') const [currentVersion, setCurrentVersion] = useState('')
api.onCurrentFileChanged = (currentFile: string) => {
setState(prevState => {
return { ...prevState, currentFile }
})
}
api.onResetResults = () => {
setState(prevState => {
return { ...prevState, currentFile: '', contractsDetails: {}, contractMap: {} }
})
}
api.onSetWorkspace = async (isLocalhost: boolean) => {
const isHardhat = isLocalhost && await compileTabLogic.isHardhatProject()
setState(prevState => {
return { ...prevState, currentFile, isHardhatProject: isHardhat }
})
}
api.onNoFileSelected = () => {
setState(prevState => {
return { ...prevState, currentFile: '' }
})
}
api.onCompilationFinished = (contractsDetails: any, contractMap: any) => {
setState(prevState => {
return { ...prevState, contractsDetails, contractMap }
})
}
const toast = (message: string) => { const toast = (message: string) => {
setState(prevState => { setState(prevState => {
return { ...prevState, toasterMsg: message } return { ...prevState, toasterMsg: message }
...@@ -38,7 +71,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { ...@@ -38,7 +71,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
const updateCurrentVersion = (value) => { const updateCurrentVersion = (value) => {
setCurrentVersion(value) setCurrentVersion(value)
plugin.setSelectedVersion(value) api.setCompilerParameters({ version: value })
} }
const modal = async (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => { const modal = async (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => {
...@@ -75,23 +108,22 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { ...@@ -75,23 +108,22 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
</div> </div>
) )
const currentFile = plugin.getConfiguration('currentFile')
return ( return (
<> <>
<div id="compileTabView"> <div id="compileTabView">
<CompilerContainer api={plugin} compileTabLogic={compileTabLogic} tooltip={toast} modal={modal} compiledFileName={currentFile} updateCurrentVersion={updateCurrentVersion} configurationSettings={configurationSettings} /> <CompilerContainer api={api} isHardhatProject={state.isHardhatProject} compileTabLogic={compileTabLogic} tooltip={toast} modal={modal} compiledFileName={currentFile} updateCurrentVersion={updateCurrentVersion} configurationSettings={configurationSettings} />
<ContractSelection api={plugin} contractMap={contractMap} contractsDetails={contractsDetails} modal={modal} /> <ContractSelection api={api} contractMap={contractMap} contractsDetails={contractsDetails} modal={modal} />
<div className="remixui_errorBlobs p-4" data-id="compiledErrors"> <div className="remixui_errorBlobs p-4" data-id="compiledErrors">
<span data-id={`compilationFinishedWith_${currentVersion}`}></span> <span data-id={`compilationFinishedWith_${currentVersion}`}></span>
{ compileErrors.error && <Renderer message={compileErrors.error.formattedMessage || compileErrors.error} plugin={plugin} opt={{ type: compileErrors.error.severity || 'error', errorType: compileErrors.error.type }} /> } { compileErrors.error && <Renderer message={compileErrors.error.formattedMessage || compileErrors.error} plugin={api} opt={{ type: compileErrors.error.severity || 'error', errorType: compileErrors.error.type }} /> }
{ compileErrors.error && (compileErrors.error.mode === 'panic') && modal('Error', panicMessage(compileErrors.error.formattedMessage), 'Close', null) } { compileErrors.error && (compileErrors.error.mode === 'panic') && modal('Error', panicMessage(compileErrors.error.formattedMessage), 'Close', null) }
{ compileErrors.errors && compileErrors.errors.length && compileErrors.errors.map((err, index) => { { compileErrors.errors && compileErrors.errors.length && compileErrors.errors.map((err, index) => {
if (plugin.getConfiguration('hideWarnings')) { if (api.getAppParameter('hideWarnings')) {
if (err.severity !== 'warning') { if (err.severity !== 'warning') {
return <Renderer key={index} message={err.formattedMessage} plugin={plugin} opt={{ type: err.severity, errorType: err.type }} /> return <Renderer key={index} message={err.formattedMessage} plugin={api} opt={{ type: err.severity, errorType: err.type }} />
} }
} else { } else {
return <Renderer key={index} message={err.formattedMessage} plugin={plugin} opt={{ type: err.severity, errorType: err.type }} /> return <Renderer key={index} message={err.formattedMessage} plugin={api} opt={{ type: err.severity, errorType: err.type }} />
} }
}) } }) }
</div> </div>
......
import { ICompilerApi, ConfigurationSettings } from '@remix-project/remix-lib-ts'
import { CompileTabLogic } from '../logic/compileTabLogic'
export type onCurrentFileChanged = (fileName: string) => void
export interface SolidityCompilerProps { export interface SolidityCompilerProps {
plugin: { api: ICompilerApi
contractMap: {
file: string
} | Record<string, any>
compileErrors: any,
compileTabLogic: any,
contractsDetails: Record<string, any>,
contentImport: any,
call: (...args) => void
on: (...args) => void,
setSelectedVersion: (value: string) => void,
configurationSettings: ConfigurationSettings,
getConfiguration: (value: string) => string,
setConfiguration: (name: string, value: string) => void
},
} }
export interface CompilerContainerProps { export interface CompilerContainerProps {
api: any, api: ICompilerApi,
compileTabLogic: any, compileTabLogic: CompileTabLogic,
isHardhatProject: boolean,
tooltip: (message: string | JSX.Element) => void, tooltip: (message: string | JSX.Element) => void,
modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void,
compiledFileName: string, compiledFileName: string,
...@@ -26,18 +17,10 @@ export interface CompilerContainerProps { ...@@ -26,18 +17,10 @@ export interface CompilerContainerProps {
configurationSettings: ConfigurationSettings configurationSettings: ConfigurationSettings
} }
export interface ContractSelectionProps { export interface ContractSelectionProps {
api: any, api: ICompilerApi,
contractMap: { contractMap: {
file: string file: string
} | Record<string, any>, } | Record<string, any>,
modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void,
contractsDetails: Record<string, any> contractsDetails: Record<string, any>
} }
export interface ConfigurationSettings {
version: string,
evmVersion: string,
language: string,
optimize: boolean,
runs: string
}
import React, { useEffect, useState, useReducer } from 'react' import React, { useEffect, useState, useReducer } from 'react'
import Button from './Button/StaticAnalyserButton' // eslint-disable-line import Button from './Button/StaticAnalyserButton' // eslint-disable-line
import remixLib from '@remix-project/remix-lib' import { util } from '@remix-project/remix-lib'
import _ from 'lodash' import _ from 'lodash'
import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line
import { RemixUiCheckbox } from '@remix-ui/checkbox' // eslint-disable-line import { RemixUiCheckbox } from '@remix-ui/checkbox' // eslint-disable-line
...@@ -9,7 +9,6 @@ import { compilation } from './actions/staticAnalysisActions' ...@@ -9,7 +9,6 @@ import { compilation } from './actions/staticAnalysisActions'
import { initialState, analysisReducer } from './reducers/staticAnalysisReducer' import { initialState, analysisReducer } from './reducers/staticAnalysisReducer'
import { OverlayTrigger, Tooltip } from 'react-bootstrap'// eslint-disable-line import { OverlayTrigger, Tooltip } from 'react-bootstrap'// eslint-disable-line
const StaticAnalysisRunner = require('@remix-project/remix-analyzer').CodeAnalysis const StaticAnalysisRunner = require('@remix-project/remix-analyzer').CodeAnalysis
const utils = remixLib.util
declare global { declare global {
interface Window { interface Window {
...@@ -38,7 +37,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { ...@@ -38,7 +37,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
}) })
} }
const groupedModules = utils.groupBy( const groupedModules = util.groupBy(
preProcessModules(runner.modules()), preProcessModules(runner.modules()),
'categoryId' 'categoryId'
) )
...@@ -217,7 +216,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { ...@@ -217,7 +216,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
}) })
// Slither Analysis // Slither Analysis
if (slitherEnabled) { if (slitherEnabled) {
props.analysisModule.call('solidity-logic', 'getCompilerState').then(async (compilerState) => { props.analysisModule.call('solidity', 'getCompilerState').then((compilerState) => {
const { currentVersion, optimize, evmVersion } = compilerState const { currentVersion, optimize, evmVersion } = compilerState
props.analysisModule.call('terminal', 'log', { type: 'info', value: '[Slither Analysis]: Running...' }) props.analysisModule.call('terminal', 'log', { type: 'info', value: '[Slither Analysis]: Running...' })
_paq.push(['trackEvent', 'solidityStaticAnalyzer', 'analyzeWithSlither']) _paq.push(['trackEvent', 'solidityStaticAnalyzer', 'analyzeWithSlither'])
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
"tags": [] "tags": []
}, },
"remix-ui-settings": { "remix-ui-settings": {
"tags": [] "tags": []
}, },
"remix-ui-static-analyser": { "remix-ui-static-analyser": {
"tags": [] "tags": []
...@@ -120,6 +120,9 @@ ...@@ -120,6 +120,9 @@
}, },
"remix-ui-renderer": { "remix-ui-renderer": {
"tags": [] "tags": []
},
"solidity-compiler": {
"tags": []
} }
} }
} }
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
"bumpVersion:libs": "gulp & gulp syncLibVersions;", "bumpVersion:libs": "gulp & gulp syncLibVersions;",
"browsertest": "sleep 5 && npm run nightwatch_local", "browsertest": "sleep 5 && npm run nightwatch_local",
"csslint": "csslint --ignore=order-alphabetical --errors='errors,duplicate-properties,empty-rules' --exclude-list='apps/remix-ide/src/assets/css/font-awesome.min.css' apps/remix-ide/src/assets/css/", "csslint": "csslint --ignore=order-alphabetical --errors='errors,duplicate-properties,empty-rules' --exclude-list='apps/remix-ide/src/assets/css/font-awesome.min.css' apps/remix-ide/src/assets/css/",
"downloadsolc_assets": "wget --no-check-certificate https://binaries.soliditylang.org/wasm/soljson-v0.8.7+commit.e28d00a7.js -O ./apps/remix-ide/src/assets/js/soljson.js", "downloadsolc_assets": "wget --no-check-certificate https://binaries.soliditylang.org/wasm/soljson-v0.8.7+commit.e28d00a7.js -O ./apps/remix-ide/src/assets/js/soljson.js && wget --no-check-certificate https://binaries.soliditylang.org/wasm/soljson-v0.8.7+commit.e28d00a7.js -O ./apps/solidity-compiler/src/assets/js/soljson.js",
"make-mock-compiler": "node apps/remix-ide/ci/makeMockCompiler.js", "make-mock-compiler": "node apps/remix-ide/ci/makeMockCompiler.js",
"minify": "uglifyjs --in-source-map inline --source-map-inline -c warnings=false", "minify": "uglifyjs --in-source-map inline --source-map-inline -c warnings=false",
"build:production": "NODE_ENV=production npx nx build remix-ide --with-deps --skip-nx-cache", "build:production": "NODE_ENV=production npx nx build remix-ide --with-deps --skip-nx-cache",
......
...@@ -15,6 +15,7 @@ Release managers will oversee the various aspects of a project before it is due ...@@ -15,6 +15,7 @@ Release managers will oversee the various aspects of a project before it is due
## Quality checks: ## Quality checks:
The quality of the release needs to be reviewed before a project is officially launched. The quality of the release needs to be reviewed before a project is officially launched.
The release manager is in charge of ensuring manual testing is properly planned and done. The release manager is in charge of ensuring manual testing is properly planned and done.
During the feature freeze time, only the release manager has permission to merge pull requests. As staging should at this point be already deployed, this is to ensure that the release manager has enough visibility on the changes being applied.
Also that unit testing and e2e for new feaures have been included. Also that unit testing and e2e for new feaures have been included.
## Deployment: ## Deployment:
......
...@@ -25,12 +25,14 @@ ...@@ -25,12 +25,14 @@
"@remix-project/remix-tests": ["dist/libs/remix-tests/src/index.js"], "@remix-project/remix-tests": ["dist/libs/remix-tests/src/index.js"],
"@remix-project/remix-url-resolver": ["dist/libs/remix-url-resolver/index.js"], "@remix-project/remix-url-resolver": ["dist/libs/remix-url-resolver/index.js"],
"@remixproject/debugger-plugin": ["apps/debugger/src/index.ts"], "@remixproject/debugger-plugin": ["apps/debugger/src/index.ts"],
"@remixproject/solidity-compiler-plugin": ["apps/solidity-compiler/src/index.ts"],
"@remix-project/remixd": ["dist/libs/remixd/index.js"], "@remix-project/remixd": ["dist/libs/remixd/index.js"],
"@remix-ui/tree-view": ["libs/remix-ui/tree-view/src/index.ts"], "@remix-ui/tree-view": ["libs/remix-ui/tree-view/src/index.ts"],
"@remix-ui/debugger-ui": ["libs/remix-ui/debugger-ui/src/index.ts"], "@remix-ui/debugger-ui": ["libs/remix-ui/debugger-ui/src/index.ts"],
"@remix-ui/utils": ["libs/remix-ui/utils/src/index.ts"], "@remix-ui/utils": ["libs/remix-ui/utils/src/index.ts"],
"@remix-ui/clipboard": ["libs/remix-ui/clipboard/src/index.ts"], "@remix-ui/clipboard": ["libs/remix-ui/clipboard/src/index.ts"],
"@remix-project/remix-solidity-ts": ["libs/remix-solidity/src/index.ts"], "@remix-project/remix-solidity-ts": ["libs/remix-solidity/src/index.ts"],
"@remix-project/remix-lib-ts": ["libs/remix-lib/src/index.ts"],
"@remix-ui/modal-dialog": ["libs/remix-ui/modal-dialog/src/index.ts"], "@remix-ui/modal-dialog": ["libs/remix-ui/modal-dialog/src/index.ts"],
"@remix-ui/toaster": ["libs/remix-ui/toaster/src/index.ts"], "@remix-ui/toaster": ["libs/remix-ui/toaster/src/index.ts"],
"@remix-ui/file-explorer": ["libs/remix-ui/file-explorer/src/index.ts"], "@remix-ui/file-explorer": ["libs/remix-ui/file-explorer/src/index.ts"],
......
...@@ -875,6 +875,76 @@ ...@@ -875,6 +875,76 @@
} }
} }
} }
},
"solidity-compiler": {
"root": "apps/solidity-compiler",
"sourceRoot": "apps/solidity-compiler/src",
"projectType": "application",
"schematics": {},
"architect": {
"build": {
"builder": "@nrwl/web:build",
"options": {
"outputPath": "dist/apps/solidity-compiler",
"index": "apps/solidity-compiler/src/index.html",
"main": "apps/solidity-compiler/src/main.tsx",
"polyfills": "apps/solidity-compiler/src/polyfills.ts",
"tsConfig": "apps/solidity-compiler/tsconfig.app.json",
"assets": [
"apps/solidity-compiler/src/favicon.ico",
"apps/solidity-compiler/src/assets",
"apps/solidity-compiler/src/index.html"
],
"styles": ["apps/solidity-compiler/src/styles.css"],
"scripts": [],
"webpackConfig": "apps/solidity-compiler/webpack.config.js",
"maxWorkers": 2
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "apps/solidity-compiler/src/environments/environment.ts",
"with": "apps/solidity-compiler/src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
"serve": {
"builder": "@nrwl/web:dev-server",
"options": {
"buildTarget": "solidity-compiler:build"
},
"configurations": {
"production": {
"buildTarget": "solidity-compiler:build:production"
}
}
},
"lint": {
"builder": "@nrwl/linter:lint",
"options": {
"linter": "eslint",
"tsConfig": ["apps/solidity-compiler/tsconfig.app.json"],
"exclude": ["**/node_modules/**", "!apps/solidity-compiler/**/*"]
}
}
}
} }
}, },
"cli": { "cli": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment