Skip to content

Commit 24ed25f

Browse files
committed
fix(miles): lowercase address before hitting Fuul totals endpoint
Wagmi's useAccount returns EIP-55 checksummed (mixed-case) addresses, which Fuul's /payouts/totals/{address} 404s on — Fuul keys records by lowercase address (their leaderboard endpoint returns lowercase wallets, confirming the normalization). The 404 caused payoutPoints to fall back to 0 even for wallets with existing credits. Also reverts the previous '404 → 0' normalization, which would silently zero out a real total whenever the leaderboard cache lacked the user.
1 parent 6077b5e commit 24ed25f

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

src/app/api/fuul/payouts/route.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ export async function GET(request: NextRequest) {
2222
)
2323
}
2424

25-
const url = `${FUUL_TOTALS_URL}/${encodeURIComponent(address)}`
25+
// Fuul stores/keys addresses in lowercase (their leaderboard endpoint
26+
// returns lowercase wallets). A checksummed mixed-case lookup against
27+
// /payouts/totals/{address} 404s even when the wallet has credits, so
28+
// always normalize before hitting Fuul.
29+
const url = `${FUUL_TOTALS_URL}/${encodeURIComponent(address.toLowerCase())}`
2630

2731
const response = await fetch(url, {
2832
method: "GET",
@@ -33,12 +37,6 @@ export async function GET(request: NextRequest) {
3337
})
3438

3539
if (!response.ok) {
36-
// 404 just means Fuul has no payout record for this address yet —
37-
// either the wallet has never been credited, or the most recent
38-
// settlement hasn't been indexed by Fuul's ETL yet. Treat as 0.
39-
if (response.status === 404) {
40-
return NextResponse.json({ success: true, data: null, totalPoints: 0 }, { status: 200 })
41-
}
4240
const errorText = await response.text()
4341
console.error("Fuul API error:", response.status, errorText)
4442
return NextResponse.json(

0 commit comments

Comments
 (0)