mirror of
https://github.com/Instadapp/dsa-resolvers-deprecated.git
synced 2024-07-29 22:38:16 +00:00
commit
42cf9278ab
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.sol linguist-language=Solidity
|
65
.gitignore
vendored
Normal file
65
.gitignore
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
lib-cov
|
||||
*.seed
|
||||
*.log
|
||||
*.csv
|
||||
*.dat
|
||||
*.out
|
||||
*.pid
|
||||
*.gz
|
||||
*.swp
|
||||
|
||||
pids
|
||||
logs
|
||||
results
|
||||
tmp
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
#Build
|
||||
coverage
|
||||
public/css/main.css
|
||||
.nyc_output/*
|
||||
|
||||
#Libraries from npm packages
|
||||
public/js/lib/bootstrap.min*
|
||||
public/js/lib/jquery.min*
|
||||
public/js/lib/popper.min*
|
||||
|
||||
# API keys and secrets
|
||||
.env
|
||||
|
||||
# Dependency directory
|
||||
node_modules
|
||||
bower_components
|
||||
|
||||
# Editors
|
||||
.idea
|
||||
.vscode
|
||||
*.iml
|
||||
modules.xml
|
||||
*.ipr
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# OS metadata
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# truffle
|
||||
build/contracts
|
||||
|
||||
# buidler
|
||||
artifacts
|
||||
cache
|
69
contracts/dsa/gnosis.sol
Normal file
69
contracts/dsa/gnosis.sol
Normal file
|
@ -0,0 +1,69 @@
|
|||
pragma solidity ^0.6.0;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
interface GnosisSafeProxy {
|
||||
function NAME() external view returns(string memory);
|
||||
function VERSION() external view returns(string memory);
|
||||
function nonce() external view returns(uint);
|
||||
function getThreshold() external view returns(uint);
|
||||
function getOwners() external view returns (address[] memory);
|
||||
}
|
||||
|
||||
interface GnosisFactoryInterface {
|
||||
function proxyRuntimeCode() external pure returns (bytes memory);
|
||||
}
|
||||
|
||||
|
||||
contract Helpers {
|
||||
GnosisFactoryInterface gnosisFactoryContract = GnosisFactoryInterface(0x76E2cFc1F5Fa8F6a5b3fC4c8F4788F0116861F9B);
|
||||
|
||||
struct MultiSigData {
|
||||
address[] owners;
|
||||
string version;
|
||||
uint nonce;
|
||||
uint threshold;
|
||||
}
|
||||
|
||||
|
||||
function getContractCode(address _addr) public view returns (bytes memory o_code) {
|
||||
assembly {
|
||||
// retrieve the size of the code, this needs assembly
|
||||
let size := extcodesize(_addr)
|
||||
// allocate output byte array - this could also be done without assembly
|
||||
// by using o_code = new bytes(size)
|
||||
o_code := mload(0x40)
|
||||
// new "memory end" including padding
|
||||
mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))
|
||||
// store length in memory
|
||||
mstore(o_code, size)
|
||||
// actually retrieve the code, this needs assembly
|
||||
extcodecopy(_addr, add(o_code, 0x20), 0, size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contract Resolver is Helpers{
|
||||
function getGnosisSafeDetails(address safeAddress) public view returns(MultiSigData memory) {
|
||||
GnosisSafeProxy safeContract = GnosisSafeProxy(safeAddress);
|
||||
return MultiSigData({
|
||||
owners: safeContract.getOwners(),
|
||||
version: safeContract.VERSION(),
|
||||
nonce: safeContract.nonce(),
|
||||
threshold: safeContract.getThreshold()
|
||||
});
|
||||
}
|
||||
|
||||
function getGnosisSafesDetails(address[] memory safeAddresses) public view returns(MultiSigData[] memory) {
|
||||
MultiSigData[] memory multiData = new MultiSigData[](safeAddresses.length);
|
||||
for (uint i = 0; i < safeAddresses.length; i++) {
|
||||
multiData[i] = getGnosisSafeDetails(safeAddresses[i]);
|
||||
}
|
||||
return multiData;
|
||||
}
|
||||
|
||||
function isSafeContract(address safeAddress) public view returns(bool) {
|
||||
bytes memory multiSigCode = gnosisFactoryContract.proxyRuntimeCode();
|
||||
bytes memory _contractCode = getContractCode(safeAddress);
|
||||
return keccak256(abi.encode(multiSigCode)) == keccak256(abi.encode(_contractCode));
|
||||
}
|
||||
}
|
|
@ -47,7 +47,6 @@ interface IndexInterface {
|
|||
function account(uint) external view returns (address);
|
||||
function check(uint) external view returns (address);
|
||||
function versionCount() external view returns (uint);
|
||||
|
||||
}
|
||||
|
||||
interface ConnectorsInterface {
|
||||
|
@ -74,6 +73,11 @@ interface ConnectorInterface {
|
|||
function name() external view returns (string memory);
|
||||
}
|
||||
|
||||
interface GnosisFactoryInterface {
|
||||
function proxyRuntimeCode() external pure returns (bytes memory);
|
||||
}
|
||||
|
||||
|
||||
contract Helpers {
|
||||
address public index;
|
||||
address public list;
|
||||
|
@ -81,6 +85,24 @@ contract Helpers {
|
|||
IndexInterface indexContract;
|
||||
ListInterface listContract;
|
||||
ConnectorsInterface connectorsContract;
|
||||
|
||||
GnosisFactoryInterface[] public gnosisFactoryContracts;
|
||||
|
||||
function getContractCode(address _addr) public view returns (bytes memory o_code) {
|
||||
assembly {
|
||||
// retrieve the size of the code, this needs assembly
|
||||
let size := extcodesize(_addr)
|
||||
// allocate output byte array - this could also be done without assembly
|
||||
// by using o_code = new bytes(size)
|
||||
o_code := mload(0x40)
|
||||
// new "memory end" including padding
|
||||
mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))
|
||||
// store length in memory
|
||||
mstore(o_code, size)
|
||||
// actually retrieve the code, this needs assembly
|
||||
extcodecopy(_addr, add(o_code, 0x20), 0, size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contract AccountResolver is Helpers {
|
||||
|
@ -183,6 +205,41 @@ contract AccountResolver is Helpers {
|
|||
function isShield(address account) public view returns(bool shield) {
|
||||
shield = AccountInterface(account).sheild();
|
||||
}
|
||||
|
||||
struct AuthType {
|
||||
address owner;
|
||||
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++) {
|
||||
bytes memory _contractCode = getContractCode(authorities[i]);
|
||||
bool isSafe;
|
||||
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 {
|
||||
types[i] = AuthType({
|
||||
owner: authorities[i],
|
||||
authType: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
function getAccountAuthoritiesTypes(address account) public view returns(AuthType[] memory) {
|
||||
return getAuthorityTypes(getAccountAuthorities(account));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -256,12 +313,17 @@ contract InstaDSAResolver is ConnectorsResolver {
|
|||
string public constant name = "DSA-Resolver-v1";
|
||||
uint public constant version = 1;
|
||||
|
||||
constructor(address _index) public{
|
||||
constructor(address _index, address[] memory _gnosisFactory) public{
|
||||
index = _index;
|
||||
indexContract = IndexInterface(index);
|
||||
list = indexContract.list();
|
||||
listContract = ListInterface(list);
|
||||
connectors = indexContract.connectors(version);
|
||||
connectorsContract = ConnectorsInterface(connectors);
|
||||
for (uint i = 0; i < _gnosisFactory.length; i++) {
|
||||
require(_gnosisFactory[i] != address(0), "address-not-vaild");
|
||||
GnosisFactoryInterface gnosisFactoryContract = GnosisFactoryInterface(_gnosisFactory[i]);
|
||||
gnosisFactoryContracts.push(gnosisFactoryContract);
|
||||
}
|
||||
}
|
||||
}
|
3060
package-lock.json
generated
Normal file
3060
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
package.json
Normal file
25
package.json
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "dsa-resolvers",
|
||||
"version": "1.0.0",
|
||||
"description": "The smart contracts which simplifies read operations.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/InstaDApp/dsa-resolvers.git"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/InstaDApp/dsa-resolvers/issues"
|
||||
},
|
||||
"homepage": "https://github.com/InstaDApp/dsa-resolvers#readme",
|
||||
"dependencies": {
|
||||
"solc": "^0.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"web3": "^1.2.9"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user