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: remove gov dependency from modules and sdk #18424

Merged
merged 3 commits into from Nov 9, 2023

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Nov 9, 2023

Description

ref: #18290

Extract a all x/gov changes from #18381 to extract x/gov from the SDK and modules.
Extracting from the original PR because I was getting issues.
Additionally, scoped PR are better :D

proof


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Summary by CodeRabbit

  • New Features
    • Introduced a new testutil package with constants representing module names.
    • Added a new error ErrInvalidSigner in x/crisis/types and x/slashing/types for better error handling.
  • Refactor
    • Replaced hard-coded module names with references from the testutil package across various parts of the code.
    • Removed cyclic dependencies with the x/gov module by introducing new constants in x/crisis/types, x/upgrade/types, and x/slashing/types.
  • Chores
    • Updated comments in x/distribution/types and x/protocolpool/types to explain the duplication of the GovModuleName.

Copy link
Contributor

coderabbitai bot commented Nov 9, 2023

Walkthrough

Walkthrough

The changes primarily involve the introduction of a new testutil package and the replacement of hardcoded module names with constants from this package across various files. This aims to improve code maintainability and reduce potential errors related to hardcoded strings. Additionally, new error types are introduced in the x/crisis and x/slashing modules, and cyclic dependencies with the x/gov module are avoided by duplicating the module name in several modules.

Changes

File(s) Change Summary
baseapp/block_gas_test.go, testutil/configurator/configurator.go, testutil/types.go Introduced a new testutil package and replaced hardcoded module names with constants from this package.
go.work.example Added the "./x/mint" module.
x/crisis/keeper/msg_server.go, x/crisis/module.go, x/crisis/types/errors.go, x/crisis/types/keys.go Removed import of "cosmossdk.io/x/gov/types", introduced a new error ErrInvalidSigner, and added a new constant GovModuleName to avoid cyclic dependency with the x/gov module.
x/distribution/types/keys.go, x/protocolpool/types/keys.go Added a comment explaining the duplication of the GovModuleName to avoid cyclic dependency with x/gov.
x/protocolpool/testutil/app_config.go Removed the import of "cosmossdk.io/x/gov" and the corresponding configuration module from the application setup.
x/slashing/keeper/keeper_test.go, x/slashing/keeper/msg_server.go, x/slashing/module.go, x/slashing/types/errors.go, x/slashing/types/keys.go Removed import of "cosmossdk.io/x/gov/types", introduced a new error ErrInvalidSigner, and added a new global variable GovModuleName to avoid cyclic dependency.
x/upgrade/keeper/grpc_query_test.go, x/upgrade/keeper/keeper_test.go, x/upgrade/module.go, x/upgrade/types/keys.go Replaced hardcoded module name "gov" with a reference to the types.GovModuleName constant and introduced a new constant GovModuleName to avoid cyclic dependency with the x/gov module.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

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

@julienrbrt julienrbrt marked this pull request as ready for review November 9, 2023 19:18
@julienrbrt julienrbrt requested a review from a team as a code owner November 9, 2023 19:18
@github-prbot github-prbot requested review from a team, alexanderbez and testinginprod and removed request for a team November 9, 2023 19:19
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 097f99d and 8273002.
Files ignored due to filter (17)
  • client/v2/go.mod
  • go.mod
  • x/accounts/go.mod
  • x/auth/go.mod
  • x/bank/go.mod
  • x/circuit/go.mod
  • x/distribution/go.mod
  • x/distribution/go.sum
  • x/evidence/go.mod
  • x/mint/go.mod
  • x/nft/go.mod
  • x/protocolpool/go.mod
  • x/protocolpool/go.sum
  • x/slashing/go.mod
  • x/slashing/go.sum
  • x/staking/go.mod
  • x/staking/go.sum
