op_revm/transaction/
deposit.rs

1use revm::primitives::B256;
2
3pub const DEPOSIT_TRANSACTION_TYPE: u8 = 0x7E;
4
5#[derive(Clone, Debug, Default, PartialEq, Eq)]
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7pub struct DepositTransactionParts {
8    pub source_hash: B256,
9    pub mint: Option<u128>,
10    pub is_system_transaction: bool,
11}
12
13impl DepositTransactionParts {
14    pub fn new(source_hash: B256, mint: Option<u128>, is_system_transaction: bool) -> Self {
15        Self {
16            source_hash,
17            mint,
18            is_system_transaction,
19        }
20    }
21}
22
23#[cfg(all(test, feature = "serde"))]
24mod tests {
25    use super::*;
26    use revm::primitives::b256;
27
28    #[test]
29    fn serialize_json_deposit_tx_parts() {
30        let response = r#"{"source_hash":"0xe927a1448525fb5d32cb50ee1408461a945ba6c39bd5cf5621407d500ecc8de9","mint":52,"is_system_transaction":false}"#;
31
32        let deposit_tx_parts: DepositTransactionParts = serde_json::from_str(response).unwrap();
33        assert_eq!(
34            deposit_tx_parts,
35            DepositTransactionParts {
36                source_hash: b256!(
37                    "0xe927a1448525fb5d32cb50ee1408461a945ba6c39bd5cf5621407d500ecc8de9"
38                ),
39                mint: Some(0x34),
40                is_system_transaction: false,
41            }
42        );
43    }
44}