diff --git a/contracts/powerResolver/dsa.sol b/contracts/powerResolver/dsa.sol index c88d2e9..a1bccbd 100644 --- a/contracts/powerResolver/dsa.sol +++ b/contracts/powerResolver/dsa.sol @@ -6,12 +6,39 @@ interface ListInterface { function accountAddr(uint64) external view returns (address); } -contract Resolver { +interface AccountInterface { + function version() external view returns (uint64); +} + +contract InstaDSAPowerResolver { + + struct DSAs { + address dsa; + uint256 version; + } + function getTotalAccounts() public view returns(uint totalAccounts) { ListInterface list = ListInterface(0x4c8a1BEb8a87765788946D6B19C6C6355194AbEb); totalAccounts = uint(list.accounts()); } + function getDSAWalletsData(uint start, uint end) public view returns(DSAs[] memory wallets) { + assert(start < end); + ListInterface list = ListInterface(0x4c8a1BEb8a87765788946D6B19C6C6355194AbEb); + uint totalAccounts = uint(list.accounts()); + end = totalAccounts < end ? totalAccounts : end; + uint len = (end - start) + 1; + wallets = new DSAs[](len); + for (uint i = 0; i < len; i++) { + address dsa = list.accountAddr(uint64(start + i)); + wallets[i] = DSAs({ + dsa: dsa, + version: AccountInterface(dsa).version() + }); + } + return wallets; + } + function getDSAWallets(uint start, uint end) public view returns(address[] memory) { assert(start < end); ListInterface list = ListInterface(0x4c8a1BEb8a87765788946D6B19C6C6355194AbEb); @@ -24,4 +51,12 @@ contract Resolver { } return wallets; } -} + + function getDSAVersions(address[] memory dsas) public view returns(uint256[] memory versions) { + versions = new uint256[](dsas.length); + for (uint i = 0; i < dsas.length; i++) { + versions[i] = AccountInterface(dsas[i]).version(); + } + return versions; + } +} \ No newline at end of file