Files selected for processing (20)
  • baseapp/block_gas_test.go (3 hunks)
  • go.work.example (1 hunks)
  • testutil/configurator/configurator.go (10 hunks)
  • testutil/types.go (1 hunks)
  • x/crisis/keeper/msg_server.go (2 hunks)
  • x/crisis/module.go (2 hunks)
  • x/crisis/types/errors.go (1 hunks)
  • x/crisis/types/keys.go (1 hunks)
  • x/distribution/types/keys.go (1 hunks)
  • x/protocolpool/testutil/app_config.go (2 hunks)
  • x/protocolpool/types/keys.go (1 hunks)
  • x/slashing/keeper/keeper_test.go (2 hunks)
  • x/slashing/keeper/msg_server.go (2 hunks)
  • x/slashing/module.go (2 hunks)
  • x/slashing/types/errors.go (1 hunks)
  • x/slashing/types/keys.go (1 hunks)
  • x/upgrade/keeper/grpc_query_test.go (1 hunks)
  • x/upgrade/keeper/keeper_test.go (2 hunks)
  • x/upgrade/module.go (2 hunks)
  • x/upgrade/types/keys.go (1 hunks)
Files skipped from review due to trivial changes (12)
  • baseapp/block_gas_test.go
  • go.work.example
  • testutil/types.go
  • x/crisis/types/errors.go
  • x/crisis/types/keys.go
  • x/distribution/types/keys.go
  • x/protocolpool/types/keys.go
  • x/slashing/keeper/msg_server.go
  • x/slashing/types/errors.go
  • x/slashing/types/keys.go
  • x/upgrade/module.go
  • x/upgrade/types/keys.go
Additional comments: 23
x/upgrade/keeper/keeper_test.go (1)
  • 66-71: The change from govModuleName to types.GovModuleName is correct and aligns with the goal of removing the dependency on the x/gov module. Ensure that the types.GovModuleName constant is correctly defined and that it matches the previous value of govModuleName.
x/upgrade/keeper/grpc_query_test.go (1)
  • 41-47: The change from govModuleName to types.GovModuleName is consistent with the PR's goal of removing the dependency on the x/gov module. Ensure that types.GovModuleName is correctly defined and imported.
x/protocolpool/testutil/app_config.go (2)
  • 5-10: The removal of the x/gov module from the import statements is consistent with the goal of decoupling it from the SDK. Ensure that all dependencies on this module have been properly refactored throughout the codebase.

  • 24-27: The x/gov module is no longer part of the application configuration. This change should be verified across all application setups to ensure consistency.

x/crisis/keeper/msg_server.go (2)
  • 4-9: The import of "cosmossdk.io/x/gov/types" has been removed. Ensure that this does not cause any undefined types or functions in the current file.

  • 79-81: The error type has been updated from govtypes.ErrInvalidSigner to types.ErrInvalidSigner. Ensure that the new error type is defined in the "types" package and is used consistently across the codebase.

- return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority)
+ return nil, errors.Wrapf(types.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority)
x/slashing/keeper/keeper_test.go (2)
  • 13-19: The import of "cosmossdk.io/x/gov/types" is removed and "cosmossdk.io/x/slashing/types" is added. Ensure that all the references to the "govtypes" are replaced with "types" in the entire codebase.

  • 58-59: The reference to "govtypes.ModuleName" is replaced with "types.GovModuleName". This change is consistent with the removal of the "govtypes" import.

x/slashing/module.go (2)
  • 12-17: The import statements are well organized and follow the best practices of grouping them by standard library, external packages, and internal packages.

  • 217-223: The ProvideModule function has been updated to use types.GovModuleName instead of govtypes.ModuleName. Ensure that types.GovModuleName is correctly defined and that all references to govtypes.ModuleName have been replaced throughout the codebase.

x/crisis/module.go (2)
  • 16-21: The import of cosmossdk.io/x/gov/types has been removed. Ensure that this does not cause any undefined references in the code.

  • 200-206: The usage of govtypes.ModuleName has been replaced with types.GovModuleName. Ensure that types.GovModuleName is correctly defined and imported.

