Skip to content

Commit d588c79

Browse files
Add IContractFactory interface (#219)
1 parent 044df1d commit d588c79

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

contracts/TWFactory.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ pragma solidity ^0.8.11;
33

44
import "./TWRegistry.sol";
55
import "./interfaces/IThirdwebContract.sol";
6+
import "./extension/interface/IContractFactory.sol";
67

78
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
89
import "@openzeppelin/contracts/metatx/ERC2771Context.sol";
910
import "@openzeppelin/contracts/utils/Create2.sol";
1011
import "@openzeppelin/contracts/utils/Multicall.sol";
1112
import "@openzeppelin/contracts/proxy/Clones.sol";
1213

13-
contract TWFactory is Multicall, ERC2771Context, AccessControlEnumerable {
14+
contract TWFactory is Multicall, ERC2771Context, AccessControlEnumerable, IContractFactory {
1415
/// @dev Only FACTORY_ROLE holders can approve/unapprove implementations for proxies to point to.
1516
bytes32 public constant FACTORY_ROLE = keccak256("FACTORY_ROLE");
1617

@@ -64,7 +65,7 @@ contract TWFactory is Multicall, ERC2771Context, AccessControlEnumerable {
6465
address _implementation,
6566
bytes memory _data,
6667
bytes32 _salt
67-
) public returns (address deployedProxy) {
68+
) public override returns (address deployedProxy) {
6869
require(approval[_implementation], "implementation not approved");
6970

7071
bytes32 salthash = keccak256(abi.encodePacked(_msgSender(), _salt));
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.0;
3+
4+
interface IContractFactory {
5+
/**
6+
* @notice Deploys a proxy that points to that points to the given implementation.
7+
*
8+
* @param implementation Address of the implementation to point to.
9+
*
10+
* @param data Additional data to pass to the proxy constructor or any other data useful during deployement.
11+
* @param salt Salt to use for the deterministic address generation.
12+
*/
13+
function deployProxyByImplementation(
14+
address implementation,
15+
bytes memory data,
16+
bytes32 salt
17+
) external returns (address);
18+
}

docs/IContractFactory.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# IContractFactory
2+
3+
4+
5+
6+
7+
8+
9+
10+
11+
## Methods
12+
13+
### deployProxyByImplementation
14+
15+
```solidity
16+
function deployProxyByImplementation(address implementation, bytes data, bytes32 salt) external nonpayable returns (address)
17+
```
18+
19+
Deploys a proxy that points to that points to the given implementation.
20+
21+
22+
23+
#### Parameters
24+
25+
| Name | Type | Description |
26+
|---|---|---|
27+
| implementation | address | Address of the implementation to point to.
28+
| data | bytes | Additional data to pass to the proxy constructor or any other data useful during deployement.
29+
| salt | bytes32 | Salt to use for the deterministic address generation.
30+
31+
#### Returns
32+
33+
| Name | Type | Description |
34+
|---|---|---|
35+
| _0 | address | undefined
36+
37+
38+
39+

0 commit comments

Comments
 (0)