File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { Network } from 'types' ;
21import {
32 usdcBigIntToDecimal ,
43 decimalToUsdcBigInt ,
@@ -10,9 +9,11 @@ import { USDC_ADDRESS } from 'services/fund-repo/constants';
109import { FacilitatorClient } from 'services/facilitator/facilitatorService' ;
1110import {
1211 ExactEvmPayload ,
12+ ExactEvmPayloadSchema ,
1313 PaymentPayload ,
1414 PaymentRequirementsSchema ,
1515 SettleRequestSchema ,
16+ Network ,
1617} from 'services/facilitator/x402-types' ;
1718import { Decimal } from '@prisma/client/runtime/library' ;
1819import logger from 'logger' ;
@@ -44,8 +45,16 @@ export async function settle(
4445 return undefined ;
4546 }
4647
47- const payload = xPaymentData . payload as ExactEvmPayload ;
48- logger . info ( `Payment payload: ${ JSON . stringify ( payload ) } ` ) ;
48+ const payloadResult = ExactEvmPayloadSchema . safeParse ( xPaymentData . payload ) ;
49+ if ( ! payloadResult . success ) {
50+ logger . error ( 'Invalid ExactEvmPayload in settle' , {
51+ error : payloadResult . error ,
52+ payload : xPaymentData . payload ,
53+ } ) ;
54+ buildX402Response ( req , res , maxCost ) ;
55+ return undefined ;
56+ }
57+ const payload = payloadResult . data ;
4958
5059 const paymentAmount = payload . authorization . value ;
5160 const paymentAmountDecimal = usdcBigIntToDecimal ( paymentAmount ) ;
Original file line number Diff line number Diff line change @@ -261,9 +261,9 @@ export class EchoControlService {
261261 ? applyEchoMarkup ( transaction . rawTransactionCost )
262262 : new Decimal ( 0 ) ;
263263
264- const totalTransactionCostDecimal = transaction . rawTransactionCost . plus (
265- totalAppProfitDecimal
266- ) . plus ( echoProfitDecimal ) ;
264+ const totalTransactionCostDecimal = transaction . rawTransactionCost
265+ . plus ( totalAppProfitDecimal )
266+ . plus ( echoProfitDecimal ) ;
267267
268268 // Return Decimal values directly
269269 return {
You can’t perform that action at this time.
0 commit comments