- authority := authtypes.NewModuleAddress(govtypes.ModuleName)
+ authority := authtypes.NewModuleAddress(types.GovModuleName)
testutil/configurator/configurator.go (11)
  • 8-14: The new module countermodulev1 is imported and used in the CounterModule function. Ensure that this module is implemented correctly and that all dependencies are properly managed.

  • 42-109: The defaultConfig function has been updated to use constants from the testutil package instead of hard-coded strings. This is a good practice as it reduces the chance of typos and makes it easier to manage these values.

  • 138-164: The BankModule and AuthModule functions have been updated to use constants from the testutil package. This is a good practice as it reduces the chance of typos and makes it easier to manage these values.

  • 167-201: The ParamsModule, TxModule, StakingModule, and SlashingModule functions have been updated to use constants from the testutil package. This is a good practice as it reduces the chance of typos and makes it easier to manage these values.

  • 212-228: The DistributionModule and FeegrantModule functions have been updated to use constants from the testutil package. This is a good practice as it reduces the chance of typos and makes it easier to manage these values.

  • 239-246: The GovModule function has been updated to use a constant from the testutil package. This is a good practice as it reduces the chance of typos and makes it easier to manage these values.

  • 257-264: The MintModule function has been updated to use a constant from the testutil package. This is a good practice as it reduces the chance of typos and makes it easier to manage these values.

  • 272-287: The EvidenceModule and AuthzModule functions have been updated to use constants from the testutil package. This is a good practice as it reduces the chance of typos and makes it easier to manage these values.

  • 291-323: The GroupModule, NFTModule, CircuitModule, and ProtocolPoolModule functions have been updated to use constants from the testutil package. This is a good practice as it reduces the chance of typos and makes it easier to manage these values.

  • 327-332: The CounterModule function has been added. Ensure that this module is implemented correctly and that all dependencies are properly managed.

  • 375-380: The AuthModuleName is checked in the cfg.ModuleConfigs and if it exists, a new StoreKeyConfig is appended to overrides. This is a good practice as it ensures that the AuthModuleName is properly configured before it is used.

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

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 097f99d and 8273002.
Files ignored due to filter (17)
  • client/v2/go.mod
  • go.mod
  • x/accounts/go.mod
  • x/auth/go.mod
  • x/bank/go.mod
  • x/circuit/go.mod
  • x/distribution/go.mod
  • x/distribution/go.sum
  • x/evidence/go.mod
  • x/mint/go.mod
  • x/nft/go.mod
  • x/protocolpool/go.mod
  • x/protocolpool/go.sum
  • x/slashing/go.mod
  • x/slashing/go.sum
  • x/staking/go.mod
  • x/staking/go.sum
Files selected for processing (20)
  • baseapp/block_gas_test.go (3 hunks)
  • go.work.example (1 hunks)
  • testutil/configurator/configurator.go (10 hunks)
  • testutil/types.go (1 hunks)
  • x/crisis/keeper/msg_server.go (2 hunks)
  • x/crisis/module.go (2 hunks)
  • x/crisis/types/errors.go (1 hunks)
  • x/crisis/types/keys.go (1 hunks)
  • x/distribution/types/keys.go (1 hunks)
  • x/protocolpool/testutil/app_config.go (2 hunks)
  • x/protocolpool/types/keys.go (1 hunks)
  • x/slashing/keeper/keeper_test.go (2 hunks)
  • x/slashing/keeper/msg_server.go (2 hunks)
  • x/slashing/module.go (2 hunks)
  • x/slashing/types/errors.go (1 hunks)
  • x/slashing/types/keys.go (1 hunks)
  • x/upgrade/keeper/grpc_query_test.go (1 hunks)
  • x/upgrade/keeper/keeper_test.go (2 hunks)
  • x/upgrade/module.go (2 hunks)
  • x/upgrade/types/keys.go (1 hunks)
