I see the issue. The deposit processor has a simulated delay of 3-5 seconds, which is reasonable. But you mentioned it's taking much longer than 2-3 minutes. The UI might be polling for updates. Let me check the crypto wallet component to see how it handles transaction status updates:
I see the issue now. The deposit processor has a short delay (3-5 seconds), but you said it's taking minutes. The problem might be that the request is timing out or the process is somehow being delayed. Let me reduce the simulated delay to make deposits complete much faster (1-2 seconds instead of 3-5):
Now let me also check the withdraw processor and update it similarly:
I've reduced the simulated processing delay for both deposits and withdrawals from 3-5 seconds to 1-2 seconds. Transactions should now complete within a few seconds and the UI will pick up the changes via the 2-second polling interval. The total time from initiating a deposit to seeing it complete should now be under 5 seconds.
Now I see the issue. Looking at the logs, I can see the polling is happening (getOrCreateWallet and getTransactions every 2 seconds), but I don't see any calls to initiateDeposit, process-deposit, or the webhook/deposit endpoint. This means the deposit process isn't being triggered or the webhooks aren't being called.
The problem is likely that the fetch call to /api/process-deposit from the server action is using "fire and forget" pattern, but the fetch might be failing silently. Let me check the wallet actions to see how deposits are initiated:
Now I see the issue. The "fire and forget" fetch call is problematic because in serverless environments, the function can return before the fetch completes, and Next.js server actions can terminate the process. The fetch is being dropped before it completes.
I need to change the approach - instead of firing off separate API calls, I'll process the deposit directly in the server action itself and use a simulated delay inline. This will be much more reliable:
Now let me also fix the withdrawal to use the same inline processing approach:
Now let me fix the withdrawal function to use inline processing as well:
Now let me also remove the unused getBaseUrl function since we no longer need it:
I've completely rewritten the deposit and withdrawal processing logic. Instead of using "fire and forget" fetch calls to separate API endpoints (which were being dropped before completion in the serverless environment), the processing now happens inline within the server actions themselves. This means:
Transactions should now complete within 2-3 seconds instead of hanging indefinitely.