Added gnosis support

This commit is contained in:
Thrilok Kumar 2020-08-27 11:01:30 +05:30
parent c0c4e38372
commit 53d95eec26

View File

@ -86,7 +86,7 @@ contract Helpers {
ListInterface listContract; ListInterface listContract;
ConnectorsInterface connectorsContract; ConnectorsInterface connectorsContract;
GnosisFactoryInterface gnosisFactoryContract; GnosisFactoryInterface[] public gnosisFactoryContracts;
function getContractCode(address _addr) public view returns (bytes memory o_code) { function getContractCode(address _addr) public view returns (bytes memory o_code) {
assembly { assembly {
@ -205,22 +205,39 @@ contract AccountResolver is Helpers {
function isShield(address account) public view returns(bool shield) { function isShield(address account) public view returns(bool shield) {
shield = AccountInterface(account).sheild(); shield = AccountInterface(account).sheild();
} }
function getAuthorityTypes(address[] memory authorities) public view returns(uint[] memory) { struct AuthType {
bytes memory multiSigCode = gnosisFactoryContract.proxyRuntimeCode(); address owner;
uint[] memory types = new uint[](authorities.length); uint authType;
}
function getAuthorityTypes(address[] memory authorities) public view returns(AuthType[] memory) {
AuthType[] memory types = new AuthType[](authorities.length);
for (uint i = 0; i < authorities.length; i++) { for (uint i = 0; i < authorities.length; i++) {
bytes memory _contractCode = getContractCode(authorities[i]); bytes memory _contractCode = getContractCode(authorities[i]);
if(keccak256(abi.encode(multiSigCode)) == keccak256(abi.encode(_contractCode))) { bool isSafe;
types[i] = 1; for (uint k = 0; k < gnosisFactoryContracts.length; k++) {
bytes memory multiSigCode = gnosisFactoryContracts[k].proxyRuntimeCode();
if(keccak256(abi.encode(multiSigCode)) == keccak256(abi.encode(_contractCode))) {
isSafe = true;
}
}
if (isSafe) {
types[i] = AuthType({
owner: authorities[i],
authType: 1
});
} else { } else {
types[i] = 0; types[i] = AuthType({
owner: authorities[i],
authType: 0
});
} }
} }
return types; return types;
} }
function getAccountAuthoritiesTypes(address account) public view returns(uint[] memory) { function getAccountAuthoritiesTypes(address account) public view returns(AuthType[] memory) {
return getAuthorityTypes(getAccountAuthorities(account)); return getAuthorityTypes(getAccountAuthorities(account));
} }
} }
@ -296,13 +313,17 @@ contract InstaDSAResolver is ConnectorsResolver {
string public constant name = "DSA-Resolver-v1"; string public constant name = "DSA-Resolver-v1";
uint public constant version = 1; uint public constant version = 1;
constructor(address _index, address gnosisFactory) public{ constructor(address _index, address[] memory _gnosisFactory) public{
index = _index; index = _index;
indexContract = IndexInterface(index); indexContract = IndexInterface(index);
list = indexContract.list(); list = indexContract.list();
listContract = ListInterface(list); listContract = ListInterface(list);
connectors = indexContract.connectors(version); connectors = indexContract.connectors(version);
connectorsContract = ConnectorsInterface(connectors); connectorsContract = ConnectorsInterface(connectors);
gnosisFactoryContract = GnosisFactoryInterface(gnosisFactory); for (uint i = 0; i < _gnosisFactory.length; i++) {
require(_gnosisFactory[i] != address(0), "address-not-vaild");
GnosisFactoryInterface gnosisFactoryContract = GnosisFactoryInterface(_gnosisFactory[i]);
gnosisFactoryContracts.push(gnosisFactoryContract);
}
} }
} }