This repository has been archived by the owner on Dec 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
83 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,56 @@ | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// SPDX-License-Identifier: GNU-3 | ||
pragma solidity >=0.4.23; | ||
|
||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
pragma solidity ^0.4.13; | ||
|
||
contract DSAuthority { | ||
function canCall( | ||
address src, address dst, bytes4 sig | ||
) public view returns (bool); | ||
interface DSAuthority { | ||
function canCall( | ||
address src, address dst, bytes4 sig | ||
) external view returns (bool); | ||
} | ||
|
||
contract DSAuthEvents { | ||
event LogSetAuthority (address indexed authority); | ||
event LogSetOwner (address indexed owner); | ||
event LogSetAuthority (address indexed authority); | ||
event LogSetOwner (address indexed owner); | ||
} | ||
|
||
contract DSAuth is DSAuthEvents { | ||
DSAuthority public authority; | ||
address public owner; | ||
DSAuthority public authority; | ||
address public owner; | ||
|
||
function DSAuth() public { | ||
owner = msg.sender; | ||
LogSetOwner(msg.sender); | ||
} | ||
constructor() { | ||
owner = msg.sender; | ||
emit LogSetOwner(msg.sender); | ||
} | ||
|
||
function setOwner(address owner_) | ||
public | ||
auth | ||
{ | ||
owner = owner_; | ||
LogSetOwner(owner); | ||
} | ||
function setOwner(address owner_) | ||
public | ||
auth | ||
{ | ||
owner = owner_; | ||
emit LogSetOwner(owner); | ||
} | ||
|
||
function setAuthority(DSAuthority authority_) | ||
public | ||
auth | ||
{ | ||
authority = authority_; | ||
LogSetAuthority(authority); | ||
} | ||
function setAuthority(DSAuthority authority_) | ||
public | ||
auth | ||
{ | ||
authority = authority_; | ||
emit LogSetAuthority(address(authority)); | ||
} | ||
|
||
modifier auth { | ||
require(isAuthorized(msg.sender, msg.sig)); | ||
_; | ||
} | ||
modifier auth { | ||
require(isAuthorized(msg.sender, msg.sig), "ds-auth-unauthorized"); | ||
_; | ||
} | ||
|
||
function isAuthorized(address src, bytes4 sig) internal view returns (bool) { | ||
if (src == address(this)) { | ||
return true; | ||
} else if (src == owner) { | ||
return true; | ||
} else if (authority == DSAuthority(0)) { | ||
return false; | ||
} else { | ||
return authority.canCall(src, this, sig); | ||
function isAuthorized(address src, bytes4 sig) internal view returns (bool) { | ||
if (src == address(this)) { | ||
return true; | ||
} else if (src == owner) { | ||
return true; | ||
} else if (authority == DSAuthority(address(0))) { | ||
return false; | ||
} else { | ||
return authority.canCall(src, address(this), sig); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters