@@ -72,7 +72,7 @@ module.exports = {
7272` ) ;
7373 } ,
7474 getNonce : async function ( from ) {
75- return ( await web3 . eth . getTransactionCount ( from . address ) ) ;
75+ return ( await web3 . eth . getTransactionCount ( from . address , "pending" ) ) ;
7676 } ,
7777 sendTransaction : async function ( from , action , gasPrice , value , factor ) {
7878 let contractRegistry = await connect ( action . _parent . options . jsonInterface , action . _parent . _address ) ;
@@ -94,8 +94,12 @@ module.exports = {
9494 let block = await web3 . eth . getBlock ( "latest" ) ;
9595 let networkGasLimit = block . gasLimit ;
9696
97- let gas = Math . round ( factor * ( await action . estimateGas ( { from : from . address , value : value } ) ) ) ;
98- if ( gas > networkGasLimit ) gas = networkGasLimit ;
97+ try {
98+ let gas = Math . round ( factor * ( await action . estimateGas ( { from : from . address , value : value } ) ) ) ;
99+ if ( gas > networkGasLimit ) gas = networkGasLimit ;
100+ } catch ( exception ) {
101+ gas = networkGasLimit ;
102+ }
99103
100104 console . log ( chalk . black . bgYellowBright ( `---- Transaction executed: ${ action . _method . name } - Gas limit provided: ${ gas } ----` ) ) ;
101105
@@ -129,7 +133,7 @@ module.exports = {
129133 ) ;
130134 } ) ;
131135 } ,
132- sendTransactionWithNonce : async function ( from , action , gasPrice , value , factor , minNonce ) {
136+ sendTransactionWithNonce : async function ( from , action , gasPrice , minNonce , value , factor ) {
133137 let contractRegistry = await connect ( action . _parent . options . jsonInterface , action . _parent . _address ) ;
134138
135139 //NOTE this is a condition to verify if the transaction comes from a module or not.
@@ -143,16 +147,21 @@ module.exports = {
143147 process . exit ( 0 ) ;
144148 }
145149 }
146- if ( typeof factor === 'undefined' ) factor = 1.2 ;
147- let block = await web3 . eth . getBlock ( "latest" ) ;
150+ if ( typeof factor === 'undefined' ) factor = 1.2 ;
151+
152+ let block = await web3 . eth . getBlock ( "latest" ) ;
148153 let networkGasLimit = block . gasLimit ;
149- let gas = Math . round ( factor * ( await action . estimateGas ( { from : from . address , value : value } ) ) ) ;
154+
155+ let gas = Math . round ( factor * ( await action . estimateGas ( { from : from . address , value : value } ) ) ) ;
150156 if ( gas > networkGasLimit ) gas = networkGasLimit ;
151157
152158 console . log ( chalk . black . bgYellowBright ( `---- Transaction executed: ${ action . _method . name } - Gas limit provided: ${ gas } ----` ) ) ;
153- let nonce = await web3 . eth . getTransactionCount ( from . address ) ;
154- if ( nonce < minNonce )
159+
160+ let nonce = await web3 . eth . getTransactionCount ( from . address ) ;
161+
162+ if ( nonce < minNonce ) {
155163 nonce = minNonce ;
164+ }
156165 let abi = action . encodeABI ( ) ;
157166 let parameter = {
158167 from : from . address ,
0 commit comments