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

clean up file structure for external devs #43

Merged
merged 5 commits into from
Feb 19, 2024
Merged

Conversation

tmsdkeys
Copy link
Contributor

@tmsdkeys tmsdkeys commented Feb 16, 2024

Closes: #36

This PR:

  • refactors file structure of the contracts folder, with meaningful organization into core, interfaces, utils etc.
  • updates imports for contracts and test directories
  • compilation and tests are okay

This will improve code readability for external developers (either application or chain devs)

Summary by CodeRabbit

  • Chores
    • Reorganized and updated import paths across various contracts and test files for improved project structure and maintainability.

Copy link

coderabbitai bot commented Feb 16, 2024

Walkthrough

The project underwent a significant reorganization to enhance developer experience by categorizing Solidity contracts into more intuitive directories such as core, interfaces, libs, examples, and utils. This restructure aims to declutter the contracts folder, making it easier for developers, especially those integrating via npm packages, to navigate and understand the project structure.

Changes

Files Change Summary
contracts/base/GeneralMiddleware.sol, contracts/examples/..., contracts/utils/... Updated import paths for interfaces and libraries.
contracts/core/..., contracts/interfaces/... Updated import paths and moved to interfaces or libs directories.

Assessment against linked issues

Objective Addressed Explanation
Refactor contracts folder for improved developer experience (#36)

Poem

"In the realm of code, where logic intertwines,
A rabbit hopped, through the lines.
🐰 With a swift, keen leap, and a joyful cheer,
Organized the chaos, far and near.
Into folders clear, the contracts fell,
Making devs' lives easier, as far as I can tell.
🌟 'Tis a tale of order, from clutter freed,
A story of success, in the code we read."

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@tmsdkeys
Copy link
Contributor Author

Considering updating the interface contracts to match the IInterfaceContract.sol naming conventions, e.g. IIbcDispatcher.sol

@tmsdkeys tmsdkeys marked this pull request as ready for review February 16, 2024 17:13
Copy link
Contributor

@nicopernas nicopernas left a comment

Choose a reason for hiding this comment

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

Lgtm!

We could also remove the src folder that's not used anymore. Or maybe move the contracts to src?

@tmsdkeys tmsdkeys merged commit f915d5f into main Feb 19, 2024
1 check passed
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 4151e64 and feb0a21.
Files selected for processing (24)
  • contracts/base/GeneralMiddleware.sol (1 hunks)
  • contracts/core/Dispatcher.sol (1 hunks)
  • contracts/core/OpConsensusStateManager.sol (1 hunks)
  • contracts/core/OpProofVerifier.sol (1 hunks)
  • contracts/core/UniversalChannelHandler.sol (1 hunks)
  • contracts/examples/Earth.sol (1 hunks)
  • contracts/examples/Mars.sol (1 hunks)
  • contracts/interfaces/ConsensusStateManager.sol (1 hunks)
  • contracts/interfaces/IbcDispatcher.sol (1 hunks)
  • contracts/interfaces/IbcMiddleware.sol (1 hunks)
  • contracts/interfaces/IbcReceiver.sol (1 hunks)
  • contracts/utils/DummyConsensusStateManager.sol (1 hunks)
  • contracts/utils/DummyProofVerifier.sol (1 hunks)
  • test/Dispatcher.base.t.sol (1 hunks)
  • test/Dispatcher.client.t.sol (1 hunks)
  • test/Dispatcher.proof.t.sol (1 hunks)
  • test/Dispatcher.t.sol (1 hunks)
  • test/Ibc.t.sol (1 hunks)
  • test/OpConsensusStateManager.t.sol (1 hunks)
  • test/Proof.base.t.sol (1 hunks)
  • test/Verifier.t.sol (1 hunks)
  • test/VirtualChain.sol (1 hunks)
  • test/payload/ack.t.sol (1 hunks)
  • test/universal.channel.t.sol (1 hunks)
Files skipped from review due to trivial changes (9)
  • contracts/base/GeneralMiddleware.sol
  • contracts/core/Dispatcher.sol
  • contracts/core/OpConsensusStateManager.sol
  • contracts/core/OpProofVerifier.sol
  • contracts/examples/Mars.sol
  • contracts/interfaces/IbcDispatcher.sol
  • contracts/interfaces/IbcMiddleware.sol
  • contracts/interfaces/IbcReceiver.sol
  • test/Dispatcher.t.sol
Additional comments: 16
contracts/utils/DummyProofVerifier.sol (1)
  • 4-4: The updated import path for ProofVerifier.sol correctly reflects the new structure of the contracts folder. This change is consistent with the PR's objectives to enhance code readability and maintainability.
contracts/interfaces/ConsensusStateManager.sol (1)
  • 4-4: The updated import path for Ibc.sol correctly reflects its new location within the project structure. This change supports the PR's goal of improving the project's organization and developer experience.
contracts/utils/DummyConsensusStateManager.sol (1)
  • 4-4: The updated import path for ConsensusStateManager.sol is correctly adjusted to match the new project structure. This change facilitates better organization and maintainability of the codebase.
test/Dispatcher.client.t.sol (1)
  • 4-9: The updated import paths for various contracts and interfaces accurately reflect their new locations within the project structure. These changes support the PR's goal of improving code organization and maintainability.
test/Ibc.t.sol (1)
  • 4-4: The updated import path for Ibc.sol correctly reflects its new location within the project structure. This change is in line with the PR's objectives to enhance the organization and readability of the codebase.
test/Dispatcher.proof.t.sol (2)
  • 4-6: The import paths have been updated to reflect the new project structure. Ensure that the new paths correctly point to the intended contracts within the libs, core, and examples directories.
  • 7-7: The import paths for contracts within the core directory are correctly updated. This change aligns with the PR's objective to enhance project structure and readability.
contracts/core/UniversalChannelHandler.sol (2)
  • 6-9: The import paths for interfaces and libraries have been correctly updated to reflect the new project structure, specifically pointing to the interfaces and libs directories. This change enhances the organization and readability of the codebase.
  • 10-10: The import path for the Mars contract within the examples directory is correctly updated, aligning with the PR's objective to improve project structure and readability.
test/Verifier.t.sol (2)
  • 4-5: The import paths for OpProofVerifier.sol and Ibc.sol have been updated to reflect their new locations within the core and libs directories, respectively. This change is in line with the PR's objective to reorganize the project structure for better readability and maintainability.
  • 6-6: The import path for the DummyConsensusStateManager utility has been correctly updated to reflect its location within the utils directory. This change aligns with the PR's objective to enhance project structure and readability.
test/VirtualChain.sol (2)
  • 6-14: The import paths for contracts and interfaces have been updated to reflect their new locations within the libs, core, interfaces, examples, and utils directories. This change enhances the organization and readability of the codebase, aligning with the PR's objectives.
  • 15-15: The import path for the GeneralMiddleware contract within the base directory is correctly updated, aligning with the PR's objective to improve project structure and readability.
test/universal.channel.t.sol (3)
  • 4-10: The import paths have been updated to reflect the new structure of the contracts folder. This is a crucial change to ensure that the tests are aligned with the reorganized project structure. However, it's important to verify that these paths are correct and that the referenced contracts exist at the new locations.
Verification successful

The verification process has successfully confirmed the existence of all the newly referenced contracts and interfaces at the specified locations within the contracts folder. This ensures that the updated import paths in the universal.channel.t.sol file are correct and align with the reorganized project structure.

  • Ibc.sol is located at contracts/libs/Ibc.sol.
  • Dispatcher.sol is located at contracts/core/Dispatcher.sol.
  • IbcDispatcher.sol is located at contracts/interfaces/IbcDispatcher.sol.
  • IbcReceiver.sol is located at contracts/interfaces/IbcReceiver.sol.
  • UniversalChannelHandler.sol is located at contracts/core/UniversalChannelHandler.sol.
  • Mars.sol is located at contracts/examples/Mars.sol.
  • OpConsensusStateManager.sol is located at contracts/core/OpConsensusStateManager.sol.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the existence of the newly referenced contracts and interfaces.
fd 'Ibc.sol' --exec test -f {}
fd 'Dispatcher.sol' --exec test -f {}
fd 'IbcDispatcher.sol' --exec test -f {}
fd 'IbcReceiver.sol' --exec test -f {}
fd 'UniversalChannelHandler.sol' --exec test -f {}
fd 'Mars.sol' --exec test -f {}
fd 'OpConsensusStateManager.sol' --exec test -f {}

Length of output: 584



Script:

#!/bin/bash
# Correctly verify the existence of the newly referenced contracts and interfaces by listing them.
fd 'Ibc.sol'
fd 'Dispatcher.sol'
fd 'IbcDispatcher.sol'
fd 'IbcReceiver.sol'
fd 'UniversalChannelHandler.sol'
fd 'Mars.sol'
fd 'OpConsensusStateManager.sol'

Length of output: 438

* 11-11: The tests within this file cover a wide range of scenarios, including channel settings, packet flows, and timeouts. It's commendable that the tests are designed to verify the functionality of the Universal Channel in various configurations and conditions. Ensure that these tests are comprehensive and cover all edge cases to maintain the robustness of the smart contract. * 11-11: Given the restructuring of the `contracts` folder, it's essential to ensure that all referenced contracts in the tests are correctly imported and utilized. This includes verifying that the contracts and interfaces are correctly placed in their new directories and that the import paths accurately reflect these changes. It's also important to ensure that the tests themselves are logically structured and follow best practices for smart contract testing.

@tmsdkeys tmsdkeys deleted the thomas/file-structure branch February 20, 2024 19:00
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.

Proposal to refactor contracts folder for devUX
2 participants