autodeploy libs when creating instances

pull/1/head
yann300 7 years ago
parent 1deb3279e9
commit 3a7b34e9c5
  1. 41
      src/app/tabs/run-tab.js

@ -387,19 +387,7 @@ function contractDropdown (events, self) {
selectContractNames.addEventListener('change', setInputParamsPlaceHolder)
// DEPLOY INSTANCE
function createInstance (args) {
var selectedContract = getSelectedContract()
if (selectedContract.contract.object.evm.bytecode.object.length === 0) {
modalDialogCustom.alert('This contract does not implement all functions and thus cannot be created.')
return
}
var constructor = txHelper.getConstructorInterface(selectedContract.contract.object.abi)
self._deps.filePanel.compilerMetadata().metadataOf(selectedContract.name, (error, librariesAddresses) => {
if (error) return self._deps.logCallback(`creation of ${selectedContract.name} errored: ` + error)
txFormat.encodeConstructorCallAndLinkLibraries(selectedContract.contract.object, constructor, args, librariesAddresses.linkReferences, selectedContract.contract.object.evm.bytecode.linkReferences, (error, data) => {
function createInstanceCallback (error, selectedContract, data) {
if (error) return self._deps.logCallback(`creation of ${selectedContract.name} errored: ` + error)
self._deps.logCallback(`creation of ${selectedContract.name} pending...`)
self._deps.udapp.createContract(data, (error, txResult) => {
@ -422,7 +410,34 @@ function contractDropdown (events, self) {
instanceContainer.appendChild(self._deps.udappUI.renderInstance(selectedContract.contract.object, address, selectContractNames.value))
}
})
}
// DEPLOY INSTANCE
function createInstance (args) {
var selectedContract = getSelectedContract()
if (selectedContract.contract.object.evm.bytecode.object.length === 0) {
modalDialogCustom.alert('This contract does not implement all functions and thus cannot be created.')
return
}
var constructor = txHelper.getConstructorInterface(selectedContract.contract.object.abi)
self._deps.filePanel.compilerMetadata().metadataOf(selectedContract.name, (error, contractMetadata) => {
if (error) return self._deps.logCallback(`creation of ${selectedContract.name} errored: ` + error)
if (contractMetadata.autoDeployLib) {
txFormat.buildData(selectedContract.name, selectedContract.contract.object, self._deps.compiler.getContracts(), true, constructor, args, (error, data) => {
createInstanceCallback(error, selectedContract, data)
}, (msg) => {
self._deps.logCallback(msg)
}, (data, runTxCallback) => {
// called for libraries deployment
self._deps.udapp.runTx(data, runTxCallback)
})
} else {
txFormat.encodeConstructorCallAndLinkLibraries(selectedContract.contract.object, args, constructor, contractMetadata.linkReferences, selectedContract.contract.object.evm.bytecode.linkReferences, (error, data) => {
createInstanceCallback(error, selectedContract, data)
})
}
})
}

Loading…
Cancel
Save