From 4b00d4c5b9ca4527e4e8e2ac847d19f5bc4dfbc4 Mon Sep 17 00:00:00 2001 From: Lisandro Corbalan Date: Mon, 6 Apr 2020 12:29:23 -0300 Subject: [PATCH 1/3] Fix subgraph address --- netlify.toml | 4 ++-- src/components/PollDetails/data.ts | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/netlify.toml b/netlify.toml index e3d3006..92da4c0 100644 --- a/netlify.toml +++ b/netlify.toml @@ -8,8 +8,8 @@ status = 200 [context.production.environment] - REACT_APP_GRAPH_HTTP = "https://api.thegraph.com/subgraphs/name/protofire/makerdao-governance-v1_5" - REACT_APP_GRAPH_WS = "wss://api.thegraph.com/subgraphs/name/protofire/makerdao-governance-v1_5" + REACT_APP_GRAPH_HTTP = "https://api.thegraph.com/subgraphs/name/protofire/makerdao-governance" + REACT_APP_GRAPH_WS = "wss://api.thegraph.com/subgraphs/name/protofire/makerdao-governance" REACT_APP_MKR_GRAPH_HTTP='https://api.thegraph.com/subgraphs/name/protofire/mkr-registry' REACT_APP_ETHERSCAN_API_KEY='XQ2QTEM7H4KX7AQTE9JWXD3HWTTZ46TTU9' diff --git a/src/components/PollDetails/data.ts b/src/components/PollDetails/data.ts index 94e80e1..77cac79 100644 --- a/src/components/PollDetails/data.ts +++ b/src/components/PollDetails/data.ts @@ -143,6 +143,11 @@ export const getPollDataWithoutBalances = async poll => { {}, ) + console.log( + 'mkrVoter', + Object.keys(mkrVoter).map(e => [e, mkrVoter[e].toString()]), + ) + const votersPerOption = getPollVotersPerOption(poll) const mkrOptions = Object.keys(votersPerOption).reduce((acc, op) => { const voters = votersPerOption[op] From 27aad92db86807dd623b70131628939d4e346b17 Mon Sep 17 00:00:00 2001 From: Lisandro Corbalan Date: Mon, 6 Apr 2020 12:32:00 -0300 Subject: [PATCH 2/3] Remove log --- src/components/PollDetails/data.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/PollDetails/data.ts b/src/components/PollDetails/data.ts index 77cac79..94e80e1 100644 --- a/src/components/PollDetails/data.ts +++ b/src/components/PollDetails/data.ts @@ -143,11 +143,6 @@ export const getPollDataWithoutBalances = async poll => { {}, ) - console.log( - 'mkrVoter', - Object.keys(mkrVoter).map(e => [e, mkrVoter[e].toString()]), - ) - const votersPerOption = getPollVotersPerOption(poll) const mkrOptions = Object.keys(votersPerOption).reduce((acc, op) => { const voters = votersPerOption[op] From d7456ba68bf67e62536e59a63fa4f736f6813658 Mon Sep 17 00:00:00 2001 From: Lisandro Corbalan Date: Tue, 7 Apr 2020 09:08:23 -0300 Subject: [PATCH 3/3] Remove duplicated ProxyRegistries so we don't count twice the same staked mkr when cold and hot are the same address --- src/components/PollDetails/data.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/PollDetails/data.ts b/src/components/PollDetails/data.ts index 94e80e1..a78f52b 100644 --- a/src/components/PollDetails/data.ts +++ b/src/components/PollDetails/data.ts @@ -47,7 +47,10 @@ export const getVoterRegistries = async (addresses, endDate) => { endDate, }) - return [...result.cold, ...result.hot] + // When cold and hot are the same the registry cames twice, so we keep only one of them + const registriesById = new Map([...result.cold, ...result.hot].map(reg => [reg.id, reg])) + + return Array.from(registriesById.values()) } export const getVoterAddresses = poll => { @@ -257,7 +260,7 @@ export const totalStaked = (poll, lookup, balances, stakedProxies) => { if (!addedColHotByVoter[voter]) { const hotBalance = balances[hot] || ZERO - const coldBalance = balances[cold] || ZERO + const coldBalance = hot !== cold ? balances[cold] || ZERO : ZERO addedColHotByVoter[voter] = true return acc.plus(proxyAmount.plus(hotBalance).plus(coldBalance))