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

Fix naming conflicts in generate code #301

Merged
merged 2 commits into from
Jan 8, 2024

Conversation

kpob
Copy link
Contributor

@kpob kpob commented Dec 15, 2023

  • update macro code
  • move Ownable2Step module to ownable.rs

Before, keeping Ownable and Ownable2Step in the module did not work due to naming conflicts. Some entrypoints have the same name, and reexporting execute_ functions causes an error.
Keeping them inside separate modules resolves the issue. The only downside is using fully qualified paths when calling functions.

Summary by CodeRabbit

  • New Features

    • Implemented a two-step ownership transfer system with initiation and confirmation steps.
    • Introduced a new event to signal the start of an ownership transfer.
  • Refactor

    • Streamlined function call processes and enhanced error handling within the deployment utilities.
    • Simplified internal code structure by removing outdated components and updating naming conventions.
  • Documentation

    • Removed the ownable_2step module from the public documentation.
  • Style

    • Adjusted code style for better clarity and consistency in the use of module prefixes.

> * update macro code
> * move Ownable2Step module to ownable.rs
modules/src/access/ownable.rs Outdated Show resolved Hide resolved
@zie1ony
Copy link
Contributor

zie1ony commented Jan 5, 2024

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jan 5, 2024

Warning

Rate Limit Exceeded

@kpob has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 2 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between d26a17b and b30fc4e.

Walkthrough

The recent updates involve a significant overhaul of the ownership transfer mechanism, with a focus on a two-step transfer process. The ownable.rs module now supports a more secure ownership transition, and the macro-related files have undergone structural changes, simplifying the codebase by removing unnecessary components and refining the use of modules.

Changes

File Path Change Summary
.../access/ownable.rs Updated error variants and added two-step ownership transfer functionality with corresponding events.
.../src/lib.rs Removed ownable_2step from public modules.
.../ast/deployer_item.rs Replaced function calls with those from the __erc20_exec_parts module.
.../ast/deployer_utils.rs,
.../ast/module_impl_item.rs
Modified function return types and removed unused fields.
.../ast/exec_parts.rs Removed ExecPartsReexportItem and associated reexport logic.
.../ast/test_parts.rs,
.../ast/wasm_parts.rs
Renamed fields and updated function calls; added map operation and modified TryFrom implementations.

Poem

🐇✨
In the burrows of code, where the digits do leap,
A two-step dance for ownership, not to lose in a peep.
Refactoring done, with less clutter to sweep,
Now the code hops along, efficient and neat. 🌟
🐇✨

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.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9b753cc and d26a17b.
Files selected for processing (8)
  • modules/src/access/ownable.rs (2 hunks)
  • modules/src/lib.rs (1 hunks)
  • odra-macros/src/ast/deployer_item.rs (2 hunks)
  • odra-macros/src/ast/deployer_utils.rs (3 hunks)
  • odra-macros/src/ast/exec_parts.rs (1 hunks)
  • odra-macros/src/ast/module_impl_item.rs (2 hunks)
  • odra-macros/src/ast/test_parts.rs (4 hunks)
  • odra-macros/src/ast/wasm_parts.rs (6 hunks)
Files skipped from review due to trivial changes (1)
  • modules/src/lib.rs
Additional comments: 22
odra-macros/src/ast/module_impl_item.rs (2)
  • 3-3: The addition of ExecPartsItem to the imports suggests that it is now being used within this file. Ensure that this new import is indeed utilized in the subsequent code to avoid unused imports.

  • 19-19: The exec_parts_reexport field has been removed from the ModuleImplItem struct. Confirm that this field is no longer necessary and that its removal does not affect any functionality that depends on it.

odra-macros/src/ast/deployer_item.rs (2)
  • 94-106: The function calls within the match statement have been updated to use the __erc20_exec_parts module prefix. This change likely resolves the naming conflicts mentioned in the PR objectives. Ensure that the __erc20_exec_parts module is correctly defined and accessible from this context.

  • 145-149: Similar to the previous comment, the function calls within this match statement have been updated to use the __erc20_exec_parts module prefix. Verify that these changes are consistent throughout the codebase and that the __erc20_exec_parts module is correctly defined and accessible.

odra-macros/src/ast/deployer_utils.rs (3)
  • 67-67: The entrypoint_caller function now returns a syn::Result<syn::Expr> instead of Result<syn::Expr, syn::Error>. This change standardizes the error type with the rest of the codebase, assuming syn::Error is the only error type used.

  • 76-78: The collection of CallerBranch instances now includes error handling, which will propagate any errors encountered during the mapping process. This is a good practice as it ensures that errors are not silently ignored and are handled appropriately.

  • 182-193: The FunctionCallBranch struct now implements the TryFrom trait, and its call_stmt method returns a syn::Result<syn::Stmt> instead of syn::Stmt. This change enhances error handling by allowing the call_stmt method to return errors, which is consistent with the rest of the codebase.

odra-macros/src/ast/exec_parts.rs (1)
  • 10-12: The ExecPartsReexportItem struct and its associated logic have been removed. Confirm that this struct is no longer required and that its removal does not negatively impact any areas of the code that may have depended on the reexport functionality it provided.
odra-macros/src/ast/test_parts.rs (4)
  • 14-14: The attr field in the TestPartsReexportItem struct has been renamed to not_wasm_attr. This renaming makes the purpose of the attribute clearer, indicating that it is related to non-WASM targets.

  • 24-24: The not_wasm_attr field is being used to apply an attribute to the reexport statement. Ensure that this attribute is correctly applied in all relevant contexts and that the renaming does not affect any conditional compilation logic.

  • 180-192: Function calls within the Erc20Deployer struct's init method have been updated to use the __erc20_exec_parts module prefix. This change is consistent with the PR objectives to resolve naming conflicts. Verify that the __erc20_exec_parts module is correctly defined and accessible from this context.

  • 306-310: Similar to the previous comment, function calls within the Erc20Deployer struct's init method have been updated to use the __erc20_exec_parts module prefix. Again, verify that the __erc20_exec_parts module is correctly defined and accessible.

modules/src/access/ownable.rs (2)
  • 1-4: The import statements have been updated to include CallerNotTheNewOwner and OwnershipTransferStarted, which are new or renamed entities. Additionally, the Ownable module now emits the OwnershipTransferStarted event. Ensure that these changes are reflected throughout the codebase and that the new event is handled correctly where necessary.

  • 79-152: The Ownable2Step struct has been added, which includes a ModuleWrapper<Ownable> and a pending_owner variable for two-step ownership transfer. New functions such as transfer_ownership and accept_ownership have been introduced, along with the OwnershipTransferStarted event. Verify that the two-step ownership transfer logic is correctly implemented and that the new functions and events are integrated properly with the rest of the system.

odra-macros/src/ast/wasm_parts.rs (8)
  • 51-57: The addition of .map(|f| (module, f)) in the entry_points collection process is a logical change that aligns with the new TryFrom implementation for NoMangleFnItem which now requires a tuple of ModuleImplIR and FnIR. This ensures that the necessary context is passed to create NoMangleFnItem instances.

  • 160-175: The changes to the try_from method of NoMangleFnItem correctly use the exec_parts_ident to prefix the function calls, ensuring that the functions are called from the correct module. This is a necessary change to resolve the naming conflicts mentioned in the PR objectives.

  • 347-347: The update to prefix the execute_init function call with __erc20_exec_parts:: is consistent with the changes made to resolve naming conflicts. This ensures that the function is called from the correct module.

  • 352-352: The update to prefix the execute_total_supply function call with __erc20_exec_parts:: is consistent with the changes made to resolve naming conflicts. This ensures that the function is called from the correct module.

  • 362-362: The update to prefix the execute_pay_to_mint function call with __erc20_exec_parts:: is consistent with the changes made to resolve naming conflicts. This ensures that the function is called from the correct module.

  • 367-367: The update to prefix the execute_approve function call with __erc20_exec_parts:: is consistent with the changes made to resolve naming conflicts. This ensures that the function is called from the correct module.

  • 425-425: The update to prefix the execute_total_supply function call with __erc20_exec_parts:: in the test trait implementation is consistent with the changes made to resolve naming conflicts. This ensures that the function is called from the correct module.

  • 435-435: The update to prefix the execute_pay_to_mint function call with __erc20_exec_parts:: in the test trait implementation is consistent with the changes made to resolve naming conflicts. This ensures that the function is called from the correct module.

@kpob kpob merged commit 418e712 into release/0.8.0 Jan 8, 2024
1 check passed
@kpob kpob deleted the fix/macro/many-odra-modules-in-single-module branch January 8, 2024 06:49
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