@@ -8,11 +8,15 @@ var BigNumber = require('bignumber.js');
88
99// this is a temporary module to deploy a single contract, will be refactored
1010
11- SingleDeploy = function ( compiledContracts , _web3 ) {
11+ SingleDeploy = function ( compiledContracts , gasLimit , gasPrice , _web3 ) {
1212 if ( _web3 !== undefined ) {
1313 web3 = _web3 ;
1414 }
1515 this . compiledContracts = compiledContracts ;
16+ this . gasLimit = gasLimit ;
17+ this . gasPrice = gasPrice ;
18+ this . deployedContracts = { } ;
19+ web3 . eth . defaultAccount = web3 . eth . coinbase ;
1620} ;
1721
1822SingleDeploy . waitForContract = function ( transactionHash , cb ) {
@@ -21,7 +25,7 @@ SingleDeploy.waitForContract = function(transactionHash, cb) {
2125 cb ( receipt . contractAddress ) ;
2226 }
2327 else {
24- Deploy . waitForContract ( transactionHash , cb ) ;
28+ SingleDeploy . waitForContract ( transactionHash , cb ) ;
2529 }
2630 } ) ;
2731} ;
@@ -32,24 +36,25 @@ SingleDeploy.prototype.deploy_contract = function(contractObject, contractParams
3236 cb ( contract . address ) ;
3337 }
3438 else {
35- Deploy . waitForContract ( contract . transactionHash , cb ) ;
39+ SingleDeploy . waitForContract ( contract . transactionHash , cb ) ;
3640 }
3741 } ;
3842
3943 contractParams . push ( callback ) ;
4044 contractObject [ "new" ] . apply ( contractObject , contractParams ) ;
4145} ;
4246
43- Deploy . prototype . deploy_a_contract = function ( className , args , cb ) {
47+ SingleDeploy . prototype . deploy_a_contract = function ( className , args , cb ) {
48+ var self = this ;
4449 var contract = this . compiledContracts [ className ] ;
45- var contractObject = web3 . eth . contract ( contract . compiled . info . abiDefinition ) ;
50+ var contractObject = web3 . eth . contract ( contract . info . abiDefinition ) ;
4651
4752 contractParams = args . slice ( ) ;
4853 contractParams . push ( {
49- from : primaryAddress ,
50- data : contract . compiled . code ,
51- gas : contract . gasLimit ,
52- gasPrice : contract . gasPrice
54+ from : web3 . eth . coinbase ,
55+ data : contract . code ,
56+ gas : this . gasLimit ,
57+ gasPrice : this . gasPrice
5358 } ) ;
5459
5560 console . log ( 'trying to obtain ' + className + ' address...' ) ;
@@ -62,6 +67,7 @@ Deploy.prototype.deploy_a_contract = function(className, args, cb) {
6267 console . log ( "=========" ) ;
6368 }
6469
70+ self . deployedContracts [ className ] = contractAddress ;
6571 cb ( ) ;
6672 } ) ;
6773
@@ -82,14 +88,13 @@ SingleDeploy.prototype.generate_provider_file = function() {
8288
8389SingleDeploy . prototype . generate_abi_file = function ( ) {
8490 var result = "" ;
85-
8691 result += 'blockchain = ' + JSON . stringify ( this . blockchainConfig ) + ';' ;
8792
8893 for ( className in this . deployedContracts ) {
8994 var deployedContract = this . deployedContracts [ className ] ;
90- var contract = this . contractDB [ className ] ;
95+ var contract = this . compiledContracts [ className ] ;
9196
92- var abi = JSON . stringify ( contract . compiled . info . abiDefinition ) ;
97+ var abi = JSON . stringify ( contract . info . abiDefinition ) ;
9398 var contractAddress = deployedContract ;
9499
95100 console . log ( 'address is ' + contractAddress ) ;
0 commit comments