File tree Expand file tree Collapse file tree 7 files changed +45
-4
lines changed
boilerplate/config/development Expand file tree Collapse file tree 7 files changed +45
-4
lines changed Original file line number Diff line number Diff line change 11{
2- "config" : {},
2+ "config" : {
3+ "homesteadBlock" : 1
4+ },
35 "nonce" : " 0x0000000000000042" ,
46 "difficulty" : " 0x0" ,
57 "alloc" : {
Original file line number Diff line number Diff line change 11{
2- "config" : {},
2+ "config" : {
3+ "homesteadBlock" : 1
4+ },
35 "nonce" : " 0x0000000000000042" ,
46 "difficulty" : " 0x0" ,
57 "alloc" : {
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ class Compiler {
9595 // [2] classname
9696 const regex = / ( .* ) : ( .* ) / ;
9797 const className = contractName . match ( regex ) [ 2 ] ;
98+ const filename = contractName . match ( regex ) [ 1 ] ;
9899
99100 compiled_object [ className ] = { } ;
100101 compiled_object [ className ] . code = contract . bytecode ;
@@ -104,7 +105,9 @@ class Compiler {
104105 compiled_object [ className ] . gasEstimates = contract . gasEstimates ;
105106 compiled_object [ className ] . functionHashes = contract . functionHashes ;
106107 compiled_object [ className ] . abiDefinition = JSON . parse ( contract . interface ) ;
108+ compiled_object [ className ] . filename = filename
107109 }
110+
108111 callback ( null , compiled_object ) ;
109112 }
110113 ] , function ( err , result ) {
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ class ContractsManager {
6161 contract . gasEstimates = compiledContract . gasEstimates ;
6262 contract . functionHashes = compiledContract . functionHashes ;
6363 contract . abiDefinition = compiledContract . abiDefinition ;
64+ contract . filename = compiledContract . filename ;
6465
6566 contract . gas = ( contractConfig && contractConfig . gas ) || self . contractsConfig . gas || 'auto' ;
6667 self . adjustGas ( contract ) ;
Original file line number Diff line number Diff line change @@ -105,18 +105,32 @@ class Deploy {
105105 return callback ( new Error ( err ) ) ;
106106 }
107107
108+ let contractCode = contract . code ;
109+ let contractsList = self . contractsManager . listContracts ( ) ;
110+ for ( let contractObj of contractsList ) {
111+ let filename = contractObj . filename ;
112+ let deployedAddress = contractObj . deployedAddress ;
113+ if ( deployedAddress ) {
114+ deployedAddress = deployedAddress . substr ( 2 ) ;
115+ }
116+ let linkReference = '__' + filename + ":" + contractObj . className ;
117+ let toReplace = linkReference + "_" . repeat ( 40 - linkReference . length ) ;
118+ contractCode = contractCode . replace ( toReplace , deployedAddress ) ;
119+ }
120+
108121 // TODO: probably needs to be defaultAccount
109122 // TODO: it wouldn't necessary be the first address
110123 // use defined blockchain address or first address
111124 contractParams . push ( {
112125 //from: this.web3.eth.coinbase,
113126 from : accounts [ 0 ] ,
114- data : "0x" + contract . code ,
127+ data : "0x" + contractCode ,
115128 gas : contract . gas ,
116129 gasPrice : contract . gasPrice
117130 } ) ;
118131
119132 self . logger . info ( "deploying " + contract . className . bold . cyan + " with " . green + contract . gas + " gas" . green ) ;
133+
120134 contractParams . push ( function ( err , transaction ) {
121135 self . logger . contractsState ( self . contractsManager . contractsState ( ) ) ;
122136
Original file line number Diff line number Diff line change 1+ pragma solidity ^ 0.4.11 ;
2+
3+ library AMyLib {
4+
5+ function add (uint _a , uint _b ) returns (uint _c ) {
6+ return _a + _b;
7+ }
8+
9+ }
10+
11+ contract Test {
12+
13+ function testAdd () constant returns (uint _result ) {
14+ return AMyLib.add (1 , 2 );
15+ }
16+
17+ }
Original file line number Diff line number Diff line change 11{
2- "config" : {},
2+ "config" : {
3+ "homesteadBlock" : 1
4+ },
35 "nonce" : " 0x0000000000000042" ,
46 "difficulty" : " 0x0" ,
57 "alloc" : {
You can’t perform that action at this time.
0 commit comments