eth-owned

EIP-173 interface and tools for chainlib-eth
git clone git://holbrook.no/eth-owned.git
Log | Files | Refs

VoidOwner.sol (864B)


      1 pragma solidity >=0.6.11;
      2 
      3 // SPDX-License-Identifier: GPL-3.0-or-later
      4 
      5 contract VoidOwner {
      6 
      7 	event OwnershipTaken(address _result);
      8 
      9 	// Implements OwnedTaker
     10 	function takeOwnership(address _contract) public returns (bool) {
     11 		bool ok;
     12 		bytes memory result;
     13 		address newOwner;
     14 
     15 		(ok, result) = _contract.call(abi.encodeWithSignature("acceptOwnership()"));
     16 		require(ok, "ERR_ACCEPT");
     17 
     18 		(ok, result) = _contract.call(abi.encodeWithSignature("owner()"));
     19 		require(ok, "ERR_INTERFACE");
     20 		newOwner = abi.decode(result, (address)); 
     21 		require(address(this) == newOwner);
     22 		
     23 		emit OwnershipTaken(_contract);
     24 		return ok;
     25 	}
     26 
     27 	// Implements EIP165
     28 	function supportsInterface(bytes4 _sum) public pure returns (bool) {
     29 		if (_sum == 0x6b578339) { // OwnedTaker
     30 			return true;
     31 		}
     32 		if (_sum == 0x01ffc9a7) { // EIP165
     33 			return true;
     34 		}
     35 		return false;
     36 	}
     37 }