Skip to main content

libid_contracts/bindings/
factory.rs

1//! Bindings for the deterministic deployment factory. Mirrors
2//! `solidity/contracts/factory/`.
3
4/// Bindings for `factory/LibidFactory.sol`.
5///
6/// Every protocol proxy is deployed through this factory via CREATE3 with
7/// `salt = keccak256(bytes(name))`, so its address is a function of
8/// (factory address, name) only โ€” and since the factory lives at the same
9/// address on every chain (see [`crate::factory`]), `predict(name)` answers
10/// the same address on every EVM network.
11#[allow(clippy::too_many_arguments, unused_attributes)]
12mod factory_inner {
13    use alloy::sol;
14
15    sol! {
16        #[sol(rpc)]
17        interface LibidFactory {
18            function initialize(address owner_) external;
19            /// CREATE3-deploy `creationCode` under `name`; lands on
20            /// `predict(name)` whatever the code is. Owner-gated; a name is
21            /// single-use.
22            function deploy(string calldata name, bytes calldata creationCode) external returns (address);
23            /// The address `deploy(name, ยท)` lands on โ€” answerable pre-deploy.
24            function predict(string calldata name) external view returns (address);
25            /// Where `name` was deployed, or zero if it wasn't yet.
26            function deployedAt(string calldata name) external view returns (address);
27            /// Name-hash (`keccak256(bytes(name))`) โ†’ deployed address.
28            function deployments(bytes32 nameHash) external view returns (address);
29
30            function owner() external view returns (address);
31            function pendingOwner() external view returns (address);
32            function transferOwnership(address newOwner) external;
33            function acceptOwnership() external;
34
35            event Deployed(bytes32 indexed nameHash, string name, address addr);
36        }
37    }
38}
39
40pub use factory_inner::LibidFactory;