Merge pull request #1998 from thundercore/scottt-compiler-tab-add-evmVersion-select

compile-tab: add evmVersion
pull/1/head
yann300 6 years ago committed by GitHub
commit dd927657d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      package.json
  2. 13
      src/app/tabs/compileTab/compileTab.js
  3. 56
      src/app/tabs/compileTab/compilerContainer.js

@ -47,7 +47,7 @@
"remix-analyzer": "0.3.6", "remix-analyzer": "0.3.6",
"remix-debug": "0.3.7", "remix-debug": "0.3.7",
"remix-lib": "0.4.6", "remix-lib": "0.4.6",
"remix-solidity": "0.3.6", "remix-solidity": "0.3.7",
"remix-tabs": "1.0.46", "remix-tabs": "1.0.46",
"remix-tests": "0.1.8", "remix-tests": "0.1.8",
"remixd": "0.1.8-alpha.6", "remixd": "0.1.8-alpha.6",

@ -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 {
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,17 +134,55 @@ 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 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.compilationButton = this.compilationButton()
this._view.compileContainer = yo` this._view.compileContainer = yo`
<section> <section>
<!-- Select Compiler Version --> <!-- Select Compiler Version -->
<article> <article>
<header class="navbar navbar-light bg-light input-group mb-3"> <header class="navbar navbar-light bg-light">
<div class="input-group-prepend"> <div class="row w-100 no-gutters mb-2">
<label class="input-group-text border-0" for="versionSelector">Compiler</label> <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> </div>
${this._view.versionSelector}
</header> </header>
${this._view.compilationButton} ${this._view.compilationButton}
</article> </article>
@ -189,6 +227,16 @@ 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)
this.compile()
}
onchangeLoadVersion (event) { onchangeLoadVersion (event) {
this.data.selectedVersion = this._view.versionSelector.value this.data.selectedVersion = this._view.versionSelector.value
this._updateVersionSelector() this._updateVersionSelector()

Loading…
Cancel
Save