Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodriguespn committed Jan 19, 2024
2 parents 5019ac8 + 1aac37f commit f706285
Show file tree
Hide file tree
Showing 24 changed files with 485 additions and 130 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# For connection with the backend
VITE_WARD_API_BASE_URL=https://wardanalyticsapi.com
VITE_WARD_API_KEY=

Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ name: Deploy to Firebase Hosting on PR
env:
VITE_WARD_API_BASE_URL: "https://wardanalyticsapi.com"
VITE_WARD_API_KEY: ${{ secrets.WARD_API_KEY }}
VITE_FIREBASE_API_KEY: "AIzaSyD1LUGU2RM-bhxKgeYdnzItbwBC0VSTOV0"
VITE_FIREBASE_AUTH_DOMAIN: "graphapp-bca04.firebaseapp.com"
VITE_FIREBASE_PROJECT_ID: "graphapp-bca04"
VITE_FIREBASE_STORAGE_BUCKET: "graphapp-bca04.appspot.com"
VITE_FIREBASE_MESSAGING_SENDER_ID: "1030502540585"
VITE_FIREBASE_APP_ID: "1:1030502540585:web:cfe727695aad44d0494338"
VITE_FIREBASE_API_KEY: "AIzaSyBZCnEQus6G42SodGNRf6o2zmBnGN0nXes"
VITE_FIREBASE_AUTH_DOMAIN: "graphapp-dev.firebaseapp.com"
VITE_FIREBASE_PROJECT_ID: "graphapp-dev"
VITE_FIREBASE_STORAGE_BUCKET: "graphapp-dev.appspot.com"
VITE_FIREBASE_MESSAGING_SENDER_ID: "897485812844"
VITE_FIREBASE_APP_ID: "1:897485812844:web:039de3b976c1559fded449"
# For Google Analytics
VITE_FIREBASE_MEASUREMENT_ID: "G-RYB03B2Q13"
VITE_FIREBASE_MEASUREMENT_ID: "G-V2S9JPMH7S"

jobs:
build_and_preview:
Expand Down
6 changes: 4 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<!doctype html>
<html lang="en">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#">

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="ward-logo-blue.svg" />
<link rel="icon" type="image/x-icon" href="./src/assets/ward-logo-blue.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta property="og:image"
content="https://firebasestorage.googleapis.com/v0/b/graphapp-bca04.appspot.com/o/Screenshot%20from%202024-01-16%2023-18-32-overlay.png?alt=media&token=e573d2ab-db72-4e10-80e4-a51b695aeb3c" />
<title>Ward Graph</title>
</head>

Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-draggable": "^4.4.6",
"react-icons": "^5.0.1",
"react-query": "^3.39.3",
"react-share": "^5.0.3",
"reactflow": "^11.10.1",
"uuid": "^9.0.1",
"vite-plugin-environment": "^1.1.3",
"yarn": "^1.22.21"
},
Expand All @@ -36,6 +39,7 @@
"@types/dotenv": "^8.2.0",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.15",
"@types/uuid": "^9.0.7",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react": "^4.2.0",
Expand Down
10 changes: 10 additions & 0 deletions src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ import { FC, lazy } from "react";
import { RouteObject, useRoutes } from "react-router-dom";

const GraphTemplate = lazy(() => import("./templates/GraphTemplate"));
const RedirectShortUrl = lazy(() => import("./templates/RedirectShortUrl"))

// TODO: Replace the last route with a 404 page
const PublicRoutes: RouteObject[] = [
{
path: "/",
element: <GraphTemplate />,
},
{
path: "/short/:key",
element: <RedirectShortUrl />,
},
{
path: "*",
element: <GraphTemplate />,
},
];

