diff --git a/frontend/src/components/EntriesNavigation.js b/frontend/src/components/EntriesNavigation.js index ee07eb60..91b7f399 100644 --- a/frontend/src/components/EntriesNavigation.js +++ b/frontend/src/components/EntriesNavigation.js @@ -102,7 +102,16 @@ const EntriesNavigation = () => { previousEventRefetch(); setInitialized(true); } - }, [streamBoundary, initialized]); + }, [ + streamBoundary, + initialized, + setInitialized, + setDefaultBoundary, + eventsRefetch, + latestEventsRefetch, + nextEventRefetch, + previousEventRefetch, + ]); useEffect(() => { if (events) { diff --git a/frontend/src/components/StreamEntry.js b/frontend/src/components/StreamEntry.js index da7d2313..30972b0d 100644 --- a/frontend/src/components/StreamEntry.js +++ b/frontend/src/components/StreamEntry.js @@ -3,6 +3,7 @@ import { Flex, IconButton, Stack, Tooltip, chakra } from "@chakra-ui/react"; import { ArrowRightIcon } from "@chakra-ui/icons"; import UIContext from "../core/providers/UIProvider/context"; import EthereumMempoolCard from "./stream-cards/EthereumMempool"; +import EthereumWhalewatchCard from "./stream-cards/EthereumWhalewatch"; const StreamEntry_ = ({ entry, showOnboardingTooltips, className }) => { const ui = useContext(UIContext); @@ -38,13 +39,10 @@ const StreamEntry_ = ({ entry, showOnboardingTooltips, className }) => { )} - {/* ToDo: Add another types of cards in here - - {entryType === "" && ( - + {entry.event_type === "ethereum_whalewatch" && ( + )} - */} { + const { subscriptionsCache, subscriptionTypeIcons } = useSubscriptions(); + const ui = useContext(UIContext); + const [copyString, setCopyString] = useState(false); + const [icon, setIcon] = useState(null); + const { onCopy, hasCopied } = useClipboard(copyString, 1); + const toast = useToast(); + + useEffect(() => { + if (hasCopied && copyString) { + toast("Copied to clipboard", "success"); + setCopyString(false); + } else if (copyString) { + onCopy(); + } + }, [copyString, onCopy, hasCopied, toast]); + + useEffect(() => { + if (subscriptionTypeIcons) { + setIcon(subscriptionTypeIcons.ethereum_whalewatch); + } + }, [subscriptionTypeIcons, setIcon]); + + const [showFullView] = useMediaQuery(["(min-width: 420px)"]); + if (subscriptionsCache.isLoading) return ; + + const whales = { + transactionsOut: entry?.event_data?.transactions_out[0] || {}, + transactionsIn: entry?.event_data?.transactions_in[0] || {}, + valueOut: entry?.event_data?.value_out[0] || {}, + valueIn: entry?.event_data?.value_in[0] || {}, + }; + + console.log("PURPLE RAIN:", whales); + + Object.values(whales).forEach((whaleInfo) => { + whaleInfo.color = + subscriptionsCache.data.subscriptions.find((obj) => { + return obj.address === whaleInfo.address; + })?.color ?? "gray.500"; + whaleInfo.label = + subscriptionsCache.data.subscriptions.find((obj) => { + return obj.address === whaleInfo.address; + })?.label ?? whaleInfo.address; + }); + + const rowLabels = { + transactionsOut: "Number of transactions sent", + transactionsIn: "Number of transactions received", + valueOut: "ETH sent", + valueIn: "ETH received", + }; + + return ( + + + + {icon ? : ""} + + Ethereum whale watch + + + + {`${entry.event_data.date_range.start_time} to ${entry.event_data.date_range.end_time}`} + + + + {Object.keys(whales).map((whaleType) => { + { + console.log("PURPLE RAIN: whaleType:", whaleType); + } + return ( + + + + + Address: + + + + setCopyString(whales[whaleType].address)} + > + {whales[whaleType].label} + + + + + + + To: + + + + {whales[whaleType].statistic} + + + + + ); + })} + + ); +}; + +const EthereumWhalewatchCard = chakra(EthereumWhalewatchCard_, { + baseStyle: { + my: 0, + direction: "column", + flexBasis: "10px", + flexGrow: 1, + borderWidth: "2px", + borderLeftRadius: "md", + borderColor: "gray.600", + spacing: 0, + h: "auto", + overflowX: "hidden", + overflowY: "visible", + }, +}); + +export default EthereumWhalewatchCard;