fix library deploy

pull/3094/head
yann300 7 years ago
parent d8d7241a6a
commit 01ae71fe79
  1. 15
      src/app/execution/txFormat.js
  2. 2
      src/app/tabs/run-tab.js
  3. 8
      src/recorder.js
  4. 4
      src/universal-dapp.js

@ -35,6 +35,7 @@ module.exports = {
/**
* build the transaction data
*
* @param {String} contractName
* @param {Object} contract - abi definition of the current contract.
* @param {Object} contracts - map of all compiled contracts.
* @param {Bool} isConstructor - isConstructor.
@ -44,7 +45,7 @@ module.exports = {
* @param {Function} callback - callback
* @param {Function} callbackStep - callbackStep
*/
buildData: function (contract, contracts, isConstructor, funAbi, params, udapp, callback, callbackStep) {
buildData: function (contractName, contract, contracts, isConstructor, funAbi, params, udapp, callback, callbackStep) {
var funArgs = ''
try {
funArgs = $.parseJSON('[' + params + ']')
@ -79,7 +80,7 @@ module.exports = {
callback('Error deploying required libraries: ' + err)
} else {
bytecodeToDeploy = bytecode + dataHex
return callback(null, { dataHex: bytecodeToDeploy, funAbi, funArgs, contractBytecode })
return callback(null, {dataHex: bytecodeToDeploy, funAbi, funArgs, contractBytecode, contractName: contractName})
}
}, callbackStep)
return
@ -89,7 +90,7 @@ module.exports = {
} else {
dataHex = Buffer.concat([helper.encodeFunctionId(funAbi), data]).toString('hex')
}
callback(null, { dataHex, funAbi, funArgs, contractBytecode })
callback(null, { dataHex, funAbi, funArgs, contractBytecode, contractName: contractName })
},
atAddress: function () {},
@ -116,7 +117,7 @@ module.exports = {
if (!library) {
return callback('Library ' + libraryName + ' not found.')
}
this.deployLibrary(libraryName, library, contracts, udapp, (err, address) => {
this.deployLibrary(libraryName, libraryShortName, library, contracts, udapp, (err, address) => {
if (err) {
return callback(err)
}
@ -130,7 +131,7 @@ module.exports = {
}, callbackStep)
},
deployLibrary: function (libraryName, library, contracts, udapp, callback, callbackStep) {
deployLibrary: function (libraryName, libraryShortName, library, contracts, udapp, callback, callbackStep) {
var address = library.address
if (address) {
return callback(null, address)
@ -139,11 +140,11 @@ module.exports = {
if (bytecode.indexOf('_') >= 0) {
this.linkBytecode(libraryName, contracts, udapp, (err, bytecode) => {
if (err) callback(err)
else this.deployLibrary(libraryName, library, contracts, udapp, callback, callbackStep)
else this.deployLibrary(libraryName, libraryShortName, library, contracts, udapp, callback, callbackStep)
}, callbackStep)
} else {
callbackStep(`creation of library ${libraryName} pending...`)
var data = {dataHex: bytecode, funAbi: {type: 'constructor'}, funArgs: [], contractBytecode: bytecode}
var data = {dataHex: bytecode, funAbi: {type: 'constructor'}, funArgs: [], contractBytecode: bytecode, contractName: libraryShortName}
udapp.runTx({ data: data, useCall: false }, (err, txResult) => {
if (err) {
return callback(err)

@ -395,7 +395,7 @@ function contractDropdown (appAPI, appEvents, instanceContainer) {
var constructor = txHelper.getConstructorInterface(selectedContract.contract.object.abi)
var args = createButtonInput.value
txFormat.buildData(selectedContract.contract.object, appAPI.getContracts(), true, constructor, args, appAPI.udapp(), (error, data) => {
txFormat.buildData(selectedContract.name, selectedContract.contract.object, appAPI.getContracts(), true, constructor, args, appAPI.udapp(), (error, data) => {
if (!error) {
appAPI.logMessage(`creation of ${selectedContract.name} pending...`)
txExecution.createContract(data, appAPI.udapp(), (error, txResult) => {

@ -30,12 +30,12 @@ class Recorder {
if (this.data._listen) {
var record = { value, parameters: payLoad.funArgs }
if (!to) {
var selectedContract = self._api.getSelectedContract()
var selectedContract = self._api.getContract(payLoad.contractName)
if (selectedContract) {
var abi = selectedContract.contract.object.abi
var abi = selectedContract.object.abi
var sha3 = ethutil.bufferToHex(ethutil.sha3(abi))
record.abi = sha3
record.contractName = selectedContract.name
record.contractName = payLoad.contractName
record.bytecode = payLoad.contractBytecode
self.data._abis[sha3] = abi
@ -195,7 +195,7 @@ class Recorder {
cb(data.error)
return
} else {
record.data = { dataHex: data.data, funArgs: tx.record.parameters, funAbi: fnABI, contractBytecode: tx.record.bytecode }
record.data = { dataHex: data.data, funArgs: tx.record.parameters, funAbi: fnABI, contractBytecode: tx.record.bytecode, contractName: tx.record.contractName }
}
self._api.udapp().runTx(record, function (err, txResult) {
if (err) {

@ -381,7 +381,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
logMsg = `call to ${args.contractName}.${(args.funABI.name) ? args.funABI.name : '(fallback)'}`
}
}
txFormat.buildData(args.contractAbi, self.contracts, false, args.funABI, inputField.value, self, (error, data) => {
txFormat.buildData(args.contractName, args.contractAbi, self.contracts, false, args.funABI, inputField.value, self, (error, data) => {
if (!error) {
if (isUserAction) {
if (!args.funABI.constant) {
@ -467,7 +467,7 @@ function execute (pipeline, env, callback) {
UniversalDApp.prototype.runTx = function (args, cb) {
var self = this
var tx = { to: args.to, data: args.data.dataHex, useCall: args.useCall, from: args.from, value: args.value }
var payLoad = { funAbi: args.data.funAbi, funArgs: args.data.funArgs, contractBytecode: args.data.contractBytecode } // contains decoded parameters
var payLoad = { funAbi: args.data.funAbi, funArgs: args.data.funArgs, contractBytecode: args.data.contractBytecode, contractName: args.data.contractName } // contains decoded parameters
var pipeline = [queryGasLimit]
if (!args.value) {
pipeline.push(queryValue)

Loading…
Cancel
Save