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.
36 lines
1.0 KiB
36 lines
1.0 KiB
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
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 implementation, bytes calldata initdata) public payable {
|
|
_initAndEmit(implementation.clone(), initdata);
|
|
}
|
|
|
|
function cloneDeterministic(
|
|
address implementation,
|
|
bytes32 salt,
|
|
bytes calldata initdata
|
|
) public payable {
|
|
_initAndEmit(implementation.cloneDeterministic(salt), initdata);
|
|
}
|
|
|
|
function predictDeterministicAddress(address implementation, bytes32 salt) public view returns (address predicted) {
|
|
return implementation.predictDeterministicAddress(salt);
|
|
}
|
|
|
|
function _initAndEmit(address instance, bytes memory initdata) private {
|
|
if (initdata.length > 0) {
|
|
instance.functionCallWithValue(initdata, msg.value);
|
|
}
|
|
emit NewInstance(instance);
|
|
}
|
|
}
|
|
|