Skip to content

Commit

Permalink
Merge pull request #1998 from thundercore/scottt-compiler-tab-add-evm…
Browse files Browse the repository at this point in the history
…Version-select

compile-tab: add evmVersion
  • Loading branch information
yann300 committed Jun 17, 2019
2 parents 01597bb + e03a46b commit dd92765
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"remix-analyzer": "0.3.6",
"remix-debug": "0.3.7",
"remix-lib": "0.4.6",
"remix-solidity": "0.3.6",
"remix-solidity": "0.3.7",
"remix-tabs": "1.0.46",
"remix-tests": "0.1.8",
"remixd": "0.1.8-alpha.6",
Expand Down
13 changes: 13 additions & 0 deletions src/app/tabs/compileTab/compileTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ class CompileTab {
this.optimize = this.optimize === 'true'
this.queryParams.update({ optimize: 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) {
Expand All @@ -33,6 +40,12 @@ class CompileTab {
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
* @param {string} target the path to the file to compile
Expand Down
56 changes: 52 additions & 4 deletions src/app/tabs/compileTab/compilerContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,55 @@ class CompilerContainer {
</select>`
this._view.version = yo`<span id="version"></span>`

this._view.evmVersionSelector = yo`
<select onchange="${this.onchangeEvmVersion.bind(this)}" class="custom-select" id="evmVersionSelector">
<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 = 0 // compiler default
this.onchangeEvmVersion()
} else {
s.selectedIndex = i
}
}

this._view.compilationButton = this.compilationButton()

this._view.compileContainer = yo`
<section>
<!-- Select Compiler Version -->
<article>
<header class="navbar navbar-light bg-light input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text border-0" for="versionSelector">Compiler</label>
<header class="navbar navbar-light bg-light">
<div class="row w-100 no-gutters mb-2">
<div class="col-sm-4">
<label class="input-group-text border-0" for="versionSelector">Compiler</label>
</div>
<div class="col-sm-8">
${this._view.versionSelector}
</div>
</div>
<div class="row w-100 no-gutters">
<div class="col-sm-4">
<label class="input-group-text border-0" for="evmVersionSelector">EVM Version</label>
</div>
<div class="col-sm-8">
${this._view.evmVersionSelector}
</div>
</div>
${this._view.versionSelector}
</header>
${this._view.compilationButton}
</article>
Expand Down Expand Up @@ -189,6 +227,16 @@ class CompilerContainer {
this.compileTabLogic.runCompiler()
}

onchangeEvmVersion (_) {
let s = this._view.evmVersionSelector
let v = s.value
if (v === 'default') {
v = null
}
this.compileTabLogic.setEvmVersion(v)
this.compile()
}

onchangeLoadVersion (event) {
this.data.selectedVersion = this._view.versionSelector.value
this._updateVersionSelector()
Expand Down

0 comments on commit dd92765

Please sign in to comment.