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

feat(relapi): get QuoteRequest by txhash #3032

Merged
merged 7 commits into from
Aug 20, 2024
Merged

feat(relapi): get QuoteRequest by txhash #3032

merged 7 commits into from
Aug 20, 2024

Conversation

golangisfun123
Copy link
Collaborator

@golangisfun123 golangisfun123 commented Aug 16, 2024

we already had it for getting it by txID, for completeness added txHash

Summary by CodeRabbit

  • New Features

    • Introduced a new method to retrieve quote requests by transaction hash.
    • Added a new API endpoint to handle requests for retrieving quote requests based on transaction hashes.
  • Chores

    • Removed unnecessary dependency from project modules to streamline the codebase.

Copy link
Contributor

coderabbitai bot commented Aug 16, 2024

Walkthrough

The recent changes streamline the codebase by removing the github.com/BurntSushi/toml dependency from two Go modules. New functionalities have been added to the relayerClient and Handler struct, enabling the retrieval of quote requests using transaction hashes. Additionally, the API server has been updated to support this feature, enhancing overall capabilities and improving client interactions.

Changes

Files Change Summary
.../go.mod Removed github.com/BurntSushi/toml v1.4.0 dependency from both contrib/screener-api and ethergo.
.../relapi/client.go Added method GetQuoteRequestByTxHash to relayerClient for retrieving quote requests by transaction hash; marked old status methods as deprecated.
.../relapi/handler.go Introduced function GetQuoteRequestByTxHash in Handler to handle HTTP requests for quote requests by transaction hash.
.../relapi/server.go Added the /request/by_tx_hash endpoint and updated Run method to register the new route handler.
.../relapi/client_test.go Renamed test TestGetQuoteByTX to TestGetQuoteByTxID and added new test TestGetQuoteByTxHash for the transaction hash retrieval functionality.

Poem

In the burrow, changes made,
Dependencies trimmed, the code displayed.
New paths for quotes, oh what a sight,
Transaction hashes shining bright!
Hopping along, with joy we cheer,
For every update brings us near! 🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@github-actions github-actions bot added go Pull requests that update Go code size/s labels Aug 16, 2024
Copy link

codecov bot commented Aug 16, 2024

Codecov Report

Attention: Patch coverage is 61.11111% with 14 lines in your changes missing coverage. Please review.

Project coverage is 23.40442%. Comparing base (9dfde6c) to head (c6e59f2).
Report is 4 commits behind head on master.

Files Patch % Lines
services/rfq/relayer/relapi/handler.go 60.00000% 6 Missing and 2 partials ⚠️
services/rfq/relayer/relapi/client.go 53.84615% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #3032         +/-   ##
===================================================
+ Coverage   23.38100%   23.40442%   +0.02341%     
===================================================
  Files            644         644                 
  Lines          50139       50170         +31     
  Branches          82          82                 
===================================================
+ Hits           11723       11742         +19     
- Misses         37255       37263          +8     
- Partials        1161        1165          +4     
Flag Coverage Δ
opbot 0.48900% <ø> (ø)
promexporter 6.94006% <ø> (ø)
rfq 21.96220% <61.11111%> (+0.14659%) ⬆️

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

cloudflare-workers-and-pages bot commented Aug 16, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: c6e59f2
Status: ✅  Deploy successful!
Preview URL: https://382b466c.sanguine-fe.pages.dev
Branch Preview URL: https://qr-by-txhash.sanguine-fe.pages.dev

View logs

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This pull request adds functionality to retrieve QuoteRequests by transaction hash in the relayer API, complementing the existing ability to fetch by transaction ID.

  • Added GetQuoteRequestbyTxHash method in services/rfq/relayer/relapi/client.go
  • Implemented GetQuoteRequestByTxHash function in services/rfq/relayer/relapi/handler.go
  • Created new API endpoint '/request/by_tx_hash' in services/rfq/relayer/relapi/server.go
  • Removed dependency on github.com/BurntSushi/toml in contrib/screener-api/go.mod and ethergo/go.mod

