-
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
Fix: add instant trx check endpoint #1767
Conversation
Warning Rate limit exceeded@Meriem-BM has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 31 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe recent changes significantly enhance the functionality of draft donation handling and transaction validation. The Changes
Possibly related issues
Poem
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 as PR comments)
Additionally, you can add 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: 0
Outside diff range, codebase verification and nitpick comments (1)
src/resolvers/draftDonationResolver.ts (1)
382-388
: Fix missing parentheses ingetTime
method call.The
getTime
method should be invoked with parentheses to properly compare the timestamps. Update the line tonew Date(draftDonation.expiresAt).getTime() < new Date().getTime()
.
src/resolvers/draftDonationResolver.ts
: Line 384Analysis chain
Verify time comparison logic for expiration check.
Ensure that the time comparison logic correctly identifies expired donations and updates their status.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the time comparison logic for donation expiration. # Test: Search for all instances of `expiresAt` usage to ensure consistency. rg --type ts 'expiresAt'Length of output: 1565
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.
Thanks @Meriem-BM just rename the resolver name please, and would appreciate writing a few test cases. feel free to merge it once you do them
…raph into feat/stellar_integration
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
const getStellarTransactionInfo = async ( | ||
txHash: string, | ||
): Promise<NetworkTransactionInfo | null> => { | ||
const NATIVE_STELLAR_ASSET_CODE = 'XLM'; | ||
// Fetch transaction info from stellar network | ||
|
||
const response = await axios.get( | ||
`${STELLAR_HORIZON_API_URL}/transactions/${txHash}/payments`, | ||
); | ||
|
||
const transaction = response.data._embedded.records[0]; | ||
|
||
if (!transaction) return null; | ||
|
||
// when a transaction is made to a newly created account, Stellar mark it as type 'create_account' | ||
if (transaction.type === 'create_account') { | ||
return { | ||
hash: transaction.transaction_hash, | ||
amount: Number(transaction.starting_balance), | ||
from: transaction.source_account, | ||
to: transaction.account, | ||
currency: NATIVE_STELLAR_ASSET_CODE, | ||
timestamp: transaction.created_at, | ||
}; | ||
} else if (transaction.type === 'payment') { | ||
if (transaction.asset_type !== 'native') return null; | ||
return { | ||
hash: transaction.transaction_hash, | ||
amount: Number(transaction.amount), | ||
from: transaction.from, | ||
to: transaction.to, | ||
currency: NATIVE_STELLAR_ASSET_CODE, | ||
timestamp: transaction.created_at, | ||
}; | ||
} else return null; |
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.
Add error handling for network calls.
Consider adding try-catch blocks to handle potential errors from the axios.get
call. This will help manage network issues or unexpected responses gracefully.
try {
const response = await axios.get(
`${STELLAR_HORIZON_API_URL}/transactions/${txHash}/payments`,
);
const transaction = response.data._embedded.records[0];
if (!transaction) return null;
// existing logic
} catch (error) {
// handle error, e.g., log it or throw a custom error
console.error('Error fetching transaction:', error);
return null;
}
Related to Giveth/giveth-dapps-v2#4573
Summary by CodeRabbit
New Features
Improvements
Bug Fixes