compiler iframe, load default parameters

pull/1342/head
yann300 3 years ago committed by davidzagi93@gmail.com
parent 6f34305199
commit 346481aa6b
  1. 53
      apps/solidity-compiler/src/app/compiler.ts

@ -17,6 +17,25 @@ const profile = {
methods: ['getCompilationResult', 'compile', 'compileWithParameters', 'setCompilerConfig', 'compileFile' ,'getCompilerState'] methods: ['getCompilationResult', 'compile', 'compileWithParameters', 'setCompilerConfig', 'compileFile' ,'getCompilerState']
} }
const defaultAppParameters = {
'hideWarnings': () => false,
'autoCompile': () => false,
'includeNightlies': () => false
}
const defaultCompilerParameters = {
runs: '200',
optimize: false,
version: 'soljson-v0.8.7+commit.e28d00a7',
evmVersion: null, // default
language: 'Solidity'
}
const getOptimize = () => {
let value = localStorage.getItem('optimize') || defaultCompilerParameters['optimize']
value = (value === 'false' || value === null || value === undefined) ? false : value
value = value === 'true' ? true : false
}
export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements ICompilerApi { export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements ICompilerApi {
constructor () { constructor () {
@ -29,26 +48,30 @@ export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements
} }
getCompilerParameters () { getCompilerParameters () {
return { const params = {
runs: '200', runs: localStorage.getItem('runs') || defaultCompilerParameters['runs'],
optimize: false, optimize: localStorage.getItem('optimize') === 'true' ? true : false,
version: '0.8.7+commit.e28d00a7', version: localStorage.getItem('version') || defaultCompilerParameters['version'],
evmVersion: null, // default evmVersion: localStorage.getItem('evmVersion') || defaultCompilerParameters['evmVersion'], // default
language: 'Solidity' language: localStorage.getItem('language') || defaultCompilerParameters['language']
} }
return params
} }
setCompilerParameters (params) {} setCompilerParameters (params) {
for (const key in Object.keys(params)) {
localStorage.setItem(key, params[key])
}
}
getAppParameter (name) { getAppParameter (name) {
const conf = { const param = localStorage.getItem(name) || defaultAppParameters[name]
'currentFile': () => this.currentFile, if (param === 'true') return true
'hideWarnings': () => false, if (param === 'false') return false
'autoCompile': () => false, return param
'includeNightlies': () => false
}
return conf[name]()
} }
setAppParameter (name, value) {} setAppParameter (name, value) {
localStorage.setItem(name, value)
}
} }

Loading…
Cancel
Save