Fixed using file

pull/2249/head
lianahus 3 years ago committed by yann300
parent aa6a348c0e
commit 74dcfd2472
  1. 124
      apps/remix-ide/contracts/solidity_compiler_config.json
  2. 6
      apps/solidity-compiler/src/app/compiler.ts
  3. 4
      libs/remix-lib/src/types/ICompilerApi.ts
  4. 6
      libs/remix-solidity/src/compiler/compiler-input.ts
  5. 33
      libs/remix-solidity/src/compiler/compiler.ts
  6. 4
      libs/remix-solidity/src/compiler/types.ts
  7. 3
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
  8. 14
      libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts

@ -1,61 +1,65 @@
{
"_comment": "For more info please visit https://docs.soliditylang.org/en/develop/using-the-compiler.html?highlight=standard%20json#input-description",
"language": "Solidity",
"settings":
{
"stopAfter": "parsing",
"remappings": [ ":g=/dir" ],
"optimizer": {
"enabled": false,
"runs": 200,
"details": {
"peephole": true,
"inliner": true,
"jumpdestRemover": true,
"orderLiterals": false,
"deduplicate": false,
"cse": false,
"constantOptimizer": false,
"yul": false,
"yulDetails": {
"stackAllocation": true,
"optimizerSteps": "dhfoDgvulfnTUtnIf..."
}
}
},
"evmVersion": "byzantium",
"viaIR": true,
"debug": {
"revertStrings": "default",
"debugInfo": ["location", "snippet"]
},
"metadata": {
"useLiteralContent": true,
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"*": [
"metadata", "evm.bytecode",
"evm.bytecode.sourceMap"
],
"": [
"ast"
]
},
"def": {
"MyContract": [ "abi", "evm.bytecode.opcodes" ]
}
},
"modelChecker":
{
"divModNoSlacks": false,
"engine": "chc",
"invariants": ["contract", "reentrancy"],
"showUnproved": true,
"solvers": ["cvc4", "smtlib2", "z3"],
"targets": ["underflow", "overflow", "assert"],
"timeout": 20000
}
}
}
"language": "Solidity",
"settings": {
"remappings": [
":g=/dir"
],
"optimizer": {
"enabled": true,
"runs": 200,
"details": {
"peephole": true,
"inliner": true,
"jumpdestRemover": true,
"orderLiterals": false,
"deduplicate": false,
"cse": false,
"constantOptimizer": false,
"yul": false
}
},
"evmVersion": "byzantium",
"viaIR": true,
"debug": {
"revertStrings": "default"
},
"metadata": {
"useLiteralContent": true,
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"*": [
"metadata",
"evm.bytecode",
"evm.bytecode.sourceMap"
],
"": [
"ast"
]
},
"def": {
"MyContract": [
"abi",
"evm.bytecode.opcodes"
]
}
},
"modelChecker": {
"divModNoSlacks": false,
"engine": "chc",
"showUnproved": true,
"solvers": [
"cvc4",
"smtlib2",
"z3"
],
"targets": [
"underflow",
"overflow",
"assert"
],
"timeout": 20000
}
}
}

@ -26,7 +26,7 @@ const defaultCompilerParameters = {
evmVersion: null, // compiler default
language: 'Solidity',
useFileConfiguration: false,
configFileContent: ''
configFilePath: ''
}
export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements ICompilerApi {
constructor () {
@ -45,8 +45,8 @@ export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements
version: localStorage.getItem('version') || defaultCompilerParameters.version,
evmVersion: localStorage.getItem('evmVersion') || defaultCompilerParameters.evmVersion, // default
language: localStorage.getItem('language') || defaultCompilerParameters.language,
useFileConfiguration: localStorage.getItem('useFileConfiguration') || defaultCompilerParameters.useFileConfiguration,
configFileContent: localStorage.getItem('configFileContent') || defaultCompilerParameters.configFileContent
useFileConfiguration: localStorage.getItem('useFileConfiguration') == 'true',
configFilePath: localStorage.getItem('configFilePath') || defaultCompilerParameters.configFilePath
}
return params
}

@ -57,5 +57,7 @@ export interface ConfigurationSettings {
evmVersion: string,
language: string,
optimize: boolean,
runs: string
runs: string,
useFileConfiguration: boolean,
configFilePath: string
}

@ -46,3 +46,9 @@ export function getValidLanguage (val: string): Language {
}
return null
}
export function compilerInputForConfigFile(sources: Source, opts)
{
opts.sources = sources
return JSON.stringify(opts)
}

