You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
970 B
33 lines
970 B
4 years ago
|
// SPDX-License-Identifier: MIT
|
||
|
|
||
4 years ago
|
pragma solidity >=0.6.0 <0.9.0;
|
||
4 years ago
|
|
||
|
import "../proxy/Clones.sol";
|
||
|
import "../utils/Address.sol";
|
||
|
|
||
|
contract ClonesMock {
|
||
|
using Address for address;
|
||
|
using Clones for address;
|
||
|
|
||
|
event NewInstance(address instance);
|
||
|
|
||
|
function clone(address master, bytes calldata initdata) public payable {
|
||
|
_initAndEmit(master.clone(), initdata);
|
||
|
}
|
||
|
|
||
|
function cloneDeterministic(address master, bytes32 salt, bytes calldata initdata) public payable {
|
||
|
_initAndEmit(master.cloneDeterministic(salt), initdata);
|
||
|
}
|
||
|
|
||
|
function predictDeterministicAddress(address master, bytes32 salt) public view returns (address predicted) {
|
||
|
return master.predictDeterministicAddress(salt);
|
||
|
}
|
||
|
|
||
|
function _initAndEmit(address instance, bytes memory initdata) private {
|
||
|
if (initdata.length > 0) {
|
||
|
instance.functionCallWithValue(initdata, msg.value);
|
||
|
}
|
||
|
emit NewInstance(instance);
|
||
|
}
|
||
|
}
|