Skip to content

Commit

Permalink
add optional chaining in MM response validation
Browse files Browse the repository at this point in the history
  • Loading branch information
rileydcampbell committed Jan 31, 2024
1 parent 68cd1ac commit 4ead407
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/entities/QuoteResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<QuoteRequestData, 'tokenInChainId' | 'tokenOutChainId' | 'amount' | 'type' | 'numOutputs'> {
Expand Down Expand Up @@ -54,16 +54,16 @@ export class QuoteResponse implements QuoteResponseData {
stripUnknown: true,
});

if (responseValidation.error) {
if (responseValidation?.error) {
validationError = {
message: responseValidation.error?.message,
value: data,
};
}

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}`,
Expand Down

0 comments on commit 4ead407

Please sign in to comment.