From c35a5426944e37e7be91ffa2983dba4cc7688814 Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Wed, 2 Oct 2024 20:19:28 -0700 Subject: [PATCH 01/14] feat(mint): port mint module from cosmos sdk v0.50.7 --- client/app/app.go | 1 - client/app/app_config.go | 2 +- client/x/mint/README.md | 383 ++++++ client/x/mint/keeper/abci.go | 75 + client/x/mint/keeper/genesis.go | 35 + client/x/mint/keeper/genesis_test.go | 91 ++ client/x/mint/keeper/grpc_query.go | 47 + client/x/mint/keeper/grpc_query_test.go | 89 ++ client/x/mint/keeper/keeper.go | 110 ++ client/x/mint/keeper/keeper_test.go | 97 ++ client/x/mint/keeper/msg_server.go | 42 + client/x/mint/keeper/msg_server_test.go | 74 + client/x/mint/module/depinject.go | 80 ++ client/x/mint/module/module.go | 141 ++ client/x/mint/module/module.proto | 19 + client/x/mint/module/module.pulsar.go | 651 +++++++++ .../x/mint/testutil/expected_keepers_mocks.go | 195 +++ client/x/mint/types/codec.go | 25 + client/x/mint/types/events.go | 10 + client/x/mint/types/expected_keepers.go | 32 + client/x/mint/types/genesis.go | 45 + client/x/mint/types/genesis.pb.go | 378 ++++++ client/x/mint/types/genesis.proto | 17 + client/x/mint/types/keys.go | 17 + client/x/mint/types/mint.pb.go | 781 +++++++++++ client/x/mint/types/mint.proto | 62 + client/x/mint/types/minter.go | 83 ++ client/x/mint/types/minter_test.go | 140 ++ client/x/mint/types/params.go | 173 +++ client/x/mint/types/params_legacy.go | 39 + client/x/mint/types/query.pb.go | 1204 +++++++++++++++++ client/x/mint/types/query.pb.gw.go | 283 ++++ client/x/mint/types/query.proto | 68 + client/x/mint/types/tx.pb.go | 605 +++++++++ client/x/mint/types/tx.proto | 43 + go.mod | 4 +- 36 files changed, 6137 insertions(+), 4 deletions(-) create mode 100644 client/x/mint/README.md create mode 100644 client/x/mint/keeper/abci.go create mode 100644 client/x/mint/keeper/genesis.go create mode 100644 client/x/mint/keeper/genesis_test.go create mode 100644 client/x/mint/keeper/grpc_query.go create mode 100644 client/x/mint/keeper/grpc_query_test.go create mode 100644 client/x/mint/keeper/keeper.go create mode 100644 client/x/mint/keeper/keeper_test.go create mode 100644 client/x/mint/keeper/msg_server.go create mode 100644 client/x/mint/keeper/msg_server_test.go create mode 100644 client/x/mint/module/depinject.go create mode 100644 client/x/mint/module/module.go create mode 100644 client/x/mint/module/module.proto create mode 100644 client/x/mint/module/module.pulsar.go create mode 100644 client/x/mint/testutil/expected_keepers_mocks.go create mode 100644 client/x/mint/types/codec.go create mode 100644 client/x/mint/types/events.go create mode 100644 client/x/mint/types/expected_keepers.go create mode 100644 client/x/mint/types/genesis.go create mode 100644 client/x/mint/types/genesis.pb.go create mode 100644 client/x/mint/types/genesis.proto create mode 100644 client/x/mint/types/keys.go create mode 100644 client/x/mint/types/mint.pb.go create mode 100644 client/x/mint/types/mint.proto create mode 100644 client/x/mint/types/minter.go create mode 100644 client/x/mint/types/minter_test.go create mode 100644 client/x/mint/types/params.go create mode 100644 client/x/mint/types/params_legacy.go create mode 100644 client/x/mint/types/query.pb.go create mode 100644 client/x/mint/types/query.pb.gw.go create mode 100644 client/x/mint/types/query.proto create mode 100644 client/x/mint/types/tx.pb.go create mode 100644 client/x/mint/types/tx.proto diff --git a/client/app/app.go b/client/app/app.go index 094aafd6..18820584 100644 --- a/client/app/app.go +++ b/client/app/app.go @@ -36,7 +36,6 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/distribution" // import for side-effects _ "github.com/cosmos/cosmos-sdk/x/genutil" // import for side-effects _ "github.com/cosmos/cosmos-sdk/x/gov" // import for side-effects - _ "github.com/cosmos/cosmos-sdk/x/mint" // import for side-effects _ "github.com/cosmos/cosmos-sdk/x/slashing" // import for side-effects _ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects ) diff --git a/client/app/app_config.go b/client/app/app_config.go index faee4920..f4371670 100644 --- a/client/app/app_config.go +++ b/client/app/app_config.go @@ -26,7 +26,6 @@ import ( distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -36,6 +35,7 @@ import ( evmenginetypes "github.com/piplabs/story/client/x/evmengine/types" evmstakingmodule "github.com/piplabs/story/client/x/evmstaking/module" evmstakingtypes "github.com/piplabs/story/client/x/evmstaking/types" + minttypes "github.com/piplabs/story/client/x/mint/types" ) // Bech32HRP is the human-readable-part of the Bech32 address format. diff --git a/client/x/mint/README.md b/client/x/mint/README.md new file mode 100644 index 00000000..80198010 --- /dev/null +++ b/client/x/mint/README.md @@ -0,0 +1,383 @@ +--- +sidebar_position: 1 +--- + +# `x/mint` + +## Contents + +* [State](#state) + * [Minter](#minter) + * [Params](#params) +* [Begin-Block](#begin-block) + * [NextInflationRate](#nextinflationrate) + * [NextAnnualProvisions](#nextannualprovisions) + * [BlockProvision](#blockprovision) +* [Parameters](#parameters) +* [Events](#events) + * [BeginBlocker](#beginblocker) +* [Client](#client) + * [CLI](#cli) + * [gRPC](#grpc) + * [REST](#rest) + +## Concepts + +### The Minting Mechanism + +The minting mechanism was designed to: + +* allow for a flexible inflation rate determined by market demand targeting a particular bonded-stake ratio +* effect a balance between market liquidity and staked supply + +In order to best determine the appropriate market rate for inflation rewards, a +moving change rate is used. The moving change rate mechanism ensures that if +the % bonded is either over or under the goal %-bonded, the inflation rate will +adjust to further incentivize or disincentivize being bonded, respectively. Setting the goal +%-bonded at less than 100% encourages the network to maintain some non-staked tokens +which should help provide some liquidity. + +It can be broken down in the following way: + +* If the actual percentage of bonded tokens is below the goal %-bonded the inflation rate will + increase until a maximum value is reached +* If the goal % bonded (67% in Cosmos-Hub) is maintained, then the inflation + rate will stay constant +* If the actual percentage of bonded tokens is above the goal %-bonded the inflation rate will + decrease until a minimum value is reached + + +## State + +### Minter + +The minter is a space for holding current inflation information. + +* Minter: `0x00 -> ProtocolBuffer(minter)` + +```protobuf reference +https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/mint/v1beta1/mint.proto#L10-L24 +``` + +### Params + +The mint module stores its params in state with the prefix of `0x01`, +it can be updated with governance or the address with authority. + +* Params: `mint/params -> legacy_amino(params)` + +```protobuf reference +https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/mint/v1beta1/mint.proto#L26-L59 +``` + +## Begin-Block + +Minting parameters are recalculated and inflation paid at the beginning of each block. + +### Inflation rate calculation + +Inflation rate is calculated using an "inflation calculation function" that's +passed to the `NewAppModule` function. If no function is passed, then the SDK's +default inflation function will be used (`NextInflationRate`). In case a custom +inflation calculation logic is needed, this can be achieved by defining and +passing a function that matches `InflationCalculationFn`'s signature. + +```go +type InflationCalculationFn func(ctx sdk.Context, minter Minter, params Params, bondedRatio math.LegacyDec) math.LegacyDec +``` + +#### NextInflationRate + +The target annual inflation rate is recalculated each block. +The inflation is also subject to a rate change (positive or negative) +depending on the distance from the desired ratio (67%). The maximum rate change +possible is defined to be 13% per year, however, the annual inflation is capped +as between 7% and 20%. + +```go +NextInflationRate(params Params, bondedRatio math.LegacyDec) (inflation math.LegacyDec) { + inflationRateChangePerYear = (1 - bondedRatio/params.GoalBonded) * params.InflationRateChange + inflationRateChange = inflationRateChangePerYear/blocksPerYr + + // increase the new annual inflation for this next block + inflation += inflationRateChange + if inflation > params.InflationMax { + inflation = params.InflationMax + } + if inflation < params.InflationMin { + inflation = params.InflationMin + } + + return inflation +} +``` + +### NextAnnualProvisions + +Calculate the annual provisions based on current total supply and inflation +rate. This parameter is calculated once per block. + +```go +NextAnnualProvisions(params Params, totalSupply math.LegacyDec) (provisions math.LegacyDec) { + return Inflation * totalSupply +``` + +### BlockProvision + +Calculate the provisions generated for each block based on current annual provisions. The provisions are then minted by the `mint` module's `ModuleMinterAccount` and then transferred to the `auth`'s `FeeCollector` `ModuleAccount`. + +```go +BlockProvision(params Params) sdk.Coin { + provisionAmt = AnnualProvisions/ params.BlocksPerYear + return sdk.NewCoin(params.MintDenom, provisionAmt.Truncate()) +``` + + +## Parameters + +The minting module contains the following parameters: + +| Key | Type | Example | +|---------------------|-----------------|------------------------| +| MintDenom | string | "uatom" | +| InflationRateChange | string (dec) | "0.130000000000000000" | +| InflationMax | string (dec) | "0.200000000000000000" | +| InflationMin | string (dec) | "0.070000000000000000" | +| GoalBonded | string (dec) | "0.670000000000000000" | +| BlocksPerYear | string (uint64) | "6311520" | + + +## Events + +The minting module emits the following events: + +### BeginBlocker + +| Type | Attribute Key | Attribute Value | +|------|-------------------|--------------------| +| mint | bonded_ratio | {bondedRatio} | +| mint | inflation | {inflation} | +| mint | annual_provisions | {annualProvisions} | +| mint | amount | {amount} | + + +## Client + +### CLI + +A user can query and interact with the `mint` module using the CLI. + +#### Query + +The `query` commands allows users to query `mint` state. + +```shell +simd query mint --help +``` + +##### annual-provisions + +The `annual-provisions` command allows users to query the current minting annual provisions value + +```shell +simd query mint annual-provisions [flags] +``` + +Example: + +```shell +simd query mint annual-provisions +``` + +Example Output: + +```shell +22268504368893.612100895088410693 +``` + +##### inflation + +The `inflation` command allows users to query the current minting inflation value + +```shell +simd query mint inflation [flags] +``` + +Example: + +```shell +simd query mint inflation +``` + +Example Output: + +```shell +0.199200302563256955 +``` + +##### params + +The `params` command allows users to query the current minting parameters + +```shell +simd query mint params [flags] +``` + +Example: + +```yml +blocks_per_year: "4360000" +goal_bonded: "0.670000000000000000" +inflation_max: "0.200000000000000000" +inflation_min: "0.070000000000000000" +inflation_rate_change: "0.130000000000000000" +mint_denom: stake +``` + +### gRPC + +A user can query the `mint` module using gRPC endpoints. + +#### AnnualProvisions + +The `AnnualProvisions` endpoint allows users to query the current minting annual provisions value + +```shell +/cosmos.mint.v1beta1.Query/AnnualProvisions +``` + +Example: + +```shell +grpcurl -plaintext localhost:9090 cosmos.mint.v1beta1.Query/AnnualProvisions +``` + +Example Output: + +```json +{ + "annualProvisions": "1432452520532626265712995618" +} +``` + +#### Inflation + +The `Inflation` endpoint allows users to query the current minting inflation value + +```shell +/cosmos.mint.v1beta1.Query/Inflation +``` + +Example: + +```shell +grpcurl -plaintext localhost:9090 cosmos.mint.v1beta1.Query/Inflation +``` + +Example Output: + +```json +{ + "inflation": "130197115720711261" +} +``` + +#### Params + +The `Params` endpoint allows users to query the current minting parameters + +```shell +/cosmos.mint.v1beta1.Query/Params +``` + +Example: + +```shell +grpcurl -plaintext localhost:9090 cosmos.mint.v1beta1.Query/Params +``` + +Example Output: + +```json +{ + "params": { + "mintDenom": "stake", + "inflationRateChange": "130000000000000000", + "inflationMax": "200000000000000000", + "inflationMin": "70000000000000000", + "goalBonded": "670000000000000000", + "blocksPerYear": "6311520" + } +} +``` + +### REST + +A user can query the `mint` module using REST endpoints. + +#### annual-provisions + +```shell +/cosmos/mint/v1beta1/annual_provisions +``` + +Example: + +```shell +curl "localhost:1317/cosmos/mint/v1beta1/annual_provisions" +``` + +Example Output: + +```json +{ + "annualProvisions": "1432452520532626265712995618" +} +``` + +#### inflation + +```shell +/cosmos/mint/v1beta1/inflation +``` + +Example: + +```shell +curl "localhost:1317/cosmos/mint/v1beta1/inflation" +``` + +Example Output: + +```json +{ + "inflation": "130197115720711261" +} +``` + +#### params + +```shell +/cosmos/mint/v1beta1/params +``` + +Example: + +```shell +curl "localhost:1317/cosmos/mint/v1beta1/params" +``` + +Example Output: + +```json +{ + "params": { + "mintDenom": "stake", + "inflationRateChange": "130000000000000000", + "inflationMax": "200000000000000000", + "inflationMin": "70000000000000000", + "goalBonded": "670000000000000000", + "blocksPerYear": "6311520" + } +} +``` diff --git a/client/x/mint/keeper/abci.go b/client/x/mint/keeper/abci.go new file mode 100644 index 00000000..8707ea5f --- /dev/null +++ b/client/x/mint/keeper/abci.go @@ -0,0 +1,75 @@ +package keeper + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/piplabs/story/client/x/mint/types" +) + +// BeginBlocker mints new tokens for the previous block. +func (k Keeper) BeginBlocker(ctx context.Context, ic types.InflationCalculationFn) error { + defer telemetry.ModuleMeasureSince(types.ModuleName, telemetry.Now(), telemetry.MetricKeyBeginBlocker) + + // fetch stored minter & params + minter, err := k.Minter.Get(ctx) + if err != nil { + return err + } + + params, err := k.Params.Get(ctx) + if err != nil { + return err + } + + // recalculate inflation rate + totalStakingSupply, err := k.StakingTokenSupply(ctx) + if err != nil { + return err + } + + bondedRatio, err := k.BondedRatio(ctx) + if err != nil { + return err + } + + minter.Inflation = ic(ctx, minter, params, bondedRatio) + minter.AnnualProvisions = minter.NextAnnualProvisions(params, totalStakingSupply) + if err = k.Minter.Set(ctx, minter); err != nil { + return err + } + + // mint coins, update supply + mintedCoin := minter.BlockProvision(params) + mintedCoins := sdk.NewCoins(mintedCoin) + + err = k.MintCoins(ctx, mintedCoins) + if err != nil { + return err + } + + // send the minted coins to the fee collector account + err = k.AddCollectedFees(ctx, mintedCoins) + if err != nil { + return err + } + + if mintedCoin.Amount.IsInt64() { + defer telemetry.ModuleSetGauge(types.ModuleName, float32(mintedCoin.Amount.Int64()), "minted_tokens") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + sdkCtx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeMint, + sdk.NewAttribute(types.AttributeKeyBondedRatio, bondedRatio.String()), + sdk.NewAttribute(types.AttributeKeyInflation, minter.Inflation.String()), + sdk.NewAttribute(types.AttributeKeyAnnualProvisions, minter.AnnualProvisions.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, mintedCoin.Amount.String()), + ), + ) + + return nil +} diff --git a/client/x/mint/keeper/genesis.go b/client/x/mint/keeper/genesis.go new file mode 100644 index 00000000..e856230a --- /dev/null +++ b/client/x/mint/keeper/genesis.go @@ -0,0 +1,35 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/piplabs/story/client/x/mint/types" +) + +// InitGenesis new mint genesis. +func (k Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) { + if err := k.Minter.Set(ctx, data.Minter); err != nil { + panic(err) + } + + if err := k.Params.Set(ctx, data.Params); err != nil { + panic(err) + } + + ak.GetModuleAccount(ctx, types.ModuleName) +} + +// ExportGenesis returns a GenesisState for a given context and keeper. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + minter, err := k.Minter.Get(ctx) + if err != nil { + panic(err) + } + + params, err := k.Params.Get(ctx) + if err != nil { + panic(err) + } + + return types.NewGenesisState(minter, params) +} diff --git a/client/x/mint/keeper/genesis_test.go b/client/x/mint/keeper/genesis_test.go new file mode 100644 index 00000000..31238544 --- /dev/null +++ b/client/x/mint/keeper/genesis_test.go @@ -0,0 +1,91 @@ +//nolint:paralleltest // just for testing +package keeper_test + +import ( + "testing" + + "cosmossdk.io/collections" + "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/runtime" + "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/golang/mock/gomock" + "github.com/stretchr/testify/suite" + + "github.com/piplabs/story/client/x/mint/keeper" + mintmodule "github.com/piplabs/story/client/x/mint/module" + minttestutil "github.com/piplabs/story/client/x/mint/testutil" + "github.com/piplabs/story/client/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 := storetypes.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) + encCfg := moduletestutil.MakeTestEncodingConfig(mintmodule.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, runtime.NewKVStoreService(key), stakingKeeper, accountKeeper, bankKeeper, "", "") +} + +func (s *GenesisTestSuite) TestImportExportGenesis() { + genesisState := types.DefaultGenesisState() + genesisState.Minter = types.NewMinter(math.LegacyNewDecWithPrec(20, 2), math.LegacyNewDec(1)) + genesisState.Params = types.NewParams( + "testDenom", + math.LegacyNewDecWithPrec(15, 2), + math.LegacyNewDecWithPrec(22, 2), + math.LegacyNewDecWithPrec(9, 2), + math.LegacyNewDecWithPrec(69, 2), + uint64(60*60*8766/5), + ) + + s.keeper.InitGenesis(s.sdkCtx, s.accountKeeper, genesisState) + + minter, err := s.keeper.Minter.Get(s.sdkCtx) + s.Require().Equal(genesisState.Minter, minter) + s.Require().NoError(err) + + invalidCtx := testutil.DefaultContextWithDB(s.T(), s.key, storetypes.NewTransientStoreKey("transient_test")) + _, err = s.keeper.Minter.Get(invalidCtx.Ctx) + s.Require().ErrorIs(err, collections.ErrNotFound) + + params, err := s.keeper.Params.Get(s.sdkCtx) + s.Require().Equal(genesisState.Params, params) + s.Require().NoError(err) + + genesisState2 := s.keeper.ExportGenesis(s.sdkCtx) + s.Require().Equal(genesisState, genesisState2) +} diff --git a/client/x/mint/keeper/grpc_query.go b/client/x/mint/keeper/grpc_query.go new file mode 100644 index 00000000..9908ac65 --- /dev/null +++ b/client/x/mint/keeper/grpc_query.go @@ -0,0 +1,47 @@ +package keeper + +import ( + "context" + + "github.com/piplabs/story/client/x/mint/types" +) + +var _ types.QueryServer = queryServer{} + +func NewQueryServerImpl(k Keeper) types.QueryServer { + return queryServer{k} +} + +type queryServer struct { + k Keeper +} + +// Params returns params of the mint module. +func (q queryServer) Params(ctx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + params, err := q.k.Params.Get(ctx) + if err != nil { + return nil, err + } + + return &types.QueryParamsResponse{Params: params}, nil +} + +// Inflation returns minter.Inflation of the mint module. +func (q queryServer) Inflation(ctx context.Context, _ *types.QueryInflationRequest) (*types.QueryInflationResponse, error) { + minter, err := q.k.Minter.Get(ctx) + if err != nil { + return nil, err + } + + return &types.QueryInflationResponse{Inflation: minter.Inflation}, nil +} + +// AnnualProvisions returns minter.AnnualProvisions of the mint module. +func (q queryServer) AnnualProvisions(ctx context.Context, _ *types.QueryAnnualProvisionsRequest) (*types.QueryAnnualProvisionsResponse, error) { + minter, err := q.k.Minter.Get(ctx) + if err != nil { + return nil, err + } + + return &types.QueryAnnualProvisionsResponse{AnnualProvisions: minter.AnnualProvisions}, nil +} diff --git a/client/x/mint/keeper/grpc_query_test.go b/client/x/mint/keeper/grpc_query_test.go new file mode 100644 index 00000000..a2582f38 --- /dev/null +++ b/client/x/mint/keeper/grpc_query_test.go @@ -0,0 +1,89 @@ +//nolint:paralleltest // just for testing +package keeper_test + +import ( + gocontext "context" + "testing" + + storetypes "cosmossdk.io/store/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/runtime" + "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/golang/mock/gomock" + "github.com/stretchr/testify/suite" + + "github.com/piplabs/story/client/x/mint/keeper" + mintmodule "github.com/piplabs/story/client/x/mint/module" + minttestutil "github.com/piplabs/story/client/x/mint/testutil" + "github.com/piplabs/story/client/x/mint/types" +) + +type MintTestSuite struct { + suite.Suite + + ctx sdk.Context + queryClient types.QueryClient + mintKeeper keeper.Keeper +} + +func (suite *MintTestSuite) SetupTest() { + encCfg := moduletestutil.MakeTestEncodingConfig(mintmodule.AppModuleBasic{}) + key := storetypes.NewKVStoreKey(types.StoreKey) + storeService := runtime.NewKVStoreService(key) + testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.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, + storeService, + stakingKeeper, + accountKeeper, + bankKeeper, + authtypes.FeeCollectorName, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + err := suite.mintKeeper.Params.Set(suite.ctx, types.DefaultParams()) + suite.Require().NoError(err) + suite.Require().NoError(suite.mintKeeper.Minter.Set(suite.ctx, types.DefaultInitialMinter())) + + queryHelper := baseapp.NewQueryServerTestHelper(testCtx.Ctx, encCfg.InterfaceRegistry) + types.RegisterQueryServer(queryHelper, keeper.NewQueryServerImpl(suite.mintKeeper)) + + suite.queryClient = types.NewQueryClient(queryHelper) +} + +func (suite *MintTestSuite) TestGRPCParams() { + params, err := suite.queryClient.Params(gocontext.Background(), &types.QueryParamsRequest{}) + suite.Require().NoError(err) + kparams, err := suite.mintKeeper.Params.Get(suite.ctx) + suite.Require().NoError(err) + suite.Require().Equal(params.Params, kparams) + + inflation, err := suite.queryClient.Inflation(gocontext.Background(), &types.QueryInflationRequest{}) + suite.Require().NoError(err) + minter, err := suite.mintKeeper.Minter.Get(suite.ctx) + suite.Require().NoError(err) + suite.Require().Equal(inflation.Inflation, minter.Inflation) + + annualProvisions, err := suite.queryClient.AnnualProvisions(gocontext.Background(), &types.QueryAnnualProvisionsRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(annualProvisions.AnnualProvisions, minter.AnnualProvisions) +} + +func TestMintTestSuite(t *testing.T) { + suite.Run(t, new(MintTestSuite)) +} diff --git a/client/x/mint/keeper/keeper.go b/client/x/mint/keeper/keeper.go new file mode 100644 index 00000000..ef41c925 --- /dev/null +++ b/client/x/mint/keeper/keeper.go @@ -0,0 +1,110 @@ +//nolint:revive // just use interface{} +package keeper + +import ( + "context" + "fmt" + + "cosmossdk.io/collections" + storetypes "cosmossdk.io/core/store" + "cosmossdk.io/log" + "cosmossdk.io/math" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/piplabs/story/client/x/mint/types" +) + +// Keeper of the mint store. +type Keeper struct { + cdc codec.BinaryCodec + storeService storetypes.KVStoreService + stakingKeeper types.StakingKeeper + bankKeeper types.BankKeeper + feeCollectorName string + + // the address capable of executing a MsgUpdateParams message. Typically, this + // should be the x/gov module account. + authority string + + Schema collections.Schema + Params collections.Item[types.Params] + Minter collections.Item[types.Minter] +} + +// NewKeeper creates a new mint Keeper instance. +func NewKeeper( + cdc codec.BinaryCodec, + storeService storetypes.KVStoreService, + 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 { + panic(fmt.Sprintf("the x/%s module account has not been set", types.ModuleName)) + } + + sb := collections.NewSchemaBuilder(storeService) + k := Keeper{ + cdc: cdc, + storeService: storeService, + stakingKeeper: sk, + bankKeeper: bk, + feeCollectorName: feeCollectorName, + authority: authority, + Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), + Minter: collections.NewItem(sb, types.MinterKey, "minter", codec.CollValue[types.Minter](cdc)), + } + + schema, err := sb.Build() + if err != nil { + panic(err) + } + k.Schema = schema + + return k +} + +// GetAuthority returns the x/mint module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx context.Context) log.Logger { + sdkCtx := sdk.UnwrapSDKContext(ctx) + return sdkCtx.Logger().With("module", "x/"+types.ModuleName) +} + +// StakingTokenSupply implements an alias call to the underlying staking keeper's +// StakingTokenSupply to be used in BeginBlocker. +func (k Keeper) StakingTokenSupply(ctx context.Context) (math.Int, error) { + return k.stakingKeeper.StakingTokenSupply(ctx) +} + +// BondedRatio implements an alias call to the underlying staking keeper's +// BondedRatio to be used in BeginBlocker. +func (k Keeper) BondedRatio(ctx context.Context) (math.LegacyDec, error) { + return k.stakingKeeper.BondedRatio(ctx) +} + +// MintCoins implements an alias call to the underlying supply keeper's +// MintCoins to be used in BeginBlocker. +func (k Keeper) MintCoins(ctx context.Context, newCoins sdk.Coins) error { + if newCoins.Empty() { + // skip as no coins need to be minted + return nil + } + + return k.bankKeeper.MintCoins(ctx, types.ModuleName, newCoins) +} + +// AddCollectedFees implements an alias call to the underlying supply keeper's +// AddCollectedFees to be used in BeginBlocker. +func (k Keeper) AddCollectedFees(ctx context.Context, fees sdk.Coins) error { + return k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, k.feeCollectorName, fees) +} diff --git a/client/x/mint/keeper/keeper_test.go b/client/x/mint/keeper/keeper_test.go new file mode 100644 index 00000000..7d28732d --- /dev/null +++ b/client/x/mint/keeper/keeper_test.go @@ -0,0 +1,97 @@ +//nolint:paralleltest // just for testing +package keeper_test + +import ( + "testing" + + "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" + + "github.com/cosmos/cosmos-sdk/runtime" + "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/golang/mock/gomock" + "github.com/stretchr/testify/suite" + + "github.com/piplabs/story/client/x/mint/keeper" + mintmodule "github.com/piplabs/story/client/x/mint/module" + minttestutil "github.com/piplabs/story/client/x/mint/testutil" + "github.com/piplabs/story/client/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(mintmodule.AppModuleBasic{}) + key := storetypes.NewKVStoreKey(types.StoreKey) + storeService := runtime.NewKVStoreService(key) + testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.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, + storeService, + 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.Params.Set(s.ctx, types.DefaultParams()) + s.Require().NoError(err) + s.Require().NoError(s.mintKeeper.Minter.Set(s.ctx, types.DefaultInitialMinter())) + + s.msgServer = keeper.NewMsgServerImpl(s.mintKeeper) +} + +func (s *IntegrationTestSuite) TestAliasFunctions() { + stakingTokenSupply := math.NewIntFromUint64(100000000000) + s.stakingKeeper.EXPECT().StakingTokenSupply(s.ctx).Return(stakingTokenSupply, nil) + tokenSupply, err := s.mintKeeper.StakingTokenSupply(s.ctx) + s.Require().NoError(err) + s.Require().Equal(tokenSupply, stakingTokenSupply) + + bondedRatio := math.LegacyNewDecWithPrec(15, 2) + s.stakingKeeper.EXPECT().BondedRatio(s.ctx).Return(bondedRatio, nil) + ratio, err := s.mintKeeper.BondedRatio(s.ctx) + s.Require().NoError(err) + s.Require().Equal(ratio, bondedRatio) + + coins := sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1000000))) + s.bankKeeper.EXPECT().MintCoins(s.ctx, types.ModuleName, coins).Return(nil) + s.Require().NoError(s.mintKeeper.MintCoins(s.ctx, sdk.NewCoins())) + s.Require().NoError(s.mintKeeper.MintCoins(s.ctx, coins)) + + fees := sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1000))) + s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(s.ctx, types.ModuleName, authtypes.FeeCollectorName, fees).Return(nil) + s.Require().NoError(s.mintKeeper.AddCollectedFees(s.ctx, fees)) +} diff --git a/client/x/mint/keeper/msg_server.go b/client/x/mint/keeper/msg_server.go new file mode 100644 index 00000000..ab122e2e --- /dev/null +++ b/client/x/mint/keeper/msg_server.go @@ -0,0 +1,42 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/errors" + + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/piplabs/story/client/x/mint/types" +) + +var _ types.MsgServer = msgServer{} + +// msgServer is a wrapper of Keeper. +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the x/mint MsgServer interface. +func NewMsgServerImpl(k Keeper) types.MsgServer { + return &msgServer{ + Keeper: k, + } +} + +// UpdateParams updates the params. +func (ms msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if ms.authority != msg.Authority { + return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.authority, msg.Authority) + } + + if err := msg.Params.Validate(); err != nil { + return nil, err + } + + if err := ms.Params.Set(ctx, msg.Params); err != nil { + return nil, err + } + + return &types.MsgUpdateParamsResponse{}, nil +} diff --git a/client/x/mint/keeper/msg_server_test.go b/client/x/mint/keeper/msg_server_test.go new file mode 100644 index 00000000..dd97ec10 --- /dev/null +++ b/client/x/mint/keeper/msg_server_test.go @@ -0,0 +1,74 @@ +package keeper_test + +import ( + sdkmath "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/piplabs/story/client/x/mint/types" +) + +func (s *IntegrationTestSuite) TestUpdateParams() { + testCases := []struct { + name string + request *types.MsgUpdateParams + expectErr bool + }{ + { + name: "set invalid authority (not an address)", + request: &types.MsgUpdateParams{ + Authority: "foo", + }, + expectErr: true, + }, + { + name: "set invalid authority (not defined authority)", + request: &types.MsgUpdateParams{ + // pragma: allowlist secret + Authority: "cosmos139f7kncmglres2nf3h4hc4tade85ekfr8sulz5", // pragma: allowlist secret + }, + expectErr: true, + }, + { + name: "set invalid params", + request: &types.MsgUpdateParams{ + Authority: s.mintKeeper.GetAuthority(), + Params: types.Params{ + MintDenom: sdk.DefaultBondDenom, + InflationRateChange: sdkmath.LegacyNewDecWithPrec(-13, 2), + InflationMax: sdkmath.LegacyNewDecWithPrec(20, 2), + InflationMin: sdkmath.LegacyNewDecWithPrec(7, 2), + GoalBonded: sdkmath.LegacyNewDecWithPrec(67, 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, + InflationRateChange: sdkmath.LegacyNewDecWithPrec(8, 2), + InflationMax: sdkmath.LegacyNewDecWithPrec(20, 2), + InflationMin: sdkmath.LegacyNewDecWithPrec(2, 2), + GoalBonded: sdkmath.LegacyNewDecWithPrec(37, 2), + BlocksPerYear: uint64(60 * 60 * 8766 / 5), + }, + }, + expectErr: false, + }, + } + + for _, tc := range testCases { + 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/client/x/mint/module/depinject.go b/client/x/mint/module/depinject.go new file mode 100644 index 00000000..e4496fa3 --- /dev/null +++ b/client/x/mint/module/depinject.go @@ -0,0 +1,80 @@ +//nolint:revive // just use interface{} +package module + +import ( + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + + "github.com/cosmos/cosmos-sdk/codec" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/piplabs/story/client/x/mint/keeper" + "github.com/piplabs/story/client/x/mint/types" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +//nolint:gochecknoinits // depinject +func init() { + appmodule.Register( + &Module{}, + appmodule.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + ModuleKey depinject.OwnModuleKey + Config *Module + StoreService store.KVStoreService + Cdc codec.Codec + InflationCalculationFn types.InflationCalculationFn `optional:"true"` + + AccountKeeper types.AccountKeeper + BankKeeper types.BankKeeper + StakingKeeper types.StakingKeeper +} + +type ModuleOutputs struct { + depinject.Out + + MintKeeper keeper.Keeper + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + feeCollectorName := in.Config.GetFeeCollectorName() + if feeCollectorName == "" { + feeCollectorName = authtypes.FeeCollectorName + } + + // default to governance authority if not provided + authority := authtypes.NewModuleAddress(govtypes.ModuleName) + if in.Config.GetAuthority() != "" { + authority = authtypes.NewModuleAddressOrBech32Address(in.Config.GetAuthority()) + } + + k := keeper.NewKeeper( + in.Cdc, + in.StoreService, + in.StakingKeeper, + in.AccountKeeper, + in.BankKeeper, + feeCollectorName, + authority.String(), + ) + + // when no inflation calculation function is provided it will use the default types.DefaultInflationCalculationFn + m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.InflationCalculationFn) + + return ModuleOutputs{MintKeeper: k, Module: m} +} diff --git a/client/x/mint/module/module.go b/client/x/mint/module/module.go new file mode 100644 index 00000000..64cb8cf4 --- /dev/null +++ b/client/x/mint/module/module.go @@ -0,0 +1,141 @@ +//nolint:revive // keep method receiver untouched +package module + +import ( + "context" + "encoding/json" + "fmt" + + "cosmossdk.io/core/appmodule" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" + + "github.com/piplabs/story/client/x/mint/keeper" + "github.com/piplabs/story/client/x/mint/types" + "github.com/piplabs/story/lib/errors" +) + +// ConsensusVersion defines the current x/mint module consensus version. +const ConsensusVersion = 2 + +var ( + _ module.AppModuleBasic = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} +) + +// AppModuleBasic defines the basic application module used by the mint module. +type AppModuleBasic struct { + cdc codec.Codec +} + +// Name returns the mint module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types. +func (b AppModuleBasic) RegisterInterfaces(r cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(r) +} + +// DefaultGenesis returns default genesis state as raw bytes for the mint +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the mint module. +// + +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var data types.GenesisState + if err := cdc.UnmarshalJSON(bz, &data); err != nil { + return errors.Wrap(err, fmt.Sprintf("failed to unmarshal %s genesis state", types.ModuleName)) + } + + return types.ValidateGenesis(data) +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the mint module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +// AppModule implements an application module for the mint module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + authKeeper types.AccountKeeper + + // inflationCalculator is used to calculate the inflation rate during BeginBlock. + // If inflationCalculator is nil, the default inflation calculation logic is used. + inflationCalculator types.InflationCalculationFn +} + +// NewAppModule creates a new AppModule object. If the InflationCalculationFn +// argument is nil, then the SDK's default inflation function will be used. +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + ak types.AccountKeeper, + ic types.InflationCalculationFn, +) AppModule { + if ic == nil { + ic = types.DefaultInflationCalculationFn + } + + return AppModule{ + AppModuleBasic: AppModuleBasic{cdc: cdc}, + keeper: keeper, + authKeeper: ak, + inflationCalculator: ic, + } +} + +// RegisterServices registers a gRPC query service to respond to the +// module-specific gRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper)) +} + +// InitGenesis performs genesis initialization for the mint module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) { + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + + am.keeper.InitGenesis(ctx, am.authKeeper, &genesisState) +} + +// ExportGenesis returns the exported genesis state as raw bytes for the mint +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(gs) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } + +// BeginBlock returns the begin blocker for the mint module. +func (am AppModule) BeginBlock(ctx context.Context) error { + return am.keeper.BeginBlocker(ctx, am.inflationCalculator) +} diff --git a/client/x/mint/module/module.proto b/client/x/mint/module/module.proto new file mode 100644 index 00000000..a41c163b --- /dev/null +++ b/client/x/mint/module/module.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package client.x.mint.module; + +import "cosmos/app/v1alpha1/module.proto"; + +option go_package = "client/x/mint/module"; + +// Module is the config object of the mint module. +message Module { + option (cosmos.app.v1alpha1.module) = { + go_import: "github.com/piplabs/story/client/x/mint" + }; + + string fee_collector_name = 1; + + // authority defines the custom module authority. If not set, defaults to the governance module. + string authority = 2; +} \ No newline at end of file diff --git a/client/x/mint/module/module.pulsar.go b/client/x/mint/module/module.pulsar.go new file mode 100644 index 00000000..76566e81 --- /dev/null +++ b/client/x/mint/module/module.pulsar.go @@ -0,0 +1,651 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package module + +import ( + _ "cosmossdk.io/api/cosmos/app/v1alpha1" + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" +) + +var ( + md_Module protoreflect.MessageDescriptor + fd_Module_fee_collector_name protoreflect.FieldDescriptor + fd_Module_authority protoreflect.FieldDescriptor +) + +func init() { + file_client_x_mint_module_module_proto_init() + md_Module = File_client_x_mint_module_module_proto.Messages().ByName("Module") + fd_Module_fee_collector_name = md_Module.Fields().ByName("fee_collector_name") + fd_Module_authority = md_Module.Fields().ByName("authority") +} + +var _ protoreflect.Message = (*fastReflection_Module)(nil) + +type fastReflection_Module Module + +func (x *Module) ProtoReflect() protoreflect.Message { + return (*fastReflection_Module)(x) +} + +func (x *Module) slowProtoReflect() protoreflect.Message { + mi := &file_client_x_mint_module_module_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_Module_messageType fastReflection_Module_messageType +var _ protoreflect.MessageType = fastReflection_Module_messageType{} + +type fastReflection_Module_messageType struct{} + +func (x fastReflection_Module_messageType) Zero() protoreflect.Message { + return (*fastReflection_Module)(nil) +} +func (x fastReflection_Module_messageType) New() protoreflect.Message { + return new(fastReflection_Module) +} +func (x fastReflection_Module_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Module +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Module) Descriptor() protoreflect.MessageDescriptor { + return md_Module +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_Module) Type() protoreflect.MessageType { + return _fastReflection_Module_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Module) New() protoreflect.Message { + return new(fastReflection_Module) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Module) Interface() protoreflect.ProtoMessage { + return (*Module)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.FeeCollectorName != "" { + value := protoreflect.ValueOfString(x.FeeCollectorName) + if !f(fd_Module_fee_collector_name, value) { + return + } + } + if x.Authority != "" { + value := protoreflect.ValueOfString(x.Authority) + if !f(fd_Module_authority, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "client.x.mint.module.Module.fee_collector_name": + return x.FeeCollectorName != "" + case "client.x.mint.module.Module.authority": + return x.Authority != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: client.x.mint.module.Module")) + } + panic(fmt.Errorf("message client.x.mint.module.Module does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "client.x.mint.module.Module.fee_collector_name": + x.FeeCollectorName = "" + case "client.x.mint.module.Module.authority": + x.Authority = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: client.x.mint.module.Module")) + } + panic(fmt.Errorf("message client.x.mint.module.Module does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "client.x.mint.module.Module.fee_collector_name": + value := x.FeeCollectorName + return protoreflect.ValueOfString(value) + case "client.x.mint.module.Module.authority": + value := x.Authority + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: client.x.mint.module.Module")) + } + panic(fmt.Errorf("message client.x.mint.module.Module does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "client.x.mint.module.Module.fee_collector_name": + x.FeeCollectorName = value.Interface().(string) + case "client.x.mint.module.Module.authority": + x.Authority = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: client.x.mint.module.Module")) + } + panic(fmt.Errorf("message client.x.mint.module.Module does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "client.x.mint.module.Module.fee_collector_name": + panic(fmt.Errorf("field fee_collector_name of message client.x.mint.module.Module is not mutable")) + case "client.x.mint.module.Module.authority": + panic(fmt.Errorf("field authority of message client.x.mint.module.Module is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: client.x.mint.module.Module")) + } + panic(fmt.Errorf("message client.x.mint.module.Module does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "client.x.mint.module.Module.fee_collector_name": + return protoreflect.ValueOfString("") + case "client.x.mint.module.Module.authority": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: client.x.mint.module.Module")) + } + panic(fmt.Errorf("message client.x.mint.module.Module does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_Module) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in client.x.mint.module.Module", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_Module) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Module) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_Module) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Module) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.FeeCollectorName) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Authority) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*Module) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Authority) > 0 { + i -= len(x.Authority) + copy(dAtA[i:], x.Authority) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Authority))) + i-- + dAtA[i] = 0x12 + } + if len(x.FeeCollectorName) > 0 { + i -= len(x.FeeCollectorName) + copy(dAtA[i:], x.FeeCollectorName) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.FeeCollectorName))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*Module) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FeeCollectorName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.FeeCollectorName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: client/x/mint/module/module.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Module is the config object of the mint module. +type Module struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FeeCollectorName string `protobuf:"bytes,1,opt,name=fee_collector_name,json=feeCollectorName,proto3" json:"fee_collector_name,omitempty"` + // authority defines the custom module authority. If not set, defaults to the governance module. + Authority string `protobuf:"bytes,2,opt,name=authority,proto3" json:"authority,omitempty"` +} + +func (x *Module) Reset() { + *x = Module{} + if protoimpl.UnsafeEnabled { + mi := &file_client_x_mint_module_module_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Module) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Module) ProtoMessage() {} + +// Deprecated: Use Module.ProtoReflect.Descriptor instead. +func (*Module) Descriptor() ([]byte, []int) { + return file_client_x_mint_module_module_proto_rawDescGZIP(), []int{0} +} + +func (x *Module) GetFeeCollectorName() string { + if x != nil { + return x.FeeCollectorName + } + return "" +} + +func (x *Module) GetAuthority() string { + if x != nil { + return x.Authority + } + return "" +} + +var File_client_x_mint_module_module_proto protoreflect.FileDescriptor + +var file_client_x_mint_module_module_proto_rawDesc = []byte{ + 0x0a, 0x21, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x78, 0x2f, 0x6d, 0x69, 0x6e, 0x74, 0x2f, + 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x78, 0x2e, 0x6d, 0x69, + 0x6e, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x1a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x84, 0x01, 0x0a, 0x06, + 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x2c, 0x0a, 0x12, 0x66, 0x65, 0x65, 0x5f, 0x63, 0x6f, + 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x10, 0x66, 0x65, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, + 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, + 0x74, 0x79, 0x3a, 0x2e, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x28, 0x0a, 0x26, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x69, 0x70, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x73, + 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x78, 0x2f, 0x6d, 0x69, + 0x6e, 0x74, 0x42, 0xc2, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x2e, 0x78, 0x2e, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x42, + 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x25, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x78, 0x2f, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x6d, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0xa2, 0x02, 0x04, 0x43, 0x58, 0x4d, 0x4d, 0xaa, 0x02, 0x14, 0x43, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x58, 0x2e, 0x4d, 0x69, 0x6e, 0x74, 0x2e, 0x4d, 0x6f, 0x64, + 0x75, 0x6c, 0x65, 0xca, 0x02, 0x14, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x58, 0x5c, 0x4d, + 0x69, 0x6e, 0x74, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0xe2, 0x02, 0x20, 0x43, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x5c, 0x58, 0x5c, 0x4d, 0x69, 0x6e, 0x74, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, + 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x17, + 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3a, 0x3a, 0x58, 0x3a, 0x3a, 0x4d, 0x69, 0x6e, 0x74, 0x3a, + 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_client_x_mint_module_module_proto_rawDescOnce sync.Once + file_client_x_mint_module_module_proto_rawDescData = file_client_x_mint_module_module_proto_rawDesc +) + +func file_client_x_mint_module_module_proto_rawDescGZIP() []byte { + file_client_x_mint_module_module_proto_rawDescOnce.Do(func() { + file_client_x_mint_module_module_proto_rawDescData = protoimpl.X.CompressGZIP(file_client_x_mint_module_module_proto_rawDescData) + }) + return file_client_x_mint_module_module_proto_rawDescData +} + +var file_client_x_mint_module_module_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_client_x_mint_module_module_proto_goTypes = []interface{}{ + (*Module)(nil), // 0: client.x.mint.module.Module +} +var file_client_x_mint_module_module_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_client_x_mint_module_module_proto_init() } +func file_client_x_mint_module_module_proto_init() { + if File_client_x_mint_module_module_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_client_x_mint_module_module_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Module); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_client_x_mint_module_module_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_client_x_mint_module_module_proto_goTypes, + DependencyIndexes: file_client_x_mint_module_module_proto_depIdxs, + MessageInfos: file_client_x_mint_module_module_proto_msgTypes, + }.Build() + File_client_x_mint_module_module_proto = out.File + file_client_x_mint_module_module_proto_rawDesc = nil + file_client_x_mint_module_module_proto_goTypes = nil + file_client_x_mint_module_module_proto_depIdxs = nil +} diff --git a/client/x/mint/testutil/expected_keepers_mocks.go b/client/x/mint/testutil/expected_keepers_mocks.go new file mode 100644 index 00000000..26be50dd --- /dev/null +++ b/client/x/mint/testutil/expected_keepers_mocks.go @@ -0,0 +1,195 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: x/mint/types/expected_keepers.go + +// Package testutil is a generated GoMock package. +package testutil + +import ( + context "context" + reflect "reflect" + + math "cosmossdk.io/math" + types "github.com/cosmos/cosmos-sdk/types" + gomock "github.com/golang/mock/gomock" +) + +// MockStakingKeeper is a mock of StakingKeeper interface. +type MockStakingKeeper struct { + ctrl *gomock.Controller + recorder *MockStakingKeeperMockRecorder +} + +// MockStakingKeeperMockRecorder is the mock recorder for MockStakingKeeper. +type MockStakingKeeperMockRecorder struct { + mock *MockStakingKeeper +} + +// NewMockStakingKeeper creates a new mock instance. +func NewMockStakingKeeper(ctrl *gomock.Controller) *MockStakingKeeper { + mock := &MockStakingKeeper{ctrl: ctrl} + mock.recorder = &MockStakingKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { + return m.recorder +} + +// BondedRatio mocks base method. +func (m *MockStakingKeeper) BondedRatio(ctx context.Context) (math.LegacyDec, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BondedRatio", ctx) + ret0, _ := ret[0].(math.LegacyDec) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// BondedRatio indicates an expected call of BondedRatio. +func (mr *MockStakingKeeperMockRecorder) BondedRatio(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BondedRatio", reflect.TypeOf((*MockStakingKeeper)(nil).BondedRatio), ctx) +} + +// StakingTokenSupply mocks base method. +func (m *MockStakingKeeper) StakingTokenSupply(ctx context.Context) (math.Int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StakingTokenSupply", ctx) + ret0, _ := ret[0].(math.Int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StakingTokenSupply indicates an expected call of StakingTokenSupply. +func (mr *MockStakingKeeperMockRecorder) StakingTokenSupply(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StakingTokenSupply", reflect.TypeOf((*MockStakingKeeper)(nil).StakingTokenSupply), ctx) +} + +// MockAccountKeeper is a mock of AccountKeeper interface. +type MockAccountKeeper struct { + ctrl *gomock.Controller + recorder *MockAccountKeeperMockRecorder +} + +// MockAccountKeeperMockRecorder is the mock recorder for MockAccountKeeper. +type MockAccountKeeperMockRecorder struct { + mock *MockAccountKeeper +} + +// NewMockAccountKeeper creates a new mock instance. +func NewMockAccountKeeper(ctrl *gomock.Controller) *MockAccountKeeper { + mock := &MockAccountKeeper{ctrl: ctrl} + mock.recorder = &MockAccountKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { + return m.recorder +} + +// GetModuleAccount mocks base method. +func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) types.ModuleAccountI { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName) + ret0, _ := ret[0].(types.ModuleAccountI) + return ret0 +} + +// GetModuleAccount indicates an expected call of GetModuleAccount. +func (mr *MockAccountKeeperMockRecorder) GetModuleAccount(ctx, moduleName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAccount", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAccount), ctx, moduleName) +} + +// GetModuleAddress mocks base method. +func (m *MockAccountKeeper) GetModuleAddress(name string) types.AccAddress { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetModuleAddress", name) + ret0, _ := ret[0].(types.AccAddress) + return ret0 +} + +// GetModuleAddress indicates an expected call of GetModuleAddress. +func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAddress", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAddress), name) +} + +// SetModuleAccount mocks base method. +func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types.ModuleAccountI) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetModuleAccount", arg0, arg1) +} + +// SetModuleAccount indicates an expected call of SetModuleAccount. +func (mr *MockAccountKeeperMockRecorder) SetModuleAccount(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetModuleAccount", reflect.TypeOf((*MockAccountKeeper)(nil).SetModuleAccount), arg0, arg1) +} + +// MockBankKeeper is a mock of BankKeeper interface. +type MockBankKeeper struct { + ctrl *gomock.Controller + recorder *MockBankKeeperMockRecorder +} + +// MockBankKeeperMockRecorder is the mock recorder for MockBankKeeper. +type MockBankKeeperMockRecorder struct { + mock *MockBankKeeper +} + +// NewMockBankKeeper creates a new mock instance. +func NewMockBankKeeper(ctrl *gomock.Controller) *MockBankKeeper { + mock := &MockBankKeeper{ctrl: ctrl} + mock.recorder = &MockBankKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { + return m.recorder +} + +// MintCoins mocks base method. +func (m *MockBankKeeper) MintCoins(ctx context.Context, name string, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MintCoins", ctx, name, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// MintCoins indicates an expected call of MintCoins. +func (mr *MockBankKeeperMockRecorder) MintCoins(ctx, name, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MintCoins", reflect.TypeOf((*MockBankKeeper)(nil).MintCoins), ctx, name, amt) +} + +// SendCoinsFromModuleToAccount mocks base method. +func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr types.AccAddress, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendCoinsFromModuleToAccount indicates an expected call of SendCoinsFromModuleToAccount. +func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromModuleToAccount", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromModuleToAccount), ctx, senderModule, recipientAddr, amt) +} + +// SendCoinsFromModuleToModule mocks base method. +func (m *MockBankKeeper) SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoinsFromModuleToModule", ctx, senderModule, recipientModule, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendCoinsFromModuleToModule indicates an expected call of SendCoinsFromModuleToModule. +func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToModule(ctx, senderModule, recipientModule, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromModuleToModule", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromModuleToModule), ctx, senderModule, recipientModule, amt) +} diff --git a/client/x/mint/types/codec.go b/client/x/mint/types/codec.go new file mode 100644 index 00000000..53d87eb6 --- /dev/null +++ b/client/x/mint/types/codec.go @@ -0,0 +1,25 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/mint/Params", nil) + legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/mint/MsgUpdateParams") +} + +// RegisterInterfaces registers the interfaces types with the interface registry. +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgUpdateParams{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} diff --git a/client/x/mint/types/events.go b/client/x/mint/types/events.go new file mode 100644 index 00000000..5b8e45b0 --- /dev/null +++ b/client/x/mint/types/events.go @@ -0,0 +1,10 @@ +package types + +// Minting module event types. +const ( + EventTypeMint = ModuleName + + AttributeKeyBondedRatio = "bonded_ratio" + AttributeKeyInflation = "inflation" + AttributeKeyAnnualProvisions = "annual_provisions" +) diff --git a/client/x/mint/types/expected_keepers.go b/client/x/mint/types/expected_keepers.go new file mode 100644 index 00000000..dcdfda77 --- /dev/null +++ b/client/x/mint/types/expected_keepers.go @@ -0,0 +1,32 @@ +package types // noalias + +import ( + "context" + + "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// StakingKeeper defines the expected staking keeper. +type StakingKeeper interface { + StakingTokenSupply(ctx context.Context) (math.Int, error) + BondedRatio(ctx context.Context) (math.LegacyDec, error) +} + +// AccountKeeper defines the contract required for account APIs. +type AccountKeeper interface { + GetModuleAddress(name string) sdk.AccAddress + + // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 + SetModuleAccount(ctx context.Context, moduleAccount sdk.ModuleAccountI) + GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI +} + +// BankKeeper defines the contract needed to be fulfilled for banking and supply +// dependencies. +type BankKeeper interface { + SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt sdk.Coins) error + MintCoins(ctx context.Context, name string, amt sdk.Coins) error +} diff --git a/client/x/mint/types/genesis.go b/client/x/mint/types/genesis.go new file mode 100644 index 00000000..4f3d399e --- /dev/null +++ b/client/x/mint/types/genesis.go @@ -0,0 +1,45 @@ +package types + +import ( + "context" + + "cosmossdk.io/math" +) + +// InflationCalculationFn defines the function required to calculate inflation rate during +// BeginBlock. It receives the minter and params stored in the keeper, along with the current +// bondedRatio and returns the newly calculated inflation rate. +// It can be used to specify a custom inflation calculation logic, instead of relying on the +// default logic provided by the sdk. +type InflationCalculationFn func(ctx context.Context, minter Minter, params Params, bondedRatio math.LegacyDec) math.LegacyDec + +// DefaultInflationCalculationFn is the default function used to calculate inflation. +func DefaultInflationCalculationFn(_ context.Context, minter Minter, params Params, bondedRatio math.LegacyDec) math.LegacyDec { + return minter.NextInflationRate(params, bondedRatio) +} + +// NewGenesisState creates a new GenesisState object. +func NewGenesisState(minter Minter, params Params) *GenesisState { + return &GenesisState{ + Minter: minter, + Params: params, + } +} + +// DefaultGenesisState creates a default GenesisState object. +func DefaultGenesisState() *GenesisState { + return &GenesisState{ + Minter: DefaultInitialMinter(), + Params: DefaultParams(), + } +} + +// ValidateGenesis validates the provided genesis state to ensure the +// expected invariants holds. +func ValidateGenesis(data GenesisState) error { + if err := data.Params.Validate(); err != nil { + return err + } + + return ValidateMinter(data.Minter) +} diff --git a/client/x/mint/types/genesis.pb.go b/client/x/mint/types/genesis.pb.go new file mode 100644 index 00000000..9afe5286 --- /dev/null +++ b/client/x/mint/types/genesis.pb.go @@ -0,0 +1,378 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: client/x/mint/types/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the mint module's genesis state. +type GenesisState struct { + // minter is a space for holding current inflation information. + Minter Minter `protobuf:"bytes,1,opt,name=minter,proto3" json:"minter"` + // params defines all the parameters of the module. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_f5cd7edb2fa50db9, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetMinter() Minter { + if m != nil { + return m.Minter + } + return Minter{} +} + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "client.x.mint.types.GenesisState") +} + +func init() { proto.RegisterFile("client/x/mint/types/genesis.proto", fileDescriptor_f5cd7edb2fa50db9) } + +var fileDescriptor_f5cd7edb2fa50db9 = []byte{ + // 210 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0xce, 0xc9, 0x4c, + 0xcd, 0x2b, 0xd1, 0xaf, 0xd0, 0xcf, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, + 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, + 0x28, 0xd1, 0xab, 0xd0, 0x03, 0x29, 0xd1, 0x03, 0x2b, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, + 0xcb, 0xeb, 0x83, 0x58, 0x10, 0xa5, 0x52, 0x72, 0xd8, 0x4c, 0x03, 0xeb, 0x82, 0xc8, 0x0b, 0x26, + 0xe6, 0x66, 0xe6, 0xe5, 0xeb, 0x83, 0x49, 0x88, 0x90, 0x52, 0x1f, 0x23, 0x17, 0x8f, 0x3b, 0xc4, + 0xbe, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x3b, 0x2e, 0x36, 0x90, 0x8e, 0xd4, 0x22, 0x09, 0x46, + 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x69, 0x3d, 0x2c, 0xf6, 0xeb, 0xf9, 0x82, 0x95, 0x38, 0x71, 0x9e, + 0xb8, 0x27, 0xcf, 0xb0, 0xe2, 0xf9, 0x06, 0x2d, 0xc6, 0x20, 0xa8, 0x2e, 0x90, 0xfe, 0x82, 0xc4, + 0xa2, 0xc4, 0xdc, 0x62, 0x09, 0x26, 0x3c, 0xfa, 0x03, 0xc0, 0x4a, 0x50, 0xf4, 0x43, 0x74, 0x39, + 0xe9, 0x9e, 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, 0x30, 0x16, 0xdf, 0x25, + 0xb1, 0x81, 0xbd, 0x61, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x2e, 0x65, 0xcc, 0x25, 0x49, 0x01, + 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Minter.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Minter.Size() + n += 1 + l + sovGenesis(uint64(l)) + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Minter", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Minter.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/client/x/mint/types/genesis.proto b/client/x/mint/types/genesis.proto new file mode 100644 index 00000000..20b956b6 --- /dev/null +++ b/client/x/mint/types/genesis.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package client.x.mint.types; + +import "gogoproto/gogo.proto"; +import "client/x/mint/types/mint.proto"; +import "amino/amino.proto"; + +option go_package = "client/x/mint/types"; + +// GenesisState defines the mint module's genesis state. +message GenesisState { + // minter is a space for holding current inflation information. + Minter minter = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + + // params defines all the parameters of the module. + Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} diff --git a/client/x/mint/types/keys.go b/client/x/mint/types/keys.go new file mode 100644 index 00000000..cfa4cfd5 --- /dev/null +++ b/client/x/mint/types/keys.go @@ -0,0 +1,17 @@ +package types + +import "cosmossdk.io/collections" + +var ( + // MinterKey is the key to use for the keeper store. + MinterKey = collections.NewPrefix(0) + ParamsKey = collections.NewPrefix(1) +) + +const ( + // module name. + ModuleName = "mint" + + // StoreKey is the default store key for mint. + StoreKey = ModuleName +) diff --git a/client/x/mint/types/mint.pb.go b/client/x/mint/types/mint.pb.go new file mode 100644 index 00000000..c115de0c --- /dev/null +++ b/client/x/mint/types/mint.pb.go @@ -0,0 +1,781 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: client/x/mint/types/mint.proto + +package types + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Minter represents the minting state. +type Minter struct { + // current annual inflation rate + Inflation cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=inflation,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation"` + // current annual expected provisions + AnnualProvisions cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=annual_provisions,json=annualProvisions,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"annual_provisions"` +} + +func (m *Minter) Reset() { *m = Minter{} } +func (m *Minter) String() string { return proto.CompactTextString(m) } +func (*Minter) ProtoMessage() {} +func (*Minter) Descriptor() ([]byte, []int) { + return fileDescriptor_9c6e60aec58f52af, []int{0} +} +func (m *Minter) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Minter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Minter.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Minter) XXX_Merge(src proto.Message) { + xxx_messageInfo_Minter.Merge(m, src) +} +func (m *Minter) XXX_Size() int { + return m.Size() +} +func (m *Minter) XXX_DiscardUnknown() { + xxx_messageInfo_Minter.DiscardUnknown(m) +} + +var xxx_messageInfo_Minter proto.InternalMessageInfo + +// Params defines the parameters for the x/mint module. +type Params struct { + // type of coin to mint + MintDenom string `protobuf:"bytes,1,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` + // maximum annual change in inflation rate + InflationRateChange cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=inflation_rate_change,json=inflationRateChange,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation_rate_change"` + // maximum inflation rate + InflationMax cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=inflation_max,json=inflationMax,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation_max"` + // minimum inflation rate + InflationMin cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=inflation_min,json=inflationMin,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation_min"` + // goal of percent bonded atoms + GoalBonded cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=goal_bonded,json=goalBonded,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"goal_bonded"` + // expected blocks per year + BlocksPerYear uint64 `protobuf:"varint,6,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_9c6e60aec58f52af, []int{1} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetMintDenom() string { + if m != nil { + return m.MintDenom + } + return "" +} + +func (m *Params) GetBlocksPerYear() uint64 { + if m != nil { + return m.BlocksPerYear + } + return 0 +} + +func init() { + proto.RegisterType((*Minter)(nil), "client.x.mint.types.Minter") + proto.RegisterType((*Params)(nil), "client.x.mint.types.Params") +} + +func init() { proto.RegisterFile("client/x/mint/types/mint.proto", fileDescriptor_9c6e60aec58f52af) } + +var fileDescriptor_9c6e60aec58f52af = []byte{ + // 423 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xc1, 0x8a, 0x13, 0x31, + 0x18, 0xc7, 0x27, 0xee, 0x3a, 0xd0, 0xe8, 0xa2, 0x9b, 0x2a, 0x8c, 0x2b, 0x3b, 0xbb, 0xf4, 0x20, + 0xa5, 0xd0, 0x19, 0x44, 0xf0, 0xe0, 0xb1, 0xf6, 0x68, 0xb1, 0xcc, 0x45, 0x54, 0x70, 0xf8, 0x3a, + 0x13, 0xa7, 0xb1, 0x33, 0x49, 0x49, 0xa2, 0x4c, 0x5f, 0xc1, 0x93, 0x8f, 0xe1, 0xb1, 0x07, 0x2f, + 0xbe, 0x41, 0x8f, 0xc5, 0x93, 0x78, 0x28, 0xd2, 0x1e, 0x7a, 0xf2, 0x1d, 0x64, 0x92, 0x3a, 0x05, + 0xf1, 0xa2, 0xf5, 0x12, 0xbe, 0xfc, 0xff, 0xe1, 0xf7, 0xfd, 0x49, 0xf2, 0x61, 0x3f, 0xc9, 0x19, + 0xe5, 0x3a, 0x2c, 0xc3, 0x82, 0x71, 0x1d, 0xea, 0xd9, 0x94, 0x2a, 0x53, 0x06, 0x53, 0x29, 0xb4, + 0x20, 0x4d, 0xeb, 0x07, 0x65, 0x60, 0x44, 0xe3, 0x9f, 0xdd, 0xca, 0x44, 0x26, 0x8c, 0x1f, 0x56, + 0x95, 0x3d, 0x7a, 0x76, 0x27, 0x11, 0xaa, 0x10, 0x2a, 0xb6, 0x86, 0xdd, 0xec, 0xac, 0x53, 0x28, + 0x18, 0x17, 0xa1, 0x59, 0xad, 0xd4, 0xfa, 0x8c, 0xb0, 0x3b, 0x60, 0x5c, 0x53, 0x49, 0x9e, 0xe2, + 0x06, 0xe3, 0xaf, 0x73, 0xd0, 0x4c, 0x70, 0x0f, 0x5d, 0xa2, 0x76, 0xa3, 0x77, 0x7f, 0xb1, 0xba, + 0x70, 0xbe, 0xad, 0x2e, 0xee, 0x5a, 0x8c, 0x4a, 0x27, 0x01, 0x13, 0x61, 0x01, 0x7a, 0x1c, 0x3c, + 0xa1, 0x19, 0x24, 0xb3, 0x3e, 0x4d, 0xbe, 0x7c, 0xea, 0xe2, 0x5d, 0x97, 0x3e, 0x4d, 0xa2, 0x3d, + 0x83, 0xbc, 0xc2, 0xa7, 0xc0, 0xf9, 0x5b, 0xc8, 0xab, 0x2c, 0xef, 0x98, 0x62, 0x82, 0x2b, 0xef, + 0xca, 0xbf, 0x82, 0x6f, 0x5a, 0xd6, 0xb0, 0x46, 0xb5, 0x7e, 0x1c, 0x61, 0x77, 0x08, 0x12, 0x0a, + 0x45, 0xce, 0x31, 0xae, 0x2e, 0x26, 0x4e, 0x29, 0x17, 0x85, 0x0d, 0x1f, 0x35, 0x2a, 0xa5, 0x5f, + 0x09, 0xe4, 0x0d, 0xbe, 0x5d, 0xc7, 0x8a, 0x25, 0x68, 0x1a, 0x27, 0x63, 0xe0, 0x19, 0xdd, 0xa5, + 0x79, 0xf8, 0xd7, 0x69, 0x3e, 0x6e, 0xe7, 0x1d, 0x14, 0x35, 0x6b, 0x68, 0x04, 0x9a, 0x3e, 0x36, + 0x48, 0xf2, 0x12, 0x9f, 0xec, 0x7b, 0x15, 0x50, 0x7a, 0x47, 0x07, 0xf5, 0xb8, 0x5e, 0xc3, 0x06, + 0x50, 0xfe, 0x06, 0x67, 0xdc, 0x3b, 0xfe, 0x5f, 0x70, 0xc6, 0xc9, 0x33, 0x7c, 0x2d, 0x13, 0x90, + 0xc7, 0x23, 0xc1, 0x53, 0x9a, 0x7a, 0x57, 0x0f, 0x42, 0xe3, 0x0a, 0xd5, 0x33, 0x24, 0x72, 0x0f, + 0xdf, 0x18, 0xe5, 0x22, 0x99, 0xa8, 0x78, 0x4a, 0x65, 0x3c, 0xa3, 0x20, 0x3d, 0xf7, 0x12, 0xb5, + 0x8f, 0xa3, 0x13, 0x2b, 0x0f, 0xa9, 0x7c, 0x4e, 0x41, 0x3e, 0x3a, 0x7f, 0xbf, 0x9d, 0x77, 0x3c, + 0x4b, 0xea, 0xaa, 0x74, 0xf2, 0x6b, 0x1c, 0xec, 0x23, 0xf7, 0xba, 0x8b, 0xb5, 0x8f, 0x96, 0x6b, + 0x1f, 0x7d, 0x5f, 0xfb, 0xe8, 0xc3, 0xc6, 0x77, 0x96, 0x1b, 0xdf, 0xf9, 0xba, 0xf1, 0x9d, 0x17, + 0xcd, 0x3f, 0x8c, 0xcf, 0xc8, 0x35, 0x3f, 0xfc, 0xc1, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x28, + 0x7a, 0x3e, 0xa7, 0x5c, 0x03, 0x00, 0x00, +} + +func (m *Minter) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Minter) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Minter) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.AnnualProvisions.Size() + i -= size + if _, err := m.AnnualProvisions.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.Inflation.Size() + i -= size + if _, err := m.Inflation.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BlocksPerYear != 0 { + i = encodeVarintMint(dAtA, i, uint64(m.BlocksPerYear)) + i-- + dAtA[i] = 0x30 + } + { + size := m.GoalBonded.Size() + i -= size + if _, err := m.GoalBonded.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.InflationMin.Size() + i -= size + if _, err := m.InflationMin.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.InflationMax.Size() + i -= size + if _, err := m.InflationMax.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.InflationRateChange.Size() + i -= size + if _, err := m.InflationRateChange.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.MintDenom) > 0 { + i -= len(m.MintDenom) + copy(dAtA[i:], m.MintDenom) + i = encodeVarintMint(dAtA, i, uint64(len(m.MintDenom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintMint(dAtA []byte, offset int, v uint64) int { + offset -= sovMint(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Minter) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Inflation.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.AnnualProvisions.Size() + n += 1 + l + sovMint(uint64(l)) + return n +} + +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MintDenom) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + l = m.InflationRateChange.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.InflationMax.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.InflationMin.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.GoalBonded.Size() + n += 1 + l + sovMint(uint64(l)) + if m.BlocksPerYear != 0 { + n += 1 + sovMint(uint64(m.BlocksPerYear)) + } + return n +} + +func sovMint(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMint(x uint64) (n int) { + return sovMint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Minter) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Minter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Minter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Inflation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Inflation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AnnualProvisions", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AnnualProvisions.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMint(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MintDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MintDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InflationRateChange", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InflationRateChange.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InflationMax", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InflationMax.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InflationMin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InflationMin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GoalBonded", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.GoalBonded.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlocksPerYear", wireType) + } + m.BlocksPerYear = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlocksPerYear |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipMint(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMint(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMint + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMint + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMint + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthMint + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMint + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMint + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMint = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMint = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMint = fmt.Errorf("proto: unexpected end of group") +) diff --git a/client/x/mint/types/mint.proto b/client/x/mint/types/mint.proto new file mode 100644 index 00000000..72354d5f --- /dev/null +++ b/client/x/mint/types/mint.proto @@ -0,0 +1,62 @@ +syntax = "proto3"; +package client.x.mint.types; + +option go_package = "client/x/mint/types"; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "amino/amino.proto"; + +// Minter represents the minting state. +message Minter { + // current annual inflation rate + string inflation = 1 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + // current annual expected provisions + string annual_provisions = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; +} + +// Params defines the parameters for the x/mint module. +message Params { + option (amino.name) = "cosmos-sdk/x/mint/Params"; + + // type of coin to mint + string mint_denom = 1; + // maximum annual change in inflation rate + string inflation_rate_change = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; + // maximum inflation rate + string inflation_max = 3 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; + // minimum inflation rate + string inflation_min = 4 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; + // goal of percent bonded atoms + string goal_bonded = 5 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; + // expected blocks per year + uint64 blocks_per_year = 6; +} diff --git a/client/x/mint/types/minter.go b/client/x/mint/types/minter.go new file mode 100644 index 00000000..383307fd --- /dev/null +++ b/client/x/mint/types/minter.go @@ -0,0 +1,83 @@ +package types + +import ( + "fmt" + + "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// NewMinter returns a new Minter object with the given inflation and annual +// provisions values. +func NewMinter(inflation, annualProvisions math.LegacyDec) Minter { + return Minter{ + Inflation: inflation, + AnnualProvisions: annualProvisions, + } +} + +// InitialMinter returns an initial Minter object with a given inflation value. +func InitialMinter(inflation math.LegacyDec) Minter { + return NewMinter( + inflation, + math.LegacyNewDec(0), + ) +} + +// DefaultInitialMinter returns a default initial Minter object for a new chain +// which uses an inflation rate of 13%. +func DefaultInitialMinter() Minter { + return InitialMinter( + math.LegacyNewDecWithPrec(13, 2), + ) +} + +// ValidateMinter does a basic validation on minter. +func ValidateMinter(minter Minter) error { + if minter.Inflation.IsNegative() { + return fmt.Errorf("mint parameter Inflation should be positive, is %s", + minter.Inflation.String()) + } + + return nil +} + +// NextInflationRate returns the new inflation rate for the next block. +func (m Minter) NextInflationRate(params Params, bondedRatio math.LegacyDec) math.LegacyDec { + // The target annual inflation rate is recalculated for each block. The inflation + // is also subject to a rate change (positive or negative) depending on the + // distance from the desired ratio (67%). The maximum rate change possible is + // defined to be 13% per year, however the annual inflation is capped as between + // 7% and 20%. + + // (1 - bondedRatio/GoalBonded) * InflationRateChange + inflationRateChangePerYear := math.LegacyOneDec(). + Sub(bondedRatio.Quo(params.GoalBonded)). + Mul(params.InflationRateChange) + inflationRateChange := inflationRateChangePerYear.Quo(math.LegacyNewDec(int64(params.BlocksPerYear))) + + // adjust the new annual inflation for this next block + inflation := m.Inflation.Add(inflationRateChange) // note inflationRateChange may be negative + if inflation.GT(params.InflationMax) { + inflation = params.InflationMax + } + if inflation.LT(params.InflationMin) { + inflation = params.InflationMin + } + + return inflation +} + +// NextAnnualProvisions returns the annual provisions based on current total +// supply and inflation rate. +func (m Minter) NextAnnualProvisions(_ Params, totalSupply math.Int) math.LegacyDec { + return m.Inflation.MulInt(totalSupply) +} + +// BlockProvision returns the provisions for a block based on the annual +// provisions rate. +func (m Minter) BlockProvision(params Params) sdk.Coin { + provisionAmt := m.AnnualProvisions.QuoInt(math.NewInt(int64(params.BlocksPerYear))) + return sdk.NewCoin(params.MintDenom, provisionAmt.TruncateInt()) +} diff --git a/client/x/mint/types/minter_test.go b/client/x/mint/types/minter_test.go new file mode 100644 index 00000000..a84969d1 --- /dev/null +++ b/client/x/mint/types/minter_test.go @@ -0,0 +1,140 @@ +//nolint:paralleltest // just for testing +package types_test + +import ( + "math/rand" + "testing" + + "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/piplabs/story/client/x/mint/types" +) + +func TestNextInflation(t *testing.T) { + minter := types.DefaultInitialMinter() + params := types.DefaultParams() + blocksPerYr := math.LegacyNewDec(int64(params.BlocksPerYear)) + + // Governing Mechanism: + // inflationRateChangePerYear = (1- BondedRatio/ GoalBonded) * MaxInflationRateChange + + tests := []struct { + bondedRatio, setInflation, expChange math.LegacyDec + }{ + // with 0% bonded atom supply the inflation should increase by InflationRateChange + {math.LegacyZeroDec(), math.LegacyNewDecWithPrec(7, 2), params.InflationRateChange.Quo(blocksPerYr)}, + + // 100% bonded, starting at 20% inflation and being reduced + // (1 - (1/0.67))*(0.13/8667) + { + math.LegacyOneDec(), math.LegacyNewDecWithPrec(20, 2), + math.LegacyOneDec().Sub(math.LegacyOneDec().Quo(params.GoalBonded)).Mul(params.InflationRateChange).Quo(blocksPerYr), + }, + + // 50% bonded, starting at 10% inflation and being increased + { + math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(10, 2), + math.LegacyOneDec().Sub(math.LegacyNewDecWithPrec(5, 1).Quo(params.GoalBonded)).Mul(params.InflationRateChange).Quo(blocksPerYr), + }, + + // test 7% minimum stop (testing with 100% bonded) + {math.LegacyOneDec(), math.LegacyNewDecWithPrec(7, 2), math.LegacyZeroDec()}, + {math.LegacyOneDec(), math.LegacyNewDecWithPrec(700000001, 10), math.LegacyNewDecWithPrec(-1, 10)}, + + // test 20% maximum stop (testing with 0% bonded) + {math.LegacyZeroDec(), math.LegacyNewDecWithPrec(20, 2), math.LegacyZeroDec()}, + {math.LegacyZeroDec(), math.LegacyNewDecWithPrec(1999999999, 10), math.LegacyNewDecWithPrec(1, 10)}, + + // perfect balance shouldn't change inflation + {math.LegacyNewDecWithPrec(67, 2), math.LegacyNewDecWithPrec(15, 2), math.LegacyZeroDec()}, + } + for i, tc := range tests { + minter.Inflation = tc.setInflation + + inflation := minter.NextInflationRate(params, tc.bondedRatio) + diffInflation := inflation.Sub(tc.setInflation) + + require.True(t, diffInflation.Equal(tc.expChange), + "Test Index: %v\nDiff: %v\nExpected: %v\n", i, diffInflation, tc.expChange) + } +} + +func TestBlockProvision(t *testing.T) { + minter := types.InitialMinter(math.LegacyNewDecWithPrec(1, 1)) + params := types.DefaultParams() + + secondsPerYear := int64(60 * 60 * 8766) + + tests := []struct { + annualProvisions int64 + expProvisions int64 + }{ + {secondsPerYear / 5, 1}, + {secondsPerYear/5 + 1, 1}, + {(secondsPerYear / 5) * 2, 2}, + {(secondsPerYear / 5) / 2, 0}, + } + for i, tc := range tests { + minter.AnnualProvisions = math.LegacyNewDec(tc.annualProvisions) + provisions := minter.BlockProvision(params) + + expProvisions := sdk.NewCoin(params.MintDenom, + math.NewInt(tc.expProvisions)) + + require.True(t, expProvisions.IsEqual(provisions), + "test: %v\n\tExp: %v\n\tGot: %v\n", + i, tc.expProvisions, provisions) + } +} + +// Benchmarking :) +// previously using math.Int operations: +// BenchmarkBlockProvision-4 5000000 220 ns/op +// +// using math.LegacyDec operations: (current implementation) +// BenchmarkBlockProvision-4 3000000 429 ns/op. +func BenchmarkBlockProvision(b *testing.B) { + b.ReportAllocs() + minter := types.InitialMinter(math.LegacyNewDecWithPrec(1, 1)) + params := types.DefaultParams() + + s1 := rand.NewSource(100) + r1 := rand.New(s1) + minter.AnnualProvisions = math.LegacyNewDec(r1.Int63n(1000000)) + + // run the BlockProvision function b.N times + for n := 0; n < b.N; n++ { + minter.BlockProvision(params) + } +} + +// Next inflation benchmarking +// BenchmarkNextInflation-4 1000000 1828 ns/op. +func BenchmarkNextInflation(b *testing.B) { + b.ReportAllocs() + minter := types.InitialMinter(math.LegacyNewDecWithPrec(1, 1)) + params := types.DefaultParams() + bondedRatio := math.LegacyNewDecWithPrec(1, 1) + + // run the NextInflationRate function b.N times + for n := 0; n < b.N; n++ { + minter.NextInflationRate(params, bondedRatio) + } +} + +// Next annual provisions benchmarking +// BenchmarkNextAnnualProvisions-4 5000000 251 ns/op. +func BenchmarkNextAnnualProvisions(b *testing.B) { + b.ReportAllocs() + minter := types.InitialMinter(math.LegacyNewDecWithPrec(1, 1)) + params := types.DefaultParams() + totalSupply := math.NewInt(100000000000000) + + // run the NextAnnualProvisions function b.N times + for n := 0; n < b.N; n++ { + minter.NextAnnualProvisions(params, totalSupply) + } +} diff --git a/client/x/mint/types/params.go b/client/x/mint/types/params.go new file mode 100644 index 00000000..704b5bb4 --- /dev/null +++ b/client/x/mint/types/params.go @@ -0,0 +1,173 @@ +//nolint:revive // just use interface{} +package types + +import ( + "fmt" + "strings" + + "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/piplabs/story/lib/errors" +) + +// NewParams returns Params instance with the given values. +func NewParams(mintDenom string, inflationRateChange, inflationMax, inflationMin, goalBonded math.LegacyDec, blocksPerYear uint64) Params { + return Params{ + MintDenom: mintDenom, + InflationRateChange: inflationRateChange, + InflationMax: inflationMax, + InflationMin: inflationMin, + GoalBonded: goalBonded, + BlocksPerYear: blocksPerYear, + } +} + +// DefaultParams returns default x/mint module parameters. +func DefaultParams() Params { + return Params{ + MintDenom: sdk.DefaultBondDenom, + InflationRateChange: math.LegacyNewDecWithPrec(13, 2), + InflationMax: math.LegacyNewDecWithPrec(20, 2), + InflationMin: math.LegacyNewDecWithPrec(7, 2), + GoalBonded: math.LegacyNewDecWithPrec(67, 2), + BlocksPerYear: uint64(60 * 60 * 8766 / 5), // assuming 5 second block times + } +} + +// Validate does the sanity check on the params. +func (p Params) Validate() error { + if err := validateMintDenom(p.MintDenom); err != nil { + return err + } + if err := validateInflationRateChange(p.InflationRateChange); err != nil { + return err + } + if err := validateInflationMax(p.InflationMax); err != nil { + return err + } + if err := validateInflationMin(p.InflationMin); err != nil { + return err + } + if err := validateGoalBonded(p.GoalBonded); err != nil { + return err + } + if err := validateBlocksPerYear(p.BlocksPerYear); err != nil { + return err + } + if p.InflationMax.LT(p.InflationMin) { + return fmt.Errorf( + "max inflation (%s) must be greater than or equal to min inflation (%s)", + p.InflationMax, p.InflationMin, + ) + } + + return nil +} + +func validateMintDenom(i interface{}) error { + v, ok := i.(string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if strings.TrimSpace(v) == "" { + return errors.New("mint denom cannot be blank") + } + + if err := sdk.ValidateDenom(v); err != nil { + return errors.Wrap(err, "mint denom is invalid") + } + + return nil +} + +func validateInflationRateChange(i interface{}) error { + v, ok := i.(math.LegacyDec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNil() { + return fmt.Errorf("inflation rate change cannot be nil: %s", v) + } + if v.IsNegative() { + return fmt.Errorf("inflation rate change cannot be negative: %s", v) + } + if v.GT(math.LegacyOneDec()) { + return fmt.Errorf("inflation rate change too large: %s", v) + } + + return nil +} + +func validateInflationMax(i interface{}) error { + v, ok := i.(math.LegacyDec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNil() { + return fmt.Errorf("max inflation cannot be nil: %s", v) + } + if v.IsNegative() { + return fmt.Errorf("max inflation cannot be negative: %s", v) + } + if v.GT(math.LegacyOneDec()) { + return fmt.Errorf("max inflation too large: %s", v) + } + + return nil +} + +func validateInflationMin(i interface{}) error { + v, ok := i.(math.LegacyDec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNil() { + return fmt.Errorf("min inflation cannot be nil: %s", v) + } + if v.IsNegative() { + return fmt.Errorf("min inflation cannot be negative: %s", v) + } + if v.GT(math.LegacyOneDec()) { + return fmt.Errorf("min inflation too large: %s", v) + } + + return nil +} + +func validateGoalBonded(i interface{}) error { + v, ok := i.(math.LegacyDec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNil() { + return fmt.Errorf("goal bonded cannot be nil: %s", v) + } + if v.IsNegative() || v.IsZero() { + return fmt.Errorf("goal bonded must be positive: %s", v) + } + if v.GT(math.LegacyOneDec()) { + return fmt.Errorf("goal bonded too large: %s", v) + } + + return nil +} + +func validateBlocksPerYear(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("blocks per year must be positive: %d", v) + } + + return nil +} diff --git a/client/x/mint/types/params_legacy.go b/client/x/mint/types/params_legacy.go new file mode 100644 index 00000000..46e5ab51 --- /dev/null +++ b/client/x/mint/types/params_legacy.go @@ -0,0 +1,39 @@ +/* +NOTE: Usage of x/params to manage parameters is deprecated in favor of x/gov +controlled execution of MsgUpdateParams messages. These types remains solely +for migration purposes and will be removed in a future release. +*/ +package types + +import ( + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// Parameter store keys. +var ( + KeyMintDenom = []byte("MintDenom") + KeyInflationRateChange = []byte("InflationRateChange") + KeyInflationMax = []byte("InflationMax") + KeyInflationMin = []byte("InflationMin") + KeyGoalBonded = []byte("GoalBonded") + KeyBlocksPerYear = []byte("BlocksPerYear") +) + +// Deprecated: ParamTable for minting module. +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// Implements params.ParamSet +// +// Deprecated. +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyMintDenom, &p.MintDenom, validateMintDenom), + paramtypes.NewParamSetPair(KeyInflationRateChange, &p.InflationRateChange, validateInflationRateChange), + paramtypes.NewParamSetPair(KeyInflationMax, &p.InflationMax, validateInflationMax), + paramtypes.NewParamSetPair(KeyInflationMin, &p.InflationMin, validateInflationMin), + paramtypes.NewParamSetPair(KeyGoalBonded, &p.GoalBonded, validateGoalBonded), + paramtypes.NewParamSetPair(KeyBlocksPerYear, &p.BlocksPerYear, validateBlocksPerYear), + } +} diff --git a/client/x/mint/types/query.pb.go b/client/x/mint/types/query.pb.go new file mode 100644 index 00000000..4459954b --- /dev/null +++ b/client/x/mint/types/query.pb.go @@ -0,0 +1,1204 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: client/x/mint/types/query.proto + +package types + +import ( + context "context" + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + 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" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a6d4efab0120ffa4, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params defines the parameters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a6d4efab0120ffa4, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// QueryInflationRequest is the request type for the Query/Inflation RPC method. +type QueryInflationRequest struct { +} + +func (m *QueryInflationRequest) Reset() { *m = QueryInflationRequest{} } +func (m *QueryInflationRequest) String() string { return proto.CompactTextString(m) } +func (*QueryInflationRequest) ProtoMessage() {} +func (*QueryInflationRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a6d4efab0120ffa4, []int{2} +} +func (m *QueryInflationRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryInflationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryInflationRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryInflationRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryInflationRequest.Merge(m, src) +} +func (m *QueryInflationRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryInflationRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryInflationRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryInflationRequest proto.InternalMessageInfo + +// QueryInflationResponse is the response type for the Query/Inflation RPC +// method. +type QueryInflationResponse struct { + // inflation is the current minting inflation value. + Inflation cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=inflation,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation"` +} + +func (m *QueryInflationResponse) Reset() { *m = QueryInflationResponse{} } +func (m *QueryInflationResponse) String() string { return proto.CompactTextString(m) } +func (*QueryInflationResponse) ProtoMessage() {} +func (*QueryInflationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a6d4efab0120ffa4, []int{3} +} +func (m *QueryInflationResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryInflationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryInflationResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryInflationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryInflationResponse.Merge(m, src) +} +func (m *QueryInflationResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryInflationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryInflationResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryInflationResponse proto.InternalMessageInfo + +// QueryAnnualProvisionsRequest is the request type for the +// Query/AnnualProvisions RPC method. +type QueryAnnualProvisionsRequest struct { +} + +func (m *QueryAnnualProvisionsRequest) Reset() { *m = QueryAnnualProvisionsRequest{} } +func (m *QueryAnnualProvisionsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAnnualProvisionsRequest) ProtoMessage() {} +func (*QueryAnnualProvisionsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a6d4efab0120ffa4, []int{4} +} +func (m *QueryAnnualProvisionsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAnnualProvisionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAnnualProvisionsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAnnualProvisionsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAnnualProvisionsRequest.Merge(m, src) +} +func (m *QueryAnnualProvisionsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAnnualProvisionsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAnnualProvisionsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAnnualProvisionsRequest proto.InternalMessageInfo + +// QueryAnnualProvisionsResponse is the response type for the +// Query/AnnualProvisions RPC method. +type QueryAnnualProvisionsResponse struct { + // annual_provisions is the current minting annual provisions value. + AnnualProvisions cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=annual_provisions,json=annualProvisions,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"annual_provisions"` +} + +func (m *QueryAnnualProvisionsResponse) Reset() { *m = QueryAnnualProvisionsResponse{} } +func (m *QueryAnnualProvisionsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAnnualProvisionsResponse) ProtoMessage() {} +func (*QueryAnnualProvisionsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a6d4efab0120ffa4, []int{5} +} +func (m *QueryAnnualProvisionsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAnnualProvisionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAnnualProvisionsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAnnualProvisionsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAnnualProvisionsResponse.Merge(m, src) +} +func (m *QueryAnnualProvisionsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAnnualProvisionsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAnnualProvisionsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAnnualProvisionsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "client.x.mint.types.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "client.x.mint.types.QueryParamsResponse") + proto.RegisterType((*QueryInflationRequest)(nil), "client.x.mint.types.QueryInflationRequest") + proto.RegisterType((*QueryInflationResponse)(nil), "client.x.mint.types.QueryInflationResponse") + proto.RegisterType((*QueryAnnualProvisionsRequest)(nil), "client.x.mint.types.QueryAnnualProvisionsRequest") + proto.RegisterType((*QueryAnnualProvisionsResponse)(nil), "client.x.mint.types.QueryAnnualProvisionsResponse") +} + +func init() { proto.RegisterFile("client/x/mint/types/query.proto", fileDescriptor_a6d4efab0120ffa4) } + +var fileDescriptor_a6d4efab0120ffa4 = []byte{ + // 485 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xcf, 0x6b, 0x14, 0x31, + 0x18, 0x9d, 0x28, 0x2e, 0x6c, 0xf4, 0xd0, 0x66, 0xeb, 0xaf, 0xd9, 0x36, 0x5b, 0x46, 0xa8, 0x4b, + 0xa5, 0x09, 0xbb, 0x82, 0x47, 0xc1, 0xa5, 0x17, 0xc1, 0x43, 0x2d, 0x7a, 0xf1, 0x22, 0xe9, 0x18, + 0xc7, 0xe0, 0x4c, 0x32, 0x9d, 0x64, 0x4b, 0xf7, 0x26, 0xe2, 0xd1, 0x83, 0xe0, 0x3f, 0xa1, 0x37, + 0x0f, 0xfe, 0x0b, 0x42, 0x8f, 0x45, 0x2f, 0xe2, 0xa1, 0xc8, 0xae, 0xe0, 0xbf, 0x21, 0x93, 0x64, + 0x2b, 0x4e, 0x67, 0x50, 0xe9, 0x65, 0xd9, 0xf9, 0xde, 0xcb, 0xf7, 0xde, 0xf7, 0xbd, 0x04, 0xf6, + 0xe2, 0x54, 0x70, 0x69, 0xe8, 0x3e, 0xcd, 0x84, 0x34, 0xd4, 0x4c, 0x72, 0xae, 0xe9, 0xee, 0x98, + 0x17, 0x13, 0x92, 0x17, 0xca, 0x28, 0xd4, 0x71, 0x04, 0xb2, 0x4f, 0x4a, 0x02, 0xb1, 0x84, 0x70, + 0x29, 0x51, 0x89, 0xb2, 0x38, 0x2d, 0xff, 0x39, 0x6a, 0xb8, 0x9c, 0x28, 0x95, 0xa4, 0x9c, 0xb2, + 0x5c, 0x50, 0x26, 0xa5, 0x32, 0xcc, 0x08, 0x25, 0xb5, 0x47, 0x71, 0x9d, 0x92, 0xed, 0xe9, 0xf0, + 0x45, 0x96, 0x09, 0xa9, 0xa8, 0xfd, 0xf5, 0xa5, 0xab, 0xb1, 0xd2, 0x99, 0xd2, 0x8f, 0x9d, 0x92, + 0xfb, 0x70, 0x50, 0xb4, 0x04, 0xd1, 0xfd, 0xd2, 0xe5, 0x16, 0x2b, 0x58, 0xa6, 0xb7, 0xf9, 0xee, + 0x98, 0x6b, 0x13, 0x3d, 0x84, 0x9d, 0x3f, 0xaa, 0x3a, 0x57, 0x52, 0x73, 0x74, 0x1b, 0xb6, 0x72, + 0x5b, 0xb9, 0x02, 0x56, 0x41, 0xff, 0xfc, 0xb0, 0x4b, 0x6a, 0x86, 0x22, 0xee, 0xd0, 0xa8, 0x7d, + 0x70, 0xd4, 0x0b, 0xde, 0xfd, 0xfc, 0xb0, 0x0e, 0xb6, 0xfd, 0xa9, 0xe8, 0x32, 0xbc, 0x68, 0xdb, + 0xde, 0x95, 0x4f, 0x53, 0x3b, 0xd3, 0x5c, 0x4f, 0xc2, 0x4b, 0x55, 0xc0, 0x4b, 0x3e, 0x80, 0x6d, + 0x31, 0x2f, 0x5a, 0xd5, 0x0b, 0xa3, 0x5b, 0x65, 0xe3, 0x6f, 0x47, 0xbd, 0xae, 0x1b, 0x44, 0x3f, + 0x79, 0x4e, 0x84, 0xa2, 0x19, 0x33, 0xcf, 0xc8, 0x3d, 0x9e, 0xb0, 0x78, 0xb2, 0xc9, 0xe3, 0xcf, + 0x1f, 0x37, 0xa0, 0x9f, 0x73, 0x93, 0xc7, 0xce, 0xc5, 0xef, 0x46, 0x11, 0x86, 0xcb, 0x56, 0xef, + 0x8e, 0x94, 0x63, 0x96, 0x6e, 0x15, 0x6a, 0x4f, 0xe8, 0x72, 0xc5, 0x73, 0x3f, 0xaf, 0x00, 0x5c, + 0x69, 0x20, 0x78, 0x5f, 0x31, 0x5c, 0x64, 0x16, 0x2b, 0x97, 0xea, 0xc1, 0x53, 0xfa, 0x5b, 0x60, + 0x15, 0xb1, 0xe1, 0xa7, 0xb3, 0xf0, 0x9c, 0xb5, 0x81, 0x5e, 0x00, 0xd8, 0x72, 0x7b, 0x45, 0xd7, + 0x6b, 0x97, 0x7e, 0x32, 0xc4, 0xb0, 0xff, 0x77, 0xa2, 0x1b, 0x26, 0xba, 0xf6, 0xf2, 0xcb, 0x8f, + 0xb7, 0x67, 0x56, 0x50, 0xd7, 0xdf, 0x0d, 0x77, 0xb3, 0xf6, 0x06, 0x3b, 0xdc, 0xb0, 0x01, 0x75, + 0xe1, 0xa1, 0xd7, 0x00, 0xb6, 0x8f, 0xf3, 0x41, 0xeb, 0xcd, 0xcd, 0xab, 0xe9, 0x86, 0x37, 0xfe, + 0x89, 0xeb, 0xbd, 0xac, 0x59, 0x2f, 0xab, 0x08, 0xd7, 0x7a, 0x39, 0x8e, 0x10, 0xbd, 0x07, 0x70, + 0xa1, 0x9a, 0x0e, 0x1a, 0x34, 0x2b, 0x35, 0x44, 0x1d, 0x0e, 0xff, 0xe7, 0x88, 0xf7, 0x48, 0xac, + 0xc7, 0x3e, 0x5a, 0xab, 0xf5, 0x78, 0xe2, 0x5e, 0x8c, 0x36, 0x0e, 0xa6, 0x18, 0x1c, 0x4e, 0x31, + 0xf8, 0x3e, 0xc5, 0xe0, 0xcd, 0x0c, 0x07, 0x87, 0x33, 0x1c, 0x7c, 0x9d, 0xe1, 0xe0, 0x51, 0xa7, + 0xe6, 0x31, 0xef, 0xb4, 0xec, 0xd3, 0xbc, 0xf9, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x1a, 0xf6, 0x69, + 0xa1, 0x54, 0x04, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Params returns the total set of minting parameters. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Inflation returns the current minting inflation value. + Inflation(ctx context.Context, in *QueryInflationRequest, opts ...grpc.CallOption) (*QueryInflationResponse, error) + // AnnualProvisions current minting annual provisions value. + AnnualProvisions(ctx context.Context, in *QueryAnnualProvisionsRequest, opts ...grpc.CallOption) (*QueryAnnualProvisionsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/client.x.mint.types.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Inflation(ctx context.Context, in *QueryInflationRequest, opts ...grpc.CallOption) (*QueryInflationResponse, error) { + out := new(QueryInflationResponse) + err := c.cc.Invoke(ctx, "/client.x.mint.types.Query/Inflation", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) AnnualProvisions(ctx context.Context, in *QueryAnnualProvisionsRequest, opts ...grpc.CallOption) (*QueryAnnualProvisionsResponse, error) { + out := new(QueryAnnualProvisionsResponse) + err := c.cc.Invoke(ctx, "/client.x.mint.types.Query/AnnualProvisions", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params returns the total set of minting parameters. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Inflation returns the current minting inflation value. + Inflation(context.Context, *QueryInflationRequest) (*QueryInflationResponse, error) + // AnnualProvisions current minting annual provisions value. + AnnualProvisions(context.Context, *QueryAnnualProvisionsRequest) (*QueryAnnualProvisionsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) Inflation(ctx context.Context, req *QueryInflationRequest) (*QueryInflationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Inflation not implemented") +} +func (*UnimplementedQueryServer) AnnualProvisions(ctx context.Context, req *QueryAnnualProvisionsRequest) (*QueryAnnualProvisionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AnnualProvisions not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/client.x.mint.types.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Inflation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryInflationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Inflation(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/client.x.mint.types.Query/Inflation", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Inflation(ctx, req.(*QueryInflationRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_AnnualProvisions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAnnualProvisionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AnnualProvisions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/client.x.mint.types.Query/AnnualProvisions", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AnnualProvisions(ctx, req.(*QueryAnnualProvisionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "client.x.mint.types.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Inflation", + Handler: _Query_Inflation_Handler, + }, + { + MethodName: "AnnualProvisions", + Handler: _Query_AnnualProvisions_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "client/x/mint/types/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryInflationRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryInflationRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryInflationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryInflationResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryInflationResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryInflationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Inflation.Size() + i -= size + if _, err := m.Inflation.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryAnnualProvisionsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAnnualProvisionsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAnnualProvisionsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryAnnualProvisionsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAnnualProvisionsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAnnualProvisionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.AnnualProvisions.Size() + i -= size + if _, err := m.AnnualProvisions.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryInflationRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryInflationResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Inflation.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAnnualProvisionsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryAnnualProvisionsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.AnnualProvisions.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryInflationRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryInflationRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryInflationRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryInflationResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryInflationResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryInflationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Inflation", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Inflation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAnnualProvisionsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAnnualProvisionsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAnnualProvisionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAnnualProvisionsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAnnualProvisionsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAnnualProvisionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AnnualProvisions", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AnnualProvisions.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/client/x/mint/types/query.pb.gw.go b/client/x/mint/types/query.pb.gw.go new file mode 100644 index 00000000..7ed551a6 --- /dev/null +++ b/client/x/mint/types/query.pb.gw.go @@ -0,0 +1,283 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: cosmos/mint/v1beta1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Inflation_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryInflationRequest + var metadata runtime.ServerMetadata + + msg, err := client.Inflation(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Inflation_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryInflationRequest + var metadata runtime.ServerMetadata + + msg, err := server.Inflation(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_AnnualProvisions_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAnnualProvisionsRequest + var metadata runtime.ServerMetadata + + msg, err := client.AnnualProvisions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AnnualProvisions_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAnnualProvisionsRequest + var metadata runtime.ServerMetadata + + msg, err := server.AnnualProvisions(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Inflation_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Inflation_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Inflation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AnnualProvisions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_AnnualProvisions_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AnnualProvisions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Inflation_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Inflation_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Inflation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AnnualProvisions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_AnnualProvisions_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AnnualProvisions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "mint", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Inflation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "mint", "v1beta1", "inflation"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_AnnualProvisions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "mint", "v1beta1", "annual_provisions"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Inflation_0 = runtime.ForwardResponseMessage + + forward_Query_AnnualProvisions_0 = runtime.ForwardResponseMessage +) diff --git a/client/x/mint/types/query.proto b/client/x/mint/types/query.proto new file mode 100644 index 00000000..d8b77103 --- /dev/null +++ b/client/x/mint/types/query.proto @@ -0,0 +1,68 @@ +syntax = "proto3"; +package client.x.mint.types; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "client/x/mint/types/mint.proto"; +import "amino/amino.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "client/x/mint/types"; + +// Query provides defines the gRPC querier service. +service Query { + // Params returns the total set of minting parameters. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/params"; + } + + // Inflation returns the current minting inflation value. + rpc Inflation(QueryInflationRequest) returns (QueryInflationResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/inflation"; + } + + // AnnualProvisions current minting annual provisions value. + rpc AnnualProvisions(QueryAnnualProvisionsRequest) returns (QueryAnnualProvisionsResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/annual_provisions"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params defines the parameters of the module. + Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} + +// QueryInflationRequest is the request type for the Query/Inflation RPC method. +message QueryInflationRequest {} + +// QueryInflationResponse is the response type for the Query/Inflation RPC +// method. +message QueryInflationResponse { + // inflation is the current minting inflation value. + bytes inflation = 1 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; +} + +// QueryAnnualProvisionsRequest is the request type for the +// Query/AnnualProvisions RPC method. +message QueryAnnualProvisionsRequest {} + +// QueryAnnualProvisionsResponse is the response type for the +// Query/AnnualProvisions RPC method. +message QueryAnnualProvisionsResponse { + // annual_provisions is the current minting annual provisions value. + bytes annual_provisions = 1 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; +} diff --git a/client/x/mint/types/tx.pb.go b/client/x/mint/types/tx.pb.go new file mode 100644 index 00000000..fd49a22a --- /dev/null +++ b/client/x/mint/types/tx.pb.go @@ -0,0 +1,605 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: client/x/mint/types/tx.proto + +package types + +import ( + context "context" + 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/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" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgUpdateParams is the Msg/UpdateParams request type. +// +// Since: cosmos-sdk 0.47 +type MsgUpdateParams struct { + // 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"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_7c916c0799b3044c, []int{0} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +// +// Since: cosmos-sdk 0.47 +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7c916c0799b3044c, []int{1} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUpdateParams)(nil), "client.x.mint.types.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "client.x.mint.types.MsgUpdateParamsResponse") +} + +func init() { proto.RegisterFile("client/x/mint/types/tx.proto", fileDescriptor_7c916c0799b3044c) } + +var fileDescriptor_7c916c0799b3044c = []byte{ + // 331 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xce, 0xc9, 0x4c, + 0xcd, 0x2b, 0xd1, 0xaf, 0xd0, 0xcf, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, + 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xc8, 0xea, 0x55, 0xe8, 0x81, + 0x64, 0xf5, 0xc0, 0xb2, 0x52, 0xe2, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xfa, 0xb9, 0xc5, 0xe9, + 0xfa, 0x65, 0x86, 0x20, 0x0a, 0xa2, 0x5a, 0x4a, 0x30, 0x31, 0x37, 0x33, 0x2f, 0x5f, 0x1f, 0x4c, + 0x42, 0x85, 0xe4, 0xb0, 0x19, 0x0f, 0x36, 0x0b, 0x22, 0x2f, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x66, + 0xea, 0x83, 0x58, 0x50, 0x51, 0x49, 0x88, 0x0d, 0xf1, 0x10, 0x09, 0x08, 0x07, 0x22, 0xa5, 0xb4, + 0x9f, 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, 0x46, 0xc7, 0x94, + 0x94, 0xa2, 0xd4, 0xe2, 0xe2, 0xe0, 0x92, 0xa2, 0xcc, 0xbc, 0xf4, 0x20, 0x84, 0x52, 0x21, 0x3b, + 0x2e, 0xb6, 0x02, 0xb0, 0x09, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0xd2, 0x7a, 0x58, 0xbc, + 0xab, 0x07, 0xb1, 0xc4, 0x89, 0xf3, 0xc4, 0x3d, 0x79, 0x86, 0x15, 0xcf, 0x37, 0x68, 0x31, 0x06, + 0x41, 0x75, 0x59, 0x99, 0x34, 0x3d, 0xdf, 0xa0, 0x85, 0x30, 0xaf, 0xeb, 0xf9, 0x06, 0x2d, 0x45, + 0x88, 0x9d, 0xba, 0xc5, 0x29, 0xd9, 0x30, 0x3f, 0xa3, 0xb9, 0x56, 0x49, 0x92, 0x4b, 0x1c, 0x4d, + 0x28, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0xd5, 0xa8, 0x80, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, + 0x28, 0x89, 0x8b, 0x07, 0xc5, 0x7f, 0x2a, 0x58, 0xdd, 0x85, 0x66, 0x88, 0x94, 0x0e, 0x31, 0xaa, + 0x60, 0x56, 0x49, 0xb1, 0x36, 0x80, 0xbc, 0xe2, 0xa4, 0x7b, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, + 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, + 0xc7, 0x72, 0x0c, 0x51, 0xc2, 0x58, 0x62, 0x2e, 0x89, 0x0d, 0x1c, 0x09, 0xc6, 0x80, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xfa, 0xa4, 0x7e, 0xfe, 0x36, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// 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 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 msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/client.x.mint.types.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// 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) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +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.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/client.x.mint.types.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "client.x.mint.types.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "client/x/mint/types/tx.proto", +} + +func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/client/x/mint/types/tx.proto b/client/x/mint/types/tx.proto new file mode 100644 index 00000000..47bce31e --- /dev/null +++ b/client/x/mint/types/tx.proto @@ -0,0 +1,43 @@ +syntax = "proto3"; +package client.x.mint.types; + +option go_package = "client/x/mint/types"; + +import "cosmos/msg/v1/msg.proto"; +import "amino/amino.proto"; +import "client/x/mint/types/mint.proto"; +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; + +// 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 is the Msg/UpdateParams request type. +// +// Since: cosmos-sdk 0.47 +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + 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, (amino.dont_omitempty) = true]; +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +// +// Since: cosmos-sdk 0.47 +message MsgUpdateParamsResponse {} diff --git a/go.mod b/go.mod index 3c36fe7a..0d310872 100644 --- a/go.mod +++ b/go.mod @@ -129,8 +129,8 @@ require ( github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.2.0 // indirect - github.com/golang/mock v1.6.0 // indirect - github.com/golang/protobuf v1.5.4 // indirect + github.com/golang/mock v1.6.0 + github.com/golang/protobuf v1.5.4 github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/btree v1.1.2 // indirect github.com/google/cel-go v0.20.1 // indirect From 3d07bd724ea76af2ef3de842f9bac971db8e0bd8 Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Wed, 2 Oct 2024 20:28:47 -0700 Subject: [PATCH 02/14] feat(mint): port mint module from cosmos sdk v0.50.7 --- client/app/app_config.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/app/app_config.go b/client/app/app_config.go index f4371670..8e4fc0cc 100644 --- a/client/app/app_config.go +++ b/client/app/app_config.go @@ -9,7 +9,6 @@ import ( distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" govmodulev1 "cosmossdk.io/api/cosmos/gov/module/v1" - mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1" slashingmodulev1 "cosmossdk.io/api/cosmos/slashing/module/v1" stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1" @@ -35,6 +34,7 @@ import ( evmenginetypes "github.com/piplabs/story/client/x/evmengine/types" evmstakingmodule "github.com/piplabs/story/client/x/evmstaking/module" evmstakingtypes "github.com/piplabs/story/client/x/evmstaking/types" + mintmodule "github.com/piplabs/story/client/x/mint/module" minttypes "github.com/piplabs/story/client/x/mint/types" ) @@ -82,13 +82,13 @@ var ( stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, - minttypes.ModuleName, genutiltypes.ModuleName, upgradetypes.ModuleName, // Story modules epochstypes.ModuleName, evmenginetypes.ModuleName, evmstakingtypes.ModuleName, + minttypes.ModuleName, } // NOTE: upgrade module must come first, as upgrades might break state schema. @@ -215,7 +215,7 @@ var ( }, { Name: minttypes.ModuleName, - Config: appconfig.WrapAny(&mintmodulev1.Module{}), + Config: appconfig.WrapAny(&mintmodule.Module{}), }, }, }) From 67374f2b1dc911a97cb27c3c58f08fa99bdbe33d Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Wed, 2 Oct 2024 21:02:41 -0700 Subject: [PATCH 03/14] feat(mint): port mint module from cosmos sdk v0.50.7 --- client/x/mint/module/module.go | 6 +--- client/x/mint/types/mint.pb.go | 54 ++++++++++++++-------------- client/x/mint/types/mint.proto | 2 +- client/x/mint/types/query.pb.go | 64 ++++++++++++++++----------------- client/x/mint/types/query.proto | 6 ++-- client/x/mint/types/tx.pb.go | 20 +++++------ client/x/mint/types/tx.proto | 2 +- 7 files changed, 75 insertions(+), 79 deletions(-) diff --git a/client/x/mint/module/module.go b/client/x/mint/module/module.go index 64cb8cf4..4b90071d 100644 --- a/client/x/mint/module/module.go +++ b/client/x/mint/module/module.go @@ -71,11 +71,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingCo } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the mint module. -func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) { - if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { - panic(err) - } -} +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {} // AppModule implements an application module for the mint module. type AppModule struct { diff --git a/client/x/mint/types/mint.pb.go b/client/x/mint/types/mint.pb.go index c115de0c..3c045235 100644 --- a/client/x/mint/types/mint.pb.go +++ b/client/x/mint/types/mint.pb.go @@ -138,34 +138,34 @@ func init() { func init() { proto.RegisterFile("client/x/mint/types/mint.proto", fileDescriptor_9c6e60aec58f52af) } var fileDescriptor_9c6e60aec58f52af = []byte{ - // 423 bytes of a gzipped FileDescriptorProto + // 418 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xc1, 0x8a, 0x13, 0x31, - 0x18, 0xc7, 0x27, 0xee, 0x3a, 0xd0, 0xe8, 0xa2, 0x9b, 0x2a, 0x8c, 0x2b, 0x3b, 0xbb, 0xf4, 0x20, - 0xa5, 0xd0, 0x19, 0x44, 0xf0, 0xe0, 0xb1, 0xf6, 0x68, 0xb1, 0xcc, 0x45, 0x54, 0x70, 0xf8, 0x3a, - 0x13, 0xa7, 0xb1, 0x33, 0x49, 0x49, 0xa2, 0x4c, 0x5f, 0xc1, 0x93, 0x8f, 0xe1, 0xb1, 0x07, 0x2f, - 0xbe, 0x41, 0x8f, 0xc5, 0x93, 0x78, 0x28, 0xd2, 0x1e, 0x7a, 0xf2, 0x1d, 0x64, 0x92, 0x3a, 0x05, - 0xf1, 0xa2, 0xf5, 0x12, 0xbe, 0xfc, 0xff, 0xe1, 0xf7, 0xfd, 0x49, 0xf2, 0x61, 0x3f, 0xc9, 0x19, - 0xe5, 0x3a, 0x2c, 0xc3, 0x82, 0x71, 0x1d, 0xea, 0xd9, 0x94, 0x2a, 0x53, 0x06, 0x53, 0x29, 0xb4, - 0x20, 0x4d, 0xeb, 0x07, 0x65, 0x60, 0x44, 0xe3, 0x9f, 0xdd, 0xca, 0x44, 0x26, 0x8c, 0x1f, 0x56, - 0x95, 0x3d, 0x7a, 0x76, 0x27, 0x11, 0xaa, 0x10, 0x2a, 0xb6, 0x86, 0xdd, 0xec, 0xac, 0x53, 0x28, - 0x18, 0x17, 0xa1, 0x59, 0xad, 0xd4, 0xfa, 0x8c, 0xb0, 0x3b, 0x60, 0x5c, 0x53, 0x49, 0x9e, 0xe2, - 0x06, 0xe3, 0xaf, 0x73, 0xd0, 0x4c, 0x70, 0x0f, 0x5d, 0xa2, 0x76, 0xa3, 0x77, 0x7f, 0xb1, 0xba, - 0x70, 0xbe, 0xad, 0x2e, 0xee, 0x5a, 0x8c, 0x4a, 0x27, 0x01, 0x13, 0x61, 0x01, 0x7a, 0x1c, 0x3c, - 0xa1, 0x19, 0x24, 0xb3, 0x3e, 0x4d, 0xbe, 0x7c, 0xea, 0xe2, 0x5d, 0x97, 0x3e, 0x4d, 0xa2, 0x3d, - 0x83, 0xbc, 0xc2, 0xa7, 0xc0, 0xf9, 0x5b, 0xc8, 0xab, 0x2c, 0xef, 0x98, 0x62, 0x82, 0x2b, 0xef, - 0xca, 0xbf, 0x82, 0x6f, 0x5a, 0xd6, 0xb0, 0x46, 0xb5, 0x7e, 0x1c, 0x61, 0x77, 0x08, 0x12, 0x0a, - 0x45, 0xce, 0x31, 0xae, 0x2e, 0x26, 0x4e, 0x29, 0x17, 0x85, 0x0d, 0x1f, 0x35, 0x2a, 0xa5, 0x5f, - 0x09, 0xe4, 0x0d, 0xbe, 0x5d, 0xc7, 0x8a, 0x25, 0x68, 0x1a, 0x27, 0x63, 0xe0, 0x19, 0xdd, 0xa5, - 0x79, 0xf8, 0xd7, 0x69, 0x3e, 0x6e, 0xe7, 0x1d, 0x14, 0x35, 0x6b, 0x68, 0x04, 0x9a, 0x3e, 0x36, - 0x48, 0xf2, 0x12, 0x9f, 0xec, 0x7b, 0x15, 0x50, 0x7a, 0x47, 0x07, 0xf5, 0xb8, 0x5e, 0xc3, 0x06, - 0x50, 0xfe, 0x06, 0x67, 0xdc, 0x3b, 0xfe, 0x5f, 0x70, 0xc6, 0xc9, 0x33, 0x7c, 0x2d, 0x13, 0x90, - 0xc7, 0x23, 0xc1, 0x53, 0x9a, 0x7a, 0x57, 0x0f, 0x42, 0xe3, 0x0a, 0xd5, 0x33, 0x24, 0x72, 0x0f, - 0xdf, 0x18, 0xe5, 0x22, 0x99, 0xa8, 0x78, 0x4a, 0x65, 0x3c, 0xa3, 0x20, 0x3d, 0xf7, 0x12, 0xb5, - 0x8f, 0xa3, 0x13, 0x2b, 0x0f, 0xa9, 0x7c, 0x4e, 0x41, 0x3e, 0x3a, 0x7f, 0xbf, 0x9d, 0x77, 0x3c, - 0x4b, 0xea, 0xaa, 0x74, 0xf2, 0x6b, 0x1c, 0xec, 0x23, 0xf7, 0xba, 0x8b, 0xb5, 0x8f, 0x96, 0x6b, - 0x1f, 0x7d, 0x5f, 0xfb, 0xe8, 0xc3, 0xc6, 0x77, 0x96, 0x1b, 0xdf, 0xf9, 0xba, 0xf1, 0x9d, 0x17, - 0xcd, 0x3f, 0x8c, 0xcf, 0xc8, 0x35, 0x3f, 0xfc, 0xc1, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x28, - 0x7a, 0x3e, 0xa7, 0x5c, 0x03, 0x00, 0x00, + 0x18, 0xc7, 0x27, 0xee, 0x3a, 0xd0, 0xe8, 0xa2, 0x9b, 0xae, 0x30, 0xbb, 0xe2, 0xec, 0xb2, 0x07, + 0x29, 0x85, 0xce, 0x20, 0x82, 0x07, 0x8f, 0xb5, 0x47, 0x8b, 0x65, 0x2e, 0xa2, 0x82, 0xc3, 0xd7, + 0x99, 0x38, 0x8d, 0x9d, 0x49, 0x4a, 0x12, 0x65, 0xfa, 0x0a, 0x9e, 0x7c, 0x0c, 0x8f, 0x3d, 0x78, + 0xf1, 0x0d, 0x7a, 0x2c, 0x9e, 0xc4, 0x43, 0x91, 0xf6, 0x50, 0x7c, 0x0b, 0x99, 0xa4, 0x4c, 0x51, + 0xbc, 0x68, 0xf7, 0x12, 0xbe, 0xfc, 0xff, 0xe1, 0xf7, 0xfd, 0x49, 0xf2, 0x61, 0x3f, 0xc9, 0x19, + 0xe5, 0x3a, 0x2c, 0xc3, 0x82, 0x71, 0x1d, 0xea, 0xe9, 0x84, 0x2a, 0x53, 0x06, 0x13, 0x29, 0xb4, + 0x20, 0x4d, 0xeb, 0x07, 0x65, 0x60, 0x44, 0xe3, 0x9f, 0x9d, 0x64, 0x22, 0x13, 0xc6, 0x0f, 0xab, + 0xca, 0x1e, 0x3d, 0x3b, 0x4d, 0x84, 0x2a, 0x84, 0x8a, 0xad, 0x61, 0x37, 0x5b, 0xeb, 0x18, 0x0a, + 0xc6, 0x45, 0x68, 0x56, 0x2b, 0x5d, 0x7e, 0x41, 0xd8, 0xed, 0x33, 0xae, 0xa9, 0x24, 0xcf, 0x70, + 0x83, 0xf1, 0x37, 0x39, 0x68, 0x26, 0xb8, 0x87, 0x2e, 0x50, 0xab, 0xd1, 0x7d, 0x30, 0x5f, 0x9e, + 0x3b, 0xdf, 0x97, 0xe7, 0x77, 0x2d, 0x46, 0xa5, 0xe3, 0x80, 0x89, 0xb0, 0x00, 0x3d, 0x0a, 0x9e, + 0xd2, 0x0c, 0x92, 0x69, 0x8f, 0x26, 0x5f, 0x3f, 0x77, 0xf0, 0xb6, 0x4b, 0x8f, 0x26, 0xd1, 0x8e, + 0x41, 0x5e, 0xe3, 0x63, 0xe0, 0xfc, 0x1d, 0xe4, 0x55, 0x96, 0xf7, 0x4c, 0x31, 0xc1, 0x95, 0x77, + 0xed, 0x7f, 0xc1, 0xb7, 0x2d, 0x6b, 0x50, 0xa3, 0x2e, 0x7f, 0x1e, 0x60, 0x77, 0x00, 0x12, 0x0a, + 0x45, 0xee, 0x61, 0x5c, 0x5d, 0x4c, 0x9c, 0x52, 0x2e, 0x0a, 0x1b, 0x3e, 0x6a, 0x54, 0x4a, 0xaf, + 0x12, 0xc8, 0x5b, 0x7c, 0xa7, 0x8e, 0x15, 0x4b, 0xd0, 0x34, 0x4e, 0x46, 0xc0, 0x33, 0xba, 0x4d, + 0xf3, 0xe8, 0x9f, 0xd3, 0x7c, 0xda, 0xcc, 0xda, 0x28, 0x6a, 0xd6, 0xd0, 0x08, 0x34, 0x7d, 0x62, + 0x90, 0xe4, 0x15, 0x3e, 0xda, 0xf5, 0x2a, 0xa0, 0xf4, 0x0e, 0xf6, 0xea, 0x71, 0xb3, 0x86, 0xf5, + 0xa1, 0xfc, 0x03, 0xce, 0xb8, 0x77, 0x78, 0x55, 0x70, 0xc6, 0xc9, 0x73, 0x7c, 0x23, 0x13, 0x90, + 0xc7, 0x43, 0xc1, 0x53, 0x9a, 0x7a, 0xd7, 0xf7, 0x42, 0xe3, 0x0a, 0xd5, 0x35, 0x24, 0x72, 0x1f, + 0xdf, 0x1a, 0xe6, 0x22, 0x19, 0xab, 0x78, 0x42, 0x65, 0x3c, 0xa5, 0x20, 0x3d, 0xf7, 0x02, 0xb5, + 0x0e, 0xa3, 0x23, 0x2b, 0x0f, 0xa8, 0x7c, 0x41, 0x41, 0x3e, 0x3e, 0xfd, 0xb0, 0x99, 0xb5, 0x4f, + 0x7e, 0x1f, 0x05, 0xfb, 0xc0, 0xdd, 0xce, 0x7c, 0xe5, 0xa3, 0xc5, 0xca, 0x47, 0x3f, 0x56, 0x3e, + 0xfa, 0xb8, 0xf6, 0x9d, 0xc5, 0xda, 0x77, 0xbe, 0xad, 0x7d, 0xe7, 0x65, 0xf3, 0x2f, 0xa3, 0x33, + 0x74, 0xcd, 0xef, 0x7e, 0xf8, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xac, 0xa1, 0x1b, 0xe6, 0x58, 0x03, + 0x00, 0x00, } func (m *Minter) Marshal() (dAtA []byte, err error) { diff --git a/client/x/mint/types/mint.proto b/client/x/mint/types/mint.proto index 72354d5f..81a3d587 100644 --- a/client/x/mint/types/mint.proto +++ b/client/x/mint/types/mint.proto @@ -25,7 +25,7 @@ message Minter { // Params defines the parameters for the x/mint module. message Params { - option (amino.name) = "cosmos-sdk/x/mint/Params"; + option (amino.name) = "client/x/mint/Params"; // type of coin to mint string mint_denom = 1; diff --git a/client/x/mint/types/query.pb.go b/client/x/mint/types/query.pb.go index 4459954b..23a1be15 100644 --- a/client/x/mint/types/query.pb.go +++ b/client/x/mint/types/query.pb.go @@ -282,38 +282,38 @@ func init() { func init() { proto.RegisterFile("client/x/mint/types/query.proto", fileDescriptor_a6d4efab0120ffa4) } var fileDescriptor_a6d4efab0120ffa4 = []byte{ - // 485 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xcf, 0x6b, 0x14, 0x31, - 0x18, 0x9d, 0x28, 0x2e, 0x6c, 0xf4, 0xd0, 0x66, 0xeb, 0xaf, 0xd9, 0x36, 0x5b, 0x46, 0xa8, 0x4b, - 0xa5, 0x09, 0xbb, 0x82, 0x47, 0xc1, 0xa5, 0x17, 0xc1, 0x43, 0x2d, 0x7a, 0xf1, 0x22, 0xe9, 0x18, - 0xc7, 0xe0, 0x4c, 0x32, 0x9d, 0x64, 0x4b, 0xf7, 0x26, 0xe2, 0xd1, 0x83, 0xe0, 0x3f, 0xa1, 0x37, - 0x0f, 0xfe, 0x0b, 0x42, 0x8f, 0x45, 0x2f, 0xe2, 0xa1, 0xc8, 0xae, 0xe0, 0xbf, 0x21, 0x93, 0x64, - 0x2b, 0x4e, 0x67, 0x50, 0xe9, 0x65, 0xd9, 0xf9, 0xde, 0xcb, 0xf7, 0xde, 0xf7, 0xbd, 0x04, 0xf6, - 0xe2, 0x54, 0x70, 0x69, 0xe8, 0x3e, 0xcd, 0x84, 0x34, 0xd4, 0x4c, 0x72, 0xae, 0xe9, 0xee, 0x98, - 0x17, 0x13, 0x92, 0x17, 0xca, 0x28, 0xd4, 0x71, 0x04, 0xb2, 0x4f, 0x4a, 0x02, 0xb1, 0x84, 0x70, - 0x29, 0x51, 0x89, 0xb2, 0x38, 0x2d, 0xff, 0x39, 0x6a, 0xb8, 0x9c, 0x28, 0x95, 0xa4, 0x9c, 0xb2, - 0x5c, 0x50, 0x26, 0xa5, 0x32, 0xcc, 0x08, 0x25, 0xb5, 0x47, 0x71, 0x9d, 0x92, 0xed, 0xe9, 0xf0, - 0x45, 0x96, 0x09, 0xa9, 0xa8, 0xfd, 0xf5, 0xa5, 0xab, 0xb1, 0xd2, 0x99, 0xd2, 0x8f, 0x9d, 0x92, - 0xfb, 0x70, 0x50, 0xb4, 0x04, 0xd1, 0xfd, 0xd2, 0xe5, 0x16, 0x2b, 0x58, 0xa6, 0xb7, 0xf9, 0xee, - 0x98, 0x6b, 0x13, 0x3d, 0x84, 0x9d, 0x3f, 0xaa, 0x3a, 0x57, 0x52, 0x73, 0x74, 0x1b, 0xb6, 0x72, - 0x5b, 0xb9, 0x02, 0x56, 0x41, 0xff, 0xfc, 0xb0, 0x4b, 0x6a, 0x86, 0x22, 0xee, 0xd0, 0xa8, 0x7d, - 0x70, 0xd4, 0x0b, 0xde, 0xfd, 0xfc, 0xb0, 0x0e, 0xb6, 0xfd, 0xa9, 0xe8, 0x32, 0xbc, 0x68, 0xdb, - 0xde, 0x95, 0x4f, 0x53, 0x3b, 0xd3, 0x5c, 0x4f, 0xc2, 0x4b, 0x55, 0xc0, 0x4b, 0x3e, 0x80, 0x6d, - 0x31, 0x2f, 0x5a, 0xd5, 0x0b, 0xa3, 0x5b, 0x65, 0xe3, 0x6f, 0x47, 0xbd, 0xae, 0x1b, 0x44, 0x3f, - 0x79, 0x4e, 0x84, 0xa2, 0x19, 0x33, 0xcf, 0xc8, 0x3d, 0x9e, 0xb0, 0x78, 0xb2, 0xc9, 0xe3, 0xcf, - 0x1f, 0x37, 0xa0, 0x9f, 0x73, 0x93, 0xc7, 0xce, 0xc5, 0xef, 0x46, 0x11, 0x86, 0xcb, 0x56, 0xef, - 0x8e, 0x94, 0x63, 0x96, 0x6e, 0x15, 0x6a, 0x4f, 0xe8, 0x72, 0xc5, 0x73, 0x3f, 0xaf, 0x00, 0x5c, - 0x69, 0x20, 0x78, 0x5f, 0x31, 0x5c, 0x64, 0x16, 0x2b, 0x97, 0xea, 0xc1, 0x53, 0xfa, 0x5b, 0x60, - 0x15, 0xb1, 0xe1, 0xa7, 0xb3, 0xf0, 0x9c, 0xb5, 0x81, 0x5e, 0x00, 0xd8, 0x72, 0x7b, 0x45, 0xd7, - 0x6b, 0x97, 0x7e, 0x32, 0xc4, 0xb0, 0xff, 0x77, 0xa2, 0x1b, 0x26, 0xba, 0xf6, 0xf2, 0xcb, 0x8f, - 0xb7, 0x67, 0x56, 0x50, 0xd7, 0xdf, 0x0d, 0x77, 0xb3, 0xf6, 0x06, 0x3b, 0xdc, 0xb0, 0x01, 0x75, - 0xe1, 0xa1, 0xd7, 0x00, 0xb6, 0x8f, 0xf3, 0x41, 0xeb, 0xcd, 0xcd, 0xab, 0xe9, 0x86, 0x37, 0xfe, - 0x89, 0xeb, 0xbd, 0xac, 0x59, 0x2f, 0xab, 0x08, 0xd7, 0x7a, 0x39, 0x8e, 0x10, 0xbd, 0x07, 0x70, - 0xa1, 0x9a, 0x0e, 0x1a, 0x34, 0x2b, 0x35, 0x44, 0x1d, 0x0e, 0xff, 0xe7, 0x88, 0xf7, 0x48, 0xac, - 0xc7, 0x3e, 0x5a, 0xab, 0xf5, 0x78, 0xe2, 0x5e, 0x8c, 0x36, 0x0e, 0xa6, 0x18, 0x1c, 0x4e, 0x31, - 0xf8, 0x3e, 0xc5, 0xe0, 0xcd, 0x0c, 0x07, 0x87, 0x33, 0x1c, 0x7c, 0x9d, 0xe1, 0xe0, 0x51, 0xa7, - 0xe6, 0x31, 0xef, 0xb4, 0xec, 0xd3, 0xbc, 0xf9, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x1a, 0xf6, 0x69, - 0xa1, 0x54, 0x04, 0x00, 0x00, + // 482 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0x41, 0x6b, 0x14, 0x31, + 0x18, 0x9d, 0x28, 0x2e, 0x6c, 0xf4, 0xd0, 0x66, 0x6b, 0x6d, 0x67, 0x6b, 0xd6, 0x8e, 0x07, 0x6b, + 0xa5, 0x09, 0x5d, 0xc1, 0xa3, 0xe0, 0xd2, 0x8b, 0xe0, 0xa1, 0x16, 0xbd, 0x78, 0x91, 0x38, 0xc6, + 0x31, 0x38, 0x93, 0x4c, 0x27, 0xd9, 0xd2, 0xc5, 0x9b, 0x08, 0x5e, 0x05, 0xff, 0x82, 0x07, 0x8f, + 0x1e, 0xf4, 0x3f, 0xf4, 0x58, 0xf4, 0x22, 0x1e, 0x8a, 0xec, 0x0a, 0xfe, 0x0d, 0x99, 0x24, 0xbb, + 0xe2, 0xec, 0x0c, 0x2a, 0x5e, 0x96, 0x9d, 0xef, 0xbd, 0x7c, 0xef, 0x7d, 0xdf, 0x4b, 0x60, 0x2f, + 0x4e, 0x05, 0x97, 0x86, 0x1e, 0xd2, 0x4c, 0x48, 0x43, 0xcd, 0x28, 0xe7, 0x9a, 0xee, 0x0f, 0x79, + 0x31, 0x22, 0x79, 0xa1, 0x8c, 0x42, 0x1d, 0x47, 0x20, 0x87, 0xa4, 0x24, 0x10, 0x4b, 0x08, 0x97, + 0x12, 0x95, 0x28, 0x8b, 0xd3, 0xf2, 0x9f, 0xa3, 0x86, 0x6b, 0x89, 0x52, 0x49, 0xca, 0x29, 0xcb, + 0x05, 0x65, 0x52, 0x2a, 0xc3, 0x8c, 0x50, 0x52, 0x7b, 0x14, 0xd7, 0x29, 0xd9, 0x9e, 0x0e, 0x5f, + 0x64, 0x99, 0x90, 0x8a, 0xda, 0x5f, 0x5f, 0x5a, 0x8d, 0x95, 0xce, 0x94, 0x7e, 0xe8, 0x94, 0xdc, + 0x87, 0x83, 0xa2, 0x25, 0x88, 0xee, 0x96, 0x2e, 0x77, 0x59, 0xc1, 0x32, 0xbd, 0xc7, 0xf7, 0x87, + 0x5c, 0x9b, 0xe8, 0x3e, 0xec, 0xfc, 0x56, 0xd5, 0xb9, 0x92, 0x9a, 0xa3, 0x9b, 0xb0, 0x95, 0xdb, + 0xca, 0x0a, 0xb8, 0x04, 0x36, 0xce, 0xf6, 0xbb, 0xa4, 0x66, 0x28, 0xe2, 0x0e, 0x0d, 0xda, 0x47, + 0x27, 0xbd, 0xe0, 0xdd, 0x8f, 0xf7, 0x9b, 0x60, 0xcf, 0x9f, 0x8a, 0x2e, 0xc0, 0xf3, 0xb6, 0xed, + 0x6d, 0xf9, 0x24, 0xb5, 0x33, 0x4d, 0xf5, 0x24, 0x5c, 0xae, 0x02, 0x5e, 0xf2, 0x1e, 0x6c, 0x8b, + 0x69, 0xd1, 0xaa, 0x9e, 0x1b, 0xdc, 0x28, 0x1b, 0x7f, 0x3d, 0xe9, 0x75, 0xdd, 0x20, 0xfa, 0xf1, + 0x33, 0x22, 0x14, 0xcd, 0x98, 0x79, 0x4a, 0xee, 0xf0, 0x84, 0xc5, 0xa3, 0x1d, 0x1e, 0x7f, 0xfa, + 0xb0, 0x05, 0xfd, 0x9c, 0x3b, 0x3c, 0x76, 0x2e, 0x7e, 0x35, 0x8a, 0x30, 0x5c, 0xb3, 0x7a, 0xb7, + 0xa4, 0x1c, 0xb2, 0x74, 0xb7, 0x50, 0x07, 0x42, 0x97, 0x2b, 0x9e, 0xfa, 0x79, 0x09, 0xe0, 0xc5, + 0x06, 0x82, 0xf7, 0x15, 0xc3, 0x45, 0x66, 0xb1, 0x72, 0xa9, 0x1e, 0xfc, 0x4f, 0x7f, 0x0b, 0xac, + 0x22, 0xd6, 0xff, 0x78, 0x1a, 0x9e, 0xb1, 0x36, 0xd0, 0x73, 0xd8, 0x72, 0x6b, 0x45, 0x57, 0x6a, + 0x77, 0x3e, 0x9f, 0x61, 0xb8, 0xf1, 0x67, 0xa2, 0x9b, 0x25, 0xc2, 0x2f, 0x3e, 0x7f, 0x7f, 0x73, + 0x6a, 0x05, 0x2d, 0x53, 0x7f, 0xb5, 0xec, 0xc5, 0x3a, 0xd8, 0xa6, 0x2e, 0x36, 0xf4, 0x0a, 0xc0, + 0xf6, 0x2c, 0x19, 0xb4, 0xd9, 0xdc, 0xb7, 0x9a, 0x6b, 0x78, 0xed, 0xaf, 0xb8, 0xde, 0xc6, 0xba, + 0xb5, 0xd1, 0x45, 0xab, 0x55, 0x1b, 0xb3, 0xdc, 0xd0, 0x5b, 0x00, 0x17, 0xaa, 0x91, 0xa0, 0xed, + 0x66, 0x91, 0x86, 0x7c, 0xc3, 0xfe, 0xbf, 0x1c, 0xf1, 0xf6, 0xae, 0x5a, 0x7b, 0x97, 0xd1, 0x7a, + 0xd5, 0xde, 0xdc, 0x3d, 0x18, 0x6c, 0x1d, 0x8d, 0x31, 0x38, 0x1e, 0x63, 0xf0, 0x6d, 0x8c, 0xc1, + 0xeb, 0x09, 0x0e, 0x8e, 0x27, 0x38, 0xf8, 0x32, 0xc1, 0xc1, 0x83, 0x4e, 0xcd, 0xe3, 0x7d, 0xd4, + 0xb2, 0x4f, 0xf1, 0xfa, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd2, 0xb2, 0xf7, 0xd3, 0x44, 0x04, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/client/x/mint/types/query.proto b/client/x/mint/types/query.proto index d8b77103..e3fa38ef 100644 --- a/client/x/mint/types/query.proto +++ b/client/x/mint/types/query.proto @@ -13,17 +13,17 @@ option go_package = "client/x/mint/types"; service Query { // Params returns the total set of minting parameters. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/cosmos/mint/v1beta1/params"; + option (google.api.http).get = "/client/mint/v1/params"; } // Inflation returns the current minting inflation value. rpc Inflation(QueryInflationRequest) returns (QueryInflationResponse) { - option (google.api.http).get = "/cosmos/mint/v1beta1/inflation"; + option (google.api.http).get = "/client/mint/v1/inflation"; } // AnnualProvisions current minting annual provisions value. rpc AnnualProvisions(QueryAnnualProvisionsRequest) returns (QueryAnnualProvisionsResponse) { - option (google.api.http).get = "/cosmos/mint/v1beta1/annual_provisions"; + option (google.api.http).get = "/client/mint/v1/annual_provisions"; } } diff --git a/client/x/mint/types/tx.pb.go b/client/x/mint/types/tx.pb.go index fd49a22a..d0a68220 100644 --- a/client/x/mint/types/tx.pb.go +++ b/client/x/mint/types/tx.pb.go @@ -138,7 +138,7 @@ func init() { func init() { proto.RegisterFile("client/x/mint/types/tx.proto", fileDescriptor_7c916c0799b3044c) } var fileDescriptor_7c916c0799b3044c = []byte{ - // 331 bytes of a gzipped FileDescriptorProto + // 325 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0xaf, 0xd0, 0xcf, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xc8, 0xea, 0x55, 0xe8, 0x81, @@ -146,20 +146,20 @@ var fileDescriptor_7c916c0799b3044c = []byte{ 0xfa, 0x65, 0x86, 0x20, 0x0a, 0xa2, 0x5a, 0x4a, 0x30, 0x31, 0x37, 0x33, 0x2f, 0x5f, 0x1f, 0x4c, 0x42, 0x85, 0xe4, 0xb0, 0x19, 0x0f, 0x36, 0x0b, 0x22, 0x2f, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x66, 0xea, 0x83, 0x58, 0x50, 0x51, 0x49, 0x88, 0x0d, 0xf1, 0x10, 0x09, 0x08, 0x07, 0x22, 0xa5, 0xb4, - 0x9f, 0x91, 0x8b, 0xdf, 0xb7, 0x38, 0x3d, 0xb4, 0x20, 0x25, 0xb1, 0x24, 0x35, 0x20, 0xb1, 0x28, + 0x9b, 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, 0x46, 0xc7, 0x94, 0x94, 0xa2, 0xd4, 0xe2, 0xe2, 0xe0, 0x92, 0xa2, 0xcc, 0xbc, 0xf4, 0x20, 0x84, 0x52, 0x21, 0x3b, 0x2e, 0xb6, 0x02, 0xb0, 0x09, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0xd2, 0x7a, 0x58, 0xbc, 0xab, 0x07, 0xb1, 0xc4, 0x89, 0xf3, 0xc4, 0x3d, 0x79, 0x86, 0x15, 0xcf, 0x37, 0x68, 0x31, 0x06, - 0x41, 0x75, 0x59, 0x99, 0x34, 0x3d, 0xdf, 0xa0, 0x85, 0x30, 0xaf, 0xeb, 0xf9, 0x06, 0x2d, 0x45, - 0x88, 0x9d, 0xba, 0xc5, 0x29, 0xd9, 0x30, 0x3f, 0xa3, 0xb9, 0x56, 0x49, 0x92, 0x4b, 0x1c, 0x4d, - 0x28, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0xd5, 0xa8, 0x80, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, - 0x28, 0x89, 0x8b, 0x07, 0xc5, 0x7f, 0x2a, 0x58, 0xdd, 0x85, 0x66, 0x88, 0x94, 0x0e, 0x31, 0xaa, - 0x60, 0x56, 0x49, 0xb1, 0x36, 0x80, 0xbc, 0xe2, 0xa4, 0x7b, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, - 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, - 0xc7, 0x72, 0x0c, 0x51, 0xc2, 0x58, 0x62, 0x2e, 0x89, 0x0d, 0x1c, 0x09, 0xc6, 0x80, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xfa, 0xa4, 0x7e, 0xfe, 0x36, 0x02, 0x00, 0x00, + 0x41, 0x75, 0x59, 0x19, 0x34, 0x3d, 0xdf, 0xa0, 0x85, 0x30, 0xaf, 0xeb, 0xf9, 0x06, 0x2d, 0x59, + 0x54, 0xff, 0xa2, 0xb9, 0x54, 0x49, 0x92, 0x4b, 0x1c, 0x4d, 0x28, 0x28, 0xb5, 0xb8, 0x20, 0x3f, + 0xaf, 0x38, 0xd5, 0xa8, 0x80, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0x28, 0x89, 0x8b, 0x07, 0xc5, 0x6f, + 0x2a, 0x58, 0xdd, 0x84, 0x66, 0x88, 0x94, 0x0e, 0x31, 0xaa, 0x60, 0x56, 0x49, 0xb1, 0x36, 0x80, + 0xbc, 0xe1, 0xa4, 0x7b, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, + 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xc2, 0x58, + 0x62, 0x2d, 0x89, 0x0d, 0x1c, 0x01, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x99, 0xe2, + 0xc9, 0x32, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/client/x/mint/types/tx.proto b/client/x/mint/types/tx.proto index 47bce31e..3d29c21b 100644 --- a/client/x/mint/types/tx.proto +++ b/client/x/mint/types/tx.proto @@ -25,7 +25,7 @@ service Msg { // Since: cosmos-sdk 0.47 message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; - option (amino.name) = "cosmos-sdk/x/mint/MsgUpdateParams"; + option (amino.name) = "client/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"]; From 4e0dda6a32244b3af94aa4ff6b6a0bbf0ee2d23a Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Wed, 2 Oct 2024 21:05:11 -0700 Subject: [PATCH 04/14] feat(mint): port mint module from cosmos sdk v0.50.7 --- client/x/mint/types/query.pb.gw.go | 283 ----------------------------- 1 file changed, 283 deletions(-) delete mode 100644 client/x/mint/types/query.pb.gw.go diff --git a/client/x/mint/types/query.pb.gw.go b/client/x/mint/types/query.pb.gw.go deleted file mode 100644 index 7ed551a6..00000000 --- a/client/x/mint/types/query.pb.gw.go +++ /dev/null @@ -1,283 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: cosmos/mint/v1beta1/query.proto - -/* -Package types is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package types - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := server.Params(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_Inflation_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryInflationRequest - var metadata runtime.ServerMetadata - - msg, err := client.Inflation(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Inflation_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryInflationRequest - var metadata runtime.ServerMetadata - - msg, err := server.Inflation(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_AnnualProvisions_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAnnualProvisionsRequest - var metadata runtime.ServerMetadata - - msg, err := client.AnnualProvisions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_AnnualProvisions_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAnnualProvisionsRequest - var metadata runtime.ServerMetadata - - msg, err := server.AnnualProvisions(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_Inflation_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Inflation_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Inflation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_AnnualProvisions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_AnnualProvisions_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_AnnualProvisions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_Inflation_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Inflation_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Inflation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_AnnualProvisions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_AnnualProvisions_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_AnnualProvisions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "mint", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_Inflation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "mint", "v1beta1", "inflation"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_AnnualProvisions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "mint", "v1beta1", "annual_provisions"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage - - forward_Query_Inflation_0 = runtime.ForwardResponseMessage - - forward_Query_AnnualProvisions_0 = runtime.ForwardResponseMessage -) From 61b1f92508e509fc8e9e0adc293cdf32d42887a3 Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Wed, 2 Oct 2024 21:55:28 -0700 Subject: [PATCH 05/14] feat(mint): remove useless parameters --- client/x/mint/keeper/genesis_test.go | 2 +- client/x/mint/keeper/grpc_query.go | 20 - client/x/mint/keeper/grpc_query_test.go | 12 - client/x/mint/keeper/keeper.go | 11 - client/x/mint/keeper/keeper_test.go | 5 - client/x/mint/keeper/msg_server.go | 42 -- client/x/mint/keeper/msg_server_test.go | 74 --- client/x/mint/keeper/params.go | 19 + client/x/mint/module/depinject.go | 8 - client/x/mint/module/module.go | 1 - client/x/mint/module/module.proto | 3 - client/x/mint/module/module.pulsar.go | 115 +--- client/x/mint/types/codec.go | 8 +- client/x/mint/types/query.pb.go | 706 +----------------------- client/x/mint/types/query.proto | 42 -- client/x/mint/types/tx.pb.go | 605 -------------------- client/x/mint/types/tx.proto | 43 -- 17 files changed, 60 insertions(+), 1656 deletions(-) delete mode 100644 client/x/mint/keeper/msg_server.go delete mode 100644 client/x/mint/keeper/msg_server_test.go create mode 100644 client/x/mint/keeper/params.go delete mode 100644 client/x/mint/types/tx.pb.go delete mode 100644 client/x/mint/types/tx.proto diff --git a/client/x/mint/keeper/genesis_test.go b/client/x/mint/keeper/genesis_test.go index 31238544..b66e29de 100644 --- a/client/x/mint/keeper/genesis_test.go +++ b/client/x/mint/keeper/genesis_test.go @@ -57,7 +57,7 @@ func (s *GenesisTestSuite) SetupTest() { accountKeeper.EXPECT().GetModuleAddress(minterAcc.Name).Return(minterAcc.GetAddress()) accountKeeper.EXPECT().GetModuleAccount(s.sdkCtx, minterAcc.Name).Return(minterAcc) - s.keeper = keeper.NewKeeper(s.cdc, runtime.NewKVStoreService(key), stakingKeeper, accountKeeper, bankKeeper, "", "") + s.keeper = keeper.NewKeeper(s.cdc, runtime.NewKVStoreService(key), stakingKeeper, accountKeeper, bankKeeper, "") } func (s *GenesisTestSuite) TestImportExportGenesis() { diff --git a/client/x/mint/keeper/grpc_query.go b/client/x/mint/keeper/grpc_query.go index 9908ac65..1a677391 100644 --- a/client/x/mint/keeper/grpc_query.go +++ b/client/x/mint/keeper/grpc_query.go @@ -25,23 +25,3 @@ func (q queryServer) Params(ctx context.Context, _ *types.QueryParamsRequest) (* return &types.QueryParamsResponse{Params: params}, nil } - -// Inflation returns minter.Inflation of the mint module. -func (q queryServer) Inflation(ctx context.Context, _ *types.QueryInflationRequest) (*types.QueryInflationResponse, error) { - minter, err := q.k.Minter.Get(ctx) - if err != nil { - return nil, err - } - - return &types.QueryInflationResponse{Inflation: minter.Inflation}, nil -} - -// AnnualProvisions returns minter.AnnualProvisions of the mint module. -func (q queryServer) AnnualProvisions(ctx context.Context, _ *types.QueryAnnualProvisionsRequest) (*types.QueryAnnualProvisionsResponse, error) { - minter, err := q.k.Minter.Get(ctx) - if err != nil { - return nil, err - } - - return &types.QueryAnnualProvisionsResponse{AnnualProvisions: minter.AnnualProvisions}, nil -} diff --git a/client/x/mint/keeper/grpc_query_test.go b/client/x/mint/keeper/grpc_query_test.go index a2582f38..07f315b4 100644 --- a/client/x/mint/keeper/grpc_query_test.go +++ b/client/x/mint/keeper/grpc_query_test.go @@ -13,7 +13,6 @@ import ( 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/golang/mock/gomock" "github.com/stretchr/testify/suite" @@ -53,7 +52,6 @@ func (suite *MintTestSuite) SetupTest() { accountKeeper, bankKeeper, authtypes.FeeCollectorName, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) err := suite.mintKeeper.Params.Set(suite.ctx, types.DefaultParams()) @@ -72,16 +70,6 @@ func (suite *MintTestSuite) TestGRPCParams() { kparams, err := suite.mintKeeper.Params.Get(suite.ctx) suite.Require().NoError(err) suite.Require().Equal(params.Params, kparams) - - inflation, err := suite.queryClient.Inflation(gocontext.Background(), &types.QueryInflationRequest{}) - suite.Require().NoError(err) - minter, err := suite.mintKeeper.Minter.Get(suite.ctx) - suite.Require().NoError(err) - suite.Require().Equal(inflation.Inflation, minter.Inflation) - - annualProvisions, err := suite.queryClient.AnnualProvisions(gocontext.Background(), &types.QueryAnnualProvisionsRequest{}) - suite.Require().NoError(err) - suite.Require().Equal(annualProvisions.AnnualProvisions, minter.AnnualProvisions) } func TestMintTestSuite(t *testing.T) { diff --git a/client/x/mint/keeper/keeper.go b/client/x/mint/keeper/keeper.go index ef41c925..ab61740e 100644 --- a/client/x/mint/keeper/keeper.go +++ b/client/x/mint/keeper/keeper.go @@ -24,10 +24,6 @@ type Keeper struct { bankKeeper types.BankKeeper feeCollectorName string - // the address capable of executing a MsgUpdateParams message. Typically, this - // should be the x/gov module account. - authority string - Schema collections.Schema Params collections.Item[types.Params] Minter collections.Item[types.Minter] @@ -41,7 +37,6 @@ func NewKeeper( 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 { @@ -55,7 +50,6 @@ func NewKeeper( stakingKeeper: sk, bankKeeper: bk, feeCollectorName: feeCollectorName, - authority: authority, Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), Minter: collections.NewItem(sb, types.MinterKey, "minter", codec.CollValue[types.Minter](cdc)), } @@ -69,11 +63,6 @@ func NewKeeper( return k } -// GetAuthority returns the x/mint module's authority. -func (k Keeper) GetAuthority() string { - return k.authority -} - // Logger returns a module-specific logger. func (k Keeper) Logger(ctx context.Context) log.Logger { sdkCtx := sdk.UnwrapSDKContext(ctx) diff --git a/client/x/mint/keeper/keeper_test.go b/client/x/mint/keeper/keeper_test.go index 7d28732d..15c90b24 100644 --- a/client/x/mint/keeper/keeper_test.go +++ b/client/x/mint/keeper/keeper_test.go @@ -12,7 +12,6 @@ import ( 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/golang/mock/gomock" "github.com/stretchr/testify/suite" @@ -27,7 +26,6 @@ type IntegrationTestSuite struct { mintKeeper keeper.Keeper ctx sdk.Context - msgServer types.MsgServer stakingKeeper *minttestutil.MockStakingKeeper bankKeeper *minttestutil.MockBankKeeper } @@ -58,7 +56,6 @@ func (s *IntegrationTestSuite) SetupTest() { accountKeeper, bankKeeper, authtypes.FeeCollectorName, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) s.stakingKeeper = stakingKeeper s.bankKeeper = bankKeeper @@ -69,8 +66,6 @@ func (s *IntegrationTestSuite) SetupTest() { err := s.mintKeeper.Params.Set(s.ctx, types.DefaultParams()) s.Require().NoError(err) s.Require().NoError(s.mintKeeper.Minter.Set(s.ctx, types.DefaultInitialMinter())) - - s.msgServer = keeper.NewMsgServerImpl(s.mintKeeper) } func (s *IntegrationTestSuite) TestAliasFunctions() { diff --git a/client/x/mint/keeper/msg_server.go b/client/x/mint/keeper/msg_server.go deleted file mode 100644 index ab122e2e..00000000 --- a/client/x/mint/keeper/msg_server.go +++ /dev/null @@ -1,42 +0,0 @@ -package keeper - -import ( - "context" - - "cosmossdk.io/errors" - - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - - "github.com/piplabs/story/client/x/mint/types" -) - -var _ types.MsgServer = msgServer{} - -// msgServer is a wrapper of Keeper. -type msgServer struct { - Keeper -} - -// NewMsgServerImpl returns an implementation of the x/mint MsgServer interface. -func NewMsgServerImpl(k Keeper) types.MsgServer { - return &msgServer{ - Keeper: k, - } -} - -// UpdateParams updates the params. -func (ms msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { - if ms.authority != msg.Authority { - return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.authority, msg.Authority) - } - - if err := msg.Params.Validate(); err != nil { - return nil, err - } - - if err := ms.Params.Set(ctx, msg.Params); err != nil { - return nil, err - } - - return &types.MsgUpdateParamsResponse{}, nil -} diff --git a/client/x/mint/keeper/msg_server_test.go b/client/x/mint/keeper/msg_server_test.go deleted file mode 100644 index dd97ec10..00000000 --- a/client/x/mint/keeper/msg_server_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package keeper_test - -import ( - sdkmath "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/piplabs/story/client/x/mint/types" -) - -func (s *IntegrationTestSuite) TestUpdateParams() { - testCases := []struct { - name string - request *types.MsgUpdateParams - expectErr bool - }{ - { - name: "set invalid authority (not an address)", - request: &types.MsgUpdateParams{ - Authority: "foo", - }, - expectErr: true, - }, - { - name: "set invalid authority (not defined authority)", - request: &types.MsgUpdateParams{ - // pragma: allowlist secret - Authority: "cosmos139f7kncmglres2nf3h4hc4tade85ekfr8sulz5", // pragma: allowlist secret - }, - expectErr: true, - }, - { - name: "set invalid params", - request: &types.MsgUpdateParams{ - Authority: s.mintKeeper.GetAuthority(), - Params: types.Params{ - MintDenom: sdk.DefaultBondDenom, - InflationRateChange: sdkmath.LegacyNewDecWithPrec(-13, 2), - InflationMax: sdkmath.LegacyNewDecWithPrec(20, 2), - InflationMin: sdkmath.LegacyNewDecWithPrec(7, 2), - GoalBonded: sdkmath.LegacyNewDecWithPrec(67, 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, - InflationRateChange: sdkmath.LegacyNewDecWithPrec(8, 2), - InflationMax: sdkmath.LegacyNewDecWithPrec(20, 2), - InflationMin: sdkmath.LegacyNewDecWithPrec(2, 2), - GoalBonded: sdkmath.LegacyNewDecWithPrec(37, 2), - BlocksPerYear: uint64(60 * 60 * 8766 / 5), - }, - }, - expectErr: false, - }, - } - - for _, tc := range testCases { - 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/client/x/mint/keeper/params.go b/client/x/mint/keeper/params.go new file mode 100644 index 00000000..fa615d34 --- /dev/null +++ b/client/x/mint/keeper/params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + "github.com/piplabs/story/client/x/mint/types" +) + +func (k Keeper) GetParams(ctx context.Context) (types.Params, error) { + return k.Params.Get(ctx) +} + +func (k Keeper) SetParams(ctx context.Context, value types.Params) error { + if err := value.Validate(); err != nil { + return err + } + + return k.Params.Set(ctx, value) +} diff --git a/client/x/mint/module/depinject.go b/client/x/mint/module/depinject.go index e4496fa3..c1ef3699 100644 --- a/client/x/mint/module/depinject.go +++ b/client/x/mint/module/depinject.go @@ -8,7 +8,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/piplabs/story/client/x/mint/keeper" "github.com/piplabs/story/client/x/mint/types" @@ -57,12 +56,6 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { feeCollectorName = authtypes.FeeCollectorName } - // default to governance authority if not provided - authority := authtypes.NewModuleAddress(govtypes.ModuleName) - if in.Config.GetAuthority() != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.GetAuthority()) - } - k := keeper.NewKeeper( in.Cdc, in.StoreService, @@ -70,7 +63,6 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { in.AccountKeeper, in.BankKeeper, feeCollectorName, - authority.String(), ) // when no inflation calculation function is provided it will use the default types.DefaultInflationCalculationFn diff --git a/client/x/mint/module/module.go b/client/x/mint/module/module.go index 4b90071d..d03db0ec 100644 --- a/client/x/mint/module/module.go +++ b/client/x/mint/module/module.go @@ -108,7 +108,6 @@ func NewAppModule( // RegisterServices registers a gRPC query service to respond to the // module-specific gRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper)) } diff --git a/client/x/mint/module/module.proto b/client/x/mint/module/module.proto index a41c163b..de949a56 100644 --- a/client/x/mint/module/module.proto +++ b/client/x/mint/module/module.proto @@ -13,7 +13,4 @@ message Module { }; string fee_collector_name = 1; - - // authority defines the custom module authority. If not set, defaults to the governance module. - string authority = 2; } \ No newline at end of file diff --git a/client/x/mint/module/module.pulsar.go b/client/x/mint/module/module.pulsar.go index 76566e81..a8015ade 100644 --- a/client/x/mint/module/module.pulsar.go +++ b/client/x/mint/module/module.pulsar.go @@ -16,14 +16,12 @@ import ( var ( md_Module protoreflect.MessageDescriptor fd_Module_fee_collector_name protoreflect.FieldDescriptor - fd_Module_authority protoreflect.FieldDescriptor ) func init() { file_client_x_mint_module_module_proto_init() md_Module = File_client_x_mint_module_module_proto.Messages().ByName("Module") fd_Module_fee_collector_name = md_Module.Fields().ByName("fee_collector_name") - fd_Module_authority = md_Module.Fields().ByName("authority") } var _ protoreflect.Message = (*fastReflection_Module)(nil) @@ -97,12 +95,6 @@ func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, proto return } } - if x.Authority != "" { - value := protoreflect.ValueOfString(x.Authority) - if !f(fd_Module_authority, value) { - return - } - } } // Has reports whether a field is populated. @@ -120,8 +112,6 @@ func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { case "client.x.mint.module.Module.fee_collector_name": return x.FeeCollectorName != "" - case "client.x.mint.module.Module.authority": - return x.Authority != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: client.x.mint.module.Module")) @@ -140,8 +130,6 @@ func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { case "client.x.mint.module.Module.fee_collector_name": x.FeeCollectorName = "" - case "client.x.mint.module.Module.authority": - x.Authority = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: client.x.mint.module.Module")) @@ -161,9 +149,6 @@ func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) pro case "client.x.mint.module.Module.fee_collector_name": value := x.FeeCollectorName return protoreflect.ValueOfString(value) - case "client.x.mint.module.Module.authority": - value := x.Authority - return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: client.x.mint.module.Module")) @@ -186,8 +171,6 @@ func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value proto switch fd.FullName() { case "client.x.mint.module.Module.fee_collector_name": x.FeeCollectorName = value.Interface().(string) - case "client.x.mint.module.Module.authority": - x.Authority = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: client.x.mint.module.Module")) @@ -210,8 +193,6 @@ func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protore switch fd.FullName() { case "client.x.mint.module.Module.fee_collector_name": panic(fmt.Errorf("field fee_collector_name of message client.x.mint.module.Module is not mutable")) - case "client.x.mint.module.Module.authority": - panic(fmt.Errorf("field authority of message client.x.mint.module.Module is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: client.x.mint.module.Module")) @@ -227,8 +208,6 @@ func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protor switch fd.FullName() { case "client.x.mint.module.Module.fee_collector_name": return protoreflect.ValueOfString("") - case "client.x.mint.module.Module.authority": - return protoreflect.ValueOfString("") default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: client.x.mint.module.Module")) @@ -302,10 +281,6 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - l = len(x.Authority) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -335,13 +310,6 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.Authority) > 0 { - i -= len(x.Authority) - copy(dAtA[i:], x.Authority) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Authority))) - i-- - dAtA[i] = 0x12 - } if len(x.FeeCollectorName) > 0 { i -= len(x.FeeCollectorName) copy(dAtA[i:], x.FeeCollectorName) @@ -430,38 +398,6 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { } x.FeeCollectorName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -517,8 +453,6 @@ type Module struct { unknownFields protoimpl.UnknownFields FeeCollectorName string `protobuf:"bytes,1,opt,name=fee_collector_name,json=feeCollectorName,proto3" json:"fee_collector_name,omitempty"` - // authority defines the custom module authority. If not set, defaults to the governance module. - Authority string `protobuf:"bytes,2,opt,name=authority,proto3" json:"authority,omitempty"` } func (x *Module) Reset() { @@ -548,13 +482,6 @@ func (x *Module) GetFeeCollectorName() string { return "" } -func (x *Module) GetAuthority() string { - if x != nil { - return x.Authority - } - return "" -} - var File_client_x_mint_module_module_proto protoreflect.FileDescriptor var file_client_x_mint_module_module_proto_rawDesc = []byte{ @@ -563,28 +490,26 @@ var file_client_x_mint_module_module_proto_rawDesc = []byte{ 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x78, 0x2e, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x1a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, - 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x84, 0x01, 0x0a, 0x06, - 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x2c, 0x0a, 0x12, 0x66, 0x65, 0x65, 0x5f, 0x63, 0x6f, - 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x10, 0x66, 0x65, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, - 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, - 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, - 0x74, 0x79, 0x3a, 0x2e, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x28, 0x0a, 0x26, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x69, 0x70, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x73, - 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x78, 0x2f, 0x6d, 0x69, - 0x6e, 0x74, 0x42, 0xc2, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x2e, 0x78, 0x2e, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x42, - 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x25, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x78, 0x2f, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x6d, - 0x6f, 0x64, 0x75, 0x6c, 0x65, 0xa2, 0x02, 0x04, 0x43, 0x58, 0x4d, 0x4d, 0xaa, 0x02, 0x14, 0x43, - 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x58, 0x2e, 0x4d, 0x69, 0x6e, 0x74, 0x2e, 0x4d, 0x6f, 0x64, - 0x75, 0x6c, 0x65, 0xca, 0x02, 0x14, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x58, 0x5c, 0x4d, - 0x69, 0x6e, 0x74, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0xe2, 0x02, 0x20, 0x43, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x5c, 0x58, 0x5c, 0x4d, 0x69, 0x6e, 0x74, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, - 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x17, - 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3a, 0x3a, 0x58, 0x3a, 0x3a, 0x4d, 0x69, 0x6e, 0x74, 0x3a, - 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x66, 0x0a, 0x06, 0x4d, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x2c, 0x0a, 0x12, 0x66, 0x65, 0x65, 0x5f, 0x63, 0x6f, 0x6c, + 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x10, 0x66, 0x65, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x4e, + 0x61, 0x6d, 0x65, 0x3a, 0x2e, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x28, 0x0a, 0x26, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x69, 0x70, 0x6c, 0x61, 0x62, 0x73, 0x2f, + 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x78, 0x2f, 0x6d, + 0x69, 0x6e, 0x74, 0x42, 0xc2, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x2e, 0x78, 0x2e, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, + 0x25, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x78, 0x2f, 0x6d, 0x69, 0x6e, 0x74, 0x2f, + 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0xa2, 0x02, 0x04, 0x43, 0x58, 0x4d, 0x4d, 0xaa, 0x02, 0x14, + 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x58, 0x2e, 0x4d, 0x69, 0x6e, 0x74, 0x2e, 0x4d, 0x6f, + 0x64, 0x75, 0x6c, 0x65, 0xca, 0x02, 0x14, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x58, 0x5c, + 0x4d, 0x69, 0x6e, 0x74, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0xe2, 0x02, 0x20, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x58, 0x5c, 0x4d, 0x69, 0x6e, 0x74, 0x5c, 0x4d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x17, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3a, 0x3a, 0x58, 0x3a, 0x3a, 0x4d, 0x69, 0x6e, 0x74, + 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/client/x/mint/types/codec.go b/client/x/mint/types/codec.go index 53d87eb6..a3fdb433 100644 --- a/client/x/mint/types/codec.go +++ b/client/x/mint/types/codec.go @@ -2,24 +2,18 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec. func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/mint/Params", nil) - legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/mint/MsgUpdateParams") + cdc.RegisterConcrete(Params{}, "client/x/mint/Params", nil) } // RegisterInterfaces registers the interfaces types with the interface registry. func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), - &MsgUpdateParams{}, ) - - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/client/x/mint/types/query.pb.go b/client/x/mint/types/query.pb.go index 23a1be15..89738614 100644 --- a/client/x/mint/types/query.pb.go +++ b/client/x/mint/types/query.pb.go @@ -5,9 +5,7 @@ package types import ( context "context" - cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -115,205 +113,33 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } -// QueryInflationRequest is the request type for the Query/Inflation RPC method. -type QueryInflationRequest struct { -} - -func (m *QueryInflationRequest) Reset() { *m = QueryInflationRequest{} } -func (m *QueryInflationRequest) String() string { return proto.CompactTextString(m) } -func (*QueryInflationRequest) ProtoMessage() {} -func (*QueryInflationRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a6d4efab0120ffa4, []int{2} -} -func (m *QueryInflationRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryInflationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryInflationRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryInflationRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryInflationRequest.Merge(m, src) -} -func (m *QueryInflationRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryInflationRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryInflationRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryInflationRequest proto.InternalMessageInfo - -// QueryInflationResponse is the response type for the Query/Inflation RPC -// method. -type QueryInflationResponse struct { - // inflation is the current minting inflation value. - Inflation cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=inflation,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation"` -} - -func (m *QueryInflationResponse) Reset() { *m = QueryInflationResponse{} } -func (m *QueryInflationResponse) String() string { return proto.CompactTextString(m) } -func (*QueryInflationResponse) ProtoMessage() {} -func (*QueryInflationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a6d4efab0120ffa4, []int{3} -} -func (m *QueryInflationResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryInflationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryInflationResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryInflationResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryInflationResponse.Merge(m, src) -} -func (m *QueryInflationResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryInflationResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryInflationResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryInflationResponse proto.InternalMessageInfo - -// QueryAnnualProvisionsRequest is the request type for the -// Query/AnnualProvisions RPC method. -type QueryAnnualProvisionsRequest struct { -} - -func (m *QueryAnnualProvisionsRequest) Reset() { *m = QueryAnnualProvisionsRequest{} } -func (m *QueryAnnualProvisionsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAnnualProvisionsRequest) ProtoMessage() {} -func (*QueryAnnualProvisionsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a6d4efab0120ffa4, []int{4} -} -func (m *QueryAnnualProvisionsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAnnualProvisionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAnnualProvisionsRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryAnnualProvisionsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAnnualProvisionsRequest.Merge(m, src) -} -func (m *QueryAnnualProvisionsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryAnnualProvisionsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAnnualProvisionsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAnnualProvisionsRequest proto.InternalMessageInfo - -// QueryAnnualProvisionsResponse is the response type for the -// Query/AnnualProvisions RPC method. -type QueryAnnualProvisionsResponse struct { - // annual_provisions is the current minting annual provisions value. - AnnualProvisions cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=annual_provisions,json=annualProvisions,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"annual_provisions"` -} - -func (m *QueryAnnualProvisionsResponse) Reset() { *m = QueryAnnualProvisionsResponse{} } -func (m *QueryAnnualProvisionsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAnnualProvisionsResponse) ProtoMessage() {} -func (*QueryAnnualProvisionsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a6d4efab0120ffa4, []int{5} -} -func (m *QueryAnnualProvisionsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAnnualProvisionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAnnualProvisionsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryAnnualProvisionsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAnnualProvisionsResponse.Merge(m, src) -} -func (m *QueryAnnualProvisionsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryAnnualProvisionsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAnnualProvisionsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAnnualProvisionsResponse proto.InternalMessageInfo - func init() { proto.RegisterType((*QueryParamsRequest)(nil), "client.x.mint.types.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "client.x.mint.types.QueryParamsResponse") - proto.RegisterType((*QueryInflationRequest)(nil), "client.x.mint.types.QueryInflationRequest") - proto.RegisterType((*QueryInflationResponse)(nil), "client.x.mint.types.QueryInflationResponse") - proto.RegisterType((*QueryAnnualProvisionsRequest)(nil), "client.x.mint.types.QueryAnnualProvisionsRequest") - proto.RegisterType((*QueryAnnualProvisionsResponse)(nil), "client.x.mint.types.QueryAnnualProvisionsResponse") } func init() { proto.RegisterFile("client/x/mint/types/query.proto", fileDescriptor_a6d4efab0120ffa4) } var fileDescriptor_a6d4efab0120ffa4 = []byte{ - // 482 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0x41, 0x6b, 0x14, 0x31, - 0x18, 0x9d, 0x28, 0x2e, 0x6c, 0xf4, 0xd0, 0x66, 0x6b, 0x6d, 0x67, 0x6b, 0xd6, 0x8e, 0x07, 0x6b, - 0xa5, 0x09, 0x5d, 0xc1, 0xa3, 0xe0, 0xd2, 0x8b, 0xe0, 0xa1, 0x16, 0xbd, 0x78, 0x91, 0x38, 0xc6, - 0x31, 0x38, 0x93, 0x4c, 0x27, 0xd9, 0xd2, 0xc5, 0x9b, 0x08, 0x5e, 0x05, 0xff, 0x82, 0x07, 0x8f, - 0x1e, 0xf4, 0x3f, 0xf4, 0x58, 0xf4, 0x22, 0x1e, 0x8a, 0xec, 0x0a, 0xfe, 0x0d, 0x99, 0x24, 0xbb, - 0xe2, 0xec, 0x0c, 0x2a, 0x5e, 0x96, 0x9d, 0xef, 0xbd, 0x7c, 0xef, 0x7d, 0xdf, 0x4b, 0x60, 0x2f, - 0x4e, 0x05, 0x97, 0x86, 0x1e, 0xd2, 0x4c, 0x48, 0x43, 0xcd, 0x28, 0xe7, 0x9a, 0xee, 0x0f, 0x79, - 0x31, 0x22, 0x79, 0xa1, 0x8c, 0x42, 0x1d, 0x47, 0x20, 0x87, 0xa4, 0x24, 0x10, 0x4b, 0x08, 0x97, - 0x12, 0x95, 0x28, 0x8b, 0xd3, 0xf2, 0x9f, 0xa3, 0x86, 0x6b, 0x89, 0x52, 0x49, 0xca, 0x29, 0xcb, - 0x05, 0x65, 0x52, 0x2a, 0xc3, 0x8c, 0x50, 0x52, 0x7b, 0x14, 0xd7, 0x29, 0xd9, 0x9e, 0x0e, 0x5f, - 0x64, 0x99, 0x90, 0x8a, 0xda, 0x5f, 0x5f, 0x5a, 0x8d, 0x95, 0xce, 0x94, 0x7e, 0xe8, 0x94, 0xdc, - 0x87, 0x83, 0xa2, 0x25, 0x88, 0xee, 0x96, 0x2e, 0x77, 0x59, 0xc1, 0x32, 0xbd, 0xc7, 0xf7, 0x87, - 0x5c, 0x9b, 0xe8, 0x3e, 0xec, 0xfc, 0x56, 0xd5, 0xb9, 0x92, 0x9a, 0xa3, 0x9b, 0xb0, 0x95, 0xdb, - 0xca, 0x0a, 0xb8, 0x04, 0x36, 0xce, 0xf6, 0xbb, 0xa4, 0x66, 0x28, 0xe2, 0x0e, 0x0d, 0xda, 0x47, - 0x27, 0xbd, 0xe0, 0xdd, 0x8f, 0xf7, 0x9b, 0x60, 0xcf, 0x9f, 0x8a, 0x2e, 0xc0, 0xf3, 0xb6, 0xed, - 0x6d, 0xf9, 0x24, 0xb5, 0x33, 0x4d, 0xf5, 0x24, 0x5c, 0xae, 0x02, 0x5e, 0xf2, 0x1e, 0x6c, 0x8b, - 0x69, 0xd1, 0xaa, 0x9e, 0x1b, 0xdc, 0x28, 0x1b, 0x7f, 0x3d, 0xe9, 0x75, 0xdd, 0x20, 0xfa, 0xf1, - 0x33, 0x22, 0x14, 0xcd, 0x98, 0x79, 0x4a, 0xee, 0xf0, 0x84, 0xc5, 0xa3, 0x1d, 0x1e, 0x7f, 0xfa, - 0xb0, 0x05, 0xfd, 0x9c, 0x3b, 0x3c, 0x76, 0x2e, 0x7e, 0x35, 0x8a, 0x30, 0x5c, 0xb3, 0x7a, 0xb7, - 0xa4, 0x1c, 0xb2, 0x74, 0xb7, 0x50, 0x07, 0x42, 0x97, 0x2b, 0x9e, 0xfa, 0x79, 0x09, 0xe0, 0xc5, - 0x06, 0x82, 0xf7, 0x15, 0xc3, 0x45, 0x66, 0xb1, 0x72, 0xa9, 0x1e, 0xfc, 0x4f, 0x7f, 0x0b, 0xac, - 0x22, 0xd6, 0xff, 0x78, 0x1a, 0x9e, 0xb1, 0x36, 0xd0, 0x73, 0xd8, 0x72, 0x6b, 0x45, 0x57, 0x6a, - 0x77, 0x3e, 0x9f, 0x61, 0xb8, 0xf1, 0x67, 0xa2, 0x9b, 0x25, 0xc2, 0x2f, 0x3e, 0x7f, 0x7f, 0x73, - 0x6a, 0x05, 0x2d, 0x53, 0x7f, 0xb5, 0xec, 0xc5, 0x3a, 0xd8, 0xa6, 0x2e, 0x36, 0xf4, 0x0a, 0xc0, - 0xf6, 0x2c, 0x19, 0xb4, 0xd9, 0xdc, 0xb7, 0x9a, 0x6b, 0x78, 0xed, 0xaf, 0xb8, 0xde, 0xc6, 0xba, - 0xb5, 0xd1, 0x45, 0xab, 0x55, 0x1b, 0xb3, 0xdc, 0xd0, 0x5b, 0x00, 0x17, 0xaa, 0x91, 0xa0, 0xed, - 0x66, 0x91, 0x86, 0x7c, 0xc3, 0xfe, 0xbf, 0x1c, 0xf1, 0xf6, 0xae, 0x5a, 0x7b, 0x97, 0xd1, 0x7a, - 0xd5, 0xde, 0xdc, 0x3d, 0x18, 0x6c, 0x1d, 0x8d, 0x31, 0x38, 0x1e, 0x63, 0xf0, 0x6d, 0x8c, 0xc1, - 0xeb, 0x09, 0x0e, 0x8e, 0x27, 0x38, 0xf8, 0x32, 0xc1, 0xc1, 0x83, 0x4e, 0xcd, 0xe3, 0x7d, 0xd4, - 0xb2, 0x4f, 0xf1, 0xfa, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd2, 0xb2, 0xf7, 0xd3, 0x44, 0x04, - 0x00, 0x00, + // 279 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xce, 0xc9, 0x4c, + 0xcd, 0x2b, 0xd1, 0xaf, 0xd0, 0xcf, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, + 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0x28, 0xd0, + 0xab, 0xd0, 0x03, 0x29, 0xd0, 0x03, 0x2b, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, + 0x83, 0x58, 0x10, 0xa5, 0x52, 0x32, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x89, 0x05, 0x99, + 0xfa, 0x89, 0x79, 0x79, 0xf9, 0x25, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xc5, 0x50, 0x59, 0x39, 0x6c, + 0x36, 0x81, 0xcd, 0x84, 0xc8, 0x0b, 0x26, 0xe6, 0x66, 0xe6, 0xe5, 0xeb, 0x83, 0x49, 0x88, 0x90, + 0x92, 0x08, 0x97, 0x50, 0x20, 0xc8, 0x29, 0x01, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x41, 0xa9, 0x85, + 0xa5, 0xa9, 0xc5, 0x25, 0x4a, 0xa1, 0x5c, 0xc2, 0x28, 0xa2, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, + 0x42, 0x76, 0x5c, 0x6c, 0x05, 0x60, 0x11, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x69, 0x3d, + 0x2c, 0x2e, 0xd7, 0x83, 0x68, 0x72, 0xe2, 0x3c, 0x71, 0x4f, 0x9e, 0x61, 0xc5, 0xf3, 0x0d, 0x5a, + 0x8c, 0x41, 0x50, 0x5d, 0x46, 0x2d, 0x8c, 0x5c, 0xac, 0x60, 0x73, 0x85, 0xaa, 0xb9, 0xd8, 0x20, + 0xca, 0x84, 0xd4, 0xb1, 0x9a, 0x81, 0xe9, 0x26, 0x29, 0x0d, 0xc2, 0x0a, 0x21, 0xce, 0x54, 0x92, + 0x6b, 0xba, 0xfc, 0x64, 0x32, 0x93, 0x84, 0x90, 0x98, 0x3e, 0x34, 0x3c, 0xc0, 0xa1, 0x51, 0x66, + 0xa8, 0x0f, 0x71, 0x86, 0x93, 0xee, 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, + 0x09, 0x63, 0x09, 0xc0, 0x24, 0x36, 0x70, 0x48, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x33, + 0x4d, 0xc0, 0x75, 0xc8, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -330,10 +156,6 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Params returns the total set of minting parameters. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // Inflation returns the current minting inflation value. - Inflation(ctx context.Context, in *QueryInflationRequest, opts ...grpc.CallOption) (*QueryInflationResponse, error) - // AnnualProvisions current minting annual provisions value. - AnnualProvisions(ctx context.Context, in *QueryAnnualProvisionsRequest, opts ...grpc.CallOption) (*QueryAnnualProvisionsResponse, error) } type queryClient struct { @@ -353,32 +175,10 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } -func (c *queryClient) Inflation(ctx context.Context, in *QueryInflationRequest, opts ...grpc.CallOption) (*QueryInflationResponse, error) { - out := new(QueryInflationResponse) - err := c.cc.Invoke(ctx, "/client.x.mint.types.Query/Inflation", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) AnnualProvisions(ctx context.Context, in *QueryAnnualProvisionsRequest, opts ...grpc.CallOption) (*QueryAnnualProvisionsResponse, error) { - out := new(QueryAnnualProvisionsResponse) - err := c.cc.Invoke(ctx, "/client.x.mint.types.Query/AnnualProvisions", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // QueryServer is the server API for Query service. type QueryServer interface { // Params returns the total set of minting parameters. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // Inflation returns the current minting inflation value. - Inflation(context.Context, *QueryInflationRequest) (*QueryInflationResponse, error) - // AnnualProvisions current minting annual provisions value. - AnnualProvisions(context.Context, *QueryAnnualProvisionsRequest) (*QueryAnnualProvisionsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -388,12 +188,6 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } -func (*UnimplementedQueryServer) Inflation(ctx context.Context, req *QueryInflationRequest) (*QueryInflationResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Inflation not implemented") -} -func (*UnimplementedQueryServer) AnnualProvisions(ctx context.Context, req *QueryAnnualProvisionsRequest) (*QueryAnnualProvisionsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AnnualProvisions not implemented") -} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -417,42 +211,6 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } -func _Query_Inflation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryInflationRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Inflation(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/client.x.mint.types.Query/Inflation", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Inflation(ctx, req.(*QueryInflationRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_AnnualProvisions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAnnualProvisionsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).AnnualProvisions(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/client.x.mint.types.Query/AnnualProvisions", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).AnnualProvisions(ctx, req.(*QueryAnnualProvisionsRequest)) - } - return interceptor(ctx, in, info, handler) -} - var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "client.x.mint.types.Query", HandlerType: (*QueryServer)(nil), @@ -461,14 +219,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, - { - MethodName: "Inflation", - Handler: _Query_Inflation_Handler, - }, - { - MethodName: "AnnualProvisions", - Handler: _Query_AnnualProvisions_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "client/x/mint/types/query.proto", @@ -530,118 +280,6 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryInflationRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryInflationRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryInflationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryInflationResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryInflationResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryInflationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Inflation.Size() - i -= size - if _, err := m.Inflation.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryAnnualProvisionsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryAnnualProvisionsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAnnualProvisionsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryAnnualProvisionsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryAnnualProvisionsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAnnualProvisionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.AnnualProvisions.Size() - i -= size - if _, err := m.AnnualProvisions.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -673,46 +311,6 @@ func (m *QueryParamsResponse) Size() (n int) { return n } -func (m *QueryInflationRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryInflationResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Inflation.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryAnnualProvisionsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryAnnualProvisionsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.AnnualProvisions.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -852,272 +450,6 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryInflationRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryInflationRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryInflationRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryInflationResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryInflationResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryInflationResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Inflation", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Inflation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryAnnualProvisionsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryAnnualProvisionsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAnnualProvisionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryAnnualProvisionsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryAnnualProvisionsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAnnualProvisionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AnnualProvisions", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.AnnualProvisions.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/client/x/mint/types/query.proto b/client/x/mint/types/query.proto index e3fa38ef..c71b49f3 100644 --- a/client/x/mint/types/query.proto +++ b/client/x/mint/types/query.proto @@ -5,7 +5,6 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "client/x/mint/types/mint.proto"; import "amino/amino.proto"; -import "cosmos_proto/cosmos.proto"; option go_package = "client/x/mint/types"; @@ -15,16 +14,6 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/client/mint/v1/params"; } - - // Inflation returns the current minting inflation value. - rpc Inflation(QueryInflationRequest) returns (QueryInflationResponse) { - option (google.api.http).get = "/client/mint/v1/inflation"; - } - - // AnnualProvisions current minting annual provisions value. - rpc AnnualProvisions(QueryAnnualProvisionsRequest) returns (QueryAnnualProvisionsResponse) { - option (google.api.http).get = "/client/mint/v1/annual_provisions"; - } } // QueryParamsRequest is the request type for the Query/Params RPC method. @@ -35,34 +24,3 @@ message QueryParamsResponse { // params defines the parameters of the module. Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } - -// QueryInflationRequest is the request type for the Query/Inflation RPC method. -message QueryInflationRequest {} - -// QueryInflationResponse is the response type for the Query/Inflation RPC -// method. -message QueryInflationResponse { - // inflation is the current minting inflation value. - bytes inflation = 1 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; -} - -// QueryAnnualProvisionsRequest is the request type for the -// Query/AnnualProvisions RPC method. -message QueryAnnualProvisionsRequest {} - -// QueryAnnualProvisionsResponse is the response type for the -// Query/AnnualProvisions RPC method. -message QueryAnnualProvisionsResponse { - // annual_provisions is the current minting annual provisions value. - bytes annual_provisions = 1 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; -} diff --git a/client/x/mint/types/tx.pb.go b/client/x/mint/types/tx.pb.go deleted file mode 100644 index d0a68220..00000000 --- a/client/x/mint/types/tx.pb.go +++ /dev/null @@ -1,605 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: client/x/mint/types/tx.proto - -package types - -import ( - context "context" - 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/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" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// MsgUpdateParams is the Msg/UpdateParams request type. -// -// Since: cosmos-sdk 0.47 -type MsgUpdateParams struct { - // 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"` -} - -func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } -func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParams) ProtoMessage() {} -func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_7c916c0799b3044c, []int{0} -} -func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParams.Merge(m, src) -} -func (m *MsgUpdateParams) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParams) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo - -func (m *MsgUpdateParams) GetAuthority() string { - if m != nil { - return m.Authority - } - return "" -} - -func (m *MsgUpdateParams) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -// MsgUpdateParamsResponse defines the response structure for executing a -// MsgUpdateParams message. -// -// Since: cosmos-sdk 0.47 -type MsgUpdateParamsResponse struct { -} - -func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } -func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParamsResponse) ProtoMessage() {} -func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7c916c0799b3044c, []int{1} -} -func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) -} -func (m *MsgUpdateParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*MsgUpdateParams)(nil), "client.x.mint.types.MsgUpdateParams") - proto.RegisterType((*MsgUpdateParamsResponse)(nil), "client.x.mint.types.MsgUpdateParamsResponse") -} - -func init() { proto.RegisterFile("client/x/mint/types/tx.proto", fileDescriptor_7c916c0799b3044c) } - -var fileDescriptor_7c916c0799b3044c = []byte{ - // 325 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xce, 0xc9, 0x4c, - 0xcd, 0x2b, 0xd1, 0xaf, 0xd0, 0xcf, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, - 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xc8, 0xea, 0x55, 0xe8, 0x81, - 0x64, 0xf5, 0xc0, 0xb2, 0x52, 0xe2, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xfa, 0xb9, 0xc5, 0xe9, - 0xfa, 0x65, 0x86, 0x20, 0x0a, 0xa2, 0x5a, 0x4a, 0x30, 0x31, 0x37, 0x33, 0x2f, 0x5f, 0x1f, 0x4c, - 0x42, 0x85, 0xe4, 0xb0, 0x19, 0x0f, 0x36, 0x0b, 0x22, 0x2f, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x66, - 0xea, 0x83, 0x58, 0x50, 0x51, 0x49, 0x88, 0x0d, 0xf1, 0x10, 0x09, 0x08, 0x07, 0x22, 0xa5, 0xb4, - 0x9b, 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, 0x46, 0xc7, 0x94, - 0x94, 0xa2, 0xd4, 0xe2, 0xe2, 0xe0, 0x92, 0xa2, 0xcc, 0xbc, 0xf4, 0x20, 0x84, 0x52, 0x21, 0x3b, - 0x2e, 0xb6, 0x02, 0xb0, 0x09, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0xd2, 0x7a, 0x58, 0xbc, - 0xab, 0x07, 0xb1, 0xc4, 0x89, 0xf3, 0xc4, 0x3d, 0x79, 0x86, 0x15, 0xcf, 0x37, 0x68, 0x31, 0x06, - 0x41, 0x75, 0x59, 0x19, 0x34, 0x3d, 0xdf, 0xa0, 0x85, 0x30, 0xaf, 0xeb, 0xf9, 0x06, 0x2d, 0x59, - 0x54, 0xff, 0xa2, 0xb9, 0x54, 0x49, 0x92, 0x4b, 0x1c, 0x4d, 0x28, 0x28, 0xb5, 0xb8, 0x20, 0x3f, - 0xaf, 0x38, 0xd5, 0xa8, 0x80, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0x28, 0x89, 0x8b, 0x07, 0xc5, 0x6f, - 0x2a, 0x58, 0xdd, 0x84, 0x66, 0x88, 0x94, 0x0e, 0x31, 0xaa, 0x60, 0x56, 0x49, 0xb1, 0x36, 0x80, - 0xbc, 0xe1, 0xa4, 0x7b, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, - 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xc2, 0x58, - 0x62, 0x2d, 0x89, 0x0d, 0x1c, 0x01, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x99, 0xe2, - 0xc9, 0x32, 0x02, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// 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 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 msgClient struct { - cc grpc1.ClientConn -} - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} -} - -func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { - out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, "/client.x.mint.types.Msg/UpdateParams", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// 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) -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} - -func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") -} - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} - -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.(MsgServer).UpdateParams(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/client.x.mint.types.Msg/UpdateParams", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "client.x.mint.types.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "UpdateParams", - Handler: _Msg_UpdateParams_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "client/x/mint/types/tx.proto", -} - -func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgUpdateParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Params.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgUpdateParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTx(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTx - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTx - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTx - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") -) diff --git a/client/x/mint/types/tx.proto b/client/x/mint/types/tx.proto deleted file mode 100644 index 3d29c21b..00000000 --- a/client/x/mint/types/tx.proto +++ /dev/null @@ -1,43 +0,0 @@ -syntax = "proto3"; -package client.x.mint.types; - -option go_package = "client/x/mint/types"; - -import "cosmos/msg/v1/msg.proto"; -import "amino/amino.proto"; -import "client/x/mint/types/mint.proto"; -import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; - -// 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 is the Msg/UpdateParams request type. -// -// Since: cosmos-sdk 0.47 -message MsgUpdateParams { - option (cosmos.msg.v1.signer) = "authority"; - option (amino.name) = "client/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, (amino.dont_omitempty) = true]; -} - -// MsgUpdateParamsResponse defines the response structure for executing a -// MsgUpdateParams message. -// -// Since: cosmos-sdk 0.47 -message MsgUpdateParamsResponse {} From 4da2ff7e3dcce90a6bf10fffcb958bb54583d730 Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Wed, 2 Oct 2024 22:41:26 -0700 Subject: [PATCH 06/14] feat(mint): new inflation function --- client/x/mint/keeper/abci.go | 30 +- client/x/mint/keeper/genesis.go | 11 +- client/x/mint/keeper/genesis_test.go | 15 +- client/x/mint/keeper/grpc_query_test.go | 1 - client/x/mint/keeper/keeper.go | 2 - client/x/mint/keeper/keeper_test.go | 1 - client/x/mint/module/module.go | 2 +- client/x/mint/types/events.go | 4 +- client/x/mint/types/genesis.go | 22 +- client/x/mint/types/genesis.pb.go | 74 +--- client/x/mint/types/genesis.proto | 5 +- client/x/mint/types/mint.pb.go | 428 ++---------------------- client/x/mint/types/mint.proto | 43 +-- client/x/mint/types/minter.go | 83 ----- client/x/mint/types/minter_test.go | 140 -------- client/x/mint/types/params.go | 103 +----- client/x/mint/types/params_legacy.go | 39 --- go.mod | 2 +- 18 files changed, 71 insertions(+), 934 deletions(-) delete mode 100644 client/x/mint/types/minter.go delete mode 100644 client/x/mint/types/minter_test.go delete mode 100644 client/x/mint/types/params_legacy.go diff --git a/client/x/mint/keeper/abci.go b/client/x/mint/keeper/abci.go index 8707ea5f..87de2d16 100644 --- a/client/x/mint/keeper/abci.go +++ b/client/x/mint/keeper/abci.go @@ -13,46 +13,26 @@ import ( func (k Keeper) BeginBlocker(ctx context.Context, ic types.InflationCalculationFn) error { defer telemetry.ModuleMeasureSince(types.ModuleName, telemetry.Now(), telemetry.MetricKeyBeginBlocker) - // fetch stored minter & params - minter, err := k.Minter.Get(ctx) - if err != nil { - return err - } - params, err := k.Params.Get(ctx) if err != nil { return err } - // recalculate inflation rate - totalStakingSupply, err := k.StakingTokenSupply(ctx) - if err != nil { - return err - } - bondedRatio, err := k.BondedRatio(ctx) if err != nil { return err } - minter.Inflation = ic(ctx, minter, params, bondedRatio) - minter.AnnualProvisions = minter.NextAnnualProvisions(params, totalStakingSupply) - if err = k.Minter.Set(ctx, minter); err != nil { - return err - } - // mint coins, update supply - mintedCoin := minter.BlockProvision(params) + mintedCoinAmt := ic(ctx, params, bondedRatio) + mintedCoin := sdk.NewCoin(params.MintDenom, mintedCoinAmt.TruncateInt()) mintedCoins := sdk.NewCoins(mintedCoin) - - err = k.MintCoins(ctx, mintedCoins) - if err != nil { + if err := k.MintCoins(ctx, mintedCoins); err != nil { return err } // send the minted coins to the fee collector account - err = k.AddCollectedFees(ctx, mintedCoins) - if err != nil { + if err := k.AddCollectedFees(ctx, mintedCoins); err != nil { return err } @@ -65,8 +45,6 @@ func (k Keeper) BeginBlocker(ctx context.Context, ic types.InflationCalculationF sdk.NewEvent( types.EventTypeMint, sdk.NewAttribute(types.AttributeKeyBondedRatio, bondedRatio.String()), - sdk.NewAttribute(types.AttributeKeyInflation, minter.Inflation.String()), - sdk.NewAttribute(types.AttributeKeyAnnualProvisions, minter.AnnualProvisions.String()), sdk.NewAttribute(sdk.AttributeKeyAmount, mintedCoin.Amount.String()), ), ) diff --git a/client/x/mint/keeper/genesis.go b/client/x/mint/keeper/genesis.go index e856230a..3b12a540 100644 --- a/client/x/mint/keeper/genesis.go +++ b/client/x/mint/keeper/genesis.go @@ -8,10 +8,6 @@ import ( // InitGenesis new mint genesis. func (k Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) { - if err := k.Minter.Set(ctx, data.Minter); err != nil { - panic(err) - } - if err := k.Params.Set(ctx, data.Params); err != nil { panic(err) } @@ -21,15 +17,10 @@ func (k Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types // ExportGenesis returns a GenesisState for a given context and keeper. func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - minter, err := k.Minter.Get(ctx) - if err != nil { - panic(err) - } - params, err := k.Params.Get(ctx) if err != nil { panic(err) } - return types.NewGenesisState(minter, params) + return types.NewGenesisState(params) } diff --git a/client/x/mint/keeper/genesis_test.go b/client/x/mint/keeper/genesis_test.go index b66e29de..a68ac4fc 100644 --- a/client/x/mint/keeper/genesis_test.go +++ b/client/x/mint/keeper/genesis_test.go @@ -4,7 +4,6 @@ package keeper_test import ( "testing" - "cosmossdk.io/collections" "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" @@ -62,26 +61,14 @@ func (s *GenesisTestSuite) SetupTest() { func (s *GenesisTestSuite) TestImportExportGenesis() { genesisState := types.DefaultGenesisState() - genesisState.Minter = types.NewMinter(math.LegacyNewDecWithPrec(20, 2), math.LegacyNewDec(1)) genesisState.Params = types.NewParams( "testDenom", - math.LegacyNewDecWithPrec(15, 2), - math.LegacyNewDecWithPrec(22, 2), - math.LegacyNewDecWithPrec(9, 2), - math.LegacyNewDecWithPrec(69, 2), + math.LegacyNewDecWithPrec(24625000, 0), uint64(60*60*8766/5), ) s.keeper.InitGenesis(s.sdkCtx, s.accountKeeper, genesisState) - minter, err := s.keeper.Minter.Get(s.sdkCtx) - s.Require().Equal(genesisState.Minter, minter) - s.Require().NoError(err) - - invalidCtx := testutil.DefaultContextWithDB(s.T(), s.key, storetypes.NewTransientStoreKey("transient_test")) - _, err = s.keeper.Minter.Get(invalidCtx.Ctx) - s.Require().ErrorIs(err, collections.ErrNotFound) - params, err := s.keeper.Params.Get(s.sdkCtx) s.Require().Equal(genesisState.Params, params) s.Require().NoError(err) diff --git a/client/x/mint/keeper/grpc_query_test.go b/client/x/mint/keeper/grpc_query_test.go index 07f315b4..0ca2dc67 100644 --- a/client/x/mint/keeper/grpc_query_test.go +++ b/client/x/mint/keeper/grpc_query_test.go @@ -56,7 +56,6 @@ func (suite *MintTestSuite) SetupTest() { err := suite.mintKeeper.Params.Set(suite.ctx, types.DefaultParams()) suite.Require().NoError(err) - suite.Require().NoError(suite.mintKeeper.Minter.Set(suite.ctx, types.DefaultInitialMinter())) queryHelper := baseapp.NewQueryServerTestHelper(testCtx.Ctx, encCfg.InterfaceRegistry) types.RegisterQueryServer(queryHelper, keeper.NewQueryServerImpl(suite.mintKeeper)) diff --git a/client/x/mint/keeper/keeper.go b/client/x/mint/keeper/keeper.go index ab61740e..8e8f18ff 100644 --- a/client/x/mint/keeper/keeper.go +++ b/client/x/mint/keeper/keeper.go @@ -26,7 +26,6 @@ type Keeper struct { Schema collections.Schema Params collections.Item[types.Params] - Minter collections.Item[types.Minter] } // NewKeeper creates a new mint Keeper instance. @@ -51,7 +50,6 @@ func NewKeeper( bankKeeper: bk, feeCollectorName: feeCollectorName, Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), - Minter: collections.NewItem(sb, types.MinterKey, "minter", codec.CollValue[types.Minter](cdc)), } schema, err := sb.Build() diff --git a/client/x/mint/keeper/keeper_test.go b/client/x/mint/keeper/keeper_test.go index 15c90b24..c22fa287 100644 --- a/client/x/mint/keeper/keeper_test.go +++ b/client/x/mint/keeper/keeper_test.go @@ -65,7 +65,6 @@ func (s *IntegrationTestSuite) SetupTest() { err := s.mintKeeper.Params.Set(s.ctx, types.DefaultParams()) s.Require().NoError(err) - s.Require().NoError(s.mintKeeper.Minter.Set(s.ctx, types.DefaultInitialMinter())) } func (s *IntegrationTestSuite) TestAliasFunctions() { diff --git a/client/x/mint/module/module.go b/client/x/mint/module/module.go index d03db0ec..1abc263f 100644 --- a/client/x/mint/module/module.go +++ b/client/x/mint/module/module.go @@ -80,7 +80,7 @@ type AppModule struct { keeper keeper.Keeper authKeeper types.AccountKeeper - // inflationCalculator is used to calculate the inflation rate during BeginBlock. + // inflationCalculator is used to calculate the inflation amount during BeginBlock. // If inflationCalculator is nil, the default inflation calculation logic is used. inflationCalculator types.InflationCalculationFn } diff --git a/client/x/mint/types/events.go b/client/x/mint/types/events.go index 5b8e45b0..708da313 100644 --- a/client/x/mint/types/events.go +++ b/client/x/mint/types/events.go @@ -4,7 +4,5 @@ package types const ( EventTypeMint = ModuleName - AttributeKeyBondedRatio = "bonded_ratio" - AttributeKeyInflation = "inflation" - AttributeKeyAnnualProvisions = "annual_provisions" + AttributeKeyBondedRatio = "bonded_ratio" ) diff --git a/client/x/mint/types/genesis.go b/client/x/mint/types/genesis.go index 4f3d399e..2adb0289 100644 --- a/client/x/mint/types/genesis.go +++ b/client/x/mint/types/genesis.go @@ -6,22 +6,21 @@ import ( "cosmossdk.io/math" ) -// InflationCalculationFn defines the function required to calculate inflation rate during -// BeginBlock. It receives the minter and params stored in the keeper, along with the current -// bondedRatio and returns the newly calculated inflation rate. +// InflationCalculationFn defines the function required to calculate inflation amount during +// BeginBlock. It receives the params stored in the keeper, along with the current +// bondedRatio and returns the newly calculated inflation amount. // It can be used to specify a custom inflation calculation logic, instead of relying on the // default logic provided by the sdk. -type InflationCalculationFn func(ctx context.Context, minter Minter, params Params, bondedRatio math.LegacyDec) math.LegacyDec +type InflationCalculationFn func(ctx context.Context, params Params, _ math.LegacyDec) math.LegacyDec // DefaultInflationCalculationFn is the default function used to calculate inflation. -func DefaultInflationCalculationFn(_ context.Context, minter Minter, params Params, bondedRatio math.LegacyDec) math.LegacyDec { - return minter.NextInflationRate(params, bondedRatio) +func DefaultInflationCalculationFn(_ context.Context, params Params, _ math.LegacyDec) math.LegacyDec { + return params.InflationsPerYear.QuoInt64(int64(params.BlocksPerYear)) } // NewGenesisState creates a new GenesisState object. -func NewGenesisState(minter Minter, params Params) *GenesisState { +func NewGenesisState(params Params) *GenesisState { return &GenesisState{ - Minter: minter, Params: params, } } @@ -29,7 +28,6 @@ func NewGenesisState(minter Minter, params Params) *GenesisState { // DefaultGenesisState creates a default GenesisState object. func DefaultGenesisState() *GenesisState { return &GenesisState{ - Minter: DefaultInitialMinter(), Params: DefaultParams(), } } @@ -37,9 +35,5 @@ func DefaultGenesisState() *GenesisState { // ValidateGenesis validates the provided genesis state to ensure the // expected invariants holds. func ValidateGenesis(data GenesisState) error { - if err := data.Params.Validate(); err != nil { - return err - } - - return ValidateMinter(data.Minter) + return data.Params.Validate() } diff --git a/client/x/mint/types/genesis.pb.go b/client/x/mint/types/genesis.pb.go index 9afe5286..9f7e83c8 100644 --- a/client/x/mint/types/genesis.pb.go +++ b/client/x/mint/types/genesis.pb.go @@ -26,10 +26,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the mint module's genesis state. type GenesisState struct { - // minter is a space for holding current inflation information. - Minter Minter `protobuf:"bytes,1,opt,name=minter,proto3" json:"minter"` // params defines all the parameters of the module. - Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -65,13 +63,6 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetMinter() Minter { - if m != nil { - return m.Minter - } - return Minter{} -} - func (m *GenesisState) GetParams() Params { if m != nil { return m.Params @@ -86,21 +77,19 @@ func init() { func init() { proto.RegisterFile("client/x/mint/types/genesis.proto", fileDescriptor_f5cd7edb2fa50db9) } var fileDescriptor_f5cd7edb2fa50db9 = []byte{ - // 210 bytes of a gzipped FileDescriptorProto + // 192 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0xaf, 0xd0, 0xcf, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0x28, 0xd1, 0xab, 0xd0, 0x03, 0x29, 0xd1, 0x03, 0x2b, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, 0x10, 0xa5, 0x52, 0x72, 0xd8, 0x4c, 0x03, 0xeb, 0x82, 0xc8, 0x0b, 0x26, - 0xe6, 0x66, 0xe6, 0xe5, 0xeb, 0x83, 0x49, 0x88, 0x90, 0x52, 0x1f, 0x23, 0x17, 0x8f, 0x3b, 0xc4, - 0xbe, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x3b, 0x2e, 0x36, 0x90, 0x8e, 0xd4, 0x22, 0x09, 0x46, - 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x69, 0x3d, 0x2c, 0xf6, 0xeb, 0xf9, 0x82, 0x95, 0x38, 0x71, 0x9e, - 0xb8, 0x27, 0xcf, 0xb0, 0xe2, 0xf9, 0x06, 0x2d, 0xc6, 0x20, 0xa8, 0x2e, 0x90, 0xfe, 0x82, 0xc4, - 0xa2, 0xc4, 0xdc, 0x62, 0x09, 0x26, 0x3c, 0xfa, 0x03, 0xc0, 0x4a, 0x50, 0xf4, 0x43, 0x74, 0x39, - 0xe9, 0x9e, 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, 0x30, 0x16, 0xdf, 0x25, - 0xb1, 0x81, 0xbd, 0x61, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x2e, 0x65, 0xcc, 0x25, 0x49, 0x01, - 0x00, 0x00, + 0xe6, 0x66, 0xe6, 0xe5, 0xeb, 0x83, 0x49, 0x88, 0x90, 0x92, 0x1f, 0x17, 0x8f, 0x3b, 0xc4, 0xba, + 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x3b, 0x2e, 0xb6, 0x82, 0xc4, 0xa2, 0xc4, 0xdc, 0x62, 0x09, + 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x69, 0x3d, 0x2c, 0xd6, 0xeb, 0x05, 0x80, 0x95, 0x38, 0x71, + 0x9e, 0xb8, 0x27, 0xcf, 0xb0, 0xe2, 0xf9, 0x06, 0x2d, 0xc6, 0x20, 0xa8, 0x2e, 0x27, 0xdd, 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, 0x12, 0xc6, 0xe2, 0xb8, 0x24, 0x36, 0xb0, + 0x2b, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xfb, 0xaf, 0x59, 0x3b, 0x08, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -132,16 +121,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 - { - size, err := m.Minter.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -163,8 +142,6 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l - l = m.Minter.Size() - n += 1 + l + sovGenesis(uint64(l)) l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) return n @@ -206,39 +183,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Minter", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Minter.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } diff --git a/client/x/mint/types/genesis.proto b/client/x/mint/types/genesis.proto index 20b956b6..e9d0af6e 100644 --- a/client/x/mint/types/genesis.proto +++ b/client/x/mint/types/genesis.proto @@ -9,9 +9,6 @@ option go_package = "client/x/mint/types"; // GenesisState defines the mint module's genesis state. message GenesisState { - // minter is a space for holding current inflation information. - Minter minter = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; - // params defines all the parameters of the module. - Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } diff --git a/client/x/mint/types/mint.pb.go b/client/x/mint/types/mint.pb.go index 3c045235..5a225b11 100644 --- a/client/x/mint/types/mint.pb.go +++ b/client/x/mint/types/mint.pb.go @@ -26,68 +26,21 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Minter represents the minting state. -type Minter struct { - // current annual inflation rate - Inflation cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=inflation,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation"` - // current annual expected provisions - AnnualProvisions cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=annual_provisions,json=annualProvisions,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"annual_provisions"` -} - -func (m *Minter) Reset() { *m = Minter{} } -func (m *Minter) String() string { return proto.CompactTextString(m) } -func (*Minter) ProtoMessage() {} -func (*Minter) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6e60aec58f52af, []int{0} -} -func (m *Minter) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Minter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Minter.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Minter) XXX_Merge(src proto.Message) { - xxx_messageInfo_Minter.Merge(m, src) -} -func (m *Minter) XXX_Size() int { - return m.Size() -} -func (m *Minter) XXX_DiscardUnknown() { - xxx_messageInfo_Minter.DiscardUnknown(m) -} - -var xxx_messageInfo_Minter proto.InternalMessageInfo - // Params defines the parameters for the x/mint module. type Params struct { // type of coin to mint MintDenom string `protobuf:"bytes,1,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` - // maximum annual change in inflation rate - InflationRateChange cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=inflation_rate_change,json=inflationRateChange,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation_rate_change"` - // maximum inflation rate - InflationMax cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=inflation_max,json=inflationMax,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation_max"` - // minimum inflation rate - InflationMin cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=inflation_min,json=inflationMin,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation_min"` - // goal of percent bonded atoms - GoalBonded cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=goal_bonded,json=goalBonded,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"goal_bonded"` + // inflation amount per year + InflationsPerYear cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=inflations_per_year,json=inflationsPerYear,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflations_per_year"` // expected blocks per year - BlocksPerYear uint64 `protobuf:"varint,6,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty"` + BlocksPerYear uint64 `protobuf:"varint,3,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty"` } func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6e60aec58f52af, []int{1} + return fileDescriptor_9c6e60aec58f52af, []int{0} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -131,84 +84,32 @@ func (m *Params) GetBlocksPerYear() uint64 { } func init() { - proto.RegisterType((*Minter)(nil), "client.x.mint.types.Minter") proto.RegisterType((*Params)(nil), "client.x.mint.types.Params") } func init() { proto.RegisterFile("client/x/mint/types/mint.proto", fileDescriptor_9c6e60aec58f52af) } var fileDescriptor_9c6e60aec58f52af = []byte{ - // 418 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xc1, 0x8a, 0x13, 0x31, - 0x18, 0xc7, 0x27, 0xee, 0x3a, 0xd0, 0xe8, 0xa2, 0x9b, 0xae, 0x30, 0xbb, 0xe2, 0xec, 0xb2, 0x07, - 0x29, 0x85, 0xce, 0x20, 0x82, 0x07, 0x8f, 0xb5, 0x47, 0x8b, 0x65, 0x2e, 0xa2, 0x82, 0xc3, 0xd7, - 0x99, 0x38, 0x8d, 0x9d, 0x49, 0x4a, 0x12, 0x65, 0xfa, 0x0a, 0x9e, 0x7c, 0x0c, 0x8f, 0x3d, 0x78, - 0xf1, 0x0d, 0x7a, 0x2c, 0x9e, 0xc4, 0x43, 0x91, 0xf6, 0x50, 0x7c, 0x0b, 0x99, 0xa4, 0x4c, 0x51, - 0xbc, 0x68, 0xf7, 0x12, 0xbe, 0xfc, 0xff, 0xe1, 0xf7, 0xfd, 0x49, 0xf2, 0x61, 0x3f, 0xc9, 0x19, - 0xe5, 0x3a, 0x2c, 0xc3, 0x82, 0x71, 0x1d, 0xea, 0xe9, 0x84, 0x2a, 0x53, 0x06, 0x13, 0x29, 0xb4, - 0x20, 0x4d, 0xeb, 0x07, 0x65, 0x60, 0x44, 0xe3, 0x9f, 0x9d, 0x64, 0x22, 0x13, 0xc6, 0x0f, 0xab, - 0xca, 0x1e, 0x3d, 0x3b, 0x4d, 0x84, 0x2a, 0x84, 0x8a, 0xad, 0x61, 0x37, 0x5b, 0xeb, 0x18, 0x0a, - 0xc6, 0x45, 0x68, 0x56, 0x2b, 0x5d, 0x7e, 0x41, 0xd8, 0xed, 0x33, 0xae, 0xa9, 0x24, 0xcf, 0x70, - 0x83, 0xf1, 0x37, 0x39, 0x68, 0x26, 0xb8, 0x87, 0x2e, 0x50, 0xab, 0xd1, 0x7d, 0x30, 0x5f, 0x9e, - 0x3b, 0xdf, 0x97, 0xe7, 0x77, 0x2d, 0x46, 0xa5, 0xe3, 0x80, 0x89, 0xb0, 0x00, 0x3d, 0x0a, 0x9e, - 0xd2, 0x0c, 0x92, 0x69, 0x8f, 0x26, 0x5f, 0x3f, 0x77, 0xf0, 0xb6, 0x4b, 0x8f, 0x26, 0xd1, 0x8e, - 0x41, 0x5e, 0xe3, 0x63, 0xe0, 0xfc, 0x1d, 0xe4, 0x55, 0x96, 0xf7, 0x4c, 0x31, 0xc1, 0x95, 0x77, - 0xed, 0x7f, 0xc1, 0xb7, 0x2d, 0x6b, 0x50, 0xa3, 0x2e, 0x7f, 0x1e, 0x60, 0x77, 0x00, 0x12, 0x0a, - 0x45, 0xee, 0x61, 0x5c, 0x5d, 0x4c, 0x9c, 0x52, 0x2e, 0x0a, 0x1b, 0x3e, 0x6a, 0x54, 0x4a, 0xaf, - 0x12, 0xc8, 0x5b, 0x7c, 0xa7, 0x8e, 0x15, 0x4b, 0xd0, 0x34, 0x4e, 0x46, 0xc0, 0x33, 0xba, 0x4d, - 0xf3, 0xe8, 0x9f, 0xd3, 0x7c, 0xda, 0xcc, 0xda, 0x28, 0x6a, 0xd6, 0xd0, 0x08, 0x34, 0x7d, 0x62, - 0x90, 0xe4, 0x15, 0x3e, 0xda, 0xf5, 0x2a, 0xa0, 0xf4, 0x0e, 0xf6, 0xea, 0x71, 0xb3, 0x86, 0xf5, - 0xa1, 0xfc, 0x03, 0xce, 0xb8, 0x77, 0x78, 0x55, 0x70, 0xc6, 0xc9, 0x73, 0x7c, 0x23, 0x13, 0x90, - 0xc7, 0x43, 0xc1, 0x53, 0x9a, 0x7a, 0xd7, 0xf7, 0x42, 0xe3, 0x0a, 0xd5, 0x35, 0x24, 0x72, 0x1f, - 0xdf, 0x1a, 0xe6, 0x22, 0x19, 0xab, 0x78, 0x42, 0x65, 0x3c, 0xa5, 0x20, 0x3d, 0xf7, 0x02, 0xb5, - 0x0e, 0xa3, 0x23, 0x2b, 0x0f, 0xa8, 0x7c, 0x41, 0x41, 0x3e, 0x3e, 0xfd, 0xb0, 0x99, 0xb5, 0x4f, - 0x7e, 0x1f, 0x05, 0xfb, 0xc0, 0xdd, 0xce, 0x7c, 0xe5, 0xa3, 0xc5, 0xca, 0x47, 0x3f, 0x56, 0x3e, - 0xfa, 0xb8, 0xf6, 0x9d, 0xc5, 0xda, 0x77, 0xbe, 0xad, 0x7d, 0xe7, 0x65, 0xf3, 0x2f, 0xa3, 0x33, - 0x74, 0xcd, 0xef, 0x7e, 0xf8, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xac, 0xa1, 0x1b, 0xe6, 0x58, 0x03, - 0x00, 0x00, -} - -func (m *Minter) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Minter) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Minter) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.AnnualProvisions.Size() - i -= size - if _, err := m.AnnualProvisions.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintMint(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.Inflation.Size() - i -= size - if _, err := m.Inflation.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintMint(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil + // 295 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xce, 0xc9, 0x4c, + 0xcd, 0x2b, 0xd1, 0xaf, 0xd0, 0xcf, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x06, + 0x33, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x84, 0x21, 0xf2, 0x7a, 0x15, 0x7a, 0x60, 0x41, + 0xb0, 0xbc, 0x94, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, 0x58, 0x5e, 0x1f, 0xc4, 0x82, 0x28, 0x95, 0x92, + 0x4c, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0x8e, 0x87, 0x48, 0x40, 0x38, 0x50, 0x29, 0xc1, 0xc4, 0xdc, + 0xcc, 0xbc, 0x7c, 0x7d, 0x30, 0x09, 0x11, 0x52, 0xba, 0xc4, 0xc8, 0xc5, 0x16, 0x90, 0x58, 0x94, + 0x98, 0x5b, 0x2c, 0x24, 0xcb, 0xc5, 0x05, 0x32, 0x3c, 0x3e, 0x25, 0x35, 0x2f, 0x3f, 0x57, 0x82, + 0x51, 0x81, 0x51, 0x83, 0x33, 0x88, 0x13, 0x24, 0xe2, 0x02, 0x12, 0x10, 0x4a, 0xe3, 0x12, 0xce, + 0xcc, 0x4b, 0xcb, 0x49, 0x2c, 0xc9, 0xcc, 0xcf, 0x2b, 0x8e, 0x2f, 0x48, 0x2d, 0x8a, 0xaf, 0x4c, + 0x4d, 0x2c, 0x92, 0x60, 0x02, 0xa9, 0x73, 0x32, 0x3b, 0x71, 0x4f, 0x9e, 0xe1, 0xd6, 0x3d, 0x79, + 0x69, 0x88, 0x7d, 0xc5, 0x29, 0xd9, 0x7a, 0x99, 0xf9, 0xfa, 0xb9, 0x89, 0x25, 0x19, 0x7a, 0x3e, + 0xa9, 0xe9, 0x89, 0xc9, 0x95, 0x2e, 0xa9, 0xc9, 0x97, 0xb6, 0xe8, 0x72, 0x41, 0x9d, 0xe3, 0x92, + 0x9a, 0xbc, 0xe2, 0xf9, 0x06, 0x2d, 0xc6, 0x20, 0x41, 0x84, 0x91, 0x01, 0xa9, 0x45, 0x91, 0xa9, + 0x89, 0x45, 0x42, 0x6a, 0x5c, 0xfc, 0x49, 0x39, 0xf9, 0xc9, 0xd9, 0x48, 0x76, 0x30, 0x2b, 0x30, + 0x6a, 0xb0, 0x04, 0xf1, 0x42, 0x84, 0xa1, 0xea, 0xac, 0x24, 0xbb, 0x9e, 0x6f, 0xd0, 0x12, 0x41, + 0x0d, 0x37, 0x88, 0x4f, 0x9c, 0x74, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, + 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, + 0x4a, 0x18, 0x4b, 0x38, 0x27, 0xb1, 0x81, 0x83, 0xc2, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x05, + 0x53, 0x24, 0x0d, 0x85, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -234,42 +135,12 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.BlocksPerYear != 0 { i = encodeVarintMint(dAtA, i, uint64(m.BlocksPerYear)) i-- - dAtA[i] = 0x30 - } - { - size := m.GoalBonded.Size() - i -= size - if _, err := m.GoalBonded.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintMint(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size := m.InflationMin.Size() - i -= size - if _, err := m.InflationMin.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintMint(dAtA, i, uint64(size)) + dAtA[i] = 0x18 } - i-- - dAtA[i] = 0x22 { - size := m.InflationMax.Size() + size := m.InflationsPerYear.Size() i -= size - if _, err := m.InflationMax.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintMint(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.InflationRateChange.Size() - i -= size - if _, err := m.InflationRateChange.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.InflationsPerYear.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintMint(dAtA, i, uint64(size)) @@ -297,19 +168,6 @@ func encodeVarintMint(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *Minter) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Inflation.Size() - n += 1 + l + sovMint(uint64(l)) - l = m.AnnualProvisions.Size() - n += 1 + l + sovMint(uint64(l)) - return n -} - func (m *Params) Size() (n int) { if m == nil { return 0 @@ -320,13 +178,7 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovMint(uint64(l)) } - l = m.InflationRateChange.Size() - n += 1 + l + sovMint(uint64(l)) - l = m.InflationMax.Size() - n += 1 + l + sovMint(uint64(l)) - l = m.InflationMin.Size() - n += 1 + l + sovMint(uint64(l)) - l = m.GoalBonded.Size() + l = m.InflationsPerYear.Size() n += 1 + l + sovMint(uint64(l)) if m.BlocksPerYear != 0 { n += 1 + sovMint(uint64(m.BlocksPerYear)) @@ -340,124 +192,6 @@ func sovMint(x uint64) (n int) { func sozMint(x uint64) (n int) { return sovMint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *Minter) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Minter: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Minter: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Inflation", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Inflation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AnnualProvisions", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.AnnualProvisions.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMint(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMint - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *Params) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -521,7 +255,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InflationRateChange", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field InflationsPerYear", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -549,113 +283,11 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.InflationRateChange.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.InflationsPerYear.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InflationMax", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.InflationMax.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InflationMin", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.InflationMin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GoalBonded", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.GoalBonded.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field BlocksPerYear", wireType) } diff --git a/client/x/mint/types/mint.proto b/client/x/mint/types/mint.proto index 81a3d587..49fce484 100644 --- a/client/x/mint/types/mint.proto +++ b/client/x/mint/types/mint.proto @@ -7,56 +7,19 @@ import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; import "amino/amino.proto"; -// Minter represents the minting state. -message Minter { - // current annual inflation rate - string inflation = 1 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; - // current annual expected provisions - string annual_provisions = 2 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; -} - // Params defines the parameters for the x/mint module. message Params { option (amino.name) = "client/x/mint/Params"; // type of coin to mint string mint_denom = 1; - // maximum annual change in inflation rate - string inflation_rate_change = 2 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; - // maximum inflation rate - string inflation_max = 3 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; - // minimum inflation rate - string inflation_min = 4 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; - // goal of percent bonded atoms - string goal_bonded = 5 [ + // inflation amount per year + string inflations_per_year = 2 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; // expected blocks per year - uint64 blocks_per_year = 6; + uint64 blocks_per_year = 3; } diff --git a/client/x/mint/types/minter.go b/client/x/mint/types/minter.go deleted file mode 100644 index 383307fd..00000000 --- a/client/x/mint/types/minter.go +++ /dev/null @@ -1,83 +0,0 @@ -package types - -import ( - "fmt" - - "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// NewMinter returns a new Minter object with the given inflation and annual -// provisions values. -func NewMinter(inflation, annualProvisions math.LegacyDec) Minter { - return Minter{ - Inflation: inflation, - AnnualProvisions: annualProvisions, - } -} - -// InitialMinter returns an initial Minter object with a given inflation value. -func InitialMinter(inflation math.LegacyDec) Minter { - return NewMinter( - inflation, - math.LegacyNewDec(0), - ) -} - -// DefaultInitialMinter returns a default initial Minter object for a new chain -// which uses an inflation rate of 13%. -func DefaultInitialMinter() Minter { - return InitialMinter( - math.LegacyNewDecWithPrec(13, 2), - ) -} - -// ValidateMinter does a basic validation on minter. -func ValidateMinter(minter Minter) error { - if minter.Inflation.IsNegative() { - return fmt.Errorf("mint parameter Inflation should be positive, is %s", - minter.Inflation.String()) - } - - return nil -} - -// NextInflationRate returns the new inflation rate for the next block. -func (m Minter) NextInflationRate(params Params, bondedRatio math.LegacyDec) math.LegacyDec { - // The target annual inflation rate is recalculated for each block. The inflation - // is also subject to a rate change (positive or negative) depending on the - // distance from the desired ratio (67%). The maximum rate change possible is - // defined to be 13% per year, however the annual inflation is capped as between - // 7% and 20%. - - // (1 - bondedRatio/GoalBonded) * InflationRateChange - inflationRateChangePerYear := math.LegacyOneDec(). - Sub(bondedRatio.Quo(params.GoalBonded)). - Mul(params.InflationRateChange) - inflationRateChange := inflationRateChangePerYear.Quo(math.LegacyNewDec(int64(params.BlocksPerYear))) - - // adjust the new annual inflation for this next block - inflation := m.Inflation.Add(inflationRateChange) // note inflationRateChange may be negative - if inflation.GT(params.InflationMax) { - inflation = params.InflationMax - } - if inflation.LT(params.InflationMin) { - inflation = params.InflationMin - } - - return inflation -} - -// NextAnnualProvisions returns the annual provisions based on current total -// supply and inflation rate. -func (m Minter) NextAnnualProvisions(_ Params, totalSupply math.Int) math.LegacyDec { - return m.Inflation.MulInt(totalSupply) -} - -// BlockProvision returns the provisions for a block based on the annual -// provisions rate. -func (m Minter) BlockProvision(params Params) sdk.Coin { - provisionAmt := m.AnnualProvisions.QuoInt(math.NewInt(int64(params.BlocksPerYear))) - return sdk.NewCoin(params.MintDenom, provisionAmt.TruncateInt()) -} diff --git a/client/x/mint/types/minter_test.go b/client/x/mint/types/minter_test.go deleted file mode 100644 index a84969d1..00000000 --- a/client/x/mint/types/minter_test.go +++ /dev/null @@ -1,140 +0,0 @@ -//nolint:paralleltest // just for testing -package types_test - -import ( - "math/rand" - "testing" - - "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - "github.com/piplabs/story/client/x/mint/types" -) - -func TestNextInflation(t *testing.T) { - minter := types.DefaultInitialMinter() - params := types.DefaultParams() - blocksPerYr := math.LegacyNewDec(int64(params.BlocksPerYear)) - - // Governing Mechanism: - // inflationRateChangePerYear = (1- BondedRatio/ GoalBonded) * MaxInflationRateChange - - tests := []struct { - bondedRatio, setInflation, expChange math.LegacyDec - }{ - // with 0% bonded atom supply the inflation should increase by InflationRateChange - {math.LegacyZeroDec(), math.LegacyNewDecWithPrec(7, 2), params.InflationRateChange.Quo(blocksPerYr)}, - - // 100% bonded, starting at 20% inflation and being reduced - // (1 - (1/0.67))*(0.13/8667) - { - math.LegacyOneDec(), math.LegacyNewDecWithPrec(20, 2), - math.LegacyOneDec().Sub(math.LegacyOneDec().Quo(params.GoalBonded)).Mul(params.InflationRateChange).Quo(blocksPerYr), - }, - - // 50% bonded, starting at 10% inflation and being increased - { - math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(10, 2), - math.LegacyOneDec().Sub(math.LegacyNewDecWithPrec(5, 1).Quo(params.GoalBonded)).Mul(params.InflationRateChange).Quo(blocksPerYr), - }, - - // test 7% minimum stop (testing with 100% bonded) - {math.LegacyOneDec(), math.LegacyNewDecWithPrec(7, 2), math.LegacyZeroDec()}, - {math.LegacyOneDec(), math.LegacyNewDecWithPrec(700000001, 10), math.LegacyNewDecWithPrec(-1, 10)}, - - // test 20% maximum stop (testing with 0% bonded) - {math.LegacyZeroDec(), math.LegacyNewDecWithPrec(20, 2), math.LegacyZeroDec()}, - {math.LegacyZeroDec(), math.LegacyNewDecWithPrec(1999999999, 10), math.LegacyNewDecWithPrec(1, 10)}, - - // perfect balance shouldn't change inflation - {math.LegacyNewDecWithPrec(67, 2), math.LegacyNewDecWithPrec(15, 2), math.LegacyZeroDec()}, - } - for i, tc := range tests { - minter.Inflation = tc.setInflation - - inflation := minter.NextInflationRate(params, tc.bondedRatio) - diffInflation := inflation.Sub(tc.setInflation) - - require.True(t, diffInflation.Equal(tc.expChange), - "Test Index: %v\nDiff: %v\nExpected: %v\n", i, diffInflation, tc.expChange) - } -} - -func TestBlockProvision(t *testing.T) { - minter := types.InitialMinter(math.LegacyNewDecWithPrec(1, 1)) - params := types.DefaultParams() - - secondsPerYear := int64(60 * 60 * 8766) - - tests := []struct { - annualProvisions int64 - expProvisions int64 - }{ - {secondsPerYear / 5, 1}, - {secondsPerYear/5 + 1, 1}, - {(secondsPerYear / 5) * 2, 2}, - {(secondsPerYear / 5) / 2, 0}, - } - for i, tc := range tests { - minter.AnnualProvisions = math.LegacyNewDec(tc.annualProvisions) - provisions := minter.BlockProvision(params) - - expProvisions := sdk.NewCoin(params.MintDenom, - math.NewInt(tc.expProvisions)) - - require.True(t, expProvisions.IsEqual(provisions), - "test: %v\n\tExp: %v\n\tGot: %v\n", - i, tc.expProvisions, provisions) - } -} - -// Benchmarking :) -// previously using math.Int operations: -// BenchmarkBlockProvision-4 5000000 220 ns/op -// -// using math.LegacyDec operations: (current implementation) -// BenchmarkBlockProvision-4 3000000 429 ns/op. -func BenchmarkBlockProvision(b *testing.B) { - b.ReportAllocs() - minter := types.InitialMinter(math.LegacyNewDecWithPrec(1, 1)) - params := types.DefaultParams() - - s1 := rand.NewSource(100) - r1 := rand.New(s1) - minter.AnnualProvisions = math.LegacyNewDec(r1.Int63n(1000000)) - - // run the BlockProvision function b.N times - for n := 0; n < b.N; n++ { - minter.BlockProvision(params) - } -} - -// Next inflation benchmarking -// BenchmarkNextInflation-4 1000000 1828 ns/op. -func BenchmarkNextInflation(b *testing.B) { - b.ReportAllocs() - minter := types.InitialMinter(math.LegacyNewDecWithPrec(1, 1)) - params := types.DefaultParams() - bondedRatio := math.LegacyNewDecWithPrec(1, 1) - - // run the NextInflationRate function b.N times - for n := 0; n < b.N; n++ { - minter.NextInflationRate(params, bondedRatio) - } -} - -// Next annual provisions benchmarking -// BenchmarkNextAnnualProvisions-4 5000000 251 ns/op. -func BenchmarkNextAnnualProvisions(b *testing.B) { - b.ReportAllocs() - minter := types.InitialMinter(math.LegacyNewDecWithPrec(1, 1)) - params := types.DefaultParams() - totalSupply := math.NewInt(100000000000000) - - // run the NextAnnualProvisions function b.N times - for n := 0; n < b.N; n++ { - minter.NextAnnualProvisions(params, totalSupply) - } -} diff --git a/client/x/mint/types/params.go b/client/x/mint/types/params.go index 704b5bb4..57dd0e9a 100644 --- a/client/x/mint/types/params.go +++ b/client/x/mint/types/params.go @@ -13,26 +13,20 @@ import ( ) // NewParams returns Params instance with the given values. -func NewParams(mintDenom string, inflationRateChange, inflationMax, inflationMin, goalBonded math.LegacyDec, blocksPerYear uint64) Params { +func NewParams(mintDenom string, inflationsPerYear math.LegacyDec, blocksPerYear uint64) Params { return Params{ - MintDenom: mintDenom, - InflationRateChange: inflationRateChange, - InflationMax: inflationMax, - InflationMin: inflationMin, - GoalBonded: goalBonded, - BlocksPerYear: blocksPerYear, + MintDenom: mintDenom, + InflationsPerYear: inflationsPerYear, + BlocksPerYear: blocksPerYear, } } // DefaultParams returns default x/mint module parameters. func DefaultParams() Params { return Params{ - MintDenom: sdk.DefaultBondDenom, - InflationRateChange: math.LegacyNewDecWithPrec(13, 2), - InflationMax: math.LegacyNewDecWithPrec(20, 2), - InflationMin: math.LegacyNewDecWithPrec(7, 2), - GoalBonded: math.LegacyNewDecWithPrec(67, 2), - BlocksPerYear: uint64(60 * 60 * 8766 / 5), // assuming 5 second block times + MintDenom: sdk.DefaultBondDenom, + InflationsPerYear: math.LegacyNewDecWithPrec(24625000, 2), + BlocksPerYear: uint64(60 * 60 * 8766 / 5), // assuming 5 second block times } } @@ -41,27 +35,12 @@ func (p Params) Validate() error { if err := validateMintDenom(p.MintDenom); err != nil { return err } - if err := validateInflationRateChange(p.InflationRateChange); err != nil { - return err - } - if err := validateInflationMax(p.InflationMax); err != nil { - return err - } - if err := validateInflationMin(p.InflationMin); err != nil { - return err - } - if err := validateGoalBonded(p.GoalBonded); err != nil { + if err := validateInflationsPerYear(p.InflationsPerYear); err != nil { return err } if err := validateBlocksPerYear(p.BlocksPerYear); err != nil { return err } - if p.InflationMax.LT(p.InflationMin) { - return fmt.Errorf( - "max inflation (%s) must be greater than or equal to min inflation (%s)", - p.InflationMax, p.InflationMin, - ) - } return nil } @@ -83,77 +62,17 @@ func validateMintDenom(i interface{}) error { return nil } -func validateInflationRateChange(i interface{}) error { +func validateInflationsPerYear(i interface{}) error { v, ok := i.(math.LegacyDec) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } if v.IsNil() { - return fmt.Errorf("inflation rate change cannot be nil: %s", v) + return fmt.Errorf("inflations per year cannot be nil: %s", v) } if v.IsNegative() { - return fmt.Errorf("inflation rate change cannot be negative: %s", v) - } - if v.GT(math.LegacyOneDec()) { - return fmt.Errorf("inflation rate change too large: %s", v) - } - - return nil -} - -func validateInflationMax(i interface{}) error { - v, ok := i.(math.LegacyDec) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v.IsNil() { - return fmt.Errorf("max inflation cannot be nil: %s", v) - } - if v.IsNegative() { - return fmt.Errorf("max inflation cannot be negative: %s", v) - } - if v.GT(math.LegacyOneDec()) { - return fmt.Errorf("max inflation too large: %s", v) - } - - return nil -} - -func validateInflationMin(i interface{}) error { - v, ok := i.(math.LegacyDec) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v.IsNil() { - return fmt.Errorf("min inflation cannot be nil: %s", v) - } - if v.IsNegative() { - return fmt.Errorf("min inflation cannot be negative: %s", v) - } - if v.GT(math.LegacyOneDec()) { - return fmt.Errorf("min inflation too large: %s", v) - } - - return nil -} - -func validateGoalBonded(i interface{}) error { - v, ok := i.(math.LegacyDec) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v.IsNil() { - return fmt.Errorf("goal bonded cannot be nil: %s", v) - } - if v.IsNegative() || v.IsZero() { - return fmt.Errorf("goal bonded must be positive: %s", v) - } - if v.GT(math.LegacyOneDec()) { - return fmt.Errorf("goal bonded too large: %s", v) + return fmt.Errorf("inflations per year cannot be negative: %s", v) } return nil diff --git a/client/x/mint/types/params_legacy.go b/client/x/mint/types/params_legacy.go deleted file mode 100644 index 46e5ab51..00000000 --- a/client/x/mint/types/params_legacy.go +++ /dev/null @@ -1,39 +0,0 @@ -/* -NOTE: Usage of x/params to manage parameters is deprecated in favor of x/gov -controlled execution of MsgUpdateParams messages. These types remains solely -for migration purposes and will be removed in a future release. -*/ -package types - -import ( - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" -) - -// Parameter store keys. -var ( - KeyMintDenom = []byte("MintDenom") - KeyInflationRateChange = []byte("InflationRateChange") - KeyInflationMax = []byte("InflationMax") - KeyInflationMin = []byte("InflationMin") - KeyGoalBonded = []byte("GoalBonded") - KeyBlocksPerYear = []byte("BlocksPerYear") -) - -// Deprecated: ParamTable for minting module. -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - -// Implements params.ParamSet -// -// Deprecated. -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyMintDenom, &p.MintDenom, validateMintDenom), - paramtypes.NewParamSetPair(KeyInflationRateChange, &p.InflationRateChange, validateInflationRateChange), - paramtypes.NewParamSetPair(KeyInflationMax, &p.InflationMax, validateInflationMax), - paramtypes.NewParamSetPair(KeyInflationMin, &p.InflationMin, validateInflationMin), - paramtypes.NewParamSetPair(KeyGoalBonded, &p.GoalBonded, validateGoalBonded), - paramtypes.NewParamSetPair(KeyBlocksPerYear, &p.BlocksPerYear, validateBlocksPerYear), - } -} diff --git a/go.mod b/go.mod index 0d310872..6cc516df 100644 --- a/go.mod +++ b/go.mod @@ -130,7 +130,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.2.0 // indirect github.com/golang/mock v1.6.0 - github.com/golang/protobuf v1.5.4 + github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/btree v1.1.2 // indirect github.com/google/cel-go v0.20.1 // indirect From cd943ea2dd92645577e34877e7f14bf23388e3a7 Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Thu, 3 Oct 2024 10:40:23 -0700 Subject: [PATCH 07/14] feat(mint): mint parameters change event log processing --- .../x/evmengine/keeper/abci_internal_test.go | 10 +- client/x/evmengine/keeper/keeper.go | 3 + .../evmengine/keeper/keeper_internal_test.go | 6 +- client/x/evmengine/keeper/msg_server.go | 3 + .../keeper/msg_server_internal_test.go | 3 +- .../keeper/proposal_server_internal_test.go | 4 +- .../keeper/upgrades_internal_test.go | 3 +- client/x/evmengine/module/depinject.go | 2 + .../testutil/expected_keepers_mocks.go | 41 +- client/x/evmengine/types/expected_keepers.go | 4 + client/x/mint/README.md | 371 ++---------------- client/x/mint/keeper/keeper.go | 36 ++ .../x/mint/keeper/set_inflation_parameters.go | 14 + client/x/mint/types/inflation_contract.go | 36 ++ 14 files changed, 188 insertions(+), 348 deletions(-) create mode 100644 client/x/mint/keeper/set_inflation_parameters.go create mode 100644 client/x/mint/types/inflation_contract.go diff --git a/client/x/evmengine/keeper/abci_internal_test.go b/client/x/evmengine/keeper/abci_internal_test.go index 0206a04c..eca2a1fc 100644 --- a/client/x/evmengine/keeper/abci_internal_test.go +++ b/client/x/evmengine/keeper/abci_internal_test.go @@ -221,6 +221,7 @@ func TestKeeper_PrepareProposal(t *testing.T) { ak := moduletestutil.NewMockAccountKeeper(ctrl) esk := moduletestutil.NewMockEvmStakingKeeper(ctrl) uk := moduletestutil.NewMockUpgradeKeeper(ctrl) + mk := moduletestutil.NewMockMintKeeper(ctrl) if tt.setupMocks != nil { tt.setupMocks(esk) @@ -230,7 +231,7 @@ func TestKeeper_PrepareProposal(t *testing.T) { tt.mockEngine.EngineClient, err = ethclient.NewEngineMock(storeKey) require.NoError(t, err) - k, err := NewKeeper(cdc, storeService, &tt.mockEngine, &tt.mockClient, txConfig, ak, esk, uk) + k, err := NewKeeper(cdc, storeService, &tt.mockEngine, &tt.mockClient, txConfig, ak, esk, uk, mk) require.NoError(t, err) k.SetValidatorAddress(common.BytesToAddress([]byte("test"))) populateGenesisHead(ctx, t, k) @@ -261,11 +262,11 @@ func TestKeeper_PrepareProposal(t *testing.T) { ak := moduletestutil.NewMockAccountKeeper(ctrl) esk := moduletestutil.NewMockEvmStakingKeeper(ctrl) uk := moduletestutil.NewMockUpgradeKeeper(ctrl) - + mk := moduletestutil.NewMockMintKeeper(ctrl) // Expected call for PeekEligibleWithdrawals esk.EXPECT().PeekEligibleWithdrawals(gomock.Any()).Return(nil, nil).AnyTimes() - keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk) + keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, mk) require.NoError(t, err) keeper.SetValidatorAddress(common.BytesToAddress([]byte("test"))) populateGenesisHead(ctx, t, keeper) @@ -446,6 +447,7 @@ func TestKeeper_PostFinalize(t *testing.T) { ak := moduletestutil.NewMockAccountKeeper(ctrl) esk := moduletestutil.NewMockEvmStakingKeeper(ctrl) uk := moduletestutil.NewMockUpgradeKeeper(ctrl) + mk := moduletestutil.NewMockMintKeeper(ctrl) if tt.setupMocks != nil { tt.setupMocks(esk) @@ -464,7 +466,7 @@ func TestKeeper_PostFinalize(t *testing.T) { tt.mockEngine.EngineClient, err = ethclient.NewEngineMock(storeKey) require.NoError(t, err) - k, err := NewKeeper(cdc, storeService, &tt.mockEngine, &tt.mockClient, txConfig, ak, esk, uk) + k, err := NewKeeper(cdc, storeService, &tt.mockEngine, &tt.mockClient, txConfig, ak, esk, uk, mk) require.NoError(t, err) k.SetCometAPI(cmtAPI) k.SetValidatorAddress(nxtAddr) diff --git a/client/x/evmengine/keeper/keeper.go b/client/x/evmengine/keeper/keeper.go index 41e265a3..fe6a6ee7 100644 --- a/client/x/evmengine/keeper/keeper.go +++ b/client/x/evmengine/keeper/keeper.go @@ -41,6 +41,7 @@ type Keeper struct { accountKeeper types.AccountKeeper evmstakingKeeper types.EvmStakingKeeper upgradeKeeper types.UpgradeKeeper + mintKeeper types.MintKeeper upgradeContract *bindings.UpgradeEntrypoint @@ -64,6 +65,7 @@ func NewKeeper( ak types.AccountKeeper, esk types.EvmStakingKeeper, uk types.UpgradeKeeper, + mk types.MintKeeper, ) (*Keeper, error) { schema := &ormv1alpha1.ModuleSchemaDescriptor{SchemaFile: []*ormv1alpha1.ModuleSchemaDescriptor_FileEntry{ {Id: 1, ProtoFileName: File_client_x_evmengine_keeper_evmengine_proto.Path()}, @@ -94,6 +96,7 @@ func NewKeeper( evmstakingKeeper: esk, upgradeKeeper: uk, upgradeContract: upgradeContract, + mintKeeper: mk, }, nil } diff --git a/client/x/evmengine/keeper/keeper_internal_test.go b/client/x/evmengine/keeper/keeper_internal_test.go index 40fd34a9..d9ab3b58 100644 --- a/client/x/evmengine/keeper/keeper_internal_test.go +++ b/client/x/evmengine/keeper/keeper_internal_test.go @@ -49,12 +49,13 @@ func createTestKeeper(t *testing.T) (context.Context, *Keeper) { ak := moduletestutil.NewMockAccountKeeper(ctrl) esk := moduletestutil.NewMockEvmStakingKeeper(ctrl) uk := moduletestutil.NewMockUpgradeKeeper(ctrl) + mk := moduletestutil.NewMockMintKeeper(ctrl) ctx, storeKey, storeService := setupCtxStore(t, &header) mockEngine, err := newMockEngineAPI(storeKey, 0) require.NoError(t, err) - keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk) + keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, mk) require.NoError(t, err) keeper.SetCometAPI(cmtAPI) @@ -78,11 +79,12 @@ func createKeeper(t *testing.T, args args) (sdk.Context, *mockCometAPI, *Keeper) ak := moduletestutil.NewMockAccountKeeper(ctrl) esk := moduletestutil.NewMockEvmStakingKeeper(ctrl) uk := moduletestutil.NewMockUpgradeKeeper(ctrl) + mk := moduletestutil.NewMockMintKeeper(ctrl) ctx, storeKey, storeService := setupCtxStore(t, &header) mockEngine, err := newMockEngineAPI(storeKey, 0) require.NoError(t, err) - keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk) + keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, mk) require.NoError(t, err) keeper.SetCometAPI(cmtAPI) keeper.SetValidatorAddress(nxtAddr) diff --git a/client/x/evmengine/keeper/msg_server.go b/client/x/evmengine/keeper/msg_server.go index 01591507..fb77c4c4 100644 --- a/client/x/evmengine/keeper/msg_server.go +++ b/client/x/evmengine/keeper/msg_server.go @@ -115,6 +115,9 @@ func (s msgServer) ExecutionPayload(ctx context.Context, msg *types.MsgExecution if err := s.ProcessUpgradeEvents(ctx, payload.Number-1, msg.PrevPayloadEvents); err != nil { return nil, errors.Wrap(err, "deliver upgrade-related event logs") } + if err := s.mintKeeper.ProcessInflationEvents(ctx, payload.Number-1, msg.PrevPayloadEvents); err != nil { + return nil, errors.Wrap(err, "deliver inflation-related event logs") + } if err := s.updateExecutionHead(ctx, payload); err != nil { return nil, errors.Wrap(err, "update execution head") diff --git a/client/x/evmengine/keeper/msg_server_internal_test.go b/client/x/evmengine/keeper/msg_server_internal_test.go index e2378bca..25692afa 100644 --- a/client/x/evmengine/keeper/msg_server_internal_test.go +++ b/client/x/evmengine/keeper/msg_server_internal_test.go @@ -40,6 +40,7 @@ func Test_msgServer_ExecutionPayload(t *testing.T) { ak := moduletestutil.NewMockAccountKeeper(ctrl) esk := moduletestutil.NewMockEvmStakingKeeper(ctrl) uk := moduletestutil.NewMockUpgradeKeeper(ctrl) + mk := moduletestutil.NewMockMintKeeper(ctrl) cmtAPI := newMockCometAPI(t, nil) // set the header and proposer so we have the correct next proposer @@ -53,7 +54,7 @@ func Test_msgServer_ExecutionPayload(t *testing.T) { evmLogProc := mockLogProvider{deliverErr: errors.New("test error")} mockEngine, err := newMockEngineAPI(storeKey, 2) require.NoError(t, err) - keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk) + keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, mk) require.NoError(t, err) keeper.SetCometAPI(cmtAPI) keeper.SetValidatorAddress(nxtAddr) diff --git a/client/x/evmengine/keeper/proposal_server_internal_test.go b/client/x/evmengine/keeper/proposal_server_internal_test.go index 96c9d5ec..45e590a9 100644 --- a/client/x/evmengine/keeper/proposal_server_internal_test.go +++ b/client/x/evmengine/keeper/proposal_server_internal_test.go @@ -34,14 +34,14 @@ func Test_proposalServer_ExecutionPayload(t *testing.T) { ak := moduletestutil.NewMockAccountKeeper(ctrl) esk := moduletestutil.NewMockEvmStakingKeeper(ctrl) uk := moduletestutil.NewMockUpgradeKeeper(ctrl) - + mk := moduletestutil.NewMockMintKeeper(ctrl) esk.EXPECT().PeekEligibleWithdrawals(gomock.Any()).Return(nil, nil).AnyTimes() sdkCtx, storeKey, storeService := setupCtxStore(t, &cmtproto.Header{AppHash: tutil.RandomHash().Bytes()}) sdkCtx = sdkCtx.WithExecMode(sdk.ExecModeFinalize) mockEngine, err := newMockEngineAPI(storeKey, 0) require.NoError(t, err) - keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk) + keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, mk) require.NoError(t, err) populateGenesisHead(sdkCtx, t, keeper) propSrv := NewProposalServer(keeper) diff --git a/client/x/evmengine/keeper/upgrades_internal_test.go b/client/x/evmengine/keeper/upgrades_internal_test.go index 722c69a1..8aea641f 100644 --- a/client/x/evmengine/keeper/upgrades_internal_test.go +++ b/client/x/evmengine/keeper/upgrades_internal_test.go @@ -262,12 +262,13 @@ func setupTestEnvironment(t *testing.T) (*Keeper, sdk.Context, *gomock.Controlle ak := moduletestutil.NewMockAccountKeeper(ctrl) esk := moduletestutil.NewMockEvmStakingKeeper(ctrl) uk := moduletestutil.NewMockUpgradeKeeper(ctrl) + mk := moduletestutil.NewMockMintKeeper(ctrl) ctx, storeKey, storeService := setupCtxStore(t, &header) mockEngine, err := newMockEngineAPI(storeKey, 0) require.NoError(t, err) - keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk) + keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, mk) require.NoError(t, err) keeper.SetCometAPI(cmtAPI) nxtAddr, err := k1util.PubKeyToAddress(cmtAPI.validatorSet.Validators[1].PubKey) diff --git a/client/x/evmengine/module/depinject.go b/client/x/evmengine/module/depinject.go index 25b66a39..e35d3dd4 100644 --- a/client/x/evmengine/module/depinject.go +++ b/client/x/evmengine/module/depinject.go @@ -36,6 +36,7 @@ type ModuleInputs struct { AccountKeeper types.AccountKeeper EvmStakingKeeper types.EvmStakingKeeper UpgradeKeeper types.UpgradeKeeper + MintKeeper types.MintKeeper } type ModuleOutputs struct { @@ -56,6 +57,7 @@ func ProvideModule(in ModuleInputs) (ModuleOutputs, error) { in.AccountKeeper, in.EvmStakingKeeper, in.UpgradeKeeper, + in.MintKeeper, ) if err != nil { return ModuleOutputs{}, err diff --git a/client/x/evmengine/testutil/expected_keepers_mocks.go b/client/x/evmengine/testutil/expected_keepers_mocks.go index 3d40b6cc..b6b265c7 100644 --- a/client/x/evmengine/testutil/expected_keepers_mocks.go +++ b/client/x/evmengine/testutil/expected_keepers_mocks.go @@ -1,9 +1,9 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: ../client/x/evmengine/types/expected_keepers.go +// Source: ./client/x/evmengine/types/expected_keepers.go // // Generated by this command: // -// mockgen -source=../client/x/evmengine/types/expected_keepers.go -package testutil -destination ../client/x/evmengine/testutil/expected_keepers_mocks.go +// mockgen -source=./client/x/evmengine/types/expected_keepers.go -package testutil -destination ./client/x/evmengine/testutil/expected_keepers_mocks.go // // Package testutil is a generated GoMock package. @@ -219,3 +219,40 @@ func (mr *MockUpgradeKeeperMockRecorder) ScheduleUpgrade(ctx, plan any) *gomock. mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ScheduleUpgrade", reflect.TypeOf((*MockUpgradeKeeper)(nil).ScheduleUpgrade), ctx, plan) } + +// MockMintKeeper is a mock of MintKeeper interface. +type MockMintKeeper struct { + ctrl *gomock.Controller + recorder *MockMintKeeperMockRecorder +} + +// MockMintKeeperMockRecorder is the mock recorder for MockMintKeeper. +type MockMintKeeperMockRecorder struct { + mock *MockMintKeeper +} + +// NewMockMintKeeper creates a new mock instance. +func NewMockMintKeeper(ctrl *gomock.Controller) *MockMintKeeper { + mock := &MockMintKeeper{ctrl: ctrl} + mock.recorder = &MockMintKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMintKeeper) EXPECT() *MockMintKeeperMockRecorder { + return m.recorder +} + +// ProcessInflationEvents mocks base method. +func (m *MockMintKeeper) ProcessInflationEvents(ctx context.Context, height uint64, logs []*types2.EVMEvent) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ProcessInflationEvents", ctx, height, logs) + ret0, _ := ret[0].(error) + return ret0 +} + +// ProcessInflationEvents indicates an expected call of ProcessInflationEvents. +func (mr *MockMintKeeperMockRecorder) ProcessInflationEvents(ctx, height, logs any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProcessInflationEvents", reflect.TypeOf((*MockMintKeeper)(nil).ProcessInflationEvents), ctx, height, logs) +} diff --git a/client/x/evmengine/types/expected_keepers.go b/client/x/evmengine/types/expected_keepers.go index 59ca321f..401899f8 100644 --- a/client/x/evmengine/types/expected_keepers.go +++ b/client/x/evmengine/types/expected_keepers.go @@ -28,3 +28,7 @@ type EvmStakingKeeper interface { type UpgradeKeeper interface { ScheduleUpgrade(ctx context.Context, plan upgradetypes.Plan) error } + +type MintKeeper interface { + ProcessInflationEvents(ctx context.Context, height uint64, logs []*EVMEvent) error +} diff --git a/client/x/mint/README.md b/client/x/mint/README.md index 80198010..d7a41e42 100644 --- a/client/x/mint/README.md +++ b/client/x/mint/README.md @@ -6,79 +6,52 @@ sidebar_position: 1 ## Contents -* [State](#state) - * [Minter](#minter) - * [Params](#params) -* [Begin-Block](#begin-block) - * [NextInflationRate](#nextinflationrate) - * [NextAnnualProvisions](#nextannualprovisions) - * [BlockProvision](#blockprovision) -* [Parameters](#parameters) -* [Events](#events) - * [BeginBlocker](#beginblocker) -* [Client](#client) - * [CLI](#cli) - * [gRPC](#grpc) - * [REST](#rest) - -## Concepts - -### The Minting Mechanism - -The minting mechanism was designed to: - -* allow for a flexible inflation rate determined by market demand targeting a particular bonded-stake ratio -* effect a balance between market liquidity and staked supply - -In order to best determine the appropriate market rate for inflation rewards, a -moving change rate is used. The moving change rate mechanism ensures that if -the % bonded is either over or under the goal %-bonded, the inflation rate will -adjust to further incentivize or disincentivize being bonded, respectively. Setting the goal -%-bonded at less than 100% encourages the network to maintain some non-staked tokens -which should help provide some liquidity. - -It can be broken down in the following way: - -* If the actual percentage of bonded tokens is below the goal %-bonded the inflation rate will - increase until a maximum value is reached -* If the goal % bonded (67% in Cosmos-Hub) is maintained, then the inflation - rate will stay constant -* If the actual percentage of bonded tokens is above the goal %-bonded the inflation rate will - decrease until a minimum value is reached - +- [`x/mint`](#xmint) + - [Contents](#contents) + - [State](#state) + - [Params](#params) + - [Begin-Block](#begin-block) + - [Inflation amount calculation](#inflation-amount-calculation) + - [Parameters](#parameters) + - [Events](#events) + - [BeginBlocker](#beginblocker) ## State -### Minter - -The minter is a space for holding current inflation information. - -* Minter: `0x00 -> ProtocolBuffer(minter)` - -```protobuf reference -https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/mint/v1beta1/mint.proto#L10-L24 -``` - ### Params The mint module stores its params in state with the prefix of `0x01`, -it can be updated with governance or the address with authority. +it can be updated by authority via specific smart contract. * Params: `mint/params -> legacy_amino(params)` -```protobuf reference -https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/mint/v1beta1/mint.proto#L26-L59 +```protobuf +message Params { + option (amino.name) = "client/x/mint/Params"; + + // type of coin to mint + string mint_denom = 1; + // inflation amount per year + string inflations_per_year = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; + // expected blocks per year + uint64 blocks_per_year = ; +} ``` ## Begin-Block -Minting parameters are recalculated and inflation paid at the beginning of each block. +Minting parameters are calculated and inflation paid at the beginning of each block. -### Inflation rate calculation +### Inflation amount calculation -Inflation rate is calculated using an "inflation calculation function" that's +Inflation amount is calculated using an "inflation calculation function" that's passed to the `NewAppModule` function. If no function is passed, then the SDK's -default inflation function will be used (`NextInflationRate`). In case a custom +default inflation function will be used (`DefaultInflationCalculationFn`). In case a custom inflation calculation logic is needed, this can be achieved by defining and passing a function that matches `InflationCalculationFn`'s signature. @@ -86,65 +59,15 @@ passing a function that matches `InflationCalculationFn`'s signature. type InflationCalculationFn func(ctx sdk.Context, minter Minter, params Params, bondedRatio math.LegacyDec) math.LegacyDec ``` -#### NextInflationRate - -The target annual inflation rate is recalculated each block. -The inflation is also subject to a rate change (positive or negative) -depending on the distance from the desired ratio (67%). The maximum rate change -possible is defined to be 13% per year, however, the annual inflation is capped -as between 7% and 20%. - -```go -NextInflationRate(params Params, bondedRatio math.LegacyDec) (inflation math.LegacyDec) { - inflationRateChangePerYear = (1 - bondedRatio/params.GoalBonded) * params.InflationRateChange - inflationRateChange = inflationRateChangePerYear/blocksPerYr - - // increase the new annual inflation for this next block - inflation += inflationRateChange - if inflation > params.InflationMax { - inflation = params.InflationMax - } - if inflation < params.InflationMin { - inflation = params.InflationMin - } - - return inflation -} -``` - -### NextAnnualProvisions - -Calculate the annual provisions based on current total supply and inflation -rate. This parameter is calculated once per block. - -```go -NextAnnualProvisions(params Params, totalSupply math.LegacyDec) (provisions math.LegacyDec) { - return Inflation * totalSupply -``` - -### BlockProvision - -Calculate the provisions generated for each block based on current annual provisions. The provisions are then minted by the `mint` module's `ModuleMinterAccount` and then transferred to the `auth`'s `FeeCollector` `ModuleAccount`. - -```go -BlockProvision(params Params) sdk.Coin { - provisionAmt = AnnualProvisions/ params.BlocksPerYear - return sdk.NewCoin(params.MintDenom, provisionAmt.Truncate()) -``` - - ## Parameters The minting module contains the following parameters: -| Key | Type | Example | -|---------------------|-----------------|------------------------| -| MintDenom | string | "uatom" | -| InflationRateChange | string (dec) | "0.130000000000000000" | -| InflationMax | string (dec) | "0.200000000000000000" | -| InflationMin | string (dec) | "0.070000000000000000" | -| GoalBonded | string (dec) | "0.670000000000000000" | -| BlocksPerYear | string (uint64) | "6311520" | +| Key | Type | Example | +|---------------------|-----------------|------------------------------| +| MintDenom | string | "stake" | +| InflationsPerYear | string (dec) | "2460000.000000000000000000" | +| BlocksPerYear | string (uint64) | "6311520" | ## Events @@ -156,228 +79,4 @@ The minting module emits the following events: | Type | Attribute Key | Attribute Value | |------|-------------------|--------------------| | mint | bonded_ratio | {bondedRatio} | -| mint | inflation | {inflation} | -| mint | annual_provisions | {annualProvisions} | | mint | amount | {amount} | - - -## Client - -### CLI - -A user can query and interact with the `mint` module using the CLI. - -#### Query - -The `query` commands allows users to query `mint` state. - -```shell -simd query mint --help -``` - -##### annual-provisions - -The `annual-provisions` command allows users to query the current minting annual provisions value - -```shell -simd query mint annual-provisions [flags] -``` - -Example: - -```shell -simd query mint annual-provisions -``` - -Example Output: - -```shell -22268504368893.612100895088410693 -``` - -##### inflation - -The `inflation` command allows users to query the current minting inflation value - -```shell -simd query mint inflation [flags] -``` - -Example: - -```shell -simd query mint inflation -``` - -Example Output: - -```shell -0.199200302563256955 -``` - -##### params - -The `params` command allows users to query the current minting parameters - -```shell -simd query mint params [flags] -``` - -Example: - -```yml -blocks_per_year: "4360000" -goal_bonded: "0.670000000000000000" -inflation_max: "0.200000000000000000" -inflation_min: "0.070000000000000000" -inflation_rate_change: "0.130000000000000000" -mint_denom: stake -``` - -### gRPC - -A user can query the `mint` module using gRPC endpoints. - -#### AnnualProvisions - -The `AnnualProvisions` endpoint allows users to query the current minting annual provisions value - -```shell -/cosmos.mint.v1beta1.Query/AnnualProvisions -``` - -Example: - -```shell -grpcurl -plaintext localhost:9090 cosmos.mint.v1beta1.Query/AnnualProvisions -``` - -Example Output: - -```json -{ - "annualProvisions": "1432452520532626265712995618" -} -``` - -#### Inflation - -The `Inflation` endpoint allows users to query the current minting inflation value - -```shell -/cosmos.mint.v1beta1.Query/Inflation -``` - -Example: - -```shell -grpcurl -plaintext localhost:9090 cosmos.mint.v1beta1.Query/Inflation -``` - -Example Output: - -```json -{ - "inflation": "130197115720711261" -} -``` - -#### Params - -The `Params` endpoint allows users to query the current minting parameters - -```shell -/cosmos.mint.v1beta1.Query/Params -``` - -Example: - -```shell -grpcurl -plaintext localhost:9090 cosmos.mint.v1beta1.Query/Params -``` - -Example Output: - -```json -{ - "params": { - "mintDenom": "stake", - "inflationRateChange": "130000000000000000", - "inflationMax": "200000000000000000", - "inflationMin": "70000000000000000", - "goalBonded": "670000000000000000", - "blocksPerYear": "6311520" - } -} -``` - -### REST - -A user can query the `mint` module using REST endpoints. - -#### annual-provisions - -```shell -/cosmos/mint/v1beta1/annual_provisions -``` - -Example: - -```shell -curl "localhost:1317/cosmos/mint/v1beta1/annual_provisions" -``` - -Example Output: - -```json -{ - "annualProvisions": "1432452520532626265712995618" -} -``` - -#### inflation - -```shell -/cosmos/mint/v1beta1/inflation -``` - -Example: - -```shell -curl "localhost:1317/cosmos/mint/v1beta1/inflation" -``` - -Example Output: - -```json -{ - "inflation": "130197115720711261" -} -``` - -#### params - -```shell -/cosmos/mint/v1beta1/params -``` - -Example: - -```shell -curl "localhost:1317/cosmos/mint/v1beta1/params" -``` - -Example Output: - -```json -{ - "params": { - "mintDenom": "stake", - "inflationRateChange": "130000000000000000", - "inflationMax": "200000000000000000", - "inflationMin": "70000000000000000", - "goalBonded": "670000000000000000", - "blocksPerYear": "6311520" - } -} -``` diff --git a/client/x/mint/keeper/keeper.go b/client/x/mint/keeper/keeper.go index 8e8f18ff..32206e83 100644 --- a/client/x/mint/keeper/keeper.go +++ b/client/x/mint/keeper/keeper.go @@ -4,6 +4,7 @@ package keeper import ( "context" "fmt" + "math/big" "cosmossdk.io/collections" storetypes "cosmossdk.io/core/store" @@ -13,7 +14,11 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + evmenginetypes "github.com/piplabs/story/client/x/evmengine/types" "github.com/piplabs/story/client/x/mint/types" + "github.com/piplabs/story/contracts/bindings" + "github.com/piplabs/story/lib/errors" + clog "github.com/piplabs/story/lib/log" ) // Keeper of the mint store. @@ -24,6 +29,8 @@ type Keeper struct { bankKeeper types.BankKeeper feeCollectorName string + inflationUpdateContract *bindings.IPTokenStaking // (rayden) TODO + Schema collections.Schema Params collections.Item[types.Params] } @@ -95,3 +102,32 @@ func (k Keeper) MintCoins(ctx context.Context, newCoins sdk.Coins) error { func (k Keeper) AddCollectedFees(ctx context.Context, fees sdk.Coins) error { return k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, k.feeCollectorName, fees) } + +func (k Keeper) ProcessInflationEvents(ctx context.Context, height uint64, logs []*evmenginetypes.EVMEvent) error { + gwei, exp := big.NewInt(10), big.NewInt(9) + gwei.Exp(gwei, exp, nil) + + for _, evmLog := range logs { + if err := evmLog.Verify(); err != nil { + return errors.Wrap(err, "verify log [BUG]") // This shouldn't happen + } + ethlog := evmLog.ToEthLog() + + // (rayden) TODO: handle when each event processing fails. + if ethlog.Topics[0] == types.SetInflationParameters.ID { + ev, err := k.inflationUpdateContract.ParseDeposit(ethlog) + if err != nil { + clog.Error(ctx, "Failed to parse SetInflationParameters log", err) + continue + } + if err = k.ProcessSetInflationParameters(ctx, ev); err != nil { + clog.Error(ctx, "Failed to process update inflation parameters", err) + continue + } + } + } + + clog.Debug(ctx, "Processed inflation events", "height", height, "count", len(logs)) + + return nil +} diff --git a/client/x/mint/keeper/set_inflation_parameters.go b/client/x/mint/keeper/set_inflation_parameters.go new file mode 100644 index 00000000..70de29cb --- /dev/null +++ b/client/x/mint/keeper/set_inflation_parameters.go @@ -0,0 +1,14 @@ +package keeper + +import ( + "context" + + "github.com/piplabs/story/contracts/bindings" +) + +//nolint:revive // (rayden) TODO +func (k Keeper) ProcessSetInflationParameters(ctx context.Context, ev *bindings.IPTokenStakingDeposit) error { + // (rayden) TODO + + return nil +} diff --git a/client/x/mint/types/inflation_contract.go b/client/x/mint/types/inflation_contract.go new file mode 100644 index 00000000..d00ae4ce --- /dev/null +++ b/client/x/mint/types/inflation_contract.go @@ -0,0 +1,36 @@ +package types + +import ( + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + + "github.com/piplabs/story/contracts/bindings" +) + +// (rayden) TODO. +var ( + inflationUpdateABI = mustGetABI(bindings.IPTokenStakingMetaData) + SetInflationParameters = mustGetEvent(inflationUpdateABI, "SetInflationParameters") +) + +// mustGetABI returns the metadata's ABI as an abi.ABI type. +// It panics on error. +func mustGetABI(metadata *bind.MetaData) *abi.ABI { + abi, err := metadata.GetAbi() + if err != nil { + panic(err) + } + + return abi +} + +// mustGetEvent returns the event with the given name from the ABI. +// It panics if the event is not found. +func mustGetEvent(abi *abi.ABI, name string) abi.Event { + event, ok := abi.Events[name] + if !ok { + panic("event not found") + } + + return event +} From 028eec81c2d36224c5119ac3b33b9fc1f8e64514 Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Thu, 3 Oct 2024 15:26:37 -0700 Subject: [PATCH 08/14] feat(mint): mint module api --- client/app/app.go | 6 ++++++ client/app/keepers/types.go | 2 ++ client/server/mint.go | 28 +++++++++++++++++++++++++ client/server/server.go | 3 +++ client/x/mint/keeper/grpc_query.go | 10 ++++----- client/x/mint/keeper/grpc_query_test.go | 2 +- client/x/mint/module/module.go | 2 +- 7 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 client/server/mint.go diff --git a/client/app/app.go b/client/app/app.go index 18820584..6927b903 100644 --- a/client/app/app.go +++ b/client/app/app.go @@ -24,6 +24,7 @@ import ( "github.com/piplabs/story/client/app/keepers" "github.com/piplabs/story/client/comet" evmstakingkeeper "github.com/piplabs/story/client/x/evmstaking/keeper" + mintkeeper "github.com/piplabs/story/client/x/mint/keeper" "github.com/piplabs/story/lib/errors" "github.com/piplabs/story/lib/ethclient" @@ -94,6 +95,7 @@ func newApp( &app.Keepers.EpochsKeeper, &app.Keepers.EvmStakingKeeper, &app.Keepers.EVMEngKeeper, + &app.Keepers.MintKeeper, ); err != nil { return nil, errors.Wrap(err, "dep inject") } @@ -206,3 +208,7 @@ func (a App) GetDistrKeeper() distrkeeper.Keeper { func (a App) GetUpgradeKeeper() *upgradekeeper.Keeper { return a.Keepers.UpgradeKeeper } + +func (a App) GetMintKeeper() mintkeeper.Keeper { + return a.Keepers.MintKeeper +} diff --git a/client/app/keepers/types.go b/client/app/keepers/types.go index 7b21abdc..71e85a94 100644 --- a/client/app/keepers/types.go +++ b/client/app/keepers/types.go @@ -18,6 +18,7 @@ import ( epochskeeper "github.com/piplabs/story/client/x/epochs/keeper" evmengkeeper "github.com/piplabs/story/client/x/evmengine/keeper" evmstakingkeeper "github.com/piplabs/story/client/x/evmstaking/keeper" + mintkeeper "github.com/piplabs/story/client/x/mint/keeper" ) // Keepers includes all possible keepers. We separated it into a separate struct to make it easier to scaffold upgrades. @@ -36,4 +37,5 @@ type Keepers struct { EvmStakingKeeper *evmstakingkeeper.Keeper EVMEngKeeper *evmengkeeper.Keeper EpochsKeeper *epochskeeper.Keeper + MintKeeper mintkeeper.Keeper } diff --git a/client/server/mint.go b/client/server/mint.go new file mode 100644 index 00000000..76051229 --- /dev/null +++ b/client/server/mint.go @@ -0,0 +1,28 @@ +package server + +import ( + "net/http" + + "github.com/piplabs/story/client/server/utils" + "github.com/piplabs/story/client/x/mint/keeper" + minttypes "github.com/piplabs/story/client/x/mint/types" +) + +func (s *Server) initMintRoute() { + s.httpMux.HandleFunc("/mint/params", utils.SimpleWrap(s.aminoCodec, s.GetMintParams)) +} + +// GetMintParams queries params of the mint module. +func (s *Server) GetMintParams(r *http.Request) (resp any, err error) { + queryContext, err := s.createQueryContextByHeader(r) + if err != nil { + return nil, err + } + + queryResp, err := keeper.NewQuerier(s.store.GetMintKeeper()).Params(queryContext, &minttypes.QueryParamsRequest{}) + if err != nil { + return nil, err + } + + return queryResp, nil +} diff --git a/client/server/server.go b/client/server/server.go index ce31c476..d866c549 100644 --- a/client/server/server.go +++ b/client/server/server.go @@ -28,6 +28,7 @@ import ( "github.com/gorilla/mux" evmstakingkeeper "github.com/piplabs/story/client/x/evmstaking/keeper" + mintkeeper "github.com/piplabs/story/client/x/mint/keeper" ) type Store interface { @@ -39,6 +40,7 @@ type Store interface { GetBankKeeper() bankkeeper.Keeper GetDistrKeeper() distrkeeper.Keeper GetUpgradeKeeper() *upgradekeeper.Keeper + GetMintKeeper() mintkeeper.Keeper } type Server struct { @@ -121,6 +123,7 @@ func (s *Server) registerHandle() { s.initSlashingRoute() s.initStakingRoute() s.initUpgradeRoute() + s.initMintRoute() } func (s *Server) createQueryContextByHeader(r *http.Request) (sdk.Context, error) { diff --git a/client/x/mint/keeper/grpc_query.go b/client/x/mint/keeper/grpc_query.go index 1a677391..de614f23 100644 --- a/client/x/mint/keeper/grpc_query.go +++ b/client/x/mint/keeper/grpc_query.go @@ -6,18 +6,18 @@ import ( "github.com/piplabs/story/client/x/mint/types" ) -var _ types.QueryServer = queryServer{} +var _ types.QueryServer = Querier{} -func NewQueryServerImpl(k Keeper) types.QueryServer { - return queryServer{k} +func NewQuerier(k Keeper) types.QueryServer { + return Querier{k} } -type queryServer struct { +type Querier struct { k Keeper } // Params returns params of the mint module. -func (q queryServer) Params(ctx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { +func (q Querier) Params(ctx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { params, err := q.k.Params.Get(ctx) if err != nil { return nil, err diff --git a/client/x/mint/keeper/grpc_query_test.go b/client/x/mint/keeper/grpc_query_test.go index 0ca2dc67..63b433d6 100644 --- a/client/x/mint/keeper/grpc_query_test.go +++ b/client/x/mint/keeper/grpc_query_test.go @@ -58,7 +58,7 @@ func (suite *MintTestSuite) SetupTest() { suite.Require().NoError(err) queryHelper := baseapp.NewQueryServerTestHelper(testCtx.Ctx, encCfg.InterfaceRegistry) - types.RegisterQueryServer(queryHelper, keeper.NewQueryServerImpl(suite.mintKeeper)) + types.RegisterQueryServer(queryHelper, keeper.NewQuerier(suite.mintKeeper)) suite.queryClient = types.NewQueryClient(queryHelper) } diff --git a/client/x/mint/module/module.go b/client/x/mint/module/module.go index 1abc263f..02d8a85a 100644 --- a/client/x/mint/module/module.go +++ b/client/x/mint/module/module.go @@ -108,7 +108,7 @@ func NewAppModule( // RegisterServices registers a gRPC query service to respond to the // module-specific gRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.keeper)) } // InitGenesis performs genesis initialization for the mint module. It returns From 37ffe1a1f0b1f248f344444fe309d1bd564f910e Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Thu, 3 Oct 2024 15:55:47 -0700 Subject: [PATCH 09/14] feat(mint): placeholder for param change events --- client/x/mint/keeper/keeper.go | 39 +++++------------------ client/x/mint/types/inflation_contract.go | 2 +- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/client/x/mint/keeper/keeper.go b/client/x/mint/keeper/keeper.go index 32206e83..0f1d9394 100644 --- a/client/x/mint/keeper/keeper.go +++ b/client/x/mint/keeper/keeper.go @@ -4,7 +4,6 @@ package keeper import ( "context" "fmt" - "math/big" "cosmossdk.io/collections" storetypes "cosmossdk.io/core/store" @@ -17,7 +16,6 @@ import ( evmenginetypes "github.com/piplabs/story/client/x/evmengine/types" "github.com/piplabs/story/client/x/mint/types" "github.com/piplabs/story/contracts/bindings" - "github.com/piplabs/story/lib/errors" clog "github.com/piplabs/story/lib/log" ) @@ -51,12 +49,13 @@ func NewKeeper( sb := collections.NewSchemaBuilder(storeService) k := Keeper{ - cdc: cdc, - storeService: storeService, - stakingKeeper: sk, - bankKeeper: bk, - feeCollectorName: feeCollectorName, - Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), + cdc: cdc, + storeService: storeService, + stakingKeeper: sk, + bankKeeper: bk, + feeCollectorName: feeCollectorName, + inflationUpdateContract: nil, + Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), } schema, err := sb.Build() @@ -104,29 +103,7 @@ func (k Keeper) AddCollectedFees(ctx context.Context, fees sdk.Coins) error { } func (k Keeper) ProcessInflationEvents(ctx context.Context, height uint64, logs []*evmenginetypes.EVMEvent) error { - gwei, exp := big.NewInt(10), big.NewInt(9) - gwei.Exp(gwei, exp, nil) - - for _, evmLog := range logs { - if err := evmLog.Verify(); err != nil { - return errors.Wrap(err, "verify log [BUG]") // This shouldn't happen - } - ethlog := evmLog.ToEthLog() - - // (rayden) TODO: handle when each event processing fails. - if ethlog.Topics[0] == types.SetInflationParameters.ID { - ev, err := k.inflationUpdateContract.ParseDeposit(ethlog) - if err != nil { - clog.Error(ctx, "Failed to parse SetInflationParameters log", err) - continue - } - if err = k.ProcessSetInflationParameters(ctx, ev); err != nil { - clog.Error(ctx, "Failed to process update inflation parameters", err) - continue - } - } - } - + // (rayden) TODO clog.Debug(ctx, "Processed inflation events", "height", height, "count", len(logs)) return nil diff --git a/client/x/mint/types/inflation_contract.go b/client/x/mint/types/inflation_contract.go index d00ae4ce..113232c3 100644 --- a/client/x/mint/types/inflation_contract.go +++ b/client/x/mint/types/inflation_contract.go @@ -10,7 +10,7 @@ import ( // (rayden) TODO. var ( inflationUpdateABI = mustGetABI(bindings.IPTokenStakingMetaData) - SetInflationParameters = mustGetEvent(inflationUpdateABI, "SetInflationParameters") + SetInflationParameters = mustGetEvent(inflationUpdateABI, "Deposit") ) // mustGetABI returns the metadata's ABI as an abi.ABI type. From 4632fa4f567705538a8ad1495e7889616b95386d Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Thu, 3 Oct 2024 16:45:07 -0700 Subject: [PATCH 10/14] feat(mint): fix unit test --- client/x/evmengine/keeper/msg_server_internal_test.go | 1 + client/x/evmengine/testutil/expected_keepers_mocks.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/x/evmengine/keeper/msg_server_internal_test.go b/client/x/evmengine/keeper/msg_server_internal_test.go index 25692afa..b3f93cdc 100644 --- a/client/x/evmengine/keeper/msg_server_internal_test.go +++ b/client/x/evmengine/keeper/msg_server_internal_test.go @@ -100,6 +100,7 @@ func Test_msgServer_ExecutionPayload(t *testing.T) { setup: func(c context.Context) sdk.Context { esk.EXPECT().DequeueEligibleWithdrawals(c).Return(nil, nil) esk.EXPECT().ProcessStakingEvents(c, gomock.Any(), gomock.Any()).Return(nil) + mk.EXPECT().ProcessInflationEvents(c, gomock.Any(), gomock.Any()).Return(nil) return sdk.UnwrapSDKContext(c) }, diff --git a/client/x/evmengine/testutil/expected_keepers_mocks.go b/client/x/evmengine/testutil/expected_keepers_mocks.go index b6b265c7..cd96969d 100644 --- a/client/x/evmengine/testutil/expected_keepers_mocks.go +++ b/client/x/evmengine/testutil/expected_keepers_mocks.go @@ -1,9 +1,9 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: ./client/x/evmengine/types/expected_keepers.go +// Source: ../client/x/evmengine/types/expected_keepers.go // // Generated by this command: // -// mockgen -source=./client/x/evmengine/types/expected_keepers.go -package testutil -destination ./client/x/evmengine/testutil/expected_keepers_mocks.go +// mockgen -source=../client/x/evmengine/types/expected_keepers.go -package testutil -destination ../client/x/evmengine/testutil/expected_keepers_mocks.go // // Package testutil is a generated GoMock package. From d2ba2c718b6f320dccd49fcaa49d9853fd2c77b2 Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Fri, 4 Oct 2024 17:05:05 -0700 Subject: [PATCH 11/14] feat(mint): fix based on comments --- client/app/app_config.go | 2 +- client/x/mint/keeper/abci.go | 10 ++-- client/x/mint/keeper/genesis_test.go | 3 +- client/x/mint/module/module.go | 2 +- client/x/mint/types/events.go | 2 - client/x/mint/types/genesis.go | 4 +- client/x/mint/types/mint.pb.go | 80 +++++++++++----------------- client/x/mint/types/mint.proto | 9 +--- client/x/mint/types/params.go | 4 +- 9 files changed, 41 insertions(+), 75 deletions(-) diff --git a/client/app/app_config.go b/client/app/app_config.go index 8e4fc0cc..193befd6 100644 --- a/client/app/app_config.go +++ b/client/app/app_config.go @@ -78,6 +78,7 @@ var ( genesisModuleOrder = []string{ authtypes.ModuleName, banktypes.ModuleName, + minttypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, @@ -88,7 +89,6 @@ var ( epochstypes.ModuleName, evmenginetypes.ModuleName, evmstakingtypes.ModuleName, - minttypes.ModuleName, } // NOTE: upgrade module must come first, as upgrades might break state schema. diff --git a/client/x/mint/keeper/abci.go b/client/x/mint/keeper/abci.go index 87de2d16..3fb8198e 100644 --- a/client/x/mint/keeper/abci.go +++ b/client/x/mint/keeper/abci.go @@ -3,6 +3,8 @@ package keeper import ( "context" + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" @@ -18,13 +20,8 @@ func (k Keeper) BeginBlocker(ctx context.Context, ic types.InflationCalculationF return err } - bondedRatio, err := k.BondedRatio(ctx) - if err != nil { - return err - } - // mint coins, update supply - mintedCoinAmt := ic(ctx, params, bondedRatio) + mintedCoinAmt := ic(ctx, params, math.LegacyNewDec(0)) // NOTE: bondedRatio is not used in current implementation. mintedCoin := sdk.NewCoin(params.MintDenom, mintedCoinAmt.TruncateInt()) mintedCoins := sdk.NewCoins(mintedCoin) if err := k.MintCoins(ctx, mintedCoins); err != nil { @@ -44,7 +41,6 @@ func (k Keeper) BeginBlocker(ctx context.Context, ic types.InflationCalculationF sdkCtx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeMint, - sdk.NewAttribute(types.AttributeKeyBondedRatio, bondedRatio.String()), sdk.NewAttribute(sdk.AttributeKeyAmount, mintedCoin.Amount.String()), ), ) diff --git a/client/x/mint/keeper/genesis_test.go b/client/x/mint/keeper/genesis_test.go index a68ac4fc..affa5818 100644 --- a/client/x/mint/keeper/genesis_test.go +++ b/client/x/mint/keeper/genesis_test.go @@ -4,7 +4,6 @@ package keeper_test import ( "testing" - "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" @@ -63,7 +62,7 @@ func (s *GenesisTestSuite) TestImportExportGenesis() { genesisState := types.DefaultGenesisState() genesisState.Params = types.NewParams( "testDenom", - math.LegacyNewDecWithPrec(24625000, 0), + 24625000_000_000_000, uint64(60*60*8766/5), ) diff --git a/client/x/mint/module/module.go b/client/x/mint/module/module.go index 02d8a85a..9b1cff08 100644 --- a/client/x/mint/module/module.go +++ b/client/x/mint/module/module.go @@ -21,7 +21,7 @@ import ( ) // ConsensusVersion defines the current x/mint module consensus version. -const ConsensusVersion = 2 +const ConsensusVersion = 1 var ( _ module.AppModuleBasic = AppModule{} diff --git a/client/x/mint/types/events.go b/client/x/mint/types/events.go index 708da313..053d12a3 100644 --- a/client/x/mint/types/events.go +++ b/client/x/mint/types/events.go @@ -3,6 +3,4 @@ package types // Minting module event types. const ( EventTypeMint = ModuleName - - AttributeKeyBondedRatio = "bonded_ratio" ) diff --git a/client/x/mint/types/genesis.go b/client/x/mint/types/genesis.go index 2adb0289..ff80226e 100644 --- a/client/x/mint/types/genesis.go +++ b/client/x/mint/types/genesis.go @@ -11,11 +11,11 @@ import ( // bondedRatio and returns the newly calculated inflation amount. // It can be used to specify a custom inflation calculation logic, instead of relying on the // default logic provided by the sdk. -type InflationCalculationFn func(ctx context.Context, params Params, _ math.LegacyDec) math.LegacyDec +type InflationCalculationFn func(ctx context.Context, params Params, bondedRatio math.LegacyDec) math.LegacyDec // DefaultInflationCalculationFn is the default function used to calculate inflation. func DefaultInflationCalculationFn(_ context.Context, params Params, _ math.LegacyDec) math.LegacyDec { - return params.InflationsPerYear.QuoInt64(int64(params.BlocksPerYear)) + return math.LegacyNewDec(int64(params.InflationsPerYear)).Quo(math.LegacyNewDec(int64(params.BlocksPerYear))) } // NewGenesisState creates a new GenesisState object. diff --git a/client/x/mint/types/mint.pb.go b/client/x/mint/types/mint.pb.go index 5a225b11..59f0e424 100644 --- a/client/x/mint/types/mint.pb.go +++ b/client/x/mint/types/mint.pb.go @@ -4,11 +4,8 @@ package types import ( - cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" - _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -31,7 +28,7 @@ type Params struct { // type of coin to mint MintDenom string `protobuf:"bytes,1,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` // inflation amount per year - InflationsPerYear cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=inflations_per_year,json=inflationsPerYear,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflations_per_year"` + InflationsPerYear uint64 `protobuf:"varint,2,opt,name=inflations_per_year,json=inflationsPerYear,proto3" json:"inflations_per_year,omitempty"` // expected blocks per year BlocksPerYear uint64 `protobuf:"varint,3,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty"` } @@ -76,6 +73,13 @@ func (m *Params) GetMintDenom() string { return "" } +func (m *Params) GetInflationsPerYear() uint64 { + if m != nil { + return m.InflationsPerYear + } + return 0 +} + func (m *Params) GetBlocksPerYear() uint64 { if m != nil { return m.BlocksPerYear @@ -90,26 +94,21 @@ func init() { func init() { proto.RegisterFile("client/x/mint/types/mint.proto", fileDescriptor_9c6e60aec58f52af) } var fileDescriptor_9c6e60aec58f52af = []byte{ - // 295 bytes of a gzipped FileDescriptorProto + // 219 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0xaf, 0xd0, 0xcf, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x06, 0x33, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x84, 0x21, 0xf2, 0x7a, 0x15, 0x7a, 0x60, 0x41, - 0xb0, 0xbc, 0x94, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, 0x58, 0x5e, 0x1f, 0xc4, 0x82, 0x28, 0x95, 0x92, - 0x4c, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0x8e, 0x87, 0x48, 0x40, 0x38, 0x50, 0x29, 0xc1, 0xc4, 0xdc, - 0xcc, 0xbc, 0x7c, 0x7d, 0x30, 0x09, 0x11, 0x52, 0xba, 0xc4, 0xc8, 0xc5, 0x16, 0x90, 0x58, 0x94, - 0x98, 0x5b, 0x2c, 0x24, 0xcb, 0xc5, 0x05, 0x32, 0x3c, 0x3e, 0x25, 0x35, 0x2f, 0x3f, 0x57, 0x82, - 0x51, 0x81, 0x51, 0x83, 0x33, 0x88, 0x13, 0x24, 0xe2, 0x02, 0x12, 0x10, 0x4a, 0xe3, 0x12, 0xce, - 0xcc, 0x4b, 0xcb, 0x49, 0x2c, 0xc9, 0xcc, 0xcf, 0x2b, 0x8e, 0x2f, 0x48, 0x2d, 0x8a, 0xaf, 0x4c, - 0x4d, 0x2c, 0x92, 0x60, 0x02, 0xa9, 0x73, 0x32, 0x3b, 0x71, 0x4f, 0x9e, 0xe1, 0xd6, 0x3d, 0x79, - 0x69, 0x88, 0x7d, 0xc5, 0x29, 0xd9, 0x7a, 0x99, 0xf9, 0xfa, 0xb9, 0x89, 0x25, 0x19, 0x7a, 0x3e, - 0xa9, 0xe9, 0x89, 0xc9, 0x95, 0x2e, 0xa9, 0xc9, 0x97, 0xb6, 0xe8, 0x72, 0x41, 0x9d, 0xe3, 0x92, - 0x9a, 0xbc, 0xe2, 0xf9, 0x06, 0x2d, 0xc6, 0x20, 0x41, 0x84, 0x91, 0x01, 0xa9, 0x45, 0x91, 0xa9, - 0x89, 0x45, 0x42, 0x6a, 0x5c, 0xfc, 0x49, 0x39, 0xf9, 0xc9, 0xd9, 0x48, 0x76, 0x30, 0x2b, 0x30, - 0x6a, 0xb0, 0x04, 0xf1, 0x42, 0x84, 0xa1, 0xea, 0xac, 0x24, 0xbb, 0x9e, 0x6f, 0xd0, 0x12, 0x41, - 0x0d, 0x37, 0x88, 0x4f, 0x9c, 0x74, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, - 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, - 0x4a, 0x18, 0x4b, 0x38, 0x27, 0xb1, 0x81, 0x83, 0xc2, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x05, - 0x53, 0x24, 0x0d, 0x85, 0x01, 0x00, 0x00, + 0xb0, 0xbc, 0x94, 0x60, 0x62, 0x6e, 0x66, 0x5e, 0xbe, 0x3e, 0x98, 0x84, 0xa8, 0x53, 0x9a, 0xc5, + 0xc8, 0xc5, 0x16, 0x90, 0x58, 0x94, 0x98, 0x5b, 0x2c, 0x24, 0xcb, 0xc5, 0x05, 0x52, 0x1b, 0x9f, + 0x92, 0x9a, 0x97, 0x9f, 0x2b, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0xc4, 0x09, 0x12, 0x71, 0x01, + 0x09, 0x08, 0xe9, 0x71, 0x09, 0x67, 0xe6, 0xa5, 0xe5, 0x24, 0x96, 0x64, 0xe6, 0xe7, 0x15, 0xc7, + 0x17, 0xa4, 0x16, 0xc5, 0x57, 0xa6, 0x26, 0x16, 0x49, 0x30, 0x29, 0x30, 0x6a, 0xb0, 0x04, 0x09, + 0x22, 0xa4, 0x02, 0x52, 0x8b, 0x22, 0x53, 0x13, 0x8b, 0x84, 0xd4, 0xb8, 0xf8, 0x93, 0x72, 0xf2, + 0x93, 0xb3, 0x91, 0xd4, 0x32, 0x83, 0xd5, 0xf2, 0x42, 0x84, 0xa1, 0xea, 0xac, 0x24, 0xbb, 0x9e, + 0x6f, 0xd0, 0x12, 0x41, 0xf5, 0x0e, 0xc4, 0x45, 0x4e, 0xba, 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, 0x25, 0x8c, 0xc5, 0xfb, 0x49, 0x6c, 0x60, 0x2f, 0x19, 0x03, 0x02, 0x00, + 0x00, 0xff, 0xff, 0xd9, 0x4d, 0x19, 0x4f, 0x1c, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -137,16 +136,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x18 } - { - size := m.InflationsPerYear.Size() - i -= size - if _, err := m.InflationsPerYear.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintMint(dAtA, i, uint64(size)) + if m.InflationsPerYear != 0 { + i = encodeVarintMint(dAtA, i, uint64(m.InflationsPerYear)) + i-- + dAtA[i] = 0x10 } - i-- - dAtA[i] = 0x12 if len(m.MintDenom) > 0 { i -= len(m.MintDenom) copy(dAtA[i:], m.MintDenom) @@ -178,8 +172,9 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovMint(uint64(l)) } - l = m.InflationsPerYear.Size() - n += 1 + l + sovMint(uint64(l)) + if m.InflationsPerYear != 0 { + n += 1 + sovMint(uint64(m.InflationsPerYear)) + } if m.BlocksPerYear != 0 { n += 1 + sovMint(uint64(m.BlocksPerYear)) } @@ -254,10 +249,10 @@ func (m *Params) Unmarshal(dAtA []byte) error { m.MintDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field InflationsPerYear", wireType) } - var stringLen uint64 + m.InflationsPerYear = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowMint @@ -267,26 +262,11 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.InflationsPerYear |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.InflationsPerYear.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field BlocksPerYear", wireType) diff --git a/client/x/mint/types/mint.proto b/client/x/mint/types/mint.proto index 49fce484..509ccd8f 100644 --- a/client/x/mint/types/mint.proto +++ b/client/x/mint/types/mint.proto @@ -3,8 +3,6 @@ package client.x.mint.types; option go_package = "client/x/mint/types"; -import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; import "amino/amino.proto"; // Params defines the parameters for the x/mint module. @@ -14,12 +12,7 @@ message Params { // type of coin to mint string mint_denom = 1; // inflation amount per year - string inflations_per_year = 2 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; + uint64 inflations_per_year = 2; // expected blocks per year uint64 blocks_per_year = 3; } diff --git a/client/x/mint/types/params.go b/client/x/mint/types/params.go index 57dd0e9a..cc5197a3 100644 --- a/client/x/mint/types/params.go +++ b/client/x/mint/types/params.go @@ -13,7 +13,7 @@ import ( ) // NewParams returns Params instance with the given values. -func NewParams(mintDenom string, inflationsPerYear math.LegacyDec, blocksPerYear uint64) Params { +func NewParams(mintDenom string, inflationsPerYear uint64, blocksPerYear uint64) Params { return Params{ MintDenom: mintDenom, InflationsPerYear: inflationsPerYear, @@ -25,7 +25,7 @@ func NewParams(mintDenom string, inflationsPerYear math.LegacyDec, blocksPerYear func DefaultParams() Params { return Params{ MintDenom: sdk.DefaultBondDenom, - InflationsPerYear: math.LegacyNewDecWithPrec(24625000, 2), + InflationsPerYear: 24625000_000_000_000, BlocksPerYear: uint64(60 * 60 * 8766 / 5), // assuming 5 second block times } } From 6d3572229d6a13e0bbb5358c51b67ebcc5bb3560 Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Fri, 4 Oct 2024 17:06:55 -0700 Subject: [PATCH 12/14] feat(mint): fix based on comments --- client/app/app_config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/app/app_config.go b/client/app/app_config.go index 193befd6..3a5c5b98 100644 --- a/client/app/app_config.go +++ b/client/app/app_config.go @@ -78,11 +78,11 @@ var ( genesisModuleOrder = []string{ authtypes.ModuleName, banktypes.ModuleName, - minttypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, + minttypes.ModuleName, genutiltypes.ModuleName, upgradetypes.ModuleName, // Story modules From 577d59fd7f9eb638e495e82b3a5044b80b299305 Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Fri, 4 Oct 2024 17:11:35 -0700 Subject: [PATCH 13/14] feat(mint): update readme --- client/x/mint/README.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/client/x/mint/README.md b/client/x/mint/README.md index d7a41e42..b7c8d585 100644 --- a/client/x/mint/README.md +++ b/client/x/mint/README.md @@ -32,12 +32,7 @@ message Params { // type of coin to mint string mint_denom = 1; // inflation amount per year - string inflations_per_year = 2 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; + uint64 inflations_per_year = 2; // expected blocks per year uint64 blocks_per_year = ; } @@ -66,7 +61,7 @@ The minting module contains the following parameters: | Key | Type | Example | |---------------------|-----------------|------------------------------| | MintDenom | string | "stake" | -| InflationsPerYear | string (dec) | "2460000.000000000000000000" | +| InflationsPerYear | string (dec) | "24625000000000000" | | BlocksPerYear | string (uint64) | "6311520" | @@ -78,5 +73,4 @@ The minting module emits the following events: | Type | Attribute Key | Attribute Value | |------|-------------------|--------------------| -| mint | bonded_ratio | {bondedRatio} | | mint | amount | {amount} | From 5126446c595c7a062904f2be40d0fbe84f0568e4 Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Fri, 4 Oct 2024 17:13:21 -0700 Subject: [PATCH 14/14] feat(mint): update readme --- client/x/mint/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/x/mint/README.md b/client/x/mint/README.md index b7c8d585..600267c3 100644 --- a/client/x/mint/README.md +++ b/client/x/mint/README.md @@ -61,7 +61,7 @@ The minting module contains the following parameters: | Key | Type | Example | |---------------------|-----------------|------------------------------| | MintDenom | string | "stake" | -| InflationsPerYear | string (dec) | "24625000000000000" | +| InflationsPerYear | string (dec) | "24625000000000000" | | BlocksPerYear | string (uint64) | "6311520" |