Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/ens name #422

Open
wants to merge 45 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
406f34b
feat: add h-full into swap-section
heronlancellot Sep 19, 2024
ebc5733
fix: remove ens searched address
heronlancellot Sep 19, 2024
73162ca
fix: commented sections and add documentation about ens-name-address
heronlancellot Sep 19, 2024
7ba9d5a
Update components/01-atoms/ENSAvatar.tsx
heronlancellot Sep 20, 2024
280c696
Update components/01-atoms/ENSAvatar.tsx
heronlancellot Sep 20, 2024
f64f7c3
Update components/02-molecules/UserOfferInfo.tsx
heronlancellot Sep 20, 2024
8e8bdbe
Update components/01-atoms/ENSAvatar.tsx
heronlancellot Sep 20, 2024
a70daeb
Update components/01-atoms/SearchBar.tsx
heronlancellot Sep 20, 2024
be10d92
Update components/02-molecules/UserOfferInfo.tsx
heronlancellot Sep 20, 2024
ff85adc
fix: comment text
heronlancellot Sep 20, 2024
88078a7
fix: comment text
heronlancellot Sep 20, 2024
995f856
Update components/01-atoms/ENSAvatar.tsx
heronlancellot Sep 20, 2024
8805899
Update components/01-atoms/SearchBar.tsx
heronlancellot Sep 20, 2024
c3a6bc1
Update components/01-atoms/SearchBar.tsx
heronlancellot Sep 20, 2024
dc4300f
Update components/01-atoms/index.ts
heronlancellot Sep 20, 2024
a4d04b2
Update components/01-atoms/SearchBar.tsx
heronlancellot Sep 20, 2024
5410490
Update components/01-atoms/SearchBar.tsx
heronlancellot Sep 20, 2024
1c87f74
Update components/01-atoms/SearchBar.tsx
heronlancellot Sep 20, 2024
0f9b7ea
Update components/01-atoms/ENSAvatar.tsx
heronlancellot Sep 24, 2024
ef4854e
Update components/01-atoms/ENSAvatar.tsx
heronlancellot Sep 24, 2024
d0b9d78
Update components/01-atoms/ENSAvatar.tsx
heronlancellot Sep 24, 2024
12716a1
Update components/01-atoms/ENSAvatar.tsx
heronlancellot Sep 24, 2024
5623181
Update components/01-atoms/SearchBar.tsx
heronlancellot Sep 24, 2024
469c6eb
Update components/01-atoms/SearchBar.tsx
heronlancellot Sep 24, 2024
021a569
Update components/01-atoms/SearchBar.tsx
heronlancellot Sep 24, 2024
2441ff8
Update components/01-atoms/SearchBar.tsx
heronlancellot Sep 24, 2024
c169cb1
Update components/01-atoms/SearchBar.tsx
heronlancellot Sep 24, 2024
09d5093
Update components/02-molecules/EnsNameAndAddressWallet.tsx
heronlancellot Sep 24, 2024
4599dc6
Update components/02-molecules/OfferSummary.tsx
heronlancellot Sep 24, 2024
3ee2958
Update components/02-molecules/TheHeader.tsx
heronlancellot Sep 24, 2024
d478d30
Update components/02-molecules/UserOfferInfo.tsx
heronlancellot Sep 24, 2024
8cde85a
Update components/02-molecules/UserOfferInfo.tsx
heronlancellot Sep 24, 2024
dd9fb72
Update components/02-molecules/UserOfferInfo.tsx
heronlancellot Sep 24, 2024
a2993c0
Update components/02-molecules/UserOfferInfo.tsx
heronlancellot Sep 24, 2024
16e14cc
Update components/02-molecules/UserOfferInfo.tsx
heronlancellot Sep 24, 2024
6ab76c3
Update components/02-molecules/UserOfferInfo.tsx
heronlancellot Sep 24, 2024
36de969
update: SearchBar comments
heronlancellot Sep 24, 2024
356585c
update: comments
heronlancellot Sep 24, 2024
bec62ed
update: comments
heronlancellot Sep 24, 2024
8b510c4
update: comments
heronlancellot Sep 24, 2024
8da92a0
update: comments
heronlancellot Sep 24, 2024
d79539d
update: comments
heronlancellot Sep 24, 2024
f659bcd
update: comments
heronlancellot Sep 24, 2024
c6edfd2
Update components/01-atoms/SearchBar.tsx
heronlancellot Sep 24, 2024
38666df
Update components/02-molecules/EnsNameAndAddressWallet.tsx
heronlancellot Sep 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions components/01-atoms/ENSAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
/**
* @deprecated This component is deprecated because the searched ENS address
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved
* sometimes returns incorrect results, which negatively impacts the user flow
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved
* of the application.
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved
*
* The `ENSAvatar` component is responsible for displaying an Ethereum Name Service (ENS)
* avatar based on the provided ENS address. It supports two sizes: small and medium.
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved
*
* The component uses the `useEnsData` hook to fetch the avatar data. Depending on the
* status of the query, it either shows a loading indicator, an error icon, or the
* fetched avatar image.
*
* @component
* @param {EthereumAddress} avatarENSAddress - The ENS address to fetch the avatar for.
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved
* @param {ENSAvatarSize} [size=ENSAvatarSize.MEDIUM] - The size of the avatar to display.
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved
*
* @returns {JSX.Element} The rendered ENS avatar component.
*/
/* eslint-disable react-hooks/exhaustive-deps */

/**
import { LoadingIndicator, PersonIcon } from "@/components/01-atoms";
import {
ENSAvatarQueryStatus,
Expand Down Expand Up @@ -101,3 +121,5 @@ export const ENSAvatar = ({
</div>
);
};

*/
33 changes: 25 additions & 8 deletions components/01-atoms/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,35 @@ import { ForWhom } from "../03-organisms";
import { MagnifyingGlassIcon } from "@/components/01-atoms";
import { EthereumAddress } from "@/lib/shared/types";
import { ADDRESS_ZERO } from "@/lib/client/constants";
import { normalizeENSName } from "@/lib/client/blockchain-utils";
/* import { normalizeENSName } from "@/lib/client/blockchain-utils"; */
import { SwapContext } from "@/lib/client/contexts";
import { useContext, useEffect } from "react";
/**
import { ENS } from "web3-eth-ens";
import Web3 from "web3";
*/
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved
import toast from "react-hot-toast";

/**
*
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved
* These sections are currently commented out because the `ens-avatar-searched-address` has issues fetching the correct address.
* Since the ENS are not working properly. We're commenting those sections.
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved
*/

export const SearchBar = () => {
if (!process.env.NEXT_PUBLIC_ALCHEMY_ETHEREUM_HTTP) {
throw new Error(
"Cannot get the ENS primary name`s address without an Alchemy API Key",
);
}
const provider = new Web3.providers.HttpProvider(
process.env.NEXT_PUBLIC_ALCHEMY_ETHEREUM_HTTP,
);
const ens = new ENS(undefined, provider);
/**

const provider = new Web3.providers.HttpProvider(
process.env.NEXT_PUBLIC_ALCHEMY_ETHEREUM_HTTP,
);
const ens = new ENS(undefined, provider);
*
*/
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved

const {
lastWalletConnected,
Expand Down Expand Up @@ -75,19 +87,24 @@ export const SearchBar = () => {

const getUserAddress = async () => {
if (lastWalletConnected && inputAddress.length > 2) {
const _inputAddress = inputAddress;
const formattedAddress = normalizeENSName(inputAddress);
/**
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved
const _inputAddress = inputAddress;
const formattedAddress = normalizeENSName(inputAddress);
*/
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved

try {
/**
const address: unknown = await ens.getOwner(formattedAddress);
if (typeof address !== "string") {
toast.error(
"Wrong type of address returned by provider. Please contact the team",
);
return;
}
*/
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved

validateAddressToSwap(
address === ADDRESS_ZERO ? _inputAddress : address,
inputAddress !== ADDRESS_ZERO ? inputAddress : ADDRESS_ZERO,
);
} catch (error) {
toast.error("Invalid Ethereum Address");
Expand Down
2 changes: 1 addition & 1 deletion components/01-atoms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export * from "./ApproveTokenCards";
export * from "./BlockExplorerExternalLinkButton";
export * from "./ConnectWallet";
export * from "./DisconnectWallet";
export * from "./ENSAvatar";
// export * from "./ENSAvatar";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment in here as well

heronlancellot marked this conversation as resolved.
Show resolved Hide resolved
export * from "./LoadingIndicator";
export * from "./NetworkDropdown";
export * from "./MobileNotSupported";
Expand Down
28 changes: 23 additions & 5 deletions components/02-molecules/EnsNameAndAddressWallet.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
/**
* Component that displays the authenticated user's ENS name and address wallet.
*
* This component utilizes the `useAuthenticatedUser` hook to retrieve the authenticated user's address.
* It also includes commented sections that are intended for future use with ENS (Ethereum Name Service) data.
*
* The commented sections include:
* - `useEnsData` hook: This hook is used to fetch ENS data, such as the primary name associated with an address.
* - `ENSAvatar` component: This component is used to display the ENS avatar for a given address.
*
* These sections are currently commented out because the `ens-avatar-searched-address` has issues fetching the correct address.
*
* The component renders a copy address button and a block explorer external link button if the authenticated user's address is available.
*
*/

import { CopyAdressButton } from "@/components/02-molecules";
import {
BlockExplorerExternalLinkButton,
ENSAvatar,
/*ENSAvatar */
} from "@/components/01-atoms";
import { useAuthenticatedUser } from "@/lib/client/hooks/useAuthenticatedUser";
import { useEnsData } from "@/lib/client/hooks/useENSData";
/*import { useEnsData } from "@/lib/client/hooks/useENSData";*/

export const EnsNameAndAddressWallet = () => {
const { authenticatedUserAddress } = useAuthenticatedUser();

/**
const { primaryName } = useEnsData({
ensAddress: authenticatedUserAddress,
});
Comment on lines 28 to 30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is missing documentation on why it is commented out

*/

if (!authenticatedUserAddress) return null;

Expand All @@ -21,17 +39,17 @@ export const EnsNameAndAddressWallet = () => {
<div className="flex gap-3 pb-5">
{authenticatedUserAddress && (
<>
<ENSAvatar avatarENSAddress={authenticatedUserAddress} />
{/* <ENSAvatar avatarENSAddress={authenticatedUserAddress} /> */}
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved
<div className="flex flex-col">
<div className="flex items-center justify-start gap-2">
{primaryName && (
{/* {primaryName && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment section can reproduce the method of commenting deprecated feature that the other sections received! Please go ahead and do so 🧑🏼‍💻👊🏼🧑🏼‍💻

<>
<h3 className="text-sm ">{`${primaryName}`}</h3>
<h3 className="text-sm text-softGray dark:text-mediumGray">
|
</h3>
</>
)}
)} */}
<CopyAdressButton
authenticatedUserAddress={authenticatedUserAddress.toString()}
displayAddress={displayAddress}
Expand Down
60 changes: 43 additions & 17 deletions components/02-molecules/OfferSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ForWhom } from "../03-organisms";
import { ENSAvatar, ENSAvatarSize, PersonIcon } from "@/components/01-atoms";
import { PersonIcon } from "@/components/01-atoms";
import {
EtherFieldAddition,
TokenCardStyleType,
Expand All @@ -8,9 +8,33 @@ import {
import { ADDRESS_ZERO } from "@/lib/client/constants";
import { SwapContext } from "@/lib/client/contexts";
import { useAuthenticatedUser } from "@/lib/client/hooks/useAuthenticatedUser";
import { useEnsData } from "@/lib/client/hooks/useENSData";
// import { useEnsData } from "@/lib/client/hooks/useENSData";
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved
import { useContext } from "react";

/**
* OfferSummary component displays a summary of token offers for a given user.
*
* @param {Object} props - The properties object.
* @param {ForWhom} props.variant - Specifies whether the summary is for the authenticated user or another user.
*
* @returns {JSX.Element} The rendered OfferSummary component.
*
* @remarks
* This component uses the `SwapContext` to fetch the necessary data for rendering the token offers.
* It also utilizes the `useAuthenticatedUser` hook to get the authenticated user's address.
*
* The component conditionally renders different sections based on the `variant` prop:
* - If `variant` is `ForWhom.Yours`, it displays the authenticated user's token offers.
* - If `variant` is `ForWhom.Their`, it displays the searched user's token offers.
*
* The ENS-related sections are currently commented out due to issues with fetching the correct ENS address.
* These sections include:
* - Displaying the ENS avatar for the searched address.
* - Displaying the ENS name for the searched address.
*
* These sections are currently commented out because the `ens-avatar-searched-address` has issues fetching the correct address.
* Since the ENS are not working properly. We're commenting those sections.
*/
export const OfferSummary = ({ variant }: { variant: ForWhom }) => {
const {
validatedAddressToSwap,
Expand All @@ -24,20 +48,22 @@ export const OfferSummary = ({ variant }: { variant: ForWhom }) => {
? authenticatedUserTokensList
: searchedUserTokensList;

/**
const { primaryName: searchedENSName } = useEnsData({
ensAddress: validatedAddressToSwap,
});
const { primaryName: authenticatedUserENSName } = useEnsData({
ensAddress: authenticatedUserAddress,
});
*/

return (
<div className="w-full h-full dark:bg-darkGreen border dark:border-darkGray bg-[#F0EEEE] borderlightSilver rounded-lg ">
<div className="flex flex-col gap-4 px-4 pt-2 pb-4">
<div className="flex justify-between items-center h-9 gap-2">
<div className="flex space-x-2 items-center">
<div className="flex items-center">
{variant === ForWhom.Their && validatedAddressToSwap ? (
{/* {variant === ForWhom.Their && validatedAddressToSwap ? (
<ENSAvatar
avatarENSAddress={validatedAddressToSwap}
size={ENSAvatarSize.SMALL}
Expand All @@ -47,22 +73,22 @@ export const OfferSummary = ({ variant }: { variant: ForWhom }) => {
avatarENSAddress={authenticatedUserAddress}
size={ENSAvatarSize.SMALL}
/>
) : (
<div className="bg-lightSilver dark:bg-darkGray p-[5px] rounded-md">
<PersonIcon
size="14"
className="text-sageGray dark:text-mediumGray"
/>
</div>
)}
) : ( */}
<div className="bg-lightSilver dark:bg-darkGray p-[5px] rounded-md">
<PersonIcon
size="14"
className="text-sageGray dark:text-mediumGray"
/>
</div>
{/* )} */}
</div>
<div className="items-center">
<p className="p-small-variant-black-3 dark:p-small-variant-light-2 contrast-50">
{variant === ForWhom.Their && validatedAddressToSwap
? `${
searchedENSName
? `${searchedENSName} offers`
: validatedAddressToSwap
// searchedENSName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the other comment syntax

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// ? `${searchedENSName} offers`
validatedAddressToSwap
? `${
validatedAddressToSwap.address === ADDRESS_ZERO
? "Any user offers"
Expand All @@ -75,9 +101,9 @@ export const OfferSummary = ({ variant }: { variant: ForWhom }) => {
? "They offer"
: variant === ForWhom.Yours && authenticatedUserAddress
? `${
authenticatedUserENSName
? `${authenticatedUserENSName} offers`
: authenticatedUserAddress
// authenticatedUserENSName
// ? `${authenticatedUserENSName} offers`
authenticatedUserAddress
? `${authenticatedUserAddress.getEllipsedAddress()} offers`
: "Connect your wallet"
}`
Expand Down
12 changes: 9 additions & 3 deletions components/02-molecules/TheHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { useScreenSize } from "@/lib/client/hooks/useScreenSize";
import { useAuthenticatedUser } from "@/lib/client/hooks/useAuthenticatedUser";
import {
ConnectWallet,
ENSAvatar,
// ENSAvatar,
MoonIcon,
NetworkDropdown,
NetworkVariantPosition,
PersonIcon,
SunIcon,
SwaplaceIcon,
SwappingIcons,
Expand Down Expand Up @@ -93,9 +94,14 @@ export const TheHeader = () => {
<Tooltip position={"left"} content={"Your wallet"}>
<button
onClick={() => toggleSidebar()}
className="rounded-[10px] flex items-center justify-center"
className="rounded-[10px] flex items-center justify-center w-full h-full"
>
<ENSAvatar avatarENSAddress={authenticatedUserAddress} />
{/*This section is commented because the ENS-AVATAR is not working properly since the searched address by ens not working correctly. Check more about in useENSData file. */}
heronlancellot marked this conversation as resolved.
Show resolved Hide resolved
{/* <ENSAvatar avatarENSAddress={authenticatedUserAddress} /> */}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well, adding a comment on why this is out

<PersonIcon
size={"20"}
className="h-full items-center justify-center flex w-full p-2 text-sageGray dark:text-mediumGray"
/>
</button>
</Tooltip>
) : (
Expand Down
Loading