From 84264f2d4b43b3b763ffd75dfe9c35591c86d8af Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Tue, 18 Jun 2024 11:23:40 +0700 Subject: [PATCH] add main bond denom --- proto/multistaking/v1/params.proto | 9 + proto/multistaking/v1/tx.proto | 28 ++ test/simapp/app.go | 1 + x/multi-staking/keeper/keeper.go | 12 + x/multi-staking/keeper/msg_server.go | 29 +- x/multi-staking/keeper/params.go | 30 ++ x/multi-staking/module.go | 3 +- x/multi-staking/types/codec.go | 20 +- x/multi-staking/types/key.go | 2 + x/multi-staking/types/msg.go | 36 ++ x/multi-staking/types/params.pb.go | 318 +++++++++++++++ x/multi-staking/types/tx.pb.go | 590 +++++++++++++++++++++++++++ 12 files changed, 1072 insertions(+), 6 deletions(-) create mode 100644 proto/multistaking/v1/params.proto create mode 100644 proto/multistaking/v1/tx.proto create mode 100644 x/multi-staking/keeper/params.go create mode 100644 x/multi-staking/types/msg.go create mode 100644 x/multi-staking/types/params.pb.go create mode 100644 x/multi-staking/types/tx.pb.go diff --git a/proto/multistaking/v1/params.proto b/proto/multistaking/v1/params.proto new file mode 100644 index 00000000..74d860f8 --- /dev/null +++ b/proto/multistaking/v1/params.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package multistaking.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/realiotech/multi-staking/x/multi-staking/types"; + +// Params defines the incentives module params +message Params { string main_bond_denom = 1; } \ No newline at end of file diff --git a/proto/multistaking/v1/tx.proto b/proto/multistaking/v1/tx.proto new file mode 100644 index 00000000..14bd54e9 --- /dev/null +++ b/proto/multistaking/v1/tx.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; +package multistaking.v1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "multistaking/v1/params.proto"; +import "cosmos/msg/v1/msg.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/realiotech/multi-staking/x/multi-staking/types"; + +service Msg { + rpc UpdateMultiStakingParams(MsgUpdateMultiStakingParams) + returns (MsgUpdateMultiStakingParamsResponse); +} + +message MsgUpdateMultiStakingParams { + 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/evm parameters to update. + // NOTE: All parameters must be supplied. + Params params = 2 [ (gogoproto.nullable) = false ]; +} + +message MsgUpdateMultiStakingParamsResponse {} \ No newline at end of file diff --git a/test/simapp/app.go b/test/simapp/app.go index 40a4fe26..986c1392 100644 --- a/test/simapp/app.go +++ b/test/simapp/app.go @@ -352,6 +352,7 @@ func NewSimApp( app.StakingKeeper, app.BankKeeper, keys[multistakingtypes.StoreKey], + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper) diff --git a/x/multi-staking/keeper/keeper.go b/x/multi-staking/keeper/keeper.go index 8bc179fd..49e83267 100644 --- a/x/multi-staking/keeper/keeper.go +++ b/x/multi-staking/keeper/keeper.go @@ -23,6 +23,7 @@ type Keeper struct { accountKeeper types.AccountKeeper stakingKeeper *stakingkeeper.Keeper bankKeeper types.BankKeeper + authority string } func NewKeeper( @@ -31,6 +32,7 @@ func NewKeeper( stakingKeeper *stakingkeeper.Keeper, bankKeeper types.BankKeeper, key storetypes.StoreKey, + authority string, ) *Keeper { return &Keeper{ cdc: cdc, @@ -38,6 +40,7 @@ func NewKeeper( accountKeeper: accountKeeper, stakingKeeper: stakingKeeper, bankKeeper: bankKeeper, + authority: authority, } } @@ -161,3 +164,12 @@ func (k Keeper) AdjustCancelUnbondingAmount(ctx sdk.Context, delAcc sdk.AccAddre return math.MinInt(totalUnbondingAmount, amount), nil } + +func (k Keeper) BondDenom(ctx sdk.Context) string { + bondDenom := k.GetParams(ctx).MainBondDenom + return bondDenom +} + +func (k Keeper) IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, fn func(index int64, delegation stakingtypes.DelegationI) (stop bool)) { + k.stakingKeeper.IterateDelegations(ctx, delegator, fn) +} diff --git a/x/multi-staking/keeper/msg_server.go b/x/multi-staking/keeper/msg_server.go index 600e3929..8059d16b 100644 --- a/x/multi-staking/keeper/msg_server.go +++ b/x/multi-staking/keeper/msg_server.go @@ -14,14 +14,35 @@ import ( type msgServer struct { keeper Keeper stakingMsgServer stakingtypes.MsgServer - authority string } var _ stakingtypes.MsgServer = msgServer{} +var _ types.MsgServer = msgServer{} + +func NewMultiStakingMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{ + keeper: keeper, + } +} + +func (k msgServer) UpdateMultiStakingParams(goCtx context.Context, msg *types.MsgUpdateMultiStakingParams) (*types.MsgUpdateMultiStakingParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if k.keeper.authority != msg.Authority { + return nil, fmt.Errorf("invalid authority; expected %s, got %s", k.keeper.authority, msg.Authority) + } + + // store params + if err := k.keeper.SetParams(ctx, msg.Params); err != nil { + return nil, err + } + + return &types.MsgUpdateMultiStakingParamsResponse{}, nil +} // NewMsgServerImpl returns an implementation of the bank MsgServer interface // for the provided Keeper. -func NewMsgServerImpl(keeper Keeper) stakingtypes.MsgServer { +func NewMsgServerImpl(keeper Keeper) *msgServer { return &msgServer{ keeper: keeper, stakingMsgServer: stakingkeeper.NewMsgServerImpl(keeper.stakingKeeper), @@ -32,8 +53,8 @@ func NewMsgServerImpl(keeper Keeper) stakingtypes.MsgServer { func (k msgServer) UpdateParams(goCtx context.Context, msg *stakingtypes.MsgUpdateParams) (*stakingtypes.MsgUpdateParamsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if k.authority != msg.Authority { - return nil, fmt.Errorf("invalid authority; expected %s, got %s", k.authority, msg.Authority) + if k.keeper.authority != msg.Authority { + return nil, fmt.Errorf("invalid authority; expected %s, got %s", k.keeper.authority, msg.Authority) } // store params diff --git a/x/multi-staking/keeper/params.go b/x/multi-staking/keeper/params.go new file mode 100644 index 00000000..4000b9f0 --- /dev/null +++ b/x/multi-staking/keeper/params.go @@ -0,0 +1,30 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/realio-tech/multi-staking-module/x/multi-staking/types" +) + +// SetParams sets the x/staking module parameters. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { + store := ctx.KVStore(k.storeKey) + bz, err := k.cdc.Marshal(¶ms) + if err != nil { + return err + } + store.Set(types.ParamsKey, bz) + + return nil +} + +// GetParams sets the x/staking module parameters. +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) + if bz == nil { + return params + } + + k.cdc.MustUnmarshal(bz, ¶ms) + return params +} diff --git a/x/multi-staking/module.go b/x/multi-staking/module.go index 882354fa..51ff82a5 100644 --- a/x/multi-staking/module.go +++ b/x/multi-staking/module.go @@ -132,8 +132,9 @@ func (AppModule) QuerierRoute() string { // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { stakingtypes.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) - multistakingtypes.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper)) + multistakingtypes.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + multistakingtypes.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper)) querier := stakingkeeper.Querier{Keeper: am.sk} stakingtypes.RegisterQueryServer(cfg.QueryServer(), querier) diff --git a/x/multi-staking/types/codec.go b/x/multi-staking/types/codec.go index 68ad5149..b39fa162 100644 --- a/x/multi-staking/types/codec.go +++ b/x/multi-staking/types/codec.go @@ -2,10 +2,16 @@ 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" v1beta1types "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" + govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec" + groupcodec "github.com/cosmos/cosmos-sdk/x/group/codec" ) var ( @@ -21,21 +27,33 @@ var ( ) func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + legacy.RegisterAminoMsg(cdc, &MsgUpdateMultiStakingParams{}, "multistaking/MsgUpdateMultiStakingParams") + cdc.RegisterConcrete(&AddMultiStakingCoinProposal{}, "multistaking/AddMultiStakingCoinProposal", nil) cdc.RegisterConcrete(&UpdateBondWeightProposal{}, "multistaking/UpdateBondWeightProposal", nil) // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &AddMultiStakingCoinProposal{}, + ) registry.RegisterImplementations( (*v1beta1types.Content)(nil), &AddMultiStakingCoinProposal{}, - &UpdateBondWeightProposal{}, ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be + // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances + RegisterLegacyAminoCodec(authzcodec.Amino) + RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(groupcodec.Amino) } diff --git a/x/multi-staking/types/key.go b/x/multi-staking/types/key.go index ae93c65b..a96695cb 100644 --- a/x/multi-staking/types/key.go +++ b/x/multi-staking/types/key.go @@ -27,6 +27,8 @@ var ( MultiStakingLockPrefix = []byte{0x02} MultiStakingUnlockPrefix = []byte{0x11} // key for an unbonding-delegation + + ParamsKey = []byte{0x03} // prefix for parameters for module x/multistaking ) func KeyPrefix(key string) []byte { diff --git a/x/multi-staking/types/msg.go b/x/multi-staking/types/msg.go new file mode 100644 index 00000000..33fd7a18 --- /dev/null +++ b/x/multi-staking/types/msg.go @@ -0,0 +1,36 @@ +package types + +import ( + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// staking message types +const ( + TypeMsgUpdateMultiStakingParams = "update_multistaking_params" +) + +var ( + _ sdk.Msg = &MsgUpdateMultiStakingParams{} +) + +// GetSignBytes returns the raw bytes for a MsgUpdateParams message that +// the expected signer needs to sign. +func (m *MsgUpdateMultiStakingParams) GetSignBytes() []byte { + bz := AminoCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic executes sanity validation on the provided data +func (m *MsgUpdateMultiStakingParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { + return sdkerrors.Wrap(err, "invalid authority address") + } + return nil +} + +// GetSigners returns the expected signers for a MsgUpdateParams message +func (m *MsgUpdateMultiStakingParams) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(m.Authority) + return []sdk.AccAddress{addr} +} diff --git a/x/multi-staking/types/params.pb.go b/x/multi-staking/types/params.pb.go new file mode 100644 index 00000000..f178c04c --- /dev/null +++ b/x/multi-staking/types/params.pb.go @@ -0,0 +1,318 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: multistaking/v1/params.proto + +package types + +import ( + fmt "fmt" + _ "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 + +// Params defines the incentives module params +type Params struct { + MainBondDenom string `protobuf:"bytes,1,opt,name=main_bond_denom,json=mainBondDenom,proto3" json:"main_bond_denom,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_7a0d2887d9ef4798, []int{0} +} +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) GetMainBondDenom() string { + if m != nil { + return m.MainBondDenom + } + return "" +} + +func init() { + proto.RegisterType((*Params)(nil), "multistaking.v1.Params") +} + +func init() { proto.RegisterFile("multistaking/v1/params.proto", fileDescriptor_7a0d2887d9ef4798) } + +var fileDescriptor_7a0d2887d9ef4798 = []byte{ + // 187 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0x2d, 0xcd, 0x29, + 0xc9, 0x2c, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xd7, 0x2f, 0x33, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, + 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x47, 0x96, 0xd5, 0x2b, 0x33, 0x94, + 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xe9, 0x83, 0x58, 0x10, 0x65, 0x4a, 0x06, 0x5c, 0x6c, + 0x01, 0x60, 0x6d, 0x42, 0x6a, 0x5c, 0xfc, 0xb9, 0x89, 0x99, 0x79, 0xf1, 0x49, 0xf9, 0x79, 0x29, + 0xf1, 0x29, 0xa9, 0x79, 0xf9, 0xb9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0xbc, 0x20, 0x61, + 0xa7, 0xfc, 0xbc, 0x14, 0x17, 0x90, 0xa0, 0x53, 0xf0, 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, 0x59, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x17, + 0xa5, 0x26, 0xe6, 0x64, 0xe6, 0x97, 0xa4, 0x26, 0x67, 0xe8, 0x83, 0x1d, 0xa2, 0x0b, 0x73, 0x67, + 0x05, 0x1a, 0xbf, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x1a, 0x63, 0x40, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x49, 0x67, 0xd2, 0x7b, 0xd4, 0x00, 0x00, 0x00, +} + +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 len(m.MainBondDenom) > 0 { + i -= len(m.MainBondDenom) + copy(dAtA[i:], m.MainBondDenom) + i = encodeVarintParams(dAtA, i, uint64(len(m.MainBondDenom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MainBondDenom) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +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 ErrIntOverflowParams + } + 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 MainBondDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MainBondDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/multi-staking/types/tx.pb.go b/x/multi-staking/types/tx.pb.go new file mode 100644 index 00000000..77a7898d --- /dev/null +++ b/x/multi-staking/types/tx.pb.go @@ -0,0 +1,590 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: multistaking/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "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 + +type MsgUpdateMultiStakingParams 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/evm parameters to update. + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateMultiStakingParams) Reset() { *m = MsgUpdateMultiStakingParams{} } +func (m *MsgUpdateMultiStakingParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateMultiStakingParams) ProtoMessage() {} +func (*MsgUpdateMultiStakingParams) Descriptor() ([]byte, []int) { + return fileDescriptor_c52c073cb95ae80e, []int{0} +} +func (m *MsgUpdateMultiStakingParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateMultiStakingParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateMultiStakingParams.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 *MsgUpdateMultiStakingParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateMultiStakingParams.Merge(m, src) +} +func (m *MsgUpdateMultiStakingParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateMultiStakingParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateMultiStakingParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateMultiStakingParams proto.InternalMessageInfo + +func (m *MsgUpdateMultiStakingParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateMultiStakingParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +type MsgUpdateMultiStakingParamsResponse struct { +} + +func (m *MsgUpdateMultiStakingParamsResponse) Reset() { *m = MsgUpdateMultiStakingParamsResponse{} } +func (m *MsgUpdateMultiStakingParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateMultiStakingParamsResponse) ProtoMessage() {} +func (*MsgUpdateMultiStakingParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c52c073cb95ae80e, []int{1} +} +func (m *MsgUpdateMultiStakingParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateMultiStakingParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateMultiStakingParamsResponse.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 *MsgUpdateMultiStakingParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateMultiStakingParamsResponse.Merge(m, src) +} +func (m *MsgUpdateMultiStakingParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateMultiStakingParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateMultiStakingParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateMultiStakingParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUpdateMultiStakingParams)(nil), "multistaking.v1.MsgUpdateMultiStakingParams") + proto.RegisterType((*MsgUpdateMultiStakingParamsResponse)(nil), "multistaking.v1.MsgUpdateMultiStakingParamsResponse") +} + +func init() { proto.RegisterFile("multistaking/v1/tx.proto", fileDescriptor_c52c073cb95ae80e) } + +var fileDescriptor_c52c073cb95ae80e = []byte{ + // 348 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc8, 0x2d, 0xcd, 0x29, + 0xc9, 0x2c, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xd7, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, + 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x47, 0x96, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, + 0xcf, 0x07, 0xcb, 0xe9, 0x83, 0x58, 0x10, 0x65, 0x52, 0x32, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, + 0xfa, 0x89, 0x05, 0x99, 0xfa, 0x89, 0x79, 0x79, 0xf9, 0x25, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xc5, + 0x30, 0x59, 0x74, 0xe3, 0x0b, 0x12, 0x8b, 0x12, 0x73, 0x61, 0xb2, 0xe2, 0xc9, 0xf9, 0xc5, 0xb9, + 0xf9, 0xc5, 0xfa, 0xb9, 0xc5, 0x60, 0xb9, 0xdc, 0xe2, 0x74, 0xa8, 0x84, 0x24, 0x44, 0x22, 0x1e, + 0x62, 0x1b, 0x84, 0x03, 0x91, 0x52, 0x9a, 0xc3, 0xc8, 0x25, 0xed, 0x5b, 0x9c, 0x1e, 0x5a, 0x90, + 0x92, 0x58, 0x92, 0xea, 0x0b, 0x32, 0x3d, 0x18, 0x62, 0x7a, 0x00, 0xd8, 0x64, 0x21, 0x33, 0x2e, + 0xce, 0xc4, 0xd2, 0x92, 0x8c, 0xfc, 0xa2, 0xcc, 0x92, 0x4a, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x4e, + 0x27, 0x89, 0x4b, 0x5b, 0x74, 0x45, 0xa0, 0x86, 0x38, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x07, + 0x97, 0x14, 0x65, 0xe6, 0xa5, 0x07, 0x21, 0x94, 0x0a, 0x99, 0x72, 0xb1, 0x41, 0xdc, 0x26, 0xc1, + 0xa4, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xae, 0x87, 0xe6, 0x7f, 0x3d, 0x88, 0x05, 0x4e, 0x2c, 0x27, + 0xee, 0xc9, 0x33, 0x04, 0x41, 0x15, 0x5b, 0xf1, 0x35, 0x3d, 0xdf, 0xa0, 0x85, 0x30, 0x46, 0x49, + 0x95, 0x4b, 0x19, 0x8f, 0xeb, 0x82, 0x52, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x8d, 0x5a, 0x19, + 0xb9, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0xea, 0xb8, 0x24, 0x70, 0xfa, 0x44, 0x07, 0xc3, 0x05, 0x78, + 0x4c, 0x96, 0x32, 0x21, 0x45, 0x35, 0xcc, 0x1d, 0x4e, 0xc1, 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, 0x65, 0x99, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, + 0x5f, 0x94, 0x9a, 0x98, 0x93, 0x99, 0x5f, 0x92, 0x9a, 0x9c, 0xa1, 0x0f, 0xb6, 0x44, 0x17, 0x16, + 0xa1, 0x15, 0x68, 0xfc, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x4c, 0x19, 0x03, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x40, 0x56, 0x39, 0xe7, 0x5c, 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 { + UpdateMultiStakingParams(ctx context.Context, in *MsgUpdateMultiStakingParams, opts ...grpc.CallOption) (*MsgUpdateMultiStakingParamsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UpdateMultiStakingParams(ctx context.Context, in *MsgUpdateMultiStakingParams, opts ...grpc.CallOption) (*MsgUpdateMultiStakingParamsResponse, error) { + out := new(MsgUpdateMultiStakingParamsResponse) + err := c.cc.Invoke(ctx, "/multistaking.v1.Msg/UpdateMultiStakingParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + UpdateMultiStakingParams(context.Context, *MsgUpdateMultiStakingParams) (*MsgUpdateMultiStakingParamsResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) UpdateMultiStakingParams(ctx context.Context, req *MsgUpdateMultiStakingParams) (*MsgUpdateMultiStakingParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateMultiStakingParams not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_UpdateMultiStakingParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateMultiStakingParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateMultiStakingParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/multistaking.v1.Msg/UpdateMultiStakingParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateMultiStakingParams(ctx, req.(*MsgUpdateMultiStakingParams)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "multistaking.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateMultiStakingParams", + Handler: _Msg_UpdateMultiStakingParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "multistaking/v1/tx.proto", +} + +func (m *MsgUpdateMultiStakingParams) 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 *MsgUpdateMultiStakingParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateMultiStakingParams) 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 *MsgUpdateMultiStakingParamsResponse) 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 *MsgUpdateMultiStakingParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateMultiStakingParamsResponse) 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 *MsgUpdateMultiStakingParams) 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 *MsgUpdateMultiStakingParamsResponse) 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 *MsgUpdateMultiStakingParams) 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: MsgUpdateMultiStakingParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateMultiStakingParams: 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 *MsgUpdateMultiStakingParamsResponse) 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: MsgUpdateMultiStakingParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateMultiStakingParamsResponse: 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") +)