Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify LSK getTransactions API util filters #1988

Closed
slaweet opened this issue May 8, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@slaweet
Copy link
Member

commented May 8, 2019

Actual situation

There is a lot of conditions in LSK getTransactions API util

const params = {
limit,
offset,
sort,
};
if (type !== undefined) params.type = type;
if (customFilters.message) params.data = `%${customFilters.message}%`;
if (customFilters.dateFrom && customFilters.dateFrom !== '') {
params.fromTimestamp = getTimestampFromFirstBlock(customFilters.dateFrom, 'DD.MM.YY');
params.fromTimestamp = params.fromTimestamp > 0 ? params.fromTimestamp : 0;
}
if (customFilters.dateTo && customFilters.dateTo !== '') {
params.toTimestamp = getTimestampFromFirstBlock(customFilters.dateTo, 'DD.MM.YY', { inclusive: true });
params.toTimestamp = params.toTimestamp > 1 ? params.toTimestamp : 1;
}
if (customFilters.amountFrom && customFilters.amountFrom !== '') {
params.minAmount = toRawLsk(customFilters.amountFrom);
}
if (customFilters.amountTo && customFilters.amountTo !== '') {
params.maxAmount = toRawLsk(customFilters.amountTo);
}
if (filter === txFilters.incoming) params.recipientId = address;
if (filter === txFilters.outgoing) params.senderId = address;
if (filter === txFilters.all) params.senderIdOrRecipientId = address;
return getAPIClient(networkConfig).transactions.get(params);
};

Expected situation

getTransactions should be a lot simpler, so it doesn't have to have eslint checks disabled

// eslint-disable-next-line max-statements, complexity, import/prefer-default-export

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.