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

refactor(torii/graphql): use camelCase in graphql to be more consistent #2515

Merged
merged 1 commit into from
Oct 13, 2024

Conversation

lambda-0x
Copy link
Contributor

@lambda-0x lambda-0x commented Oct 10, 2024

Stack:

⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.

Summary by CodeRabbit

  • New Features
    • Standardized naming conventions for ERC token fields to camelCase, improving clarity and consistency in data structures.
  • Bug Fixes
    • Enhanced case-insensitivity for contract type comparisons in ERC transfers.
  • Documentation
    • Updated variable signatures to reflect new naming conventions for better understanding and usage.

Copy link

coderabbitai bot commented Oct 10, 2024

Walkthrough

Ohayo, sensei! The changes in this pull request involve standardizing naming conventions across several files related to ERC token mappings and balance/transfer objects. Specifically, various fields have been renamed to follow camelCase formatting, enhancing consistency in the data structures and outputs. This includes updates in type mappings and function parameters, ensuring that all relevant fields align with the new naming standard.

Changes

File Path Change Summary
crates/torii/graphql/src/mapping.rs Renamed fields in fetch_erc_balances function to camelCase: token_id to tokenId, contract_address to contractAddress, token_metadata to tokenMetadata.
crates/torii/graphql/src/object/erc/erc_balance.rs Renamed token_metadata to tokenMetadata in ERC_BALANCE_TYPE_MAPPING.
crates/torii/graphql/src/object/erc/erc_transfer.rs Renamed fields in ERC_TRANSFER_TYPE_MAPPING: executed_at to executedAt, token_metadata to tokenMetadata. Updated fetch_erc_transfers function to use camelCase for fields and made contract type comparisons case-insensitive.
crates/torii/graphql/src/object/erc/erc_token.rs Renamed fields in ERC_TOKEN_TYPE_MAPPING: token_id to tokenId, contract_address to contractAddress.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant ERCMapping

    Client->>Server: Request ERC Balances
    Server->>ERCMapping: fetch_erc_balances(tokenId, contractAddress, tokenMetadata)
    ERCMapping-->>Server: Return ERC Balances
    Server-->>Client: Send ERC Balances Response
Loading
sequenceDiagram
    participant Client
    participant Server
    participant ERCMapping

    Client->>Server: Request ERC Transfers
    Server->>ERCMapping: fetch_erc_transfers(tokenId, contractAddress, executedAt, tokenMetadata)
    ERCMapping-->>Server: Return ERC Transfers
    Server-->>Client: Send ERC Transfers Response
Loading

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0b7b2ab and 798ff06.

📒 Files selected for processing (3)
  • crates/torii/graphql/src/mapping.rs (1 hunks)
  • crates/torii/graphql/src/object/erc/erc_balance.rs (2 hunks)
  • crates/torii/graphql/src/object/erc/erc_transfer.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/torii/graphql/src/object/erc/erc_balance.rs
  • crates/torii/graphql/src/object/erc/erc_transfer.rs
🧰 Additional context used
🔇 Additional comments (4)
crates/torii/graphql/src/mapping.rs (4)

151-151: Ohayo, sensei! LGTM: Consistent camelCase naming.

The renaming of "token_metadata" to "tokenMetadata" aligns perfectly with our mission to use camelCase in GraphQL. This change enhances consistency and makes our GraphQL schema more idiomatic. Excellent work!


159-160: Ohayo again, sensei! LGTM: Consistent camelCase naming continues.

The renaming of "executed_at" to "executedAt" and "token_metadata" to "tokenMetadata" in the ERC_TRANSFER_TYPE_MAPPING is spot on! These changes further our goal of using camelCase in GraphQL, making our schema more consistent and easier to work with for frontend developers. Keep up the great work!


166-168: Ohayo once more, sensei! LGTM: Camel case consistency achieved!

