diff --git a/package.json b/package.json index e3ecf9f..3427144 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "react-scripts": "3.2.0", "redux": "^4.1.2", "redux-thunk": "^2.4.1", - "styled-components": "^5.3.3" + "styled-components": "^5.3.3", + "victory": "^36.3.2" }, "proxy": "http://localhost:42609", "scripts": { diff --git a/src/pages/tickets.js b/src/pages/tickets.js index 63231b1..6a40d77 100644 --- a/src/pages/tickets.js +++ b/src/pages/tickets.js @@ -5,6 +5,7 @@ import { useSelector, useDispatch } from 'react-redux'; import { Accordion } from '@mantine/core'; import ScrollContainer from 'react-indiana-drag-scroll'; import Address from '../components/OrchAddressViewer'; +import { VictoryPie } from 'victory'; const Tickets = (obj) => { const livepeer = useSelector((state) => state.livepeerstate); @@ -13,6 +14,43 @@ const Tickets = (obj) => { console.log("Rendering Winning Ticket Viewer"); + const getName = (address) => { + let hasThreeBox = false; + let thisDomain = null; + // Lookup domain in cache + if (livepeer.ensDomainMapping) { + for (const thisAddr of livepeer.ensDomainMapping) { + if (thisAddr.address === address) { + thisDomain = thisAddr; + break; + } + } + } + // Lookup current info in cache only if this addr has a mapped ENS domain + if (thisDomain && thisDomain.domain) { + for (const thisAddr of livepeer.ensInfoMapping) { + if (thisAddr.domain === thisDomain.domain) { + return thisAddr.domain; + } + } + } + + if (livepeer.threeBoxInfo) { + for (const thisAddr of livepeer.threeBoxInfo) { + if (thisAddr.address === address) { + if (thisAddr.name) { + return thisAddr.name; + } else { + return address; + } + break; + } + } + } + + return address; + } + useEffect(() => { // Process Winning tickets as: // List of Months containing @@ -28,7 +66,6 @@ const Tickets = (obj) => { const thisTime = new Date(thisTicket.transactionTime * 1000); const thisYear = thisTime.getFullYear(); const thisMonth = thisTime.getMonth(); - console.log(thisMonth); ticketIdx -= 1; // On a new month @@ -37,6 +74,7 @@ const Tickets = (obj) => { if (currentOrchCounter.length) { // Sort this months data let sortedList = [] + let currentSum = 0; while (currentOrchCounter.length) { let ticketIdx2 = currentOrchCounter.length - 1; let largestIdx = 0; @@ -50,6 +88,7 @@ const Tickets = (obj) => { } ticketIdx2 -= 1; } + currentSum += largestValue; // Push current biggest list sortedList.push(currentOrchCounter[largestIdx]); // Remove from list @@ -59,7 +98,8 @@ const Tickets = (obj) => { { year: currentYear, month: currentMonth, - orchestrators: sortedList + orchestrators: sortedList, + total: currentSum } ); } @@ -92,9 +132,12 @@ const Tickets = (obj) => { currentOrchCounter[thisIdx].sum += thisTicket.eventValue; } } + + if (currentOrchCounter.length) { // Sort this months data let sortedList = [] + let currentSum = 0; while (currentOrchCounter.length) { let ticketIdx2 = currentOrchCounter.length - 1; let largestIdx = 0; @@ -108,6 +151,7 @@ const Tickets = (obj) => { } ticketIdx2 -= 1; } + currentSum += largestValue; // Push current biggest list sortedList.push(currentOrchCounter[largestIdx]); // Remove from list @@ -117,11 +161,14 @@ const Tickets = (obj) => { { year: currentYear, month: currentMonth, - orchestrators: sortedList + orchestrators: sortedList, + total: currentSum } ); } + + setTicketsPerMonth(ticketsPerMonth); }, [livepeer.winningTickets]); @@ -151,16 +198,16 @@ const Tickets = (obj) => {