Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Commit

Permalink
Resolve lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhaiwat10 committed Nov 30, 2021
1 parent a11f5cd commit 86867b5
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 61 deletions.
4 changes: 3 additions & 1 deletion packages/react-app/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
};
10 changes: 4 additions & 6 deletions packages/react-app/helpers/Web3Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand Down Expand Up @@ -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 = (
<div style={{ zIndex: 2, position: "absolute", right: 0, top: 60, padding: 16 }}>
Expand Down Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-app/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions packages/react-app/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion packages/react-app/pages/api/image-storage.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
3 changes: 0 additions & 3 deletions packages/react-app/pages/api/json-storage.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-app/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 2 additions & 4 deletions packages/react-app/pages/profile/approval/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -92,7 +90,7 @@ function ApproveShareContactInformation() {
),
status: "success",
});
const receipt = await tx.wait();
await tx.wait();
toast({
title: "Approval transaction confirmed",
description: (
Expand Down
39 changes: 11 additions & 28 deletions packages/react-app/pages/profile/edit-private-profile.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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,
Expand All @@ -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);
}
Expand All @@ -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, [
Expand Down
3 changes: 1 addition & 2 deletions packages/react-app/pages/profile/edit-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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]);
Expand Down
15 changes: 3 additions & 12 deletions packages/react-app/pages/profile/edit-public-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,23 @@ import {
Divider,
Input,
Stack,
Image,
Textarea,
Tag,
TagLabel,
SimpleGrid,
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,
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit 86867b5

Please sign in to comment.