1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#![allow(clippy::too_many_arguments)]
#![allow(missing_docs)]
use alloy_primitives::Address;
use alloy_sol_types::sol;

use self::Orders::{OrdersErrors, OrdersEvents};

sol!(
    #[sol(rpc)]
    #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    Zenith,
    "abi/Zenith.json"
);

// Zenith types
impl Copy for Zenith::BlockHeader {}
impl Copy for Zenith::BlockSubmitted {}
impl Copy for Zenith::SequencerSet {}
impl Copy for Zenith::BadSequence {}
impl Copy for Zenith::BadSignature {}
impl Copy for Zenith::BlockExpired {}
impl Copy for Zenith::OneRollupBlockPerHostBlock {}
impl Copy for Zenith::OnlySequencerAdmin {}

// Passage types
impl Copy for Zenith::Enter {}
impl Copy for Zenith::Withdrawal {}
impl Copy for Zenith::OnlyWithdrawalAdmin {}

impl Copy for Zenith::ZenithErrors {}

impl Clone for Zenith::ZenithErrors {
    fn clone(&self) -> Self {
        *self
    }
}

impl Clone for Zenith::ZenithEvents {
    fn clone(&self) -> Self {
        match self {
            Self::BlockSubmitted(inner) => Self::BlockSubmitted(*inner),
            Self::Enter(inner) => Self::Enter(*inner),
            Self::SequencerSet(inner) => Self::SequencerSet(*inner),
            Self::Transact(inner) => Self::Transact(inner.clone()),
            Self::Withdrawal(inner) => Self::Withdrawal(*inner),
        }
    }
}

impl From<&Zenith::BlockSubmitted> for Zenith::BlockHeader {
    fn from(event: &Zenith::BlockSubmitted) -> Zenith::BlockHeader {
        Zenith::BlockHeader {
            rollupChainId: event.rollupChainId,
            sequence: event.sequence,
            confirmBy: event.confirmBy,
            gasLimit: event.gasLimit,
            rewardAddress: event.rewardAddress,
            blockDataHash: event.blockDataHash,
        }
    }
}

impl Zenith::ZenithEvents {
    /// Get the chain ID of the event (discarding high bytes), returns `None`
    /// if the event has no associated chain id.
    pub const fn rollup_chain_id(&self) -> Option<u64> {
        match self {
            Zenith::ZenithEvents::BlockSubmitted(inner) => Some(inner.rollup_chain_id()),
            Zenith::ZenithEvents::Enter(inner) => Some(inner.rollup_chain_id()),
            Zenith::ZenithEvents::Transact(inner) => Some(inner.rollup_chain_id()),
            _ => None,
        }
    }
}

impl Zenith::BlockSubmitted {
    /// Get the chain ID of the event (discarding high bytes), returns `None`
    /// if the event has no associated chain id.
    pub const fn rollup_chain_id(&self) -> u64 {
        self.rollupChainId.as_limbs()[0]
    }
}

impl Zenith::Enter {
    /// Get the chain ID of the event (discarding high bytes), returns `None`
    /// if the event has no associated chain id.
    pub const fn rollup_chain_id(&self) -> u64 {
        self.rollupChainId.as_limbs()[0]
    }
}

impl Zenith::Transact {
    /// Get the chain ID of the event (discarding high bytes), returns `None`
    /// if the event has no associated chain id.
    pub const fn rollup_chain_id(&self) -> u64 {
        self.rollupChainId.as_limbs()[0]
    }
}

impl Zenith::BlockHeader {
    /// Get the chain ID of the block (discarding high bytes).
    pub const fn chain_id(&self) -> u64 {
        self.rollupChainId.as_limbs()[0]
    }

    /// Get the sequence of the block (discarding high bytes).
    pub const fn sequence(&self) -> u64 {
        self.sequence.as_limbs()[0]
    }

    /// Get the confirm by time of the block (discarding high bytes).
    pub const fn confirm_by(&self) -> u64 {
        self.confirmBy.as_limbs()[0]
    }

    /// Get the gas limit of the block (discarding high bytes).
    pub const fn gas_limit(&self) -> u64 {
        self.gasLimit.as_limbs()[0]
    }

    /// Get the reward address of the block.
    pub const fn reward_address(&self) -> Address {
        self.rewardAddress
    }
}

sol!(
    #[sol(rpc)]
    #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    Orders,
    "abi/Orders.json"
);

impl Copy for Orders::Swap {}
impl Copy for Orders::Sweep {}
impl Copy for Orders::SwapFulfilled {}
impl Copy for Orders::OrderExpired {}
impl Copy for OrdersEvents {}
impl Copy for OrdersErrors {}

impl Clone for Orders::OrdersEvents {
    fn clone(&self) -> Self {
        *self
    }
}

impl Clone for Orders::OrdersErrors {
    fn clone(&self) -> Self {
        *self
    }
}

impl Orders::SwapFulfilled {
    /// Get the target chain ID of the swap (discarding high bytes).
    pub const fn origin_chain_id(&self) -> u64 {
        self.originChainId.as_limbs()[0]
    }
}

impl Orders::Swap {
    /// Get the target chain ID of the swap (discarding high bytes).
    pub const fn target_chain_id(&self) -> u64 {
        self.targetChainId.as_limbs()[0]
    }
}