From 356da99ca5138a35c9403879784e983ab284d0bb Mon Sep 17 00:00:00 2001 From: "frankind.eth" <49823133+FrancoAguzzi@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:35:38 -0300 Subject: [PATCH 1/2] Create CODEOWNERS --- CODEOWNERS | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 00000000..b0269319 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,3 @@ +# Default owners for everything in the repo + +* @FrancoAguzzi @heronlancellot @eduramme From 103c9b1403d6171ad08873c986e22b02207c7571 Mon Sep 17 00:00:00 2001 From: "frankind.eth" Date: Wed, 7 Feb 2024 18:03:08 -0300 Subject: [PATCH 2/2] Configured ESLint --- .eslintrc.json => .eslintrc | 0 components/01-atoms/ConfirmSwapModal.tsx | 11 +- components/01-atoms/SearchBar.tsx | 8 +- components/01-atoms/SelectDestinyChain.tsx | 4 +- components/01-atoms/SwapContext.tsx | 8 +- .../01-atoms/TransactionResultModal.tsx | 10 +- components/02-molecules/CardHome.tsx | 2 +- components/02-molecules/NftCard.tsx | 63 +-- components/02-molecules/NftsList.tsx | 3 +- components/02-molecules/OfferSummary.tsx | 8 +- components/02-molecules/SwapStation.tsx | 2 +- components/02-molecules/TheHeader.tsx | 4 +- components/03-organisms/NftsShelf.tsx | 15 +- components/03-organisms/SwappingShelfs.tsx | 5 +- components/04-templates/Layout.tsx | 1 + lib/client/blockchain-data.ts | 6 +- lib/client/constants.ts | 1 + lib/client/hooks/useAuthedAccess.tsx | 3 +- lib/client/hooks/useAuthenticatedUser.tsx | 13 +- lib/client/hooks/useScreenSize.tsx | 2 +- lib/client/utils.ts | 2 + lib/wallet/wallet-config.ts | 2 +- package-lock.json | 398 +++++++++++++++++- package.json | 4 + pages/_app.tsx | 2 +- pages/swap.tsx | 2 +- 26 files changed, 472 insertions(+), 107 deletions(-) rename .eslintrc.json => .eslintrc (100%) diff --git a/.eslintrc.json b/.eslintrc similarity index 100% rename from .eslintrc.json rename to .eslintrc diff --git a/components/01-atoms/ConfirmSwapModal.tsx b/components/01-atoms/ConfirmSwapModal.tsx index f137efdb..5a488d14 100644 --- a/components/01-atoms/ConfirmSwapModal.tsx +++ b/components/01-atoms/ConfirmSwapModal.tsx @@ -1,5 +1,3 @@ -import { Dialog, Transition } from "@headlessui/react"; -import { Fragment, useContext, useEffect, useState } from "react"; import { NftCard, NftCardActionType, @@ -8,11 +6,10 @@ import { TransactionResultModal, } from "."; import { useAuthenticatedUser } from "@/lib/client/hooks/useAuthenticatedUser"; -import { makeSwap } from "@/lib/client/blockchain-data"; import { SWAPLACE_SMART_CONTRACT_ADDRESS } from "@/lib/client/constants"; +import { Dialog, Transition } from "@headlessui/react"; +import { Fragment, useContext, useEffect, useState } from "react"; import { useNetwork, useWalletClient } from "wagmi"; -import { getTimestamp } from "@/lib/client/utils"; -import { signTransaction } from "viem/actions"; import toast from "react-hot-toast"; interface ConfirmSwapModalProps { @@ -33,7 +30,7 @@ export enum TransactionResult { export const ConfirmSwapModal = ({ open, onClose }: ConfirmSwapModalProps) => { const { authenticatedUserAddress } = useAuthenticatedUser(); - const { nftInputUser, nftAuthUser, validatedAddressToSwap, destinyChain } = + const { nftInputUser, nftAuthUser, validatedAddressToSwap } = useContext(SwapContext); const [createOfferStatus, setCreateOfferStatus] = useState( @@ -61,7 +58,7 @@ export const ConfirmSwapModal = ({ open, onClose }: ConfirmSwapModalProps) => { chain && SWAPLACE_SMART_CONTRACT_ADDRESS[chain?.id]; if (swaplaceContractForCurrentChain && walletClient) { - const farFarInTheFuture = getTimestamp(chain.id); + // const farFarInTheFuture = getTimestamp(chain.id); setCreateOfferStatus(CreateOfferStatus.WAITING_WALLET_APPROVAL); walletClient diff --git a/components/01-atoms/SearchBar.tsx b/components/01-atoms/SearchBar.tsx index ff1c27ea..6b2b3171 100644 --- a/components/01-atoms/SearchBar.tsx +++ b/components/01-atoms/SearchBar.tsx @@ -1,5 +1,6 @@ -import cc from "classcat"; -import { useContext, useEffect, useState } from "react"; +/* eslint-disable react-hooks/exhaustive-deps */ +/* eslint-disable import/no-named-as-default-member */ +/* eslint-disable import/no-named-as-default */ import { MagnifyingGlassIcon, SelectAuthedUserChain, @@ -7,14 +8,15 @@ import { SwapContext, } from "."; import { useAuthenticatedUser } from "@/lib/client/hooks/useAuthenticatedUser"; +import { useContext, useEffect, useState } from "react"; import { ENS } from "web3-eth-ens"; +import cc from "classcat"; import Web3 from "web3"; export const SearchBar = () => { const { setInputAddress, inputAddress, - validatedAddressToSwap, validateAddressToSwap, userJustValidatedInput, } = useContext(SwapContext); diff --git a/components/01-atoms/SelectDestinyChain.tsx b/components/01-atoms/SelectDestinyChain.tsx index 171920e2..eacb8693 100644 --- a/components/01-atoms/SelectDestinyChain.tsx +++ b/components/01-atoms/SelectDestinyChain.tsx @@ -1,7 +1,7 @@ -import { Dialog, Transition } from "@headlessui/react"; -import { Fragment, useContext, useState } from "react"; import { EthereumIcon, PolygonIcon, SwapContext } from "."; import { ChainInfo, SupportedNetworks } from "@/lib/client/constants"; +import { Dialog, Transition } from "@headlessui/react"; +import { Fragment, useContext, useState } from "react"; import cc from "classcat"; export const SelectDestinyChain = () => { diff --git a/components/01-atoms/SwapContext.tsx b/components/01-atoms/SwapContext.tsx index 3e5c527b..919d36f6 100644 --- a/components/01-atoms/SwapContext.tsx +++ b/components/01-atoms/SwapContext.tsx @@ -1,7 +1,11 @@ -import React, { Dispatch, useEffect, useState } from "react"; -import toast from "react-hot-toast"; +/* eslint-disable react-hooks/exhaustive-deps */ +/* eslint-disable @typescript-eslint/no-empty-function */ +/* eslint-disable unused-imports/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import { ADDRESS_ZERO, NFT, SupportedNetworks } from "@/lib/client/constants"; import { EthereumAddress } from "@/lib/shared/types"; +import React, { Dispatch, useEffect, useState } from "react"; +import toast from "react-hot-toast"; interface SwapContextProps { inputAddress: string; diff --git a/components/01-atoms/TransactionResultModal.tsx b/components/01-atoms/TransactionResultModal.tsx index 464c8866..65401fe9 100644 --- a/components/01-atoms/TransactionResultModal.tsx +++ b/components/01-atoms/TransactionResultModal.tsx @@ -1,9 +1,9 @@ -import { Dialog, Transition } from "@headlessui/react"; import { TransactionResult } from "."; -import { Fragment, useState } from "react"; import LoadingIndicator from "./LoadingIndicator"; -import { CheckmarkIcon } from "react-hot-toast"; import { DangerIcon } from "./icons/DangerIcon"; +import { Dialog, Transition } from "@headlessui/react"; +import { CheckmarkIcon } from "react-hot-toast"; +import { Fragment, useState } from "react"; interface TransactionResultModalProps { onClose: () => void; @@ -14,12 +14,12 @@ export const TransactionResultModal = ({ transactionResult, onClose, }: TransactionResultModalProps) => { + const [open, setOpen] = useState(true); + if (!transactionResult) { return null; } - const [open, setOpen] = useState(true); - const closeModal = () => { setOpen(false); onClose(); diff --git a/components/02-molecules/CardHome.tsx b/components/02-molecules/CardHome.tsx index b102075c..f36f591b 100644 --- a/components/02-molecules/CardHome.tsx +++ b/components/02-molecules/CardHome.tsx @@ -1,5 +1,5 @@ -import React from "react"; import { ConnectWallet, SwaplaceIcon } from "@/components/01-atoms"; +import React from "react"; export const CardHome = () => { return ( diff --git a/components/02-molecules/NftCard.tsx b/components/02-molecules/NftCard.tsx index 182b6221..cf2b4f33 100644 --- a/components/02-molecules/NftCard.tsx +++ b/components/02-molecules/NftCard.tsx @@ -1,8 +1,9 @@ -import { NFT } from "@/lib/client/constants"; -import React, { useContext, useEffect, useState } from "react"; +/* eslint-disable react-hooks/exhaustive-deps */ import { SwapContext } from "../01-atoms"; +import { NFT } from "@/lib/client/constants"; import { useAuthenticatedUser } from "@/lib/client/hooks/useAuthenticatedUser"; import { EthereumAddress } from "@/lib/shared/types"; +import React, { useContext, useEffect, useState } from "react"; import cc from "classcat"; import toast from "react-hot-toast"; @@ -33,12 +34,38 @@ export const NftCard = ({ withSelectionValidation = true, onClickAction = NftCardActionType.SELECT_NFT_FOR_SWAP, }: INftCard) => { - if (!nftData || !nftData.id || !nftData.contract || !ownerAddress) - return null; - const { authenticatedUserAddress } = useAuthenticatedUser(); const { setNftAuthUser, setNftInputUser, nftAuthUser, nftInputUser } = useContext(SwapContext); + const [couldntLoadNftImage, setCouldntLoadNftImage] = useState(false); + const [currentNftIsSelected, setCurrentNftIsSelected] = useState(false); + + useEffect(() => { + setCouldntLoadNftImage(false); + }, [nftData]); + + useEffect(() => { + const currentNftIsFromAuthedUser = ownerAddress + ? authenticatedUserAddress?.equals(new EthereumAddress(ownerAddress)) + : null; + + if (currentNftIsFromAuthedUser) { + if (nftAuthUser.length) { + setCurrentNftIsSelected(nftAuthUser[0].id === nftData.id); + } else { + setCurrentNftIsSelected(false); + } + } else { + if (nftInputUser.length) { + setCurrentNftIsSelected(nftInputUser[0].id === nftData.id); + } else { + setCurrentNftIsSelected(false); + } + } + }, [authenticatedUserAddress, ownerAddress, nftAuthUser, nftInputUser]); + + if (!nftData || !nftData.id || !nftData.contract || !ownerAddress) + return null; const setNftAsActiveOne = () => { if (onClickAction === NftCardActionType.SELECT_NFT_FOR_SWAP) { @@ -65,36 +92,10 @@ export const NftCard = ({ } }; - const [currentNftIsSelected, setCurrentNftIsSelected] = useState(false); - useEffect(() => { - const currentNftIsFromAuthedUser = authenticatedUserAddress?.equals( - new EthereumAddress(ownerAddress) - ); - - if (currentNftIsFromAuthedUser) { - if (nftAuthUser.length) { - setCurrentNftIsSelected(nftAuthUser[0].id === nftData.id); - } else { - setCurrentNftIsSelected(false); - } - } else { - if (nftInputUser.length) { - setCurrentNftIsSelected(nftInputUser[0].id === nftData.id); - } else { - setCurrentNftIsSelected(false); - } - } - }, [authenticatedUserAddress, ownerAddress, nftAuthUser, nftInputUser]); - - const [couldntLoadNftImage, setCouldntLoadNftImage] = useState(false); const handleImageLoadError = () => { setCouldntLoadNftImage(true); }; - useEffect(() => { - setCouldntLoadNftImage(false); - }, [nftData]); - const ButtonLayout = (children: React.ReactNode) => { return (