Added min one auth condition

This commit is contained in:
Thrilok Kumar 2020-08-10 17:53:23 +05:30
parent 955d57ae76
commit 498f717ccb

View File

@ -1,4 +1,5 @@
pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;
/**
* @title ConnectAuth.
@ -14,6 +15,39 @@ interface EventInterface {
function emitEvent(uint _connectorType, uint _connectorID, bytes32 _eventCode, bytes calldata _eventData) external;
}
interface ListInterface {
struct UserLink {
uint64 first;
uint64 last;
uint64 count;
}
struct UserList {
uint64 prev;
uint64 next;
}
struct AccountLink {
address first;
address last;
uint64 count;
}
struct AccountList {
address prev;
address next;
}
function accounts() external view returns (uint);
function accountID(address) external view returns (uint64);
function accountAddr(uint64) external view returns (address);
function userLink(address) external view returns (UserLink memory);
function userList(address, uint64) external view returns (UserList memory);
function accountLink(uint64) external view returns (AccountLink memory);
function accountList(uint64, address) external view returns (AccountList memory);
}
contract Basics {
@ -24,17 +58,31 @@ contract Basics {
return 0x2af7ea6Cb911035f3eb1ED895Cb6692C39ecbA97;
}
/**
* @dev Return InstaList Address.
*/
function getListAddr() internal pure returns (address) {
return 0x4c8a1BEb8a87765788946D6B19C6C6355194AbEb;
}
/**
* @dev Connector ID and Type.
*/
function connectorID() public pure returns(uint _type, uint _id) {
(_type, _id) = (1, 10);
(_type, _id) = (1, 37);
}
}
contract Helpers is Basics {
function checkAuthCount() internal view returns (uint count) {
ListInterface listContract = ListInterface(getListAddr());
uint64 accountId = listContract.accountID(address(this));
count = listContract.accountLink(accountId).count;
}
}
contract Auth is Basics {
contract Auth is Helpers {
event LogAddAuth(address indexed _msgSender, address indexed _authority);
event LogRemoveAuth(address indexed _msgSender, address indexed _authority);
@ -59,6 +107,7 @@ contract Auth is Basics {
* @param authority authority Address.
*/
function remove(address authority) external payable {
require(checkAuthCount() > 1, "Removing-all-authorities");
AccountInterface(address(this)).disable(authority);
emit LogRemoveAuth(msg.sender, authority);