diff --git a/CHANGELOG.md b/CHANGELOG.md index c7c84a5cf27f..a253b02dd6c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -153,7 +153,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (crypto) [#15070](https://github.com/cosmos/cosmos-sdk/pull/15070) `GenerateFromPassword` and `Cost` from `bcrypt.go` now take a `uint32` instead of a `int` type. * (x/capability) [#15344](https://github.com/cosmos/cosmos-sdk/pull/15344) Capability module was removed and is now housed in [IBC-GO](https://github.com/cosmos/ibc-go). * [#15299](https://github.com/cosmos/cosmos-sdk/pull/15299) remove `StdTx` transaction and signing APIs. No SDK version has actually supported `StdTx` since before Stargate. -* [#15600](https://github.com/cosmos/cosmos-sdk/pull/15600) add support for getting signers to `codec.Codec` and protoregistry support to `InterfaceRegistry`: +* (codec) [#15600](https://github.com/cosmos/cosmos-sdk/pull/15600) add support for getting signers to `codec.Codec` and protoregistry support to `InterfaceRegistry`: * `Codec` is now a private interface and has the methods `InterfaceRegistry`, `GetMsgAnySigners`, `GetMsgV1Signers`, and `GetMsgV2Signers` which will fail when using `AminoCodec`. All implementations of `Codec` by other users must now embed an official implementation from the `codec` package. * `InterfaceRegistry` is now a private interface and implements `protodesc.Resolver` plus the `RangeFiles` method @@ -167,6 +167,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### CLI Breaking Changes +* (cli) [#15826](https://github.com/cosmos/cosmos-sdk/pull/15826) Remove ` q account` command. Use ` q auth account` instead. * (x/staking) [#14864](https://github.com/cosmos/cosmos-sdk/pull/14864) `create-validator` CLI command now takes a json file as an arg instead of having a bunch of required flags to it. * (cli) [#14659](https://github.com/cosmos/cosmos-sdk/pull/14659) ` q block ` is removed as it just output json. The new command allows either height/hash and is ` q block --type=height|hash `. * (x/gov) [#14880](https://github.com/cosmos/cosmos-sdk/pull/14880) Remove ` tx gov submit-legacy-proposal cancel-software-upgrade` and `software-upgrade` commands. These commands are now in the `x/upgrade` module and using gov v1. Use `tx upgrade software-upgrade` instead. diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 23e4707be0c5..77bfddd68fdc 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -238,7 +238,6 @@ func queryCommand() *cobra.Command { } cmd.AddCommand( - authcmd.GetAccountCmd(), rpc.ValidatorCommand(), server.QueryBlockCmd(), authcmd.QueryTxsByEventsCmd(), diff --git a/tests/e2e/auth/suite.go b/tests/e2e/auth/suite.go index 990edbab1822..977203e17dc1 100644 --- a/tests/e2e/auth/suite.go +++ b/tests/e2e/auth/suite.go @@ -15,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" @@ -1251,7 +1252,7 @@ func (s *E2ETestSuite) TestMultisignBatch() { defer filename.Close() val.ClientCtx.HomeDir = strings.Replace(val.ClientCtx.HomeDir, "simd", "simcli", 1) - queryResJSON, err := authclitestutil.QueryAccountExec(val.ClientCtx, addr) + queryResJSON, err := authclitestutil.QueryAccountExec(val.ClientCtx, addr, address.NewBech32Codec("cosmos")) s.Require().NoError(err) var account sdk.AccountI s.Require().NoError(val.ClientCtx.Codec.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account)) @@ -1319,7 +1320,7 @@ func (s *E2ETestSuite) TestGetAccountCmd() { s.Run(tc.name, func() { clientCtx := val.ClientCtx - out, err := authclitestutil.QueryAccountExec(clientCtx, tc.address) + out, err := authclitestutil.QueryAccountExec(clientCtx, tc.address, address.NewBech32Codec("cosmos")) if tc.expectErr { s.Require().Error(err) s.Require().NotEqual("internal", err.Error()) diff --git a/x/auth/client/cli/query.go b/x/auth/client/cli/query.go index 5995a4c3d37b..1cc788a711d2 100644 --- a/x/auth/client/cli/query.go +++ b/x/auth/client/cli/query.go @@ -6,6 +6,7 @@ import ( "strconv" "strings" + "cosmossdk.io/core/address" errorsmod "cosmossdk.io/errors" "github.com/spf13/cobra" @@ -34,7 +35,7 @@ const ( ) // GetQueryCmd returns the transaction commands for this module -func GetQueryCmd() *cobra.Command { +func GetQueryCmd(ac address.Codec) *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, Short: "Querying commands for the auth module", @@ -44,7 +45,7 @@ func GetQueryCmd() *cobra.Command { } cmd.AddCommand( - GetAccountCmd(), + GetAccountCmd(ac), GetAccountAddressByIDCmd(), GetAccountsCmd(), QueryParamsCmd(), @@ -88,7 +89,7 @@ $ query auth params // GetAccountCmd returns a query account that will display the state of the // account at a given address. -func GetAccountCmd() *cobra.Command { +func GetAccountCmd(ac address.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "account [address]", Short: "Query for account by address", @@ -98,13 +99,13 @@ func GetAccountCmd() *cobra.Command { if err != nil { return err } - key, err := sdk.AccAddressFromBech32(args[0]) + _, err = ac.StringToBytes(args[0]) if err != nil { return err } queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.Account(cmd.Context(), &types.QueryAccountRequest{Address: key.String()}) + res, err := queryClient.Account(cmd.Context(), &types.QueryAccountRequest{Address: args[0]}) if err != nil { node, err2 := clientCtx.GetNode() if err2 != nil { diff --git a/x/auth/client/cli/suite_test.go b/x/auth/client/cli/suite_test.go index cf40d0a258e6..c5ef2c648656 100644 --- a/x/auth/client/cli/suite_test.go +++ b/x/auth/client/cli/suite_test.go @@ -8,6 +8,7 @@ import ( "strings" "testing" + "cosmossdk.io/core/address" "cosmossdk.io/math" abci "github.com/cometbft/cometbft/abci/types" rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock" @@ -15,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" @@ -46,6 +48,8 @@ type CLITestSuite struct { clientCtx client.Context val sdk.AccAddress val1 sdk.AccAddress + + ac address.Codec } func TestCLITestSuite(t *testing.T) { @@ -99,6 +103,8 @@ func (s *CLITestSuite) SetupSuite() { multi := kmultisig.NewLegacyAminoPubKey(2, []cryptotypes.PubKey{pub1, pub2}) _, err = kb.SaveMultisig("multi", multi) s.Require().NoError(err) + + s.ac = addresscodec.NewBech32Codec("cosmos") } func (s *CLITestSuite) TestCLIValidateSignatures() { @@ -606,7 +612,7 @@ func (s *CLITestSuite) TestSignWithMultisig() { // Create an address that is not in the keyring, will be used to simulate `--multisig` multisig := "cosmos1hd6fsrvnz6qkp87s3u86ludegq97agxsdkwzyh" - multisigAddr, err := sdk.AccAddressFromBech32(multisig) + _, err = s.ac.StringToBytes(multisig) s.Require().NoError(err) // Generate a transaction for testing --multisig with an address not in the keyring. @@ -632,7 +638,7 @@ func (s *CLITestSuite) TestSignWithMultisig() { // even though the tx signer is NOT the multisig address. This is fine though, // as the main point of this test is to test the `--multisig` flag with an address // that is not in the keyring. - _, err = authtestutil.TxSignExec(s.clientCtx, addr1, multiGeneratedTx2File.Name(), "--multisig", multisigAddr.String()) + _, err = authtestutil.TxSignExec(s.clientCtx, addr1, multiGeneratedTx2File.Name(), "--multisig", multisig) s.Require().Contains(err.Error(), "error getting account from keybase") } @@ -788,9 +794,9 @@ func (s *CLITestSuite) TestGetBroadcastCommandWithoutOfflineFlag() { // Create new file with tx builder := txCfg.NewTxBuilder() builder.SetGasLimit(200000) - from, err := sdk.AccAddressFromBech32("cosmos1cxlt8kznps92fwu3j6npahx4mjfutydyene2qw") + from, err := s.ac.StringToBytes("cosmos1cxlt8kznps92fwu3j6npahx4mjfutydyene2qw") s.Require().NoError(err) - to, err := sdk.AccAddressFromBech32("cosmos1cxlt8kznps92fwu3j6npahx4mjfutydyene2qw") + to, err := s.ac.StringToBytes("cosmos1cxlt8kznps92fwu3j6npahx4mjfutydyene2qw") s.Require().NoError(err) err = builder.SetMsgs(banktypes.NewMsgSend(from, to, sdk.Coins{sdk.NewInt64Coin("stake", 10000)})) s.Require().NoError(err) diff --git a/x/auth/client/testutil/helpers.go b/x/auth/client/testutil/helpers.go index 98654eef0d55..5d53a35c09e8 100644 --- a/x/auth/client/testutil/helpers.go +++ b/x/auth/client/testutil/helpers.go @@ -4,6 +4,7 @@ import ( "fmt" "strings" + "cosmossdk.io/core/address" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -89,10 +90,10 @@ func TxAuxToFeeExec(clientCtx client.Context, filename string, extraArgs ...stri return clitestutil.ExecTestCLICmd(clientCtx, cli.GetAuxToFeeCommand(), append(args, extraArgs...)) } -func QueryAccountExec(clientCtx client.Context, address fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) { +func QueryAccountExec(clientCtx client.Context, address fmt.Stringer, ac address.Codec, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)} - return clitestutil.ExecTestCLICmd(clientCtx, cli.GetAccountCmd(), append(args, extraArgs...)) + return clitestutil.ExecTestCLICmd(clientCtx, cli.GetAccountCmd(ac), append(args, extraArgs...)) } func TxMultiSignBatchExec(clientCtx client.Context, filename, from, sigFile1, sigFile2 string, extraArgs ...string) (testutil.BufferWriter, error) { diff --git a/x/auth/keeper/deterministic_test.go b/x/auth/keeper/deterministic_test.go index f003033a0fb2..ea7e6b64d3bb 100644 --- a/x/auth/keeper/deterministic_test.go +++ b/x/auth/keeper/deterministic_test.go @@ -145,7 +145,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryAccounts() { }) // Regression test - addr1, err := sdk.AccAddressFromBech32("cosmos1892yr6fzlj7ud0kfkah2ctrav3a4p4n060ze8f") + addr1, err := suite.accountKeeper.GetAddressCodec().StringToBytes("cosmos1892yr6fzlj7ud0kfkah2ctrav3a4p4n060ze8f") suite.Require().NoError(err) pub1, err := hex.DecodeString("D1002E1B019000010BB7034500E71F011F1CA90D5B000E134BFB0F3603030D0303") suite.Require().NoError(err) diff --git a/x/auth/keeper/grpc_query.go b/x/auth/keeper/grpc_query.go index 7571d61361be..482890de7a51 100644 --- a/x/auth/keeper/grpc_query.go +++ b/x/auth/keeper/grpc_query.go @@ -78,7 +78,7 @@ func (ak AccountKeeper) Account(c context.Context, req *types.QueryAccountReques } ctx := sdk.UnwrapSDKContext(c) - addr, err := sdk.AccAddressFromBech32(req.Address) + addr, err := ak.addressCdc.StringToBytes(req.Address) if err != nil { return nil, err } @@ -222,7 +222,7 @@ func (ak AccountKeeper) AccountInfo(goCtx context.Context, req *types.QueryAccou } ctx := sdk.UnwrapSDKContext(goCtx) - addr, err := sdk.AccAddressFromBech32(req.Address) + addr, err := ak.addressCdc.StringToBytes(req.Address) if err != nil { return nil, err } @@ -239,7 +239,7 @@ func (ak AccountKeeper) AccountInfo(goCtx context.Context, req *types.QueryAccou return &types.QueryAccountInfoResponse{ Info: &types.BaseAccount{ - Address: addr.String(), + Address: req.Address, PubKey: pkAny, AccountNumber: account.GetAccountNumber(), Sequence: account.GetSequence(), diff --git a/x/auth/module.go b/x/auth/module.go index bff5d93c154b..900c39514e9e 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -42,7 +42,9 @@ var ( ) // AppModuleBasic defines the basic application module used by the auth module. -type AppModuleBasic struct{} +type AppModuleBasic struct { + ac address.Codec +} // Name returns the auth module's name. func (AppModuleBasic) Name() string { @@ -83,8 +85,8 @@ func (AppModuleBasic) GetTxCmd() *cobra.Command { } // GetQueryCmd returns the root query command for the auth module. -func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd() +func (ab AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(ab.ac) } // RegisterInterfaces registers interfaces and implementations of the auth module. @@ -114,7 +116,7 @@ func (am AppModule) IsAppModule() {} // NewAppModule creates a new AppModule object func NewAppModule(cdc codec.Codec, accountKeeper keeper.AccountKeeper, randGenAccountsFn types.RandomGenesisAccountsFn, ss exported.Subspace) AppModule { return AppModule{ - AppModuleBasic: AppModuleBasic{}, + AppModuleBasic: AppModuleBasic{ac: accountKeeper.GetAddressCodec()}, accountKeeper: accountKeeper, randGenAccountsFn: randGenAccountsFn, legacySubspace: ss,