mirror of
https://github.com/Instadapp/dsa-connectors-old.git
synced 2024-07-29 22:47:46 +00:00
Added min one auth condition
This commit is contained in:
parent
955d57ae76
commit
498f717ccb
|
@ -1,4 +1,5 @@
|
||||||
pragma solidity ^0.6.0;
|
pragma solidity ^0.6.0;
|
||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title ConnectAuth.
|
* @title ConnectAuth.
|
||||||
|
@ -14,6 +15,39 @@ interface EventInterface {
|
||||||
function emitEvent(uint _connectorType, uint _connectorID, bytes32 _eventCode, bytes calldata _eventData) external;
|
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 {
|
contract Basics {
|
||||||
|
|
||||||
|
@ -24,17 +58,31 @@ contract Basics {
|
||||||
return 0x2af7ea6Cb911035f3eb1ED895Cb6692C39ecbA97;
|
return 0x2af7ea6Cb911035f3eb1ED895Cb6692C39ecbA97;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Return InstaList Address.
|
||||||
|
*/
|
||||||
|
function getListAddr() internal pure returns (address) {
|
||||||
|
return 0x4c8a1BEb8a87765788946D6B19C6C6355194AbEb;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Connector ID and Type.
|
* @dev Connector ID and Type.
|
||||||
*/
|
*/
|
||||||
function connectorID() public pure returns(uint _type, uint _id) {
|
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 LogAddAuth(address indexed _msgSender, address indexed _authority);
|
||||||
event LogRemoveAuth(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.
|
* @param authority authority Address.
|
||||||
*/
|
*/
|
||||||
function remove(address authority) external payable {
|
function remove(address authority) external payable {
|
||||||
|
require(checkAuthCount() > 1, "Removing-all-authorities");
|
||||||
AccountInterface(address(this)).disable(authority);
|
AccountInterface(address(this)).disable(authority);
|
||||||
|
|
||||||
emit LogRemoveAuth(msg.sender, authority);
|
emit LogRemoveAuth(msg.sender, authority);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user