mirror of https://github.com/embarklabs/embark.git
track deployed contracts taking into account swarm hash inserted by solc
This commit is contained in:
parent
3525754cde
commit
dbb0b0b171
|
@ -102,6 +102,8 @@ Compiler.prototype.compile_solidity = function(contractFiles, cb) {
|
|||
compiled_object[className] = {};
|
||||
compiled_object[className].code = contract.bytecode;
|
||||
compiled_object[className].runtimeBytecode = contract.runtimeBytecode;
|
||||
compiled_object[className].realRuntimeBytecode = contract.runtimeBytecode.slice(0, -68);
|
||||
compiled_object[className].swarmHash = contract.runtimeBytecode.slice(-68).slice(0,64);
|
||||
compiled_object[className].gasEstimates = contract.gasEstimates;
|
||||
compiled_object[className].functionHashes = contract.functionHashes;
|
||||
compiled_object[className].abiDefinition = JSON.parse(contract.interface);
|
||||
|
|
|
@ -75,6 +75,8 @@ ContractsManager.prototype.build = function(done) {
|
|||
|
||||
contract.code = compiledContract.code;
|
||||
contract.runtimeBytecode = compiledContract.runtimeBytecode;
|
||||
contract.realRuntimeBytecode = (contract.realRuntimeBytecode || contract.runtimeBytecode);
|
||||
contract.swarmHash = compiledContract.swarmHash;
|
||||
contract.gasEstimates = compiledContract.gasEstimates;
|
||||
contract.functionHashes = compiledContract.functionHashes;
|
||||
contract.abiDefinition = compiledContract.abiDefinition;
|
||||
|
|
|
@ -53,13 +53,13 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
|
|||
realArgs = self.determineArguments(params || contract.args);
|
||||
|
||||
contract.deployedAddress = contract.address;
|
||||
self.deployTracker.trackContract(contract.className, contract.code, realArgs, contract.address);
|
||||
self.deployTracker.trackContract(contract.className, contract.realRuntimeBytecode, realArgs, contract.address);
|
||||
self.deployTracker.save();
|
||||
self.logger.contractsState(self.contractsManager.contractsState());
|
||||
return callback();
|
||||
}
|
||||
|
||||
var trackedContract = self.deployTracker.getContract(contract.className, contract.code, contract.args);
|
||||
var trackedContract = self.deployTracker.getContract(contract.className, contract.realRuntimeBytecode, contract.args);
|
||||
|
||||
if (trackedContract && this.web3.eth.getCode(trackedContract.address) !== "0x") {
|
||||
self.logger.info(contract.className.bold.cyan + " already deployed at ".green + trackedContract.address.bold.cyan);
|
||||
|
@ -74,7 +74,7 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
|
|||
if (err) {
|
||||
return callback(new Error(err));
|
||||
}
|
||||
self.deployTracker.trackContract(contract.className, contract.code, realArgs, address);
|
||||
self.deployTracker.trackContract(contract.className, contract.realRuntimeBytecode, realArgs, address);
|
||||
self.deployTracker.save();
|
||||
self.logger.contractsState(self.contractsManager.contractsState());
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue