zenith_types/
lib.rs

1#![doc = include_str!("../README.md")]
2#![warn(
3    missing_copy_implementations,
4    missing_debug_implementations,
5    missing_docs,
6    unreachable_pub,
7    clippy::missing_const_for_fn,
8    rustdoc::all
9)]
10#![cfg_attr(not(test), warn(unused_crate_dependencies))]
11#![deny(unused_must_use, rust_2018_idioms)]
12#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
13
14mod bindings;
15pub use bindings::{
16    mintCall, BundleHelper, HostOrders, Passage, RollupOrders, RollupPassage, Transactor, Zenith,
17};
18
19mod block;
20pub use block::{decode_txns, encode_txns, Alloy2718Coder, Coder, ZenithBlock, ZenithTransaction};
21
22mod orders;
23pub use orders::{AggregateOrders, SignedOrder};
24
25mod bundle;
26pub use bundle::{
27    ZenithCallBundle, ZenithCallBundleResponse, ZenithEthBundle, ZenithEthBundleResponse,
28};
29
30mod req;
31pub use req::SignRequest;
32
33mod resp;
34pub use resp::SignResponse;
35
36use alloy::primitives::{address, Address};
37
38/// System address with permission to mint tokens on pre-deploys.
39pub const MINTER_ADDRESS: Address = address!("00000000000000000000746f6b656e61646d696e");
40
41/// A [`RequestSigner`] signs [`SignRequest`]s by delegating to an
42/// [`alloy::signers::Signer`].
43pub trait RequestSigner {
44    /// Signs a [`SignRequest`] and returns the [`alloy::primitives::Signature`].
45    fn sign_request(
46        &self,
47        request: &SignRequest,
48    ) -> impl std::future::Future<
49        Output = Result<alloy::primitives::PrimitiveSignature, alloy::signers::Error>,
50    > + Send;
51}
52
53impl<T> RequestSigner for T
54where
55    T: alloy::signers::Signer + Send + Sync,
56{
57    async fn sign_request(
58        &self,
59        request: &SignRequest,
60    ) -> Result<alloy::primitives::PrimitiveSignature, alloy::signers::Error> {
61        let hash = request.signing_hash();
62        self.sign_hash(&hash).await
63    }
64}