From 89f592c890bb42ab912caf67f6b9ba01a2cf34aa Mon Sep 17 00:00:00 2001 From: Julian Toledano Date: Mon, 15 Apr 2024 10:30:37 +0200 Subject: [PATCH 1/3] update: remove AccString --- CHANGELOG.md | 1 + x/crisis/depinject.go | 7 ++++++- x/crisis/keeper/msg_server_test.go | 10 +++++++--- x/crisis/types/msgs.go | 4 ++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a146f35db77..6f2330520db2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -118,6 +118,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### API Breaking Changes +* (x/crisis) []() Changed `NewMsgVerifyInvariant` to accept a string 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. diff --git a/x/crisis/depinject.go b/x/crisis/depinject.go index 3879333c1602..1aac71f65f9d 100644 --- a/x/crisis/depinject.go +++ b/x/crisis/depinject.go @@ -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, ) diff --git a/x/crisis/keeper/msg_server_test.go b/x/crisis/keeper/msg_server_test.go index ea60b9ac9fe8..fc7abcee47f7 100644 --- a/x/crisis/keeper/msg_server_test.go +++ b/x/crisis/keeper/msg_server_test.go @@ -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 @@ -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 }) @@ -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", }, @@ -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", }, diff --git a/x/crisis/types/msgs.go b/x/crisis/types/msgs.go index b62eaaf023a0..4c692e159fa8 100644 --- a/x/crisis/types/msgs.go +++ b/x/crisis/types/msgs.go @@ -10,9 +10,9 @@ var ( ) // NewMsgVerifyInvariant creates a new MsgVerifyInvariant object -func NewMsgVerifyInvariant(sender sdk.AccAddress, invModeName, invRoute string) *MsgVerifyInvariant { +func NewMsgVerifyInvariant(sender string, invModeName, invRoute string) *MsgVerifyInvariant { return &MsgVerifyInvariant{ - Sender: sender.String(), + Sender: sender, InvariantModuleName: invModeName, InvariantRoute: invRoute, } From ed5c93833446c7841c642a6589559f6b89c1482c Mon Sep 17 00:00:00 2001 From: Julian Toledano Date: Mon, 15 Apr 2024 10:34:59 +0200 Subject: [PATCH 2/3] lint --- CHANGELOG.md | 2 +- x/crisis/types/msgs.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f2330520db2..0700f0defc52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -118,7 +118,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### API Breaking Changes -* (x/crisis) []() Changed `NewMsgVerifyInvariant` to accept a string instead of an `AccAddress`. +* (x/crisis) []() 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. diff --git a/x/crisis/types/msgs.go b/x/crisis/types/msgs.go index 4c692e159fa8..ed8542ea33ca 100644 --- a/x/crisis/types/msgs.go +++ b/x/crisis/types/msgs.go @@ -10,7 +10,7 @@ var ( ) // NewMsgVerifyInvariant creates a new MsgVerifyInvariant object -func NewMsgVerifyInvariant(sender string, invModeName, invRoute string) *MsgVerifyInvariant { +func NewMsgVerifyInvariant(sender, invModeName, invRoute string) *MsgVerifyInvariant { return &MsgVerifyInvariant{ Sender: sender, InvariantModuleName: invModeName, From 7e8ac4a0a750e71821afbf966323a3d8e6b436e8 Mon Sep 17 00:00:00 2001 From: Julian Toledano Date: Mon, 15 Apr 2024 10:37:51 +0200 Subject: [PATCH 3/3] CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0700f0defc52..89940b431e57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -118,7 +118,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### API Breaking Changes -* (x/crisis) []() Changed `NewMsgVerifyInvariant` to accept a string as argument instead of an `AccAddress`. +* (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.