Skip to content

Commit 84908df

Browse files
DoTheBestToGetTheBestmattsse
authored and
ben186
committed
feat(provider) : introduction to eth_sendRawTransactionConditional RPC endpoint type (alloy-rs#1009)
* Update request.rs * Update trait.rs * clippy * Update trait.rs * Update trait.rs * added reference and camelCase serde * Update request.rs * Update lib.rs * Create eip4337.rs * Update eip4337.rs * fix serde * reorder --------- Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
1 parent 0c4978d commit 84908df

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

crates/rpc-types-eth/src/eip4337.rs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
use alloy_primitives::{Address, BlockNumber, B256, U256};
2+
use serde::{Deserialize, Serialize};
3+
use std::collections::HashMap;
4+
5+
/// Options for conditional raw transaction submissions.
6+
// reference for the implementation <https://notes.ethereum.org/@yoav/SkaX2lS9j#>
7+
// See also <https://pkg.go.dev/github.com/aK0nshin/go-ethereum/arbitrum_types#ConditionalOptions>
8+
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
9+
#[serde(rename_all = "camelCase")]
10+
pub struct ConditionalOptions {
11+
/// A map of account addresses to their expected storage states.
12+
/// Each account can have a specified storage root or explicit slot-value pairs.
13+
#[serde(default)]
14+
pub known_accounts: HashMap<Address, AccountStorage>,
15+
/// The minimal block number at which the transaction can be included.
16+
/// `None` indicates no minimum block number constraint.
17+
#[serde(default, skip_serializing_if = "Option::is_none")]
18+
pub block_number_min: Option<BlockNumber>,
19+
/// The maximal block number at which the transaction can be included.
20+
/// `None` indicates no maximum block number constraint.
21+
#[serde(default, skip_serializing_if = "Option::is_none")]
22+
pub block_number_max: Option<BlockNumber>,
23+
/// The minimal timestamp at which the transaction can be included.
24+
/// `None` indicates no minimum timestamp constraint.
25+
#[serde(default, skip_serializing_if = "Option::is_none")]
26+
pub timestamp_min: Option<u64>,
27+
/// The maximal timestamp at which the transaction can be included.
28+
/// `None` indicates no maximum timestamp constraint.
29+
#[serde(default, skip_serializing_if = "Option::is_none")]
30+
pub timestamp_max: Option<u64>,
31+
}
32+
33+
/// Represents the expected state of an account for a transaction to be conditionally accepted.
34+
#[derive(Debug, Serialize, Deserialize, Clone)]
35+
#[serde(untagged)]
36+
pub enum AccountStorage {
37+
/// Expected storage root hash of the account.
38+
RootHash(B256),
39+
/// Explicit storage slots and their expected values.
40+
Slots(HashMap<U256, B256>),
41+
}

crates/rpc-types-eth/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ pub use transaction::*;
4646

4747
mod work;
4848
pub use work::Work;
49+
50+
/// This module provides implementations for EIP-4337.
51+
pub mod eip4337;

crates/rpc-types-eth/src/transaction/request.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use alloy_consensus::{
88
use alloy_primitives::{Address, Bytes, ChainId, TxKind, B256, U256};
99
use serde::{Deserialize, Serialize};
1010
use std::hash::Hash;
11-
1211
/// Represents _all_ transaction requests to/from RPC.
1312
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
1413
#[serde(rename_all = "camelCase")]

0 commit comments

Comments
 (0)