From 93dd7c3e9551ac13f4f70aed07a7e35c47d9c317 Mon Sep 17 00:00:00 2001 From: Yoginth Date: Fri, 6 Dec 2024 14:16:16 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=BA=20Lens=20and=20Hey=20v3:=20v38=20(?= =?UTF-8?q?#lens-v3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Removed Lens v3 integration and related components. Highlights: • Deleted `WrapWmatic.tsx` and removed WMATIC token from `seedTokens.ts`. • Removed `Signup` components and routes from the `Staff` section. • Simplified `Delete.tsx` by removing contract interactions and error handling. Read more: https://pierre.co/hey/hey/lens-v3 --- .../src/components/Settings/Danger/Delete.tsx | 42 +------- .../index.tsx => NoBalanceError.tsx} | 7 -- .../Shared/NoBalanceError/WrapWmatic.tsx | 97 ------------------- apps/web/src/components/Staff/Sidebar.tsx | 8 +- .../Staff/Signup/AccountsCreated.tsx | 8 -- .../components/Staff/Signup/LensCredits.tsx | 27 ------ apps/web/src/components/Staff/Signup/Mint.tsx | 83 ---------------- .../components/Staff/Signup/NftsMinted.tsx | 24 ----- .../components/Staff/Signup/SignupPrice.tsx | 27 ------ .../web/src/components/Staff/Signup/index.tsx | 52 ---------- apps/web/src/pages/staff/signup.tsx | 3 - packages/db/prisma/db/seed/seedTokens.ts | 6 -- 12 files changed, 6 insertions(+), 378 deletions(-) rename apps/web/src/components/Shared/{NoBalanceError/index.tsx => NoBalanceError.tsx} (88%) delete mode 100644 apps/web/src/components/Shared/NoBalanceError/WrapWmatic.tsx delete mode 100644 apps/web/src/components/Staff/Signup/AccountsCreated.tsx delete mode 100644 apps/web/src/components/Staff/Signup/LensCredits.tsx delete mode 100644 apps/web/src/components/Staff/Signup/Mint.tsx delete mode 100644 apps/web/src/components/Staff/Signup/NftsMinted.tsx delete mode 100644 apps/web/src/components/Staff/Signup/SignupPrice.tsx delete mode 100644 apps/web/src/components/Staff/Signup/index.tsx delete mode 100644 apps/web/src/pages/staff/signup.tsx diff --git a/apps/web/src/components/Settings/Danger/Delete.tsx b/apps/web/src/components/Settings/Danger/Delete.tsx index a094b11b9435..f09025d23d12 100644 --- a/apps/web/src/components/Settings/Danger/Delete.tsx +++ b/apps/web/src/components/Settings/Danger/Delete.tsx @@ -1,8 +1,6 @@ import SingleAccount from "@components/Shared/SingleAccount"; -import errorToast from "@helpers/errorToast"; import { TrashIcon } from "@heroicons/react/24/outline"; -import { LensHub } from "@hey/abis"; -import { APP_NAME, LENS_HUB } from "@hey/data/constants"; +import { APP_NAME } from "@hey/data/constants"; import { Errors } from "@hey/data/errors"; import type { Account } from "@hey/indexer"; import { @@ -19,52 +17,22 @@ import { useState } from "react"; import toast from "react-hot-toast"; import useHandleWrongNetwork from "src/hooks/useHandleWrongNetwork"; import { useAccountStore } from "src/store/persisted/useAccountStore"; -import { signOut } from "src/store/persisted/useAuthStore"; -import { useDisconnect, useWriteContract } from "wagmi"; const DeleteSettings: FC = () => { const { currentAccount } = useAccountStore(); const [showWarningModal, setShowWarningModal] = useState(false); const [isLoading, setIsLoading] = useState(false); - const { disconnect } = useDisconnect(); const handleWrongNetwork = useHandleWrongNetwork(); - const onCompleted = () => { - signOut(); - disconnect?.(); - location.href = "/"; - }; - - const onError = (error: any) => { - setIsLoading(false); - errorToast(error); - }; - - const { writeContractAsync } = useWriteContract({ - mutation: { onSuccess: onCompleted } - }); - - const write = async ({ args }: { args: any[] }) => { - return await writeContractAsync({ - abi: LensHub, - address: LENS_HUB, - args, - functionName: "burn" - }); - }; - const handleDelete = async () => { if (!currentAccount) { return toast.error(Errors.SignWallet); } - try { - setIsLoading(true); - await handleWrongNetwork(); - return await write({ args: [currentAccount?.address] }); - } catch (error) { - onError(error); - } + setIsLoading(true); + await handleWrongNetwork(); + setIsLoading(false); + return toast.success("Feature not implemented yet"); }; return ( diff --git a/apps/web/src/components/Shared/NoBalanceError/index.tsx b/apps/web/src/components/Shared/NoBalanceError.tsx similarity index 88% rename from apps/web/src/components/Shared/NoBalanceError/index.tsx rename to apps/web/src/components/Shared/NoBalanceError.tsx index 19d7fdf3719f..d1f09800b8bb 100644 --- a/apps/web/src/components/Shared/NoBalanceError/index.tsx +++ b/apps/web/src/components/Shared/NoBalanceError.tsx @@ -3,7 +3,6 @@ import getUniswapURL from "@hey/helpers/getUniswapURL"; import type { Amount } from "@hey/indexer"; import Link from "next/link"; import type { FC, ReactNode } from "react"; -import WrapWmatic from "./WrapWmatic"; interface NoBalanceErrorProps { errorMessage?: ReactNode; @@ -18,12 +17,6 @@ const NoBalanceError: FC = ({ const currency = moduleAmount?.asset?.symbol; const assetAddress = moduleAmount?.asset?.contract.address; - if (currency === "WMATIC") { - return ( - - ); - } - return (
diff --git a/apps/web/src/components/Shared/NoBalanceError/WrapWmatic.tsx b/apps/web/src/components/Shared/NoBalanceError/WrapWmatic.tsx deleted file mode 100644 index 252aab995ed4..000000000000 --- a/apps/web/src/components/Shared/NoBalanceError/WrapWmatic.tsx +++ /dev/null @@ -1,97 +0,0 @@ -import errorToast from "@helpers/errorToast"; -import type { Amount } from "@hey/indexer"; -import { Button } from "@hey/ui"; -import type { FC, ReactNode } from "react"; -import { useState } from "react"; -import { parseEther } from "viem"; -import { useWriteContract } from "wagmi"; -import IndexStatus from "../IndexStatus"; - -interface WrapWmaticProps { - errorMessage?: ReactNode; - moduleAmount: Amount; -} - -const WrapWmatic: FC = ({ errorMessage, moduleAmount }) => { - const [isLoading, setIsLoading] = useState(false); - - const amount = moduleAmount?.value; - const currency = moduleAmount?.asset?.symbol; - const assetAddress = moduleAmount?.asset?.contract.address; - - const onError = (error: any) => { - setIsLoading(false); - errorToast(error); - }; - - const { data: writeHash, writeContractAsync } = useWriteContract({ - mutation: { onError } - }); - - const writeAsync = () => { - return writeContractAsync({ - abi: [ - { - anonymous: false, - inputs: [ - { indexed: true, name: "dst", type: "address" }, - { indexed: false, name: "wad", type: "uint256" } - ], - name: "Deposit", - type: "event" - }, - { - constant: false, - inputs: [], - name: "deposit", - outputs: [], - payable: true, - stateMutability: "payable", - type: "function" - } - ], - address: assetAddress, - functionName: "deposit", - value: parseEther(amount) - }); - }; - - const handleDeposit = async () => { - try { - setIsLoading(true); - return await writeAsync(); - } catch (error) { - onError(error); - } finally { - setIsLoading(false); - } - }; - - return ( -
- {writeHash ? ( - - ) : ( - <> -
- {errorMessage ? ( - errorMessage - ) : ( - - You don't have enough {currency} - - )} -
- - - )} -
- ); -}; - -export default WrapWmatic; diff --git a/apps/web/src/components/Staff/Sidebar.tsx b/apps/web/src/components/Staff/Sidebar.tsx index 580d5ef6d2c0..94e56fc1b1ad 100644 --- a/apps/web/src/components/Staff/Sidebar.tsx +++ b/apps/web/src/components/Staff/Sidebar.tsx @@ -4,8 +4,7 @@ import { ChartBarIcon, ClipboardIcon, CurrencyDollarIcon, - UserIcon, - UserPlusIcon + UserIcon } from "@heroicons/react/24/outline"; import type { FC } from "react"; @@ -39,11 +38,6 @@ const sidebarItems = [ icon: , title: "Permissions", url: "/staff/permissions" - }, - { - icon: , - title: "Signup", - url: "/staff/signup" } ]; diff --git a/apps/web/src/components/Staff/Signup/AccountsCreated.tsx b/apps/web/src/components/Staff/Signup/AccountsCreated.tsx deleted file mode 100644 index e67e6d3938be..000000000000 --- a/apps/web/src/components/Staff/Signup/AccountsCreated.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { NumberedStat } from "@hey/ui"; -import type { FC } from "react"; - -const AccountsCreated: FC = () => { - return ; -}; - -export default AccountsCreated; diff --git a/apps/web/src/components/Staff/Signup/LensCredits.tsx b/apps/web/src/components/Staff/Signup/LensCredits.tsx deleted file mode 100644 index 53e986baa76a..000000000000 --- a/apps/web/src/components/Staff/Signup/LensCredits.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { PermissionlessCreator } from "@hey/abis"; -import { HEY_LENS_SIGNUP, PERMISSIONLESS_CREATOR } from "@hey/data/constants"; -import { NumberedStat } from "@hey/ui"; -import type { FC } from "react"; -import { useReadContract } from "wagmi"; - -const LensCredits: FC = () => { - const { data } = useReadContract({ - abi: PermissionlessCreator, - address: PERMISSIONLESS_CREATOR, - args: [HEY_LENS_SIGNUP], - functionName: "getCreditBalance", - query: { refetchInterval: 2000 } - }); - - const credits = data?.toString(); - - return ( - - ); -}; - -export default LensCredits; diff --git a/apps/web/src/components/Staff/Signup/Mint.tsx b/apps/web/src/components/Staff/Signup/Mint.tsx deleted file mode 100644 index 3a0ce33a0798..000000000000 --- a/apps/web/src/components/Staff/Signup/Mint.tsx +++ /dev/null @@ -1,83 +0,0 @@ -import errorToast from "@helpers/errorToast"; -import { HeyLensSignup } from "@hey/abis"; -import { - HANDLE_PREFIX, - HEY_LENS_SIGNUP, - ZERO_ADDRESS -} from "@hey/data/constants"; -import { Regex } from "@hey/data/regex"; -import { Button, Card, CardHeader, Form, Input, useZodForm } from "@hey/ui"; -import type { FC } from "react"; -import { useState } from "react"; -import toast from "react-hot-toast"; -import { useWriteContract } from "wagmi"; -import { object, string, type z } from "zod"; - -const newProfileSchema = object({ - address: string().regex(Regex.ethereumAddress), - handle: string() - .min(5, { message: "Handle must be at least 5 characters long" }) - .max(26, { message: "Handle must be at most 26 characters long" }) - .regex(Regex.username) -}); - -const Mint: FC = () => { - const [isLoading, setIsLoading] = useState(false); - const form = useZodForm({ mode: "onChange", schema: newProfileSchema }); - - const { writeContractAsync } = useWriteContract({ - mutation: { - onError: errorToast, - onSuccess: (hash: string) => { - form.reset(); - toast.success(hash); - } - } - }); - - const handleMint = async ({ - handle, - address - }: z.infer) => { - try { - setIsLoading(true); - return await writeContractAsync({ - abi: HeyLensSignup, - address: HEY_LENS_SIGNUP, - args: [ - [address, ZERO_ADDRESS, "0x"], - handle.toLowerCase(), - ["0xe88E17550978A9f87819ABE96b3f9ec1edc3d953"] - ], - functionName: "createProfileWithHandle" - }); - } catch (error) { - errorToast(error); - } finally { - setIsLoading(false); - } - }; - - return ( - - -
- - - -
-
- ); -}; - -export default Mint; diff --git a/apps/web/src/components/Staff/Signup/NftsMinted.tsx b/apps/web/src/components/Staff/Signup/NftsMinted.tsx deleted file mode 100644 index 742d0542aa94..000000000000 --- a/apps/web/src/components/Staff/Signup/NftsMinted.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { HeyMembershipNft } from "@hey/abis"; -import { HEY_MEMBERSHIP_NFT } from "@hey/data/constants"; -import { NumberedStat } from "@hey/ui"; -import type { FC } from "react"; -import { useReadContract } from "wagmi"; - -const NftsMinted: FC = () => { - const { data: totalSupply } = useReadContract({ - abi: HeyMembershipNft, - address: HEY_MEMBERSHIP_NFT, - functionName: "totalSupply", - query: { refetchInterval: 2000 } - }); - - return ( - - ); -}; - -export default NftsMinted; diff --git a/apps/web/src/components/Staff/Signup/SignupPrice.tsx b/apps/web/src/components/Staff/Signup/SignupPrice.tsx deleted file mode 100644 index 89c7dbd0749a..000000000000 --- a/apps/web/src/components/Staff/Signup/SignupPrice.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { HeyLensSignup } from "@hey/abis"; -import { HEY_LENS_SIGNUP } from "@hey/data/constants"; -import { NumberedStat } from "@hey/ui"; -import type { FC } from "react"; -import { useReadContract } from "wagmi"; - -const SignupPrice: FC = () => { - const { data } = useReadContract({ - abi: HeyLensSignup, - address: HEY_LENS_SIGNUP, - functionName: "signupPrice", - query: { refetchInterval: 10000 } - }); - - const price = data?.toString(); - const priceInMatic = price ? Number(price) / 10 ** 18 : 0; - - return ( - - ); -}; - -export default SignupPrice; diff --git a/apps/web/src/components/Staff/Signup/index.tsx b/apps/web/src/components/Staff/Signup/index.tsx deleted file mode 100644 index 9f24b13cb3c8..000000000000 --- a/apps/web/src/components/Staff/Signup/index.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import MetaTags from "@components/Common/MetaTags"; -import { APP_NAME } from "@hey/data/constants"; -import { FeatureFlag } from "@hey/data/feature-flags"; -import { - Card, - CardHeader, - GridItemEight, - GridItemFour, - GridLayout -} from "@hey/ui"; -import { useFlag } from "@unleash/proxy-client-react"; -import type { NextPage } from "next"; -import Custom404 from "src/pages/404"; -import { useAccountStore } from "src/store/persisted/useAccountStore"; -import StaffSidebar from "../Sidebar"; -import AccountsCreated from "./AccountsCreated"; -import LensCredits from "./LensCredits"; -import Mint from "./Mint"; -import NftsMinted from "./NftsMinted"; -import SignupPrice from "./SignupPrice"; - -const Signup: NextPage = () => { - const { currentAccount } = useAccountStore(); - const isStaff = useFlag(FeatureFlag.Staff); - - if (!currentAccount || !isStaff) { - return ; - } - - return ( - - - - - - - - -
- - - - -
-
- -
-
- ); -}; - -export default Signup; diff --git a/apps/web/src/pages/staff/signup.tsx b/apps/web/src/pages/staff/signup.tsx deleted file mode 100644 index 1f4253ecc51e..000000000000 --- a/apps/web/src/pages/staff/signup.tsx +++ /dev/null @@ -1,3 +0,0 @@ -import Signup from "@components/Staff/Signup"; - -export default Signup; diff --git a/packages/db/prisma/db/seed/seedTokens.ts b/packages/db/prisma/db/seed/seedTokens.ts index 3bc0ce9cfb6f..c306c68f5096 100644 --- a/packages/db/prisma/db/seed/seedTokens.ts +++ b/packages/db/prisma/db/seed/seedTokens.ts @@ -12,12 +12,6 @@ const seedTokens = async (): Promise => { name: "Bonsai", symbol: "BONSAI", decimals: 18 - }, - { - contractAddress: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", - name: "Wrapped Matic", - symbol: "WMATIC", - decimals: 18 } ] });