mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(evm): add nonce methods to TxEnv (#14014)
This commit is contained in:
@ -241,6 +241,36 @@ pub trait TransactionEnv:
|
||||
self
|
||||
}
|
||||
|
||||
/// Returns the configured nonce.
|
||||
///
|
||||
/// This may return `None`, if the nonce has been intentionally unset in the environment. This
|
||||
/// is useful in optimizations like transaction prewarming, where nonce checks should be
|
||||
/// ignored.
|
||||
fn nonce(&self) -> Option<u64>;
|
||||
|
||||
/// Sets the nonce.
|
||||
fn set_nonce(&mut self, nonce: u64);
|
||||
|
||||
/// Sets the nonce.
|
||||
fn with_nonce(mut self, nonce: u64) -> Self {
|
||||
self.set_nonce(nonce);
|
||||
self
|
||||
}
|
||||
|
||||
/// Unsets the nonce. This should be used when nonce checks for the transaction should be
|
||||
/// ignored.
|
||||
///
|
||||
/// See [`TransactionEnv::nonce`] for applications where this may be desired.
|
||||
fn unset_nonce(&mut self);
|
||||
|
||||
/// Constructs a version of this [`TransactionEnv`] that has the nonce unset.
|
||||
///
|
||||
/// See [`TransactionEnv::nonce`] for applications where this may be desired.
|
||||
fn without_nonce(mut self) -> Self {
|
||||
self.unset_nonce();
|
||||
self
|
||||
}
|
||||
|
||||
/// Returns configured gas price.
|
||||
fn gas_price(&self) -> U256;
|
||||
|
||||
@ -279,6 +309,18 @@ impl TransactionEnv for TxEnv {
|
||||
self.gas_price.to()
|
||||
}
|
||||
|
||||
fn nonce(&self) -> Option<u64> {
|
||||
self.nonce
|
||||
}
|
||||
|
||||
fn set_nonce(&mut self, nonce: u64) {
|
||||
self.nonce = Some(nonce);
|
||||
}
|
||||
|
||||
fn unset_nonce(&mut self) {
|
||||
self.nonce = None;
|
||||
}
|
||||
|
||||
fn value(&self) -> U256 {
|
||||
self.value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user