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

[CFE-635]: Feat - txs graphql to api #1135

Merged
merged 12 commits into from
Sep 18, 2024

Conversation

Poafs1
Copy link
Collaborator

@Poafs1 Poafs1 commented Sep 6, 2024

Summary by CodeRabbit

  • New Features

    • Introduced new API integration for transaction handling, improving data retrieval performance.
    • Added functions to fetch transaction data and counts by pool ID.
  • Improvements

    • Streamlined transaction count retrieval in the UI, enhancing performance and clarity.
    • Removed unused constants and functions to simplify the codebase.
  • Bug Fixes

    • Updated error handling in transaction data fetching to improve user experience.
  • Documentation

    • Updated changelog to reflect recent improvements and changes in transaction handling.

Copy link

vercel bot commented Sep 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
celatone-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 18, 2024 5:37am
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
celatone-frontend-main ⬜️ Ignored (Inspect) Visit Preview Sep 18, 2024 5:37am
initia-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Sep 18, 2024 5:37am
neutron-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Sep 18, 2024 5:37am
osmosis-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Sep 18, 2024 5:37am
sei-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Sep 18, 2024 5:37am
terra-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Sep 18, 2024 5:37am

@Poafs1 Poafs1 requested a review from songwongtp September 6, 2024 08:13
Copy link

linear bot commented Sep 6, 2024

@Poafs1 Poafs1 requested a review from evilpeach September 6, 2024 08:13
Copy link

coderabbitai bot commented Sep 6, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes involve significant updates to transaction handling within the codebase. Key modifications include the removal of outdated GraphQL queries and hooks, the introduction of new API functions for fetching transaction data, and the refactoring of components to streamline transaction count retrieval. Additionally, several constants and functions related to transaction counts have been eliminated or replaced, indicating a shift in the data-fetching strategy and overall structure.

Changes

Files Change Summary
CHANGELOG.md Added a new entry for improvements regarding API integration for transaction handling.
src/lib/data/constant.ts Removed export for the constant UPPERBOUND_COUNT, simplifying the module.
src/lib/pages/pools/components/pool-details/PoolRelatedTxs.tsx Refactored transaction count retrieval to use a single hook, improving efficiency and reducing re-renders.
src/lib/pages/pools/components/pool-details/tables/pool-txs/index.ts Updated hook for fetching transaction data, altering parameters and error handling.
src/lib/pages/pools/data.ts Removed the usePoolTxsCount function, streamlining transaction count management.
src/lib/query/tx.ts Removed getTxsByPoolIdPagination and getTxsCountByPoolId queries, simplifying transaction data retrieval.
src/lib/services/expression/index.ts Removed export for txExpression, altering the public API of the module.
src/lib/services/tx/api.ts Added new functions getTxsByPoolId and getTxsByPoolIdTableCounts for enhanced transaction querying.
src/lib/services/tx/index.ts Introduced useTxsByPoolId and useTxsByPoolIdTableCounts for improved transaction handling.
src/lib/query/index.ts Removed export of ./tx, altering the public interface of the module.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant API
    participant Service

    User->>UI: Request transaction data
    UI->>Service: Call useTxsByPoolId
    Service->>API: Fetch transaction data by pool ID
    API-->>Service: Return transaction data
    Service-->>UI: Provide transaction data
    UI-->>User: Display transaction data
Loading

🐰 "In the garden where data flows,
A new path for transactions grows.
With hooks and counts, we leap and bound,
In API fields, new treasures found!
Hooray for changes, let’s hop and play,
For smoother journeys, come what may!" 🐇✨


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 generate interesting stats about this repository and render them as a table.
    -- @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.

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.

Tip

Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI o1 for code reviews: OpenAI's new o1 model is being tested for code reviews. This model has advanced reasoning capabilities and can provide more nuanced feedback on your code.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b3d649b and 6ca8474.