const Routes: FC = () => {
Expand Down
1 change: 0 additions & 1 deletion src/assets/discord.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/github.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/linkedin.svg

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/Graph/AnalysisWindow/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Header: FC<HeaderProps> = ({
</h1>

{/* Clipboard and Block Explorer icons - only shown in expanded mode */}
<CopyToClipboardIcon address={address} />
<CopyToClipboardIcon textToCopy={address} />
{analysisData && (
<BlockExplorerAddressIcon
blockchain={analysisData.blockchain}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { FC, useState } from "react";
import { ClipboardIcon } from "@heroicons/react/24/outline";
import { FC, useState } from "react";

interface CopyToClipboardIconProps {
address: string;
textToCopy: string;
}

/** This component is an icon that copies the address to the clipboard.
* It uses the navigator.clipboard API to copy the address to the clipboard.
/** This component is an icon that copies a piece of text to the clipboard.
* It uses the navigator.clipboard API to copy the text to the clipboard.
*
* @param address: The address to copy
* @param textToCopy: The text to copy
*/

const CopyToClipboardIcon: FC<CopyToClipboardIconProps> = ({ address }) => {
// Function for copying the address to the clipboard
const CopyToClipboardIcon: FC<CopyToClipboardIconProps> = ({ textToCopy }) => {
// Function for copying text to the clipboard
const [isCopied, setIsCopied] = useState(false);
const copyToClipboard = async () => {
try {
await navigator.clipboard.writeText(address);
await navigator.clipboard.writeText(textToCopy);
setIsCopied(true);
setTimeout(() => setIsCopied(false), 500);
} catch (err) {
Expand All @@ -26,9 +26,8 @@ const CopyToClipboardIcon: FC<CopyToClipboardIconProps> = ({ address }) => {

return (
<ClipboardIcon
className={`h-5 w-5 cursor-pointer transition-all duration-200 ${
isCopied ? "text-blue-500" : "text-gray-400 hover:text-gray-500"
}`}
className={`h-5 w-5 cursor-pointer transition-all duration-200 ${isCopied ? "text-blue-500" : "text-gray-400 hover:text-gray-500"
}`}
aria-hidden="true"
onClick={copyToClipboard}
/>
Expand Down
34 changes: 27 additions & 7 deletions src/components/Graph/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@ import {
convertNodeListToRecord,
} from "./graph_calculations";

import { logEvent } from "firebase/analytics";
import { default as firebase } from "../../firebase/firebase";
import analytics from "../../firebase/analytics";
import firestore, { StoreUrlObject } from "../../firebase/firestore";
import generateShortUrl from "../../utils/generateShortUrl";
import TutorialPopup from "../tutorial/TutorialPopup";
import DraggableWindow from "./AnalysisWindow/AnalysisWindow";
import Hotbar from "./Hotbar";
import LandingPage from "./LandingPage/LandingPage";
import Legend from "./Legend";
import TransactionTooltip, {
TransactionTooltipProps,
} from "./TransactionTooltip";
import TutorialPopup from "../tutorial/TutorialPopup";


/* Pan on drag settings */
Expand All @@ -76,7 +77,8 @@ interface GraphContextProps {
getEdgeHandleID: (edgeID: string) => string;
setFocusedAddressData: (data: AddressAnalysis | null) => void;
setHoveredTransferData: (data: TransactionTooltipProps | null) => void;
copyLink: () => void;
getSharingLink: () => string;
copyLink: (url: string) => void;
doLayout: () => void;
setNodeHighlight: (address: string, highlight: boolean) => void;
getNodeCount: () => number;
Expand Down Expand Up @@ -517,8 +519,25 @@ const GraphProvided: FC<GraphProvidedProps> = ({
)}&paths=${addressPaths.join(",")}`;
}

function copyLink(): void {
navigator.clipboard.writeText(getLink());
async function copyLink(shortenedUrl: string): Promise<void> {
const link = getLink();
const key = shortenedUrl.split("/").pop()!;

console.log("link: ", shortenedUrl);

const storeUrlObj: StoreUrlObject = {
originalUrl: link,
key: key,
};

await firestore.storeUrl(storeUrlObj).then(async (id) => {
if (id) {
await navigator.clipboard.writeText(shortenedUrl);
analytics.logAnalyticsEvent("copy_link", {
link: shortenedUrl,
});
}
});
}

// Getting the node count so that we can show the legend dynamically ---------
Expand All @@ -537,6 +556,7 @@ const GraphProvided: FC<GraphProvidedProps> = ({
setFocusedAddressData,
setHoveredTransferData,
doLayout,
getSharingLink: generateShortUrl,
copyLink,
setNodeHighlight,
getNodeCount,
Expand Down Expand Up @@ -633,7 +653,7 @@ const Graph: FC = () => {
const onSetSearchedAddress = (newAddress: string) => {
setSearchedAddresses([newAddress]);

logEvent(firebase.analytics, "search_address", {
analytics.logAnalyticsEvent("search_address", {
address: newAddress,
});
};
Expand Down
26 changes: 20 additions & 6 deletions src/components/Graph/Hotbar/Hotbar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { RectangleGroupIcon, ShareIcon } from "@heroicons/react/24/solid";
import { FC, useContext, useState } from "react";
import { FC, useContext, useMemo, useState } from "react";

import { GraphContext } from "../Graph";
import ShareDialog from "../LandingPage/ShareDialog";

interface HotbarButton {
onClick?: () => void;
Expand All @@ -10,7 +11,19 @@ interface HotbarButton {
}

const Hotbar: FC = () => {
const { doLayout, copyLink } = useContext(GraphContext);
const { doLayout, copyLink, getSharingLink } = useContext(GraphContext);

const [isShareDialogOpen, setIsShareDialogOpen] = useState(false);

const shareUrl = useMemo(() => getSharingLink(), []);

const onShareUrl = () => {
copyLink(shareUrl);
}

const openShareDialog = () => {
setIsShareDialogOpen(true);
}

const Buttons: HotbarButton[] = [
{
Expand All @@ -20,10 +33,10 @@ const Hotbar: FC = () => {
},
{
Icon: ShareIcon,
name: "Copy Link",
onClick: copyLink,
},
];
name: "Share",
onClick: openShareDialog
}
]

return (
<>
Expand All @@ -43,6 +56,7 @@ const Hotbar: FC = () => {
);
})}
</div>
<ShareDialog shareUrl={shareUrl} isOpen={isShareDialogOpen} setIsOpen={setIsShareDialogOpen} onShareUrl={onShareUrl} />
</>
);
};
Expand Down
16 changes: 8 additions & 8 deletions src/components/Graph/LandingPage/LandingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ const PossibleAddresses: string[] = [
"0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD",
"0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97",
"0xd24400ae8BfEBb18cA49Be86258a3C749cf46853"
];
]

interface LandingPageProps {
setSearchedAddress: (address: string) => void;
setSearchedAddress: (address: string) => void
}

const LandingPage: FC<LandingPageProps> = ({ setSearchedAddress }) => {
function selectRandomAddress() {
const randomIndex = Math.floor(Math.random() * PossibleAddresses.length);
setSearchedAddress(PossibleAddresses[randomIndex]);
const randomIndex = Math.floor(Math.random() * PossibleAddresses.length)
setSearchedAddress(PossibleAddresses[randomIndex])
}

return (
<>
<div className="flex max-w-screen-sm flex-col items-center gap-y-10">
<img src={logo} alt="Ward Logo" className="w-2/3" />
<Searchbar className="w-full" onSearchAddress={setSearchedAddress} />
<Searchbar className="w-2/3 sm:w-full" onSearchAddress={setSearchedAddress} />
<h3
className="flex cursor-pointer flex-row items-center gap-x-2 text-sm text-blue-500"
onClick={selectRandomAddress}
Expand All @@ -36,7 +36,7 @@ const LandingPage: FC<LandingPageProps> = ({ setSearchedAddress }) => {
</h3>
</div>
</>
);
};
)
}

export default LandingPage;
export default LandingPage
Loading

0 comments on commit f706285

Please sign in to comment.