// Vulnerability label: FE1
{"Migrations.sol":{"content":"pragma solidity \u003e=0.4.21 \u003c0.6.0;\r\n\r\ncontract Migrations {\r\n  address public owner;\r\n  uint public last_completed_migration;\r\n\r\n  constructor() public {\r\n    owner = msg.sender;\r\n  }\r\n\r\n  modifier restricted() {\r\n    if (msg.sender == owner) _;\r\n  }\r\n\r\n  function setCompleted(uint completed) public restricted {\r\n    last_completed_migration = completed;\r\n  }\r\n\r\n  function upgrade(address new_address) public restricted {\r\n    Migrations upgraded = Migrations(new_address);\r\n    upgraded.setCompleted(last_completed_migration);\r\n  }\r\n}\r\n"},"OwnedUpgradeabilityProxy.sol":{"content":"pragma solidity \u003e=0.5.0;\r\n\r\nimport \u0027./UpgradeabilityProxy.sol\u0027;\r\n\r\n/**\r\n * @title OwnedUpgradeabilityProxy\r\n * @dev This contract combines an upgradeability proxy with basic authorization control functionalities\r\n */\r\ncontract OwnedUpgradeabilityProxy is UpgradeabilityProxy {\r\n  /**\r\n  * @dev Event to show ownership has been transferred\r\n  * @param previousOwner representing the address of the previous owner\r\n  * @param newOwner representing the address of the new owner\r\n  */\r\n  event ProxyOwnershipTransferred(address previousOwner, address newOwner);\r\n\r\n  // Storage position of the owner of the contract\r\n  bytes32 private constant proxyOwnerPosition = keccak256(\"org.zeppelinos.proxy.owner\");\r\n\r\n  /**\r\n  * @dev the constructor sets the original owner of the contract to the sender account.\r\n  */\r\n  constructor() public {\r\n    setUpgradeabilityOwner(msg.sender);\r\n  }\r\n\r\n  /**\r\n  * @dev Throws if called by any account other than the owner.\r\n  */\r\n  modifier onlyProxyOwner() {\r\n    require(msg.sender == proxyOwner());\r\n    _;\r\n  }\r\n\r\n  /**\r\n   * @dev Tells the address of the owner\r\n   * @return the address of the owner\r\n   */\r\n  function proxyOwner() public view returns (address owner) {\r\n    bytes32 position = proxyOwnerPosition;\r\n    assembly {\r\n      owner := sload(position)\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @dev Sets the address of the owner\r\n   */\r\n  function setUpgradeabilityOwner(address newProxyOwner) internal {\r\n    bytes32 position = proxyOwnerPosition;\r\n    assembly {\r\n      sstore(position, newProxyOwner)\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @dev Allows the current owner to transfer control of the contract to a newOwner.\r\n   * @param newOwner The address to transfer ownership to.\r\n   */\r\n  function transferProxyOwnership(address newOwner) public onlyProxyOwner {\r\n    require(newOwner != address(0));\r\n    emit ProxyOwnershipTransferred(proxyOwner(), newOwner);\r\n    setUpgradeabilityOwner(newOwner);\r\n  }\r\n\r\n  /**\r\n   * @dev Allows the proxy owner to upgrade the current version of the proxy.\r\n   * @param implementation representing the address of the new implementation to be set.\r\n   */\r\n  function upgradeTo(address implementation) public onlyProxyOwner {\r\n    _upgradeTo(implementation);\r\n  }\r\n\r\n  /**\r\n   * @dev Allows the proxy owner to upgrade the current version of the proxy and call the new implementation\r\n   * to initialize whatever is needed through a low level call.\r\n   * @param implementation representing the address of the new implementation to be set.\r\n   * @param data represents the msg.data to bet sent in the low level call. This parameter may include the function\r\n   * signature of the implementation to be called with the needed payload\r\n   */\r\n  function upgradeToAndCall(address implementation, bytes memory data) public payable onlyProxyOwner {\r\n    upgradeTo(implementation);\r\n    bool success;\r\n    bytes memory result;\r\n    (success, result) = address(this).call.value(msg.value)(data);\r\n    require(success);\r\n  }\r\n}\r\n"},"Proxy.sol":{"content":"pragma solidity \u003e=0.5.0;\r\n\r\n/**\r\n * @title Proxy\r\n * @dev Gives the possibility to delegate any call to a foreign implementation.\r\n */\r\ncontract Proxy {\r\n  /**\r\n  * @dev Tells the address of the implementation where every call will be delegated.\r\n  * @return address of the implementation to which it will be delegated\r\n  */\r\n  function implementation() public view returns (address);\r\n    event BalanceIncrease(uint amount);\r\n\r\n  /**\r\n  * @dev Fallback function allowing to perform a delegatecall to the given implementation.\r\n  * This function will return whatever the implementation call returns\r\n  */\r\n  function () payable external {\r\n    if (msg.value \u003e 0) {\r\n        emit BalanceIncrease(msg.value);\r\n        return;\r\n    }\r\n    address _impl = implementation();\r\n    require(_impl != address(0));\r\n\r\n    assembly {\r\n      let ptr := mload(0x40)\r\n      calldatacopy(ptr, 0, calldatasize)\r\n      let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0)\r\n      let size := returndatasize\r\n      returndatacopy(ptr, 0, size)\r\n\r\n      switch result\r\n      case 0 { revert(ptr, size) }\r\n      default { return(ptr, size) }\r\n    }\r\n  }\r\n}\r\n"},"UpgradeabilityProxy.sol":{"content":"pragma solidity \u003e=0.5.0 \u003c 0.6.0;\r\n\r\nimport \u0027./Proxy.sol\u0027;\r\n\r\n/**\r\n * @title UpgradeabilityProxy\r\n * @dev This contract represents a proxy where the implementation address to which it will delegate can be upgraded\r\n */\r\ncontract UpgradeabilityProxy is Proxy {\r\n  /**\r\n   * @dev This event will be emitted every time the implementation gets upgraded\r\n   * @param implementation representing the address of the upgraded implementation\r\n   */\r\n  event Upgraded(address indexed implementation);\r\n\r\n  // Storage position of the address of the current implementation\r\n  bytes32 private constant implementationPosition = keccak256(\"org.zeppelinos.proxy.implementation\");\r\n\r\n  /**\r\n   * @dev Constructor function\r\n   */\r\n  constructor() public {}\r\n\r\n  /**\r\n   * @dev Tells the address of the current implementation\r\n   * @return address of the current implementation\r\n   */\r\n  function implementation() public view returns (address impl) {\r\n    bytes32 position = implementationPosition;\r\n    assembly {\r\n      impl := sload(position)\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @dev Sets the address of the current implementation\r\n   * @param newImplementation address representing the new implementation to be set\r\n   */\r\n  function setImplementation(address newImplementation) internal {\r\n    bytes32 position = implementationPosition;\r\n    assembly {\r\n      sstore(position, newImplementation)\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @dev Upgrades the implementation address\r\n   * @param newImplementation representing the address of the new implementation to be set\r\n   */\r\n  function _upgradeTo(address newImplementation) internal {\r\n    address currentImplementation = implementation();\r\n    require(currentImplementation != newImplementation);\r\n    setImplementation(newImplementation);\r\n    emit Upgraded(newImplementation);\r\n  }\r\n}\r\n"}}