// Contract: XenBatcher
// Target function: function proxyFor(bytes32 salt) internal view returns (address proxy)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

// mainnet
address constant XEN_ADDRESS = 0x06450dEe7FD2Fb8E39061434BAbCFC05599a6Fb8;

contract Batcher {
	// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1167.md
    address private immutable original;
	address private immutable deployer;
    bytes32 private immutable miniProxyByteCode;
	
	constructor() {
        original = address(this);
		deployer = msg.sender;

        bytes memory miniProxy = bytes.concat(
            bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),
            bytes20(address(this)),
            bytes15(0x5af43d82803e903d91602b57fd5bf3)
        );
        miniProxyByteCode = keccak256(abi.encodePacked(miniProxy));
	}

	function callback(address target, bytes memory data) external {
		require(msg.sender == original, "Only original can call this function");

        (bool success, bytes memory result) = target.call(data);
        // see https://yos.io/2022/07/16/bubbling-up-errors-in-solidity/
        if (!success) { // If call reverts
            // If there is return data, the call reverted without a reason or a custom error.
            if (result.length == 0) revert();
            assembly {
                // We use Yul's revert() to bubble up errors from the target contract.
                revert(add(32, result), mload(result))
            }
        }
	}