add getUserData, fix Governance fetcher

This commit is contained in:
Roman Storm 2020-10-16 23:00:46 -07:00
parent 91dcea570c
commit ab77f2f8a0
No known key found for this signature in database
GPG Key ID: 522F2A785F34E71F
5 changed files with 30 additions and 35 deletions

View File

@ -1,19 +0,0 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
interface ENS {
function resolver(bytes32 node) external view returns (Resolver);
}
interface Resolver {
function addr(bytes32 node) external view returns (address);
}
contract EnsResolve {
ENS public constant Registry = ENS(0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e);
function resolve(bytes32 node) public view returns (address) {
return Registry.resolver(node).addr(node);
}
}

View File

@ -7,7 +7,6 @@ import "tornado-governance/contracts/Governance.sol";
contract GovernanceAggregator {
struct Proposal {
uint256 id;
address proposer;
address target;
uint256 startTime;
@ -30,7 +29,6 @@ contract GovernanceAggregator {
for (from; from < to; from++) {
(
uint256 id,
address proposer,
address target,
uint256 startTime,
@ -39,10 +37,9 @@ contract GovernanceAggregator {
uint256 againstVotes,
bool executed,
bool extended
) = governance.proposals(from + 1);
) = governance.proposals(from);
proposals[from] = Proposal({
id: id,
proposer: proposer,
target: target,
startTime: startTime,
@ -51,7 +48,7 @@ contract GovernanceAggregator {
againstVotes: againstVotes,
executed: executed,
extended: extended,
state: governance.state(id)
state: governance.state(from)
});
}
}
@ -59,7 +56,24 @@ contract GovernanceAggregator {
function getGovernanceBalances(Governance governance, address[] calldata accs) public view returns (uint256[] memory amounts) {
amounts = new uint256[](accs.length);
for (uint256 i = 0; i < accs.length; i++) {
amounts[i] = governance.balances(accs[i]);
amounts[i] = governance.lockedBalance(accs[i]);
}
}
function getUserData(Governance governance, address account)
public
view
returns (
uint256 balance,
uint256 latestProposalId,
uint256 timelock,
address delegatee
)
{
// Core core = Core(address(governance));
balance = governance.lockedBalance(account);
latestProposalId = governance.latestProposalIds(account);
timelock = governance.canWithdrawAfter(account);
delegatee = governance.delegatedTo(account);
}
}

View File

@ -2,7 +2,7 @@
pragma solidity 0.6.12;
import "./ENS.sol";
import "torn-token/contracts/ENS.sol";
interface OneSplit {
function getExpectedReturn(

View File

@ -46,7 +46,7 @@
},
"dependencies": {
"tornado-anonymity-mining": "git+https://github.com/tornadocash/tornado-anonymity-mining.git#1e1a85192be4881b51f77ae1bf3a8194a09a0605",
"torn-token": "git+https://github.com/tornadocash/torn-token.git#da424e05749ed06dc61a6a37587e7b35e42bc438",
"tornado-governance": "git+https://github.com/tornadocash/governance.git#f27663c39f5e5bf23455ffd44accf3ea42186372"
"tornado-governance": "git+https://github.com/tornadocash/governance.git#4c37f7b306d58eadfdc5e000f3bee56b3727a1b2",
"torn-token": "git+https://github.com/tornadocash/torn-token.git#dd6f782486a86653e60824da51d3b77d194398a5"
}
}

View File

@ -4567,9 +4567,9 @@ toidentifier@1.0.0:
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553"
integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
"torn-token@git+https://github.com/tornadocash/torn-token.git#971b4cfc5dd7e2a3d1da8e42aa2dac29730ecf35":
"torn-token@git+https://github.com/tornadocash/torn-token.git#a388d4f79e1a323f5bd04baf72d3b58298a0fb5f":
version "1.0.0"
resolved "git+https://github.com/tornadocash/torn-token.git#971b4cfc5dd7e2a3d1da8e42aa2dac29730ecf35"
resolved "git+https://github.com/tornadocash/torn-token.git#a388d4f79e1a323f5bd04baf72d3b58298a0fb5f"
dependencies:
"@openzeppelin/contracts" "^3.1.0"
dotenv "^8.2.0"
@ -4577,9 +4577,9 @@ toidentifier@1.0.0:
ethereumjs-util "^7.0.3"
web3 "^1.2.11"
"torn-token@git+https://github.com/tornadocash/torn-token.git#da424e05749ed06dc61a6a37587e7b35e42bc438":
"torn-token@git+https://github.com/tornadocash/torn-token.git#dd6f782486a86653e60824da51d3b77d194398a5":
version "1.0.0"
resolved "git+https://github.com/tornadocash/torn-token.git#da424e05749ed06dc61a6a37587e7b35e42bc438"
resolved "git+https://github.com/tornadocash/torn-token.git#dd6f782486a86653e60824da51d3b77d194398a5"
dependencies:
"@openzeppelin/contracts" "^3.1.0"
dotenv "^8.2.0"
@ -4599,13 +4599,13 @@ toidentifier@1.0.0:
web3 "^1.2.11"
websnark "git+https://github.com/tornadocash/websnark.git#86a526718cd6f6f5d31bdb1fe26a9ec8819f633e"
"tornado-governance@git+https://github.com/tornadocash/governance.git#f27663c39f5e5bf23455ffd44accf3ea42186372":
"tornado-governance@git+https://github.com/tornadocash/governance.git#4c37f7b306d58eadfdc5e000f3bee56b3727a1b2":
version "1.0.0"
resolved "git+https://github.com/tornadocash/governance.git#f27663c39f5e5bf23455ffd44accf3ea42186372"
resolved "git+https://github.com/tornadocash/governance.git#4c37f7b306d58eadfdc5e000f3bee56b3727a1b2"
dependencies:
"@openzeppelin/contracts" "^3.2.0-rc.0"
"@openzeppelin/upgrades-core" "^1.0.1"
torn-token "git+https://github.com/tornadocash/torn-token.git#971b4cfc5dd7e2a3d1da8e42aa2dac29730ecf35"
torn-token "git+https://github.com/tornadocash/torn-token.git#a388d4f79e1a323f5bd04baf72d3b58298a0fb5f"
tough-cookie@~2.5.0:
version "2.5.0"