Skip to content

Commit c0420d7

Browse files
committed
support deploy commands specifying contract
1 parent 3757e41 commit c0420d7

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

lib/deploy.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,12 @@ Deploy.prototype.execute_cmds = function(cmds) {
117117
for (var i = 0; i < cmds.length; i++) {
118118
var cmd = cmds[i];
119119

120-
// need to initialize all variables of deployed contracts making them
121-
// available to deployment
120+
for(className in this.deployedContracts) {
121+
var contractAddress = this.deployedContracts[className];
122+
123+
var re = new RegExp("\\$" + className, 'g');
124+
cmd = cmd.replace(re, '"' + contractAddress + '"');
125+
}
122126

123127
console.log("executing: " + cmd);
124128
eval(cmd);

test/deploy.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ describe('embark.deploy', function() {
135135
deploy.deploy_contracts("development");
136136

137137
it("should deploy contracts", function() {
138-
var all_contracts = ['DataSource', 'Manager'];
138+
var all_contracts = ['DataSource', 'MyDataSource', 'Manager'];
139139
for(var i=0; i < all_contracts.length; i++) {
140140
var className = all_contracts[i];
141141

@@ -149,10 +149,17 @@ describe('embark.deploy', function() {
149149

150150
data_source_abi = deploy.contractDB['DataSource'].compiled.info.abiDefinition;
151151
data_source_address = deploy.deployedContracts['DataSource'];
152+
my_data_source_abi = deploy.contractDB['MyDataSource'].compiled.info.abiDefinition;
153+
my_data_source_address = deploy.deployedContracts['MyDataSource'];
154+
manager_abi = deploy.contractDB['Manager'].compiled.info.abiDefinition;
155+
manager_address = deploy.deployedContracts['Manager'];
152156

153157
DataSource = web3.eth.contract(data_source_abi).at(data_source_address);
158+
MyDataSource = web3.eth.contract(my_data_source_abi).at(my_data_source_address);
159+
ManagerSource = web3.eth.contract(manager_abi).at(manager_address);
154160

155161
assert.equal(DataSource.storeData().toNumber(), 5);
162+
assert.equal(Manager.data().toString(), my_data_source_address);
156163
});
157164

158165
});

test/support/arguments3.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
development:
22
DataSource:
33
args:
4+
MyDataSource:
5+
args:
6+
instanceOf: DataSource
47
Manager:
58
stubs:
69
- DataSource
710
args:
811
- $DataSource
912
onDeploy:
1013
- DataSource.set(5)
14+
- Manager.update($MyDataSource)
1115
staging:

test/support/contracts/manager.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
contract Manager {
2-
address data;
2+
address public data;
33

44
function Manager(address dataAddress) {
55
data = dataAddress;
66
}
77

8+
function update(address _addr) {
9+
data = _addr;
10+
}
811
}

0 commit comments

Comments
 (0)