option for generating metadata

pull/1/head
yann300 6 years ago
parent 8fa95a0edb
commit f6ebee85e6
  1. 2
      src/app/files/compiler-metadata.js
  2. 3
      src/app/panels/file-panel.js
  3. 1
      src/app/tabs/run-tab.js
  4. 11
      src/app/tabs/settings-tab.js

@ -13,6 +13,7 @@ class CompilerMetadata {
var self = this
self._events.compiler.register('compilationFinished', (success, data, source) => {
if (!success) return
if (!self._opts.config.get('settings/generate-contract-metadata')) return
var provider = self._opts.fileManager.currentFileProvider()
var path = self._opts.fileManager.currentPath()
if (provider && path) {
@ -71,6 +72,7 @@ class CompilerMetadata {
var fileName = path + '/' + contractName + '.json'
provider.get(fileName, (error, content) => {
if (error) return callback(error)
if (!content) return callback()
try {
var metadata = JSON.parse(content)
return callback(null, metadata[name + ':' + id] || metadata[name] || metadata[id] || metadata[name.toLowerCase() + ':' + id] || metadata[name.toLowerCase()])

@ -68,7 +68,8 @@ function filepanel (localRegistry) {
},
{
fileManager: self._deps.fileManager,
compiler: self._deps.compiler
compiler: self._deps.compiler,
config: self._deps.config
}
)
self._compilerMetadata.syncContractMetadata()

@ -397,6 +397,7 @@ function contractDropdown (events, self) {
self._deps.udapp.runTx(data, runTxCallback)
})
} else {
if (Object.keys(selectedContract.contract.object.evm.bytecode.linkReferences).length) self._deps.logCallback(`linking ${JSON.stringify(selectedContract.contract.object.evm.bytecode.linkReferences, null, '\t')} using ${JSON.stringify(contractMetadata.linkReferences, null, '\t')}`)
txFormat.encodeConstructorCallAndLinkLibraries(selectedContract.contract.object, args, constructor, contractMetadata.linkReferences, selectedContract.contract.object.evm.bytecode.linkReferences, (error, data) => {
createInstanceCallback(error, selectedContract, data)
})

@ -26,7 +26,7 @@ module.exports = class SettingsTab {
}
self._view = { /* eslint-disable */
el: null,
optionVM: null, personal: null, warnPersonalMode: null,
optionVM: null, personal: null, warnPersonalMode: null, generateContractMetadata: null,
pluginInput: null, versionSelector: null, version: null,
theme: { dark: null, light: null },
plugins: {},
@ -62,6 +62,8 @@ module.exports = class SettingsTab {
It is not recommended (and also most likely not relevant) to use this mode with an injected provider (Mist, Metamask, ...) or with JavaScript VM.
Remix never persist any passphrase.`.split('\n').map(s => s.trim()).join(' ')
self._view.warnPersonalMode = yo`<i title=${warnText} class="${css.icon} fa fa-exclamation-triangle" aria-hidden="true"></i>`
self._view.generateContractMetadata = yo`<input onchange=${onchangeGenerateContractMetadata} id="generatecontractmetadata" type="checkbox">`
if (self._deps.config.get('settings/generate-contract-metadata')) self._view.generateContractMetadata.setAttribute('checked', '')
self._view.pluginInput = yo`<textarea rows="4" cols="70" id="plugininput" type="text" class="${css.pluginTextArea}" ></textarea>`
self._view.theme.light = yo`<input onchange=${onswitch2lightTheme} class="${css.col1}" name="theme" id="themeLight" type="radio">`
@ -71,6 +73,10 @@ module.exports = class SettingsTab {
self._view.config.general = yo`
<div class="${css.info}">
<div class=${css.title}>General settings</div>
<div class="${css.crow}">
<div>${self._view.generateContractMetadata}</div>
<span class="${css.checkboxText}">Generate contract metadata. Generate a JSON file in the contract folder. Allows to specify library addresses the contract depends on. If nothing is specified, Remix deploy libraries automatically.</span>
</div>
<div class="${css.crow}">
<div>${self._view.optionVM}</div>
<span class="${css.checkboxText}">Always use Ethereum VM at Load</span>
@ -176,6 +182,9 @@ module.exports = class SettingsTab {
loadPlugins([json], {removable: true})
}
function onchangeGenerateContractMetadata (event) {
self._deps.config.set('settings/generate-contract-metadata', !self._deps.config.get('settings/generate-contract-metadata'))
}
function onchangeOption (event) {
self._deps.config.set('settings/always-use-vm', !self._deps.config.get('settings/always-use-vm'))
}

Loading…
Cancel
Save