Files selected for processing (10)
  • CHANGELOG.md (1 hunks)
  • src/lib/data/constant.ts (1 hunks)
  • src/lib/pages/pools/components/pool-details/PoolRelatedTxs.tsx (11 hunks)
  • src/lib/pages/pools/components/pool-details/tables/pool-txs/index.tsx (3 hunks)
  • src/lib/pages/pools/data.ts (2 hunks)
  • src/lib/query/tx.ts (1 hunks)
  • src/lib/services/expression/index.ts (1 hunks)
  • src/lib/services/tx/api.ts (2 hunks)
  • src/lib/services/tx/index.ts (4 hunks)
  • src/lib/services/types/tx.ts (1 hunks)
Files skipped from review due to trivial changes (4)
  • CHANGELOG.md
  • src/lib/data/constant.ts
  • src/lib/pages/pools/data.ts
  • src/lib/services/expression/index.ts
Additional comments not posted (14)
src/lib/query/tx.ts (3)

Line range hint 1-6: Query getTxsCount is correctly implemented.

This query remains unchanged and is correctly implemented according to the GraphQL syntax. It aligns with the PR objectives of simplifying transaction data retrieval.


Line range hint 30-38: Query for transaction count by block height is correctly implemented.

The query getBlockTransactionCountByHeightQueryDocument is correctly implemented. Ensure that the block_height parameter is correctly passed and handled in the codebase to maintain the integrity of the data fetched.

Run the following script to verify the parameter handling:

Verification successful

Verification of block_height Parameter Handling

The block_height parameter is used extensively across the codebase, particularly in GraphQL queries and TypeScript files. The search results indicate that the parameter is correctly implemented and utilized in various contexts, including queries and data models. This suggests that the parameter is being handled appropriately within the codebase.

  • Files with block_height usage:
    • src/lib/query/tx.ts: Used in GraphQL queries to filter transactions by block height.
    • src/lib/gql/gql.ts: Contains multiple queries utilizing block_height.
    • src/lib/gql/graphql.ts: Defines types and queries involving block_height.

Based on the gathered information, the handling of the block_height parameter appears to be consistent and correct across the codebase. However, it is recommended to manually verify the integration points to ensure that the parameter is passed and utilized correctly in all relevant parts of the application.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of `block_height` parameter in the codebase.

# Test: Search for the parameter usage. Expect: Correct implementation and usage across the codebase.
rg --type python -A 5 $'block_height'

Length of output: 67


Script:

#!/bin/bash
# Description: Verify the handling of `block_height` parameter in the TypeScript codebase.

# Test: Search for the parameter usage in TypeScript files. Expect: Correct implementation and usage across the codebase.
rg --type ts -A 5 'block_height'

Length of output: 165396


Line range hint 8-28: Complex query handling multiple conditions.

The query getBlockTransactionsByHeightQueryDocument is complex and handles multiple conditions based on isWasm and isMove flags. Ensure that these flags are correctly handled elsewhere in the codebase to maintain the integrity of the data fetched.

Run the following script to verify the flag handling:

src/lib/pages/pools/components/pool-details/PoolRelatedTxs.tsx (4)

73-138: Approve the direct usage of transaction counts in CustomTab components.

Using the transaction counts directly from the hook's response in CustomTab components is an effective way to ensure that the displayed data is accurate and up-to-date. This approach reduces the complexity and potential for errors in data handling.


Line range hint 149-213: Approve the updated rendering logic but verify the UI display.

The return statement has been correctly updated to reflect the new data structure, ensuring that the correct transaction counts are passed to each PoolRelatedTxsTable based on the selected tab. Verify that the UI correctly displays these counts to ensure the functionality remains intact.


14-14: Verify the import of the new hook.

Ensure that the hook useTxsByPoolIdTableCounts is correctly imported and available in the lib/services/tx module as expected.

Verification successful

Import statement is correct.

The hook useTxsByPoolIdTableCounts is correctly defined and exported in the lib/services/tx module, confirming that the import statement in PoolRelatedTxs.tsx is valid. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of `useTxsByPoolIdTableCounts` in the `lib/services/tx` module.

# Test: Search for the hook definition. Expect: At least one occurrence.
rg --type typescript -A 5 $'export const useTxsByPoolIdTableCounts'

Length of output: 103


Script:

#!/bin/bash
# Description: Verify the existence of `useTxsByPoolIdTableCounts` in the `lib/services/tx` module.

# Test: Search for the hook definition. Expect: At least one occurrence.
rg --type ts -A 5 $'export const useTxsByPoolIdTableCounts'

Length of output: 442


36-46: Approve the usage of the new hook but verify its impact.

The refactoring to use useTxsByPoolIdTableCounts simplifies the component by reducing the number of hooks and potentially improving performance. However, verify that this change integrates correctly across the application, especially where transaction counts are displayed or used.

Verification successful

Verify the functionality of useTxsByPoolIdTableCounts in PoolRelatedTxs.tsx.

The useTxsByPoolIdTableCounts hook is currently only used in the PoolRelatedTxs.tsx component. Ensure that its integration is functioning correctly within this component, as there are no other usages in the codebase.

  • File: src/lib/pages/pools/components/pool-details/PoolRelatedTxs.tsx
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `useTxsByPoolIdTableCounts` across the application.

# Test: Search for the hook usage in other components. Expect: Consistent usage and handling of the response.
rg --type typescript -A 5 $'useTxsByPoolIdTableCounts'

Length of output: 88


Script:

#!/bin/bash
# Description: Verify the integration of `useTxsByPoolIdTableCounts` across the application.

# Test: Search for the hook usage in other components. Expect: Consistent usage and handling of the response.
rg --type ts -A 5 $'useTxsByPoolIdTableCounts'

Length of output: 1536

src/lib/pages/pools/components/pool-details/tables/pool-txs/index.tsx (3)

7-7: Import statement updated for new hook.

The import statement has been updated to use useTxsByPoolId instead of useTxsByPoolIdPagination. This change aligns with the new API-based approach for fetching transaction data.

Run the following script to verify the implementation of the new hook:

Verification successful

Import statement and hook implementation verified.

The useTxsByPoolId hook is correctly implemented in src/lib/services/tx/index.ts and the import statement in index.tsx is accurate. The function is defined as a constant and takes parameters suitable for fetching transactions by pool ID. No issues were found with the import or implementation.

  • src/lib/services/tx/index.ts: Implementation of useTxsByPoolId.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `useTxsByPoolId`.

# Test: Search for the hook implementation. Expect: Only occurrences of the new hook.
ast-grep --lang javascript --pattern $'export function useTxsByPoolId($_, $_, $_, $_) {
  $$$
}'

Length of output: 97


Script:

#!/bin/bash
# Description: Broaden the search for the `useTxsByPoolId` function definition.

# Search for any function definition named `useTxsByPoolId`.
ast-grep --lang javascript --pattern $'function useTxsByPoolId($$$) {
  $$$
}'

# Search for any occurrences of `useTxsByPoolId` in the codebase to gather more context.
rg 'useTxsByPoolId' -A 5

Length of output: 3065


48-49: Error handling property updated.

The error handling property in the hook's response has been updated from error to isError. This change likely standardizes error handling across the application.

Run the following script to verify consistent usage of isError across the component:

Also applies to: 61-61

Verification successful

Error handling property updated and verified.

The error handling property in the hook's response has been updated from error to isError and is used consistently in the src/lib/pages/pools/components/pool-details/tables/pool-txs/index.tsx file. No issues were found with this change.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent usage of `isError` in the component.

# Test: Search for any remaining occurrences of `error`. Expect: No occurrences.
rg --type javascript -A 5 $'error'

Length of output: 68


Script:

#!/bin/bash
# Description: Verify consistent usage of `isError` in the component.

# Test: Search for any remaining occurrences of `error`. Expect: No occurrences.
rg --type ts -A 5 $'error'

Length of output: 250477


Script:

#!/bin/bash
# Description: Verify consistent usage of `isError` in the specific file.

# Test: Search for occurrences of `error` and `isError` in the specific file.
rg 'error|isError' src/lib/pages/pools/components/pool-details/tables/pool-txs/index.tsx -A 5

Length of output: 373


