|
|
@ -124,8 +124,17 @@ class CompilerContainer { |
|
|
|
const pragmaStr = pragmaArr[0].replace('pragma solidity', '').trim() |
|
|
|
const pragmaStr = pragmaArr[0].replace('pragma solidity', '').trim() |
|
|
|
const pragma = pragmaStr.substring(0, pragmaStr.length - 1) |
|
|
|
const pragma = pragmaStr.substring(0, pragmaStr.length - 1) |
|
|
|
const releasedVersions = this.data.allversions.filter(obj => !obj.prerelease).map(obj => obj.version) |
|
|
|
const releasedVersions = this.data.allversions.filter(obj => !obj.prerelease).map(obj => obj.version) |
|
|
|
const currentCompilerName = semver.clean(this._view.versionSelector.selectedOptions[0].label) |
|
|
|
const allVersions = this.data.allversions.map(obj => this._retrieveVersion(obj.version)) |
|
|
|
if (releasedVersions.includes(currentCompilerName) && !semver.satisfies(this._retrieveVersion(), pragma)) { |
|
|
|
const currentCompilerName = this._retrieveVersion(this._view.versionSelector.selectedOptions[0].label) |
|
|
|
|
|
|
|
// contains only numbers part, for example '0.4.22'
|
|
|
|
|
|
|
|
const pureVersion = this._retrieveVersion() |
|
|
|
|
|
|
|
// is nightly build newer than the last release
|
|
|
|
|
|
|
|
const isNewestNightly = currentCompilerName.includes('nightly') && semver.gt(pureVersion, releasedVersions[0]) |
|
|
|
|
|
|
|
// checking if the selected version is in the pragma range
|
|
|
|
|
|
|
|
const isInRange = semver.satisfies(pureVersion, pragma) |
|
|
|
|
|
|
|
// checking if the selected version is from official compilers list(excluding custom versions) and in range or greater
|
|
|
|
|
|
|
|
const isOfficial = allVersions.includes(currentCompilerName) |
|
|
|
|
|
|
|
if (isOfficial && (!isInRange && !isNewestNightly)) { |
|
|
|
const compilerToLoad = semver.maxSatisfying(releasedVersions, pragma) |
|
|
|
const compilerToLoad = semver.maxSatisfying(releasedVersions, pragma) |
|
|
|
const compilerPath = this.data.allversions.filter(obj => !obj.prerelease && obj.version === compilerToLoad)[0].path |
|
|
|
const compilerPath = this.data.allversions.filter(obj => !obj.prerelease && obj.version === compilerToLoad)[0].path |
|
|
|
if (this.data.selectedVersion !== compilerPath) { |
|
|
|
if (this.data.selectedVersion !== compilerPath) { |
|
|
@ -137,9 +146,9 @@ class CompilerContainer { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_retrieveVersion () { |
|
|
|
_retrieveVersion (version) { |
|
|
|
let version = this._view.versionSelector.value |
|
|
|
if (!version) version = this._view.versionSelector.value |
|
|
|
return version.substring(9, version.length) |
|
|
|
return semver.coerce(version) ? semver.coerce(version).version : '' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render () { |
|
|
|
render () { |
|
|
@ -200,7 +209,7 @@ class CompilerContainer { |
|
|
|
this._view.compilationButton = this.compilationButton() |
|
|
|
this._view.compilationButton = this.compilationButton() |
|
|
|
|
|
|
|
|
|
|
|
this._view.includeNightlies = yo` |
|
|
|
this._view.includeNightlies = yo` |
|
|
|
<input class="mr-0 ml-1" id="nightlies" type="checkbox" onchange=${this._updateVersionSelector.bind(this)}> |
|
|
|
<input class="mr-0 ml-1" id="nightlies" type="checkbox" onchange=${() => this._updateVersionSelector()}> |
|
|
|
` |
|
|
|
` |
|
|
|
this._view.compileContainer = yo` |
|
|
|
this._view.compileContainer = yo` |
|
|
|
<section> |
|
|
|
<section> |
|
|
@ -286,9 +295,7 @@ class CompilerContainer { |
|
|
|
|
|
|
|
|
|
|
|
compile (event) { |
|
|
|
compile (event) { |
|
|
|
if (this.config.get('currentFile')) { |
|
|
|
if (this.config.get('currentFile')) { |
|
|
|
if (!this.data.selectedVersion.includes('nightly')) { |
|
|
|
|
|
|
|
this._setCompilerVersionFromPragma(this.config.get('currentFile')) |
|
|
|
this._setCompilerVersionFromPragma(this.config.get('currentFile')) |
|
|
|
} |
|
|
|
|
|
|
|
this.compileTabLogic.runCompiler() |
|
|
|
this.compileTabLogic.runCompiler() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -353,7 +360,7 @@ class CompilerContainer { |
|
|
|
this._view.versionSelector.removeAttribute('disabled') |
|
|
|
this._view.versionSelector.removeAttribute('disabled') |
|
|
|
this.queryParams.update({ version: this.data.selectedVersion }) |
|
|
|
this.queryParams.update({ version: this.data.selectedVersion }) |
|
|
|
let url |
|
|
|
let url |
|
|
|
if (customUrl) { |
|
|
|
if (customUrl !== '') { |
|
|
|
this.data.selectedVersion = customUrl |
|
|
|
this.data.selectedVersion = customUrl |
|
|
|
this._view.versionSelector.appendChild(yo`<option value="${customUrl}" selected>custom</option>`) |
|
|
|
this._view.versionSelector.appendChild(yo`<option value="${customUrl}" selected>custom</option>`) |
|
|
|
url = customUrl |
|
|
|
url = customUrl |
|
|
|