Skip to content

Commit acee934

Browse files
committed
treat library as dependencies for contract deployment
1 parent ecab599 commit acee934

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/contracts/contracts.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,15 @@ class ContractsManager {
137137
for (className in self.contracts) {
138138
contract = self.contracts[className];
139139

140-
if (contract.args === []) continue;
140+
// look in code for dependencies
141+
let libMatches = (contract.code.match(/\:(.*?)(?=_)/g) || []);
142+
for (let match of libMatches) {
143+
self.contractDependencies[className] = self.contractDependencies[className] || [];
144+
self.contractDependencies[className].push(match.substr(1));
145+
}
141146

147+
// look in arguments for dependencies
148+
if (contract.args === []) continue;
142149
let ref = contract.args;
143150
for (let j = 0; j < ref.length; j++) {
144151
let arg = ref[j];

test_app/app/contracts/test.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma solidity ^0.4.11;
22

3-
library AMyLib {
3+
library ZAMyLib {
44

55
function add(uint _a, uint _b) returns (uint _c) {
66
return _a + _b;
@@ -11,7 +11,7 @@ library AMyLib {
1111
contract Test {
1212

1313
function testAdd() constant returns (uint _result) {
14-
return AMyLib.add(1, 2);
14+
return ZAMyLib.add(1, 2);
1515
}
1616

1717
}

0 commit comments

Comments
 (0)