Skip to content

Commit

Permalink
Fix/lint errors (#38)
Browse files Browse the repository at this point in the history
* add: transfer filter to transfer resource

- Added helper functions to generate dynamic where condition based on filter input.
- Added filter to transfer resource
- Rename query name transfers and getAllTransfers to transfer and transfers

* update: transfer summary query

* update: transfers pagination default limit

* Fix: integration test

* Fix: integration test error

* Fix: bug int cannot represent non-integer value

-Use scalar type [dateTimeFlex,BigInt]

* update: transfer query to add events fields

-Added quoteEvents field to transfer resource
-Added transferEvents field to transfer resource
-Added partyLookupEventsfield to transfer resource
-Added settlementEvents to transfer resource

* fix: transfer filter bug

transfers query was returning less no of transfers documents than it was existing

* update: transaction schema and query according to new schema

* fix: conversion state filter

* fix: transfers object conversion error when no data returned for query

* create: resolver for fxTransferEvents and fxQuoteEvents lookup

* create: settlement resource prisma model

* create: settlement resource query

* add: conversionSettlementBatchId and transferSettlementBatchId lookup to transfer

* fix: lint errors

* Update two packages with high severity: body-parser  <1.20.3 & path-to-regexp  <0.1.10
They will need to be updated.

---------

Co-authored-by: Akhilesh Rawat <[email protected]>
Co-authored-by: v3-Panwar-Ujjwal <[email protected]>
Co-authored-by: nguni52 <[email protected]>
  • Loading branch information
4 people authored Nov 29, 2024
1 parent 33e33d2 commit bd5d032
Show file tree
Hide file tree
Showing 9 changed files with 655 additions and 764 deletions.
1 change: 1 addition & 0 deletions audit-ci.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"GHSA-72xf-g2v4-qvf3",
"GHSA-j8xg-fqg3-53r7",
"GHSA-3h5v-q93c-6h6q",
"GHSA-9wv6-86v2-598j",
"GHSA-qwcr-r2fm-qrc7",
"GHSA-78xj-cgh5-2h22",
"GHSA-9wv6-86v2-598j",
Expand Down
1,381 changes: 632 additions & 749 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion prisma/base/transaction.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ model Transaction {
@@unique([transactionId])
@@index([transferState])
@@index([transactionType])
@@map("transfer")
@@map("transaction")
}

type TransferStateChange {
Expand Down
10 changes: 9 additions & 1 deletion src/lib/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,12 @@ const createSettlementClient = (logQuery = false): SettlementClient => {
log: logQuery ? ['query'] : [],
});
};
export { createTransactionClient, TransactionClient, createEventStoreClient, EventStoreClient, createSettlementClient, SettlementClient};

export {
createTransactionClient,
TransactionClient,
createEventStoreClient,
EventStoreClient,
createSettlementClient,
SettlementClient,
};
3 changes: 2 additions & 1 deletion src/schema/Settlement/Query.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { extendType, nonNull, intArg } from 'nexus';
import { stringArg, extendType, nonNull, intArg } from 'nexus';


const Query = extendType({
type: 'Query',
definition(t) {
Expand Down Expand Up @@ -43,7 +45,6 @@ const Query = extendType({
if (settlements.length === 0) {
console.log(`No settlements found`);
}
console.log('Settlements data fetched is : ', settlements);
return settlements;
} catch (error) {
console.error('Error fetching transfers', error);
Expand Down
2 changes: 1 addition & 1 deletion src/schema/Settlement/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Query from './Query';
import Settlement from './Settlement';

export default [Query, Settlement];
export default [Query, Settlement];
7 changes: 4 additions & 3 deletions src/schema/Transfer/Query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const Query = extendType({
}
},
});
// Define a field to fetch multiple transfers with filters, limit, and offset
// Define a field to fetch multiple transfers with filters, limit, and offset
t.nonNull.list.nonNull.field('transfers', {
type: 'Transfer',
args: {
Expand All @@ -92,8 +92,9 @@ const Query = extendType({
});

if (transfers.length === 0) {
console.log(`No transfers found with limit: ${limit}, offset: ${offset}, and filter: ${JSON.stringify(filter)}`);

console.log(
`No transfers found with limit: ${limit}, offset: ${offset}, and filter: ${JSON.stringify(filter)}`
);
}
// console.log('Transfer data fetched is : ', transfers);
return transfers;
Expand Down
2 changes: 0 additions & 2 deletions src/schema/Transfer/Transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ const Transfer = objectType({
// Define resolver for conversionSettlementBatchId lookup
t.bigInt('conversionSettlementBatchId', {
resolve: async (parent, args, ctx) => {
console.log('settlementId resolver called with parent: ', parent.conversions?.payer?.conversionSettlementWindowId);
const settlement = await ctx.settlement.settlement.findFirst({
where: {
settlementWindows: {
Expand All @@ -208,7 +207,6 @@ const Transfer = objectType({
},
},
});
console.log('settlement resolved is: ', settlement);
return settlement ? settlement.settlementId : null;
},
});
Expand Down
11 changes: 5 additions & 6 deletions src/schema/Transfer/dataloaders/TransferState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import DataLoader from 'dataloader';
const ID = Symbol();

const findTransferStates = async (ctx: Context, transferIds: string[]) => {
console.log("findTransferStates for transferIds", transferIds);
console.log('findTransferStates for transferIds', transferIds);
const trStates = await ctx.transaction.transaction.findMany({
where: {
transferId: {
Expand All @@ -23,7 +23,7 @@ const findTransferStates = async (ctx: Context, transferIds: string[]) => {
},
select: {
transferId: true,
transferStateChanges:{
transferStateChanges: {
select: {
transferState: true,
dateTime: true,
Expand All @@ -32,10 +32,9 @@ const findTransferStates = async (ctx: Context, transferIds: string[]) => {
},
},
});
console.log("findTransferStates trStates", trStates);

return Object.fromEntries(trStates.map((e) => [e.transferId, e.transferStateChanges
]));
console.log('findTransferStates trStates', trStates);

return Object.fromEntries(trStates.map((e) => [e.transferId, e.transferStateChanges]));
};

export const getTransferStateDataloader = (ctx: Context) => {
Expand Down

0 comments on commit bd5d032

Please sign in to comment.