import {activeCustomerSession,authBody,authFailure,AuthError} from '@/lib/customer-auth';
import {json} from '@/lib/server';
import {fundingReviewView,withdrawalInput} from '@/lib/funding-review';
import {fundingError} from '@/lib/wallet-funding';
import {fundingRpc} from '@/lib/wallet-funding-server';
export async function POST(request:Request){try{const body=await authBody(request),{token}=await activeCustomerSession(request);let params;try{params=withdrawalInput(body)}catch(error){const [message,status]=fundingError((error as Error).message);throw new AuthError(message,status)}return json(fundingReviewView(await fundingRpc('marketplace_withdrawal_request',params,token)))}catch(error){return authFailure(error)}}
