diff --git a/app/app.go b/app/app.go index 1f4e2554..514ce82c 100644 --- a/app/app.go +++ b/app/app.go @@ -423,11 +423,11 @@ func New( app.MintKeeper = mintkeeper.NewKeeper( appCodec, keys[minttypes.StoreKey], - authtypes.NewModuleAddress(govtypes.ModuleName), app.StakingKeeper, app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, + authtypes.NewModuleAddress(govtypes.ModuleName), ) app.DistrKeeper = distrkeeper.NewKeeper( diff --git a/go.mod b/go.mod index 330e2832..e439ae2b 100644 --- a/go.mod +++ b/go.mod @@ -29,6 +29,7 @@ require ( github.com/stretchr/testify v1.8.2 google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44 google.golang.org/grpc v1.53.0 + gotest.tools/v3 v3.4.0 sigs.k8s.io/yaml v1.3.0 ) diff --git a/go.sum b/go.sum index c0b3920b..9b9cbff7 100644 --- a/go.sum +++ b/go.sum @@ -1878,9 +1878,9 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= +gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/proto/mint/v1beta1/tx.proto b/proto/mint/v1beta1/tx.proto index 89e23b0a..7806cb29 100644 --- a/proto/mint/v1beta1/tx.proto +++ b/proto/mint/v1beta1/tx.proto @@ -3,30 +3,42 @@ syntax = "proto3"; package mint.v1beta1; import "cosmos/msg/v1/msg.proto"; +import "amino/amino.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "mint/v1beta1/mint.proto"; option go_package = "github.com/okp4/okp4d/x/mint/types"; -// MsgService defines the service for the logic module. -// Do nothing for now as the service is without any side effects. -service MsgService { - // UpdateParams defined a governance operation for updating the x/mint module parameters. - // The authority is hard-coded to the Cosmos SDK x/gov module account +// Msg defines the x/mint Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + + // UpdateParams defines a governance operation for updating the x/mint module + // parameters. The authority is defaults to the x/gov module account. + // + // Since: cosmos-sdk 0.47 rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } -// MsgUpdateParams defines a Msg for updating the x/mint module parameters. +// MsgUpdateParams is the Msg/UpdateParams request type. +// +// Since: cosmos-sdk 0.47 message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; - // authority is the address of the governance account. + option (amino.name) = "cosmos-sdk/x/mint/MsgUpdateParams"; + + // authority is the address that controls the module (defaults to x/gov unless overwritten). string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // params defines the x/mint parameters to update. + // // NOTE: All parameters must be supplied. - Params params = 2 [(gogoproto.nullable) = false]; + Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. +// +// Since: cosmos-sdk 0.47 message MsgUpdateParamsResponse {} diff --git a/x/mint/client/cli/query_test.go b/x/mint/client/cli/query_test.go new file mode 100644 index 00000000..3a098271 --- /dev/null +++ b/x/mint/client/cli/query_test.go @@ -0,0 +1,204 @@ +package cli_test + +import ( + "context" + "fmt" + "io" + "strings" + "testing" + + rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock" + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + + "github.com/cosmos/cosmos-sdk/crypto/keyring" + testutilmod "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/okp4/okp4d/x/mint" + mintcli "github.com/okp4/okp4d/x/mint/client/cli" +) + +func TestGetCmdQueryParams(t *testing.T) { + encCfg := testutilmod.MakeTestEncodingConfig(mint.AppModuleBasic{}) + kr := keyring.NewInMemory(encCfg.Codec) + baseCtx := client.Context{}. + WithKeyring(kr). + WithTxConfig(encCfg.TxConfig). + WithCodec(encCfg.Codec). + WithClient(clitestutil.MockTendermintRPC{Client: rpcclientmock.Client{}}). + WithAccountRetriever(client.MockAccountRetriever{}). + WithOutput(io.Discard). + WithChainID("test-chain") + + cmd := mintcli.GetCmdQueryParams() + + testCases := []struct { + name string + flagArgs []string + expCmdOutput string + expectedOutput string + }{ + { + "json output", + []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)}, + `[--height=1 --output=json]`, + `{"mint_denom":"","annual_reduction_factor":"0","blocks_per_year":"0"}`, + }, + { + "text output", + []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", flags.FlagOutput)}, + `[--height=1 --output=text]`, + `annual_reduction_factor: "0" +blocks_per_year: "0" +mint_denom: ""`, + }, + } + + for _, tc := range testCases { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + ctx := svrcmd.CreateExecuteContext(context.Background()) + + cmd.SetOut(io.Discard) + require.NotNil(t, cmd) + + cmd.SetContext(ctx) + cmd.SetArgs(tc.flagArgs) + + require.NoError(t, client.SetCmdClientContextHandler(baseCtx, cmd)) + + if len(tc.flagArgs) != 0 { + require.Contains(t, fmt.Sprint(cmd), "params [] [] Query the current minting parameters") + require.Contains(t, fmt.Sprint(cmd), tc.expCmdOutput) + } + + out, err := clitestutil.ExecTestCLICmd(baseCtx, cmd, tc.flagArgs) + require.NoError(t, err) + require.Equal(t, tc.expectedOutput, strings.TrimSpace(out.String())) + }) + } +} + +func TestGetCmdQueryInflation(t *testing.T) { + encCfg := testutilmod.MakeTestEncodingConfig(mint.AppModuleBasic{}) + kr := keyring.NewInMemory(encCfg.Codec) + baseCtx := client.Context{}. + WithKeyring(kr). + WithTxConfig(encCfg.TxConfig). + WithCodec(encCfg.Codec). + WithClient(clitestutil.MockTendermintRPC{Client: rpcclientmock.Client{}}). + WithAccountRetriever(client.MockAccountRetriever{}). + WithOutput(io.Discard). + WithChainID("test-chain") + + cmd := mintcli.GetCmdQueryInflation() + + testCases := []struct { + name string + flagArgs []string + expCmdOutput string + expectedOutput string + }{ + { + "json output", + []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)}, + `[--height=1 --output=json]`, + ``, + }, + { + "text output", + []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", flags.FlagOutput)}, + `[--height=1 --output=text]`, + ``, + }, + } + + for _, tc := range testCases { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + ctx := svrcmd.CreateExecuteContext(context.Background()) + + cmd.SetOut(io.Discard) + require.NotNil(t, cmd) + + cmd.SetContext(ctx) + cmd.SetArgs(tc.flagArgs) + + require.NoError(t, client.SetCmdClientContextHandler(baseCtx, cmd)) + + if len(tc.flagArgs) != 0 { + require.Contains(t, fmt.Sprint(cmd), "inflation [] [] Query the current minting inflation value") + require.Contains(t, fmt.Sprint(cmd), tc.expCmdOutput) + } + + out, err := clitestutil.ExecTestCLICmd(baseCtx, cmd, tc.flagArgs) + require.NoError(t, err) + require.Equal(t, tc.expectedOutput, strings.TrimSpace(out.String())) + }) + } +} + +func TestGetCmdQueryAnnualProvisions(t *testing.T) { + encCfg := testutilmod.MakeTestEncodingConfig(mint.AppModuleBasic{}) + kr := keyring.NewInMemory(encCfg.Codec) + baseCtx := client.Context{}. + WithKeyring(kr). + WithTxConfig(encCfg.TxConfig). + WithCodec(encCfg.Codec). + WithClient(clitestutil.MockTendermintRPC{Client: rpcclientmock.Client{}}). + WithAccountRetriever(client.MockAccountRetriever{}). + WithOutput(io.Discard). + WithChainID("test-chain") + + cmd := mintcli.GetCmdQueryAnnualProvisions() + + testCases := []struct { + name string + flagArgs []string + expCmdOutput string + expectedOutput string + }{ + { + "json output", + []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)}, + `[--height=1 --output=json]`, + ``, + }, + { + "text output", + []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", flags.FlagOutput)}, + `[--height=1 --output=text]`, + ``, + }, + } + + for _, tc := range testCases { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + ctx := svrcmd.CreateExecuteContext(context.Background()) + + cmd.SetOut(io.Discard) + require.NotNil(t, cmd) + + cmd.SetContext(ctx) + cmd.SetArgs(tc.flagArgs) + + require.NoError(t, client.SetCmdClientContextHandler(baseCtx, cmd)) + + if len(tc.flagArgs) != 0 { + require.Contains(t, fmt.Sprint(cmd), "annual-provisions [] [] Query the current minting annual provisions value") + require.Contains(t, fmt.Sprint(cmd), tc.expCmdOutput) + } + + out, err := clitestutil.ExecTestCLICmd(baseCtx, cmd, tc.flagArgs) + require.NoError(t, err) + require.Equal(t, tc.expectedOutput, strings.TrimSpace(out.String())) + }) + } +} diff --git a/x/mint/client/testutil/cli_test.go b/x/mint/client/testutil/cli_test.go deleted file mode 100644 index 1035ca75..00000000 --- a/x/mint/client/testutil/cli_test.go +++ /dev/null @@ -1,18 +0,0 @@ -//go:build norace -// +build norace - -package testutil - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/testutil/network" - - "github.com/stretchr/testify/suite" -) - -func TestIntegrationTestSuite(t *testing.T) { - cfg := network.DefaultConfig() - cfg.NumValidators = 1 - suite.Run(t, NewIntegrationTestSuite(cfg)) -} diff --git a/x/mint/client/testutil/grpc_test.go b/x/mint/client/testutil/grpc_test.go deleted file mode 100644 index 95f31f98..00000000 --- a/x/mint/client/testutil/grpc_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package testutil - -import ( - "fmt" - - "github.com/cosmos/cosmos-sdk/testutil" - sdk "github.com/cosmos/cosmos-sdk/types" - grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" - - "github.com/gogo/protobuf/proto" - - minttypes "github.com/okp4/okp4d/x/mint/types" -) - -func (s *IntegrationTestSuite) TestQueryGRPC() { - val := s.network.Validators[0] - baseURL := val.APIAddress - testCases := []struct { - name string - url string - headers map[string]string - respType proto.Message - expected proto.Message - }{ - { - "gRPC request params", - fmt.Sprintf("%s/cosmos/mint/v1beta1/params", baseURL), - map[string]string{}, - &minttypes.QueryParamsResponse{}, - &minttypes.QueryParamsResponse{ - Params: minttypes.NewParams("stake", sdk.NewDecWithPrec(13, 2), (60 * 60 * 8766 / 5)), - }, - }, - { - "gRPC request inflation", - fmt.Sprintf("%s/cosmos/mint/v1beta1/inflation", baseURL), - map[string]string{}, - &minttypes.QueryInflationResponse{}, - &minttypes.QueryInflationResponse{ - Inflation: sdk.NewDec(1), - }, - }, - { - "gRPC request annual provisions", - fmt.Sprintf("%s/cosmos/mint/v1beta1/annual_provisions", baseURL), - map[string]string{ - grpctypes.GRPCBlockHeightHeader: "1", - }, - &minttypes.QueryAnnualProvisionsResponse{}, - &minttypes.QueryAnnualProvisionsResponse{ - AnnualProvisions: sdk.NewDec(500000000), - }, - }, - } - for _, tc := range testCases { - resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) - s.Run(tc.name, func() { - s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, tc.respType)) - s.Require().Equal(tc.expected.String(), tc.respType.String()) - }) - } -} diff --git a/x/mint/client/testutil/suite_test.go b/x/mint/client/testutil/suite_test.go deleted file mode 100644 index 49bd900b..00000000 --- a/x/mint/client/testutil/suite_test.go +++ /dev/null @@ -1,159 +0,0 @@ -package testutil - -import ( - "fmt" - "strings" - - "github.com/stretchr/testify/suite" - tmcli "github.com/tendermint/tendermint/libs/cli" - - "github.com/cosmos/cosmos-sdk/client/flags" - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - "github.com/cosmos/cosmos-sdk/testutil/network" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/okp4/okp4d/x/mint/client/cli" - minttypes "github.com/okp4/okp4d/x/mint/types" -) - -type IntegrationTestSuite struct { - suite.Suite - - cfg network.Config - network *network.Network -} - -func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite { - return &IntegrationTestSuite{cfg: cfg} -} - -func (s *IntegrationTestSuite) SetupSuite() { - s.T().Log("setting up integration test suite") - - genesisState := s.cfg.GenesisState - - var mintData minttypes.GenesisState - s.Require().NoError(s.cfg.Codec.UnmarshalJSON(genesisState[minttypes.ModuleName], &mintData)) - - inflation := sdk.MustNewDecFromStr("1.0") - mintData.Minter.Inflation = inflation - - mintDataBz, err := s.cfg.Codec.MarshalJSON(&mintData) - s.Require().NoError(err) - genesisState[minttypes.ModuleName] = mintDataBz - s.cfg.GenesisState = genesisState - - s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg) - s.Require().NoError(err) - - _, err = s.network.WaitForHeight(1) - s.Require().NoError(err) -} - -func (s *IntegrationTestSuite) TearDownSuite() { - s.T().Log("tearing down integration test suite") - s.network.Cleanup() -} - -func (s *IntegrationTestSuite) TestGetCmdQueryParams() { - val := s.network.Validators[0] - - testCases := []struct { - name string - args []string - expectedOutput string - }{ - { - "json output", - []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, - `{"mint_denom":"stake","annual_reduction_factor":"0.200000000000000000","blocks_per_year":"6311520"}`, - }, - { - "text output", - []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)}, - `blocks_per_year: "6311520" -annual_reduction_factor: "0.200000000000000000" -mint_denom: stake`, - }, - } - - for _, tc := range testCases { - tc := tc - - s.Run(tc.name, func() { - cmd := cli.GetCmdQueryParams() - clientCtx := val.ClientCtx - - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - s.Require().NoError(err) - s.Require().Equal(tc.expectedOutput, strings.TrimSpace(out.String())) - }) - } -} - -func (s *IntegrationTestSuite) TestGetCmdQueryInflation() { - val := s.network.Validators[0] - - testCases := []struct { - name string - args []string - expectedOutput string - }{ - { - "json output", - []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, - `1.000000000000000000`, - }, - { - "text output", - []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)}, - `1.000000000000000000`, - }, - } - - for _, tc := range testCases { - tc := tc - - s.Run(tc.name, func() { - cmd := cli.GetCmdQueryInflation() - clientCtx := val.ClientCtx - - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - s.Require().NoError(err) - s.Require().Equal(tc.expectedOutput, strings.TrimSpace(out.String())) - }) - } -} - -func (s *IntegrationTestSuite) TestGetCmdQueryAnnualProvisions() { - val := s.network.Validators[0] - - testCases := []struct { - name string - args []string - expectedOutput string - }{ - { - "json output", - []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, - `500000000.000000000000000000`, - }, - { - "text output", - []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)}, - `500000000.000000000000000000`, - }, - } - - for _, tc := range testCases { - tc := tc - - s.Run(tc.name, func() { - cmd := cli.GetCmdQueryAnnualProvisions() - clientCtx := val.ClientCtx - - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - s.Require().NoError(err) - s.Require().Equal(tc.expectedOutput, strings.TrimSpace(out.String())) - }) - } -} diff --git a/x/mint/keeper/genesis_test.go b/x/mint/keeper/genesis_test.go new file mode 100644 index 00000000..ea951877 --- /dev/null +++ b/x/mint/keeper/genesis_test.go @@ -0,0 +1,80 @@ +package keeper_test + +import ( + "testing" + + "cosmossdk.io/math" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/okp4/okp4d/x/mint" + "github.com/okp4/okp4d/x/mint/keeper" + minttestutil "github.com/okp4/okp4d/x/mint/testutil" + "github.com/okp4/okp4d/x/mint/types" +) + +var minterAcc = authtypes.NewEmptyModuleAccount(types.ModuleName, authtypes.Minter) + +type GenesisTestSuite struct { + suite.Suite + + sdkCtx sdk.Context + keeper keeper.Keeper + cdc codec.BinaryCodec + accountKeeper types.AccountKeeper + key *storetypes.KVStoreKey +} + +func TestGenesisTestSuite(t *testing.T) { + suite.Run(t, new(GenesisTestSuite)) +} + +func (s *GenesisTestSuite) SetupTest() { + key := sdk.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test")) + encCfg := moduletestutil.MakeTestEncodingConfig(mint.AppModuleBasic{}) + + // gomock initializations + ctrl := gomock.NewController(s.T()) + s.cdc = codec.NewProtoCodec(encCfg.InterfaceRegistry) + s.sdkCtx = testCtx.Ctx + s.key = key + + stakingKeeper := minttestutil.NewMockStakingKeeper(ctrl) + accountKeeper := minttestutil.NewMockAccountKeeper(ctrl) + bankKeeper := minttestutil.NewMockBankKeeper(ctrl) + s.accountKeeper = accountKeeper + accountKeeper.EXPECT().GetModuleAddress(minterAcc.Name).Return(minterAcc.GetAddress()) + accountKeeper.EXPECT().GetModuleAccount(s.sdkCtx, minterAcc.Name).Return(minterAcc) + + s.keeper = keeper.NewKeeper(s.cdc, key, stakingKeeper, accountKeeper, bankKeeper, "", "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn") +} + +func (s *GenesisTestSuite) TestImportExportGenesis() { + genesisState := types.DefaultGenesisState() + genesisState.Minter = types.NewMinter(sdk.OneDec(), sdk.NewDecWithPrec(20, 2), math.NewInt(1)) + genesisState.Params = types.NewParams( + "testDenom", + sdk.NewDecWithPrec(69, 2), + uint64(60*60*8766/5), + ) + + s.keeper.InitGenesis(s.sdkCtx, s.accountKeeper, genesisState) + + minter := s.keeper.GetMinter(s.sdkCtx) + s.Require().Equal(genesisState.Minter, minter) + + invalidCtx := testutil.DefaultContextWithDB(s.T(), s.key, sdk.NewTransientStoreKey("transient_test")) + s.Require().Panics(func() { s.keeper.GetMinter(invalidCtx.Ctx) }, "stored minter should not have been nil") + params := s.keeper.GetParams(s.sdkCtx) + s.Require().Equal(genesisState.Params, params) + + genesisState2 := s.keeper.ExportGenesis(s.sdkCtx) + s.Require().Equal(genesisState, genesisState2) +} diff --git a/x/mint/keeper/grpc_query_test.go b/x/mint/keeper/grpc_query_test.go new file mode 100644 index 00000000..d1404fa8 --- /dev/null +++ b/x/mint/keeper/grpc_query_test.go @@ -0,0 +1,80 @@ +package keeper_test + +import ( + gocontext "context" + "testing" + + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/okp4/okp4d/x/mint" + "github.com/okp4/okp4d/x/mint/keeper" + minttestutil "github.com/okp4/okp4d/x/mint/testutil" + "github.com/okp4/okp4d/x/mint/types" +) + +type MintTestSuite struct { + suite.Suite + + ctx sdk.Context + queryClient types.QueryClient + mintKeeper keeper.Keeper +} + +func (suite *MintTestSuite) SetupTest() { + encCfg := moduletestutil.MakeTestEncodingConfig(mint.AppModuleBasic{}) + key := sdk.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(suite.T(), key, sdk.NewTransientStoreKey("transient_test")) + suite.ctx = testCtx.Ctx + + // gomock initializations + ctrl := gomock.NewController(suite.T()) + accountKeeper := minttestutil.NewMockAccountKeeper(ctrl) + bankKeeper := minttestutil.NewMockBankKeeper(ctrl) + stakingKeeper := minttestutil.NewMockStakingKeeper(ctrl) + + accountKeeper.EXPECT().GetModuleAddress("mint").Return(sdk.AccAddress{}) + + suite.mintKeeper = keeper.NewKeeper( + encCfg.Codec, + key, + stakingKeeper, + accountKeeper, + bankKeeper, + authtypes.FeeCollectorName, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + err := suite.mintKeeper.SetParams(suite.ctx, types.DefaultParams()) + suite.Require().NoError(err) + suite.mintKeeper.SetMinter(suite.ctx, types.DefaultInitialMinter()) + + queryHelper := baseapp.NewQueryServerTestHelper(testCtx.Ctx, encCfg.InterfaceRegistry) + types.RegisterQueryServer(queryHelper, suite.mintKeeper) + + suite.queryClient = types.NewQueryClient(queryHelper) +} + +func (suite *MintTestSuite) TestGRPCParams() { + params, err := suite.queryClient.Params(gocontext.Background(), &types.QueryParamsRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(params.Params, suite.mintKeeper.GetParams(suite.ctx)) + + inflation, err := suite.queryClient.Inflation(gocontext.Background(), &types.QueryInflationRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(inflation.Inflation, suite.mintKeeper.GetMinter(suite.ctx).Inflation) + + annualProvisions, err := suite.queryClient.AnnualProvisions(gocontext.Background(), &types.QueryAnnualProvisionsRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(annualProvisions.AnnualProvisions, suite.mintKeeper.GetMinter(suite.ctx).AnnualProvisions) +} + +func TestMintTestSuite(t *testing.T) { + suite.Run(t, new(MintTestSuite)) +} diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index 3e6a749a..95de9033 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -2,7 +2,8 @@ package keeper import ( "cosmossdk.io/math" - "github.com/tendermint/tendermint/libs/log" + + "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -25,11 +26,11 @@ type Keeper struct { func NewKeeper( cdc codec.BinaryCodec, key storetypes.StoreKey, - authority sdk.AccAddress, sk types.StakingKeeper, ak types.AccountKeeper, bk types.BankKeeper, feeCollectorName string, + authority string, ) Keeper { // ensure mint module account is set if addr := ak.GetModuleAddress(types.ModuleName); addr == nil { @@ -37,20 +38,29 @@ func NewKeeper( } // ensure gov module account is set and is not nil - if err := sdk.VerifyAddressFormat(authority); err != nil { + addr, err := sdk.AccAddressFromBech32(authority) + if err != nil { + panic(err) + } + if err := sdk.VerifyAddressFormat(addr); err != nil { panic(err) } return Keeper{ cdc: cdc, storeKey: key, - authority: authority, + authority: addr, stakingKeeper: sk, bankKeeper: bk, feeCollectorName: feeCollectorName, } } +// GetAuthority returns the x/mint module's authority. +func (k Keeper) GetAuthority() string { + return k.authority.String() +} + // Logger returns a module-specific logger. func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) diff --git a/x/mint/keeper/keeper_test.go b/x/mint/keeper/keeper_test.go new file mode 100644 index 00000000..bc3267d7 --- /dev/null +++ b/x/mint/keeper/keeper_test.go @@ -0,0 +1,132 @@ +package keeper_test + +import ( + "testing" + + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/okp4/okp4d/x/mint" + "github.com/okp4/okp4d/x/mint/keeper" + minttestutil "github.com/okp4/okp4d/x/mint/testutil" + "github.com/okp4/okp4d/x/mint/types" +) + +type IntegrationTestSuite struct { + suite.Suite + + mintKeeper keeper.Keeper + ctx sdk.Context + msgServer types.MsgServer + stakingKeeper *minttestutil.MockStakingKeeper + bankKeeper *minttestutil.MockBankKeeper +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} + +func (s *IntegrationTestSuite) SetupTest() { + encCfg := moduletestutil.MakeTestEncodingConfig(mint.AppModuleBasic{}) + key := sdk.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test")) + s.ctx = testCtx.Ctx + + // gomock initializations + ctrl := gomock.NewController(s.T()) + accountKeeper := minttestutil.NewMockAccountKeeper(ctrl) + bankKeeper := minttestutil.NewMockBankKeeper(ctrl) + stakingKeeper := minttestutil.NewMockStakingKeeper(ctrl) + + accountKeeper.EXPECT().GetModuleAddress(types.ModuleName).Return(sdk.AccAddress{}) + + s.mintKeeper = keeper.NewKeeper( + encCfg.Codec, + key, + stakingKeeper, + accountKeeper, + bankKeeper, + authtypes.FeeCollectorName, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + s.stakingKeeper = stakingKeeper + s.bankKeeper = bankKeeper + + s.Require().Equal(testCtx.Ctx.Logger().With("module", "x/"+types.ModuleName), + s.mintKeeper.Logger(testCtx.Ctx)) + + err := s.mintKeeper.SetParams(s.ctx, types.DefaultParams()) + s.Require().NoError(err) + s.mintKeeper.SetMinter(s.ctx, types.DefaultInitialMinter()) + + s.msgServer = keeper.NewMsgServerImpl(s.mintKeeper) +} + +func (s *IntegrationTestSuite) TestParams() { + testCases := []struct { + name string + input types.Params + expectErr bool + }{ + { + name: "set invalid params", + input: types.Params{ + MintDenom: sdk.DefaultBondDenom, + AnnualReductionFactor: sdk.NewDecWithPrec(-13, 2), + BlocksPerYear: uint64(60 * 60 * 8766 / 5), + }, + expectErr: true, + }, + { + name: "set full valid params", + input: types.Params{ + MintDenom: sdk.DefaultBondDenom, + AnnualReductionFactor: sdk.NewDecWithPrec(8, 2), + BlocksPerYear: uint64(60 * 60 * 8766 / 5), + }, + expectErr: false, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + expected := s.mintKeeper.GetParams(s.ctx) + err := s.mintKeeper.SetParams(s.ctx, tc.input) + if tc.expectErr { + s.Require().Error(err) + } else { + expected = tc.input + s.Require().NoError(err) + } + + p := s.mintKeeper.GetParams(s.ctx) + s.Require().Equal(expected, p) + }) + } +} + +func (s *IntegrationTestSuite) TestAliasFunctions() { + stakingTokenSupply := sdk.NewIntFromUint64(100000000000) + s.stakingKeeper.EXPECT().StakingTokenSupply(s.ctx).Return(stakingTokenSupply) + s.Require().Equal(s.mintKeeper.StakingTokenSupply(s.ctx), stakingTokenSupply) + + bondedRatio := sdk.NewDecWithPrec(15, 2) + s.stakingKeeper.EXPECT().BondedRatio(s.ctx).Return(bondedRatio) + s.Require().Equal(s.mintKeeper.BondedRatio(s.ctx), bondedRatio) + + coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000000))) + s.bankKeeper.EXPECT().MintCoins(s.ctx, types.ModuleName, coins).Return(nil) + s.Require().Equal(s.mintKeeper.MintCoins(s.ctx, sdk.NewCoins()), nil) + s.Require().Nil(s.mintKeeper.MintCoins(s.ctx, coins)) + + fees := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000))) + s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(s.ctx, types.ModuleName, authtypes.FeeCollectorName, fees).Return(nil) + s.Require().Nil(s.mintKeeper.AddCollectedFees(s.ctx, fees)) +} diff --git a/x/mint/keeper/msg_server.go b/x/mint/keeper/msg_server.go index d64e8c2e..d132da47 100644 --- a/x/mint/keeper/msg_server.go +++ b/x/mint/keeper/msg_server.go @@ -9,18 +9,18 @@ import ( "github.com/okp4/okp4d/x/mint/types" ) +var _ types.MsgServer = msgServer{} + type msgServer struct { Keeper } // NewMsgServerImpl returns an implementation of the MsgServer interface // for the provided Keeper. -func NewMsgServerImpl(keeper Keeper) types.MsgServiceServer { +func NewMsgServerImpl(keeper Keeper) types.MsgServer { return &msgServer{Keeper: keeper} } -var _ types.MsgServiceServer = msgServer{} - // UpdateParams implements the gRPC MsgServer interface. When an UpdateParams // proposal passes, it updates the module parameters. The update can only be // performed if the requested authority is the Cosmos SDK governance module diff --git a/x/mint/keeper/msg_server_test.go b/x/mint/keeper/msg_server_test.go new file mode 100644 index 00000000..c3b056eb --- /dev/null +++ b/x/mint/keeper/msg_server_test.go @@ -0,0 +1,58 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/okp4/okp4d/x/mint/types" +) + +func (s *IntegrationTestSuite) TestUpdateParams() { + testCases := []struct { + name string + request *types.MsgUpdateParams + expectErr bool + }{ + { + name: "set invalid authority", + request: &types.MsgUpdateParams{ + Authority: "foo", + }, + expectErr: true, + }, + { + name: "set invalid params", + request: &types.MsgUpdateParams{ + Authority: s.mintKeeper.GetAuthority(), + Params: types.Params{ + MintDenom: sdk.DefaultBondDenom, + AnnualReductionFactor: sdk.NewDecWithPrec(-13, 2), + BlocksPerYear: uint64(60 * 60 * 8766 / 5), + }, + }, + expectErr: true, + }, + { + name: "set full valid params", + request: &types.MsgUpdateParams{ + Authority: s.mintKeeper.GetAuthority(), + Params: types.Params{ + MintDenom: sdk.DefaultBondDenom, + AnnualReductionFactor: sdk.NewDecWithPrec(8, 2), + BlocksPerYear: uint64(60 * 60 * 8766 / 5), + }, + }, + expectErr: false, + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + _, err := s.msgServer.UpdateParams(s.ctx, tc.request) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + } + }) + } +} diff --git a/x/mint/keeper/querier.go b/x/mint/keeper/querier.go deleted file mode 100644 index 0b927350..00000000 --- a/x/mint/keeper/querier.go +++ /dev/null @@ -1,62 +0,0 @@ -package keeper - -import ( - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/okp4/okp4d/x/mint/types" -) - -// NewQuerier returns a minting Querier handler. -func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, _ abci.RequestQuery) ([]byte, error) { - switch path[0] { - case types.QueryParameters: - return queryParams(ctx, k, legacyQuerierCdc) - - case types.QueryInflation: - return queryInflation(ctx, k, legacyQuerierCdc) - - case types.QueryAnnualProvisions: - return queryAnnualProvisions(ctx, k, legacyQuerierCdc) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query path: %s", path[0]) - } - } -} - -func queryParams(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - params := k.GetParams(ctx) - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, params) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryInflation(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - minter := k.GetMinter(ctx) - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, minter.Inflation) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryAnnualProvisions(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - minter := k.GetMinter(ctx) - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, minter.AnnualProvisions) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} diff --git a/x/mint/module.go b/x/mint/module.go index 7d4d3738..5b23e46b 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -4,12 +4,11 @@ import ( "context" "encoding/json" "fmt" - "math/rand" + abci "github.com/cometbft/cometbft/abci/types" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/okp4/okp4d/x/mint/exported" "github.com/spf13/cobra" - abci "github.com/tendermint/tendermint/abci/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -108,23 +107,10 @@ func (AppModule) Name() string { // RegisterInvariants registers the mint module invariants. func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Deprecated: Route returns the message routing key for the mint module. -func (AppModule) Route() sdk.Route { return sdk.Route{} } - -// QuerierRoute returns the mint module's querier route name. -func (AppModule) QuerierRoute() string { - return types.QuerierRoute -} - -// LegacyQuerierHandler returns the mint module sdk.Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper, legacyQuerierCdc) -} - // RegisterServices registers a gRPC query service to respond to the // module-specific gRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterMsgServiceServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) migrator := keeper.NewMigrator(am.keeper, am.legacySubspace) @@ -181,11 +167,6 @@ func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.We return nil } -// RandomizedParams creates randomized mint param changes for the simulator. -func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { - return simulation.ParamChanges(r) -} - // RegisterStoreDecoder registers a decoder for mint module's types. func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc) diff --git a/x/mint/module_test.go b/x/mint/module_test.go index 446fbf07..ed4f510b 100644 --- a/x/mint/module_test.go +++ b/x/mint/module_test.go @@ -3,43 +3,23 @@ package mint_test import ( "testing" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/require" - abcitypes "github.com/tendermint/tendermint/abci/types" - tmjson "github.com/tendermint/tendermint/libs/json" - "github.com/tendermint/tendermint/libs/log" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - dbm "github.com/tendermint/tm-db" - "github.com/cosmos/cosmos-sdk/simapp" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/okp4/okp4d/x/mint/types" + "github.com/cosmos/cosmos-sdk/x/mint/testutil" + "github.com/cosmos/cosmos-sdk/x/mint/types" ) func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { - db := dbm.NewMemDB() - encCdc := simapp.MakeTestEncodingConfig() - app := simapp.NewSimApp(log.NewNopLogger(), - db, - nil, - true, - map[int64]bool{}, - simapp.DefaultNodeHome, - 5, - encCdc, - simapp.EmptyAppOptions{}) + var accountKeeper authkeeper.AccountKeeper - genesisState := simapp.GenesisStateWithSingleValidator(t, app) - stateBytes, err := tmjson.Marshal(genesisState) + app, err := simtestutil.SetupAtGenesis(testutil.AppConfig, &accountKeeper) require.NoError(t, err) - app.InitChain( - abcitypes.RequestInitChain{ - AppStateBytes: stateBytes, - ChainId: "test-chain-id", - }, - ) - - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - acc := app.AccountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.ModuleName)) + ctx := app.BaseApp.NewContext(false, cmtproto.Header{}) + acc := accountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.ModuleName)) require.NotNil(t, acc) } diff --git a/x/mint/simulation/decoder_test.go b/x/mint/simulation/decoder_test.go index f276a830..29581fd0 100644 --- a/x/mint/simulation/decoder_test.go +++ b/x/mint/simulation/decoder_test.go @@ -4,24 +4,26 @@ import ( "fmt" "testing" + "github.com/okp4/okp4d/x/mint" "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/okp4/okp4d/x/mint/simulation" "github.com/okp4/okp4d/x/mint/types" ) func TestDecodeStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Codec - dec := simulation.NewDecodeStore(cdc) + encCfg := moduletestutil.MakeTestEncodingConfig(mint.AppModuleBasic{}) + + dec := simulation.NewDecodeStore(encCfg.Codec) minter := types.NewMinter(sdk.OneDec(), sdk.NewDec(15), sdk.NewInt(1)) kvPairs := kv.Pairs{ Pairs: []kv.Pair{ - {Key: types.MinterKey, Value: cdc.MustMarshal(&minter)}, + {Key: types.MinterKey, Value: encCfg.Codec.MustMarshal(&minter)}, {Key: []byte{0x99}, Value: []byte{0x99}}, }, } diff --git a/x/mint/simulation/params.go b/x/mint/simulation/params.go deleted file mode 100644 index 78071ec5..00000000 --- a/x/mint/simulation/params.go +++ /dev/null @@ -1,29 +0,0 @@ -package simulation - -// DONTCOVER - -import ( - "fmt" - "math/rand" - - "github.com/cosmos/cosmos-sdk/x/simulation" - - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/okp4/okp4d/x/mint/types" -) - -const ( - KeyAnnualReductionFactor = "AnnualReductionFactor" -) - -// ParamChanges defines the parameters that can be modified by param change proposals -// on the simulation. -func ParamChanges(r *rand.Rand) []simtypes.ParamChange { - return []simtypes.ParamChange{ - simulation.NewSimParamChange(types.ModuleName, KeyAnnualReductionFactor, - func(r *rand.Rand) string { - return fmt.Sprintf("\"%s\"", GenAnnualReductionFactorMax(r)) - }, - ), - } -} diff --git a/x/mint/simulation/params_test.go b/x/mint/simulation/params_test.go deleted file mode 100644 index be6928da..00000000 --- a/x/mint/simulation/params_test.go +++ /dev/null @@ -1,35 +0,0 @@ -//nolint:gosec -package simulation_test - -import ( - "math/rand" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/okp4/okp4d/x/mint/simulation" -) - -func TestParamChanges(t *testing.T) { - s := rand.NewSource(1) - r := rand.New(s) - - expected := []struct { - composedKey string - key string - simValue string - subspace string - }{ - {"mint/AnnualReductionFactor", "AnnualReductionFactor", "\"0.200000000000000000\"", "mint"}, - } - - paramChanges := simulation.ParamChanges(r) - require.Len(t, paramChanges, 1) - - for i, p := range paramChanges { - require.Equal(t, expected[i].composedKey, p.ComposedKey()) - require.Equal(t, expected[i].key, p.Key()) - require.Equal(t, expected[i].simValue, p.SimValue()(r)) - require.Equal(t, expected[i].subspace, p.Subspace()) - } -} diff --git a/x/mint/simulation/proposals.go b/x/mint/simulation/proposals.go new file mode 100644 index 00000000..3d0b16cd --- /dev/null +++ b/x/mint/simulation/proposals.go @@ -0,0 +1,45 @@ +package simulation + +import ( + "math/rand" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/okp4/okp4d/x/mint/types" +) + +// Simulation operation weights constants +const ( + DefaultWeightMsgUpdateParams int = 100 + + OpWeightMsgUpdateParams = "op_weight_msg_update_params" //nolint:gosec +) + +// ProposalMsgs defines the module weighted proposals' contents +func ProposalMsgs() []simtypes.WeightedProposalMsg { + return []simtypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( + OpWeightMsgUpdateParams, + DefaultWeightMsgUpdateParams, + SimulateMsgUpdateParams, + ), + } +} + +// SimulateMsgUpdateParams returns a random MsgUpdateParams +func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg { + // use the default gov module account address as authority + var authority sdk.AccAddress = address.Module("gov") + + params := types.DefaultParams() + params.BlocksPerYear = uint64(simtypes.RandIntBetween(r, 1, 1000000)) + params.AnnualReductionFactor = sdk.NewDecWithPrec(int64(simtypes.RandIntBetween(r, 1, 100)), 2) + params.MintDenom = simtypes.RandStringOfLength(r, 10) + + return &types.MsgUpdateParams{ + Authority: authority.String(), + Params: params, + } +} diff --git a/x/mint/simulation/proposals_test.go b/x/mint/simulation/proposals_test.go new file mode 100644 index 00000000..76ee4c07 --- /dev/null +++ b/x/mint/simulation/proposals_test.go @@ -0,0 +1,43 @@ +package simulation_test + +import ( + "math/rand" + "testing" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "gotest.tools/v3/assert" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/okp4/okp4d/x/mint/simulation" + "github.com/okp4/okp4d/x/mint/types" +) + +func TestProposalMsgs(t *testing.T) { + // initialize parameters + s := rand.NewSource(1) + r := rand.New(s) + + ctx := sdk.NewContext(nil, tmproto.Header{}, true, nil) + accounts := simtypes.RandomAccounts(r, 3) + + // execute ProposalMsgs function + weightedProposalMsgs := simulation.ProposalMsgs() + assert.Assert(t, len(weightedProposalMsgs) == 1) + + w0 := weightedProposalMsgs[0] + + // tests w0 interface: + assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) + assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) + + msg := w0.MsgSimulatorFn()(r, ctx, accounts) + msgUpdateParams, ok := msg.(*types.MsgUpdateParams) + assert.Assert(t, ok) + + assert.Equal(t, sdk.AccAddress(address.Module("gov")).String(), msgUpdateParams.Authority) + assert.Equal(t, uint64(122877), msgUpdateParams.Params.BlocksPerYear) + assert.DeepEqual(t, sdk.NewDecWithPrec(95, 2), msgUpdateParams.Params.AnnualReductionFactor) + assert.Equal(t, "eAerqyNEUz", msgUpdateParams.Params.MintDenom) +} diff --git a/x/mint/types/codec.go b/x/mint/types/codec.go index 7ffb2837..9161618b 100644 --- a/x/mint/types/codec.go +++ b/x/mint/types/codec.go @@ -36,7 +36,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &MsgUpdateParams{}, ) - msgservice.RegisterMsgServiceDesc(registry, &_MsgService_serviceDesc) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } // RegisterLegacyAminoCodec required for EIP-712. diff --git a/x/mint/types/genesis.pb.go b/x/mint/types/genesis.pb.go index 68825f3b..cd9b8c33 100644 --- a/x/mint/types/genesis.pb.go +++ b/x/mint/types/genesis.pb.go @@ -5,8 +5,9 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/gogo/protobuf/proto" + proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" @@ -85,20 +86,21 @@ func init() { func init() { proto.RegisterFile("mint/v1beta1/genesis.proto", fileDescriptor_1dfa75836a5d5f23) } var fileDescriptor_1dfa75836a5d5f23 = []byte{ - // 206 bytes of a gzipped FileDescriptorProto + // 219 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x01, 0xc9, 0xe9, 0x41, 0xe5, 0xa4, 0x44, 0xd2, - 0xf3, 0xd3, 0xf3, 0xc1, 0x12, 0xfa, 0x20, 0x16, 0x44, 0x8d, 0x94, 0x38, 0x8a, 0x7e, 0xb0, 0x06, - 0xb0, 0x84, 0x52, 0x19, 0x17, 0x8f, 0x3b, 0xc4, 0xb4, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x23, - 0x2e, 0x36, 0x90, 0x6c, 0x6a, 0x91, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0x88, 0x1e, 0xb2, - 0xe9, 0x7a, 0xbe, 0x60, 0x39, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0x2a, 0x41, 0x7a, - 0x0a, 0x12, 0x8b, 0x12, 0x73, 0x8b, 0x25, 0x98, 0xb0, 0xe9, 0x09, 0x00, 0xcb, 0xc1, 0xf4, 0x40, - 0x54, 0x3a, 0xd9, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, - 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x52, 0x7a, - 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x7e, 0x76, 0x81, 0x09, 0x98, 0x48, - 0xd1, 0xaf, 0x00, 0xbb, 0x5a, 0xbf, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x78, 0x63, - 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x35, 0x33, 0x58, 0xd7, 0x17, 0x01, 0x00, 0x00, + 0xf3, 0xd3, 0xf3, 0xc1, 0x12, 0xfa, 0x20, 0x16, 0x44, 0x8d, 0x94, 0x64, 0x72, 0x7e, 0x71, 0x6e, + 0x7e, 0x71, 0x3c, 0x44, 0x02, 0xc2, 0x81, 0x4a, 0x89, 0xa3, 0x18, 0x0d, 0x36, 0x0b, 0x2c, 0xa1, + 0x54, 0xc6, 0xc5, 0xe3, 0x0e, 0xb1, 0x28, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x88, 0x8b, 0x0d, + 0x24, 0x9b, 0x5a, 0x24, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xa2, 0x87, 0x6c, 0xb1, 0x9e, + 0x2f, 0x58, 0xce, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x4a, 0x90, 0x9e, 0x82, 0xc4, + 0xa2, 0xc4, 0xdc, 0x62, 0x09, 0x26, 0x6c, 0x7a, 0x02, 0xc0, 0x72, 0x30, 0x3d, 0x10, 0x95, 0x4e, + 0x36, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, + 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x94, 0x9e, 0x59, 0x92, + 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x9f, 0x5d, 0x60, 0x02, 0x26, 0x52, 0xf4, 0x2b, + 0xc0, 0xae, 0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x3b, 0xde, 0x18, 0x10, 0x00, + 0x00, 0xff, 0xff, 0xd3, 0xb8, 0x32, 0x98, 0x32, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/mint/types/mint.pb.go b/x/mint/types/mint.pb.go index c7aca81e..6a5cc301 100644 --- a/x/mint/types/mint.pb.go +++ b/x/mint/types/mint.pb.go @@ -5,9 +5,10 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/gogo/protobuf/proto" + proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" @@ -141,30 +142,31 @@ func init() { func init() { proto.RegisterFile("mint/v1beta1/mint.proto", fileDescriptor_06339c129491fd39) } var fileDescriptor_06339c129491fd39 = []byte{ - // 355 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x3f, 0x4b, 0xc3, 0x40, - 0x18, 0xc6, 0x93, 0x5a, 0x0a, 0x3d, 0x5a, 0xd4, 0xa0, 0xb4, 0x08, 0xa6, 0xd2, 0xa1, 0xb8, 0x98, - 0x50, 0x74, 0x12, 0xa7, 0x52, 0x04, 0x41, 0xa1, 0xa4, 0x93, 0x3a, 0x84, 0x4b, 0x72, 0x8d, 0xa1, - 0xc9, 0xbd, 0xc7, 0xdd, 0xa5, 0xd8, 0x6f, 0xe0, 0xe8, 0xe8, 0xe8, 0x17, 0x71, 0xef, 0xd8, 0x51, - 0x1c, 0x8a, 0xb4, 0x5f, 0x44, 0x72, 0x57, 0xff, 0xac, 0x76, 0xb9, 0x7b, 0xef, 0x79, 0x8f, 0x1f, - 0xef, 0xf3, 0xf2, 0xa0, 0x46, 0x96, 0x50, 0xe9, 0x4e, 0xba, 0x01, 0x91, 0xb8, 0xeb, 0x16, 0x0f, - 0x87, 0x71, 0x90, 0x60, 0xd5, 0x54, 0xbd, 0x6e, 0x1c, 0xec, 0xc5, 0x10, 0x83, 0x6a, 0xb8, 0x45, - 0xa5, 0xff, 0xb4, 0x9f, 0x4a, 0xa8, 0x72, 0x93, 0x50, 0x49, 0xb8, 0x75, 0x8d, 0xaa, 0x09, 0x1d, - 0xa5, 0x58, 0x26, 0x40, 0x9b, 0xe6, 0x91, 0x79, 0x5c, 0xed, 0x39, 0xb3, 0x45, 0xcb, 0xf8, 0x58, - 0xb4, 0x3a, 0x71, 0x22, 0x1f, 0xf2, 0xc0, 0x09, 0x21, 0x73, 0x43, 0x10, 0x19, 0x88, 0xf5, 0x75, - 0x22, 0xa2, 0xb1, 0x2b, 0xa7, 0x8c, 0x08, 0xa7, 0x4f, 0x42, 0xef, 0x17, 0x60, 0xdd, 0xa3, 0x5d, - 0x4c, 0x69, 0x8e, 0x53, 0x9f, 0x71, 0x98, 0x24, 0x22, 0x01, 0x2a, 0x9a, 0xa5, 0x8d, 0xa8, 0x3b, - 0x1a, 0x34, 0xf8, 0xe1, 0x58, 0x43, 0x54, 0x97, 0x98, 0xc7, 0x44, 0xfa, 0x22, 0x67, 0x2c, 0x9d, - 0x36, 0xb7, 0xfe, 0x0d, 0xbe, 0xa2, 0xd2, 0xab, 0x69, 0xc8, 0x50, 0x31, 0xda, 0x6f, 0x26, 0xaa, - 0x0c, 0x30, 0xc7, 0x99, 0xb0, 0x0e, 0x11, 0x2a, 0x76, 0xe7, 0x47, 0x84, 0x42, 0xa6, 0x77, 0xe1, - 0x55, 0x0b, 0xa5, 0x5f, 0x08, 0xd6, 0x08, 0x35, 0xd6, 0xde, 0x38, 0x89, 0xf2, 0xb0, 0xf0, 0xeb, - 0x8f, 0x70, 0x28, 0x81, 0x6f, 0xe8, 0x70, 0x5f, 0xe3, 0xbc, 0x6f, 0xda, 0xa5, 0x82, 0x59, 0x1d, - 0xb4, 0x1d, 0xa4, 0x10, 0x8e, 0x85, 0xcf, 0x08, 0xf7, 0xa7, 0x04, 0x73, 0x65, 0xb4, 0xec, 0xd5, - 0xb5, 0x3c, 0x20, 0xfc, 0x96, 0x60, 0x7e, 0x5e, 0x7e, 0x79, 0x6d, 0x19, 0xbd, 0x8b, 0xd9, 0xd2, - 0x36, 0xe7, 0x4b, 0xdb, 0xfc, 0x5c, 0xda, 0xe6, 0xf3, 0xca, 0x36, 0xe6, 0x2b, 0xdb, 0x78, 0x5f, - 0xd9, 0xc6, 0x5d, 0xfb, 0xcf, 0x18, 0x30, 0x66, 0x67, 0xea, 0x88, 0xdc, 0x47, 0x15, 0x16, 0x3d, - 0x46, 0x50, 0x51, 0x79, 0x38, 0xfd, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x8c, 0x9b, 0xc1, 0x61, 0x4e, - 0x02, 0x00, 0x00, + // 379 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0xcf, 0x6a, 0xea, 0x40, + 0x14, 0xc6, 0x13, 0xaf, 0x08, 0x0e, 0xca, 0xbd, 0x37, 0xdc, 0x8b, 0x56, 0x68, 0x2c, 0x2e, 0xa4, + 0x1b, 0x13, 0xa4, 0x5d, 0x15, 0x57, 0x22, 0x85, 0x2e, 0x0a, 0x12, 0x57, 0x75, 0x13, 0x26, 0xc9, + 0x98, 0x0e, 0x26, 0x33, 0x61, 0x66, 0x22, 0xf5, 0x2d, 0xba, 0xec, 0xb2, 0x8b, 0x3e, 0x42, 0x1f, + 0x42, 0xe8, 0x46, 0xba, 0x2a, 0x5d, 0x48, 0xd1, 0x17, 0x29, 0x33, 0x93, 0xfe, 0xd9, 0x16, 0xdc, + 0x24, 0xe7, 0x9c, 0x2f, 0xf9, 0x9d, 0xf3, 0x1d, 0x0e, 0x68, 0xa4, 0x98, 0x08, 0x77, 0xd1, 0x0f, + 0x90, 0x80, 0x7d, 0x57, 0x26, 0x4e, 0xc6, 0xa8, 0xa0, 0x56, 0x4d, 0xc5, 0x85, 0xd0, 0xfa, 0x17, + 0xd3, 0x98, 0x2a, 0xc1, 0x95, 0x91, 0xfe, 0xa6, 0x75, 0x10, 0x52, 0x9e, 0x52, 0xee, 0x6b, 0x41, + 0x27, 0x5a, 0xea, 0x3c, 0x94, 0x40, 0xe5, 0x12, 0x13, 0x81, 0x98, 0x35, 0x05, 0x55, 0x4c, 0x66, + 0x09, 0x14, 0x98, 0x92, 0xa6, 0x79, 0x64, 0x1e, 0x57, 0x87, 0x83, 0xd5, 0xa6, 0x6d, 0xbc, 0x6e, + 0xda, 0xdd, 0x18, 0x8b, 0xeb, 0x3c, 0x70, 0x42, 0x9a, 0x16, 0xbf, 0x17, 0xaf, 0x1e, 0x8f, 0xe6, + 0xae, 0x58, 0x66, 0x88, 0x3b, 0x23, 0x14, 0x3e, 0x3f, 0xf6, 0x40, 0x41, 0x1f, 0xa1, 0xd0, 0xfb, + 0xc2, 0x59, 0x18, 0xfc, 0x85, 0x84, 0xe4, 0x30, 0x91, 0x33, 0x2c, 0x30, 0xc7, 0x94, 0xf0, 0x66, + 0x69, 0x0f, 0x3d, 0xfe, 0x68, 0xec, 0xf8, 0x93, 0x6a, 0x4d, 0x40, 0x5d, 0x40, 0x16, 0x23, 0xe1, + 0xf3, 0x3c, 0xcb, 0x92, 0x65, 0xf3, 0x97, 0x6a, 0xe3, 0xfc, 0xa0, 0xcd, 0x05, 0x11, 0x5e, 0x4d, + 0x43, 0x26, 0x8a, 0xd1, 0x79, 0x32, 0x41, 0x65, 0x0c, 0x19, 0x4c, 0xb9, 0x75, 0x08, 0x80, 0x5c, + 0xb9, 0x1f, 0x21, 0x42, 0x53, 0xbd, 0x27, 0xaf, 0x2a, 0x2b, 0x23, 0x59, 0xb0, 0x04, 0x68, 0x14, + 0x4e, 0x19, 0x8a, 0xf2, 0x50, 0xba, 0xf7, 0x67, 0x30, 0x14, 0x94, 0xed, 0xc5, 0xef, 0x7f, 0x0d, + 0xf7, 0x3e, 0xd8, 0xe7, 0x0a, 0x6d, 0x75, 0xc1, 0xef, 0x20, 0xa1, 0xe1, 0x9c, 0xfb, 0x19, 0x62, + 0xfe, 0x12, 0x41, 0xa6, 0x6c, 0x97, 0xbd, 0xba, 0x2e, 0x8f, 0x11, 0xbb, 0x42, 0x90, 0x9d, 0x95, + 0xef, 0xee, 0xdb, 0xc6, 0x70, 0xb0, 0xda, 0xda, 0xe6, 0x7a, 0x6b, 0x9b, 0x6f, 0x5b, 0xdb, 0xbc, + 0xdd, 0xd9, 0xc6, 0x7a, 0x67, 0x1b, 0x2f, 0x3b, 0xdb, 0x98, 0x76, 0xbe, 0x0d, 0x45, 0xe7, 0xd9, + 0xa9, 0x7a, 0x44, 0xee, 0x8d, 0xba, 0x38, 0x3d, 0x54, 0x50, 0x51, 0x97, 0x73, 0xf2, 0x1e, 0x00, + 0x00, 0xff, 0xff, 0x14, 0x5f, 0x26, 0x39, 0x93, 0x02, 0x00, 0x00, } func (m *Minter) Marshal() (dAtA []byte, err error) { diff --git a/x/mint/types/query.pb.go b/x/mint/types/query.pb.go index a3f4b27a..8a73442e 100644 --- a/x/mint/types/query.pb.go +++ b/x/mint/types/query.pb.go @@ -6,10 +6,11 @@ package types import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/gogo/protobuf/grpc" - proto "github.com/gogo/protobuf/proto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -280,35 +281,36 @@ func init() { func init() { proto.RegisterFile("mint/v1beta1/query.proto", fileDescriptor_b0718dda172d2cb4) } var fileDescriptor_b0718dda172d2cb4 = []byte{ - // 445 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc8, 0xcd, 0xcc, 0x2b, - 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, - 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x01, 0xc9, 0xe8, 0x41, 0x65, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, - 0xf3, 0xc1, 0x12, 0xfa, 0x20, 0x16, 0x44, 0x8d, 0x94, 0x4c, 0x7a, 0x7e, 0x7e, 0x7a, 0x4e, 0xaa, - 0x7e, 0x62, 0x41, 0xa6, 0x7e, 0x62, 0x5e, 0x5e, 0x7e, 0x49, 0x62, 0x49, 0x66, 0x7e, 0x5e, 0x31, - 0x54, 0x56, 0x1c, 0xc5, 0x6c, 0xb0, 0x71, 0x60, 0x09, 0x25, 0x11, 0x2e, 0xa1, 0x40, 0x90, 0x4d, - 0x01, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x4a, 0x9e, 0x5c, - 0xc2, 0x28, 0xa2, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x42, 0x46, 0x5c, 0x6c, 0x05, 0x60, 0x11, - 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x11, 0x3d, 0x64, 0x87, 0xe9, 0x41, 0x54, 0x3b, 0xb1, - 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x04, 0x55, 0xa9, 0x24, 0xce, 0x25, 0x0a, 0x36, 0xca, 0x33, 0x2f, - 0x2d, 0x07, 0xec, 0x24, 0x98, 0x1d, 0x69, 0x5c, 0x62, 0xe8, 0x12, 0x50, 0x6b, 0x7c, 0xb8, 0x38, - 0x33, 0x61, 0x82, 0x60, 0x9b, 0x78, 0x9c, 0xf4, 0x40, 0x66, 0xde, 0xba, 0x27, 0xaf, 0x96, 0x9e, - 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x9c, 0x5f, 0x9c, 0x9b, 0x5f, 0x0c, - 0xa5, 0x74, 0x8b, 0x53, 0xb2, 0xf5, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0xf5, 0x5c, 0x52, 0x93, 0x83, - 0x10, 0x06, 0x28, 0xc9, 0x71, 0xc9, 0x80, 0xed, 0x71, 0xcc, 0xcb, 0x2b, 0x4d, 0xcc, 0x09, 0x28, - 0xca, 0x2f, 0xcb, 0x2c, 0x06, 0x85, 0x0c, 0xcc, 0x1d, 0x35, 0x5c, 0xb2, 0x38, 0xe4, 0xa1, 0xce, - 0x89, 0xe6, 0x12, 0x4c, 0x04, 0xcb, 0xc5, 0x17, 0xc0, 0x25, 0xc9, 0x74, 0x96, 0x40, 0x22, 0x9a, - 0x25, 0x46, 0x33, 0x99, 0xb9, 0x58, 0xc1, 0xd6, 0x0b, 0x15, 0x71, 0xb1, 0x41, 0x02, 0x50, 0x48, - 0x01, 0x35, 0x58, 0x31, 0xe3, 0x47, 0x4a, 0x11, 0x8f, 0x0a, 0x88, 0xab, 0x95, 0x94, 0x9b, 0x2e, - 0x3f, 0x99, 0xcc, 0x24, 0x2b, 0x24, 0x0d, 0x73, 0x10, 0x4a, 0x0a, 0x80, 0x44, 0x8e, 0x50, 0x1d, - 0x17, 0x27, 0x3c, 0xf8, 0x85, 0x94, 0xb1, 0x18, 0x8a, 0x1e, 0x6b, 0x52, 0x2a, 0xf8, 0x15, 0x41, - 0x2d, 0x57, 0x03, 0x5b, 0xae, 0x20, 0x24, 0x87, 0xd5, 0x72, 0x78, 0xdc, 0x08, 0xcd, 0x66, 0xe4, - 0x12, 0x40, 0x0f, 0x77, 0x21, 0x2d, 0x2c, 0x56, 0xe0, 0x88, 0x3c, 0x29, 0x6d, 0xa2, 0xd4, 0x42, - 0x5d, 0xa5, 0x07, 0x76, 0x95, 0x86, 0x90, 0x1a, 0x56, 0x57, 0x61, 0xc4, 0xb1, 0x93, 0xcd, 0x89, - 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, - 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x29, 0x21, 0xc5, 0x77, 0x7e, 0x76, 0x81, - 0x09, 0x98, 0x48, 0xd1, 0xaf, 0x80, 0x98, 0x08, 0x8e, 0xef, 0x24, 0x36, 0x70, 0x06, 0x33, 0x06, - 0x04, 0x00, 0x00, 0xff, 0xff, 0x6e, 0x80, 0xd0, 0xa0, 0xd7, 0x03, 0x00, 0x00, + // 452 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x4d, 0x8f, 0xd2, 0x40, + 0x00, 0x6d, 0xfd, 0x20, 0xd9, 0x71, 0x0f, 0xeb, 0x88, 0xee, 0x5a, 0x77, 0x67, 0xb1, 0x6b, 0xc8, + 0x46, 0xe3, 0x34, 0x8b, 0x1e, 0xbd, 0x48, 0xbc, 0x6c, 0xe2, 0x01, 0x39, 0xea, 0xc1, 0x0c, 0x30, + 0xd4, 0x06, 0x3a, 0x53, 0x3a, 0x53, 0x22, 0x89, 0xf1, 0xe0, 0x2f, 0x30, 0xf1, 0x64, 0xfc, 0x43, + 0x1c, 0x49, 0xbc, 0x18, 0x0f, 0xc4, 0x80, 0x3f, 0xc4, 0x74, 0x66, 0x8a, 0xb4, 0x14, 0x62, 0xbc, + 0x40, 0x3b, 0xef, 0xe5, 0xbd, 0xd7, 0xf7, 0x5a, 0x70, 0x14, 0x06, 0x4c, 0x7a, 0xe3, 0x8b, 0x0e, + 0x95, 0xe4, 0xc2, 0x1b, 0x25, 0x34, 0x9e, 0xe0, 0x28, 0xe6, 0x92, 0xc3, 0xfd, 0x14, 0xc1, 0x06, + 0x71, 0xaa, 0x3e, 0xf7, 0xb9, 0x02, 0xbc, 0xf4, 0x4a, 0x73, 0x9c, 0x63, 0x9f, 0x73, 0x7f, 0x48, + 0x3d, 0x12, 0x05, 0x1e, 0x61, 0x8c, 0x4b, 0x22, 0x03, 0xce, 0x84, 0x41, 0x0f, 0x73, 0xda, 0x4a, + 0x4e, 0x03, 0x77, 0xbb, 0x5c, 0x84, 0x5c, 0xbc, 0xd5, 0x7a, 0xfa, 0x46, 0x43, 0x6e, 0x15, 0xc0, + 0x57, 0x69, 0x88, 0x16, 0x89, 0x49, 0x28, 0xda, 0x74, 0x94, 0x50, 0x21, 0xdd, 0x4b, 0x70, 0x2b, + 0x77, 0x2a, 0x22, 0xce, 0x04, 0x85, 0x0d, 0x50, 0x89, 0xd4, 0xc9, 0x91, 0x5d, 0xb3, 0xcf, 0x6f, + 0x34, 0xaa, 0x78, 0x3d, 0x33, 0xd6, 0xec, 0xe6, 0xb5, 0xe9, 0xfc, 0xd4, 0x6a, 0x1b, 0xa6, 0x7b, + 0x08, 0x6e, 0x2b, 0xa9, 0x4b, 0xd6, 0x1f, 0xaa, 0xb4, 0x99, 0x47, 0x1f, 0xdc, 0x29, 0x02, 0xc6, + 0xe6, 0x25, 0xd8, 0x0b, 0xb2, 0x43, 0xe5, 0xb4, 0xdf, 0xc4, 0xa9, 0xe6, 0xcf, 0xf9, 0x69, 0xdd, + 0x0f, 0xe4, 0xbb, 0xa4, 0x83, 0xbb, 0x3c, 0x34, 0xcf, 0x61, 0xfe, 0x1e, 0x8b, 0xde, 0xc0, 0x93, + 0x93, 0x88, 0x0a, 0xfc, 0x82, 0x76, 0xdb, 0x7f, 0x05, 0x5c, 0x04, 0x8e, 0x95, 0xcf, 0x73, 0xc6, + 0x12, 0x32, 0x6c, 0xc5, 0x7c, 0x1c, 0x88, 0xb4, 0xb4, 0x2c, 0xc7, 0x07, 0x70, 0xb2, 0x05, 0x37, + 0x71, 0xde, 0x80, 0x9b, 0x44, 0x61, 0x69, 0x7f, 0x06, 0xfc, 0xcf, 0x58, 0x07, 0xa4, 0x60, 0xd2, + 0xf8, 0x7a, 0x15, 0x5c, 0x57, 0xf6, 0x30, 0x06, 0x15, 0x5d, 0x20, 0xac, 0xe5, 0x6b, 0xdd, 0xdc, + 0xc7, 0xb9, 0xbf, 0x83, 0xa1, 0x53, 0xbb, 0x67, 0x9f, 0xbe, 0xff, 0xfe, 0x72, 0xe5, 0x04, 0xde, + 0xcb, 0x02, 0xe5, 0x5e, 0x0e, 0x3d, 0x0e, 0xfc, 0x08, 0xf6, 0x56, 0xf5, 0xc3, 0xb3, 0x12, 0xd1, + 0xe2, 0x6a, 0xce, 0x83, 0xdd, 0x24, 0x63, 0x5e, 0x57, 0xe6, 0x35, 0x88, 0x4a, 0xcd, 0x57, 0xdb, + 0xc0, 0x6f, 0x36, 0x38, 0x28, 0xf6, 0x0e, 0x1f, 0x96, 0x58, 0x6c, 0x19, 0xcf, 0x79, 0xf4, 0x4f, + 0x5c, 0x93, 0x0a, 0xab, 0x54, 0xe7, 0xb0, 0x5e, 0x9a, 0x6a, 0x63, 0xe3, 0xe6, 0xb3, 0xe9, 0x02, + 0xd9, 0xb3, 0x05, 0xb2, 0x7f, 0x2d, 0x90, 0xfd, 0x79, 0x89, 0xac, 0xd9, 0x12, 0x59, 0x3f, 0x96, + 0xc8, 0x7a, 0xed, 0xae, 0xed, 0xcd, 0x07, 0xd1, 0x53, 0xf5, 0xd3, 0xf3, 0xde, 0x6b, 0x45, 0xb5, + 0x77, 0xa7, 0xa2, 0x3e, 0xb0, 0x27, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x45, 0x63, 0x25, + 0xf2, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/mint/types/tx.pb.go b/x/mint/types/tx.pb.go index 6f6ea75f..cb479657 100644 --- a/x/mint/types/tx.pb.go +++ b/x/mint/types/tx.pb.go @@ -8,9 +8,10 @@ import ( fmt "fmt" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/gogo/protobuf/grpc" - proto "github.com/gogo/protobuf/proto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -30,11 +31,14 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgUpdateParams defines a Msg for updating the x/mint module parameters. +// MsgUpdateParams is the Msg/UpdateParams request type. +// +// Since: cosmos-sdk 0.47 type MsgUpdateParams struct { - // authority is the address of the governance account. + // authority is the address that controls the module (defaults to x/gov unless overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` // params defines the x/mint parameters to update. + // // NOTE: All parameters must be supplied. Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` } @@ -88,6 +92,8 @@ func (m *MsgUpdateParams) GetParams() Params { // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. +// +// Since: cosmos-sdk 0.47 type MsgUpdateParamsResponse struct { } @@ -132,27 +138,29 @@ func init() { func init() { proto.RegisterFile("mint/v1beta1/tx.proto", fileDescriptor_79e41a47c726ee2e) } var fileDescriptor_79e41a47c726ee2e = []byte{ - // 313 bytes of a gzipped FileDescriptorProto + // 343 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcd, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x01, 0x09, 0xeb, 0x41, 0x85, 0xa5, 0xc4, 0x93, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, - 0xf5, 0x73, 0x8b, 0xd3, 0xf5, 0xcb, 0x0c, 0x41, 0x14, 0x44, 0x99, 0x94, 0x24, 0x44, 0x22, 0x1e, - 0xcc, 0xd3, 0x87, 0x70, 0xa0, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x10, 0x71, 0x10, 0x0b, 0x2a, - 0x2a, 0x8e, 0x62, 0x1d, 0xd8, 0x12, 0xb0, 0x84, 0x52, 0x2f, 0x23, 0x17, 0xbf, 0x6f, 0x71, 0x7a, - 0x68, 0x41, 0x4a, 0x62, 0x49, 0x6a, 0x40, 0x62, 0x51, 0x62, 0x6e, 0xb1, 0x90, 0x19, 0x17, 0x67, - 0x62, 0x69, 0x49, 0x46, 0x7e, 0x51, 0x66, 0x49, 0xa5, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xa7, 0x93, - 0xc4, 0xa5, 0x2d, 0xba, 0x22, 0x50, 0x7b, 0x1c, 0x53, 0x52, 0x8a, 0x52, 0x8b, 0x8b, 0x83, 0x4b, - 0x8a, 0x32, 0xf3, 0xd2, 0x83, 0x10, 0x4a, 0x85, 0x8c, 0xb8, 0xd8, 0x0a, 0xc0, 0x26, 0x48, 0x30, - 0x29, 0x30, 0x6a, 0x70, 0x1b, 0x89, 0xe8, 0x21, 0xfb, 0x46, 0x0f, 0x62, 0xba, 0x13, 0xcb, 0x89, - 0x7b, 0xf2, 0x0c, 0x41, 0x50, 0x95, 0x56, 0x7c, 0x4d, 0xcf, 0x37, 0x68, 0x21, 0xcc, 0x50, 0x92, - 0xe4, 0x12, 0x47, 0x73, 0x4e, 0x50, 0x6a, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0x51, 0x12, 0x17, - 0x97, 0x6f, 0x71, 0x7a, 0x70, 0x6a, 0x51, 0x59, 0x66, 0x72, 0xaa, 0x50, 0x08, 0x17, 0x0f, 0x8a, - 0xa3, 0x65, 0x51, 0x2d, 0x43, 0x33, 0x44, 0x4a, 0x15, 0xaf, 0x34, 0xcc, 0x0e, 0x27, 0x9b, 0x13, - 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, - 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x52, 0x4a, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, - 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xcf, 0xcf, 0x2e, 0x30, 0x01, 0x13, 0x29, 0xfa, 0x15, 0xe0, 0xc0, - 0xd4, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x87, 0xa9, 0x31, 0x20, 0x00, 0x00, 0xff, - 0xff, 0xeb, 0xc8, 0x3b, 0x7f, 0xdd, 0x01, 0x00, 0x00, + 0xf5, 0x73, 0x8b, 0xd3, 0xf5, 0xcb, 0x0c, 0x41, 0x14, 0x44, 0x99, 0x94, 0x60, 0x62, 0x6e, 0x66, + 0x5e, 0xbe, 0x3e, 0x98, 0x84, 0x0a, 0x49, 0x42, 0xd4, 0xc6, 0x83, 0x79, 0xfa, 0x10, 0x0e, 0x54, + 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0x22, 0x0e, 0x62, 0x41, 0x45, 0xc5, 0x51, 0x5c, 0x00, 0xb6, + 0x17, 0x2c, 0xa1, 0xb4, 0x83, 0x91, 0x8b, 0xdf, 0xb7, 0x38, 0x3d, 0xb4, 0x20, 0x25, 0xb1, 0x24, + 0x35, 0x20, 0xb1, 0x28, 0x31, 0xb7, 0x58, 0xc8, 0x8c, 0x8b, 0x33, 0xb1, 0xb4, 0x24, 0x23, 0xbf, + 0x28, 0xb3, 0xa4, 0x52, 0x82, 0x51, 0x81, 0x51, 0x83, 0xd3, 0x49, 0xe2, 0xd2, 0x16, 0x5d, 0x11, + 0xa8, 0x3d, 0x8e, 0x29, 0x29, 0x45, 0xa9, 0xc5, 0xc5, 0xc1, 0x25, 0x45, 0x99, 0x79, 0xe9, 0x41, + 0x08, 0xa5, 0x42, 0xe6, 0x5c, 0x6c, 0x05, 0x60, 0x13, 0x24, 0x98, 0x14, 0x18, 0x35, 0xb8, 0x8d, + 0x44, 0xf4, 0x90, 0x3d, 0xa8, 0x07, 0x31, 0xdd, 0x89, 0xf3, 0xc4, 0x3d, 0x79, 0x86, 0x15, 0xcf, + 0x37, 0x68, 0x31, 0x06, 0x41, 0x95, 0x5b, 0x99, 0x34, 0x3d, 0xdf, 0xa0, 0x85, 0x30, 0xa8, 0xeb, + 0xf9, 0x06, 0x2d, 0x45, 0x88, 0x65, 0xba, 0xc5, 0x29, 0xd9, 0xfa, 0x15, 0x60, 0x07, 0xeb, 0xa3, + 0x39, 0x53, 0x49, 0x92, 0x4b, 0x1c, 0x4d, 0x28, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0xd5, + 0x28, 0x89, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0x28, 0x84, 0x8b, 0x07, 0xc5, 0x63, 0xb2, 0xa8, 0x0e, + 0x42, 0xd3, 0x2d, 0xa5, 0x8a, 0x57, 0x1a, 0x66, 0xb8, 0x14, 0x6b, 0x03, 0xc8, 0xf1, 0x4e, 0x36, + 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, + 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x94, 0x9e, 0x59, 0x92, 0x51, + 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x9f, 0x5d, 0x60, 0x02, 0x26, 0x52, 0x60, 0xde, 0x28, + 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x07, 0xbf, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x03, + 0x48, 0xf5, 0xfc, 0x1b, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -163,76 +171,80 @@ var _ grpc.ClientConn // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 -// MsgServiceClient is the client API for MsgService service. +// MsgClient is the client API for Msg service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MsgServiceClient interface { - // UpdateParams defined a governance operation for updating the x/mint module parameters. - // The authority is hard-coded to the Cosmos SDK x/gov module account +type MsgClient interface { + // UpdateParams defines a governance operation for updating the x/mint module + // parameters. The authority is defaults to the x/gov module account. + // + // Since: cosmos-sdk 0.47 UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) } -type msgServiceClient struct { +type msgClient struct { cc grpc1.ClientConn } -func NewMsgServiceClient(cc grpc1.ClientConn) MsgServiceClient { - return &msgServiceClient{cc} +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} } -func (c *msgServiceClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, "/mint.v1beta1.MsgService/UpdateParams", in, out, opts...) + err := c.cc.Invoke(ctx, "/mint.v1beta1.Msg/UpdateParams", in, out, opts...) if err != nil { return nil, err } return out, nil } -// MsgServiceServer is the server API for MsgService service. -type MsgServiceServer interface { - // UpdateParams defined a governance operation for updating the x/mint module parameters. - // The authority is hard-coded to the Cosmos SDK x/gov module account +// MsgServer is the server API for Msg service. +type MsgServer interface { + // UpdateParams defines a governance operation for updating the x/mint module + // parameters. The authority is defaults to the x/gov module account. + // + // Since: cosmos-sdk 0.47 UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) } -// UnimplementedMsgServiceServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServiceServer struct { +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServiceServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } -func RegisterMsgServiceServer(s grpc1.Server, srv MsgServiceServer) { - s.RegisterService(&_MsgService_serviceDesc, srv) +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) } -func _MsgService_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgUpdateParams) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServiceServer).UpdateParams(ctx, in) + return srv.(MsgServer).UpdateParams(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/mint.v1beta1.MsgService/UpdateParams", + FullMethod: "/mint.v1beta1.Msg/UpdateParams", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServiceServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) } return interceptor(ctx, in, info, handler) } -var _MsgService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "mint.v1beta1.MsgService", - HandlerType: (*MsgServiceServer)(nil), +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "mint.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "UpdateParams", - Handler: _MsgService_UpdateParams_Handler, + Handler: _Msg_UpdateParams_Handler, }, }, Streams: []grpc.StreamDesc{},