adding pathToURL

uiCheck
LianaHus 5 years ago
parent c8238c3fbe
commit 18dde6ec1b
  1. 4
      src/app/compiler/compiler-helpers.js
  2. 2
      src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js
  3. 19
      src/app/compiler/compiler-utils.js
  4. 51
      src/app/tabs/compileTab/compilerContainer.js
  5. 6
      src/app/tabs/test-tab.js
  6. 1
      src/lib/helper.js

@ -1,5 +1,5 @@
'use strict'
import { canUseWorker } from './compiler-utils'
import { canUseWorker, urlFromVersion } from './compiler-utils'
import { Compiler } from 'remix-solidity'
import CompilerAbstract from './compiler-abstract'
@ -9,7 +9,7 @@ export const compile = async (compilationTargets, settings) => {
const compiler = new Compiler(() => {})
compiler.set('evmVersion', settings.evmVersion)
compiler.set('optimize', settings.optimize)
compiler.loadVersion(canUseWorker(settings.version), settings.compilerUrl)
compiler.loadVersion(canUseWorker(settings.version), urlFromVersion(settings.version))
compiler.event.register('compilationFinished', (success, compilationData, source) => {
if (!success) return reject(compilationData)
resolve(new CompilerAbstract(settings.version, compilationData, source))

@ -1,7 +1,6 @@
const ethutil = require('ethereumjs-util')
import * as packageJson from '../../../package.json'
import { Plugin } from '@remixproject/engine'
import { urlFromVersion } from './compiler-utils'
import { compile } from './compiler-helpers'
import globalRegistry from '../../global/registry'
@ -109,7 +108,6 @@ export default class FetchAndCompile extends Plugin {
languageName: data.metadata.language,
evmVersion: data.metadata.settings.evmVersion,
optimize: data.metadata.settings.optimizer.enabled,
compilerUrl: urlFromVersion(data.metadata.compiler.version)
}
try {
setTimeout(_ => this.emit('compiling', settings), 0)

@ -1,11 +1,15 @@
// const semver = require('semver')
const semver = require('semver')
/* global Worker */
export const baseUrl = 'https://solc-bin.ethereum.org/wasm'
export const baseURLBin = 'https://solc-bin.ethereum.org/bin'
export const baseURLWasm = 'https://solc-bin.ethereum.org/wasm'
export const pathToURL = []
export function urlFromVersion (version) {
return `${baseUrl}/soljson-v${version}.js`
return `${pathToURL[version]}/${version}`
}
/**
* Checks if the worker can be used to load a compiler.
* checks a compiler whitelist, browser support and OS.
@ -30,7 +34,14 @@ export function canUseWorker (selectedVersion) {
default :
isFromWhiteList = true
} */
return browserSupportWorker()// && (!isChrome || (isChrome && isFromWhiteList))
const version = semver.coerce(selectedVersion)
const isNightly = selectedVersion.includes('nightly')
return browserSupportWorker() &&
(
semver.gt(version, '0.6.3') ||
semver.gt(version, '0.3.5') && !isNightly
)
// && (!isChrome || (isChrome && isFromWhiteList))
}
function browserSupportWorker () {

@ -6,7 +6,7 @@ const addTooltip = require('../../ui/tooltip')
const semver = require('semver')
const modalDialogCustom = require('../../ui/modal-dialog-custom')
const css = require('../styles/compile-tab-styles')
import { canUseWorker, baseUrl } from '../../compiler/compiler-utils'
import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL } from '../../compiler/compiler-utils'
class CompilerContainer {
@ -25,7 +25,8 @@ class CompilerContainer {
allversions: null,
selectedVersion: null,
defaultVersion: 'soljson-v0.6.6+commit.6c089d02.js', // this default version is defined: in makeMockCompiler (for browser test) and in package.json (downloadsolc_root) for the builtin compiler
baseurl: baseUrl
baseURLWasm: baseURLWasm,
baseURLBin: baseURLBin
}
}
@ -383,7 +384,7 @@ class CompilerContainer {
if (this.data.selectedVersion.indexOf('soljson') !== 0 || helper.checkSpecialChars(this.data.selectedVersion)) {
return console.log('loading ' + this.data.selectedVersion + ' not allowed')
}
url = `${this.data.baseurl}/${this.data.selectedVersion}`
url = `${urlFromVersion(this.data.selectedVersion)}`
}
// Workers cannot load js on "file:"-URLs and we get a
@ -413,25 +414,59 @@ class CompilerContainer {
if (this._view.version) this._view.version.innerText = text
}
// fetching both normal and wasm builds and creating an array [version, baseUrl]
fetchAllVersion (callback) {
minixhr(`${this.data.baseurl}/list.json`, (json, event) => {
let allVersions, selectedVersion, allVersionsWasm, urls
// fetch normal builds
minixhr(`${this.data.baseURLBin}/list.json`, (json, event) => {
// @TODO: optimise and cache results to improve app loading times #2461
var allversions, selectedVersion
if (event.type !== 'error') {
try {
const data = JSON.parse(json)
allversions = data.builds.slice().reverse()
allVersions = data.builds.slice().reverse()
selectedVersion = this.data.defaultVersion
if (this.queryParams.get().version) selectedVersion = this.queryParams.get().version
// no fetching wasm builds
minixhr(`${this.data.baseURLWasm}/list.json`, (json, event) => {
// @TODO: optimise and cache results to improve app loading times #2461
if (event.type !== 'error') {
try {
const data = JSON.parse(json)
allVersionsWasm = data.builds.slice().reverse()
//selectedVersion = this.data.defaultVersion
if (this.queryParams.get().version) selectedVersion = this.queryParams.get().version
// rewriting all versions in allVersions which exist in allVersionsWasm
if (allVersionsWasm && allVersions)
allVersions.forEach((compiler, index) => {
const rewritten = allVersionsWasm.findIndex(oldCompiler => { return oldCompiler.longVersion === compiler.longVersion })
if (-1 !== rewritten) {
allVersions[index] = allVersionsWasm[rewritten]
pathToURL[compiler.path] = baseURLWasm
} else {
pathToURL[compiler.path] = baseURLBin
}
})
callback(allVersions, selectedVersion)
} catch (e) {
addTooltip('Cannot load compiler version list. It might have been blocked by an advertisement blocker. Please try deactivating any of them from this page and reload.')
}
} else {
allversions = [{ path: 'builtin', longVersion: 'latest local version' }]
allVersionsWasm = [{ path: 'builtin', longVersion: 'latest local version' }]
selectedVersion = 'builtin'
}
callback(allversions, selectedVersion)
//callback(allVersions, selectedVersion)
})
} catch (e) {
addTooltip('Cannot load compiler version list. It might have been blocked by an advertisement blocker. Please try deactivating any of them from this page and reload.')
}
} else {
allVersions = [{ path: 'builtin', longVersion: 'latest local version' }]
selectedVersion = 'builtin'
}
//callback(allVersions, selectedVersion)
})
}
scheduleCompilation () {

@ -4,7 +4,7 @@ var tooltip = require('../ui/tooltip')
var css = require('./styles/test-tab-styles')
var remixTests = require('remix-tests')
import { ViewPlugin } from '@remixproject/engine'
import { canUseWorker, baseUrl } from '../compiler/compiler-utils'
import { canUseWorker, urlFromVersion } from '../compiler/compiler-utils'
const TestTabLogic = require('./testTab/testTab')
@ -301,7 +301,7 @@ module.exports = class TestTab extends ViewPlugin {
let runningTest = {}
runningTest[path] = { content }
const {currentVersion, evmVersion, optimize} = this.compileTab.getCurrentCompilerConfig()
const currentCompilerUrl = baseUrl + '/' + currentVersion
const currentCompilerUrl = urlFromVersion(currentVersion)
const compilerConfig = {
currentCompilerUrl,
evmVersion,
@ -327,7 +327,7 @@ module.exports = class TestTab extends ViewPlugin {
const runningTest = {}
runningTest[testFilePath] = { content }
const {currentVersion, evmVersion, optimize} = this.compileTab.getCurrentCompilerConfig()
const currentCompilerUrl = baseUrl + '/' + currentVersion
const currentCompilerUrl = urlFromVersion(currentVersion)
const compilerConfig = {
currentCompilerUrl,
evmVersion,

@ -84,4 +84,3 @@ function find (args, query) {
})
return isMatch
}

Loading…
Cancel
Save