-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add info tx types #1793
Merged
+84
−46
Merged
feat: add info tx types #1793
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//! Commonly used types that contain metadata about a transaction. | ||
|
||
use alloy_primitives::{BlockHash, TxHash, B256}; | ||
|
||
/// Additional fields in the context of a block that contains this _mined_ transaction. | ||
/// | ||
/// This contains mandatory block fields (block hash, number, timestamp, index). | ||
#[derive(Debug, Clone, Copy, Default, Eq, PartialEq)] | ||
pub struct TransactionMeta { | ||
/// Hash of the transaction. | ||
pub tx_hash: B256, | ||
/// Index of the transaction in the block | ||
pub index: u64, | ||
/// Hash of the block. | ||
pub block_hash: B256, | ||
/// Number of the block. | ||
pub block_number: u64, | ||
/// Base fee of the block. | ||
pub base_fee: Option<u64>, | ||
/// The excess blob gas of the block. | ||
pub excess_blob_gas: Option<u64>, | ||
/// The block's timestamp. | ||
pub timestamp: u64, | ||
} | ||
|
||
/// Additional fields in the context of a (maybe) pending block that contains this transaction. | ||
/// | ||
/// This is commonly used when dealing with transactions for rpc where the block context is not | ||
/// known. | ||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] | ||
#[doc(alias = "TxInfo")] | ||
pub struct TransactionInfo { | ||
/// Hash of the transaction. | ||
pub hash: Option<TxHash>, | ||
/// Index of the transaction in the block | ||
pub index: Option<u64>, | ||
/// Hash of the block. | ||
pub block_hash: Option<BlockHash>, | ||
/// Number of the block. | ||
pub block_number: Option<u64>, | ||
/// Base fee of the block. | ||
pub base_fee: Option<u128>, | ||
} | ||
|
||
impl TransactionInfo { | ||
/// Returns a new [`TransactionInfo`] with the provided base fee. | ||
pub const fn with_base_fee(mut self, base_fee: u128) -> Self { | ||
self.base_fee = Some(base_fee); | ||
self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it take
base_fee
as an argument?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we set this via the additional builder fn:
into().with_base_fee()