1use alloy::primitives::{Address, Bytes, U256};
7use serde::{Deserialize, Serialize};
8use uuid::Uuid;
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct Call {
12 pub to: Address,
13 pub data: Bytes,
14 #[serde(skip_serializing_if = "Option::is_none")]
15 pub value: Option<U256>,
16 #[serde(skip_serializing_if = "Option::is_none")]
17 pub gas: Option<U256>,
18}
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct SendCallsParams {
22 pub version: String,
23 #[serde(rename = "chainId")]
24 pub chain_id: String,
25 pub from: Address,
26 pub calls: Vec<Call>,
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub capabilities: Option<serde_json::Value>,
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
32#[serde(rename_all = "UPPERCASE")]
33pub enum CallStatus {
34 Pending,
35 Confirmed,
36 Failed,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
40pub struct CallStatusResponse {
41 pub status: CallStatus,
42 pub receipts: Vec<Receipt>,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct Receipt {
47 pub logs: Vec<Log>,
48 pub status: String,
49 #[serde(rename = "blockHash")]
50 pub block_hash: String,
51 #[serde(rename = "blockNumber")]
52 pub block_number: String,
53 #[serde(rename = "gasUsed")]
54 pub gas_used: String,
55 #[serde(rename = "transactionHash")]
56 pub transaction_hash: String,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct Log {
61 pub address: Address,
62 pub topics: Vec<String>,
63 pub data: String,
64}
65
66#[derive(Debug, Clone)]
67pub struct BatchExecution {
68 pub id: Uuid,
69 pub params: SendCallsParams,
70 pub status: CallStatus,
71 pub receipts: Vec<Receipt>,
72 pub sponsored_gas: bool,
73}
74
75impl BatchExecution {
76 pub fn new(params: SendCallsParams, sponsored: bool) -> Self {
77 Self {
78 id: Uuid::new_v4(),
79 params,
80 status: CallStatus::Pending,
81 receipts: Vec::new(),
82 sponsored_gas: sponsored,
83 }
84 }
85}