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

[TRA-442] Add query for market mapper revenue share params #1746

Merged
merged 4 commits into from
Jun 21, 2024
Merged

Conversation

shrenujb
Copy link
Contributor

@shrenujb shrenujb commented Jun 20, 2024

Changelist

Add query for market mapper revenue share params

Test Plan

Added tests

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • New Features

    • Added functionality to query market mapper revenue share parameters through multiple new methods and interfaces.
  • Tests

    • Introduced tests for querying market mapper revenue share parameters ensuring accurate setting and retrieval of parameters.
  • Bug Fixes

    • Fixed how revenue share details are assigned in the response struct for the market mapper.

Copy link

linear bot commented Jun 20, 2024

Copy link
Contributor

coderabbitai bot commented Jun 20, 2024

Walkthrough

The changes introduce a new method to query market mapper revenue share parameters across various layers of a system, including gRPC service definitions, client implementation, and testing. The new functionality encompasses proto file updates, code generation adjustments, and the addition of corresponding handlers and tests within the backend logic to manage these parameters.

Changes

Files/Modules Change Summary
indexer/packages/.../query.rpc.Query.ts Added marketMapperRevenueShareParams method to Query interface and its implementation in QueryClientImpl.
indexer/packages/.../query.ts Introduced interfaces and functions for handling market mapper revenue share parameter queries and responses.
proto/dydxprotocol/revshare/query.proto Updated with new gRPC query service method and message types for MarketMapperRevenueShareParams.
protocol/x/revshare/keeper/grpc_query_marketmapper_revenue_params.go New method in Keeper struct to retrieve market mapper revenue share parameters.
protocol/x/revshare/keeper/grpc_query_marketmapper_revenue_params_test.go New test function for setting and querying market mapper revenue share parameters.
indexer/packages/.../query.lcd.ts Added a method for querying market mapper revenue share parameters in LCDQueryClient.
protocol/x/revshare/keeper/grpc_query_marketmapper_revshare_details.go Modified to assign Details in response struct without the & operator.

Poem

A rabbit hops through code unseen,
Bringing logic neat and keen,
Revenue shares for mappers unknown,
Now revealed, their details shown.
In tests and schemas, lines align,
Protobufs and queries shine.
🎉🚀✨


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 Configration 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.

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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 47ee024 and 2fc4e0e.

Files ignored due to path filters (1)
  • protocol/x/revshare/types/query.pb.go is excluded by !**/*.pb.go
Files selected for processing (5)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.rpc.Query.ts (1 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.ts (1 hunks)
  • proto/dydxprotocol/revshare/query.proto (1 hunks)
  • protocol/x/revshare/keeper/grpc_query_marketmapper_revenue_params.go (1 hunks)
  • protocol/x/revshare/keeper/grpc_query_marketmapper_revenue_params_test.go (1 hunks)
Additional context used
Biome
indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.ts

[error] 6-6: An empty interface is equivalent to {}. (lint/suspicious/noEmptyInterface)

Safe fix: Use a type alias instead.


[error] 9-9: An empty interface is equivalent to {}. (lint/suspicious/noEmptyInterface)

Safe fix: Use a type alias instead.

Additional comments not posted (10)
protocol/x/revshare/keeper/grpc_query_marketmapper_revenue_params.go (1)

10-18: The implementation of MarketMapperRevenueShareParams adheres to Cosmos SDK standards and correctly handles the context conversion and parameter retrieval.

proto/dydxprotocol/revshare/query.proto (1)

10-14: The Query service and its messages are correctly defined. Using (gogoproto.nullable) = false for the params field in QueryMarketMapperRevenueShareParamsResponse is a good practice to ensure robustness in client code.

Also applies to: 16-22

protocol/x/revshare/keeper/grpc_query_marketmapper_revenue_params_test.go (1)

12-30: The test TestQueryMarketMapperRevenueParams is well-constructed, thoroughly checking both the error handling and the correctness of the data returned by the query.

indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.rpc.Query.ts (3)

7-10: The Query interface is correctly extended to include the new marketMapperRevenueShareParams method. The optional parameter handling is appropriate for this context.


16-22: The QueryClientImpl class correctly implements the new query method, including proper binding in the constructor to handle this context correctly. The gRPC request handling is standard and well-implemented.


29-34: The createRpcQueryExtension function correctly extends an existing QueryClient with the new marketMapperRevenueShareParams method, following best practices for object extension in TypeScript.

indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.ts (4)

21-23: The function createBaseQueryMarketMapperRevenueShareParams correctly initializes an empty object. This is consistent with the expected behavior for a base creator function.


25-51: The QueryMarketMapperRevenueShareParams object methods are implemented correctly. The encode method returns the writer as expected for an empty message, and decode properly handles the protobuf reading process. The fromPartial method also correctly returns a base object.


55-58: The function createBaseQueryMarketMapperRevenueShareParamsResponse initializes the response object with params as undefined, which is appropriate for a base creator function.


61-96: The methods within QueryMarketMapperRevenueShareParamsResponse handle encoding and decoding of the response object effectively. The encode method checks for the presence of params before encoding, which is a good practice to avoid errors. The decode method processes the protobuf input correctly, and the fromPartial method handles partial inputs appropriately.

/** Queries for the default market mapper revenue share params */

