signet_zenith/
bindings.rs

1#![allow(clippy::too_many_arguments)]
2#![allow(missing_docs)]
3use alloy::primitives::{Address, Bytes, FixedBytes, U256};
4use std::borrow::Cow;
5
6mod mint {
7    alloy::sol!(
8        #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
9        function mint(address to, uint256 amount);
10    );
11}
12pub use mint::mintCall;
13
14mod zenith {
15    use super::*;
16
17    alloy::sol!(
18        #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
19        #[sol(rpc)]
20        Zenith,
21        "abi/Zenith.json"
22    );
23
24    impl Copy for Zenith::BlockHeader {}
25    impl Copy for Zenith::BlockSubmitted {}
26    impl Copy for Zenith::SequencerSet {}
27    impl Copy for Zenith::BadSignature {}
28    impl Copy for Zenith::OneRollupBlockPerHostBlock {}
29    impl Copy for Zenith::OnlySequencerAdmin {}
30    impl Copy for Zenith::IncorrectHostBlock {}
31
32    impl Zenith::BlockSubmitted {
33        /// Get the sequencer address that signed the block.
34        pub const fn sequencer(&self) -> Address {
35            self.sequencer
36        }
37
38        /// Get the chain id of the rollup.
39        pub const fn rollup_chain_id(&self) -> u64 {
40            self.rollupChainId.as_limbs()[0]
41        }
42
43        /// Get the gas limit of the block
44        pub const fn gas_limit(&self) -> u64 {
45            self.gasLimit.as_limbs()[0]
46        }
47
48        /// Get the reward address of the block.
49        pub const fn reward_address(&self) -> Address {
50            self.rewardAddress
51        }
52
53        /// Get the block data hash, i.e. the committment to the data of the block.
54        pub const fn block_data_hash(&self) -> FixedBytes<32> {
55            self.blockDataHash
56        }
57
58        /// Convert the BlockSubmitted event to a BlockHeader with the given host
59        /// block number.
60        pub const fn to_header(self, host_block_number: U256) -> Zenith::BlockHeader {
61            Zenith::BlockHeader::from_block_submitted(self, host_block_number)
62        }
63    }
64
65    impl Zenith::BlockHeader {
66        /// Create a BlockHeader from a BlockSubmitted event with the given host
67        /// block number
68        pub const fn from_block_submitted(
69            host_block_submitted: Zenith::BlockSubmitted,
70            host_block_number: U256,
71        ) -> Zenith::BlockHeader {
72            Zenith::BlockHeader {
73                rollupChainId: host_block_submitted.rollupChainId,
74                hostBlockNumber: host_block_number,
75                gasLimit: host_block_submitted.gasLimit,
76                rewardAddress: host_block_submitted.rewardAddress,
77                blockDataHash: host_block_submitted.blockDataHash,
78            }
79        }
80
81        /// Get the host block number of the block
82        pub const fn host_block_number(&self) -> u64 {
83            self.hostBlockNumber.as_limbs()[0]
84        }
85
86        /// Get the chain ID of the block (discarding high bytes).
87        pub const fn chain_id(&self) -> u64 {
88            self.rollupChainId.as_limbs()[0]
89        }
90
91        /// Get the gas limit of the block (discarding high bytes).
92        pub const fn gas_limit(&self) -> u64 {
93            self.gasLimit.as_limbs()[0]
94        }
95
96        /// Get the reward address of the block.
97        pub const fn reward_address(&self) -> Address {
98            self.rewardAddress
99        }
100
101        /// Get the block data hash, i.e. the committment to the data of the block.
102        pub const fn block_data_hash(&self) -> FixedBytes<32> {
103            self.blockDataHash
104        }
105    }
106}
107
108mod passage {
109    use super::*;
110
111    alloy::sol!(
112        #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
113        #[sol(rpc)]
114        Passage,
115        "abi/Passage.json"
116    );
117
118    impl Copy for Passage::EnterConfigured {}
119    impl Copy for Passage::Withdrawal {}
120    impl Copy for Passage::OnlyTokenAdmin {}
121    impl Copy for Passage::Enter {}
122    impl Copy for Passage::EnterToken {}
123    impl Copy for Passage::DisallowedEnter {}
124    impl Copy for Passage::FailedCall {}
125    impl Copy for Passage::InsufficientBalance {}
126    impl Copy for Passage::SafeERC20FailedOperation {}
127    impl Copy for Passage::AddressEmptyCode {}
128
129    impl Copy for Passage::PassageEvents {}
130
131    impl Passage::EnterToken {
132        /// Get the chain ID of the event (discarding high bytes), returns `None`
133        /// if the event has no associated chain id.
134        pub const fn rollup_chain_id(&self) -> u64 {
135            self.rollupChainId.as_limbs()[0]
136        }
137
138        /// Get the token address of the event.
139        pub const fn token(&self) -> Address {
140            self.token
141        }
142
143        /// Get the recipient of the event.
144        pub const fn recipient(&self) -> Address {
145            self.rollupRecipient
146        }
147
148        /// Get the amount of the event.
149        pub const fn amount(&self) -> U256 {
150            self.amount
151        }
152    }
153
154    impl Passage::Enter {
155        /// Get the chain ID of the event (discarding high bytes), returns `None`
156        /// if the event has no associated chain id.
157        pub const fn rollup_chain_id(&self) -> u64 {
158            self.rollupChainId.as_limbs()[0]
159        }
160
161        /// Get the recipient of the event.
162        pub const fn recipient(&self) -> Address {
163            self.rollupRecipient
164        }
165
166        /// Get the amount of the event.
167        pub const fn amount(&self) -> U256 {
168            self.amount
169        }
170    }
171
172    impl Passage::Withdrawal {
173        /// Get the token address of the request.
174        pub const fn token(&self) -> Address {
175            self.token
176        }
177
178        /// Get the recipient of the request.
179        pub const fn recipient(&self) -> Address {
180            self.recipient
181        }
182
183        /// Get the amount of the request.
184        pub const fn amount(&self) -> U256 {
185            self.amount
186        }
187    }
188
189    impl Passage::EnterConfigured {
190        /// Get the token address of the event.
191        pub const fn token(&self) -> Address {
192            self.token
193        }
194
195        /// Get if the token has been configured to allow or disallow enters.
196        pub const fn can_enter(&self) -> bool {
197            self.canEnter
198        }
199    }
200}
201
202mod orders {
203    use super::*;
204    use IOrders::Output;
205    use ISignatureTransfer::TokenPermissions;
206
207    alloy::sol!(
208        #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
209        #[sol(rpc)]
210        Orders,
211        "abi/RollupOrders.json"
212    );
213
214    alloy::sol! {
215       struct PermitBatchWitnessTransferFrom {
216           TokenPermissions[] permitted;
217           address spender;
218           uint256 nonce;
219           uint256 deadline;
220           Output[] outputs;
221       }
222    }
223
224    impl Copy for IOrders::Input {}
225    impl Copy for IOrders::Output {}
226    impl Copy for Orders::Sweep {}
227    impl Copy for Orders::InsufficientBalance {}
228    impl Copy for Orders::AddressEmptyCode {}
229    impl Copy for Orders::LengthMismatch {}
230    impl Copy for Orders::OrderExpired {}
231    impl Copy for Orders::OutputMismatch {}
232    impl Copy for Orders::SafeERC20FailedOperation {}
233
234    impl IOrders::Input {
235        pub const fn token(&self) -> Address {
236            self.token
237        }
238
239        pub const fn amount(&self) -> u64 {
240            self.amount.as_limbs()[0]
241        }
242    }
243
244    impl IOrders::Output {
245        pub const fn token(&self) -> Address {
246            self.token
247        }
248
249        pub const fn amount(&self) -> u64 {
250            self.amount.as_limbs()[0]
251        }
252
253        pub const fn recipient(&self) -> Address {
254            self.recipient
255        }
256
257        pub const fn chain_id(&self) -> u32 {
258            self.chainId
259        }
260    }
261
262    impl From<&IOrders::Input> for TokenPermissions {
263        fn from(input: &IOrders::Input) -> TokenPermissions {
264            TokenPermissions { token: input.token, amount: input.amount }
265        }
266    }
267
268    impl From<IOrders::Input> for TokenPermissions {
269        fn from(input: IOrders::Input) -> TokenPermissions {
270            TokenPermissions { token: input.token, amount: input.amount }
271        }
272    }
273
274    impl From<TokenPermissions> for IOrders::Input {
275        fn from(perm: TokenPermissions) -> IOrders::Input {
276            IOrders::Input { token: perm.token, amount: perm.amount }
277        }
278    }
279
280    impl From<&IOrders::Output> for TokenPermissions {
281        fn from(output: &IOrders::Output) -> TokenPermissions {
282            TokenPermissions { token: output.token, amount: output.amount }
283        }
284    }
285
286    impl From<IOrders::Output> for TokenPermissions {
287        fn from(output: IOrders::Output) -> TokenPermissions {
288            TokenPermissions { token: output.token, amount: output.amount }
289        }
290    }
291
292    impl Orders::Order {
293        /// Get the inputs of the order.
294        #[allow(clippy::missing_const_for_fn)] // false positive
295        pub fn inputs(&self) -> &[IOrders::Input] {
296            &self.inputs
297        }
298
299        /// Get the outputs of the order.
300        #[allow(clippy::missing_const_for_fn)] // false positive
301        pub fn outputs(&self) -> &[IOrders::Output] {
302            &self.outputs
303        }
304
305        /// Get the deadline of the order.
306        pub const fn deadline(&self) -> u64 {
307            self.deadline.as_limbs()[0]
308        }
309    }
310
311    impl<'a> From<&'a Orders::Order> for Cow<'a, Orders::Order> {
312        fn from(order: &'a Orders::Order) -> Self {
313            Cow::Borrowed(order)
314        }
315    }
316
317    impl Orders::Sweep {
318        pub const fn recipient(&self) -> Address {
319            self.recipient
320        }
321
322        pub const fn token(&self) -> Address {
323            self.token
324        }
325
326        pub const fn amount(&self) -> u64 {
327            self.amount.as_limbs()[0]
328        }
329    }
330
331    impl Orders::Filled {
332        pub fn outputs(&self) -> &[IOrders::Output] {
333            self.outputs.as_slice()
334        }
335    }
336
337    impl Default for Orders::Order {
338        fn default() -> Self {
339            Self { inputs: Vec::new(), outputs: Vec::new(), deadline: U256::ZERO }
340        }
341    }
342
343    impl Orders::Order {
344        /// Add an input to the Order and return the modified Order.
345        pub fn with_input(mut self, input: IOrders::Input) -> Self {
346            self.inputs.push(input);
347            self
348        }
349
350        /// Add an output to the Order and return the modified Order.
351        pub fn with_output(mut self, output: IOrders::Output) -> Self {
352            self.outputs.push(output);
353            self
354        }
355
356        /// Set the deadline of the Order and return the modified Order.
357        pub fn with_deadline(mut self, deadline: u64) -> Self {
358            self.deadline = U256::from(deadline);
359            self
360        }
361    }
362}
363
364mod transactor {
365    use super::*;
366
367    alloy::sol!(
368        #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
369        #[sol(rpc)]
370        Transactor,
371        "abi/Transactor.json"
372    );
373
374    impl Copy for Transactor::GasConfigured {}
375
376    impl Transactor::Transact {
377        /// Get the chain ID of the event (discarding high bytes).
378        pub const fn rollup_chain_id(&self) -> u64 {
379            self.rollupChainId.as_limbs()[0]
380        }
381
382        /// Get the host sender that triggered the event.
383        pub const fn host_sender(&self) -> Address {
384            self.sender
385        }
386
387        /// Get the recipient of the transact.
388        pub const fn to(&self) -> Address {
389            self.to
390        }
391
392        /// Get the data of the transact.
393        pub const fn data(&self) -> &Bytes {
394            &self.data
395        }
396
397        /// Get the value of the transact.
398        pub const fn value(&self) -> U256 {
399            self.value
400        }
401
402        /// Get the max fee per gas of the transact.
403        pub fn max_fee_per_gas(&self) -> u128 {
404            self.maxFeePerGas.to::<u128>()
405        }
406
407        /// Get the gas limit of the transact.
408        pub fn gas(&self) -> u128 {
409            self.gas.to::<u128>()
410        }
411    }
412}
413
414mod rollup_passage {
415
416    alloy::sol!(
417        #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
418        #[sol(rpc)]
419        RollupPassage,
420        "abi/RollupPassage.json"
421    );
422
423    impl Copy for RollupPassage::Exit {}
424    impl Copy for RollupPassage::ExitToken {}
425    impl Copy for RollupPassage::AddressEmptyCode {}
426    impl Copy for RollupPassage::InsufficientBalance {}
427    impl Copy for RollupPassage::SafeERC20FailedOperation {}
428
429    impl Copy for RollupPassage::RollupPassageEvents {}
430}
431
432mod bundle_helper {
433    use super::*;
434
435    use ISignatureTransfer::{PermitBatchTransferFrom, TokenPermissions};
436    use UsesPermit2::Permit2Batch;
437
438    alloy::sol!(
439        #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
440        #[sol(rpc)]
441        BundleHelper,
442        "abi/BundleHelper.json"
443    );
444
445    impl From<&RollupOrders::Output> for IOrders::Output {
446        fn from(output: &RollupOrders::Output) -> IOrders::Output {
447            IOrders::Output {
448                token: output.token,
449                amount: output.amount,
450                recipient: output.recipient,
451                chainId: output.chainId,
452            }
453        }
454    }
455
456    impl From<RollupOrders::Output> for IOrders::Output {
457        fn from(output: RollupOrders::Output) -> IOrders::Output {
458            IOrders::Output {
459                token: output.token,
460                amount: output.amount,
461                recipient: output.recipient,
462                chainId: output.chainId,
463            }
464        }
465    }
466
467    impl From<RollupOrders::Permit2Batch> for Permit2Batch {
468        fn from(permit: HostOrders::Permit2Batch) -> Permit2Batch {
469            Permit2Batch {
470                permit: permit.permit.into(),
471                owner: permit.owner,
472                signature: permit.signature,
473            }
474        }
475    }
476
477    impl From<&RollupOrders::Permit2Batch> for Permit2Batch {
478        fn from(permit: &HostOrders::Permit2Batch) -> Permit2Batch {
479            Permit2Batch {
480                permit: (&permit.permit).into(),
481                owner: permit.owner,
482                signature: permit.signature.clone(),
483            }
484        }
485    }
486
487    impl From<&RollupOrders::PermitBatchTransferFrom> for PermitBatchTransferFrom {
488        fn from(permit: &HostOrders::PermitBatchTransferFrom) -> PermitBatchTransferFrom {
489            PermitBatchTransferFrom {
490                permitted: permit.permitted.iter().map(TokenPermissions::from).collect(),
491                nonce: permit.nonce,
492                deadline: permit.deadline,
493            }
494        }
495    }
496
497    impl From<RollupOrders::PermitBatchTransferFrom> for PermitBatchTransferFrom {
498        fn from(permit: HostOrders::PermitBatchTransferFrom) -> PermitBatchTransferFrom {
499            PermitBatchTransferFrom {
500                permitted: permit.permitted.into_iter().map(TokenPermissions::from).collect(),
501                nonce: permit.nonce,
502                deadline: permit.deadline,
503            }
504        }
505    }
506
507    impl From<&crate::bindings::orders::ISignatureTransfer::TokenPermissions> for TokenPermissions {
508        fn from(perm: &HostOrders::TokenPermissions) -> TokenPermissions {
509            TokenPermissions { token: perm.token, amount: perm.amount }
510        }
511    }
512
513    impl From<crate::bindings::orders::ISignatureTransfer::TokenPermissions> for TokenPermissions {
514        fn from(perm: HostOrders::TokenPermissions) -> TokenPermissions {
515            TokenPermissions { token: perm.token, amount: perm.amount }
516        }
517    }
518}
519
520pub use zenith::Zenith;
521
522/// Contract Bindings for the RollupOrders contract.
523#[allow(non_snake_case)]
524pub mod RollupOrders {
525    pub use super::orders::IOrders::*;
526    pub use super::orders::ISignatureTransfer::*;
527    pub use super::orders::Orders::*;
528    pub use super::orders::PermitBatchWitnessTransferFrom;
529    pub use super::orders::UsesPermit2::*;
530
531    pub use super::orders::Orders::OrdersCalls as RollupOrdersCalls;
532    pub use super::orders::Orders::OrdersErrors as RollupOrdersErrors;
533    pub use super::orders::Orders::OrdersEvents as RollupOrdersEvents;
534    pub use super::orders::Orders::OrdersInstance as RollupOrdersInstance;
535}
536
537/// Contract Bindings for the HostOrders contract.
538#[allow(non_snake_case)]
539pub mod HostOrders {
540    pub use super::orders::Orders::*;
541
542    pub use super::orders::IOrders::*;
543    pub use super::orders::ISignatureTransfer::*;
544    pub use super::orders::UsesPermit2::*;
545
546    pub use super::orders::Orders::OrdersCalls as HostOrdersCalls;
547    pub use super::orders::Orders::OrdersErrors as HostOrdersErrors;
548    pub use super::orders::Orders::OrdersEvents as HostOrdersEvents;
549    pub use super::orders::Orders::OrdersInstance as HostOrdersInstance;
550}
551
552/// Contract Bindings for the Passage contract.
553#[allow(non_snake_case)]
554pub mod Passage {
555    pub use super::passage::Passage::*;
556
557    pub use super::passage::ISignatureTransfer::*;
558    pub use super::passage::UsesPermit2::*;
559}
560
561pub use transactor::Transactor;
562
563/// Contract Bindings for the RollupPassage contract.
564#[allow(non_snake_case)]
565pub mod RollupPassage {
566    pub use super::rollup_passage::RollupPassage::*;
567
568    pub use super::rollup_passage::ISignatureTransfer::*;
569    pub use super::rollup_passage::UsesPermit2::*;
570}
571
572/// Contract Bindings for the BundleHelper contract.
573#[allow(non_snake_case)]
574pub mod BundleHelper {
575    pub use super::bundle_helper::BundleHelper::*;
576    pub use super::bundle_helper::IOrders;
577    pub use super::bundle_helper::Zenith::BlockHeader;
578}