// SPDX-License-Identifier: LGPL-3.0-only pragma solidity ^0.6.0; /// @title Proxied - indicates that a contract will be proxied. Also defines storage requirements for Proxy. /// @author Alan Lu - contract Proxied { address public masterCopy; } /// @title Proxy - Generic proxy contract allows to execute all transactions applying the code of a master contract. /// @author Stefan George - contract Proxy is Proxied { /// @dev Constructor function sets address of master copy contract. /// @param _masterCopy Master copy address. constructor(address _masterCopy) public { require(_masterCopy != address(0), "The master copy is required"); masterCopy = _masterCopy; } /// @dev Fallback function forwards all transactions and returns all received return data. function _fallback() internal { address _masterCopy = masterCopy; assembly { calldatacopy(0, 0, calldatasize()) let success := delegatecall(not(0), _masterCopy, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch success case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev Fallback function that delegates calls to the masterCopy. * Runs when no other function in the contract matches the call data. */ fallback () external payable { _fallback(); } /** * @dev Fallback function that receives ether and delegates calls to masterCopy. * Runs when call data is empty. */ receive () external payable { _fallback(); } }