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-389]: Feat: add get all codes and contracts #1101

Merged
merged 6 commits into from
Aug 22, 2024

Conversation

Poafs1
Copy link
Collaborator

@Poafs1 Poafs1 commented Aug 21, 2024

Summary by CodeRabbit

  • New Features

    • Introduced new querying capabilities with ALL_CODES_BY_ADDRESS and ALL_INSTANTIATED_CONTRACTS_BY_ADDRESS enumerations.
    • Added functions useAllCodesByAddress and useAllInstantiatedContractsByAddress to enhance data retrieval options.
    • New API functions to fetch all codes and instantiated contracts based on an address.
    • Updated existing functions to utilize enhanced parsing methods for consistent error handling.
  • Bug Fixes

    • Simplified parameters for fetching instantiated contracts, improving the function's efficiency.
  • Style

    • Improved the layout and alignment of components in the ContractTop section for better visual presentation.

Copy link

linear bot commented Aug 21, 2024

Copy link

vercel bot commented Aug 21, 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 Aug 22, 2024 8:35am
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
celatone-frontend-main ⬜️ Ignored (Inspect) Visit Preview Aug 22, 2024 8:35am
initia-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Aug 22, 2024 8:35am
neutron-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Aug 22, 2024 8:35am
osmosis-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Aug 22, 2024 8:35am
sei-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Aug 22, 2024 8:35am
terra-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Aug 22, 2024 8:35am

@Poafs1 Poafs1 requested a review from songwongtp August 21, 2024 09:11
Copy link

coderabbitai bot commented Aug 21, 2024

Walkthrough

The changes include the introduction of new APIs for fetching all codes and instantiated contracts by address, enhancing the application's data retrieval capabilities. Key updates involve the addition of enumerations, new asynchronous functions, and the renaming of existing hooks for clarity and efficiency. The overall structure and presentation of frontend components were also refined. These modifications collectively expand the application's functionality and streamline backend processes.

Changes

Files Change Summary
src/lib/app-provider/env.ts Added ALL_CODES_BY_ADDRESS and ALL_INSTANTIATED_CONTRACTS_BY_ADDRESS enumerations for enhanced querying.
src/lib/model/code.ts, src/lib/services/wasm/code Replaced useCodeListByWalletAddress with useAllCodesByAddress, adjusted data structure access, and improved type safety.
src/lib/model/contract.ts Renamed useInstantiatedContractsByAddress to useAllInstantiatedContractsByAddress; simplified function parameters for data fetching.
src/lib/pages/contract-details/components/ContractTop.tsx Adjusted layout and alignment of components for improved visual presentation.
src/lib/services/wasm/code/api.ts Introduced getAllCodesByAddress function for retrieving codes by address from an API endpoint and updated parsing in getCodesByAddress.
src/lib/services/wasm/code/gql.ts Removed useCodeListByWalletAddress function; useCodeListByCodeIds remains unchanged.
src/lib/services/wasm/code/index.ts Added useAllCodesByAddress function for querying all codes associated with an address.
src/lib/services/wasm/contract/api.ts Introduced getAllInstantiatedContractsByAddress function for retrieving instantiated contracts by address from an API endpoint.
src/lib/services/wasm/contract/index.ts Added useAllInstantiatedContractsByAddress function for querying all instantiated contracts by address.
CHANGELOG.md Documented the addition of new APIs for retrieving all codes and contracts, referencing pull request #1101.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frontend
    participant Backend
    participant API

    User->>Frontend: Request codes by address
    Frontend->>Backend: Call useAllCodesByAddress(address)
    Backend->>API: GET /codes?address={address}
    API-->>Backend: Return codes data
    Backend-->>Frontend: Return codes list
    Frontend-->>User: Display codes
Loading
sequenceDiagram
    participant User
    participant Frontend
    participant Backend
    participant API

    User->>Frontend: Request instantiated contracts by address
    Frontend->>Backend: Call useAllInstantiatedContractsByAddress(address)
    Backend->>API: GET /contracts?address={address}
    API-->>Backend: Return contracts data
    Backend-->>Frontend: Return contracts list
    Frontend-->>User: Display contracts
Loading

Poem

🐇 In the garden where changes bloom,
New queries sprout, dispelling gloom.
Codes and contracts, all in sight,
Hop along, making data bright!
With a hop and a bounce, let's explore,
A world of information—who could ask for more? 🌼


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.

@Poafs1 Poafs1 requested a review from evilpeach August 21, 2024 09:11
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 043fafe and 64a0db3.

Files selected for processing (9)
  • src/lib/app-provider/env.ts (2 hunks)
  • src/lib/model/code.ts (1 hunks)
  • src/lib/model/contract.ts (2 hunks)
  • src/lib/pages/contract-details/components/ContractTop.tsx (2 hunks)
  • src/lib/services/wasm/code/api.ts (1 hunks)
  • src/lib/services/wasm/code/gql.ts (1 hunks)
  • src/lib/services/wasm/code/index.ts (2 hunks)
  • src/lib/services/wasm/contract/api.ts (1 hunks)
  • src/lib/services/wasm/contract/index.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • src/lib/pages/contract-details/components/ContractTop.tsx
Additional comments not posted (9)
src/lib/services/wasm/code/gql.ts (1)

6-6: Verify the impact of removing useCodeListByWalletAddress.

The removal of useCodeListByWalletAddress may affect components or services relying on this feature. Ensure that this change does not break any functionality.

Run the following script to identify any usage of useCodeListByWalletAddress in the codebase:

Verification successful

No impact from removing useCodeListByWalletAddress.

