Skip to content

Commit

Permalink
fix: get-orders return offerer -> swapper (#486)
Browse files Browse the repository at this point in the history
* fix get-orders return offerer -> swapper

* unused import
  • Loading branch information
ConjunctiveNormalForm authored Sep 11, 2024
1 parent 65cb6ba commit 56b00d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion lib/handlers/get-orders/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { GetOrdersResponse, GetOrdersResponseJoi } from './schema/GetOrdersRespo
import { GetPriorityOrderResponse } from './schema/GetPriorityOrderResponse'
import { GetRelayOrderResponse, GetRelayOrdersResponseJoi } from './schema/GetRelayOrderResponse'
import { GetOrdersQueryParams, GetOrdersQueryParamsJoi, RawGetOrdersQueryParams } from './schema/index'

export class GetOrdersHandler extends APIGLambdaHandler<
ContainerInjected,
RequestInjected,
Expand Down Expand Up @@ -77,7 +78,21 @@ export class GetOrdersHandler extends APIGLambdaHandler<

return {
statusCode: 200,
body: getOrdersResult,
body: {
// w/o specifying orderType, the orderDispatcher uses the legacy get implementation
// and for priority orders, the returned object will contain offerer instead of swapper
orders: getOrdersResult.orders.map((order: any) => {

Check warning on line 84 in lib/handlers/get-orders/handler.ts

View workflow job for this annotation

GitHub Actions / lint-and-test

Unexpected any. Specify a different type
if (order.offerer) {
const { offerer, ...rest } = order;
return {
...rest,
swapper: offerer
};
}
return order;
}),
cursor: getOrdersResult.cursor
},
}
} catch (e: unknown) {
// TODO: differentiate between input errors and add logging if unknown is not type Error
Expand Down
2 changes: 1 addition & 1 deletion test/unit/handlers/get-orders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ describe('Testing get orders handler.', () => {
headerExpectation.toAllowAllOrigin().toAllowCredentials().toReturnJsonContentType()
})

it('Testing valid PriorityOrder request and response.', async () => {
it('Testing valid request and response, Priority order', async () => {
const getOrdersHandler = (injectedMock = injectorPromiseMock) =>
new GetOrdersHandler('get-orders', injectedMock, mock<OrderDispatcher>())
getOrdersMock.mockReturnValue({
Expand Down

0 comments on commit 56b00d9

Please sign in to comment.