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(x/crisis)!: remove Address.String() #20043

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i

### API Breaking Changes

* (x/crisis) [#20043](https://github.com/cosmos/cosmos-sdk/pull/20043) Changed `NewMsgVerifyInvariant` to accept a string as argument instead of an `AccAddress`.
* (x/genutil) [#19926](https://github.com/cosmos/cosmos-sdk/pull/19926) Removal of the Address.String() method and related changes:
* Added an address codec as an argument to `CollectTxs`, `GenAppStateFromConfig`, and `AddGenesisAccount`.
* Removed the `ValidatorAddressCodec` argument from `CollectGenTxsCmd`, now utilizing the context for this purpose.
JulianToledano marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
7 changes: 6 additions & 1 deletion x/crisis/depinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,18 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
}

authorityAddr, err := in.AddressCodec.BytesToString(authority)
if err != nil {
panic(err)
}

k := keeper.NewKeeper(
in.Codec,
in.StoreService,
invalidCheckPeriod,
in.BankKeeper,
feeCollectorName,
authority.String(),
authorityAddr,
in.AddressCodec,
)

Expand Down
10 changes: 7 additions & 3 deletions x/crisis/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ func (s *KeeperTestSuite) SetupTest() {
storeService := runtime.NewKVStoreService(key)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, crisis.AppModule{})
keeper := keeper.NewKeeper(encCfg.Codec, storeService, 5, supplyKeeper, "", sdk.AccAddress([]byte("addr1_______________")).String(), addresscodec.NewBech32Codec("cosmos"))
addr, err := codectestutil.CodecOptions{}.GetAddressCodec().BytesToString([]byte("addr1_______________"))
s.Require().NoError(err)
keeper := keeper.NewKeeper(encCfg.Codec, storeService, 5, supplyKeeper, "", addr, addresscodec.NewBech32Codec("cosmos"))

s.ctx = testCtx.Ctx
s.keeper = keeper
Expand All @@ -57,6 +59,8 @@ func (s *KeeperTestSuite) TestMsgVerifyInvariant() {
testutil.CreateKeyringAccounts(s.T(), kr, 1)

sender := testutil.CreateKeyringAccounts(s.T(), kr, 1)[0]
senderAddr, err := codectestutil.CodecOptions{}.GetAddressCodec().BytesToString(sender.Address)
s.Require().NoError(err)

s.supplyKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2)
s.keeper.RegisterRoute("bank", "total-supply", func(sdk.Context) (string, bool) { return "", false })
Expand Down Expand Up @@ -90,7 +94,7 @@ func (s *KeeperTestSuite) TestMsgVerifyInvariant() {
{
name: "unregistered invariant route",
input: &types.MsgVerifyInvariant{
Sender: sender.Address.String(),
Sender: senderAddr,
InvariantModuleName: "module",
InvariantRoute: "invalidroute",
},
Expand All @@ -100,7 +104,7 @@ func (s *KeeperTestSuite) TestMsgVerifyInvariant() {
{
name: "valid invariant",
input: &types.MsgVerifyInvariant{
Sender: sender.Address.String(),
Sender: senderAddr,
InvariantModuleName: "bank",
InvariantRoute: "total-supply",
},
Expand Down
4 changes: 2 additions & 2 deletions x/crisis/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ var (
)

// NewMsgVerifyInvariant creates a new MsgVerifyInvariant object
func NewMsgVerifyInvariant(sender sdk.AccAddress, invModeName, invRoute string) *MsgVerifyInvariant {
func NewMsgVerifyInvariant(sender, invModeName, invRoute string) *MsgVerifyInvariant {
return &MsgVerifyInvariant{
Sender: sender.String(),
Sender: sender,
InvariantModuleName: invModeName,
InvariantRoute: invRoute,
}
Expand Down
Loading