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
31 changes: 29 additions & 2 deletions crates/rpc-types-eth/src/transaction/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use alloy_consensus::{
};
use alloy_primitives::{Address, Bytes, ChainId, TxKind, B256, U256};
use serde::{Deserialize, Serialize};
use std::hash::Hash;

use std::{collections::HashMap, hash::Hash};
/// Represents _all_ transaction requests to/from RPC.
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -767,6 +766,34 @@ impl From<TxEnvelope> for TransactionRequest {
#[non_exhaustive]
pub struct TransactionInputError;

/// Options for conditional raw transaction submissions.
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ConditionalTxOptions {
DoTheBestToGetTheBest marked this conversation as resolved.
Show resolved Hide resolved
DoTheBestToGetTheBest marked this conversation as resolved.
Show resolved Hide resolved
DoTheBestToGetTheBest marked this conversation as resolved.
Show resolved Hide resolved
/// The minimal block number at which the transaction can be included.
/// `None` indicates no minimum block number constraint.
pub block_number_min: Option<U256>,
/// The maximal block number at which the transaction can be included.
/// `None` indicates no maximum block number constraint.
pub block_number_max: Option<U256>,
/// The minimal timestamp at which the transaction can be included.
/// `None` indicates no minimum timestamp constraint.
pub timestamp_min: Option<U256>,
/// The maximal timestamp at which the transaction can be included.
/// `None` indicates no maximum timestamp constraint.
pub timestamp_max: Option<U256>,
/// A map of account addresses to their expected storage states.
/// Each account can have a specified storage root or explicit slot-value pairs.
pub known_accounts: HashMap<Address, KnownAccountState>,
}
/// Represents the expected state of an account for a transaction to be conditionally accepted.
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(untagged)]
pub enum KnownAccountState {
/// Expected storage root hash of the account.
StorageRoot(B256),
/// Explicit storage slots and their expected values.
Slots(HashMap<U256, B256>),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'm also not sure if this should be Slots(HashMap<B256, B256>), or Slots(HashMap<U256, B256>),

}
#[cfg(test)]
mod tests {
use super::*;
Expand Down