-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: register secondary stellar donation by cron job #1797
Conversation
WalkthroughThe changes involve refactoring the Changes
Sequence Diagram(s)sequenceDiagram
participant A as User
participant B as Donation Service
participant C as Stellar Network
A->>B: Initiate Donation
B->>C: Check Transaction
C-->>B: Return Transactions
B->>B: Process Transactions
alt Matching Transaction Found
B->>B: Wait 10 seconds
B->>B: Register Secondary Donation
end
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Additional comments not posted (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range, codebase verification and nitpick comments (1)
src/services/cronJobs/checkQRTransactionJob.ts (1)
Line range hint
152-329
: Consider refactoring the function into smaller, more focused functions and using a configuration value for the delay.The
checkTransactions
function is quite large and complex, which could impact readability and maintainability. It is also performing multiple tasks, such as retrieving transactions, validating transactions, and creating donations, which violates the Single Responsibility Principle.Consider breaking down the function into smaller, more focused functions to improve readability and maintainability. For example:
- Extract the logic for retrieving transactions into a separate function.
- Extract the logic for validating transactions into a separate function.
- Extract the logic for creating donations into a separate function.
Additionally, the usage of
setTimeout
with a hardcoded delay of 10 seconds is a code smell. It would be better to use a configuration value for the delay.Apply this diff to use a configuration value for the delay:
+const SECONDARY_DONATION_DELAY = config.get('SECONDARY_DONATION_DELAY') || 10000; + // Register secondary donation after the configured delay setTimeout(async () => { await registerSecondaryDonation( donation, transaction.source_account, transaction.transaction_hash, transaction.created_at, project, token, tokenPrice, donor, qfRound, ); -}, 10000); +}, SECONDARY_DONATION_DELAY);
Related to Giveth/giveth-dapps-v2#4667
Summary by CodeRabbit