Guest User

Untitled

a guest
Feb 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. pragma solidity 0.5;
  2.  
  3.  
  4. /// @title Proxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
  5. /// @author Stefan George - <stefan@gnosis.pm>
  6. contract Proxy {
  7.  
  8. // masterCopy always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
  9. address masterCopy;
  10.  
  11. /// @dev Constructor function sets address of master copy contract.
  12. /// @param _masterCopy Master copy address.
  13. constructor(address _masterCopy)
  14. public
  15. {
  16. require(_masterCopy != address(0), "Invalid master copy address provided");
  17. masterCopy = _masterCopy;
  18. }
  19.  
  20. /// @dev Fallback function forwards all transactions and returns all received return data.
  21. function ()
  22. external
  23. payable
  24. {
  25. // solium-disable-next-line security/no-inline-assembly
  26. assembly {
  27. let masterCopy := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
  28. calldatacopy(0, 0, calldatasize())
  29. let success := delegatecall(gas, masterCopy, 0, calldatasize(), 0, 0)
  30. returndatacopy(0, 0, returndatasize())
  31. if eq(success, 0) { revert(0, returndatasize()) }
  32. return(0, returndatasize())
  33. }
  34. }
  35.  
  36. function implementation()
  37. public
  38. view
  39. returns (address)
  40. {
  41. return masterCopy;
  42. }
  43.  
  44. function proxyType()
  45. public
  46. pure
  47. returns (uint256)
  48. {
  49. return 2;
  50. }
  51. }
Add Comment
Please, Sign In to add comment