Skip to content

Commit

Permalink
fix: l2 to l1 bridge flow for listed tokens (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
marthendalnunes authored Apr 3, 2024
1 parent 32ece43 commit 06f1fdf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 0 additions & 2 deletions apps/website/app/(general)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -36,7 +35,6 @@ export default function HomePage() {
}>()

const { appMode } = useAppMode()
const tokenList = useTokenList()

// If the app mode changes, reset the selected token
useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
},
})
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,10 @@ export function FormSelectErc721TokenL2({
})

const onSubmit: SubmitHandler<FormData> = (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",
Expand Down

0 comments on commit 06f1fdf

Please sign in to comment.