Skip to content
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
3 changes: 3 additions & 0 deletions src/app/api/chains/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,21 @@ export async function GET(request: Request) {

// Build query β€” fetch all, then filter after normalization
// (type filter can't be applied at DB level because stale rows have wrong types)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let query = supabase.from('cached_chains' as any).select('*')

if (hasUSDC) {
query = query.eq('has_usdc', true)
}

const { data, error } = await query.order('name')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const chains = data as any[] | null

// If cache has data, return it
if (!error && chains && chains.length > 0) {
// Map DB rows back to UnifiedChain shape, normalizing stale keys/types
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const chainMap = new Map<string, any>()

for (const c of chains) {
Expand Down
3 changes: 3 additions & 0 deletions src/app/api/stealth/claims/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ export async function GET(req: NextRequest) {
return NextResponse.json({ error: 'Failed to fetch claims' }, { status: 500 })
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const unclaimed = claims?.filter((c: any) => !c.claimed && c.amount_received > 0) || []
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const claimed = claims?.filter((c: any) => c.claimed) || []

return NextResponse.json({
unclaimed,
claimed,
total_unclaimed: unclaimed.length,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
total_claimable: unclaimed.reduce((sum: number, c: any) => sum + (c.amount_received || 0), 0),
})
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions src/app/api/transactions/[id]/hash/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ export async function PATCH(
}

const tx = data as TransactionRecord
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const metadata = (tx.route_details as any)?.metadata
const depositAddress = metadata?.depositAddress
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const bridge = (tx.route_details as any)?.routes?.[0]?.tool || tx.provider

// 2. Now trigger Inngest polling with the actual tx hash
Expand Down
1 change: 1 addition & 0 deletions src/app/api/transactions/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export async function GET(
}

// Clean response
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { payment_links, ...cleaned } = transaction
return NextResponse.json(cleaned)
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions src/app/api/transactions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export async function GET(req: NextRequest) {
}

// Clean response β€” remove the joined payment_links data
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const cleaned = transactions?.map((tx: any) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { payment_links, ...rest } = tx
return rest
}) || []
Expand Down
2 changes: 2 additions & 0 deletions src/app/api/v1/payment-links/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function GET(
}

const { id } = await params
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const supabase = createServerClient() as any

// Fetch payment link
Expand Down Expand Up @@ -71,6 +72,7 @@ export async function PATCH(
return NextResponse.json({ error: 'Invalid status' }, { status: 400 })
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const supabase = createServerClient() as any

const { data: link, error: updateError } = await supabase
Expand Down
5 changes: 4 additions & 1 deletion src/app/api/v1/payment-links/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function POST(req: NextRequest) {
let body
try {
body = await req.json()
} catch (e) {
} catch {
return NextResponse.json({ error: 'Invalid JSON request body' }, { status: 400 })
}

Expand All @@ -55,6 +55,7 @@ export async function POST(req: NextRequest) {

const data = validation.data

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const supabase = createServerClient() as any

// 3. Get merchant defaults
Expand Down Expand Up @@ -118,6 +119,7 @@ export async function POST(req: NextRequest) {
status_code: 201,
request_body: body,
ip_address: clientIp.split(',')[0]
// eslint-disable-next-line @typescript-eslint/no-explicit-any
}).then(({ error }: any) => {
if(error) console.error('Failed to log API call', error)
})
Expand Down Expand Up @@ -145,6 +147,7 @@ export async function GET(req: NextRequest) {
const limit = Math.min(parseInt(searchParams.get('limit') || '10'), 100)
const offset = parseInt(searchParams.get('offset') || '0')

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const supabase = createServerClient() as any

const { data: links, count, error: dbError } = await supabase
Expand Down
3 changes: 3 additions & 0 deletions src/app/api/v1/transactions/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function GET(
}

const { id } = await params
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const supabase = createServerClient() as any

// Fetch transaction with link verification
Expand All @@ -30,12 +31,14 @@ export async function GET(
}

// Verify ownership via payment link
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const txData = transaction as any
if (txData.payment_links?.merchant_id !== merchant.id) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 403 })
}

// Clean response
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { payment_links, ...cleanedTx } = txData

return NextResponse.json(cleanedTx)
Expand Down
3 changes: 3 additions & 0 deletions src/app/api/v1/transactions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export async function GET(req: NextRequest) {
const status = searchParams.get('status')
const paymentLinkId = searchParams.get('payment_link_id')

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const supabase = createServerClient() as any

// Build query
Expand All @@ -38,7 +39,9 @@ export async function GET(req: NextRequest) {
}

// Format for API response
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const formatted = transactions?.map((tx: any) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { payment_links, ...rest } = tx;
return rest;
});
Expand Down
3 changes: 2 additions & 1 deletion src/app/dashboard/links/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
ArrowLeft,
Loader2,
CheckCircle,
XCircle,
Clock,
ExternalLink,
QrCode
Expand Down Expand Up @@ -98,6 +97,7 @@ function LinksPageContent() {
if (!linkId) {
fetchLinks()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [linkId])

// Fetch Link Details if ID is present
Expand All @@ -107,6 +107,7 @@ function LinksPageContent() {
} else {
setSelectedLink(null)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [linkId])

async function fetchLinks() {
Expand Down
9 changes: 4 additions & 5 deletions src/app/dashboard/transactions/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@

import { useEffect, useState, use } from 'react'
import Link from 'next/link'
import { useParams, useRouter } from 'next/navigation'
import { useRouter } from 'next/navigation'
import { useAppKitAccount } from '@reown/appkit/react'
import {
ArrowLeft,
Loader2,
ExternalLink,
Copy,
CheckCircle,
XCircle,
Clock,
Share2
} from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { Separator } from '@/components/ui/separator'
import { Badge } from '@/components/ui/badge'
import { useToast } from '@/components/ui/use-toast'
Expand All @@ -37,6 +34,7 @@ interface TransactionDetails {
completed_at?: string
platform_fee?: number
actual_output?: number
// eslint-disable-next-line @typescript-eslint/no-explicit-any
metadata?: any
}

Expand All @@ -50,6 +48,7 @@ export default function TransactionDetailsPage({ params }: { params: Promise<{ i

useEffect(() => {
fetchTransactionDetails()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [resolvedParams.id])

async function fetchTransactionDetails() {
Expand Down
9 changes: 7 additions & 2 deletions src/lib/api/verify-api-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@ export async function verifyApiKey(req: NextRequest) {
return { error: 'Invalid API key format', status: 401 }
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const supabase = createServerClient() as any

// Get all merchants with API enabled
const prefix = apiKey.substring(0, 16)

// Get merchants with matching prefix and API enabled
const { data: merchants } = await supabase
.from('merchants')
.select('id, wallet_address, api_key_hash, api_enabled, api_total_calls')
.eq('api_enabled', true)
.eq('api_key_prefix', prefix)

if (!merchants || merchants.length === 0) {
return { error: 'Invalid API key', status: 401 }
}

// Check if key matches any merchant
// (Iterating to handle the extremely unlikely edge case of prefix collision)
for (const merchant of merchants) {
// Note: This iterates through all enabled merchants which is O(N) but acceptable for MVP
const isValid = await bcrypt.compare(apiKey, merchant.api_key_hash)

if (isValid) {
Expand All @@ -55,6 +59,7 @@ export async function verifyApiKey(req: NextRequest) {
status_code: 200, // Assumed success if we get here
ip_address: req.headers.get('x-forwarded-for') || 'unknown',
user_agent: req.headers.get('user-agent') || 'unknown'
// eslint-disable-next-line @typescript-eslint/no-explicit-any
}).then(({ error }: any) => {
if (error) console.error('Failed to log API request:', error)
})
Expand Down
Loading