Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit b6612cb

Browse files
authored
feat: alias Orders as RollupOrders and HostOrders (#42)
* feat: from conversion for filled structs * refactor: alias RollupOrders and HostOrders instead of differing
1 parent ede5854 commit b6612cb

File tree

2 files changed

+44
-147
lines changed

2 files changed

+44
-147
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ members = [ "crates/*" ]
33
resolver = "2"
44

55
[workspace.package]
6-
version = "0.5.1"
6+
version = "0.6.0"
77
edition = "2021"
88
rust-version = "1.76"
99
authors = ["Zenith Contributors"]

crates/types/src/bindings.rs

+43-146
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![allow(missing_docs)]
33
use alloy_primitives::{Address, Bytes, FixedBytes, U256};
44
use alloy_sol_types::sol;
5-
use HostOrders::TokenPermissions;
65

76
sol!(
87
#[sol(rpc)]
@@ -21,14 +20,7 @@ sol!(
2120
sol!(
2221
#[sol(rpc)]
2322
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
24-
HostOrders,
25-
"abi/HostOrders.json"
26-
);
27-
28-
sol!(
29-
#[sol(rpc)]
30-
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
31-
RollupOrders,
23+
Orders,
3224
"abi/RollupOrders.json"
3325
);
3426

@@ -46,6 +38,26 @@ sol!(
4638
"abi/RollupPassage.json"
4739
);
4840

41+
/// Module alias for [`Orders`].
42+
#[allow(non_snake_case)]
43+
pub mod RollupOrders {
44+
pub use super::Orders::OrdersCalls as RollupOrdersCalls;
45+
pub use super::Orders::OrdersErrors as RollupOrdersErrors;
46+
pub use super::Orders::OrdersEvents as RollupOrdersEvents;
47+
pub use super::Orders::OrdersInstance as RollupOrdersInstance;
48+
pub use super::Orders::*;
49+
}
50+
51+
/// Module alias for [`Orders`].
52+
#[allow(non_snake_case)]
53+
pub mod HostOrders {
54+
pub use super::Orders::OrdersCalls as HostOrdersCalls;
55+
pub use super::Orders::OrdersErrors as HostOrdersErrors;
56+
pub use super::Orders::OrdersEvents as HostOrdersEvents;
57+
pub use super::Orders::OrdersInstance as HostOrdersInstance;
58+
pub use super::Orders::*;
59+
}
60+
4961
// Zenith types
5062
impl Copy for Zenith::BlockHeader {}
5163
impl Copy for Zenith::BlockSubmitted {}
@@ -220,144 +232,29 @@ impl Passage::EnterConfigured {
220232
}
221233
}
222234

223-
// HostOrders types
224-
225-
impl Copy for HostOrders::Output {}
226-
impl Copy for HostOrders::TokenPermissions {}
227-
impl Copy for HostOrders::AddressEmptyCode {}
228-
impl Copy for HostOrders::FailedCall {}
229-
impl Copy for HostOrders::InsufficientBalance {}
230-
impl Copy for HostOrders::ReentrancyGuardReentrantCall {}
231-
impl Copy for HostOrders::LengthMismatch {}
232-
impl Copy for HostOrders::OutputMismatch {}
233-
impl Copy for HostOrders::SafeERC20FailedOperation {}
234-
235-
impl Clone for HostOrders::HostOrdersEvents {
236-
fn clone(&self) -> Self {
237-
match self {
238-
HostOrders::HostOrdersEvents::Filled(event) => {
239-
HostOrders::HostOrdersEvents::Filled(event.clone())
240-
}
241-
}
242-
}
243-
}
244-
245-
impl HostOrders::Output {
246-
/// Get the token address of the output.
247-
pub const fn token(&self) -> Address {
248-
self.token
249-
}
250-
251-
/// Get the recipient of the output.
252-
pub const fn recipient(&self) -> Address {
253-
self.recipient
254-
}
255-
256-
/// Get the amount of the output.
257-
pub const fn amount(&self) -> U256 {
258-
self.amount
259-
}
260-
261-
/// Get the chain ID of the output.
262-
pub const fn chain_id(&self) -> u32 {
263-
self.chainId
264-
}
265-
}
266-
267-
impl HostOrders::TokenPermissions {
268-
/// Get the token address of the output.
269-
pub const fn token(&self) -> Address {
270-
self.token
271-
}
272-
273-
/// Get the amount of the output.
274-
pub const fn amount(&self) -> U256 {
275-
self.amount
276-
}
277-
}
278-
279-
impl HostOrders::Witness {
280-
/// Get the witness hash of the witness.
281-
pub const fn witness_hash(&self) -> FixedBytes<32> {
282-
self.witnessHash
283-
}
284-
285-
/// Get the witness type string.
286-
pub fn witness_type(&self) -> String {
287-
self.witnessTypeString.clone()
288-
}
289-
}
290-
291-
impl HostOrders::Filled {
292-
/// Get the outputs of the filled order.
293-
pub fn outputs(&self) -> &[HostOrders::Output] {
294-
&self.outputs
295-
}
296-
}
297-
298-
impl HostOrders::PermitBatchTransferFrom {
299-
/// Get the permitted tokens of the batch transfer permit.
300-
pub fn permitted(&self) -> &[TokenPermissions] {
301-
&self.permitted
302-
}
303-
304-
/// Get the nonce of the batch transfer permit.
305-
pub const fn nonce(&self) -> U256 {
306-
self.nonce
307-
}
308-
309-
/// Get the deadline of the batch transfer permit.
310-
pub const fn deadline(&self) -> U256 {
311-
self.deadline
312-
}
313-
}
314-
315-
impl HostOrders::Permit2Batch {
316-
/// Get the permitted tokens of the batch transfer permit.
317-
pub const fn permit(&self) -> &HostOrders::PermitBatchTransferFrom {
318-
&self.permit
319-
}
320-
321-
/// Get the owner of the permit.
322-
pub const fn owner(&self) -> Address {
323-
self.owner
324-
}
325-
326-
/// Get the signature of the permit.
327-
pub fn signature(&self) -> Bytes {
328-
self.signature.clone()
329-
}
330-
}
331-
332235
// RollupOrders types
333236

334-
impl Copy for RollupOrders::Input {}
335-
impl Copy for RollupOrders::Output {}
336-
impl Copy for RollupOrders::Sweep {}
337-
impl Copy for RollupOrders::InsufficientBalance {}
338-
impl Copy for RollupOrders::AddressEmptyCode {}
339-
impl Copy for RollupOrders::LengthMismatch {}
340-
impl Copy for RollupOrders::OrderExpired {}
341-
impl Copy for RollupOrders::OutputMismatch {}
342-
impl Copy for RollupOrders::SafeERC20FailedOperation {}
343-
344-
impl Clone for RollupOrders::RollupOrdersEvents {
237+
impl Copy for Orders::Input {}
238+
impl Copy for Orders::Output {}
239+
impl Copy for Orders::Sweep {}
240+
impl Copy for Orders::InsufficientBalance {}
241+
impl Copy for Orders::AddressEmptyCode {}
242+
impl Copy for Orders::LengthMismatch {}
243+
impl Copy for Orders::OrderExpired {}
244+
impl Copy for Orders::OutputMismatch {}
245+
impl Copy for Orders::SafeERC20FailedOperation {}
246+
247+
impl Clone for Orders::OrdersEvents {
345248
fn clone(&self) -> Self {
346249
match self {
347-
RollupOrders::RollupOrdersEvents::Order(event) => {
348-
RollupOrders::RollupOrdersEvents::Order(event.clone())
349-
}
350-
RollupOrders::RollupOrdersEvents::Sweep(event) => {
351-
RollupOrders::RollupOrdersEvents::Sweep(*event)
352-
}
353-
RollupOrders::RollupOrdersEvents::Filled(event) => {
354-
RollupOrders::RollupOrdersEvents::Filled(event.clone())
355-
}
250+
Self::Order(event) => Self::Order(event.clone()),
251+
Self::Sweep(event) => Self::Sweep(*event),
252+
Self::Filled(event) => Self::Filled(event.clone()),
356253
}
357254
}
358255
}
359256

360-
impl RollupOrders::Input {
257+
impl Orders::Input {
361258
pub const fn token(&self) -> Address {
362259
self.token
363260
}
@@ -367,7 +264,7 @@ impl RollupOrders::Input {
367264
}
368265
}
369266

370-
impl RollupOrders::Output {
267+
impl Orders::Output {
371268
pub const fn token(&self) -> Address {
372269
self.token
373270
}
@@ -385,14 +282,14 @@ impl RollupOrders::Output {
385282
}
386283
}
387284

388-
impl RollupOrders::Order {
285+
impl Orders::Order {
389286
/// Get the inputs of the order.
390-
pub fn inputs(&self) -> &[RollupOrders::Input] {
287+
pub fn inputs(&self) -> &[Orders::Input] {
391288
&self.inputs
392289
}
393290

394291
/// Get the outputs of the order.
395-
pub fn outputs(&self) -> &[RollupOrders::Output] {
292+
pub fn outputs(&self) -> &[Orders::Output] {
396293
&self.outputs
397294
}
398295

@@ -402,7 +299,7 @@ impl RollupOrders::Order {
402299
}
403300
}
404301

405-
impl RollupOrders::Sweep {
302+
impl Orders::Sweep {
406303
pub const fn recipient(&self) -> Address {
407304
self.recipient
408305
}
@@ -416,8 +313,8 @@ impl RollupOrders::Sweep {
416313
}
417314
}
418315

419-
impl RollupOrders::Filled {
420-
pub fn outputs(&self) -> &[RollupOrders::Output] {
316+
impl Orders::Filled {
317+
pub fn outputs(&self) -> &[Orders::Output] {
421318
self.outputs.as_slice()
422319
}
423320
}

0 commit comments

Comments
 (0)