generated from foundry-rs/forge-template
-
Notifications
You must be signed in to change notification settings - Fork 44
/
ExampleCloneFactory.sol
62 lines (53 loc) · 1.87 KB
/
ExampleCloneFactory.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// SPDX-License-Identifier: BSD
pragma solidity ^0.8.4;
import {ExampleClone} from "./ExampleClone.sol";
import {ClonesWithImmutableArgs} from "./ClonesWithImmutableArgs.sol";
contract ExampleCloneFactory {
using ClonesWithImmutableArgs for address;
ExampleClone public implementation;
constructor(ExampleClone implementation_) {
implementation = implementation_;
}
function createClone(
address param1,
uint256 param2,
uint64 param3,
uint8 param4
) external payable returns (ExampleClone clone) {
bytes memory data = abi.encodePacked(param1, param2, param3, param4);
clone = ExampleClone(address(implementation).clone(data, msg.value));
}
function createClone2(
address param1,
uint256 param2,
uint64 param3,
uint8 param4
) external payable returns (ExampleClone clone) {
bytes memory data = abi.encodePacked(param1, param2, param3, param4);
clone = ExampleClone(address(implementation).clone2(data, msg.value));
}
function addressOfClone2(
address param1,
uint256 param2,
uint64 param3,
uint8 param4
) external view returns (address clone) {
bytes memory data = abi.encodePacked(param1, param2, param3, param4);
clone = address(implementation).addressOfClone2(data);
}
function createClone3(
address param1,
uint256 param2,
uint64 param3,
uint8 param4,
bytes32 salt
) external payable returns (ExampleClone clone) {
bytes memory data = abi.encodePacked(param1, param2, param3, param4);
clone = ExampleClone(
address(implementation).clone3(data, salt, msg.value)
);
}
function addressOfClone3(bytes32 salt) external view returns (address) {
return ClonesWithImmutableArgs.addressOfClone3(salt);
}
}