forked from BitGo/eth-multisig-v4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ForwarderFactory.sol
47 lines (40 loc) · 1.2 KB
/
ForwarderFactory.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.20;
import './Forwarder.sol';
import './CloneFactory.sol';
contract ForwarderFactory is CloneFactory {
address public immutable implementationAddress;
event ForwarderCreated(
address newForwarderAddress,
address parentAddress,
bool shouldAutoFlushERC721,
bool shouldAutoFlushERC1155
);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
this.createForwarder(parent, salt, true, true);
}
function createForwarder(
address parent,
bytes32 salt,
bool shouldAutoFlushERC721,
bool shouldAutoFlushERC1155
) external {
// include the parent in the salt so any contract deployed to a given address must have the same parent
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
emit ForwarderCreated(
clone,
parent,
shouldAutoFlushERC721,
shouldAutoFlushERC1155
);
Forwarder(clone).init(
parent,
shouldAutoFlushERC721,
shouldAutoFlushERC1155
);
}
}