Skip to main content

tempo_contracts/precompiles/
tip20_factory.rs

1pub use ITIP20Factory::{
2    ITIP20FactoryErrors as TIP20FactoryError, ITIP20FactoryEvents as TIP20FactoryEvent,
3};
4use alloy_primitives::Address;
5
6crate::sol! {
7  #[derive(Debug, PartialEq, Eq)]
8    #[sol(abi)]
9    interface ITIP20Factory {
10        error AddressReserved();
11        error AddressNotReserved();
12        error InvalidQuoteToken();
13        error TokenAlreadyExists(address token);
14
15        event TokenCreated(address indexed token, string name, string symbol, string currency, address quoteToken, address admin, bytes32 salt);
16
17        function createToken(
18            string memory name,
19            string memory symbol,
20            string memory currency,
21            address quoteToken,
22            address admin,
23            bytes32 salt
24        ) external returns (address);
25
26        function isTIP20(address token) public view returns (bool);
27
28        function getTokenAddress(address sender, bytes32 salt) public view returns (address);
29    }
30}
31
32impl TIP20FactoryError {
33    /// Creates an error when attempting to use a reserved address.
34    pub const fn address_reserved() -> Self {
35        Self::AddressReserved(ITIP20Factory::AddressReserved {})
36    }
37
38    /// Creates an error when address is not in the reserved range.
39    pub const fn address_not_reserved() -> Self {
40        Self::AddressNotReserved(ITIP20Factory::AddressNotReserved {})
41    }
42
43    /// Creates an error for invalid quote token.
44    pub const fn invalid_quote_token() -> Self {
45        Self::InvalidQuoteToken(ITIP20Factory::InvalidQuoteToken {})
46    }
47
48    /// Creates an error when token already exists at the given address.
49    pub const fn token_already_exists(token: Address) -> Self {
50        Self::TokenAlreadyExists(ITIP20Factory::TokenAlreadyExists { token })
51    }
52}