The search did not find any usage of useCodeListByWalletAddress in the codebase, indicating that its removal does not affect any functionality.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any usage of `useCodeListByWalletAddress` in the codebase.

# Test: Search for the function usage. Expect: No occurrences.
rg --type javascript --type typescript -A 5 $'useCodeListByWalletAddress'

Length of output: 107


Script:

#!/bin/bash
# Description: Search for any usage of `useCodeListByWalletAddress` in JavaScript and TypeScript files.

# Test: Search for the function usage. Expect: No occurrences.
rg --glob '*.js' --glob '*.ts' -A 5 'useCodeListByWalletAddress'

Length of output: 64

src/lib/model/contract.ts (1)

5-5: Verify the impact of renaming and modifying useAllInstantiatedContractsByAddress.

The function has been renamed and its parameters simplified. Verify that this change does not affect the contract retrieval logic in unintended ways.

Run the following script to identify any usage of useAllInstantiatedContractsByAddress in the codebase:

Verification successful

Verification Successful: Consistent Usage of useAllInstantiatedContractsByAddress

The function useAllInstantiatedContractsByAddress has been renamed and its parameters simplified. The usage in the codebase is consistent with the new signature, and no unintended effects on the contract retrieval logic have been identified.

  • File: src/lib/model/contract.ts
  • File: src/lib/services/wasm/contract/index.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any usage of `useAllInstantiatedContractsByAddress` in the codebase.

# Test: Search for the function usage. Expect: Consistent usage with the new signature.
rg --type javascript --type typescript -A 5 $'useAllInstantiatedContractsByAddress'

Length of output: 117


Script:

#!/bin/bash
# Description: Search for any usage of `useAllInstantiatedContractsByAddress` in the codebase.

# Test: Search for the function usage. Expect: Consistent usage with the new signature.
rg --type js --type ts -A 5 $'useAllInstantiatedContractsByAddress'

Length of output: 1341

src/lib/services/wasm/code/api.ts (1)

41-47: LGTM! New function getAllCodesByAddress added.

The function enhances the API's functionality by allowing users to fetch all codes related to a specific address. The implementation is consistent with existing patterns.

src/lib/model/code.ts (1)

12-15: Verify the impact of using useAllCodesByAddress in useStoredCodes.

The hook now uses useAllCodesByAddress, which changes how stored codes are retrieved. Ensure that this change does not affect the processing and display of stored codes.

Run the following script to identify any usage of useStoredCodes in the codebase:

Verification successful

Impact of useAllCodesByAddress in useStoredCodes is localized

The useStoredCodes function, which now uses useAllCodesByAddress, is defined and used only within src/lib/model/code.ts. This indicates that any changes in data retrieval logic are confined to this file. Ensure that the processing and display logic within this file correctly handles the data retrieved by useAllCodesByAddress.

  • File to review: src/lib/model/code.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any usage of `useStoredCodes` in the codebase.

# Test: Search for the function usage. Expect: Consistent usage with the new data retrieval logic.
rg --type javascript --type typescript -A 5 $'useStoredCodes'

Length of output: 95


Script:

#!/bin/bash
# Description: Search for any usage of `useStoredCodes` in the codebase.

# Test: Search for the function usage. Expect: Consistent usage with the new data retrieval logic.
rg --type js --type ts -A 5 $'useStoredCodes'

Length of output: 843

src/lib/services/wasm/code/index.ts (1)

105-118: LGTM! New function useAllCodesByAddress added.

The function adds a new data retrieval feature while maintaining existing functionalities. The implementation is consistent with existing patterns.

src/lib/services/wasm/contract/api.ts (1)

47-53: LGTM!

The function getAllInstantiatedContractsByAddress is correctly implemented. It constructs the URL using encodeURI and processes the response with parseWithError.

src/lib/services/wasm/contract/index.ts (1)

154-179: LGTM!

The function useAllInstantiatedContractsByAddress is well-implemented. It ensures that the query only runs if an address is provided and uses useBaseApiRoute to determine the endpoint.

src/lib/app-provider/env.ts (2)

33-33: LGTM!

The enumeration ALL_CODES_BY_ADDRESS is correctly added to CELATONE_QUERY_KEYS and follows the naming convention.


47-47: LGTM!

The enumeration ALL_INSTANTIATED_CONTRACTS_BY_ADDRESS is correctly added to CELATONE_QUERY_KEYS and follows the naming convention.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 64a0db3 and 707ea35.

Files selected for processing (1)
  • CHANGELOG.md (1 hunks)

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 707ea35 and 45a7865.

Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • src/lib/model/code.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md
Additional comments not posted (2)
src/lib/model/code.ts (2)

8-11: Import changes approved.

The import of useAllCodesByAddress and BechAddr aligns with the changes in the hook function and enhances type safety.


18-23: Changes to useStoredCodes function approved.

The use of useAllCodesByAddress with address cast to BechAddr and accessing rawStoredCodes.items is consistent with the new data structure and enhances type safety.

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 45a7865 and 40696a0.

Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • src/lib/app-provider/env.ts (2 hunks)
  • src/lib/services/wasm/contract/index.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • CHANGELOG.md
  • src/lib/app-provider/env.ts

Copy link
Collaborator

@evilpeach evilpeach left a comment

Choose a reason for hiding this comment

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

Look so good to me!!

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 40696a0 and 44379f7.

Files selected for processing (1)
  • src/lib/services/wasm/code/api.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/lib/services/wasm/code/api.ts

@evilpeach evilpeach merged commit fa7326f into develop Aug 22, 2024
13 checks passed
@evilpeach evilpeach deleted the feature/cfe-389-show-all-code-contracts branch August 22, 2024 08:37
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