diff --git a/packages/react-app/.eslintrc.js b/packages/react-app/.eslintrc.js index 47911ef..e8f90db 100644 --- a/packages/react-app/.eslintrc.js +++ b/packages/react-app/.eslintrc.js @@ -4,6 +4,8 @@ module.exports = { }, extends: ["eslint:recommended", "prettier", "next"], rules: { - "no-console": "off" + "no-console": "warn", + "no-undef": "warn", + "react-hooks/rules-of-hooks": "warn", }, }; diff --git a/packages/react-app/helpers/Web3Context.js b/packages/react-app/helpers/Web3Context.js index b0fbc15..1213ed9 100644 --- a/packages/react-app/helpers/Web3Context.js +++ b/packages/react-app/helpers/Web3Context.js @@ -5,14 +5,14 @@ import { Alert, Button } from "antd"; import axios from "axios"; import "antd/dist/antd.css"; import Authereum from "authereum"; -import { useBalance, useContractLoader, useGasPrice, useOnBlock, useUserProviderAndSigner } from "eth-hooks"; +import { useBalance, useContractLoader, useGasPrice, useUserProviderAndSigner } from "eth-hooks"; import { useExchangeEthPrice } from "eth-hooks/dapps/dex"; import Fortmatic from "fortmatic"; import React, { useCallback, useEffect, useMemo, useState } from "react"; //import Torus from "@toruslabs/torus-embed" // import WalletLink from "walletlink"; import Web3Modal from "web3modal"; -import { INFURA_ID, NETWORK, NETWORKS } from "../constants"; +import { INFURA_ID, NETWORKS } from "../constants"; import { Transactor } from "../helpers"; import { useContractConfig } from "../hooks"; import { CERAMIC_TESTNET } from "../ceramic"; @@ -24,7 +24,7 @@ const { ethers } = require("ethers"); export const Web3Context = React.createContext({}); // provider Component that wraps the entire app and provides context variables -export function Web3Provider({ children, network = "localhost", DEBUG = false, NETWORKCHECK = true, ...props }) { +export function Web3Provider({ children, network = "localhost", DEBUG = false, NETWORKCHECK = true }) { // for Nextjs Builds, return null until "window" is available if (!global.window) { return null; @@ -264,8 +264,6 @@ export function Web3Provider({ children, network = "localhost", DEBUG = false, N let networkDisplay = ""; if (NETWORKCHECK && localChainId && selectedChainId && localChainId !== selectedChainId) { - const networkSelected = NETWORK(selectedChainId); - const networkLocal = NETWORK(localChainId); if (selectedChainId === 1337 && localChainId === 31337) { networkDisplay = (
@@ -345,7 +343,7 @@ export function Web3Provider({ children, network = "localhost", DEBUG = false, N }); // Subscribe to session disconnection - connection.on("disconnect", (code, reason) => { + connection.on("disconnect", () => { logoutOfWeb3Modal(); }); }, [setInjectedProvider]); diff --git a/packages/react-app/helpers/index.js b/packages/react-app/helpers/index.js index 8317132..76357c0 100644 --- a/packages/react-app/helpers/index.js +++ b/packages/react-app/helpers/index.js @@ -13,7 +13,7 @@ export const loadDRecruitV1Contract = async (targetNetwork, signer) => { }; export const getDidFromTokenURI = tokenURI => { - const [ipfsWithColon, _, cid, didFilename] = tokenURI.split("/"); + const [, , cid, didFilename] = tokenURI.split("/"); const [did] = didFilename.split(".json"); return { did, diff --git a/packages/react-app/pages/_app.js b/packages/react-app/pages/_app.js index 8ae1a52..df886ee 100644 --- a/packages/react-app/pages/_app.js +++ b/packages/react-app/pages/_app.js @@ -10,8 +10,6 @@ import DevUI from "../components/DevUI"; import { Web3Provider } from "../helpers/Web3Context"; import "../styles/index.css"; -const { SubMenu } = Menu; - function MyApp({ Component, pageProps }) { const prevTheme = useRef("light"); const [current, setCurrent] = useState(); diff --git a/packages/react-app/pages/api/image-storage.js b/packages/react-app/pages/api/image-storage.js index 7a6d289..8843e9e 100644 --- a/packages/react-app/pages/api/image-storage.js +++ b/packages/react-app/pages/api/image-storage.js @@ -1,5 +1,4 @@ // Next.js API route support: https://nextjs.org/docs/api-routes/introduction -import { NextApiRequest, NextApiResponse } from "next"; import multiparty from "multiparty"; import { Web3Storage, File } from "web3.storage"; import * as fs from "fs"; diff --git a/packages/react-app/pages/api/json-storage.js b/packages/react-app/pages/api/json-storage.js index d1599ee..1403009 100644 --- a/packages/react-app/pages/api/json-storage.js +++ b/packages/react-app/pages/api/json-storage.js @@ -1,8 +1,5 @@ // Next.js API route support: https://nextjs.org/docs/api-routes/introduction -import { NextApiRequest, NextApiResponse } from "next"; -import multiparty from "multiparty"; import { Web3Storage, File, Blob } from "web3.storage"; -import * as fs from "fs"; function getWeb3Token() { const token = process.env.WEB3STORAGE_TOKEN; diff --git a/packages/react-app/pages/index.js b/packages/react-app/pages/index.js index ab92e7a..bb3aade 100644 --- a/packages/react-app/pages/index.js +++ b/packages/react-app/pages/index.js @@ -13,7 +13,7 @@ import { import { Web3Context } from "../helpers/Web3Context"; import { Input } from "antd"; -import { ceramicCoreFactory, CERAMIC_TESTNET } from "../ceramic"; +import { ceramicCoreFactory } from "../ceramic"; import { getDidFromTokenURI, loadDRecruitV1Contract } from "../helpers"; import MediaCard from "../components/cards/MediaCard"; import { Layout } from "../components/layout/Layout"; diff --git a/packages/react-app/pages/profile/approval/index.js b/packages/react-app/pages/profile/approval/index.js index 23c932f..af7cb57 100644 --- a/packages/react-app/pages/profile/approval/index.js +++ b/packages/react-app/pages/profile/approval/index.js @@ -2,8 +2,7 @@ import { Badge, Spacer, Box, Center, Heading, Link, SimpleGrid, Stack, Text } fr import React, { useCallback, useContext, useEffect, useState } from "react"; import { getSlicedAddress, loadDRecruitV1Contract } from "../../../helpers"; -import { ceramicCoreFactory, CERAMIC_TESTNET } from "../../../ceramic"; -import modelAliases from "../../../model.json"; +import { ceramicCoreFactory } from "../../../ceramic"; import { LinkIcon } from "@chakra-ui/icons"; import { Button } from "@chakra-ui/button"; import { Avatar } from "@chakra-ui/avatar"; @@ -31,7 +30,6 @@ function ApproveShareContactInformation() { context.injectedProvider.getSigner(), ); setContract(dRecruitV1Contract); - const addresses = await window.ethereum.enable(); const privateProfile = await context.self.get("privateProfile"); if (!privateProfile) { return; @@ -92,7 +90,7 @@ function ApproveShareContactInformation() { ), status: "success", }); - const receipt = await tx.wait(); + await tx.wait(); toast({ title: "Approval transaction confirmed", description: ( diff --git a/packages/react-app/pages/profile/edit-private-profile.js b/packages/react-app/pages/profile/edit-private-profile.js index a2366ec..d0a88b2 100644 --- a/packages/react-app/pages/profile/edit-private-profile.js +++ b/packages/react-app/pages/profile/edit-private-profile.js @@ -1,6 +1,6 @@ import { Button, FormControl, FormErrorMessage, FormLabel, Input, Stack } from "@chakra-ui/react"; import { Box } from "@chakra-ui/layout"; -import React, { useCallback, useContext, useEffect, useRef, useState } from "react"; +import React, { useContext, useEffect } from "react"; import { useForm } from "react-hook-form"; import { Web3Context } from "../../helpers/Web3Context"; import { loadDRecruitV1Contract } from "../../helpers"; @@ -10,8 +10,6 @@ import { useRouter } from "next/router"; const EditPrivateProfilePage = () => { const router = useRouter(); const { address, targetNetwork, injectedProvider, self } = useContext(Web3Context); - const [imageURL, setImageURL] = useState(); - const image = useRef(null); const { handleSubmit, register, @@ -30,16 +28,16 @@ const EditPrivateProfilePage = () => { Object.entries(decrypted).forEach(([key, value]) => { console.log({ key, value }); if (["image"].includes(key)) { - const { - original: { src: url }, - } = value; - const match = url.match(/^ipfs:\/\/(.+)$/); - if (match) { - const ipfsUrl = `//ipfs.io/ipfs/${match[1]}`; - if (key === "image") { - setImageURL(ipfsUrl); - } - } + // const { + // original: { src: url }, + // } = value; + // const match = url.match(/^ipfs:\/\/(.+)$/); + // if (match) { + // const ipfsUrl = `//ipfs.io/ipfs/${match[1]}`; + // if (key === "image") { + // setImageURL(ipfsUrl); + // } + // } } else { setValue(key, value); } @@ -50,21 +48,6 @@ const EditPrivateProfilePage = () => { })(); }, [address, self]); - const onFileChange = useCallback(event => { - const input = event.target; - const file = input.files?.[0]; - if (!file) return; - const img = image.current; - const reader = new FileReader(); - reader.addEventListener("load", () => { - console.log(reader.result); // eslint-disable-line no-console - if (input.name === "image") { - img.src = reader.result; - } - }); - reader.readAsDataURL(file); - }, []); - const onSubmit = async values => { const { data: appDid } = await axios.get(`${process.env.NEXT_PUBLIC_API_URL}/did`); const encryptedData = await self.client.ceramic.did?.createDagJWE(values, [ diff --git a/packages/react-app/pages/profile/edit-profile.js b/packages/react-app/pages/profile/edit-profile.js index 0281ace..f776714 100644 --- a/packages/react-app/pages/profile/edit-profile.js +++ b/packages/react-app/pages/profile/edit-profile.js @@ -19,7 +19,7 @@ import { COUNTRIES } from "../../helpers/countries"; import { emojis } from "../../helpers"; const EditProfilePage = () => { - const { address, targetNetwork, self } = useContext(Web3Context); + const { address, self } = useContext(Web3Context); console.log({ address }); const router = useRouter(); const [imageURL, setImageURL] = useState(); @@ -101,7 +101,6 @@ const EditProfilePage = () => { .then(response => { return response.cids; }); - const refs = { image: image.current, background: background.current }; ["image", "background"].forEach(key => { console.log(cids[key]); diff --git a/packages/react-app/pages/profile/edit-public-profile.js b/packages/react-app/pages/profile/edit-public-profile.js index a5b9ce0..b11e39f 100644 --- a/packages/react-app/pages/profile/edit-public-profile.js +++ b/packages/react-app/pages/profile/edit-public-profile.js @@ -6,7 +6,6 @@ import { Divider, Input, Stack, - Image, Textarea, Tag, TagLabel, @@ -14,24 +13,16 @@ import { TagCloseButton, Box, HStack, - IconButton, } from "@chakra-ui/react"; -import React, { useCallback, useContext, useEffect, useRef, useState } from "react"; +import React, { useContext, useEffect } from "react"; import { useFieldArray, useForm } from "react-hook-form"; -import { EthereumAuthProvider, SelfID, WebClient } from "@self.id/web"; import { useRouter } from "next/router"; -import modelAliases from "../../model.json"; -import { ceramicCoreFactory, CERAMIC_TESTNET, CERAMIC_TESTNET_NODE_URL } from "../../ceramic"; import { Web3Context } from "../../helpers/Web3Context"; const EditPublicProfilePage = () => { - const { address, targetNetwork, self } = useContext(Web3Context); + const { self } = useContext(Web3Context); const router = useRouter(); - const [imageURL, setImageURL] = useState(); - const [backgroundURL, setBackgroundURL] = useState(); - const image = useRef(null); - const background = useRef(null); const { handleSubmit, register, @@ -94,7 +85,7 @@ const EditPublicProfilePage = () => { skillTags, experiences, }); - const me = await self.client.dataStore.get("publicProfile"); + await self.client.dataStore.get("publicProfile"); return router.push("/"); }; return (