feat: deprecate x/params usage in x/mint (#12363)
This commit is contained in:
parent
61dc02329a
commit
4675cb54f3
@ -48,6 +48,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* [#12153](https://github.com/cosmos/cosmos-sdk/pull/12153) Add a new `NewSimulationManagerFromAppModules` constructor, to simplify simulation wiring.
|
||||
* [#12187](https://github.com/cosmos/cosmos-sdk/pull/12187) Add batch operation for x/nft module.
|
||||
|
||||
### State Machine Breaking
|
||||
|
||||
* (x/mint) [#12363](https://github.com/cosmos/cosmos-sdk/pull/12363) Migrate `x/mint` to self-managed parameters and deprecate it's usage of `x/params`.
|
||||
|
||||
### API Breaking Changes
|
||||
|
||||
* (x/gov) [#12368](https://github.com/cosmos/cosmos-sdk/pull/12369) Gov keeper is now passed by reference instead of copy to make post-construction mutation of Hooks and Proposal Handlers possible at a framework level.
|
||||
|
||||
@ -548,7 +548,7 @@ type GenesisState struct {
|
||||
|
||||
// minter is a space for holding current inflation information.
|
||||
Minter *Minter `protobuf:"bytes,1,opt,name=minter,proto3" json:"minter,omitempty"`
|
||||
// params defines all the paramaters of the module.
|
||||
// params defines all the parameters of the module.
|
||||
Params *Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@ -1281,7 +1281,7 @@ func (x *Minter) GetAnnualProvisions() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Params holds parameters for the mint module.
|
||||
// Params defines the parameters for the x/mint module.
|
||||
type Params struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
||||
1091
api/cosmos/mint/v1beta1/tx.pulsar.go
Normal file
1091
api/cosmos/mint/v1beta1/tx.pulsar.go
Normal file
File diff suppressed because it is too large
Load Diff
113
api/cosmos/mint/v1beta1/tx_grpc.pb.go
Normal file
113
api/cosmos/mint/v1beta1/tx_grpc.pb.go
Normal file
@ -0,0 +1,113 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc (unknown)
|
||||
// source: cosmos/mint/v1beta1/tx.proto
|
||||
|
||||
package mintv1beta1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// MsgClient is the client API for Msg service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type MsgClient interface {
|
||||
// UpdateParams defines a governance operation for updating the x/mint module
|
||||
// parameters. The authority is hard-coded 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 grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewMsgClient(cc grpc.ClientConnInterface) 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, "/cosmos.mint.v1beta1.Msg/UpdateParams", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MsgServer is the server API for Msg service.
|
||||
// All implementations must embed UnimplementedMsgServer
|
||||
// for forward compatibility
|
||||
type MsgServer interface {
|
||||
// UpdateParams defines a governance operation for updating the x/mint module
|
||||
// parameters. The authority is hard-coded to the x/gov module account.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
|
||||
mustEmbedUnimplementedMsgServer()
|
||||
}
|
||||
|
||||
// UnimplementedMsgServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedMsgServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
|
||||
}
|
||||
func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {}
|
||||
|
||||
// UnsafeMsgServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to MsgServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeMsgServer interface {
|
||||
mustEmbedUnimplementedMsgServer()
|
||||
}
|
||||
|
||||
func RegisterMsgServer(s grpc.ServiceRegistrar, 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: "/cosmos.mint.v1beta1.Msg/UpdateParams",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Msg_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "cosmos.mint.v1beta1.Msg",
|
||||
HandlerType: (*MsgServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "UpdateParams",
|
||||
Handler: _Msg_UpdateParams_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cosmos/mint/v1beta1/tx.proto",
|
||||
}
|
||||
Binary file not shown.
@ -11,6 +11,6 @@ message GenesisState {
|
||||
// minter is a space for holding current inflation information.
|
||||
Minter minter = 1 [(gogoproto.nullable) = false];
|
||||
|
||||
// params defines all the paramaters of the module.
|
||||
// params defines all the parameters of the module.
|
||||
Params params = 2 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ message Minter {
|
||||
];
|
||||
}
|
||||
|
||||
// Params holds parameters for the mint module.
|
||||
// Params defines the parameters for the x/mint module.
|
||||
message Params {
|
||||
option (gogoproto.goproto_stringer) = false;
|
||||
|
||||
|
||||
39
proto/cosmos/mint/v1beta1/tx.proto
Normal file
39
proto/cosmos/mint/v1beta1/tx.proto
Normal file
@ -0,0 +1,39 @@
|
||||
syntax = "proto3";
|
||||
package cosmos.mint.v1beta1;
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types";
|
||||
|
||||
import "cosmos/msg/v1/msg.proto";
|
||||
import "cosmos/mint/v1beta1/mint.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
|
||||
// Msg defines the x/mint Msg service.
|
||||
service Msg {
|
||||
// UpdateParams defines a governance operation for updating the x/mint module
|
||||
// parameters. The authority is hard-coded 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";
|
||||
|
||||
// authority is the address of the governance account.
|
||||
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];
|
||||
}
|
||||
|
||||
// MsgUpdateParamsResponse defines the response structure for executing a
|
||||
// MsgUpdateParams message.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
message MsgUpdateParamsResponse {}
|
||||
43
types/module/testutil/codec.go
Normal file
43
types/module/testutil/codec.go
Normal file
@ -0,0 +1,43 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/std"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
)
|
||||
|
||||
// TestEncodingConfig defines an encoding configuration that is used for testing
|
||||
// purposes. Note, MakeTestEncodingConfig takes a series of AppModuleBasic types
|
||||
// which should only contain the relevant module being tested and any potential
|
||||
// dependencies.
|
||||
type TestEncodingConfig struct {
|
||||
InterfaceRegistry types.InterfaceRegistry
|
||||
Codec codec.Codec
|
||||
TxConfig client.TxConfig
|
||||
Amino *codec.LegacyAmino
|
||||
}
|
||||
|
||||
func MakeTestEncodingConfig(modules ...module.AppModuleBasic) TestEncodingConfig {
|
||||
cdc := codec.NewLegacyAmino()
|
||||
interfaceRegistry := types.NewInterfaceRegistry()
|
||||
codec := codec.NewProtoCodec(interfaceRegistry)
|
||||
|
||||
encCfg := TestEncodingConfig{
|
||||
InterfaceRegistry: interfaceRegistry,
|
||||
Codec: codec,
|
||||
TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes),
|
||||
Amino: cdc,
|
||||
}
|
||||
|
||||
mb := module.NewBasicManager(modules...)
|
||||
|
||||
std.RegisterLegacyAminoCodec(encCfg.Amino)
|
||||
std.RegisterInterfaces(encCfg.InterfaceRegistry)
|
||||
mb.RegisterLegacyAminoCodec(encCfg.Amino)
|
||||
mb.RegisterInterfaces(encCfg.InterfaceRegistry)
|
||||
|
||||
return encCfg
|
||||
}
|
||||
18
x/mint/exported/exported.go
Normal file
18
x/mint/exported/exported.go
Normal file
@ -0,0 +1,18 @@
|
||||
package exported
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
type (
|
||||
ParamSet = paramtypes.ParamSet
|
||||
|
||||
// Subspace defines an interface that implements the legacy x/params Subspace
|
||||
// type.
|
||||
//
|
||||
// NOTE: This is used solely for migration of x/params managed parameters.
|
||||
Subspace interface {
|
||||
GetParamSet(ctx sdk.Context, ps ParamSet)
|
||||
}
|
||||
)
|
||||
@ -1,6 +1,8 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
@ -8,45 +10,51 @@ import (
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// Keeper of the mint store
|
||||
type Keeper struct {
|
||||
cdc codec.BinaryCodec
|
||||
storeKey storetypes.StoreKey
|
||||
paramSpace paramtypes.Subspace
|
||||
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
|
||||
}
|
||||
|
||||
// NewKeeper creates a new mint Keeper instance
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace,
|
||||
sk types.StakingKeeper, ak types.AccountKeeper, bk types.BankKeeper,
|
||||
cdc codec.BinaryCodec,
|
||||
key storetypes.StoreKey,
|
||||
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("the mint module account has not been set")
|
||||
}
|
||||
|
||||
// set KeyTable if it has not already been set
|
||||
if !paramSpace.HasKeyTable() {
|
||||
paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable())
|
||||
panic(fmt.Sprintf("the x/%s module account has not been set", types.ModuleName))
|
||||
}
|
||||
|
||||
return Keeper{
|
||||
cdc: cdc,
|
||||
storeKey: key,
|
||||
paramSpace: paramSpace,
|
||||
stakingKeeper: sk,
|
||||
bankKeeper: bk,
|
||||
feeCollectorName: feeCollectorName,
|
||||
authority: authority,
|
||||
}
|
||||
}
|
||||
|
||||
// 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 sdk.Context) log.Logger {
|
||||
return ctx.Logger().With("module", "x/"+types.ModuleName)
|
||||
@ -55,31 +63,45 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
||||
// get the minter
|
||||
func (k Keeper) GetMinter(ctx sdk.Context) (minter types.Minter) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
b := store.Get(types.MinterKey)
|
||||
if b == nil {
|
||||
bz := store.Get(types.MinterKey)
|
||||
if bz == nil {
|
||||
panic("stored minter should not have been nil")
|
||||
}
|
||||
|
||||
k.cdc.MustUnmarshal(b, &minter)
|
||||
k.cdc.MustUnmarshal(bz, &minter)
|
||||
return
|
||||
}
|
||||
|
||||
// set the minter
|
||||
func (k Keeper) SetMinter(ctx sdk.Context, minter types.Minter) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
b := k.cdc.MustMarshal(&minter)
|
||||
store.Set(types.MinterKey, b)
|
||||
bz := k.cdc.MustMarshal(&minter)
|
||||
store.Set(types.MinterKey, bz)
|
||||
}
|
||||
|
||||
// GetParams returns the total set of minting parameters.
|
||||
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
|
||||
k.paramSpace.GetParamSet(ctx, ¶ms)
|
||||
return params
|
||||
// SetParams sets the x/mint module parameters.
|
||||
func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error {
|
||||
if err := p.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := k.cdc.MustMarshal(&p)
|
||||
store.Set(types.ParamsKey, bz)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetParams sets the total set of minting parameters.
|
||||
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
|
||||
k.paramSpace.SetParamSet(ctx, ¶ms)
|
||||
// GetParams returns the current x/mint module parameters.
|
||||
func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(types.ParamsKey)
|
||||
if bz == nil {
|
||||
return p
|
||||
}
|
||||
|
||||
k.cdc.MustUnmarshal(bz, &p)
|
||||
return p
|
||||
}
|
||||
|
||||
// StakingTokenSupply implements an alias call to the underlying staking keeper's
|
||||
|
||||
86
x/mint/keeper/keeper_test.go
Normal file
86
x/mint/keeper/keeper_test.go
Normal file
@ -0,0 +1,86 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
type IntegrationTestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
app *simapp.SimApp
|
||||
ctx sdk.Context
|
||||
msgServer types.MsgServer
|
||||
}
|
||||
|
||||
func TestKeeperTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(IntegrationTestSuite))
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) SetupTest() {
|
||||
app := simapp.Setup(s.T(), false)
|
||||
ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()})
|
||||
|
||||
s.app = app
|
||||
s.ctx = ctx
|
||||
s.msgServer = keeper.NewMsgServerImpl(s.app.MintKeeper)
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestParams() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
input types.Params
|
||||
expectErr bool
|
||||
}{
|
||||
{
|
||||
name: "set invalid params",
|
||||
input: types.Params{
|
||||
MintDenom: sdk.DefaultBondDenom,
|
||||
InflationRateChange: sdk.NewDecWithPrec(-13, 2),
|
||||
InflationMax: sdk.NewDecWithPrec(20, 2),
|
||||
InflationMin: sdk.NewDecWithPrec(7, 2),
|
||||
GoalBonded: sdk.NewDecWithPrec(67, 2),
|
||||
BlocksPerYear: uint64(60 * 60 * 8766 / 5),
|
||||
},
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "set full valid params",
|
||||
input: types.Params{
|
||||
MintDenom: sdk.DefaultBondDenom,
|
||||
InflationRateChange: sdk.NewDecWithPrec(8, 2),
|
||||
InflationMax: sdk.NewDecWithPrec(20, 2),
|
||||
InflationMin: sdk.NewDecWithPrec(2, 2),
|
||||
GoalBonded: sdk.NewDecWithPrec(37, 2),
|
||||
BlocksPerYear: uint64(60 * 60 * 8766 / 5),
|
||||
},
|
||||
expectErr: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
expected := s.app.MintKeeper.GetParams(s.ctx)
|
||||
err := s.app.MintKeeper.SetParams(s.ctx, tc.input)
|
||||
if tc.expectErr {
|
||||
s.Require().Error(err)
|
||||
} else {
|
||||
expected = tc.input
|
||||
s.Require().NoError(err)
|
||||
}
|
||||
|
||||
p := s.app.MintKeeper.GetParams(s.ctx)
|
||||
s.Require().Equal(expected, p)
|
||||
})
|
||||
}
|
||||
}
|
||||
28
x/mint/keeper/migrator.go
Normal file
28
x/mint/keeper/migrator.go
Normal file
@ -0,0 +1,28 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/exported"
|
||||
v2 "github.com/cosmos/cosmos-sdk/x/mint/migrations/v2"
|
||||
)
|
||||
|
||||
// Migrator is a struct for handling in-place state migrations.
|
||||
type Migrator struct {
|
||||
keeper Keeper
|
||||
legacySubspace exported.Subspace
|
||||
}
|
||||
|
||||
func NewMigrator(k Keeper, ss exported.Subspace) Migrator {
|
||||
return Migrator{
|
||||
keeper: k,
|
||||
legacySubspace: ss,
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate1to2 migrates the x/mint module state from the consensus version 1 to
|
||||
// version 2. Specifically, it takes the parameters that are currently stored
|
||||
// and managed by the x/params modules and stores them directly into the x/mint
|
||||
// module state.
|
||||
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
|
||||
return v2.Migrate(ctx, ctx.KVStore(m.keeper.storeKey), m.legacySubspace, m.keeper.cdc)
|
||||
}
|
||||
36
x/mint/keeper/msg_server.go
Normal file
36
x/mint/keeper/msg_server.go
Normal file
@ -0,0 +1,36 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/errors"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
var _ types.MsgServer = msgServer{}
|
||||
|
||||
type msgServer struct {
|
||||
Keeper
|
||||
}
|
||||
|
||||
// NewMsgServerImpl returns an implementation of the x/mint MsgServer interface.
|
||||
func NewMsgServerImpl(k Keeper) types.MsgServer {
|
||||
return &msgServer{
|
||||
Keeper: k,
|
||||
}
|
||||
}
|
||||
|
||||
func (ms msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
|
||||
if ms.authority != req.Authority {
|
||||
return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.authority, req.Authority)
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
if err := ms.SetParams(ctx, req.Params); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.MsgUpdateParamsResponse{}, nil
|
||||
}
|
||||
64
x/mint/keeper/msg_server_test.go
Normal file
64
x/mint/keeper/msg_server_test.go
Normal file
@ -0,0 +1,64 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
func (s *IntegrationTestSuite) TestUpdateParams() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
request *types.MsgUpdateParams
|
||||
expectErr bool
|
||||
}{
|
||||
{
|
||||
name: "set invalid authority",
|
||||
request: &types.MsgUpdateParams{
|
||||
Authority: "foo",
|
||||
},
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "set invalid params",
|
||||
request: &types.MsgUpdateParams{
|
||||
Authority: s.app.MintKeeper.GetAuthority(),
|
||||
Params: types.Params{
|
||||
MintDenom: sdk.DefaultBondDenom,
|
||||
InflationRateChange: sdk.NewDecWithPrec(-13, 2),
|
||||
InflationMax: sdk.NewDecWithPrec(20, 2),
|
||||
InflationMin: sdk.NewDecWithPrec(7, 2),
|
||||
GoalBonded: sdk.NewDecWithPrec(67, 2),
|
||||
BlocksPerYear: uint64(60 * 60 * 8766 / 5),
|
||||
},
|
||||
},
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "set full valid params",
|
||||
request: &types.MsgUpdateParams{
|
||||
Authority: s.app.MintKeeper.GetAuthority(),
|
||||
Params: types.Params{
|
||||
MintDenom: sdk.DefaultBondDenom,
|
||||
InflationRateChange: sdk.NewDecWithPrec(8, 2),
|
||||
InflationMax: sdk.NewDecWithPrec(20, 2),
|
||||
InflationMin: sdk.NewDecWithPrec(2, 2),
|
||||
GoalBonded: sdk.NewDecWithPrec(37, 2),
|
||||
BlocksPerYear: uint64(60 * 60 * 8766 / 5),
|
||||
},
|
||||
},
|
||||
expectErr: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
s.Run(tc.name, func() {
|
||||
_, err := s.msgServer.UpdateParams(s.ctx, tc.request)
|
||||
if tc.expectErr {
|
||||
s.Require().Error(err)
|
||||
} else {
|
||||
s.Require().NoError(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
39
x/mint/migrations/v2/migrate.go
Normal file
39
x/mint/migrations/v2/migrate.go
Normal file
@ -0,0 +1,39 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
const (
|
||||
ModuleName = "mint"
|
||||
)
|
||||
|
||||
var (
|
||||
ParamsKey = []byte{0x01}
|
||||
)
|
||||
|
||||
// Migrate migrates the x/mint module state from the consensus version 1 to
|
||||
// version 2. Specifically, it takes the parameters that are currently stored
|
||||
// and managed by the x/params modules and stores them directly into the x/mint
|
||||
// module state.
|
||||
func Migrate(
|
||||
ctx sdk.Context,
|
||||
store sdk.KVStore,
|
||||
legacySubspace exported.Subspace,
|
||||
cdc codec.BinaryCodec,
|
||||
) error {
|
||||
var currParams types.Params
|
||||
legacySubspace.GetParamSet(ctx, &currParams)
|
||||
|
||||
if err := currParams.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
bz := cdc.MustMarshal(&currParams)
|
||||
store.Set(ParamsKey, bz)
|
||||
|
||||
return nil
|
||||
}
|
||||
45
x/mint/migrations/v2/migrator_test.go
Normal file
45
x/mint/migrations/v2/migrator_test.go
Normal file
@ -0,0 +1,45 @@
|
||||
package v2_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/exported"
|
||||
v2 "github.com/cosmos/cosmos-sdk/x/mint/migrations/v2"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
type mockSubspace struct {
|
||||
ps types.Params
|
||||
}
|
||||
|
||||
func newMockSubspace(ps types.Params) mockSubspace {
|
||||
return mockSubspace{ps: ps}
|
||||
}
|
||||
|
||||
func (ms mockSubspace) GetParamSet(ctx sdk.Context, ps exported.ParamSet) {
|
||||
*ps.(*types.Params) = ms.ps
|
||||
}
|
||||
|
||||
func TestMigrate(t *testing.T) {
|
||||
encCfg := moduletestutil.MakeTestEncodingConfig(mint.AppModuleBasic{})
|
||||
cdc := encCfg.Codec
|
||||
|
||||
storeKey := sdk.NewKVStoreKey(v2.ModuleName)
|
||||
tKey := sdk.NewTransientStoreKey("transient_test")
|
||||
ctx := testutil.DefaultContext(storeKey, tKey)
|
||||
store := ctx.KVStore(storeKey)
|
||||
|
||||
legacySubspace := newMockSubspace(types.DefaultParams())
|
||||
require.NoError(t, v2.Migrate(ctx, store, legacySubspace, cdc))
|
||||
|
||||
var res types.Params
|
||||
bz := store.Get(v2.ParamsKey)
|
||||
require.NoError(t, cdc.Unmarshal(bz, &res))
|
||||
require.Equal(t, legacySubspace.ps, res)
|
||||
}
|
||||
@ -6,11 +6,12 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
modulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/spf13/cobra"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
@ -21,15 +22,17 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
|
||||
modulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
// ConsensusVersion defines the current x/mint module consensus version.
|
||||
const ConsensusVersion = 2
|
||||
|
||||
var (
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
@ -49,10 +52,14 @@ func (AppModuleBasic) Name() string {
|
||||
}
|
||||
|
||||
// RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec.
|
||||
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {}
|
||||
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
types.RegisterLegacyAminoCodec(cdc)
|
||||
}
|
||||
|
||||
// RegisterInterfaces registers the module's interface types
|
||||
func (b AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {}
|
||||
func (b AppModuleBasic) RegisterInterfaces(r cdctypes.InterfaceRegistry) {
|
||||
types.RegisterInterfaces(r)
|
||||
}
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the mint
|
||||
// module.
|
||||
@ -92,6 +99,9 @@ type AppModule struct {
|
||||
keeper keeper.Keeper
|
||||
authKeeper types.AccountKeeper
|
||||
|
||||
// legacySubspace is used solely for migration of x/params managed parameters
|
||||
legacySubspace exported.Subspace
|
||||
|
||||
// inflationCalculator is used to calculate the inflation rate during BeginBlock.
|
||||
// If inflationCalculator is nil, the default inflation calculation logic is used.
|
||||
inflationCalculator types.InflationCalculationFn
|
||||
@ -99,15 +109,23 @@ type AppModule struct {
|
||||
|
||||
// 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 {
|
||||
func NewAppModule(
|
||||
cdc codec.Codec,
|
||||
keeper keeper.Keeper,
|
||||
ak types.AccountKeeper,
|
||||
ic types.InflationCalculationFn,
|
||||
ss exported.Subspace,
|
||||
) AppModule {
|
||||
if ic == nil {
|
||||
ic = types.DefaultInflationCalculationFn
|
||||
}
|
||||
|
||||
return AppModule{
|
||||
AppModuleBasic: AppModuleBasic{cdc: cdc},
|
||||
keeper: keeper,
|
||||
authKeeper: ak,
|
||||
inflationCalculator: ic,
|
||||
legacySubspace: ss,
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,7 +153,14 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
|
||||
// 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(), am.keeper)
|
||||
|
||||
m := keeper.NewMigrator(am.keeper, am.legacySubspace)
|
||||
|
||||
if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil {
|
||||
panic(fmt.Sprintf("failed to migrate x/%s from version 1 to 2: %v", types.ModuleName, err))
|
||||
}
|
||||
}
|
||||
|
||||
// InitGenesis performs genesis initialization for the mint module. It returns
|
||||
@ -156,7 +181,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
|
||||
}
|
||||
|
||||
// ConsensusVersion implements AppModule/ConsensusVersion.
|
||||
func (AppModule) ConsensusVersion() uint64 { return 1 }
|
||||
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
|
||||
|
||||
// BeginBlock returns the begin blocker for the mint module.
|
||||
func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
|
||||
@ -196,9 +221,9 @@ func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.Weighte
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// ============================================================================
|
||||
// New App Wiring Setup
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
func init() {
|
||||
appmodule.Register(&modulev1.Module{},
|
||||
@ -213,10 +238,12 @@ func provideModuleBasic() runtime.AppModuleBasicWrapper {
|
||||
type mintInputs struct {
|
||||
depinject.In
|
||||
|
||||
Config *modulev1.Module
|
||||
Key *store.KVStoreKey
|
||||
Cdc codec.Codec
|
||||
Subspace paramstypes.Subspace
|
||||
Config *modulev1.Module
|
||||
Key *store.KVStoreKey
|
||||
Cdc codec.Codec
|
||||
|
||||
// LegacySubspace is used solely for migration of x/params managed parameters
|
||||
LegacySubspace exported.Subspace
|
||||
|
||||
AccountKeeper types.AccountKeeper
|
||||
BankKeeper types.BankKeeper
|
||||
@ -236,8 +263,18 @@ func provideModule(in mintInputs) mintOutputs {
|
||||
feeCollectorName = authtypes.FeeCollectorName
|
||||
}
|
||||
|
||||
k := keeper.NewKeeper(in.Cdc, in.Key, in.Subspace, in.StakingKeeper, in.AccountKeeper, in.BankKeeper, feeCollectorName)
|
||||
m := NewAppModule(in.Cdc, k, in.AccountKeeper, nil) // TODO: allow to set inflation calculation function
|
||||
k := keeper.NewKeeper(
|
||||
in.Cdc,
|
||||
in.Key,
|
||||
in.StakingKeeper,
|
||||
in.AccountKeeper,
|
||||
in.BankKeeper,
|
||||
feeCollectorName,
|
||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
)
|
||||
|
||||
// TODO: allow to set inflation calculation function
|
||||
m := NewAppModule(in.Cdc, k, in.AccountKeeper, nil, in.LegacySubspace)
|
||||
|
||||
return mintOutputs{MintKeeper: k, Module: runtime.WrapAppModule(m)}
|
||||
}
|
||||
|
||||
@ -2,12 +2,41 @@ package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/legacy"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
|
||||
)
|
||||
|
||||
var amino = codec.NewLegacyAmino()
|
||||
var (
|
||||
amino = codec.NewLegacyAmino()
|
||||
ModuleCdc = codec.NewAminoCodec(amino)
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterLegacyAminoCodec(amino)
|
||||
cryptocodec.RegisterCrypto(amino)
|
||||
amino.Seal()
|
||||
sdk.RegisterLegacyAminoCodec(amino)
|
||||
|
||||
// Register all Amino interfaces and concrete types on the authz Amino codec
|
||||
// so that this can later be used to properly serialize MsgGrant and MsgExec
|
||||
// instances.
|
||||
RegisterLegacyAminoCodec(authzcodec.Amino)
|
||||
}
|
||||
|
||||
// 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")
|
||||
}
|
||||
|
||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
registry.RegisterImplementations(
|
||||
(*sdk.Msg)(nil),
|
||||
&MsgUpdateParams{},
|
||||
)
|
||||
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
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 paramaters of the module.
|
||||
// params defines all the parameters of the module.
|
||||
Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"`
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
package types
|
||||
|
||||
// MinterKey is the key to use for the keeper store.
|
||||
var MinterKey = []byte{0x00}
|
||||
var (
|
||||
// MinterKey is the key to use for the keeper store.
|
||||
MinterKey = []byte{0x00}
|
||||
ParamsKey = []byte{0x01}
|
||||
)
|
||||
|
||||
const (
|
||||
// module name
|
||||
|
||||
@ -66,7 +66,7 @@ func (m *Minter) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_Minter proto.InternalMessageInfo
|
||||
|
||||
// Params holds parameters for the mint module.
|
||||
// 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"`
|
||||
|
||||
32
x/mint/types/msgs.go
Normal file
32
x/mint/types/msgs.go
Normal file
@ -0,0 +1,32 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
var _ sdk.Msg = &MsgUpdateParams{}
|
||||
|
||||
// GetSignBytes implements the LegacyMsg interface.
|
||||
func (m MsgUpdateParams) GetSignBytes() []byte {
|
||||
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
|
||||
}
|
||||
|
||||
// GetSigners returns the expected signers for a MsgUpdateParams message.
|
||||
func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress {
|
||||
addr, _ := sdk.AccAddressFromBech32(m.Authority)
|
||||
return []sdk.AccAddress{addr}
|
||||
}
|
||||
|
||||
// ValidateBasic does a sanity check on the provided data.
|
||||
func (m *MsgUpdateParams) ValidateBasic() error {
|
||||
if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
|
||||
return sdkerrors.Wrap(err, "invalid authority address")
|
||||
}
|
||||
|
||||
if err := m.Params.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -8,27 +8,9 @@ import (
|
||||
"sigs.k8s.io/yaml"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
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")
|
||||
)
|
||||
|
||||
// ParamTable for minting module.
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
||||
}
|
||||
|
||||
func NewParams(
|
||||
mintDenom string, inflationRateChange, inflationMax, inflationMin, goalBonded sdk.Dec, blocksPerYear uint64,
|
||||
) Params {
|
||||
func NewParams(mintDenom string, inflationRateChange, inflationMax, inflationMin, goalBonded sdk.Dec, blocksPerYear uint64) Params {
|
||||
return Params{
|
||||
MintDenom: mintDenom,
|
||||
InflationRateChange: inflationRateChange,
|
||||
@ -39,7 +21,7 @@ func NewParams(
|
||||
}
|
||||
}
|
||||
|
||||
// default minting module parameters
|
||||
// DefaultParams returns default x/mint module parameters.
|
||||
func DefaultParams() Params {
|
||||
return Params{
|
||||
MintDenom: sdk.DefaultBondDenom,
|
||||
@ -87,18 +69,6 @@ func (p Params) String() string {
|
||||
return string(out)
|
||||
}
|
||||
|
||||
// Implements params.ParamSet
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
func validateMintDenom(i interface{}) error {
|
||||
v, ok := i.(string)
|
||||
if !ok {
|
||||
|
||||
41
x/mint/types/params_legacy.go
Normal file
41
x/mint/types/params_legacy.go
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
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")
|
||||
)
|
||||
|
||||
// ParamTable for minting module.
|
||||
//
|
||||
// NOTE: Deprecated.
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
||||
}
|
||||
|
||||
// Implements params.ParamSet
|
||||
//
|
||||
// NOTE: 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),
|
||||
}
|
||||
}
|
||||
603
x/mint/types/tx.pb.go
Normal file
603
x/mint/types/tx.pb.go
Normal file
@ -0,0 +1,603 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: cosmos/mint/v1beta1/tx.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
_ "github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
grpc1 "github.com/gogo/protobuf/grpc"
|
||||
proto "github.com/gogo/protobuf/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 of the governance account.
|
||||
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_a0d933a8bf5e188a, []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_a0d933a8bf5e188a, []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), "cosmos.mint.v1beta1.MsgUpdateParams")
|
||||
proto.RegisterType((*MsgUpdateParamsResponse)(nil), "cosmos.mint.v1beta1.MsgUpdateParamsResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("cosmos/mint/v1beta1/tx.proto", fileDescriptor_a0d933a8bf5e188a) }
|
||||
|
||||
var fileDescriptor_a0d933a8bf5e188a = []byte{
|
||||
// 311 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xce, 0x2f, 0xce,
|
||||
0xcd, 0x2f, 0xd6, 0xcf, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4,
|
||||
0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xc8, 0xea, 0x81, 0x64, 0xf5,
|
||||
0xa0, 0xb2, 0x52, 0xe2, 0x30, 0x2d, 0xc5, 0xe9, 0xfa, 0x65, 0x86, 0x20, 0x0a, 0xa2, 0x5a, 0x4a,
|
||||
0x0e, 0x9b, 0x59, 0x60, 0xad, 0x10, 0x79, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x30, 0x53, 0x1f, 0xc4,
|
||||
0x82, 0x8a, 0x4a, 0x42, 0x74, 0xc5, 0x43, 0x24, 0xa0, 0x16, 0x82, 0x39, 0x4a, 0x53, 0x18, 0xb9,
|
||||
0xf8, 0x7d, 0x8b, 0xd3, 0x43, 0x0b, 0x52, 0x12, 0x4b, 0x52, 0x03, 0x12, 0x8b, 0x12, 0x73, 0x8b,
|
||||
0x85, 0xcc, 0xb8, 0x38, 0x13, 0x4b, 0x4b, 0x32, 0xf2, 0x8b, 0x32, 0x4b, 0x2a, 0x25, 0x18, 0x15,
|
||||
0x18, 0x35, 0x38, 0x9d, 0x24, 0x2e, 0x6d, 0xd1, 0x15, 0x81, 0x6a, 0x74, 0x4c, 0x49, 0x29, 0x4a,
|
||||
0x2d, 0x2e, 0x0e, 0x2e, 0x29, 0xca, 0xcc, 0x4b, 0x0f, 0x42, 0x28, 0x15, 0xb2, 0xe4, 0x62, 0x2b,
|
||||
0x00, 0x9b, 0x20, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xad, 0x87, 0xc5, 0x6f, 0x7a, 0x10,
|
||||
0x4b, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, 0x6a, 0xb0, 0xe2, 0x6b, 0x7a, 0xbe, 0x41,
|
||||
0x0b, 0x61, 0x94, 0x92, 0x24, 0x97, 0x38, 0x9a, 0xab, 0x82, 0x52, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a,
|
||||
0x53, 0x8d, 0x32, 0xb9, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0x92, 0xb8, 0x78, 0x50, 0x1c, 0xad, 0x82,
|
||||
0xd5, 0x32, 0x34, 0x43, 0xa4, 0x74, 0x88, 0x51, 0x05, 0xb3, 0xca, 0xc9, 0xf9, 0xc4, 0x23, 0x39,
|
||||
0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63,
|
||||
0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x34, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92,
|
||||
0xf3, 0x73, 0xa1, 0xe1, 0x09, 0xa5, 0x74, 0x8b, 0x53, 0xb2, 0xf5, 0x2b, 0x20, 0xf1, 0x53, 0x52,
|
||||
0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x68, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1d,
|
||||
0x57, 0x7b, 0xef, 0x07, 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 hard-coded 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, "/cosmos.mint.v1beta1.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 hard-coded 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: "/cosmos.mint.v1beta1.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: "cosmos.mint.v1beta1.Msg",
|
||||
HandlerType: (*MsgServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "UpdateParams",
|
||||
Handler: _Msg_UpdateParams_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cosmos/mint/v1beta1/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")
|
||||
)
|
||||
@ -45,7 +45,8 @@ func init() {
|
||||
cryptocodec.RegisterCrypto(amino)
|
||||
sdk.RegisterLegacyAminoCodec(amino)
|
||||
|
||||
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
|
||||
// used to properly serialize MsgGrant and MsgExec instances
|
||||
// Register all Amino interfaces and concrete types on the authz Amino codec
|
||||
// so that this can later be used to properly serialize MsgGrant and MsgExec
|
||||
// instances.
|
||||
RegisterLegacyAminoCodec(authzcodec.Amino)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user