diff --git a/lib/deploy.js b/lib/deploy.js index a90eb30b..a4b30044 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -65,13 +65,20 @@ Deploy.prototype.deploy_contracts = function(env) { }); var transactionHash = contractObject["new"].apply(contractObject, contractParams).transactionHash; - this.deployedContracts[className] = transactionHash; // TODO: get this with sync until a different mechanism is implemented //this.deployedContracts[className] = contractAddress; //console.log("address is " + contractAddress); - console.log("deployed " + className + " with transaction hash " + transactionHash); - //console.log("deployed " + className + " at " + contractAddress); + console.log('trying to obtain ' + className + ' address...'); + var receipt = null; + while ((receipt = web3.eth.getTransactionReceipt(transactionHash)) === null) { + sleep.sleep(1); + } + var contractAddress = receipt.contractAddress; + this.deployedContracts[className] = contractAddress; + console.log('address is ' + contractAddress); + + console.log("deployed " + className + " at " + contractAddress); } } @@ -88,15 +95,8 @@ Deploy.prototype.generate_abi_file = function() { var contract = this.contractDB[className]; var abi = JSON.stringify(contract.compiled.info.abiDefinition); - var transactionHash = deployedContract; - //var contractAddress = deployedContract; + var contractAddress = deployedContract; - console.log('trying to obtain ' + className + ' address...'); - var receipt = null; - while ((receipt = web3.eth.getTransactionReceipt(transactionHash)) === null) { - sleep.sleep(1); - } - var contractAddress = receipt.contractAddress; console.log('address is ' + contractAddress); result += className + "Abi = " + abi + ";"; diff --git a/test/deploy.js b/test/deploy.js index 6070d22c..de02529b 100644 --- a/test/deploy.js +++ b/test/deploy.js @@ -61,7 +61,7 @@ describe('embark.deploy', function() { it("should deploy contracts", function() { var result = deploy.generate_abi_file(); - assert.strictEqual(result, "web3.setProvider(new web3.providers.HttpProvider('http://localhost:8101'));web3.eth.defaultAccount = web3.eth.accounts[0];var SimpleStorageAbi = 123;var SimpleStorageContract = web3.eth.contract(SimpleStorageAbi);var SimpleStorage = SimpleStorageContract.at('0x123');var AnotherStorageAbi = 234;var AnotherStorageContract = web3.eth.contract(AnotherStorageAbi);var AnotherStorage = AnotherStorageContract.at('0x234');"); + assert.strictEqual(result, "web3.setProvider(new web3.providers.HttpProvider('http://localhost:8101'));web3.eth.defaultAccount = web3.eth.accounts[0];SimpleStorageAbi = 123;SimpleStorageContract = web3.eth.contract(SimpleStorageAbi);SimpleStorage = SimpleStorageContract.at('0x123');AnotherStorageAbi = 234;AnotherStorageContract = web3.eth.contract(AnotherStorageAbi);AnotherStorage = AnotherStorageContract.at('0x234');"); }); }); });