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: refactor code & replace coinConvert with sdk RegisterDenom #2941

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

dreamer-zq
Copy link
Contributor

@dreamer-zq dreamer-zq commented May 30, 2024

Summary by CodeRabbit

  • Refactor

    • Updated internal references from iristypes to params for better modularity and maintainability.
    • Refactored token parameter declarations to use a new configuration structure.
  • Chores

    • Cleaned up import statements and updated package references across various files to ensure consistency.

These changes aim to enhance code clarity and future-proof the application by improving the organization of configuration parameters.

Copy link

coderabbitai bot commented May 30, 2024

Walkthrough

The refactoring effort primarily involves replacing references from iristypes to params across various files within the application. This includes updating import paths, variable assignments, and function calls to align with the new params package. Additionally, the changes introduce new initialization functions for token parameters and adjust the GenesisState type definition for better management of module genesis information.

Changes

Files Change Summary
app/app.go, app/genesis.go, app/params/address.go, app/params/params.go Refactored to replace iristypes with params and updated function calls and type declarations.
app/keepers/keepers.go Imported params2 and updated references to token parameters and Bech32 prefixes.
app/sim_test.go Adjusted import paths and variable assignments for token symbols and genesis state.
app/upgrades/v200/config.go Updated import statement and token parameter assignments.
cmd/iris/cmd/root.go, cmd/iris/cmd/testnet.go, cmd/iris/main.go Updated references from iristypes to params for default node home and app configuration.
modules/guardian/types/msgs_test.go Replaced import statement from iristypes to params.

Poem

In code's vast garden, changes bloom,
iristypes now finds its room,
As params take the stage anew,
With tokens bright and functions true.
A rabbit's cheer, with code refined,
For paths aligned and well-defined! 🐇🌸


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 Configration 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.

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 b1a5870 and 01ebbfc.
Files selected for processing (11)
  • app/app.go (4 hunks)
  • app/genesis.go (1 hunks)
  • app/keepers/keepers.go (4 hunks)
  • app/params/address.go (1 hunks)
  • app/params/params.go (1 hunks)
  • app/sim_test.go (4 hunks)
  • app/upgrades/v200/config.go (2 hunks)
  • cmd/iris/cmd/root.go (7 hunks)
  • cmd/iris/cmd/testnet.go (5 hunks)
  • cmd/iris/main.go (1 hunks)
  • modules/guardian/types/msgs_test.go (1 hunks)
Files skipped from review due to trivial changes (3)
  • app/params/address.go
  • app/sim_test.go
  • modules/guardian/types/msgs_test.go
Additional comments not posted (11)
cmd/iris/main.go (2)

8-8: Import of params package is correctly updated.


17-17: Usage of params.DefaultNodeHome is consistent with the refactoring goal.

Verification successful

Usage of params.DefaultNodeHome is consistent across the application.

  • app/params/params.go: Definition and initialization of DefaultNodeHome.
  • cmd/iris/main.go: Usage in svrcmd.Execute.
  • cmd/iris/cmd/root.go: Multiple usages in various commands and initializations.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `params.DefaultNodeHome` is used consistently across the application.

# Test: Search for the usage of `DefaultNodeHome`. Expect: Only occurrences from `params`.
rg --type python $'DefaultNodeHome'

Length of output: 65



Script:

#!/bin/bash
# Description: Verify that `params.DefaultNodeHome` is used consistently across the application.

# Test: Search for the usage of `DefaultNodeHome`. Expect: Only occurrences from `params`.
rg --type go 'DefaultNodeHome'

Length of output: 878

app/genesis.go (1)

12-12: Refactor of GenesisState to a map increases flexibility for module-specific genesis configurations.

app/upgrades/v200/config.go (1)

18-18: Correct use of params.EvmToken aligns with the refactoring objectives.

Verification successful

The usage of EvmToken appears consistent across the application, with references in multiple files indicating its integration. Here are the relevant locations:

  • app/params/params.go
  • app/upgrades/v200/config.go
  • app/keepers/keepers.go
  • cmd/iris/cmd/testnet.go

This confirms that params.EvmToken is correctly utilized in the refactoring process.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `EvmToken` is used consistently across the application.

# Test: Search for the usage of `EvmToken`. Expect: Only occurrences from `params`.
rg --type python $'EvmToken'

Length of output: 58



Script:

#!/bin/bash
# Description: Verify that `EvmToken` is used consistently across the application.

# Test: Search for the usage of `EvmToken`. Expect: Only occurrences from `params`.
rg --type go EvmToken

Length of output: 717

cmd/iris/cmd/root.go (1)

50-50: Updated references to params.DefaultNodeHome and params.BaseToken.MinUnit are correctly implemented.

Also applies to: 106-106, 124-124, 126-126, 132-132, 137-137, 155-155, 164-164

Verification successful

The updated references to params.DefaultNodeHome and params.BaseToken.MinUnit are used consistently across the application.

  • cmd/iris/main.go
  • cmd/iris/cmd/root.go
  • cmd/iris/cmd/testnet.go
  • app/params/params.go
  • app/keepers/keepers.go
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `DefaultNodeHome` and `BaseToken.MinUnit` are used consistently across the application.

# Test: Search for the usage of these configurations. Expect: Only occurrences from `params`.
rg --type python $'DefaultNodeHome|BaseToken.MinUnit'

Length of output: 85



Script:

#!/bin/bash
# Description: Verify that `DefaultNodeHome` and `BaseToken.MinUnit` are used consistently across the application.

# Test: Search for the usage of these configurations. Expect: Only occurrences from `params`.
rg --type go 'DefaultNodeHome|BaseToken.MinUnit'

Length of output: 1584

app/app.go (1)

87-87: Updated usage of params.AppName, GenesisState, and params.InjectCodec are correctly implemented.

Also applies to: 239-239, 362-362

Verification successful

The search results indicate that AppName, GenesisState, and InjectCodec are used in various parts of the codebase, including app/app.go, app/params/params.go, and other modules. The usage appears consistent with the refactoring goals.

  • AppName is defined in app/params/params.go and used in app/app.go and other files.
  • GenesisState is used extensively across multiple modules, indicating its central role in the application's initialization and state management.
  • InjectCodec is defined in app/params/params.go and used in app/app.go.

These findings confirm that the changes are correctly implemented and consistent across the application.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `AppName`, `GenesisState`, and `InjectCodec` are used consistently across the application.

# Test: Search for the usage of these entities. Expect: Only occurrences from `params`.
rg --type python $'AppName|GenesisState|InjectCodec'

Length of output: 84



Script:

#!/bin/bash
# Description: Verify that `AppName`, `GenesisState`, and `InjectCodec` are used consistently across the application.

# Test: Search for the usage of these entities. Expect: Only occurrences from `params`.
rg --type go 'AppName|GenesisState|InjectCodec'

Length of output: 10134

cmd/iris/cmd/testnet.go (2)

15-15: Updated import from iristypes to params aligns with the PR's objective to centralize token parameters.


305-305: Ensure that the AppConfig function is correctly handling the BaseToken.MinUnit from the params package.

app/keepers/keepers.go (3)

4-4: Updated import alias from iristypes to params2 is consistent with the PR's refactoring goals.


235-235: The update to use Bech32PrefixAccAddr from params2 ensures consistency in address formatting across the application.


559-564: The configuration of BaseToken and EvmToken using params2 aligns with the new structure and ensures correct token handling in the swap functionality.

Comment on lines +23 to +25
// AppName is the name of the app
AppName = "IrisApp"
EIP155ChainID = "6688"
Copy link

Choose a reason for hiding this comment

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

Extensive additions in params.go introduce crucial configurations and utility functions. Ensure these are covered by unit tests.

Would you like me to help in writing unit tests for these new functions?

Also applies to: 28-34, 37-101, 103-117

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 01ebbfc and 07e5392.
Files selected for processing (1)
  • app/keepers/keepers.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/keepers/keepers.go

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 07e5392 and 009f068.

Files selected for processing (1)
  • modules/guardian/types/msgs_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • modules/guardian/types/msgs_test.go

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.

1 participant