Skip to content
Closed
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: 1 addition & 1 deletion src/app/api/v1/payment-links/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export async function POST(req: NextRequest) {
method: 'POST',
status_code: 201,
request_body: body,
ip_address: clientIp.split(',')[0]
ip_address: clientIp.split(',')[0].trim()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚑ Flash Review

πŸ› Bugs: The clientIp variable might be null or undefined if the IP address cannot be determined, which would cause split() to throw a runtime error before .trim() is called. This could lead to unhandled exceptions in a critical API route.

Fix: Add a nullish coalescing operator or a check to safely handle potentially undefined clientIp:

ip_address: (clientIp?.split(',')[0] || 'unknown').trim()

// eslint-disable-next-line @typescript-eslint/no-explicit-any
}).then(({ error }: any) => {
if(error) console.error('Failed to log API call', error)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/api/verify-api-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function verifyApiKey(req: NextRequest) {
endpoint: req.nextUrl.pathname,
method: req.method,
status_code: 200, // Assumed success if we get here
ip_address: req.headers.get('x-forwarded-for') || 'unknown',
ip_address: (req.headers.get('x-forwarded-for') || 'unknown').split(',')[0].trim(),
user_agent: req.headers.get('user-agent') || 'unknown'
// eslint-disable-next-line @typescript-eslint/no-explicit-any
}).then(({ error }: any) => {
Expand Down
34 changes: 16 additions & 18 deletions src/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,22 @@ const solanaAdapter = new SolanaAdapter({
})

// Initialize AppKit modal (runs once at module load)
if (projectId) {
createAppKit({
adapters: [wagmiAdapter, solanaAdapter],
projectId,
networks: mainnetNetworks as [AppKitNetwork, ...AppKitNetwork[]],
defaultNetwork: allNetworks.mainnet,
metadata: {
name: 'Flash Protocol',
description: 'Cross-chain payment gateway',
url: typeof window !== 'undefined' ? window.location.origin : 'https://flashprotocol.com',
icons: ['/logo-black.png'],
},
features: {
analytics: false,
},
themeMode: 'dark',
})
}
createAppKit({
adapters: [wagmiAdapter, solanaAdapter],
projectId: projectId || 'fallback-project-id', // Ensure AppKit initializes even if NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID is missing during build time
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚑ Flash Review

πŸ› Bug: Using a generic 'fallback-project-id' will almost certainly cause WalletConnect to fail initialization or connection attempts, preventing users from connecting their wallets and making payments. WalletConnect Project IDs are mandatory and must be valid for the service to function.

Fix: Ensure the NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID environment variable is always set and valid. If it's critical for the application to run, consider a build-time check or an explicit error message if it's missing, rather than a silent fallback that leads to non-functional UI.

networks: mainnetNetworks as [AppKitNetwork, ...AppKitNetwork[]],
defaultNetwork: allNetworks.mainnet,
metadata: {
name: 'Flash Protocol',
description: 'Cross-chain payment gateway',
url: typeof window !== 'undefined' ? window.location.origin : 'https://flashprotocol.com',
icons: ['/logo-black.png'],
},
features: {
analytics: false,
},
themeMode: 'dark',
})

export function Providers({ children }: { children: ReactNode }) {
return (
Expand Down
Loading