builder_relayer_client_rust/
types.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
4pub enum TransactionType {
5    #[serde(rename = "SAFE")]
6    SAFE,
7    #[serde(rename = "SAFE-CREATE")]
8    SafeCreate,
9}
10
11#[derive(Clone, Debug, Serialize, Deserialize, Default)]
12pub struct SignatureParams {
13    #[serde(skip_serializing_if = "Option::is_none", rename = "gasPrice")]
14    pub gas_price: Option<String>,
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub operation: Option<String>,
17    // Match TS SDK naming (safeTxnGas)
18    #[serde(skip_serializing_if = "Option::is_none", rename = "safeTxnGas")]
19    pub safe_txn_gas: Option<String>,
20    #[serde(skip_serializing_if = "Option::is_none", rename = "baseGas")]
21    pub base_gas: Option<String>,
22    #[serde(skip_serializing_if = "Option::is_none", rename = "gasToken")]
23    pub gas_token: Option<String>,
24    #[serde(skip_serializing_if = "Option::is_none", rename = "refundReceiver")]
25    pub refund_receiver: Option<String>,
26
27    // SAFE CREATE
28    #[serde(skip_serializing_if = "Option::is_none", rename = "paymentToken")]
29    pub payment_token: Option<String>,
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub payment: Option<String>,
32    #[serde(skip_serializing_if = "Option::is_none", rename = "paymentReceiver")]
33    pub payment_receiver: Option<String>,
34}
35
36#[derive(Clone, Debug, Serialize, Deserialize)]
37pub struct NoncePayload {
38    pub nonce: String,
39}
40
41#[derive(Clone, Debug, Serialize, Deserialize)]
42pub struct TransactionRequest {
43    pub r#type: TransactionType,
44    pub from: String,
45    pub to: String,
46    #[serde(skip_serializing_if = "Option::is_none", rename = "proxyWallet")]
47    pub proxy_wallet: Option<String>,
48    pub data: String,
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub nonce: Option<String>,
51    pub signature: String,
52    #[serde(rename = "signatureParams")]
53    pub signature_params: SignatureParams,
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub metadata: Option<String>,
56}
57
58#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
59pub enum OperationType {
60    Call = 0,
61    DelegateCall = 1,
62}
63
64#[derive(Clone, Debug, Serialize, Deserialize)]
65pub struct SafeTransaction {
66    pub to: String,
67    pub operation: OperationType,
68    pub data: String,
69    pub value: String,
70}
71
72#[derive(Clone, Debug, Serialize, Deserialize)]
73pub struct SafeTransactionArgs {
74    pub from: String,
75    pub nonce: String,
76    pub chain_id: u64,
77    pub transactions: Vec<SafeTransaction>,
78    /// Optional: specify the actual Safe address instead of deriving it
79    /// If provided, this address will be used directly; otherwise it will be derived from `from`
80    #[serde(skip_serializing_if = "Option::is_none")]
81    pub safe_address: Option<String>,
82}
83
84#[derive(Clone, Debug, Serialize, Deserialize)]
85pub struct SafeCreateTransactionArgs {
86    pub from: String,
87    pub chain_id: u64,
88    pub payment_token: String,
89    pub payment: String,
90    pub payment_receiver: String,
91}
92
93#[derive(Clone, Debug, Serialize, Deserialize)]
94#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
95pub enum RelayerTransactionState {
96    #[serde(rename = "STATE_NEW")]
97    StateNew,
98    #[serde(rename = "STATE_EXECUTED")]
99    StateExecuted,
100    #[serde(rename = "STATE_MINED")]
101    StateMined,
102    #[serde(rename = "STATE_INVALID")]
103    StateInvalid,
104    #[serde(rename = "STATE_CONFIRMED")]
105    StateConfirmed,
106    #[serde(rename = "STATE_FAILED")]
107    StateFailed,
108}
109
110#[derive(Clone, Debug, Serialize, Deserialize)]
111pub struct RelayerTransaction {
112    pub transaction_id: String,
113    pub transaction_hash: String,
114    pub from: String,
115    pub to: String,
116    pub proxy_address: String,
117    pub data: String,
118    pub nonce: String,
119    pub value: String,
120    pub state: String,
121    pub r#type: String,
122    pub metadata: String,
123    pub created_at: String,
124    pub updated_at: String,
125}
126
127#[derive(Clone, Debug, Serialize, Deserialize)]
128pub struct RelayerTransactionResponse {
129    // Be flexible with field names across relayer versions
130    #[serde(
131        default,
132        rename = "transactionID",
133        alias = "transactionId",
134        alias = "transaction_id",
135        alias = "id"
136    )]
137    pub transaction_id: String,
138
139    #[serde(default, alias = "status", alias = "state")]
140    pub state: String,
141
142    // Some responses use `hash` or `txHash`; keep both `hash` and `transaction_hash`
143    #[serde(default, alias = "txHash", alias = "hash")]
144    pub hash: String,
145
146    #[serde(default, rename = "transactionHash", alias = "transaction_hash")]
147    pub transaction_hash: String,
148}
149
150#[derive(Clone, Debug, Serialize, Deserialize)]
151pub struct GetDeployedResponse {
152    pub deployed: bool,
153}