Files skipped from review due to trivial changes (8)
  • go.work.example
  • x/crisis/types/keys.go
  • x/distribution/types/keys.go
  • x/protocolpool/types/keys.go
  • x/slashing/types/errors.go
  • x/slashing/types/keys.go
  • x/upgrade/keeper/keeper_test.go
  • x/upgrade/types/keys.go
Additional comments: 27
x/crisis/types/errors.go (1)
  • 6-10: The new error ErrInvalidSigner is correctly registered with a unique error code and a descriptive message. Ensure that this error is handled appropriately in the code where it's expected to be thrown.
x/upgrade/keeper/grpc_query_test.go (1)
  • 41-47: Ensure that the change from authtypes.NewModuleAddress(govModuleName) to authtypes.NewModuleAddress(types.GovModuleName) does not affect the functionality of the UpgradeTestSuite setup. Verify that the types.GovModuleName is correctly defined and that the authority is correctly generated and used in the keeper.NewKeeper function.
testutil/types.go (1)
  • 1-25: The introduction of the testutil package with constants for module names is a good practice. It helps to avoid hard-coded strings scattered throughout the codebase, which can lead to potential errors and maintainability issues. However, ensure that all instances where these module names are used have been updated to use these constants.
baseapp/block_gas_test.go (1)
  • 26-32: The new import statement for "github.com/cosmos/cosmos-sdk/testutil" is added correctly.
x/protocolpool/testutil/app_config.go (2)
  • 5-10: The removal of the x/gov import is consistent with the PR's goal of removing the dependency on the x/gov module. Ensure that this does not affect any functionality that relies on this import.

  • 24-27: The removal of configurator.GovModule() is consistent with the PR's goal of removing the dependency on the x/gov module. Ensure that this does not affect any functionality that relies on this module.

x/upgrade/module.go (2)
  • 29-34: The init function is used to register the legacy Amino codec. This is a good practice as it ensures that the codec is registered at the package level and is available for use throughout the package.

  • 205-211: The ProvideModule function has been updated to use types.GovModuleName instead of a hardcoded string. This is a good practice as it reduces the risk of typos and makes it easier to update the module name if needed in the future. However, ensure that types.GovModuleName is correctly defined and imported.

x/crisis/module.go (2)
  • 16-21: The import statements have been updated to remove the dependency on x/gov/types. This is in line with the PR's goal of removing the dependency on the x/gov module.

  • 200-206: The govtypes.ModuleName has been replaced with types.GovModuleName to avoid a cyclic dependency. This change affects the determination of the default authority address. Ensure that types.GovModuleName is correctly defined and that this change does not affect the functionality of the ProvideModule function.

x/slashing/module.go (1)
  • 12-17: The import statements have been updated to remove the dependency on x/gov/types and replace it with the respective types from the x/slashing module. This change is in line with the goal of removing the dependency on the x/gov module from other modules and the SDK itself.
x/crisis/keeper/msg_server.go (2)
  • 4-9: The import of "cosmossdk.io/x/gov/types" has been removed and replaced with "types". This change is consistent with the PR's goal of removing the dependency on the x/gov module.

  • 77-81: The error type govtypes.ErrInvalidSigner has been replaced with types.ErrInvalidSigner. Ensure that the new error type is defined in the types package and is equivalent to the old one.

- return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority)
+ return nil, errors.Wrapf(types.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority)
x/slashing/keeper/keeper_test.go (1)
  • 58-59: The reference to "govtypes.ModuleName" has been replaced with "types.GovModuleName". Ensure that the new reference is correctly defined and imported.
x/slashing/keeper/msg_server.go (2)
  • 4-9: The import of "cosmossdk.io/x/gov/types" has been replaced with "cosmossdk.io/x/slashing/types". Ensure that the new import does not introduce any breaking changes and all the required types are available in the new package.

  • 25-31: The error type has been changed from govtypes.ErrInvalidSigner to types.ErrInvalidSigner. Make sure that the new error type is handled correctly wherever this function is called.