export interface QueryMarketMapperRevenueShareParams {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider replacing the empty interface with a type alias for clarity and to adhere to TypeScript best practices.

- export interface QueryMarketMapperRevenueShareParams {}
+ export type QueryMarketMapperRevenueShareParams = {};
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export interface QueryMarketMapperRevenueShareParams {}
export type QueryMarketMapperRevenueShareParams = {};
Tools
Biome

[error] 6-6: An empty interface is equivalent to {}. (lint/suspicious/noEmptyInterface)

Safe fix: Use a type alias instead.

export interface QueryMarketMapperRevenueShareParams {}
/** Queries for the default market mapper revenue share params */

export interface QueryMarketMapperRevenueShareParamsSDKType {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the previous comment, replace this empty interface with a type alias.

- export interface QueryMarketMapperRevenueShareParamsSDKType {}
+ export type QueryMarketMapperRevenueShareParamsSDKType = {};
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export interface QueryMarketMapperRevenueShareParamsSDKType {}
export type QueryMarketMapperRevenueShareParamsSDKType = {};
Tools
Biome

[error] 9-9: An empty interface is equivalent to {}. (lint/suspicious/noEmptyInterface)

Safe fix: Use a type alias instead.

Signed-off-by: Shrenuj Bansal <[email protected]>
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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2fc4e0e and 4b487ed.

Files ignored due to path filters (2)
  • protocol/x/revshare/types/query.pb.go is excluded by !**/*.pb.go
  • protocol/x/revshare/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
Files selected for processing (6)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.lcd.ts (2 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.rpc.Query.ts (2 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.ts (2 hunks)
  • proto/dydxprotocol/revshare/query.proto (2 hunks)
  • protocol/x/revshare/keeper/grpc_query_marketmapper_revenue_params_test.go (1 hunks)
  • protocol/x/revshare/keeper/grpc_query_marketmapper_revshare_details.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • proto/dydxprotocol/revshare/query.proto
  • protocol/x/revshare/keeper/grpc_query_marketmapper_revenue_params_test.go
Additional context used
Biome
indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.ts

[error] 7-7: An empty interface is equivalent to {}. (lint/suspicious/noEmptyInterface)

Safe fix: Use a type alias instead.


[error] 10-10: An empty interface is equivalent to {}. (lint/suspicious/noEmptyInterface)

Safe fix: Use a type alias instead.

Additional comments not posted (5)
protocol/x/revshare/keeper/grpc_query_marketmapper_revshare_details.go (1)

19-19: Simplified return statement in MarketMapperRevShareDetails.

The change from returning a pointer (&revShareDetails) to returning the object directly (revShareDetails) simplifies the code and reduces the risk of nil pointer dereferences, which is a good practice in Go.

indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.lcd.ts (1)

2-2: Enhanced querying capabilities in LCDQueryClient.

The addition of new imports and the method marketMapperRevenueShareParams aligns well with the PR's objectives to extend querying capabilities for market mapper revenue share parameters. This method is well-implemented and follows best practices for asynchronous functions in TypeScript.

Also applies to: 12-12, 19-22

indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.rpc.Query.ts (1)

4-4: Implemented new querying method and improved method binding.

The addition of the marketMapperRevenueShareParams method and its binding in the constructor enhance the querying capabilities and ensure the correct handling of the this context in asynchronous operations. The method's implementation is robust, handling encoding, making the RPC request, and decoding the response efficiently.

Also applies to: 8-12, 22-22, 26-30, 43-45

indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.ts (2)

7-7: Consider replacing the empty interface with a type alias.

As suggested in the previous review, replacing the empty interface QueryMarketMapperRevenueShareParams with a type alias would adhere to TypeScript best practices and improve code clarity.

- export interface QueryMarketMapperRevenueShareParams {}
+ export type QueryMarketMapperRevenueShareParams = {};
Tools
Biome

[error] 7-7: An empty interface is equivalent to {}. (lint/suspicious/noEmptyInterface)

Safe fix: Use a type alias instead.


10-10: Consider replacing the empty interface with a type alias.

Similarly, the empty interface QueryMarketMapperRevenueShareParamsSDKType should be replaced with a type alias to enhance code clarity and adhere to TypeScript best practices.

- export interface QueryMarketMapperRevenueShareParamsSDKType {}
+ export type QueryMarketMapperRevenueShareParamsSDKType = {};
Tools
Biome

[error] 10-10: An empty interface is equivalent to {}. (lint/suspicious/noEmptyInterface)

Safe fix: Use a type alias instead.

@shrenujb shrenujb merged commit 0f32a38 into main Jun 21, 2024
33 checks passed
@shrenujb shrenujb deleted the tra442 branch June 21, 2024 21:43
adamfraser pushed a commit that referenced this pull request Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants