From 06f1fdf177d40c296b13ec91857c2c8201768e6d Mon Sep 17 00:00:00 2001 From: Vitor Marthendal Nunes Date: Wed, 3 Apr 2024 15:57:58 -0300 Subject: [PATCH] fix: l2 to l1 bridge flow for listed tokens (#6) --- apps/website/app/(general)/page.tsx | 2 -- .../blockchain/erc721/erc721-collection-selector.tsx | 4 +++- .../components/forms/form-select-erc721-token-l2.tsx | 6 +----- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/apps/website/app/(general)/page.tsx b/apps/website/app/(general)/page.tsx index 04adec4..75884f0 100644 --- a/apps/website/app/(general)/page.tsx +++ b/apps/website/app/(general)/page.tsx @@ -5,7 +5,6 @@ import { l2NetworksOptions } from "@/data/networks/options" import { LuBadgePlus, LuGanttChart, LuPalette } from "react-icons/lu" import { type Address } from "viem" -import { useTokenList } from "@/lib/hooks/use-token-list" import { useAppMode } from "@/lib/state/app-mode" import { cn } from "@/lib/utils" import { Button } from "@/components/ui/button" @@ -36,7 +35,6 @@ export default function HomePage() { }>() const { appMode } = useAppMode() - const tokenList = useTokenList() // If the app mode changes, reset the selected token useEffect(() => { diff --git a/apps/website/components/blockchain/erc721/erc721-collection-selector.tsx b/apps/website/components/blockchain/erc721/erc721-collection-selector.tsx index e218d0b..31c4e29 100644 --- a/apps/website/components/blockchain/erc721/erc721-collection-selector.tsx +++ b/apps/website/components/blockchain/erc721/erc721-collection-selector.tsx @@ -75,12 +75,14 @@ export function Erc721CollectionSelector({ const getOtimismMintableERC721ByLocalTokenQuery = useGetOtimismMintableERC721ByLocalTokenQuery({ + chainId, localToken: isAddress(selectedUnlistedToken ?? searchValue) ? checksumAddress(selectedUnlistedToken ?? (searchValue as Address)) : "0x0", query: { enabled: Boolean(chainType === "L2") && + Boolean(chainId) && (isAddress(searchValue) || Boolean(selectedUnlistedToken)), }, }) @@ -259,7 +261,7 @@ export function Erc721CollectionSelector({ handleSelect(tokenAddress) setSelectedUnlistedToken(undefined) setDestinationNetwork?.(undefined) - setRemoteToken?.(undefined) + setRemoteToken?.(token.address as Address) setTokenMetadata?.({ logoURI: selectedTokenData?.logoURI, name: selectedTokenData?.name ?? undefined, diff --git a/apps/website/components/forms/form-select-erc721-token-l2.tsx b/apps/website/components/forms/form-select-erc721-token-l2.tsx index 79d9e84..d37831d 100644 --- a/apps/website/components/forms/form-select-erc721-token-l2.tsx +++ b/apps/website/components/forms/form-select-erc721-token-l2.tsx @@ -105,14 +105,10 @@ export function FormSelectErc721TokenL2({ }) const onSubmit: SubmitHandler = (data) => { - const remoteToken = tokenList.tokens.find( - ({ address }) => address.toLowerCase() === data.localToken.toLowerCase() - )?.extensions?.bridgeInfo?.[data?.sourceNetwork]?.tokenAddress as Address - onTokenSelected?.({ localToken: data.localToken, tokenId: data.tokenId, - remoteToken: data.remoteToken ?? remoteToken, + remoteToken: data.remoteToken ?? "", sourceNetwork: data.sourceNetwork, name: data.name ?? "", logoURI: data.logoURI ?? "/logo.svg",