Excellent work on renaming "token_id" to "tokenId" and "contract_address" to "contractAddress" in the ERC_TOKEN_TYPE_MAPPING! These changes complete our mission of using camelCase in GraphQL across all three mappings (ERC_BALANCE_TYPE_MAPPING, ERC_TRANSFER_TYPE_MAPPING, and ERC_TOKEN_TYPE_MAPPING).

The consistency achieved here will make our GraphQL schema more intuitive and easier to work with, especially for frontend developers used to JavaScript/TypeScript conventions. Great job on improving the overall quality and maintainability of our codebase!


151-168: Ohayo, sensei! Final thoughts on the camelCase revolution.

This PR has successfully achieved its objective of refactoring the GraphQL implementation in the Torii module to use camelCase naming conventions. The changes made to ERC_BALANCE_TYPE_MAPPING, ERC_TRANSFER_TYPE_MAPPING, and ERC_TOKEN_TYPE_MAPPING are consistent and improve the overall coherence of the codebase.

These modifications will enhance the developer experience, particularly for frontend developers working with the GraphQL schema. The consistent use of camelCase aligns well with JavaScript/TypeScript conventions, making the API more intuitive and easier to use.

Great job on improving the consistency and maintainability of the codebase! This refactoring sets a good precedent for future GraphQL-related work in the project.


🪧 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

@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)
crates/torii/graphql/src/object/erc/erc_transfer.rs (1)

122-123: Ohayo once more, sensei! The camelCase journey continues!

Great job on consistently applying the camelCase convention to executedAt and tokenMetadata. These changes further enhance the uniformity of the API response.

To ensure consistency across the entire codebase, consider using a linter or code formatter that enforces camelCase for all GraphQL-related field names. This could help catch any missed conversions and maintain the new standard moving forward.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7cd7d08 and 68ee72d.

📒 Files selected for processing (3)
  • crates/torii/graphql/src/mapping.rs (1 hunks)
  • crates/torii/graphql/src/object/erc/erc_balance.rs (2 hunks)
  • crates/torii/graphql/src/object/erc/erc_transfer.rs (1 hunks)
🧰 Additional context used
🔇 Additional comments (13)
crates/torii/graphql/src/object/erc/erc_balance.rs (5)

83-85: Ohayo, sensei! LGTM: Consistent camelCase naming in ERC20 token metadata.

The changes in this segment improve consistency by renaming fields to follow camelCase convention. This aligns well with the PR objective and enhances the overall code quality.


91-91: Ohayo, sensei! LGTM: Consistent camelCase naming in ERC20 balance object.

The renaming of 'token_metadata' to 'tokenMetadata' in this segment further enhances consistency with the camelCase convention. This change aligns perfectly with the PR objective.


100-103: Ohayo, sensei! LGTM: Consistent camelCase naming in ERC721 token metadata.

The changes in this segment for ERC721 token metadata align well with the camelCase convention. The renaming of 'contract_address' to 'contractAddress' and 'token_id' to 'tokenId' enhances consistency across the codebase.


110-110: Ohayo, sensei! LGTM: Consistent camelCase naming in ERC721 balance object.

The renaming of 'token_metadata' to 'tokenMetadata' in the ERC721 balance object completes the consistent application of camelCase convention across both ERC20 and ERC721 implementations.


Line range hint 83-110: Ohayo, sensei! Overall LGTM: Consistent camelCase refactoring achieved.

The changes in this file successfully implement the PR objective of using camelCase in GraphQL. The refactoring enhances consistency across ERC20 and ERC721 implementations without altering the underlying functionality. This improvement in naming conventions will likely lead to better code readability and maintainability.

Great job on maintaining consistency throughout the file, sensei!

crates/torii/graphql/src/object/erc/erc_transfer.rs (4)

106-107: Ohayo, sensei! Nice touch with the case-insensitive comparison!

The modification to convert row.contract_type to lowercase before comparison is a smart move. It enhances the robustness of the code by ensuring consistent handling of contract types regardless of case variations. This change aligns well with the goal of improving consistency in the codebase.


