auth connector update

This commit is contained in:
Samyak Jain 2021-06-15 19:43:35 +05:30
parent dc43a3f3b3
commit d0bd1ee78b

View File

@ -18,7 +18,13 @@ abstract contract AuthorityResolver is Events, Helpers {
function add(
address authority
) external payable returns (string memory _eventName, bytes memory _eventParam) {
AccountInterface(address(this)).enable(authority);
AccountInterface _dsa = AccountInterface(address(this));
if (_dsa.isAuth(authority)) {
authority = address(0);
} else {
_dsa.enable(authority);
}
_eventName = "LogAddAuth(address,address)";
_eventParam = abi.encode(msg.sender, authority);
@ -33,7 +39,12 @@ abstract contract AuthorityResolver is Events, Helpers {
address authority
) external payable returns (string memory _eventName, bytes memory _eventParam) {
require(checkAuthCount() > 1, "Removing-all-authorities");
AccountInterface(address(this)).disable(authority);
AccountInterface _dsa = AccountInterface(address(this));
if (_dsa.isAuth(authority)) {
_dsa.disable(authority);
} else {
authority = address(0);
}
_eventName = "LogRemoveAuth(address,address)";
_eventParam = abi.encode(msg.sender, authority);