This repository was archived by the owner on Oct 19, 2024. It is now read-only.
File tree 3 files changed +22
-0
lines changed
3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 14
14
[ #624 ] ( https://github.com/gakonst/ethers-rs/pull/624 ) .
15
15
- Fix ` fee_history ` to first try with ` block_count ` encoded as a hex ` QUANTITY ` .
16
16
[ #668 ] ( https://github.com/gakonst/ethers-rs/pull/668 )
17
+ - Fix ` fill_transaction ` to set nonces in transactions, if the sender is known
18
+ and no nonce is specified
17
19
18
20
## ethers-contract-abigen
19
21
Original file line number Diff line number Diff line change 77
77
& self . inner
78
78
}
79
79
80
+ async fn fill_transaction (
81
+ & self ,
82
+ tx : & mut TypedTransaction ,
83
+ block : Option < BlockId > ,
84
+ ) -> Result < ( ) , Self :: Error > {
85
+ if tx. nonce ( ) . is_none ( ) {
86
+ tx. set_nonce ( self . get_transaction_count_with_manager ( block) . await ?) ;
87
+ }
88
+
89
+ Ok ( self . inner ( ) . fill_transaction ( tx, block) . await . map_err ( FromErr :: from) ?)
90
+ }
91
+
80
92
/// Signs and broadcasts the transaction. The optional parameter `block` can be passed so that
81
93
/// gas cost and nonce calculations take it into account. For simple transactions this can be
82
94
/// left to `None`.
Original file line number Diff line number Diff line change @@ -248,6 +248,14 @@ pub trait Middleware: Sync + Send + Debug {
248
248
) -> Result < EscalatingPending < ' a , Self :: Provider > , Self :: Error > {
249
249
let mut original = tx. clone ( ) ;
250
250
self . fill_transaction ( & mut original, None ) . await ?;
251
+
252
+ // set the nonce, if no nonce is found
253
+ if original. nonce ( ) . is_none ( ) {
254
+ let nonce =
255
+ self . get_transaction_count ( tx. from ( ) . copied ( ) . unwrap_or_default ( ) , None ) . await ?;
256
+ original. set_nonce ( nonce) ;
257
+ }
258
+
251
259
let gas_price = original. gas_price ( ) . expect ( "filled" ) ;
252
260
let chain_id = self . get_chainid ( ) . await ?. low_u64 ( ) ;
253
261
let sign_futs: Vec < _ > = ( 0 ..escalations)
You can’t perform that action at this time.
0 commit comments