Skip to content

Commit

Permalink
pre-filled form
Browse files Browse the repository at this point in the history
  • Loading branch information
ilge-ustun committed Mar 11, 2024
1 parent dfc4422 commit bd87fff
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion app/src/components/FaucetForm/Faucet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ function Faucet({ enabledTokens, chainId, setLoading }: FaucetProps): JSX.Elemen
useEffect(() => {
const handleResize = () => setWindowWidth(window.innerWidth)
window.addEventListener("resize", handleResize)

const searchParams = new URLSearchParams(window.location.search)
const addressFromURL = searchParams.get("address")
if (addressFromURL) {
setWalletAddress(addressFromURL)
}

return () => window.removeEventListener("resize", handleResize)
}, [])

Expand All @@ -40,7 +47,16 @@ function Faucet({ enabledTokens, chainId, setLoading }: FaucetProps): JSX.Elemen
name: enabledTokens[0].name,
maximumAmount: Number(enabledTokens[0].maximumAmount)
})
}
} else {
const defaultToken = enabledTokens.find(token => token.address === "0x0000000000000000000000000000000000000000")
if (defaultToken !== undefined) {
setToken({
address: defaultToken.address,
name: defaultToken.name,
maximumAmount: Number(defaultToken.maximumAmount)
})
}
}
}, [enabledTokens.length])

function formatErrors(errors: string[]) {
Expand Down

0 comments on commit bd87fff

Please sign in to comment.