mirror of
https://github.com/stronk-dev/LivepeerEvents.git
synced 2025-07-05 02:35:09 +02:00
Remove 3box
This commit is contained in:
parent
46ced21124
commit
6ebc31f5c0
@ -2489,71 +2489,6 @@ apiRouter.get("/getEnsInfo", async (req, res) => {
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|
||||
3BOX DATA
|
||||
Only stored in local cache
|
||||
|
||||
*/
|
||||
|
||||
let threeboxCache = [];
|
||||
|
||||
const getThreeBoxInfo = async function (addr) {
|
||||
console.log("Getting 3box data for " + addr);
|
||||
const now = new Date().getTime();
|
||||
// See if it is cached
|
||||
for (const thisAddr of threeboxCache) {
|
||||
if (thisAddr.address === addr) {
|
||||
return thisAddr;
|
||||
}
|
||||
}
|
||||
// Else get it and cache it
|
||||
const url = "https://explorer.livepeer.org/api/3box?account=" + addr;
|
||||
await https.get(url, (res) => {
|
||||
let body = "";
|
||||
res.on("data", (chunk) => {
|
||||
body += chunk;
|
||||
});
|
||||
res.on("end", () => {
|
||||
try {
|
||||
const data = JSON.parse(body);
|
||||
const threeBoxObj = {
|
||||
address: data.id,
|
||||
name: data.name,
|
||||
website: data.website,
|
||||
description: data.description,
|
||||
image: data.image,
|
||||
timestamp: now
|
||||
}
|
||||
console.log("Caching new 3box info " + threeBoxObj.address + " @ " + threeBoxObj.timestamp);
|
||||
threeboxCache.push(threeBoxObj);
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
};
|
||||
});
|
||||
}).on("error", (error) => {
|
||||
console.error(error.message);
|
||||
});
|
||||
}
|
||||
// Gets and caches info for a single address
|
||||
apiRouter.get("/getThreeBox/:orch", async (req, res) => {
|
||||
try {
|
||||
// First resolve addr => domain name
|
||||
const threeBoxInfo = await getThreeBoxInfo(req.params.orch);
|
||||
res.send(threeBoxInfo);
|
||||
} catch (err) {
|
||||
res.status(400).send(err);
|
||||
}
|
||||
});
|
||||
// Returns entire 3box info mapping cache
|
||||
apiRouter.get("/getAllThreeBox", async (req, res) => {
|
||||
try {
|
||||
res.send(threeboxCache);
|
||||
} catch (err) {
|
||||
res.status(400).send(err);
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
LEADERBOARD TEST SCORES
|
||||
|
@ -12,7 +12,6 @@ export const RECEIVE_TICKETS = "RECEIVE_TICKETS";
|
||||
export const RECEIVE_WINNING_TICKETS = "RECEIVE_WINNING_TICKETS";
|
||||
export const SET_ALL_ENS_INFO = "SET_ALL_ENS_INFO";
|
||||
export const SET_ALL_ENS_DOMAINS = "SET_ALL_ENS_DOMAINS";
|
||||
export const SET_ALL_THREEBOX_INFO = "SET_ALL_THREEBOX_INFO";
|
||||
export const SET_ALL_ORCH_SCORES = "SET_ALL_ORCH_SCORES";
|
||||
export const SET_ALL_ORCH_INFO = "SET_ALL_ORCH_INFO";
|
||||
export const SET_ALL_DEL_INFO = "SET_ALL_DEL_INFO";
|
||||
@ -63,9 +62,6 @@ const setAllEnsInfo = message => ({
|
||||
const setAllEnsDomains = message => ({
|
||||
type: SET_ALL_ENS_DOMAINS, message
|
||||
});
|
||||
const setAllThreeBoxInfo = message => ({
|
||||
type: SET_ALL_THREEBOX_INFO, message
|
||||
});
|
||||
const setAllOrchScores = message => ({
|
||||
type: SET_ALL_ORCH_SCORES, message
|
||||
});
|
||||
@ -209,20 +205,6 @@ export const getEnsInfo = async (addr) => {
|
||||
const response = apiUtil.getEnsInfo(addr);
|
||||
};
|
||||
|
||||
|
||||
export const getAllThreeBoxInfo = () => async dispatch => {
|
||||
const response = await apiUtil.getAllThreeBox();
|
||||
const data = await response.json();
|
||||
if (response.ok) {
|
||||
return dispatch(setAllThreeBoxInfo(data));
|
||||
}
|
||||
return dispatch(receiveErrors(data));
|
||||
};
|
||||
|
||||
export const getThreeBoxInfo = async (addr) => {
|
||||
const response = apiUtil.getThreeBox(addr);
|
||||
};
|
||||
|
||||
export const getOrchestratorScores = async (year, month) => {
|
||||
const response = await apiUtil.getOrchestratorScores(year, month);
|
||||
const data = await response.json();
|
||||
|
@ -32,22 +32,6 @@ const MonthlyGraphs = (obj) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (livepeer.threeBoxInfo) {
|
||||
for (const thisAddr of livepeer.threeBoxInfo) {
|
||||
if (thisAddr.address === address) {
|
||||
if (thisAddr.name) {
|
||||
if (thisAddr.name.length > 18) {
|
||||
return (thisAddr.name.substring(0, 16) + "..");
|
||||
}
|
||||
return thisAddr.name;
|
||||
} else {
|
||||
return (address.substring(0, 16) + "..");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (address.substring(0, 16) + "..");
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ const Address = (obj) => {
|
||||
const livepeer = useSelector((state) => state.livepeerstate);
|
||||
const [hasRefreshed, setRefresh] = useState(false);
|
||||
let hasENS = false;
|
||||
let hasThreeBox = false;
|
||||
let thisDomain = null;
|
||||
let thisInfo = null;
|
||||
const now = new Date().getTime();
|
||||
@ -58,19 +57,6 @@ const Address = (obj) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Ugly shit, but temporary for now to quickly enable threebox. Sorry!
|
||||
if (!hasENS) {
|
||||
if (livepeer.threeBoxInfo) {
|
||||
for (const thisAddr of livepeer.threeBoxInfo) {
|
||||
if (thisAddr.address === obj.address) {
|
||||
thisInfo = thisAddr;
|
||||
hasThreeBox = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let thisName;
|
||||
let thisIcon;
|
||||
if (hasENS) {
|
||||
@ -86,20 +72,6 @@ const Address = (obj) => {
|
||||
<img alt="" src="ens.png" width="20em" height="20em" style={{ margin: '0.2em', padding: '0.2em' }} />
|
||||
</a >
|
||||
}
|
||||
} else if (hasThreeBox) {
|
||||
if (thisInfo.name) {
|
||||
thisName = <h4 className="elipsText elipsOnMobileExtra">{thisInfo.name}</h4>;
|
||||
} else {
|
||||
thisName = <span className="elipsText elipsOnMobileExtra">{obj.address}</span>;
|
||||
}
|
||||
if (thisInfo.image) {
|
||||
thisIcon =
|
||||
<a className="selectOrch" style={{ marginRight: '0.5em', cursor: 'grab' }} disabled>
|
||||
<img alt="" src={"https://cloudflare-ipfs.com/ipfs/" + thisInfo.image} width="20em" height="20em" style={{ margin: 0, padding: 0 }} />
|
||||
</a >
|
||||
} else {
|
||||
thisIcon = null;
|
||||
}
|
||||
} else {
|
||||
thisName = obj.address;
|
||||
thisIcon = null;
|
||||
|
@ -31,7 +31,6 @@ const OrchInfoViewer = (obj) => {
|
||||
const [opened, setOpened] = useState(false);
|
||||
const livepeer = useSelector((state) => state.livepeerstate);
|
||||
let hasENS = false;
|
||||
let hasThreeBox = false;
|
||||
let rewardCut = 0;
|
||||
let feeCut = 0;
|
||||
let totalStake = 0;
|
||||
@ -98,19 +97,6 @@ const OrchInfoViewer = (obj) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Ugly shit, but temporary for now to quickly enable threebox. Sorry!
|
||||
if (!hasENS) {
|
||||
if (livepeer.threeBoxInfo) {
|
||||
for (const thisAddr of livepeer.threeBoxInfo) {
|
||||
if (thisAddr.address === thisID) {
|
||||
thisInfo = thisAddr;
|
||||
hasThreeBox = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let ensDescription;
|
||||
let ensUrl;
|
||||
if (hasENS) {
|
||||
@ -130,23 +116,6 @@ const OrchInfoViewer = (obj) => {
|
||||
</a >
|
||||
</div>
|
||||
}
|
||||
} else if (hasThreeBox) {
|
||||
if (thisInfo.description) {
|
||||
ensDescription = thisInfo.description;
|
||||
}
|
||||
if (thisInfo.website) {
|
||||
if (!thisInfo.website.startsWith('http')) {
|
||||
thisInfo.website = "https://" + thisInfo.website;
|
||||
}
|
||||
ensUrl =
|
||||
<div className="stroke">
|
||||
<a className="selectOrchLight" style={{ cursor: 'alias' }} target="_blank" rel="noopener noreferrer" href={thisInfo.website} >
|
||||
<div className="rowAlignLeft">
|
||||
<span>{thisInfo.website}</span>
|
||||
</div>
|
||||
</a >
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
let descriptionObj;
|
||||
|
@ -28,22 +28,6 @@ const TotalStakeGraph = (obj) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (livepeer.threeBoxInfo) {
|
||||
for (const thisAddr of livepeer.threeBoxInfo) {
|
||||
if (thisAddr.address === address) {
|
||||
if (thisAddr.name) {
|
||||
if (thisAddr.name.length > 18) {
|
||||
return (thisAddr.name.substring(0, 16) + "..");
|
||||
}
|
||||
return thisAddr.name;
|
||||
} else {
|
||||
return (address.substring(0, 16) + "..");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (address.substring(0, 16) + "..");
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
getOrchestratorInfo, getEnsInfo, getThreeBoxInfo, setCachedOrch, getOrchestratorInfoSilent
|
||||
getOrchestratorInfo, getEnsInfo, setCachedOrch, getOrchestratorInfoSilent
|
||||
} from "../actions/livepeer";
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { Text } from '@mantine/core';
|
||||
@ -9,7 +9,6 @@ const EventButtonAddress = (obj) => {
|
||||
const dispatch = useDispatch();
|
||||
const livepeer = useSelector((state) => state.livepeerstate);
|
||||
const [hasRefreshed, setRefresh] = useState(false);
|
||||
const [hasThreeBoxRefreshed, setThreeBoxRefresh] = useState(false);
|
||||
const [orchInfo, setOrchInfo] = useState(null);
|
||||
const now = new Date().getTime();
|
||||
|
||||
@ -17,7 +16,6 @@ const EventButtonAddress = (obj) => {
|
||||
let thisInfo = null;
|
||||
let thisDomain = null;
|
||||
let hasENS = null;
|
||||
let hasThreeBox = null
|
||||
// Lookup domain in cache
|
||||
if (livepeer.ensDomainMapping && !hasRefreshed) {
|
||||
for (const thisAddr of livepeer.ensDomainMapping) {
|
||||
@ -69,30 +67,7 @@ const EventButtonAddress = (obj) => {
|
||||
setRefresh(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Ugly shit, but temporary for now to quickly enable threebox. Sorry!
|
||||
if (!hasENS && !hasThreeBoxRefreshed) {
|
||||
if (livepeer.threeBoxInfo) {
|
||||
for (const thisAddr of livepeer.threeBoxInfo) {
|
||||
if (thisAddr.address === obj.address) {
|
||||
thisInfo = thisAddr;
|
||||
hasThreeBox = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If it was not cached at all
|
||||
if (!hasThreeBox && !hasThreeBoxRefreshed) {
|
||||
console.log("Refresh due to non-existing 3BOX info");
|
||||
setThreeBoxRefresh(true);
|
||||
getThreeBoxInfo(obj.address);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (thisInfo && thisInfo != orchInfo) {
|
||||
console.log("Setting INFO obj");
|
||||
setOrchInfo(thisInfo);
|
||||
}
|
||||
}, [livepeer.ensDomainMapping, livepeer.threeBoxInfo]);
|
||||
}, [livepeer.ensDomainMapping]);
|
||||
|
||||
useEffect(() => {
|
||||
// Check if cached as an orchestrator
|
||||
@ -130,20 +105,6 @@ const EventButtonAddress = (obj) => {
|
||||
<img alt="" src={orchInfo.avatar.url} width="20em" height="20em" style={{ margin: 0, padding: 0 }} />
|
||||
</a >
|
||||
}
|
||||
} else if (orchInfo && (orchInfo.name || orchInfo.image)) {
|
||||
if (orchInfo.name) {
|
||||
thisName = <Text style={{ textOverflow: "ellipsis", overflow: "hidden", width: '100%' }} >{orchInfo.name}</Text>;
|
||||
} else {
|
||||
thisName = <Text style={{ textOverflow: "ellipsis", overflow: "hidden", width: '100%', maxWidth: '10vw' }} >{obj.address}</Text>;
|
||||
}
|
||||
if (orchInfo.image) {
|
||||
thisIcon =
|
||||
<a className="selectOrch" style={{ padding: '0.3em', cursor: 'grab' }} disabled>
|
||||
<img alt="" src={"https://cloudflare-ipfs.com/ipfs/" + orchInfo.image} width="20em" height="20em" style={{ margin: 0, padding: 0 }} />
|
||||
</a >
|
||||
} else {
|
||||
thisIcon = null;
|
||||
}
|
||||
} else {
|
||||
thisName = <Text style={{ textOverflow: "ellipsis", overflow: "hidden", width: '100%', maxWidth: '10vw' }} >{obj.address}</Text>;
|
||||
thisIcon = null;
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
} from "../actions/user";
|
||||
import {
|
||||
getQuotes, getBlockchainData, getCurrentOrchestratorInfo,
|
||||
getAllEnsDomains, getAllEnsInfo, getAllThreeBoxInfo, getAllOrchScores, getAllOrchInfo,
|
||||
getAllEnsDomains, getAllEnsInfo, getAllOrchScores, getAllOrchInfo,
|
||||
getAllDelInfo, getAllMonthlyStats, getAllUpdateEvents, getAllRewardEvents,
|
||||
getAllClaimEvents, getAllWithdrawStakeEvents, getAllWithdrawFeesEvents,
|
||||
getAllTransferTicketEvents, getAllRedeemTicketEvents, getAllActivateEvents,
|
||||
@ -42,7 +42,6 @@ const Startup = (obj) => {
|
||||
const refreshENS = () => {
|
||||
console.log("Refreshing ENS data...");
|
||||
batch(() => {
|
||||
dispatch(getAllThreeBoxInfo());
|
||||
dispatch(getAllEnsDomains());
|
||||
dispatch(getAllEnsInfo());
|
||||
});
|
||||
|
@ -54,22 +54,6 @@ const Stats = (obj) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (livepeer.threeBoxInfo) {
|
||||
for (const thisAddr of livepeer.threeBoxInfo) {
|
||||
if (thisAddr.address === address) {
|
||||
if (thisAddr.name) {
|
||||
if (thisAddr.name.length > 18) {
|
||||
return thisAddr.name;
|
||||
}
|
||||
return thisAddr.name;
|
||||
} else {
|
||||
return address;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ import {
|
||||
RECEIVE_WINNING_TICKETS,
|
||||
SET_ALL_ENS_INFO,
|
||||
SET_ALL_ENS_DOMAINS,
|
||||
SET_ALL_THREEBOX_INFO,
|
||||
SET_ALL_ORCH_SCORES,
|
||||
SET_ALL_ORCH_INFO,
|
||||
SET_ALL_DEL_INFO,
|
||||
@ -70,8 +69,6 @@ export default (state = {
|
||||
return { ...state, ensInfoMapping: message };
|
||||
case SET_ALL_ENS_DOMAINS:
|
||||
return { ...state, ensDomainMapping: message };
|
||||
case SET_ALL_THREEBOX_INFO:
|
||||
return { ...state, threeBoxInfo: message };
|
||||
case SET_ALL_ORCH_SCORES:
|
||||
return { ...state, orchScores: message };
|
||||
case SET_ALL_ORCH_INFO:
|
||||
|
Loading…
x
Reference in New Issue
Block a user