[f] Fixes #965 - "Console doesnt have contract objects for contracts with pre-defined addresses configured".

[f] Fix for sometimes incorrect empty code detection in contract_deployer.js ("0x" vs "0x0").
This commit is contained in:
hodlbank 2018-10-18 18:00:02 +00:00 committed by Pascal Precht
parent 985358b088
commit 870d9a814a
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 3 additions and 4 deletions

View File

@ -144,6 +144,7 @@ class ContractDeployer {
});
},
function deployIt(next) {
let skipBytecodeCheck = false;
if (contract.address !== undefined) {
try {
utils.toChecksumAddress(contract.address);
@ -155,9 +156,7 @@ class ContractDeployer {
return next(e.message);
}
contract.deployedAddress = contract.address;
self.logFunction(contract)(contract.className.bold.cyan + __(" already deployed at ").green + contract.address.bold.cyan);
self.events.emit("deploy:contract:deployed", contract);
return next();
skipBytecodeCheck = true;
}
self.plugins.emitAndRunActionsForEvent('deploy:contract:shouldDeploy', {contract: contract, shouldDeploy: true}, function(_err, params) {
@ -175,7 +174,7 @@ class ContractDeployer {
}
self.blockchain.getCode(trackedContract.address, function(_getCodeErr, codeInChain) {
if (codeInChain !== "0x") {
if (codeInChain.length > 3 || skipBytecodeCheck) { // it is "0x" or "0x0" for empty code, depending on web3 version
self.contractAlreadyDeployed(contract, trackedContract, next);
} else {
self.deployContract(contract, next);