@ -2,7 +2,7 @@
import { update } from 'solc/abi'
import * as webworkify from 'webworkify-webpack'
import compilerInput from './compiler-input'
import compilerInput, { compilerInputForConfigFile } from './compiler-input'
import EventManager from '../lib/eventManager'
import txHelper from './helper'
import {
@ -116,13 +116,13 @@ export class Compiler {
let input
try {
if (source && source.sources) {
const { optimize, runs, evmVersion, language } = this.state
let params = { optimize, runs, evmVersion, language }
const { optimize, runs, evmVersion, language, useFileConfiguration, configFileContent } = this.state
if (this.state.useFileConfiguration) {
params = JSON.parse(this.state.configFileContent)
if (useFileConfiguration) {
input = compilerInputForConfigFile(source.sources, JSON.parse(configFileContent))
} else {
input = compilerInput(source.sources, { optimize, runs, evmVersion, language })
}
input = compilerInput(source.sources, params)
result = JSON.parse(compiler.compile(input, { import: missingInputsCallback }))
}
@ -195,12 +195,13 @@ export class Compiler {
try {
if (source && source.sources) {
const { optimize, runs, evmVersion, language, useFileConfiguration, configFileContent } = this.state
let params = { optimize, runs, evmVersion, language }
if (useFileConfiguration) {
params = JSON.parse(configFileContent)
input = compilerInputForConfigFile(source.sources, JSON.parse(configFileContent))
} else {
input = compilerInput(source.sources, { optimize, runs, evmVersion, language })
}
input = compilerInput(source.sources, params)
result = JSON.parse(remoteCompiler.compile(input, { import: missingInputsCallback }))
}
} catch (exception) {
@ -302,17 +303,21 @@ export class Compiler {
this.state.compileJSON = (source: SourceWithTarget) => {
if (source && source.sources) {
const { optimize, runs, evmVersion, language } = this.state
const { optimize, runs, evmVersion, language, useFileConfiguration, configFileContent } = this.state
jobs.push({ sources: source })
let params = { optimize, runs, evmVersion, language }
let input
if (this.state.useFileConfiguration) {
params = JSON.parse(this.state.configFileContent)
if (useFileConfiguration) {
input = compilerInputForConfigFile(source.sources, JSON.parse(configFileContent))
} else {
input = compilerInput(source.sources, { optimize, runs, evmVersion, language })
}
this.state.worker.postMessage({
cmd: 'compile',
job: jobs.length - 1,
input: compilerInput(source.sources, { optimize, runs, evmVersion, language })
input: input
})
}
}

@ -164,8 +164,8 @@ export interface CompilerState {
language: Language,
compilationStartTime: number| null,
target: string | null,
useFileConfiguration: false,
configFileContent: '',
useFileConfiguration: boolean,
configFileContent: string,
lastCompilationResult: {
data: CompilationResult | null,
source: SourceWithTarget | null | undefined

@ -92,6 +92,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const autocompile = await api.getAppParameter('autoCompile') as boolean || false
const hideWarnings = await api.getAppParameter('hideWarnings') as boolean || false
const includeNightlies = await api.getAppParameter('includeNightlies') as boolean || false
setState(prevState => {
const params = api.getCompilerParameters()
const optimize = params.optimize
@ -186,7 +187,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
setConfigFilePath(configFilePathInput.current.value)
else {
modal(
'New configuration file', `The file "${configFilePathInput.current.value}"" you entered does not exist. Do you want to create a new one?`,
'New configuration file', `The file "${configFilePathInput.current.value}" you entered does not exist. Do you want to create a new one?`,
'Create',
async () => await createNewConfigFile(),
'Cancel',

@ -48,30 +48,27 @@ export class CompileTabLogic {
this.api.setCompilerParameters({ evmVersion: this.evmVersion })
this.compiler.set('evmVersion', this.evmVersion)
this.useFileConfiguration = false
this.configFilePath = ''
this.useFileConfiguration = this.api.getCompilerParameters().useFileConfiguration
this.configFilePath = this.api.getCompilerParameters().configFilePath
this.language = getValidLanguage(this.api.getCompilerParameters().language)
if (this.language != null) {
this.compiler.set('language', this.language)
}
}
setOptimize (newOptimizeValue) {
setOptimize (newOptimizeValue: boolean) {
this.optimize = newOptimizeValue
this.api.setCompilerParameters({ optimize: this.optimize })
this.compiler.set('optimize', this.optimize)
}
setUseFileConfiguration (useFileConfiguration) {
setUseFileConfiguration (useFileConfiguration: boolean) {
this.useFileConfiguration = useFileConfiguration
this.compiler.set('useFileConfiguration', useFileConfiguration)
}
setConfigFilePath (path) {
this.configFilePath = path
this.api.readFile(path).then( content => {
this.compiler.set('configFileContent', content)
})
}
setRuns (runs) {
@ -111,6 +108,9 @@ export class CompileTabLogic {
const sources = { [target]: { content } }
this.event.emit('removeAnnotations')
this.event.emit('startingCompilation')
this.api.readFile(this.configFilePath).then( content => {
this.compiler.set('configFileContent', content)
})
// setTimeout fix the animation on chrome... (animation triggered by 'staringCompilation')
setTimeout(() => { this.compiler.compile(sources, target); resolve(true) }, 100)
}).catch((error) => {

Loading…
Cancel
Save