112-114: Ohayo again, sensei! Excellent work on the camelCase conversion!

These changes perfectly align with the PR objective of using camelCase in GraphQL for improved consistency. The renaming of token_id to tokenId and contract_address to contractAddress enhances the uniformity of the API response. Keep up the great work!


134-136: Ohayo yet again, sensei! Consistency is key, and you've nailed it!

Excellent work on maintaining the camelCase convention in the ERC721 token handling section. The renaming of token_id to tokenId and contract_address to contractAddress ensures consistency across different token types. This uniformity will greatly improve the developer experience when working with your API.


144-145: Ohayo for the last time, sensei! You've brought it all together beautifully!

Fantastic job on completing the camelCase conversion for the ERC721 token handling. The consistent renaming of executed_at to executedAt and token_metadata to tokenMetadata puts the finishing touches on this refactoring effort.

These changes, combined with the earlier modifications, have successfully transformed the fetch_erc_transfers function to use camelCase consistently. This refactoring enhances the overall consistency of your GraphQL API, making it more intuitive and easier to work with for frontend developers.

Great work on improving the codebase, sensei!

crates/torii/graphql/src/mapping.rs (4)

151-151: Ohayo, sensei! LGTM: Consistent camelCase naming

The renaming of "token_metadata" to "tokenMetadata" aligns perfectly with the PR objective of using camelCase in GraphQL. This change enhances consistency with common JavaScript/TypeScript naming conventions, making the API more intuitive for frontend developers.


159-160: Ohayo again, sensei! LGTM: Consistent camelCase naming continued

The renaming of "executed_at" to "executedAt" and "token_metadata" to "tokenMetadata" in the ERC_TRANSFER_TYPE_MAPPING is spot on! These changes maintain the consistency we're aiming for with camelCase in GraphQL. It's great to see the uniformity across different mappings.


166-168: Ohayo once more, sensei! LGTM: Consistent camelCase naming achieved

The renaming of "token_id" to "tokenId" and "contract_address" to "contractAddress" in the ERC_TOKEN_TYPE_MAPPING completes the trifecta of awesome camelCase consistency! 🎉

With these changes, all three mappings (ERC_BALANCE_TYPE_MAPPING, ERC_TRANSFER_TYPE_MAPPING, and ERC_TOKEN_TYPE_MAPPING) now uniformly use camelCase for their field names. This consistency will make our GraphQL API more intuitive and easier to work with for frontend developers.

Great job on achieving the PR objective across all relevant mappings!


151-168: Ohayo, sensei! Overall assessment: Excellent work on consistent naming

You've done a fantastic job implementing the camelCase naming convention across all relevant mappings (ERC_BALANCE_TYPE_MAPPING, ERC_TRANSFER_TYPE_MAPPING, and ERC_TOKEN_TYPE_MAPPING). These changes significantly enhance the consistency of our GraphQL schema and align it with widely-accepted naming conventions in the JavaScript/TypeScript ecosystem.

The modifications you've made will improve the developer experience for those consuming our GraphQL API, making it more intuitive and easier to work with. The consistency achieved here is commendable and contributes to a more professional and polished API design.

Keep up the great work, sensei! Your attention to detail and commitment to code quality are truly appreciated.

Copy link

codecov bot commented Oct 11, 2024

Codecov Report

Attention: Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.

Project coverage is 68.60%. Comparing base (fd1e0f9) to head (798ff06).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...rates/torii/graphql/src/object/erc/erc_transfer.rs 0.00% 11 Missing ⚠️
crates/torii/graphql/src/object/erc/erc_balance.rs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2515   +/-   ##
=======================================
  Coverage   68.59%   68.60%           
=======================================
  Files         387      387           
  Lines       49988    49988           
=======================================
+ Hits        34291    34295    +4     
+ Misses      15697    15693    -4     

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants