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: implement ws order type refactoring #320

Merged
merged 1 commit into from
May 23, 2024

Conversation

bradennapier
Copy link
Collaborator

@bradennapier bradennapier commented May 23, 2024

Summary by CodeRabbit

  • Refactor

    • Improved handling and clarity of WebSocket order and fill events.
    • Enhanced type definitions and interface structures for better maintainability.
  • Documentation

    • Updated documentation to reflect changes in enums and interfaces.

Copy link
Contributor

coderabbitai bot commented May 23, 2024

Walkthrough

The recent updates primarily focus on refactoring and enhancing the codebase for handling WebSocket responses and order events. Key changes include transforming constant function declarations into function statements, reorganizing enums related to fill types, and refining interfaces for order and fill event data. These modifications aim to improve code clarity, maintainability, and alignment with updated interfaces and type definitions.

Changes

File Path Summary
src/client/webSocket/transform.ts Refactored transformOrderFill and transformOrdersMessage functions.
src/types/enums/response.ts Reorganized FillType enum into FillTypeSystem and FillTypeOrder.
src/types/webSocket/response/orders.ts Updated interfaces and types for WebSocket order events.
src/types/webSocket/response/ordersFill.ts Added new fill types and restructured related interfaces.

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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 5ed9e35 and c3cee5e.
Files selected for processing (4)
  • src/client/webSocket/transform.ts (3 hunks)
  • src/types/enums/response.ts (4 hunks)
  • src/types/webSocket/response/orders.ts (11 hunks)
  • src/types/webSocket/response/ordersFill.ts (6 hunks)
Additional comments not posted (19)
src/types/webSocket/response/ordersFill.ts (7)

1-5: Ensure that the new imports FillTypeOrder and FillTypeSystem are used appropriately throughout the file.


22-30: The documentation for IDEXOrderFillEventDataSystem has been updated to reflect its specific use case. Ensure that the documentation accurately describes the behavior and usage of this interface.


33-38: The type property in IDEXOrderFillEventDataSystem has been correctly updated to use FillTypeSystem. This change aligns with the new enum definitions and should help clarify the type of fills this interface represents.


Line range hint 44-53: The type property in IDEXOrderFillEventDataGeneral has been updated to use FillTypeOrder. This is consistent with the restructuring of the fill types and should ensure that the interface correctly represents order-related fills.


63-63: The union type IDEXOrderFillEventData has been updated to include the new interfaces. This change is necessary to ensure that all potential fill event data types are correctly handled.


123-128: The y property in WebSocketResponseOrderFillShortSystem has been updated to use the type from IDEXOrderFillEventDataSystem. This change ensures that the short message format aligns with the new system fill types.


158-159: The union type WebSocketResponseOrderFillShort has been updated to include the new short message formats. This is crucial for ensuring that the WebSocket responses can handle both system and general fill types.

src/client/webSocket/transform.ts (2)

Line range hint 117-143: The function transformOrderFill has been converted from an arrow function to a regular function declaration. This change improves readability and maintainability. Ensure that the function correctly handles the transformation logic, especially the conditional parts that depend on whether the fill is general or system-specific.


Line range hint 145-189: The function transformOrdersMessage has been updated to handle different types of order data based on the presence of the o property. This function now correctly distinguishes between system fills and general order data, mapping fills appropriately. Ensure that the transformation logic is robust and handles all edge cases.

src/types/enums/response.ts (3)

Line range hint 30-50: The FillTypeSystem enum has been introduced to separate system-specific fill types from order-related fills. This change improves clarity and helps in distinguishing between different contexts where fills are used. Ensure that the enum is used consistently across the codebase.


54-65: The FillTypeOrder enum has been introduced to specifically handle order-related fill types. This separation from system fills is a good practice as it clarifies the usage and makes the code more maintainable.


76-80: The FillType enum has been updated to include both FillTypeOrder and FillTypeSystem. This consolidation is necessary to handle cases where a fill could belong to either category. Ensure that this combined enum is used appropriately in contexts where a distinction between system and order fills is not required.

src/types/webSocket/response/orders.ts (7)

2-3: The imports have been updated to reflect the new enum and type definitions. This change is necessary to ensure that the interfaces in this file use the correct types from the updated enums.


Line range hint 65-75: The IDEXOrderEventDataBase interface has been updated to make the type property optional and read-only, reflecting its use in system fill scenarios where the type might not be defined. This change is appropriate and aligns with the new data handling strategy for order events.


86-89: The IDEXOrderEventDataSystemFill interface has been introduced to handle system fill updates specifically. This interface correctly extends IDEXOrderEventDataBase and makes the type property undefined, which is suitable for system fill scenarios.


Line range hint 103-116: The IDEXOrderEventDataGeneral interface has been updated to include properties from IDEXOrder except for those already included in IDEXOrderEventDataBase. This restructuring helps in maintaining a clear separation between general and system-specific order data.


159-160: The union type IDEXOrderEventData has been updated to include both IDEXOrderEventDataSystemFill and IDEXOrderEventDataGeneral. This change is crucial for handling different types of order events correctly in the WebSocket responses.


Line range hint 173-219: The WebSocketResponseOrderShortSystem interface has been updated to handle system-specific order shorts. This interface correctly extends WebSocketResponseOrderShortBase and sets the o property to undefined, which is appropriate for system fill scenarios.


Line range hint 228-354: The WebSocketResponseOrderShortGeneral interface has been updated to include additional properties that are relevant for general order types. This comprehensive inclusion of properties ensures that all necessary data is available for general order processing.

@bradennapier bradennapier merged commit a94c017 into beta May 23, 2024
2 checks passed
@bradennapier bradennapier deleted the feat/ws-order-type-refactor branch May 23, 2024 17:27
@idex-bot
Copy link
Contributor

🎉 This PR is included in version 4.0.0-beta.12 🎉

The release is available on:

Your semantic-release bot 📦🚀

@idex-bot
Copy link
Contributor

🎉 This PR is included in version 4.0.0-alpha.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

None yet

2 participants