67-67: Data structure updated for transactions.

The transactions are now accessed via txs?.items, indicating a change in the data structure returned by the hook. This should be verified to ensure that the PoolTxsTable component handles the new structure correctly.

Run the following script to verify the handling of txs?.items in the PoolTxsTable component:

src/lib/services/tx/api.ts (1)

7-8: Approved import changes.

The new imports are correctly placed and are essential for the added functionality.

Also applies to: 12-12

src/lib/services/types/tx.ts (3)

372-401: Review: zTxByPoolIdResponse schema implementation.

The schema is well-defined with appropriate transformations and nested structures. It correctly handles the conversion of snake_case to camelCase and parses transaction hashes. Ensure that the API consistently returns the data in the expected format to match this schema.


403-406: Review: zTxsByPoolIdResponse constant implementation.

This constant is correctly defined to represent a collection of transactions by pool ID, using an array of zTxByPoolIdResponse. It is well-aligned with the expected API response structure.


408-419: Review: zTxsByPoolIdTxsCountResponse constant implementation.

This constant is well-defined and includes a comprehensive summary of transaction counts across various categories. The transformation to camelCase is correctly applied, ensuring consistency with the rest of the application's data handling.

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, codebase verification and nitpick comments (1)
src/lib/query/index.ts (1)

Action Required: Address Remaining References to ./tx Module

The removal of the ./tx module export from src/lib/query/index.ts has not been fully integrated into the codebase. Multiple files still reference this module, which could lead to broken imports and functionality. Please ensure that all references to the ./tx module are updated or removed as necessary.

  • Files with References:
    • src/lib/utils/index.ts
    • src/lib/types/nft.ts
    • src/lib/types/contract.ts
    • src/lib/types/index.ts
    • src/lib/services/types/block.ts
    • src/lib/services/types/index.ts
    • src/lib/services/searchService.ts
    • src/lib/services/nft/sequencer.ts
    • src/lib/services/nft-collection/sequencer.ts
    • src/lib/app-provider/index.ts
    • src/lib/data/index.ts
    • And many more...
Analysis chain

Line range hint 1-9: Verify the impact of removing the ./tx module.

The removal of the ./tx module export from this file could potentially break existing functionality that depends on it. It's crucial to verify that all references to this module have been updated or removed accordingly.

Run the following script to verify the usage of the ./tx module:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the `./tx` module have been updated or removed.

# Test: Search for the module usage. Expect: No occurrences of the `./tx` module.
rg --type typescript -A 5 $'./tx'

Length of output: 67


Script:

#!/bin/bash
# Description: Verify all references to the `./tx` module have been updated or removed.

# Test: Search for the module usage. Expect: No occurrences of the `./tx` module.
rg --type ts -A 5 $'./tx'

Length of output: 62848

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6ca8474 and d7e8b0b.

Files selected for processing (1)
  • src/lib/query/index.ts (1 hunks)
Additional comments not posted (1)
src/lib/query/index.ts (1)

Line range hint 1-9: Verify the integration and usage of the ./nft and ./nftOld modules.

The addition of the ./nft and ./nftOld exports suggests new functionality or refactoring of existing features. Ensure that these modules are properly integrated and used across the codebase.

Run the following script to verify the integration and usage of the ./nft and ./nftOld modules:

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d7e8b0b and 42d49d4.

Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • src/lib/services/tx/index.ts (5 hunks)
Files skipped from review as they are similar to previous changes (2)
  • CHANGELOG.md
  • src/lib/services/tx/index.ts

@evilpeach
Copy link
Collaborator

Please resolve the conflict.

@evilpeach
Copy link
Collaborator

Also, please resolve the conflict.

@songwongtp songwongtp merged commit f96c818 into refactor/graphql Sep 18, 2024
8 checks passed
@songwongtp songwongtp deleted the feature/cfe-635-tx-graphql branch September 18, 2024 05:38
@coderabbitai coderabbitai bot mentioned this pull request Sep 18, 2024
@coderabbitai coderabbitai bot mentioned this pull request Jan 13, 2025
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.

3 participants