[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) { function deployIt(next) {
let skipBytecodeCheck = false;
if (contract.address !== undefined) { if (contract.address !== undefined) {
try { try {
utils.toChecksumAddress(contract.address); utils.toChecksumAddress(contract.address);
@ -155,9 +156,7 @@ class ContractDeployer {
return next(e.message); return next(e.message);
} }
contract.deployedAddress = contract.address; contract.deployedAddress = contract.address;
self.logFunction(contract)(contract.className.bold.cyan + __(" already deployed at ").green + contract.address.bold.cyan); skipBytecodeCheck = true;
self.events.emit("deploy:contract:deployed", contract);
return next();
} }
self.plugins.emitAndRunActionsForEvent('deploy:contract:shouldDeploy', {contract: contract, shouldDeploy: true}, function(_err, params) { 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) { 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); self.contractAlreadyDeployed(contract, trackedContract, next);
} else { } else {
self.deployContract(contract, next); self.deployContract(contract, next);