- return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority)
+ return nil, errors.Wrapf(types.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority)
testutil/configurator/configurator.go (11)
  • 8-14: The new module countermodulev1 has been added to the import statements. Ensure that this module is correctly implemented and used throughout the codebase.

  • 42-109: The defaultConfig function has been updated to use constants from the testutil package instead of hard-coded strings. This is a good practice as it reduces the risk of typos and makes it easier to manage these constants.

  • 138-164: The BankModule and AuthModule functions have been updated to use constants from the testutil package. This is a good practice as it reduces the risk of typos and makes it easier to manage these constants.

  • 167-201: The ParamsModule, TxModule, StakingModule, and SlashingModule functions have been updated to use constants from the testutil package. This is a good practice as it reduces the risk of typos and makes it easier to manage these constants.

  • 212-228: The DistributionModule and FeegrantModule functions have been updated to use constants from the testutil package. This is a good practice as it reduces the risk of typos and makes it easier to manage these constants.

  • 239-246: The GovModule function has been updated to use constants from the testutil package. This is a good practice as it reduces the risk of typos and makes it easier to manage these constants.

  • 257-264: The MintModule function has been updated to use constants from the testutil package. This is a good practice as it reduces the risk of typos and makes it easier to manage these constants.

  • 272-287: The EvidenceModule, AuthzModule, and GroupModule functions have been updated to use constants from the testutil package. This is a good practice as it reduces the risk of typos and makes it easier to manage these constants.

  • 300-315: The NFTModule, CircuitModule, and ProtocolPoolModule functions have been updated to use constants from the testutil package. This is a good practice as it reduces the risk of typos and makes it easier to manage these constants.

  • 327-333: The CounterModule function has been added. Ensure that this function is correctly implemented and used throughout the codebase.

  • 375-380: The NewAppConfig function has been updated to use constants from the testutil package. This is a good practice as it reduces the risk of typos and makes it easier to manage these constants.

Comment on lines 13 to 19
sdkmath "cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
authtypes "cosmossdk.io/x/auth/types"
govtypes "cosmossdk.io/x/gov/types"
slashingkeeper "cosmossdk.io/x/slashing/keeper"
slashingtestutil "cosmossdk.io/x/slashing/testutil"
"cosmossdk.io/x/slashing/types"
slashingtypes "cosmossdk.io/x/slashing/types"
Copy link
Contributor

Choose a reason for hiding this comment

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

The import of "cosmossdk.io/x/slashing/types" is duplicated. Remove the duplicate import.

- "cosmossdk.io/x/slashing/types"

Commitable suggestion

[!IMPORTANT]
Carefully review the code before committing. Make sure it correctly replaces the highlighted code, has no missing lines and indentaion issues.

Suggested change
sdkmath "cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
authtypes "cosmossdk.io/x/auth/types"
govtypes "cosmossdk.io/x/gov/types"
slashingkeeper "cosmossdk.io/x/slashing/keeper"
slashingtestutil "cosmossdk.io/x/slashing/testutil"
"cosmossdk.io/x/slashing/types"
slashingtypes "cosmossdk.io/x/slashing/types"
sdkmath "cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
authtypes "cosmossdk.io/x/auth/types"
slashingkeeper "cosmossdk.io/x/slashing/keeper"
slashingtestutil "cosmossdk.io/x/slashing/testutil"
slashingtypes "cosmossdk.io/x/slashing/types"

Comment on lines 129 to 137

// test account and fund
priv1, _, addr1 := testdata.KeyTestPubAddr()
err = bankKeeper.MintCoins(ctx, mintModuleName, feeAmount)
err = bankKeeper.MintCoins(ctx, testutil.MintModuleName, feeAmount)
require.NoError(t, err)
err = bankKeeper.SendCoinsFromModuleToAccount(ctx, mintModuleName, addr1, feeAmount)
err = bankKeeper.SendCoinsFromModuleToAccount(ctx, testutil.MintModuleName, addr1, feeAmount)
require.NoError(t, err)
require.Equal(t, feeCoin.Amount, bankKeeper.GetBalance(ctx, addr1, feeCoin.Denom).Amount)
seq := accountKeeper.GetAccount(ctx, addr1).GetSequence()
Copy link
Contributor

