@@ -8,6 +8,7 @@ const handlers = require("./handlers");
8
8
const override = require ( "./override" ) ;
9
9
const reformat = require ( "./reformat" ) ;
10
10
const { sendTransactionManual } = require ( "./manual-send" ) ;
11
+ const { DEFAULT_RETURN_FORMAT } = require ( "web3-types" ) ;
11
12
12
13
const execute = {
13
14
// ----------------------------------- Helpers --------------------------------------------------
@@ -83,6 +84,7 @@ const execute = {
83
84
prepareCall : async function ( constructor , methodABI , _arguments , isCall ) {
84
85
let args = Array . prototype . slice . call ( _arguments ) ;
85
86
let params = utils . getTxParams . call ( constructor , methodABI , args , isCall ) ;
87
+ let options = utils . getTxOptions . call ( constructor , methodABI , args ) ;
86
88
87
89
args = utils . convertToEthersBN ( args ) ;
88
90
@@ -104,7 +106,7 @@ const execute = {
104
106
return { args, params } ;
105
107
}
106
108
const network = await constructor . detectNetwork ( ) ;
107
- return { args, params, network } ;
109
+ return { args, params, network, options } ;
108
110
} ,
109
111
110
112
/**
@@ -202,7 +204,7 @@ const execute = {
202
204
const promiEvent = new PromiEvent ( false , constructor . debugger ) ;
203
205
execute
204
206
. prepareCall ( constructor , methodABI , arguments )
205
- . then ( async ( { args, params, network } ) => {
207
+ . then ( async ( { args, params, network, options } ) => {
206
208
const context = {
207
209
contract : constructor , // Can't name this field `constructor` or `_constructor`
208
210
promiEvent : promiEvent ,
@@ -221,15 +223,17 @@ const execute = {
221
223
contract : constructor
222
224
} ) ;
223
225
224
- params . gas = await execute . getGasEstimate . call (
225
- constructor ,
226
- params ,
227
- network . blockLimit ,
228
- promiEvent . debug //apply stacktracing mode if promiEvent.debug is true
229
- ) ;
230
-
226
+ // estimate the gas only if it's not provided
227
+ if ( ! params || ! params [ 0 ] ?. gas ) {
228
+ params . gas = await execute . getGasEstimate . call (
229
+ constructor ,
230
+ params ,
231
+ network . blockLimit ,
232
+ promiEvent . debug //apply stacktracing mode if promiEvent.debug is true
233
+ ) ;
234
+ }
231
235
execute
232
- . sendTransaction ( web3 , params , promiEvent , context ) //the crazy things we do for stacktracing...
236
+ . sendTransaction ( web3 , params , promiEvent , context , options ) //the crazy things we do for stacktracing...
233
237
. then ( receipt => {
234
238
if ( promiEvent . debug ) {
235
239
// in this case, we need to manually invoke the handler since it
@@ -561,11 +565,15 @@ const execute = {
561
565
//input works the same as input to web3.sendTransaction
562
566
//(well, OK, it's lacking some things there too, but again, good enough
563
567
//for our purposes)
564
- sendTransaction : async function ( web3 , params , promiEvent , context ) {
568
+ sendTransaction : async function ( web3 , params , promiEvent , context , options ) {
565
569
//if we don't need the debugger, let's not risk any errors on our part,
566
570
//and just have web3 do everything
567
571
if ( ! promiEvent || ! promiEvent . debug ) {
568
- const deferred = web3 . eth . sendTransaction ( params ) ;
572
+ const deferred = web3 . eth . sendTransaction (
573
+ params ,
574
+ DEFAULT_RETURN_FORMAT ,
575
+ options
576
+ ) ;
569
577
handlers . setup ( deferred , context ) ;
570
578
return deferred ;
571
579
}
0 commit comments