// SPDX-License-Identifier: UNLICENSED pragma solidity =0.8.18; // //abi.encode( // implTemplateTypes[implementation].templateAddress, // address(this), // args //) library Deployer { function deploy(bytes memory bytecode) internal returns (address addr) { return deploy(bytecode, keccak256(abi.encodePacked(block.number, bytecode))); } function deploy(bytes memory bytecode, bytes32 salt) internal returns (address addr) { assembly { addr := create2( 0, // wei sent with current call // Actual code starts after skipping the first 32 bytes add(bytecode, 0x20), mload(bytecode), // Load the size of code contained in the first 32 bytes salt // Salt from function arguments ) if iszero(extcodesize(addr)) { revert(0, 0) } } } function predictAddress(address factory, bytes32 initCodeHash, bytes32 salt) internal pure returns (address addr) { bytes32 hash = keccak256(abi.encodePacked(bytes1(0xff), factory, salt, initCodeHash)); // NOTE: cast last 20 bytes of hash to address return address(uint160(uint256(hash))); } }