base-simulacrum 0.1.0

A headless CLI tool for locally testing EIP-5792 batch transactions against a simulated Base environment
Documentation
//! Type definitions for EIP-5792 structures.
//!
//! This module contains all the data structures used for EIP-5792 batch transactions,
//! including calls, receipts, and status tracking.

use alloy::primitives::{Address, Bytes, U256};
use serde::{Deserialize, Serialize};
use uuid::Uuid;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Call {
    pub to: Address,
    pub data: Bytes,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<U256>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub gas: Option<U256>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SendCallsParams {
    pub version: String,
    #[serde(rename = "chainId")]
    pub chain_id: String,
    pub from: Address,
    pub calls: Vec<Call>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub capabilities: Option<serde_json::Value>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "UPPERCASE")]
pub enum CallStatus {
    Pending,
    Confirmed,
    Failed,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CallStatusResponse {
    pub status: CallStatus,
    pub receipts: Vec<Receipt>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Receipt {
    pub logs: Vec<Log>,
    pub status: String,
    #[serde(rename = "blockHash")]
    pub block_hash: String,
    #[serde(rename = "blockNumber")]
    pub block_number: String,
    #[serde(rename = "gasUsed")]
    pub gas_used: String,
    #[serde(rename = "transactionHash")]
    pub transaction_hash: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Log {
    pub address: Address,
    pub topics: Vec<String>,
    pub data: String,
}

#[derive(Debug, Clone)]
pub struct BatchExecution {
    pub id: Uuid,
    pub params: SendCallsParams,
    pub status: CallStatus,
    pub receipts: Vec<Receipt>,
    pub sponsored_gas: bool,
}

impl BatchExecution {
    pub fn new(params: SendCallsParams, sponsored: bool) -> Self {
        Self {
            id: Uuid::new_v4(),
            params,
            status: CallStatus::Pending,
            receipts: Vec::new(),
            sponsored_gas: sponsored,
        }
    }
}