Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
🎨 Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nagdahimanshu committed Jan 24, 2024
1 parent 97c608a commit 3e61acc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ const validateParams = async params => {
}
}

if (params.sort) validatedParams.sort = params.sort;

return validatedParams;
};

Expand All @@ -129,17 +127,6 @@ const getPendingTransactions = async params => {

const validatedParams = await validateParams(params);

const sortComparator = sortParam => {
const sortProp = sortParam.split(':')[0];
const sortOrder = sortParam.split(':')[1];

const comparator = (a, b) =>
sortOrder === 'asc'
? Number(a[sortProp] || 0) - Number(b[sortProp] || 0)
: Number(b[sortProp] || 0) - Number(a[sortProp] || 0);
return comparator;
};

if (pendingTransactionsList.length) {
// Filter according to the request params
const filteredPendingTxs = pendingTransactionsList.filter(
Expand All @@ -159,14 +146,11 @@ const getPendingTransactions = async params => {
(!validatedParams.currentChainTransactions || !transaction.params.receivingChainID),
);

pendingTransactions.data = filteredPendingTxs
.sort(sortComparator(validatedParams.sort))
.slice(offset, offset + limit)
.map(transaction => {
// Set the 'executionStatus'
transaction.executionStatus = TRANSACTION_STATUS.PENDING;
return transaction;
});
pendingTransactions.data = filteredPendingTxs.slice(offset, offset + limit).map(transaction => {
// Set the 'executionStatus'
transaction.executionStatus = TRANSACTION_STATUS.PENDING;
return transaction;
});

pendingTransactions.meta = {
count: pendingTransactions.data.length,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ describe('Test validateParams method', () => {
const params = {
moduleCommand: 'token:transfer',
address: 'lskyvvam5rxyvbvofxbdfcupxetzmqxu22phm4yuo',
sort: 'timestamp:desc',
};

const result = await validateParams(params);
Expand Down

0 comments on commit 3e61acc

Please sign in to comment.