Merge pull request #1551 from ethereum/addNewCompilationMetadata

Contract metadata
pull/1/head
yann300 6 years ago committed by GitHub
commit b8514e7282
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      src/app/files/compiler-metadata.js
  2. 2
      src/app/tabs/run-tab.js
  3. 6
      test-browser/tests/simpleContract.js

@ -18,6 +18,8 @@ class CompilerMetadata {
var path = self._opts.fileManager.currentPath()
if (provider && path) {
self._opts.compiler.visitContracts((contract) => {
if (contract.file !== source.target) return
var fileName = path + '/' + contract.name + '.json'
provider.get(fileName, (error, content) => {
if (!error) {
@ -29,11 +31,23 @@ class CompilerMetadata {
console.log(e)
}
var deploy = metadata.deploy || {}
self.networks.forEach((network) => {
metadata[network] = self._syncContext(contract, metadata[network] || {})
deploy[network] = self._syncContext(contract, deploy[network] || {})
})
provider.set(fileName, JSON.stringify(metadata, null, '\t'))
var data = {
deploy,
data: {
bytecode: contract.object.evm.bytecode,
deployedBytecode: contract.object.evm.deployedBytecode,
gasEstimates: contract.object.evm.gasEstimates,
methodIdentifiers: contract.object.evm.methodIdentifiers
},
abi: contract.object.abi
}
provider.set(fileName, JSON.stringify(data, null, '\t'))
}
})
})
@ -60,7 +74,7 @@ class CompilerMetadata {
return metadata
}
metadataOf (contractName, callback) {
deployMetadataOf (contractName, callback) {
var self = this
var provider = self._opts.fileManager.currentFileProvider()
var path = self._opts.fileManager.currentPath()
@ -75,6 +89,7 @@ class CompilerMetadata {
if (!content) return callback()
try {
var metadata = JSON.parse(content)
metadata = metadata.deploy || {}
return callback(null, metadata[name + ':' + id] || metadata[name] || metadata[id] || metadata[name.toLowerCase() + ':' + id] || metadata[name.toLowerCase()])
} catch (e) {
callback(e.message)

@ -440,7 +440,7 @@ function contractDropdown (events, self) {
var forceSend = () => {
var constructor = txHelper.getConstructorInterface(selectedContract.contract.object.abi)
self._deps.filePanel.compilerMetadata().metadataOf(selectedContract.name, (error, contractMetadata) => {
self._deps.filePanel.compilerMetadata().deployMetadataOf(selectedContract.name, (error, contractMetadata) => {
if (error) return self._deps.logCallback(`creation of ${selectedContract.name} errored: ` + error)
if (!contractMetadata || (contractMetadata && contractMetadata.autoDeployLib)) {
txFormat.buildData(selectedContract.name, selectedContract.contract.object, compiler.getContracts(), true, constructor, args, (error, data) => {

@ -118,7 +118,7 @@ function checkDeployShouldFail (browser, callback) {
contractHelper.switchFile(browser, 'browser/test.json', () => {
browser.getEditorValue((content) => {
var config = JSON.parse(content)
config['VM:-'].autoDeployLib = false
config.deploy['VM:-'].autoDeployLib = false
browser.setEditorValue(JSON.stringify(config), () => {
contractHelper.switchFile(browser, 'browser/Untitled5.sol', () => {
contractHelper.selectContract(browser, 'test', () => { // deploy lib
@ -136,8 +136,8 @@ function checkDeployShouldSucceed (browser, address, callback) {
contractHelper.switchFile(browser, 'browser/test.json', () => {
browser.getEditorValue((content) => {
var config = JSON.parse(content)
config['VM:-'].autoDeployLib = false
config['VM:-']['linkReferences']['browser/Untitled5.sol'].lib = address
config.deploy['VM:-'].autoDeployLib = false
config.deploy['VM:-']['linkReferences']['browser/Untitled5.sol'].lib = address
browser.setEditorValue(JSON.stringify(config), () => {
contractHelper.switchFile(browser, 'browser/Untitled5.sol', () => {
contractHelper.selectContract(browser, 'test', () => { // deploy lib

Loading…
Cancel
Save