alloy_zksync/contracts/l1/
bridge_hub.rs

1alloy::sol! {
2    /// Represents a direct L2 transaction request.
3    #[allow(missing_docs)]
4    struct L2TransactionRequestDirect {
5        uint256 chainId;
6        uint256 mintValue;
7        address l2Contract;
8        uint256 l2Value;
9        bytes l2Calldata;
10        uint256 l2GasLimit;
11        uint256 l2GasPerPubdataByteLimit;
12        bytes[] factoryDeps;
13        address refundRecipient;
14    }
15
16    /// Represents an L2 transaction request involving two bridges.
17    #[allow(missing_docs)]
18    struct L2TransactionRequestTwoBridges {
19        uint256 chainId;
20        uint256 mintValue;
21        uint256 l2Value;
22        uint256 l2GasLimit;
23        uint256 l2GasPerPubdataByteLimit;
24        address refundRecipient;
25        address secondBridgeAddress;
26        uint256 secondBridgeValue;
27        bytes secondBridgeCalldata;
28    }
29
30    /// Represents a canonical L2 transaction.
31    #[allow(missing_docs)]
32    struct L2CanonicalTransaction {
33        uint256 txType;
34        uint256 from;
35        uint256 to;
36        uint256 gasLimit;
37        uint256 gasPerPubdataByteLimit;
38        uint256 maxFeePerGas;
39        uint256 maxPriorityFeePerGas;
40        uint256 paymaster;
41        uint256 nonce;
42        uint256 value;
43        uint256[4] reserved;
44        bytes data;
45        bytes signature;
46        uint256[] factoryDeps;
47        bytes paymasterInput;
48        bytes reservedDynamic;
49    }
50
51    /// Bridgehub contract for handling L2 transaction requests and related operations.
52    #[allow(missing_docs)]
53    #[sol(rpc)]
54    contract Bridgehub {
55        /// Requests a direct L2 transaction.
56        ///
57        /// # Arguments
58        ///
59        /// * `request` - The L2 transaction request.
60        ///
61        /// # Returns
62        ///
63        /// The canonical transaction hash.
64        function requestL2TransactionDirect(
65            L2TransactionRequestDirect memory request
66        ) external payable returns (bytes32 canonicalTxHash);
67
68        /// Requests an L2 transaction involving two bridges.
69        ///
70        /// # Arguments
71        ///
72        /// * `_request` - The L2 transaction request.
73        ///
74        /// # Returns
75        ///
76        /// The canonical transaction hash.
77        function requestL2TransactionTwoBridges(
78            L2TransactionRequestTwoBridges calldata _request
79        ) external payable returns (bytes32 canonicalTxHash);
80
81        /// Calculates the base cost of an L2 transaction.
82        ///
83        /// # Arguments
84        ///
85        /// * `_chainId` - The chain ID.
86        /// * `_gasPrice` - The gas price.
87        /// * `_l2GasLimit` - The L2 gas limit.
88        /// * `_l2GasPerPubdataByteLimit` - The L2 gas per pubdata byte limit.
89        ///
90        /// # Returns
91        ///
92        /// The base cost of the L2 transaction.
93        function l2TransactionBaseCost(
94            uint256 _chainId,
95            uint256 _gasPrice,
96            uint256 _l2GasLimit,
97            uint256 _l2GasPerPubdataByteLimit
98        ) external view returns (uint256);
99
100        /// Emitted when a new priority request is made.
101        ///
102        /// # Arguments
103        ///
104        /// * `txId` - The transaction ID.
105        /// * `txHash` - The transaction hash.
106        /// * `expirationTimestamp` - The expiration timestamp.
107        /// * `transaction` - The canonical transaction.
108        /// * `factoryDeps` - The factory dependencies.
109        event NewPriorityRequest(
110            uint256 txId,
111            bytes32 txHash,
112            uint64 expirationTimestamp,
113            L2CanonicalTransaction transaction,
114            bytes[] factoryDeps
115        );
116    }
117}