Merge pull request #804 from ethereum/fixLib

Fix library
pull/1/head
yann300 7 years ago committed by GitHub
commit 375c604e01
  1. 25
      src/app/execution/eventsDecoder.js
  2. 22
      src/app/execution/txFormat.js
  3. 2
      src/app/execution/txHelper.js
  4. 2
      src/app/tabs/run-tab.js
  5. 2
      src/universal-dapp.js

@ -35,8 +35,8 @@ class EventsDecoder {
this._decodeEvents(tx, receipt.logs, contract, contracts, cb)
}
_eventABI (contractName, compiledContracts) {
var contractabi = JSON.parse(compiledContracts[contractName].interface)
_eventABI (contractabi) {
contractabi = JSON.parse(contractabi.interface)
var eventABI = {}
contractabi.forEach(function (funABI, i) {
if (funABI.type !== 'event') {
@ -48,13 +48,30 @@ class EventsDecoder {
return eventABI
}
_eventsABI (compiledContracts) {
var eventsABI = {}
for (var contract in compiledContracts) {
eventsABI[contract] = this._eventABI(compiledContracts[contract])
}
return eventsABI
}
_event (hash, eventsABI) {
for (var k in eventsABI) {
if (eventsABI[k][hash]) {
return eventsABI[k][hash]
}
}
return null
}
_decodeEvents (tx, logs, contractName, compiledContracts, cb) {
var eventABI = this._eventABI(contractName, compiledContracts)
var eventsABI = this._eventsABI(compiledContracts)
var events = []
for (var i in logs) {
// [address, topics, mem]
var log = logs[i]
var abi = eventABI[log.topics[0].replace('0x', '')]
var abi = this._event(log.topics[0].replace('0x', ''), eventsABI)
if (abi) {
var event
try {

@ -18,8 +18,9 @@ module.exports = {
* @param {Object} params - input paramater of the function to call
* @param {Object} udapp - udapp
* @param {Function} callback - callback
* @param {Function} callbackStep - callbackStep
*/
buildData: function (contract, contracts, isConstructor, funAbi, params, udapp, callback) {
buildData: function (contract, contracts, isConstructor, funAbi, params, udapp, callback, callbackStep) {
var funArgs = ''
try {
funArgs = $.parseJSON('[' + params + ']')
@ -54,7 +55,7 @@ module.exports = {
bytecodeToDeploy = bytecode + dataHex
return callback(null, bytecodeToDeploy)
}
})
}, callbackStep)
return
} else {
dataHex = bytecodeToDeploy + dataHex
@ -67,7 +68,7 @@ module.exports = {
atAddress: function () {},
linkBytecode: function (contract, contracts, udapp, callback) {
linkBytecode: function (contract, contracts, udapp, callback, callbackStep) {
var bytecode = contract.bytecode
if (bytecode.indexOf('_') < 0) {
return callback(null, bytecode)
@ -81,7 +82,7 @@ module.exports = {
if (!libraryabi) {
return callback('Library ' + libraryName + ' not found.')
}
this.deployLibrary(libraryabi, udapp, (err, address) => {
this.deployLibrary(libraryName, libraryabi, udapp, (err, address) => {
if (err) {
return callback(err)
}
@ -95,22 +96,23 @@ module.exports = {
bytecode = bytecode.replace(libLabel, hexAddress)
}
contract.bytecode = bytecode
this.linkBytecode(contract, contracts, udapp, callback)
})
this.linkBytecode(contract, contracts, udapp, callback, callbackStep)
}, callbackStep)
},
deployLibrary: function (libraryName, library, udapp, callback) {
deployLibrary: function (libraryName, library, udapp, callback, callbackStep) {
var address = library.address
if (address) {
return callback(null, address)
}
var bytecode = library.bytecode
if (bytecode.indexOf('_') >= 0) {
this.linkBytecode(libraryName, (err, bytecode) => {
this.linkBytecode(libraryName, library, udapp, (err, bytecode) => {
if (err) callback(err)
else this.deployLibrary(libraryName, callback)
})
else this.deployLibrary(libraryName, library, udapp, callback, callbackStep)
}, callbackStep)
} else {
callbackStep(`creation of library ${libraryName} pending...`)
udapp.runTx({ data: bytecode, useCall: false }, (err, txResult) => {
if (err) {
return callback(err)

@ -91,7 +91,7 @@ module.exports = {
getContractByName: function (contractName, contracts) {
for (var c in contracts) {
if (contracts[c].name === contractName) {
if (c === contractName) {
return contracts[c]
}
}

@ -323,6 +323,8 @@ function contractDropdown (appAPI, appEvents, instanceContainer) {
} else {
appAPI.logMessage(`creation of ${contractName} errored: ` + error)
}
}, (msg) => {
appAPI.logMessage(msg)
})
}

@ -417,6 +417,8 @@ UniversalDApp.prototype.getCallButton = function (args) {
} else {
self._api.logMessage(`${logMsg} errored: ${error} `)
}
}, (msg) => {
self._api.logMessage(msg)
})
}

Loading…
Cancel
Save