wait & set contract addresses on deployment
This commit is contained in:
parent
b9c0b8f9e5
commit
505ca5d14f
|
@ -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 + ";";
|
||||
|
|
|
@ -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');");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue