Skip to content

Commit

Permalink
fix: catch errors when ens lookup fails on address input
Browse files Browse the repository at this point in the history
  • Loading branch information
aeolianeth committed Sep 23, 2024
1 parent c23b15b commit 64897e3
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/inputs/EthAddressInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export function EthAddressInput({
async (address: string) => {
onChange?.(address)

const ensNameForAddress = await resolveAddress(address)
if (ensNameForAddress.name) {
const ensNameForAddress = await resolveAddress(address).catch(() => {}) // noop, ignore errors
if (ensNameForAddress?.name) {
setENSName(ensNameForAddress.name)
setAddressForENSName(address)
}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/api/auth/challenge-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ const WalletSigningRequestMessageTemplate = template(
*/
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
try {
if (req.method !== 'GET')
if (req.method !== 'GET') {
return res.status(405).json({ message: 'Method not allowed.' })
}

const { walletAddress } = req.query ?? {}
if (!walletAddress || typeof walletAddress !== 'string') {
return res.status(400).json({ message: 'Invalid request.' })
Expand Down
4 changes: 2 additions & 2 deletions src/pages/api/ens/resolve/[address].ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const logger = getLogger('api/ens/resolve/[address]')

const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method !== 'GET') {
return res.status(404)
return res.status(405).end()
}

try {
Expand All @@ -20,7 +20,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {

if (readNetwork.name === NetworkName.sepolia) {
// ethers v5 doesn't support ens on sepolia
return res.status(404).json({ error: 'ens not supported on sepolia' })
return res.status(400).json({ error: 'ens not supported on sepolia' })
}

let response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
enableCors(res)

if (req.method !== 'GET') {
return res.status(404)
return res.status(405).end()
}

try {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/juicebox/prices/ethusd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
enableCors(res)

if (req.method !== 'GET') {
return res.status(404)
return res.status(405).end()
}

try {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/juicebox/projectHandle/[projectId].ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const logger = getLogger('api/juicebox/projectHandle/[projectId]')

const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method !== 'GET') {
return res.status(404).json({ error: 'not found' })
return res.status(405).json({ error: 'method not supported' })
}

try {
Expand Down

0 comments on commit 64897e3

Please sign in to comment.