@@ -14,9 +14,7 @@ class DevFunds {
1414 this . networkId = null ;
1515 this . balance = Web3 . utils . toWei ( "1" , "ether" ) ;
1616 if ( this . blockchainConfig . account . balance ) {
17- console . dir ( '[blockchain/dev_funds]: converting balance from ' + this . blockchainConfig . account . balance ) ;
1817 this . balance = getWeiBalanceFromString ( this . blockchainConfig . account . balance , this . web3 ) ;
19- console . dir ( '[blockchain/dev_funds]: converted balance to ' + this . balance ) ;
2018 }
2119 }
2220
@@ -36,7 +34,7 @@ class DevFunds {
3634 return ;
3735 }
3836
39- setInterval ( function ( ) { self . _sendTx ( ) ; } , 3000 ) ;
37+ setInterval ( function ( ) { self . _sendTx ( ) ; } , 1500 ) ;
4038 if ( cb ) {
4139 cb ( ) ;
4240 }
@@ -57,7 +55,6 @@ class DevFunds {
5755 if ( accounts . length > 1 ) {
5856 this . accounts = accounts . slice ( 1 ) ;
5957 }
60- console . dir ( '----- CURRENT ACCOUNTS ' + this . accounts ) ;
6158 cb ( ) ;
6259 } ) ;
6360 }
@@ -66,89 +63,54 @@ class DevFunds {
6663 const numAccountsToCreate = numAccounts - ( this . accounts . length + 1 ) ;
6764 if ( numAccountsToCreate === 0 ) return cb ( ) ;
6865
69- console . dir ( "creating " + numAccountsToCreate + " new accounts with password " + password ) ;
7066 async . timesLimit ( numAccountsToCreate , 1 , ( _ , next ) => {
71- console . dir ( "--- creating new account" ) ;
7267 this . web3 . eth . personal . newAccount ( password , next ) ;
7368 } , ( err , accounts ) => {
74- if ( err ) console . error ( err ) ;
75- console . dir ( "-- accounts created are " ) ;
76- console . dir ( accounts ) ;
69+ if ( err ) return cb ( err ) ;
7770 this . accounts = accounts ;
78- cb ( err ) ;
71+ cb ( ) ;
7972 } ) ;
8073 }
8174
8275 unlockAccounts ( password , cb ) {
83- console . dir ( '--- CURRENT ACCOUNTS ' + this . accounts ) ;
8476 async . each ( this . accounts , ( account , next ) => {
85- console . dir ( '-- unlocking account ' + account + ' with password ' + password ) ;
8677 this . web3 . eth . personal . unlockAccount ( account , password ) . then ( ( result ) => {
87- console . dir ( '-- unlocked account ' + account + ' with password ' + password + ' and result ' + result ) ;
8878 next ( ) ;
8979 } ) . catch ( next ) ;
90- } , ( err ) => {
91- console . dir ( '-- FINISHED UNLOCKING ACCOUNTS, err= ' + err ) ;
92- cb ( err ) ;
93- } ) ;
80+ } , cb ) ;
9481 }
9582
9683 fundAccounts ( balance , cb ) {
97- console . dir ( '-- funding accounts...' ) ;
9884
9985 async . each ( this . accounts , ( account , next ) => {
10086 this . web3 . eth . getBalance ( account ) . then ( currBalance => {
10187 const remainingBalance = balance - currBalance ;
102- console . dir ( "---- account " + account + " balance needed = " + remainingBalance ) ;
10388 if ( remainingBalance <= 0 ) return next ( ) ;
10489
105- console . dir ( "-- funding account " + account + " with balance " + remainingBalance ) ;
10690 this . web3 . eth . sendTransaction ( { to : account , value : remainingBalance } ) . then ( ( result ) => {
107- console . dir ( 'FUNDING ACCT result: ' + JSON . stringify ( result ) ) ;
10891 next ( ) ;
10992 } ) . catch ( next ) ;
110- } , ( err ) => {
111- console . dir ( '-- FINISHED FUNDING ACCOUNTS, err= ' + err ) ;
112- cb ( err ) ;
113- } ) ;
93+ } , cb ) ;
11494 } ) ;
11595 }
11696
11797 createFundAndUnlockAccounts ( cb ) {
11898 async . waterfall ( [
11999 ( next ) => {
120- console . dir ( '--- CONNECTING TO NODE' ) ;
121100 this . connectToNode ( next ) ;
122101 } ,
123102 ( next ) => {
124- console . dir ( '--- CREATING THE ACCOUNTS' ) ;
125103 this . createAccounts ( this . numAccounts , this . password , next ) ;
126104 } ,
127105 ( next ) => {
128- console . dir ( '--- UNLOCKING THE ACCOUNTS' ) ;
129106 this . unlockAccounts ( this . password , next ) ;
130107 } ,
131108 ( next ) => {
132- console . dir ( '--- FUNDING THE ACCOUNTS' ) ;
133109 this . regularTxs ( ) ;
134110 this . regularUnlocks ( ) ;
135111 this . fundAccounts ( this . balance , next ) ;
136112 }
137- ] , ( err ) => {
138- console . dir ( `--- COMPLETED THE ACCOUNTS (${ this . accounts . join ( ', ' ) } and funded with ${ this . balance } wei)` ) ;
139- if ( err ) console . error ( 'Error creating, unlocking, and funding accounts' , JSON . stringify ( err ) ) ;
140-
141- // this.web3.eth.getAccounts().then((accounts) => {
142- // let numAccts = accounts.length;
143- // accounts.forEach((account) => {
144- // this.web3.eth.getBalance(account).then((balance) => {
145- // console.dir('[contracts/dev_funds]: account ' + account + ' has balance of ' + balance);
146- // if(--numAccts === 0) cb(err);
147- // });
148- // });
149- // });
150- cb ( err ) ;
151- } ) ;
113+ ] , cb ) ;
152114 }
153115}
154116
0 commit comments