Choose a reason for hiding this comment

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

The constant "mintModuleName" is replaced with "testutil.MintModuleName" correctly. This change improves maintainability by avoiding hard-coded strings.

- err = bankKeeper.MintCoins(ctx, mintModuleName, feeAmount)
+ err = bankKeeper.MintCoins(ctx, testutil.MintModuleName, feeAmount)
- err = bankKeeper.SendCoinsFromModuleToAccount(ctx, mintModuleName, addr1, feeAmount)
+ err = bankKeeper.SendCoinsFromModuleToAccount(ctx, testutil.MintModuleName, addr1, feeAmount)

Commitable suggestion

[!IMPORTANT]
Carefully review the code before committing. Make sure it correctly replaces the highlighted code, has no missing lines and indentaion issues.

Suggested change
// test account and fund
priv1, _, addr1 := testdata.KeyTestPubAddr()
err = bankKeeper.MintCoins(ctx, mintModuleName, feeAmount)
err = bankKeeper.MintCoins(ctx, testutil.MintModuleName, feeAmount)
require.NoError(t, err)
err = bankKeeper.SendCoinsFromModuleToAccount(ctx, mintModuleName, addr1, feeAmount)
err = bankKeeper.SendCoinsFromModuleToAccount(ctx, testutil.MintModuleName, addr1, feeAmount)
require.NoError(t, err)
require.Equal(t, feeCoin.Amount, bankKeeper.GetBalance(ctx, addr1, feeCoin.Denom).Amount)
seq := accountKeeper.GetAccount(ctx, addr1).GetSequence()
// test account and fund
priv1, _, addr1 := testdata.KeyTestPubAddr()
err = bankKeeper.MintCoins(ctx, testutil.MintModuleName, feeAmount)
require.NoError(t, err)
err = bankKeeper.SendCoinsFromModuleToAccount(ctx, testutil.MintModuleName, addr1, feeAmount)
require.NoError(t, err)
require.Equal(t, feeCoin.Amount, bankKeeper.GetBalance(ctx, addr1, feeCoin.Denom).Amount)
seq := accountKeeper.GetAccount(ctx, addr1).GetSequence()

Comment on lines 217 to 223

func ProvideModule(in ModuleInputs) ModuleOutputs {
// default to governance authority if not provided
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
authority := authtypes.NewModuleAddress(types.GovModuleName)
if in.Config.Authority != "" {
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The hardcoded module name "govtypes.ModuleName" has been replaced with "types.GovModuleName". This change is part of the effort to replace hardcoded module names with constants, which improves maintainability and reduces potential errors related to hardcoded strings.

- authority := authtypes.NewModuleAddress(govtypes.ModuleName)
+ authority := authtypes.NewModuleAddress(types.GovModuleName)

Commitable suggestion

[!IMPORTANT]
Carefully review the code before committing. Make sure it correctly replaces the highlighted code, has no missing lines and indentaion issues.

Suggested change
func ProvideModule(in ModuleInputs) ModuleOutputs {
// default to governance authority if not provided
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
authority := authtypes.NewModuleAddress(types.GovModuleName)
if in.Config.Authority != "" {
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
}
func ProvideModule(in ModuleInputs) ModuleOutputs {
// default to governance authority if not provided
authority := authtypes.NewModuleAddress(types.GovModuleName)
if in.Config.Authority != "" {
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
}

@julienrbrt julienrbrt added this pull request to the merge queue Nov 9, 2023
Merged via the queue into main with commit 7208905 Nov 9, 2023
60 of 63 checks passed
@julienrbrt julienrbrt deleted the julien/remove-gov-dep branch November 9, 2023 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants