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: EIP-7685 requests helpers #1699

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
3 changes: 3 additions & 0 deletions crates/eips/src/eip6110.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ use alloy_primitives::{address, Address};
/// Mainnet deposit contract address.
pub const MAINNET_DEPOSIT_CONTRACT_ADDRESS: Address =
address!("00000000219ab540356cbb839cbe05303d7705fa");

/// The [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685) request type for deposit requests.
pub const DEPOSIT_REQUEST_TYPE: u8 = 0x00;
9 changes: 9 additions & 0 deletions crates/eips/src/eip7685.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ impl Requests {
self.0.push(request);
}

/// Adds a new request with the given request type into the container.
pub fn push_request_with_type(
&mut self,
request: impl IntoIterator<Item = u8>,
request_type: u8,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we flip the order here?
feels more natural to have the correct order

also I assume there's a more efficient way to prepend a Bytes with a single byte, perhaps @DaniPopes knows?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope Bytes is immutable so it must be done at construction using a vec

) {
self.0.push(core::iter::once(request_type).chain(request).collect());
}

/// Consumes [`Requests`] and returns the inner raw opaque requests.
///
/// # Note
Expand Down