Skip to content
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(eips): Make prague field an enum #1574

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions crates/eips/src/eip7685.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,29 @@ impl Requests {
self.0.extend(other.take());
}
}
/// A list of requests or a precomputed requests hash.
DoTheBestToGetTheBest marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum PragueRequests {
DoTheBestToGetTheBest marked this conversation as resolved.
Show resolved Hide resolved
/// Stores a list of requests for dynamic requests hash calculation.
Requests(Requests),
/// Stores a precomputed requests hash.
Hash(B256),
}

impl PragueRequests {
/// Returns the requests hash for the enum instance.
///
/// - If the instance contains a list of requests, this function calculates the hash using
/// `requests_hash` of the `Requests` struct.
/// - If it contains a precomputed hash, it returns that hash directly.
DoTheBestToGetTheBest marked this conversation as resolved.
Show resolved Hide resolved
#[cfg(feature = "sha2")]
pub fn requests_hash(&self) -> B256 {
match self {
Self::Requests(requests) => requests.requests_hash(),
Self::Hash(precomputed_hash) => *precomputed_hash,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
Expand Down