Commit 39977622 authored by Scott Tsai's avatar Scott Tsai Committed by yann300

[WIP] compile-tab: add evmVersion

Specifying a specific EVM version for `solc` to target is useful when targetting older private chains deployments with the latest compiler. This work in progress patch adds an "EVM Version" drop down menu in the compiler tab. This patch depends on https://github.com/ethereum/remix/pull/1193 in `remix-solidity` to pass down the `evmVersion` option.
parent 01597bb7
...@@ -25,6 +25,13 @@ class CompileTab { ...@@ -25,6 +25,13 @@ class CompileTab {
this.optimize = this.optimize === 'true' this.optimize = this.optimize === 'true'
this.queryParams.update({ optimize: this.optimize }) this.queryParams.update({ optimize: this.optimize })
this.compiler.setOptimize(this.optimize) this.compiler.setOptimize(this.optimize)
this.evmVersion = this.queryParams.get().evmVersion
if (this.evmVersion === 'undefined' || this.evmVersion === 'null' || !this.evmVersion) {
this.evmVersion = null
}
this.queryParams.update({ evmVersion: this.evmVersion })
this.compiler.setEvmVersion(this.evmVersion)
} }
setOptimize (newOptimizeValue) { setOptimize (newOptimizeValue) {
...@@ -33,6 +40,12 @@ class CompileTab { ...@@ -33,6 +40,12 @@ class CompileTab {
this.compiler.setOptimize(this.optimize) this.compiler.setOptimize(this.optimize)
} }
setEvmVersion (newEvmVersion) {
this.evmVersion = newEvmVersion
this.queryParams.update({ evmVersion: this.evmVersion })
this.compiler.setEvmVersion(this.evmVersion)
}
/** /**
* Compile a specific file of the file manager * Compile a specific file of the file manager
* @param {string} target the path to the file to compile * @param {string} target the path to the file to compile
......
...@@ -134,6 +134,33 @@ class CompilerContainer { ...@@ -134,6 +134,33 @@ class CompilerContainer {
</select>` </select>`
this._view.version = yo`<span id="version"></span>` this._view.version = yo`<span id="version"></span>`
this._view.evmVersionSelector = yo`
<select onchange="${this.onchangeEvmVersion.bind(this)}" class="custom-select" id="evmVersionSelector">
<option disabled selected>EVM Version: default</option>
<option value="default">compiler default</option>
<option>petersburg</option>
<option>constantinople</option>
<option>byzantium</option>
<option>spuriousDragon</option>
<option>tangerineWhistle</option>
<option>homestead</option>
</select>`
if (this.compileTabLogic.evmVersion) {
let s = this._view.evmVersionSelector
let i
for (i = 0; i < s.options.length; i++) {
if (s.options[i].value === this.compileTabLogic.evmVersion) {
break
}
}
if (i === s.options.length) { // invalid evmVersion from queryParams
s.selectedIndex = 1 // compiler default
this.onchangeEvmVersion()
} else {
s.selectedIndex = i
}
}
this._view.compilationButton = this.compilationButton() this._view.compilationButton = this.compilationButton()
this._view.compileContainer = yo` this._view.compileContainer = yo`
...@@ -145,6 +172,9 @@ class CompilerContainer { ...@@ -145,6 +172,9 @@ class CompilerContainer {
<label class="input-group-text border-0" for="versionSelector">Compiler</label> <label class="input-group-text border-0" for="versionSelector">Compiler</label>
</div> </div>
${this._view.versionSelector} ${this._view.versionSelector}
<div class="input-group-prepend">
</div>
${this._view.evmVersionSelector}
</header> </header>
${this._view.compilationButton} ${this._view.compilationButton}
</article> </article>
...@@ -189,6 +219,22 @@ class CompilerContainer { ...@@ -189,6 +219,22 @@ class CompilerContainer {
this.compileTabLogic.runCompiler() this.compileTabLogic.runCompiler()
} }
onchangeEvmVersion (_) {
let s = this._view.evmVersionSelector
let v = s.value
if (v === 'default') {
v = null
}
this.compileTabLogic.setEvmVersion(v)
if (!v) {
v = 'default'
}
const o = yo` <option disabled="disabled" selected="selected">EVM Version: ${v}</option>`
s.options[0] = o
s.selectedIndex = 0
// calling `runCompiler()` here would cause the UI to freeze with the selection drop down menu open
}
onchangeLoadVersion (event) { onchangeLoadVersion (event) {
this.data.selectedVersion = this._view.versionSelector.value this.data.selectedVersion = this._view.versionSelector.value
this._updateVersionSelector() this._updateVersionSelector()
......
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