feature: set nonce in fill transaction (#687)
* feature: set nonce in fill transaction * chore: update changelog * refactor: remove nonce_setting in fill_transaction * refactor: set nonce in send_escalating
This commit is contained in:
parent
47e9e7d3c7
commit
3338cdead1
|
@ -14,6 +14,8 @@
|
||||||
[#624](https://github.com/gakonst/ethers-rs/pull/624).
|
[#624](https://github.com/gakonst/ethers-rs/pull/624).
|
||||||
- Fix `fee_history` to first try with `block_count` encoded as a hex `QUANTITY`.
|
- Fix `fee_history` to first try with `block_count` encoded as a hex `QUANTITY`.
|
||||||
[#668](https://github.com/gakonst/ethers-rs/pull/668)
|
[#668](https://github.com/gakonst/ethers-rs/pull/668)
|
||||||
|
- Fix `fill_transaction` to set nonces in transactions, if the sender is known
|
||||||
|
and no nonce is specified
|
||||||
|
|
||||||
## ethers-contract-abigen
|
## ethers-contract-abigen
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,18 @@ where
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn fill_transaction(
|
||||||
|
&self,
|
||||||
|
tx: &mut TypedTransaction,
|
||||||
|
block: Option<BlockId>,
|
||||||
|
) -> Result<(), Self::Error> {
|
||||||
|
if tx.nonce().is_none() {
|
||||||
|
tx.set_nonce(self.get_transaction_count_with_manager(block).await?);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(self.inner().fill_transaction(tx, block).await.map_err(FromErr::from)?)
|
||||||
|
}
|
||||||
|
|
||||||
/// Signs and broadcasts the transaction. The optional parameter `block` can be passed so that
|
/// Signs and broadcasts the transaction. The optional parameter `block` can be passed so that
|
||||||
/// gas cost and nonce calculations take it into account. For simple transactions this can be
|
/// gas cost and nonce calculations take it into account. For simple transactions this can be
|
||||||
/// left to `None`.
|
/// left to `None`.
|
||||||
|
|
|
@ -248,6 +248,14 @@ pub trait Middleware: Sync + Send + Debug {
|
||||||
) -> Result<EscalatingPending<'a, Self::Provider>, Self::Error> {
|
) -> Result<EscalatingPending<'a, Self::Provider>, Self::Error> {
|
||||||
let mut original = tx.clone();
|
let mut original = tx.clone();
|
||||||
self.fill_transaction(&mut original, None).await?;
|
self.fill_transaction(&mut original, None).await?;
|
||||||
|
|
||||||
|
// set the nonce, if no nonce is found
|
||||||
|
if original.nonce().is_none() {
|
||||||
|
let nonce =
|
||||||
|
self.get_transaction_count(tx.from().copied().unwrap_or_default(), None).await?;
|
||||||
|
original.set_nonce(nonce);
|
||||||
|
}
|
||||||
|
|
||||||
let gas_price = original.gas_price().expect("filled");
|
let gas_price = original.gas_price().expect("filled");
|
||||||
let chain_id = self.get_chainid().await?.low_u64();
|
let chain_id = self.get_chainid().await?.low_u64();
|
||||||
let sign_futs: Vec<_> = (0..escalations)
|
let sign_futs: Vec<_> = (0..escalations)
|
||||||
|
|
Loading…
Reference in New Issue