From 4ead407bd18962cd021b66effb796fdc4b1c08f5 Mon Sep 17 00:00:00 2001 From: Riley Campbell Date: Wed, 31 Jan 2024 12:38:15 -0500 Subject: [PATCH] add optional chaining in MM response validation --- lib/entities/QuoteResponse.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/entities/QuoteResponse.ts b/lib/entities/QuoteResponse.ts index 62b986b6..050bcf8f 100644 --- a/lib/entities/QuoteResponse.ts +++ b/lib/entities/QuoteResponse.ts @@ -2,9 +2,9 @@ import { TradeType } from '@uniswap/sdk-core'; import { BigNumber } from 'ethers'; import { v4 as uuidv4 } from 'uuid'; -import { QuoteRequestData } from '.'; import { PostQuoteResponse, RfqResponse, RfqResponseJoi } from '../handlers/quote/schema'; import { currentTimestampInMs, timestampInMstoSeconds } from '../util/time'; +import { QuoteRequestData } from '.'; export interface QuoteResponseData extends Omit { @@ -54,7 +54,7 @@ export class QuoteResponse implements QuoteResponseData { stripUnknown: true, }); - if (responseValidation.error) { + if (responseValidation?.error) { validationError = { message: responseValidation.error?.message, value: data, @@ -62,8 +62,8 @@ export class QuoteResponse implements QuoteResponseData { } if ( - request.tokenIn.toLowerCase() !== data.tokenIn.toLowerCase() || - request.tokenOut.toLowerCase() !== data.tokenOut.toLowerCase() + request?.tokenIn?.toLowerCase() !== data?.tokenIn?.toLowerCase() || + request?.tokenOut?.toLowerCase() !== data?.tokenOut?.toLowerCase() ) { validationError = { message: `RFQ response token mismatch: request tokenIn: ${request.tokenIn} tokenOut: ${request.tokenOut} response tokenIn: ${data.tokenIn} tokenOut: ${data.tokenOut}`,