|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +pragma solidity ^0.8.20; |
| 3 | + |
| 4 | +/** |
| 5 | + * @title ERC7656 |
| 6 | + * @dev Modified registry based on ERC6551Registry |
| 7 | + * https://github.com/erc6551/reference/blob/main/src/ERC6551Registry.sol |
| 8 | + * |
| 9 | + * The ERC165 interfaceId is 0xc6bdc908 |
| 10 | + * @notice Manages the creation of token linked services |
| 11 | + */ |
| 12 | +interface IERC7656Factory { |
| 13 | + /** |
| 14 | + * @notice The registry MUST emit the Created event upon successful contract creation. |
| 15 | + * @param contractAddress The address of the created contract |
| 16 | + * @param implementation The address of the implementation contract |
| 17 | + * @param chainId The chain linkedId of the chain where the contract is being created |
| 18 | + * @param linkedContract The address of the token or contract |
| 19 | + * @param linkedId The optional ID (e.g., linkedId) of the linked contract, or 0 if not applicable |
| 20 | + * @param salt The salt is a bytes32 so save 32 bytes in the bytecode. It is converted in the function to a bytes32 to use it for the create2 operation |
| 21 | + * @param mode If true, the linkedId is not used, saving 32 bytes in the bytecode |
| 22 | + */ |
| 23 | + event Created( |
| 24 | + address contractAddress, |
| 25 | + address indexed implementation, |
| 26 | + bytes32 salt, |
| 27 | + uint256 chainId, |
| 28 | + bytes12 mode, |
| 29 | + address indexed linkedContract, |
| 30 | + uint256 indexed linkedId |
| 31 | + ); |
| 32 | + |
| 33 | + /** |
| 34 | + * The registry MUST revert with CreationFailed error if the create2 operation fails. |
| 35 | + */ |
| 36 | + error CreationFailed(); |
| 37 | + |
| 38 | + /** |
| 39 | + * @notice Creates a token or contract-linked service. |
| 40 | + * If the service has already been created, returns the service address without calling create2. |
| 41 | + * @param implementation The address of the implementation contract |
| 42 | + * @param chainId The chain linkedId of the chain where the service is being created |
| 43 | + * @param linkedContract The address of the token or contract |
| 44 | + * @param linkedId The optional ID (e.g., linkedId) of the linked contract. If mode is true, this value is ignored |
| 45 | + * @param salt The salt is a bytes32 so save 32 bytes in the bytecode. It is converted in the function to a bytes32 to use it for the create2 operation |
| 46 | + * @param mode If true, the linkedId is not used, saving 32 bytes in the bytecode |
| 47 | + * @return service The address of the token or contract-linked service |
| 48 | + */ |
| 49 | + function create( |
| 50 | + address implementation, |
| 51 | + bytes32 salt, |
| 52 | + uint256 chainId, |
| 53 | + bytes12 mode, |
| 54 | + address linkedContract, |
| 55 | + uint256 linkedId |
| 56 | + ) external returns (address); |
| 57 | + |
| 58 | + /** |
| 59 | + * @notice Returns the computed token or contract-linked service address. |
| 60 | + * @param implementation The address of the implementation contract |
| 61 | + * @param salt The salt to use for the create2 operation |
| 62 | + * @param chainId The chain linkedId of the chain where the service is being created |
| 63 | + * @param linkedContract The address of the token or contract |
| 64 | + * @param linkedId The optional ID (e.g., linkedId) of the linked contract. If mode is true, this value is ignored |
| 65 | + * @param mode If true, the linkedId is not used, saving 32 bytes in the bytecode |
| 66 | + * @return service The address of the token or contract-linked service |
| 67 | + */ |
| 68 | + function compute( |
| 69 | + address implementation, |
| 70 | + bytes32 salt, |
| 71 | + uint256 chainId, |
| 72 | + bytes12 mode, |
| 73 | + address linkedContract, |
| 74 | + uint256 linkedId |
| 75 | + ) external view returns (address service); |
| 76 | +} |
0 commit comments