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(provider) : introduction to eth_sendRawTransactionConditional RPC endpoint type #1009

Merged
merged 13 commits into from
Jul 16, 2024
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