From f28a93a063c5605faee2507318ea48f2e2c70cb2 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 11 Oct 2023 15:04:40 +0200 Subject: [PATCH] refactor(cli): use clientCtx adress codecs in cli (#18070) --- x/auth/vesting/client/cli/tx.go | 22 ++++++++--------- x/auth/vesting/client/cli/tx_test.go | 6 ++--- x/auth/vesting/module.go | 9 +++---- x/authz/client/cli/tx.go | 37 ++++++++++++---------------- x/authz/client/testutil/helpers.go | 3 +-- x/authz/module/module.go | 2 +- x/feegrant/client/cli/tx.go | 11 ++++----- x/feegrant/client/cli/tx_test.go | 10 ++++---- x/feegrant/module/module.go | 8 +++--- x/upgrade/client/cli/parse_test.go | 4 +-- x/upgrade/client/cli/tx.go | 19 +++++++------- x/upgrade/module.go | 8 +++--- 12 files changed, 60 insertions(+), 79 deletions(-) diff --git a/x/auth/vesting/client/cli/tx.go b/x/auth/vesting/client/cli/tx.go index fe6a0c341f21..06c8ce58296b 100644 --- a/x/auth/vesting/client/cli/tx.go +++ b/x/auth/vesting/client/cli/tx.go @@ -9,8 +9,6 @@ import ( "github.com/spf13/cobra" - "cosmossdk.io/core/address" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -24,7 +22,7 @@ const ( ) // GetTxCmd returns vesting module's transaction commands. -func GetTxCmd(ac address.Codec) *cobra.Command { +func GetTxCmd() *cobra.Command { txCmd := &cobra.Command{ Use: types.ModuleName, Short: "Vesting transaction subcommands", @@ -34,9 +32,9 @@ func GetTxCmd(ac address.Codec) *cobra.Command { } txCmd.AddCommand( - NewMsgCreateVestingAccountCmd(ac), - NewMsgCreatePermanentLockedAccountCmd(ac), - NewMsgCreatePeriodicVestingAccountCmd(ac), + NewMsgCreateVestingAccountCmd(), + NewMsgCreatePermanentLockedAccountCmd(), + NewMsgCreatePeriodicVestingAccountCmd(), ) return txCmd @@ -44,7 +42,7 @@ func GetTxCmd(ac address.Codec) *cobra.Command { // NewMsgCreateVestingAccountCmd returns a CLI command handler for creating a // MsgCreateVestingAccount transaction. -func NewMsgCreateVestingAccountCmd(ac address.Codec) *cobra.Command { +func NewMsgCreateVestingAccountCmd() *cobra.Command { cmd := &cobra.Command{ Use: "create-vesting-account [to_address] [amount] [end_time]", Short: "Create a new vesting account funded with an allocation of tokens.", @@ -59,7 +57,7 @@ timestamp.`, if err != nil { return err } - toAddr, err := ac.StringToBytes(args[0]) + toAddr, err := clientCtx.AddressCodec.StringToBytes(args[0]) if err != nil { return err } @@ -93,7 +91,7 @@ timestamp.`, // NewMsgCreatePermanentLockedAccountCmd returns a CLI command handler for creating a // MsgCreatePermanentLockedAccount transaction. -func NewMsgCreatePermanentLockedAccountCmd(ac address.Codec) *cobra.Command { +func NewMsgCreatePermanentLockedAccountCmd() *cobra.Command { cmd := &cobra.Command{ Use: "create-permanent-locked-account [to_address] [amount]", Short: "Create a new permanently locked account funded with an allocation of tokens.", @@ -106,7 +104,7 @@ tokens.`, if err != nil { return err } - toAddr, err := ac.StringToBytes(args[0]) + toAddr, err := clientCtx.AddressCodec.StringToBytes(args[0]) if err != nil { return err } @@ -142,7 +140,7 @@ type InputPeriod struct { // NewMsgCreatePeriodicVestingAccountCmd returns a CLI command handler for creating a // MsgCreatePeriodicVestingAccountCmd transaction. -func NewMsgCreatePeriodicVestingAccountCmd(ac address.Codec) *cobra.Command { +func NewMsgCreatePeriodicVestingAccountCmd() *cobra.Command { cmd := &cobra.Command{ Use: "create-periodic-vesting-account [to_address] [periods_json_file]", Short: "Create a new vesting account funded with an allocation of tokens.", @@ -170,7 +168,7 @@ func NewMsgCreatePeriodicVestingAccountCmd(ac address.Codec) *cobra.Command { return err } - toAddr, err := ac.StringToBytes(args[0]) + toAddr, err := clientCtx.AddressCodec.StringToBytes(args[0]) if err != nil { return err } diff --git a/x/auth/vesting/client/cli/tx_test.go b/x/auth/vesting/client/cli/tx_test.go index 942b4b3810a5..8f0716e7e332 100644 --- a/x/auth/vesting/client/cli/tx_test.go +++ b/x/auth/vesting/client/cli/tx_test.go @@ -54,7 +54,7 @@ func (s *CLITestSuite) SetupSuite() { func (s *CLITestSuite) TestNewMsgCreateVestingAccountCmd() { accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1) - cmd := cli.NewMsgCreateVestingAccountCmd(addresscodec.NewBech32Codec("cosmos")) + cmd := cli.NewMsgCreateVestingAccountCmd() cmd.SetOutput(io.Discard) extraArgs := []string{ @@ -143,7 +143,7 @@ func (s *CLITestSuite) TestNewMsgCreateVestingAccountCmd() { func (s *CLITestSuite) TestNewMsgCreatePermanentLockedAccountCmd() { accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1) - cmd := cli.NewMsgCreatePermanentLockedAccountCmd(addresscodec.NewBech32Codec("cosmos")) + cmd := cli.NewMsgCreatePermanentLockedAccountCmd() cmd.SetOutput(io.Discard) extraArgs := []string{ @@ -222,7 +222,7 @@ func (s *CLITestSuite) TestNewMsgCreatePermanentLockedAccountCmd() { func (s *CLITestSuite) TestNewMsgCreatePeriodicVestingAccountCmd() { accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1) - cmd := cli.NewMsgCreatePeriodicVestingAccountCmd(addresscodec.NewBech32Codec("cosmos")) + cmd := cli.NewMsgCreatePeriodicVestingAccountCmd() cmd.SetOutput(io.Discard) extraArgs := []string{ diff --git a/x/auth/vesting/module.go b/x/auth/vesting/module.go index 139efb1af0de..48c7bc19eddb 100644 --- a/x/auth/vesting/module.go +++ b/x/auth/vesting/module.go @@ -9,7 +9,6 @@ import ( "google.golang.org/grpc" modulev1 "cosmossdk.io/api/cosmos/vesting/module/v1" - "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" "cosmossdk.io/depinject" @@ -33,9 +32,7 @@ var ( // AppModuleBasic defines the basic application module used by the sub-vesting // module. The module itself contain no special logic or state other than message // handling. -type AppModuleBasic struct { - ac address.Codec -} +type AppModuleBasic struct{} // Name returns the module's name. func (AppModuleBasic) Name() string { @@ -69,7 +66,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *gwruntime.S // GetTxCmd returns the root tx command for the auth module. func (ab AppModuleBasic) GetTxCmd() *cobra.Command { - return cli.GetTxCmd(ab.ac) + return cli.GetTxCmd() } // AppModule extends the AppModuleBasic implementation by implementing the @@ -83,7 +80,7 @@ type AppModule struct { func NewAppModule(ak keeper.AccountKeeper, bk types.BankKeeper) AppModule { return AppModule{ - AppModuleBasic: AppModuleBasic{ac: ak.AddressCodec()}, + AppModuleBasic: AppModuleBasic{}, accountKeeper: ak, bankKeeper: bk, } diff --git a/x/authz/client/cli/tx.go b/x/authz/client/cli/tx.go index 6349ff2d03ab..0ca6c50452fa 100644 --- a/x/authz/client/cli/tx.go +++ b/x/authz/client/cli/tx.go @@ -8,8 +8,6 @@ import ( "github.com/spf13/cobra" - "cosmossdk.io/core/address" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -35,7 +33,7 @@ const ( ) // GetTxCmd returns the transaction commands for this module -func GetTxCmd(ac address.Codec) *cobra.Command { +func GetTxCmd() *cobra.Command { AuthorizationTxCmd := &cobra.Command{ Use: authz.ModuleName, Short: "Authorization transactions subcommands", @@ -46,7 +44,7 @@ func GetTxCmd(ac address.Codec) *cobra.Command { } AuthorizationTxCmd.AddCommand( - NewCmdGrantAuthorization(ac), + NewCmdGrantAuthorization(), NewCmdExecAuthorization(), ) @@ -54,20 +52,17 @@ func GetTxCmd(ac address.Codec) *cobra.Command { } // NewCmdGrantAuthorization returns a CLI command handler for creating a MsgGrant transaction. -// -// cannot give autocli support, can be CLI breaking -func NewCmdGrantAuthorization(ac address.Codec) *cobra.Command { +// Migrating this command to AutoCLI is possible but would be CLI breaking. +func NewCmdGrantAuthorization() *cobra.Command { cmd := &cobra.Command{ - Use: "grant --from ", + Use: "grant [grantee] --from [granter]", Short: "Grant authorization to an address", Long: strings.TrimSpace( fmt.Sprintf(`create a new grant authorization to an address to execute a transaction on your behalf: - Examples: - $ %s tx %s grant cosmos1skjw.. send --spend-limit=1000stake --from=cosmos1skl.. - $ %s tx %s grant cosmos1skjw.. generic --msg-type=/cosmos.gov.v1.MsgVote --from=cosmos1sk.. - `, version.AppName, authz.ModuleName, version.AppName, authz.ModuleName), - ), + $ %[1]s tx authz grant cosmos1skjw.. send --spend-limit=1000stake --from=cosmos1skl.. + $ %[1]s tx authz grant cosmos1skjw.. generic --msg-type=/cosmos.gov.v1.MsgVote --from=cosmos1sk.. + `, version.AppName)), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) @@ -79,7 +74,7 @@ Examples: return errors.New("grantee and granter should be different") } - grantee, err := ac.StringToBytes(args[0]) + grantee, err := clientCtx.AddressCodec.StringToBytes(args[0]) if err != nil { return err } @@ -115,7 +110,7 @@ Examples: } } - allowed, err := bech32toAccAddresses(allowList, ac) + allowed, err := bech32toAccAddresses(clientCtx, allowList) if err != nil { return err } @@ -168,12 +163,12 @@ Examples: delegateLimit = &spendLimit } - allowed, err := bech32toValAddresses(allowValidators) + allowed, err := bech32toValAddresses(clientCtx, allowValidators) if err != nil { return err } - denied, err := bech32toValAddresses(denyValidators) + denied, err := bech32toValAddresses(clientCtx, denyValidators) if err != nil { return err } @@ -271,10 +266,10 @@ Example: } // bech32toValAddresses returns []ValAddress from a list of Bech32 string addresses. -func bech32toValAddresses(validators []string) ([]sdk.ValAddress, error) { +func bech32toValAddresses(clientCtx client.Context, validators []string) ([]sdk.ValAddress, error) { vals := make([]sdk.ValAddress, len(validators)) for i, validator := range validators { - addr, err := sdk.ValAddressFromBech32(validator) + addr, err := clientCtx.ValidatorAddressCodec.StringToBytes(validator) if err != nil { return nil, err } @@ -284,10 +279,10 @@ func bech32toValAddresses(validators []string) ([]sdk.ValAddress, error) { } // bech32toAccAddresses returns []AccAddress from a list of Bech32 string addresses. -func bech32toAccAddresses(accAddrs []string, ac address.Codec) ([]sdk.AccAddress, error) { +func bech32toAccAddresses(clientCtx client.Context, accAddrs []string) ([]sdk.AccAddress, error) { addrs := make([]sdk.AccAddress, len(accAddrs)) for i, addr := range accAddrs { - accAddr, err := ac.StringToBytes(addr) + accAddr, err := clientCtx.AddressCodec.StringToBytes(addr) if err != nil { return nil, err } diff --git a/x/authz/client/testutil/helpers.go b/x/authz/client/testutil/helpers.go index 07faa75cb3b0..231cf3bba033 100644 --- a/x/authz/client/testutil/helpers.go +++ b/x/authz/client/testutil/helpers.go @@ -2,13 +2,12 @@ package authz import ( "github.com/cosmos/cosmos-sdk/client" - addresscodec "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/x/authz/client/cli" ) func CreateGrant(clientCtx client.Context, args []string) (testutil.BufferWriter, error) { - cmd := cli.NewCmdGrantAuthorization(addresscodec.NewBech32Codec("cosmos")) + cmd := cli.NewCmdGrantAuthorization() return clitestutil.ExecTestCLICmd(clientCtx, cmd, args) } diff --git a/x/authz/module/module.go b/x/authz/module/module.go index f6379853bf78..0c60bbf272bf 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -95,7 +95,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux // GetTxCmd returns the transaction commands for the authz module func (ab AppModuleBasic) GetTxCmd() *cobra.Command { - return cli.GetTxCmd(ab.ac) + return cli.GetTxCmd() } // AppModule implements the sdk.AppModule interface diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 129a6787dc39..99561be03625 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -7,7 +7,6 @@ import ( "github.com/spf13/cobra" - "cosmossdk.io/core/address" "cosmossdk.io/x/feegrant" "github.com/cosmos/cosmos-sdk/client" @@ -27,7 +26,7 @@ const ( ) // GetTxCmd returns the transaction commands for feegrant module -func GetTxCmd(ac address.Codec) *cobra.Command { +func GetTxCmd() *cobra.Command { feegrantTxCmd := &cobra.Command{ Use: feegrant.ModuleName, Short: "Feegrant transactions sub-commands", @@ -38,7 +37,7 @@ func GetTxCmd(ac address.Codec) *cobra.Command { } feegrantTxCmd.AddCommand( - NewCmdFeeGrant(ac), + NewCmdFeeGrant(), ) return feegrantTxCmd @@ -46,7 +45,7 @@ func GetTxCmd(ac address.Codec) *cobra.Command { // NewCmdFeeGrant returns a CLI command handler to create a MsgGrantAllowance transaction. // This command is more powerful than AutoCLI generated command as it allows a better input validation. -func NewCmdFeeGrant(ac address.Codec) *cobra.Command { +func NewCmdFeeGrant() *cobra.Command { cmd := &cobra.Command{ Use: "grant [granter_key_or_address] [grantee]", Aliases: []string{"grant-allowance"}, @@ -75,13 +74,13 @@ Examples: return err } - _, err = ac.StringToBytes(args[1]) + _, err = clientCtx.AddressCodec.StringToBytes(args[1]) if err != nil { return err } granter := clientCtx.GetFromAddress() - granterStr, err := ac.BytesToString(granter) + granterStr, err := clientCtx.AddressCodec.BytesToString(granter) if err != nil { return err } diff --git a/x/feegrant/client/cli/tx_test.go b/x/feegrant/client/cli/tx_test.go index 9cc61bdcc62a..da413d50aaf0 100644 --- a/x/feegrant/client/cli/tx_test.go +++ b/x/feegrant/client/cli/tx_test.go @@ -136,7 +136,7 @@ func (s *CLITestSuite) createGrant(granter, grantee sdk.Address) { commonFlags..., ) - cmd := cli.NewCmdFeeGrant(addresscodec.NewBech32Codec("cosmos")) + cmd := cli.NewCmdFeeGrant() out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, args) s.Require().NoError(err) @@ -423,7 +423,7 @@ func (s *CLITestSuite) TestNewCmdFeeGrant() { tc := tc s.Run(tc.name, func() { - cmd := cli.NewCmdFeeGrant(addresscodec.NewBech32Codec("cosmos")) + cmd := cli.NewCmdFeeGrant() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) if tc.expectErr { @@ -466,7 +466,7 @@ func (s *CLITestSuite) TestTxWithFeeGrant() { commonFlags..., ) - cmd := cli.NewCmdFeeGrant(addresscodec.NewBech32Codec("cosmos")) + cmd := cli.NewCmdFeeGrant() var res sdk.TxResponse out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args) @@ -619,7 +619,7 @@ func (s *CLITestSuite) TestFilteredFeeAllowance() { tc := tc s.Run(tc.name, func() { - cmd := cli.NewCmdFeeGrant(addresscodec.NewBech32Codec("cosmos")) + cmd := cli.NewCmdFeeGrant() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) if tc.expectErrMsg != "" { s.Require().Error(err) @@ -669,7 +669,7 @@ func (s *CLITestSuite) TestFilteredFeeAllowance() { commonFlags..., ) - cmd := cli.NewCmdFeeGrant(addresscodec.NewBech32Codec("cosmos")) + cmd := cli.NewCmdFeeGrant() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &sdk.TxResponse{}), out.String()) diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index 320812aac29a..cc3d08cd06b0 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -9,7 +9,6 @@ import ( "github.com/spf13/cobra" modulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1" - "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" "cosmossdk.io/depinject" @@ -44,7 +43,6 @@ var ( // AppModuleBasic defines the basic application module used by the feegrant module. type AppModuleBasic struct { cdc codec.Codec - ac address.Codec } // Name returns the feegrant module's name. @@ -99,7 +97,7 @@ func (ab AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, // GetTxCmd returns the root tx command for the feegrant module. func (ab AppModuleBasic) GetTxCmd() *cobra.Command { - return cli.GetTxCmd(ab.ac) + return cli.GetTxCmd() } // ---------------------------------------------------------------------------- @@ -119,7 +117,7 @@ type AppModule struct { // NewAppModule creates a new AppModule object func NewAppModule(cdc codec.Codec, ak feegrant.AccountKeeper, bk feegrant.BankKeeper, keeper keeper.Keeper, registry cdctypes.InterfaceRegistry) AppModule { return AppModule{ - AppModuleBasic: AppModuleBasic{cdc: cdc, ac: ak.AddressCodec()}, + AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, accountKeeper: ak, bankKeeper: bk, @@ -205,6 +203,6 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return simulation.WeightedOperations( am.registry, simState.AppParams, simState.Cdc, simState.TxConfig, - am.accountKeeper, am.bankKeeper, am.keeper, am.ac, + am.accountKeeper, am.bankKeeper, am.keeper, am.accountKeeper.AddressCodec(), ) } diff --git a/x/upgrade/client/cli/parse_test.go b/x/upgrade/client/cli/parse_test.go index cb58c1e0a22d..6178133aa706 100644 --- a/x/upgrade/client/cli/parse_test.go +++ b/x/upgrade/client/cli/parse_test.go @@ -7,12 +7,10 @@ import ( "github.com/stretchr/testify/require" "cosmossdk.io/x/upgrade/types" - - addresscodec "github.com/cosmos/cosmos-sdk/codec/address" ) func TestParsePlan(t *testing.T) { - fs := NewCmdSubmitUpgradeProposal(addresscodec.NewBech32Codec("cosmos")).Flags() + fs := NewCmdSubmitUpgradeProposal().Flags() proposal := types.MsgSoftwareUpgrade{ Plan: types.Plan{ diff --git a/x/upgrade/client/cli/tx.go b/x/upgrade/client/cli/tx.go index 466b3fac5811..bbe62448a523 100644 --- a/x/upgrade/client/cli/tx.go +++ b/x/upgrade/client/cli/tx.go @@ -7,7 +7,6 @@ import ( "github.com/spf13/cobra" - addresscodec "cosmossdk.io/core/address" "cosmossdk.io/x/upgrade/plan" "cosmossdk.io/x/upgrade/types" @@ -29,22 +28,22 @@ const ( ) // GetTxCmd returns the transaction commands for this module -func GetTxCmd(ac addresscodec.Codec) *cobra.Command { +func GetTxCmd() *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, Short: "Upgrade transaction subcommands", } cmd.AddCommand( - NewCmdSubmitUpgradeProposal(ac), - NewCmdSubmitCancelUpgradeProposal(ac), + NewCmdSubmitUpgradeProposal(), + NewCmdSubmitCancelUpgradeProposal(), ) return cmd } // NewCmdSubmitUpgradeProposal implements a command handler for submitting a software upgrade proposal transaction. -func NewCmdSubmitUpgradeProposal(ac addresscodec.Codec) *cobra.Command { +func NewCmdSubmitUpgradeProposal() *cobra.Command { cmd := &cobra.Command{ Use: "software-upgrade [name] (--upgrade-height [height]) (--upgrade-info [info]) [flags]", Args: cobra.ExactArgs(1), @@ -97,11 +96,11 @@ func NewCmdSubmitUpgradeProposal(ac addresscodec.Codec) *cobra.Command { authority, _ := cmd.Flags().GetString(FlagAuthority) if authority != "" { - if _, err = ac.StringToBytes(authority); err != nil { + if _, err = clientCtx.AddressCodec.StringToBytes(authority); err != nil { return fmt.Errorf("invalid authority address: %w", err) } } else { - if authority, err = ac.BytesToString(address.Module("gov")); err != nil { + if authority, err = clientCtx.AddressCodec.BytesToString(address.Module("gov")); err != nil { return fmt.Errorf("failed to convert authority address to string: %w", err) } } @@ -138,7 +137,7 @@ func NewCmdSubmitUpgradeProposal(ac addresscodec.Codec) *cobra.Command { } // NewCmdSubmitCancelUpgradeProposal implements a command handler for submitting a software upgrade cancel proposal transaction. -func NewCmdSubmitCancelUpgradeProposal(ac addresscodec.Codec) *cobra.Command { +func NewCmdSubmitCancelUpgradeProposal() *cobra.Command { cmd := &cobra.Command{ Use: "cancel-software-upgrade [flags]", Args: cobra.ExactArgs(0), @@ -157,11 +156,11 @@ func NewCmdSubmitCancelUpgradeProposal(ac addresscodec.Codec) *cobra.Command { authority, _ := cmd.Flags().GetString(FlagAuthority) if authority != "" { - if _, err = ac.StringToBytes(authority); err != nil { + if _, err = clientCtx.AddressCodec.StringToBytes(authority); err != nil { return fmt.Errorf("invalid authority address: %w", err) } } else { - if authority, err = ac.BytesToString(address.Module("gov")); err != nil { + if authority, err = clientCtx.AddressCodec.BytesToString(address.Module("gov")); err != nil { return fmt.Errorf("failed to convert authority address to string: %w", err) } } diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 80775a8a0aa8..b1d85e912a9e 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -47,9 +47,7 @@ var ( ) // AppModuleBasic implements the sdk.AppModuleBasic interface -type AppModuleBasic struct { - ac address.Codec -} +type AppModuleBasic struct{} // Name returns the ModuleName func (AppModuleBasic) Name() string { @@ -70,7 +68,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *g // GetTxCmd returns the CLI transaction commands for this module func (ab AppModuleBasic) GetTxCmd() *cobra.Command { - return cli.GetTxCmd(ab.ac) + return cli.GetTxCmd() } // RegisterInterfaces registers interfaces and implementations of the upgrade module. @@ -87,7 +85,7 @@ type AppModule struct { // NewAppModule creates a new AppModule object func NewAppModule(keeper *keeper.Keeper, ac address.Codec) AppModule { return AppModule{ - AppModuleBasic: AppModuleBasic{ac: ac}, + AppModuleBasic: AppModuleBasic{}, keeper: keeper, } }