7 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

@@ -169,3 +168,20 @@ func (r *relayerClient) GetQuoteRequestByTXID(ctx context.Context, txid string)

return &res, nil
}

func (r *relayerClient) GetQuoteRequestbyTxHash(ctx context.Context, txHash string) (*GetQuoteRequestResponse, error) {
Copy link

Choose a reason for hiding this comment

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

syntax: Typo in function name: 'by' should be capitalized

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 317c07d and 73d04e4.

Files ignored due to path filters (2)
  • contrib/screener-api/go.sum is excluded by !**/*.sum
  • core/go.sum is excluded by !**/*.sum
Files selected for processing (5)
  • contrib/screener-api/go.mod (1 hunks)
  • ethergo/go.mod (1 hunks)
  • services/rfq/relayer/relapi/client.go (2 hunks)
  • services/rfq/relayer/relapi/handler.go (1 hunks)
  • services/rfq/relayer/relapi/server.go (2 hunks)
Files skipped from review due to trivial changes (2)
  • contrib/screener-api/go.mod
  • ethergo/go.mod
Additional comments not posted (4)
services/rfq/relayer/relapi/server.go (2)

105-105: LGTM: New route constant definition.

The getRequestByTxHash constant is correctly defined and follows the naming conventions of other route constants.


123-123: LGTM: Integration of new GET route.

The new route /request/by_tx_hash is correctly registered in the Run method and linked to the GetQuoteRequestByTxHash handler.

services/rfq/relayer/relapi/client.go (1)

172-187: LGTM: New method implementation.

The GetQuoteRequestbyTxHash method is well-implemented, consistent with existing methods, and includes appropriate error handling and status code checks.

services/rfq/relayer/relapi/handler.go (1)

183-206: LGTM: New handler function implementation.

The GetQuoteRequestByTxHash function is well-implemented, consistent with existing handlers, and includes appropriate error handling and response construction.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

This pull request adds functionality to retrieve QuoteRequests by transaction hash in the relayer API. Here's a summary of the recent changes:

  • Implemented GetQuoteRequestByTxHash function in services/rfq/relayer/relapi/handler.go
  • The new function follows a similar pattern to GetQuoteRequestByTxID, using the database service to fetch the quote request
  • Added error handling for cases where the transaction hash is not provided or the quote request is not found
  • The response includes the raw quote request data, origin and destination chain IDs, and token addresses

These changes enhance the API's functionality by providing an additional method to retrieve quote requests, improving flexibility for clients interacting with the relayer service.

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 73d04e4 and 242b44a.

Files selected for processing (1)
  • services/rfq/relayer/relapi/client.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • services/rfq/relayer/relapi/client.go

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

This pull request adds a new method GetQuoteRequestByTxHash to retrieve quote requests by transaction hash, complementing the existing GetQuoteRequestByTXID method. The implementation is consistent across the handler, client, and model files. Here's a summary of the key changes:

  • Added GetQuoteRequestByTxHash method to the RelayerClient interface in client.go
  • Implemented the new method in the relayerClient struct in client.go
  • Added a test case TestGetQuoteByTxHash in client_test.go
  • Implemented GetQuoteRequestByTxHash function in the handler file (previously reviewed)

These changes provide a complete implementation of the new functionality, allowing clients to retrieve quote requests using either transaction IDs or transaction hashes.

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

func (r *relayerClient) GetQuoteRequestByTxHash(ctx context.Context, txHash string) (*GetQuoteRequestResponse, error) {
var res GetQuoteRequestResponse
resp, err := r.client.R().SetContext(ctx).
SetQueryParam("hash", txHash).
Copy link

Choose a reason for hiding this comment

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

style: Consider using a constant for the 'hash' query parameter name

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

No major changes found since last review.

No file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 242b44a and b726d07.

Files selected for processing (2)
  • services/rfq/relayer/relapi/client.go (3 hunks)
  • services/rfq/relayer/relapi/client_test.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • services/rfq/relayer/relapi/client.go
Additional comments not posted (2)
services/rfq/relayer/relapi/client_test.go (2)

Line range hint 239-248: Renaming improves clarity.

The function TestGetQuoteByTxID has been renamed from TestGetQuoteByTX, which enhances clarity regarding the identifier being tested.


250-259: New test function added successfully.

The function TestGetQuoteByTxHash correctly tests the retrieval of a quote request by transaction hash, ensuring the new functionality is verified.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

This PR introduces a new feature to retrieve QuoteRequests by transaction hash in the RFQ (Request for Quote) relayer service. Here are the key changes:

  • Added GetQuoteRequestByTxHash method in /services/rfq/relayer/relapi/handler.go
  • Updated /services/rfq/relayer/relapi/server.go to include a new route for the new feature
  • Modified /services/rfq/api/model/response.go to support the new response structure
  • Improved concurrency handling in /services/rfq/relayer/service/handlers.go with balance locking
  • Enhanced chain listener initialization in /services/rfq/relayer/service/relayer.go

22 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

This PR extends the functionality of the RFQ relayer service by adding the ability to retrieve QuoteRequests by transaction hash, complementing the existing txID-based retrieval.

  • Introduced GetQuoteRequestByTxHash method in services/rfq/relayer/relapi/client.go, enhancing the RelayerClient interface
  • Added a new route in services/rfq/relayer/relapi/server.go to handle requests for quote retrieval by transaction hash
  • Deprecated GetQuoteRequestByTxID and GetQuoteRequestByTxIDWithStatus methods in favor of new, more flexible alternatives
  • Included TODO comments in server.go for future replacement of status-specific endpoints, indicating ongoing API structure improvements

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

services/rfq/relayer/relapi/client.go Show resolved Hide resolved
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: 1

Outside diff range, codebase verification and nitpick comments (1)
services/rfq/relayer/relapi/server.go (1)

99-99: Add a period at the end of the comment.

The comment should end with a period for consistency with other comments.

- // TODO: replace with non-status specific endpoints
+ // TODO: replace with non-status specific endpoints.
Tools
GitHub Check: Lint (services/rfq)

[failure] 99-99:
Comment should end in a period (godot)

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b726d07 and b335e97.

Files selected for processing (2)
  • services/rfq/relayer/relapi/client.go (3 hunks)
  • services/rfq/relayer/relapi/server.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • services/rfq/relayer/relapi/client.go
Additional context used
GitHub Check: Lint (services/rfq)
services/rfq/relayer/relapi/server.go

[failure] 99-99:
Comment should end in a period (godot)

Additional comments not posted (2)
services/rfq/relayer/relapi/server.go (2)

106-106: LGTM! Addition of getRequestByTxHash constant.

The new constant for the /request/by_tx_hash endpoint is a necessary addition for the new feature.


126-126: LGTM! Addition of route handler for getRequestByTxHash.

The new route handler h.GetQuoteRequestByTxHash is correctly registered.

@@ -95,13 +95,15 @@
}

const (
getHealthRoute = "/health"
getHealthRoute = "/health"
// TODO: replace with non-status specific endpoints
Copy link
Contributor

Choose a reason for hiding this comment

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

Follow-up on TODO comments.

The TODO comments indicate a need to replace status-specific endpoints. Ensure these are addressed in future updates.

Would you like me to open a GitHub issue to track the replacement of status-specific endpoints?

Also applies to: 120-122

Tools
GitHub Check: Lint (services/rfq)

[failure] 99-99:
Comment should end in a period (godot)

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

No major changes found since last review.

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b335e97 and c6e59f2.

Files selected for processing (1)
  • services/rfq/relayer/relapi/server.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • services/rfq/relayer/relapi/server.go

@trajan0x trajan0x merged commit 898b5b9 into master Aug 20, 2024
33 checks passed
@trajan0x trajan0x deleted the qr-by-txhash branch August 20, 2024 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code size/s
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants