Skip to content

Commit

Permalink
feat(provider) : introduction to eth_sendRawTransactionConditional RP…
Browse files Browse the repository at this point in the history
…C endpoint type (#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>
  • Loading branch information
DoTheBestToGetTheBest and mattsse authored Jul 16, 2024
1 parent c715e57 commit 423a4c5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
41 changes: 41 additions & 0 deletions crates/rpc-types-eth/src/eip4337.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use alloy_primitives::{Address, BlockNumber, B256, U256};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

/// Options for conditional raw transaction submissions.
// reference for the implementation <https://notes.ethereum.org/@yoav/SkaX2lS9j#>
// See also <https://pkg.go.dev/github.com/aK0nshin/go-ethereum/arbitrum_types#ConditionalOptions>
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
#[serde(rename_all = "camelCase")]
pub struct ConditionalOptions {
/// A map of account addresses to their expected storage states.
/// Each account can have a specified storage root or explicit slot-value pairs.
#[serde(default)]
pub known_accounts: HashMap<Address, AccountStorage>,
/// The minimal block number at which the transaction can be included.
/// `None` indicates no minimum block number constraint.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub block_number_min: Option<BlockNumber>,
/// The maximal block number at which the transaction can be included.
/// `None` indicates no maximum block number constraint.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub block_number_max: Option<BlockNumber>,
/// The minimal timestamp at which the transaction can be included.
/// `None` indicates no minimum timestamp constraint.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub timestamp_min: Option<u64>,
/// The maximal timestamp at which the transaction can be included.
/// `None` indicates no maximum timestamp constraint.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub timestamp_max: Option<u64>,
}

/// Represents the expected state of an account for a transaction to be conditionally accepted.
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(untagged)]
pub enum AccountStorage {
/// Expected storage root hash of the account.
RootHash(B256),
/// Explicit storage slots and their expected values.
Slots(HashMap<U256, B256>),
}
3 changes: 3 additions & 0 deletions crates/rpc-types-eth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ pub use transaction::*;

mod work;
pub use work::Work;

/// This module provides implementations for EIP-4337.
pub mod eip4337;
1 change: 0 additions & 1 deletion crates/rpc-types-eth/src/transaction/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use alloy_consensus::{
use alloy_primitives::{Address, Bytes, ChainId, TxKind, B256, U256};
use serde::{Deserialize, Serialize};
use std::hash::Hash;

/// Represents _all_ transaction requests to/from RPC.
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down

0 comments on commit 423a4c5

Please sign in to comment.