Skip to content

Commit

Permalink
feat: list offramp swap transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
okjodom committed Nov 2, 2024
1 parent 0aef221 commit 52edb3a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
7 changes: 7 additions & 0 deletions apps/api/src/swap/swap.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,11 @@ describe('SwapController', () => {
expect(swapService.findOfframpTransaction).toHaveBeenCalled();
});
});

describe('getOfframpTransactions', () => {
it('should call swapService.getOfframpTransactions', () => {
controller.getOfframpTransactions();
expect(swapService.getOfframpTransactions).toHaveBeenCalled();
});
});
});
23 changes: 21 additions & 2 deletions apps/api/src/swap/swap.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,27 @@ export class SwapController {
}

@Get('offramp/all')
getOfframpTransactions() {
return this.swapService.getOfframpTransactions();
@ApiOperation({ summary: 'List offramp swaps' })
@ApiQuery({
name: 'page',
example: '?page=0',
type: ListSwapsDto['page'],
required: false,
})
@ApiQuery({
name: 'size',
example: '?size=100',
type: ListSwapsDto['size'],
required: false,
})
getOfframpTransactions(
@Query('page') page: number = 0,
@Query('size') size: number = 100,
) {
return this.swapService.getOfframpTransactions({
page,
size,
});
}

@Post('webhook')
Expand Down
25 changes: 22 additions & 3 deletions apps/api/src/swap/swap.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ describe('SwapService', () => {
status: 'PENDING',
};
}),
listOfframpSwaps: jest.fn().mockImplementation(async () => {
return {
swaps: [
{
id: mock_id,
rate: (1 / mock_btc_kes).toString(),
status: 'PENDING',
},
],
page: 0,
size: 10,
pages: 2,
};
}),
};
});

Expand Down Expand Up @@ -169,7 +183,7 @@ describe('SwapService', () => {
});

describe('getOnrampTransactions', () => {
it('should return status 200', () => {
it('can get a paginated list of onramp swaps', () => {
expect(
swapService.getOnrampTransactions({
page: 0,
Expand Down Expand Up @@ -241,8 +255,13 @@ describe('SwapService', () => {
});

describe('getOfframpTransactions', () => {
it('should return status 200', () => {
expect(swapService.getOfframpTransactions()).toEqual({ status: 200 });
it('can get a paginated list of offramp swaps', () => {
expect(
swapService.getOfframpTransactions({
page: 0,
size: 10,
}),
).toBeDefined();
});
});
});
4 changes: 2 additions & 2 deletions apps/api/src/swap/swap.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class SwapService implements OnModuleInit {
return this.client.findOfframpSwap(req);
}

getOfframpTransactions() {
return { status: 200 };
getOfframpTransactions(req: ListSwapsDto) {
return this.client.listOfframpSwaps(req);
}
}

0 comments on commit 52edb3a

Please sign in to comment.