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

RFQ Indexer: adding search by origin tx #3277

Merged
merged 1 commit into from
Oct 12, 2024
Merged

Conversation

Defi-Moses
Copy link
Collaborator

@Defi-Moses Defi-Moses commented Oct 12, 2024

Adding search by origin txn hash and not just transactionID.

Summary by CodeRabbit

  • New Features
    • Enhanced transaction retrieval to support both transaction ID and transaction hash.
  • Documentation
    • Updated OpenAPI documentation to clarify the dual functionality of the /transaction-id/{transactionId} endpoint.

Copy link
Contributor

coderabbitai bot commented Oct 12, 2024

Walkthrough

The changes in this pull request involve modifications to the getTransactionById function in the transactionIdController.ts file, allowing it to retrieve deposit records based on either transactionId or transactionHash. Additionally, the OpenAPI documentation for the /transaction-id/{transactionId} endpoint has been updated to reflect this new dual functionality. The overall structure of the function and the documentation remains intact, with no alterations to exported or public entities.

Changes

File Path Change Summary
packages/rfq-indexer/api/src/controllers/... Modified getTransactionById to allow retrieval by either transactionId or transactionHash.
packages/rfq-indexer/api/src/routes/... Updated OpenAPI documentation for /transaction-id/{transactionId} to clarify dual functionality.

Possibly related PRs

  • Refactoring rfq-indexer API and adding swagger docs [SLT-228] #3167: This PR includes changes to the transactionIdController.ts, specifically the getTransactionById function, which is directly related to the modifications made in the main PR regarding the retrieval of transaction details.
  • RFQ-Indexer Adding events #3227: This PR introduces the "bridgedispute" event to the indexer, which may relate to the broader context of transaction handling and events in the RFQ indexer, potentially impacting how transactions are processed.
  • RFQ-Indexer DB updates #3239: This PR updates the schema for the BridgeProofDisputedEvents, which is relevant to the handling of transactions and events, aligning with the changes made in the main PR regarding transaction retrieval and processing.

Suggested labels

size/m, Sol, Typescript

Suggested reviewers

  • trajan0x
  • bigboydiamonds
  • abtestingalpha

Poem

In the code where rabbits hop,
A change was made, we can't stop!
Transaction flows now dance and twirl,
With hashes and IDs in a whirl.
Hooray for queries, broad and bright,
In our code, all feels just right! 🐇✨


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 89f6ac4
Status: ✅  Deploy successful!
Preview URL: https://567918d9.sanguine-fe.pages.dev
Branch Preview URL: https://feat-search-by-txhash.sanguine-fe.pages.dev

View logs

Copy link

codecov bot commented Oct 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 31.73701%. Comparing base (099624f) to head (89f6ac4).
Report is 3 commits behind head on master.

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #3277         +/-   ##
===================================================
+ Coverage   30.65718%   31.73701%   +1.07983%     
===================================================
  Files            447         427         -20     
  Lines          29794       28503       -1291     
  Branches          82          82                 
===================================================
- Hits            9134        9046         -88     
+ Misses         19809       18609       -1200     
+ Partials         851         848          -3     
Flag Coverage Δ
packages 90.44834% <ø> (ø)
promexporter ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 and nitpick comments (1)
packages/rfq-indexer/api/src/routes/transactionIdRoute.ts (1)

11-11: LGTM! The changes align with the PR objectives.

The updates to the OpenAPI documentation accurately reflect the new functionality of searching by either transaction ID or origin transaction hash. This enhances the clarity of the API documentation for users.

Consider adding a brief explanation of the difference between a transaction ID and an origin transaction hash in the description. This could help API users understand when to use each identifier.

 *         name: transactionId
 *         required: true
 *         schema:
 *           type: string
-*         description: The unique identifier of the transaction or the origin transaction hash
+*         description: The unique identifier of the transaction or the origin transaction hash. Use transaction ID for internal transactions and origin transaction hash for cross-chain transactions.

Also applies to: 19-19

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 099624f and 89f6ac4.

📒 Files selected for processing (2)
  • packages/rfq-indexer/api/src/controllers/transactionIdController.ts (1 hunks)
  • packages/rfq-indexer/api/src/routes/transactionIdRoute.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
packages/rfq-indexer/api/src/controllers/transactionIdController.ts (1)

13-18: Enhance function clarity and robustness

The implementation of the new search capability by both transactionId and transactionHash is a good addition that aligns with the PR objectives. However, there are several points to consider for improving clarity, robustness, and maintainability:

  1. Consider renaming the function and parameter to reflect the dual functionality. For example:

    export const getTransactionByIdOrHash = async (req: Request, res: Response) => {
      const { transactionIdOrHash } = req.params
      // ...
    }
  2. Add input validation to ensure the provided transactionIdOrHash is in the correct format for either a transaction ID or a transaction hash. This will help prevent potential errors and improve the function's robustness.

  3. Be aware of potential performance implications. Ensure that appropriate indexes are in place on both transactionId and transactionHash columns to maintain query efficiency.

  4. Update the OpenAPI documentation for this endpoint to clearly indicate that it now accepts either a transaction ID or a transaction hash.

  5. Consider adding a comment in the code explaining the dual functionality for better maintainability.

To verify the impact on query performance and ensure proper indexing, you can run the following script:

This script will help identify if proper indexes are in place and provide insights into the query execution plan.

Copy link
Collaborator

@parodime parodime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great - i like the approach where its the same single input param & just checks both. I think this could even be expanded to just search for that hash anywhere -- transactionId, deposit, relay, proof, claim, dispute.

Another edge case catch is that unlike transactionId, a single transaction hash can technically repeat on multiple bridges. (EG: a single transaction can have any number of bridge deposits --- or relays, proofs, etc)

Not sure what current expected behavior of this endpoint would be in that case, but its probably best if it returns all of the matches, even if they are multiple bridges.

Its such an edge case tho right now -- I think this is good as-is & we can always do more later!

@Defi-Moses Defi-Moses merged commit d048b2c into master Oct 12, 2024
36 checks passed
@Defi-Moses Defi-Moses deleted the feat/search-by-txhash branch October 12, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants