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: l2 to l1 bridge flow for listed tokens #6

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading