mirror of
				https://github.com/Instadapp/yield-contract.git
				synced 2024-07-29 21:47:29 +00:00 
			
		
		
		
	Updated flusher.sol to fallback function
This commit is contained in:
		
							parent
							
								
									6600facbfb
								
							
						
					
					
						commit
						2ed1eacc4d
					
				|  | @ -1,42 +1,35 @@ | |||
| // SPDX-License-Identifier: MIT | ||||
| 
 | ||||
| pragma solidity ^0.6.8; | ||||
| pragma experimental ABIEncoderV2; | ||||
| 
 | ||||
| interface DeployerInterface { | ||||
|   function signer(address) external view returns (bool);  | ||||
|   function isConnector(address[] calldata) external view returns (bool); | ||||
| } | ||||
| import "@openzeppelin/contracts/proxy/Proxy.sol"; | ||||
| 
 | ||||
| contract Flusher { | ||||
|   event LogCast(address indexed sender, uint value); | ||||
| contract Flusher is Proxy { | ||||
|     /** | ||||
|      * @dev Storage slot with the address of the current implementation. | ||||
|      * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1 | ||||
|      */ | ||||
|     bytes32 private constant _IMPLEMENTATION_SLOT = bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1); // 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc | ||||
| 
 | ||||
|   string constant public name = "Flusher-v1"; | ||||
| 
 | ||||
|   DeployerInterface public constant deployer = DeployerInterface(address(0)); // TODO - Change while deploying | ||||
| 
 | ||||
|   function spell(address _target, bytes memory _data) internal { | ||||
|     require(_target != address(0), "target-invalid"); | ||||
|     assembly { | ||||
|       let succeeded := delegatecall(gas(), _target, add(_data, 0x20), mload(_data), 0, 0) | ||||
|       switch iszero(succeeded) | ||||
|         case 1 { | ||||
|             let size := returndatasize() | ||||
|             returndatacopy(0x00, 0x00, size) | ||||
|             revert(0x00, size) | ||||
|     /** | ||||
|      * @dev Returns the current implementation address. | ||||
|      */ | ||||
|     function _implementation() internal override view returns (address impl) { | ||||
|         bytes32 slot = _IMPLEMENTATION_SLOT; | ||||
|         // solhint-disable-next-line no-inline-assembly | ||||
|         assembly { | ||||
|             impl := sload(slot) | ||||
|         } | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   function cast(address[] calldata _targets, bytes[] calldata _datas) external payable { | ||||
|     require(deployer.signer(msg.sender), "not-signer"); | ||||
|     require(_targets.length == _datas.length , "invalid-array-length"); | ||||
|     require(deployer.isConnector(_targets), "not-connector"); | ||||
|     for (uint i = 0; i < _targets.length; i++) { | ||||
|         spell(_targets[i], _datas[i]); | ||||
|     function setBasic(address newImplementation) public { | ||||
|         require(_implementation() == address(0), "_implementation-logic-already-set"); | ||||
|         require(newImplementation == address(0), "newImplementation-not-vaild"); | ||||
|         bytes32 slot = _IMPLEMENTATION_SLOT; | ||||
| 
 | ||||
|         // solhint-disable-next-line no-inline-assembly | ||||
|         assembly { | ||||
|             sstore(slot, newImplementation) | ||||
|         } | ||||
|     } | ||||
|     emit LogCast(msg.sender, msg.value); | ||||
|   } | ||||
| 
 | ||||
|   receive() external payable {} | ||||
| } | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Thrilok Kumar
						Thrilok Kumar