Skip to main content

cast/cmd/tempo/zone/
abi.rs

1//! Minimal zone client ABI, mirrored from tempoxyz/zones at a1c15e9f.
2//!
3//! Source: <https://github.com/tempoxyz/zones/tree/a1c15e9f002a5efd150f56c5076fb35519288396/crates/contracts/src/precompiles>
4
5use alloy_primitives::{Address, address};
6use alloy_sol_types::sol;
7
8/// Zone outbox precompile address.
9pub(super) const OUTBOX: Address = address!("1c00000000000000000000000000000000000002");
10
11sol! {
12    /// Encrypted recipient and memo submitted to the L1 portal.
13    struct DepositPayload {
14        bytes32 ephemeralPubkeyX;
15        uint8 ephemeralPubkeyYParity;
16        bytes ciphertext;
17        bytes12 nonce;
18        bytes16 tag;
19    }
20
21    #[sol(rpc)]
22    interface IZonePortal {
23        function zoneId() external view returns (uint32);
24        event WithdrawalProcessed(address indexed to, bytes32 indexed senderTag,
25            address token, uint128 amount, bool callbackSuccess);
26        function encryptionKeyAtBlock(uint64 tempoBlockNumber)
27            external view returns (bytes32 x, uint8 yParity, uint256 keyIndex);
28        function deposit(address token, uint128 amount, uint256 keyIndex,
29            DepositPayload encrypted, address tempoRefundRecipient)
30            external returns (bytes32 newCurrentDepositQueueHash);
31    }
32
33    #[sol(rpc)]
34    #[allow(clippy::too_many_arguments, reason = "matches the zone protocol ABI")]
35    interface IZoneOutbox {
36        event WithdrawalRequested(uint64 indexed withdrawalIndex, address indexed sender,
37            address token, address to, uint128 amount, uint128 fee, bytes32 memo,
38            uint64 gasLimit, uint64 fallbackNonce, bytes data, bytes revealTo);
39        function calculateWithdrawalFee(uint64 gasLimit) external view returns (uint128 fee);
40        function requestWithdrawal(address token, address to, uint128 amount, bytes32 memo,
41            uint64 gasLimit, address fallbackRecipient, bytes callbackData, bytes revealTo)
42            external;
43    }
44}
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49    use alloy_sol_types::SolCall;
50
51    #[test]
52    fn zone_abi_selectors() {
53        assert_eq!(IZonePortal::depositCall::SELECTOR, [0x03, 0xdd, 0x6f, 0x34]);
54        assert_eq!(IZonePortal::encryptionKeyAtBlockCall::SELECTOR, [0x39, 0xdc, 0x01, 0x5d]);
55        assert_eq!(IZoneOutbox::requestWithdrawalCall::SELECTOR, [0xb3, 0xb2, 0x00, 0xaa]);
56        assert_eq!(IZoneOutbox::calculateWithdrawalFeeCall::SELECTOR, [0x7b, 0x9c, 0x9a, 0xa4]);
57    }
58}