zenith_types/
bindings.rs

1#![allow(clippy::too_many_arguments)]
2#![allow(missing_docs)]
3use alloy::primitives::{Address, Bytes, FixedBytes, U256};
4mod mint {
5    alloy::sol!(
6        #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
7        function mint(address to, uint256 amount);
8    );
9}
10pub use mint::mintCall;
11
12mod zenith {
13    use super::*;
14
15    alloy::sol!(
16        #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
17        #[sol(rpc)]
18        Zenith,
19        "abi/Zenith.json"
20    );
21
22    impl Copy for Zenith::BlockHeader {}
23    impl Copy for Zenith::BlockSubmitted {}
24    impl Copy for Zenith::SequencerSet {}
25    impl Copy for Zenith::BadSignature {}
26    impl Copy for Zenith::OneRollupBlockPerHostBlock {}
27    impl Copy for Zenith::OnlySequencerAdmin {}
28    impl Copy for Zenith::IncorrectHostBlock {}
29
30    impl Zenith::BlockSubmitted {
31        /// Get the sequencer address that signed the block.
32        pub const fn sequencer(&self) -> Address {
33            self.sequencer
34        }
35
36        /// Get the chain id of the rollup.
37        pub const fn rollup_chain_id(&self) -> u64 {
38            self.rollupChainId.as_limbs()[0]
39        }
40
41        /// Get the gas limit of the block
42        pub const fn gas_limit(&self) -> u64 {
43            self.gasLimit.as_limbs()[0]
44        }
45
46        /// Get the reward address of the block.
47        pub const fn reward_address(&self) -> Address {
48            self.rewardAddress
49        }
50
51        /// Get the block data hash, i.e. the committment to the data of the block.
52        pub const fn block_data_hash(&self) -> FixedBytes<32> {
53            self.blockDataHash
54        }
55
56        /// Convert the BlockSubmitted event to a BlockHeader with the given host
57        /// block number.
58        pub const fn to_header(self, host_block_number: U256) -> Zenith::BlockHeader {
59            Zenith::BlockHeader::from_block_submitted(self, host_block_number)
60        }
61    }
62
63    impl Zenith::BlockHeader {
64        /// Create a BlockHeader from a BlockSubmitted event with the given host
65        /// block number
66        pub const fn from_block_submitted(
67            host_block_submitted: Zenith::BlockSubmitted,
68            host_block_number: U256,
69        ) -> Zenith::BlockHeader {
70            Zenith::BlockHeader {
71                rollupChainId: host_block_submitted.rollupChainId,
72                hostBlockNumber: host_block_number,
73                gasLimit: host_block_submitted.gasLimit,
74                rewardAddress: host_block_submitted.rewardAddress,
75                blockDataHash: host_block_submitted.blockDataHash,
76            }
77        }
78
79        /// Get the host block number of the block
80        pub const fn host_block_number(&self) -> u64 {
81            self.hostBlockNumber.as_limbs()[0]
82        }
83
84        /// Get the chain ID of the block (discarding high bytes).
85        pub const fn chain_id(&self) -> u64 {
86            self.rollupChainId.as_limbs()[0]
87        }
88
89        /// Get the gas limit of the block (discarding high bytes).
90        pub const fn gas_limit(&self) -> u64 {
91            self.gasLimit.as_limbs()[0]
92        }
93
94        /// Get the reward address of the block.
95        pub const fn reward_address(&self) -> Address {
96            self.rewardAddress
97        }
98
99        /// Get the block data hash, i.e. the committment to the data of the block.
100        pub const fn block_data_hash(&self) -> FixedBytes<32> {
101            self.blockDataHash
102        }
103    }
104}
105
106mod passage {
107    use super::*;
108
109    alloy::sol!(
110        #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
111        #[sol(rpc)]
112        Passage,
113        "abi/Passage.json"
114    );
115
116    impl Copy for Passage::EnterConfigured {}
117    impl Copy for Passage::Withdrawal {}
118    impl Copy for Passage::OnlyTokenAdmin {}
119    impl Copy for Passage::Enter {}
120    impl Copy for Passage::EnterToken {}
121    impl Copy for Passage::DisallowedEnter {}
122    impl Copy for Passage::FailedCall {}
123    impl Copy for Passage::InsufficientBalance {}
124    impl Copy for Passage::SafeERC20FailedOperation {}
125    impl Copy for Passage::AddressEmptyCode {}
126
127    impl Copy for Passage::PassageEvents {}
128
129    impl Clone for Passage::PassageEvents {
130        fn clone(&self) -> Self {
131            *self
132        }
133    }
134
135    impl Passage::EnterToken {
136        /// Get the chain ID of the event (discarding high bytes), returns `None`
137        /// if the event has no associated chain id.
138        pub const fn rollup_chain_id(&self) -> u64 {
139            self.rollupChainId.as_limbs()[0]
140        }
141
142        /// Get the token address of the event.
143        pub const fn token(&self) -> Address {
144            self.token
145        }
146
147        /// Get the recipient of the event.
148        pub const fn recipient(&self) -> Address {
149            self.rollupRecipient
150        }
151
152        /// Get the amount of the event.
153        pub const fn amount(&self) -> U256 {
154            self.amount
155        }
156    }
157
158    impl Passage::Enter {
159        /// Get the chain ID of the event (discarding high bytes), returns `None`
160        /// if the event has no associated chain id.
161        pub const fn rollup_chain_id(&self) -> u64 {
162            self.rollupChainId.as_limbs()[0]
163        }
164
165        /// Get the recipient of the event.
166        pub const fn recipient(&self) -> Address {
167            self.rollupRecipient
168        }
169
170        /// Get the amount of the event.
171        pub const fn amount(&self) -> U256 {
172            self.amount
173        }
174    }
175
176    impl Passage::Withdrawal {
177        /// Get the token address of the request.
178        pub const fn token(&self) -> Address {
179            self.token
180        }
181
182        /// Get the recipient of the request.
183        pub const fn recipient(&self) -> Address {
184            self.recipient
185        }
186
187        /// Get the amount of the request.
188        pub const fn amount(&self) -> U256 {
189            self.amount
190        }
191    }
192
193    impl Passage::EnterConfigured {
194        /// Get the token address of the event.
195        pub const fn token(&self) -> Address {
196            self.token
197        }
198
199        /// Get if the token has been configured to allow or disallow enters.
200        pub const fn can_enter(&self) -> bool {
201            self.canEnter
202        }
203    }
204}
205
206mod orders {
207    use super::*;
208
209    alloy::sol!(
210        #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
211        #[sol(rpc)]
212        Orders,
213        "abi/RollupOrders.json"
214    );
215
216    impl Copy for IOrders::Input {}
217    impl Copy for IOrders::Output {}
218    impl Copy for Orders::Sweep {}
219    impl Copy for Orders::InsufficientBalance {}
220    impl Copy for Orders::AddressEmptyCode {}
221    impl Copy for Orders::LengthMismatch {}
222    impl Copy for Orders::OrderExpired {}
223    impl Copy for Orders::OutputMismatch {}
224    impl Copy for Orders::SafeERC20FailedOperation {}
225
226    impl Clone for Orders::OrdersEvents {
227        fn clone(&self) -> Self {
228            match self {
229                Self::Order(event) => Self::Order(event.clone()),
230                Self::Sweep(event) => Self::Sweep(*event),
231                Self::Filled(event) => Self::Filled(event.clone()),
232            }
233        }
234    }
235
236    impl IOrders::Input {
237        pub const fn token(&self) -> Address {
238            self.token
239        }
240
241        pub const fn amount(&self) -> u64 {
242            self.amount.as_limbs()[0]
243        }
244    }
245
246    impl IOrders::Output {
247        pub const fn token(&self) -> Address {
248            self.token
249        }
250
251        pub const fn amount(&self) -> u64 {
252            self.amount.as_limbs()[0]
253        }
254
255        pub const fn recipient(&self) -> Address {
256            self.recipient
257        }
258
259        pub const fn chain_id(&self) -> u32 {
260            self.chainId
261        }
262    }
263
264    impl Orders::Order {
265        /// Get the inputs of the order.
266        pub fn inputs(&self) -> &[IOrders::Input] {
267            &self.inputs
268        }
269
270        /// Get the outputs of the order.
271        pub fn outputs(&self) -> &[IOrders::Output] {
272            &self.outputs
273        }
274
275        /// Get the deadline of the order.
276        pub const fn deadline(&self) -> u64 {
277            self.deadline.as_limbs()[0]
278        }
279    }
280
281    impl Orders::Sweep {
282        pub const fn recipient(&self) -> Address {
283            self.recipient
284        }
285
286        pub const fn token(&self) -> Address {
287            self.token
288        }
289
290        pub const fn amount(&self) -> u64 {
291            self.amount.as_limbs()[0]
292        }
293    }
294
295    impl Orders::Filled {
296        pub fn outputs(&self) -> &[IOrders::Output] {
297            self.outputs.as_slice()
298        }
299    }
300}
301
302mod transactor {
303    use super::*;
304
305    alloy::sol!(
306        #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
307        #[sol(rpc)]
308        Transactor,
309        "abi/Transactor.json"
310    );
311
312    impl Copy for Transactor::GasConfigured {}
313
314    impl Clone for Transactor::TransactorEvents {
315        fn clone(&self) -> Self {
316            match self {
317                Transactor::TransactorEvents::Transact(event) => {
318                    Transactor::TransactorEvents::Transact(event.clone())
319                }
320                Transactor::TransactorEvents::GasConfigured(event) => {
321                    Transactor::TransactorEvents::GasConfigured(*event)
322                }
323            }
324        }
325    }
326
327    impl Transactor::Transact {
328        pub const fn rollup_chain_id(&self) -> u64 {
329            self.rollupChainId.as_limbs()[0]
330        }
331
332        pub const fn sender(&self) -> Address {
333            self.sender
334        }
335
336        pub const fn to(&self) -> Address {
337            self.to
338        }
339
340        pub const fn data(&self) -> &Bytes {
341            &self.data
342        }
343
344        pub const fn value(&self) -> U256 {
345            self.value
346        }
347
348        pub fn max_fee_per_gas(&self) -> u128 {
349            self.maxFeePerGas.to::<u128>()
350        }
351
352        pub fn gas(&self) -> u128 {
353            self.gas.to::<u128>()
354        }
355    }
356}
357
358mod rollup_passage {
359
360    alloy::sol!(
361        #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
362        #[sol(rpc)]
363        RollupPassage,
364        "abi/RollupPassage.json"
365    );
366
367    impl Copy for RollupPassage::Exit {}
368    impl Copy for RollupPassage::ExitToken {}
369    impl Copy for RollupPassage::AddressEmptyCode {}
370    impl Copy for RollupPassage::InsufficientBalance {}
371    impl Copy for RollupPassage::SafeERC20FailedOperation {}
372
373    impl Copy for RollupPassage::RollupPassageEvents {}
374
375    impl Clone for RollupPassage::RollupPassageEvents {
376        fn clone(&self) -> Self {
377            *self
378        }
379    }
380}
381
382mod bundle_helper {
383    alloy::sol!(
384        #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
385        #[sol(rpc)]
386        BundleHelper,
387        "abi/BundleHelper.json"
388    );
389}
390
391pub use zenith::Zenith;
392
393/// Contract Bindings for the RollupOrders contract.
394#[allow(non_snake_case)]
395pub mod RollupOrders {
396    pub use super::orders::Orders::*;
397
398    pub use super::orders::IOrders::*;
399    pub use super::orders::ISignatureTransfer::*;
400    pub use super::orders::UsesPermit2::*;
401
402    pub use super::orders::Orders::OrdersCalls as RollupOrdersCalls;
403    pub use super::orders::Orders::OrdersErrors as RollupOrdersErrors;
404    pub use super::orders::Orders::OrdersEvents as RollupOrdersEvents;
405    pub use super::orders::Orders::OrdersInstance as RollupOrdersInstance;
406}
407
408/// Contract Bindings for the HostOrders contract.
409#[allow(non_snake_case)]
410pub mod HostOrders {
411    pub use super::orders::Orders::*;
412
413    pub use super::orders::IOrders::*;
414    pub use super::orders::ISignatureTransfer::*;
415    pub use super::orders::UsesPermit2::*;
416
417    pub use super::orders::Orders::OrdersCalls as HostOrdersCalls;
418    pub use super::orders::Orders::OrdersErrors as HostOrdersErrors;
419    pub use super::orders::Orders::OrdersEvents as HostOrdersEvents;
420    pub use super::orders::Orders::OrdersInstance as HostOrdersInstance;
421}
422
423/// Contract Bindings for the Passage contract.
424#[allow(non_snake_case)]
425pub mod Passage {
426    pub use super::passage::Passage::*;
427
428    pub use super::passage::ISignatureTransfer::*;
429    pub use super::passage::UsesPermit2::*;
430}
431
432pub use transactor::Transactor;
433
434/// Contract Bindings for the RollupPassage contract.
435#[allow(non_snake_case)]
436pub mod RollupPassage {
437    pub use super::rollup_passage::RollupPassage::*;
438
439    pub use super::rollup_passage::ISignatureTransfer::*;
440    pub use super::rollup_passage::UsesPermit2::*;
441}
442
443/// Contract Bindings for the BundleHelper contract.
444#[allow(non_snake_case)]
445pub mod BundleHelper {
446    pub use super::bundle_helper::BundleHelper::*;
447    pub use super::bundle_helper::Zenith::BlockHeader;
448}