@@ -72,7 +72,7 @@ module.exports = {
72
72
` ) ;
73
73
} ,
74
74
getNonce : async function ( from ) {
75
- return ( await web3 . eth . getTransactionCount ( from . address ) ) ;
75
+ return ( await web3 . eth . getTransactionCount ( from . address , "pending" ) ) ;
76
76
} ,
77
77
sendTransaction : async function ( from , action , gasPrice , value , factor ) {
78
78
let contractRegistry = await connect ( action . _parent . options . jsonInterface , action . _parent . _address ) ;
@@ -94,8 +94,12 @@ module.exports = {
94
94
let block = await web3 . eth . getBlock ( "latest" ) ;
95
95
let networkGasLimit = block . gasLimit ;
96
96
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
+ }
99
103
100
104
console . log ( chalk . black . bgYellowBright ( `---- Transaction executed: ${ action . _method . name } - Gas limit provided: ${ gas } ----` ) ) ;
101
105
@@ -129,7 +133,7 @@ module.exports = {
129
133
) ;
130
134
} ) ;
131
135
} ,
132
- sendTransactionWithNonce : async function ( from , action , gasPrice , value , factor , minNonce ) {
136
+ sendTransactionWithNonce : async function ( from , action , gasPrice , minNonce , value , factor ) {
133
137
let contractRegistry = await connect ( action . _parent . options . jsonInterface , action . _parent . _address ) ;
134
138
135
139
//NOTE this is a condition to verify if the transaction comes from a module or not.
@@ -143,16 +147,21 @@ module.exports = {
143
147
process . exit ( 0 ) ;
144
148
}
145
149
}
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" ) ;
148
153
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 } ) ) ) ;
150
156
if ( gas > networkGasLimit ) gas = networkGasLimit ;
151
157
152
158
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 ) {
155
163
nonce = minNonce ;
164
+ }
156
165
let abi = action . encodeABI ( ) ;
157
166
let parameter = {
158
167
from : from . address ,
0 commit comments