From 64104f28a7da35ba6fb1845e64e9706a66e1fbdd Mon Sep 17 00:00:00 2001 From: Hanjun Kim Date: Thu, 6 Jun 2024 21:54:43 +0900 Subject: [PATCH] fix: remove legacy x/params and x/gov (#5) continued from #4 --- x/icacallbacks/types/params.go | 13 - x/records/types/params.go | 16 - x/stakeibc/types/codec.go | 8 - x/stakeibc/types/gov.go | 141 ----- x/stakeibc/types/gov.pb.go | 911 --------------------------------- x/stakeibc/types/params.go | 54 +- x/tokenfactory/types/params.go | 20 +- 7 files changed, 5 insertions(+), 1158 deletions(-) delete mode 100644 x/stakeibc/types/gov.go delete mode 100644 x/stakeibc/types/gov.pb.go diff --git a/x/icacallbacks/types/params.go b/x/icacallbacks/types/params.go index 357196ad..f4b9ae24 100644 --- a/x/icacallbacks/types/params.go +++ b/x/icacallbacks/types/params.go @@ -1,17 +1,9 @@ package types import ( - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "gopkg.in/yaml.v2" ) -var _ paramtypes.ParamSet = (*Params)(nil) - -// ParamKeyTable the param key table for launch module -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - // NewParams creates a new Params instance func NewParams() Params { return Params{} @@ -22,11 +14,6 @@ func DefaultParams() Params { return NewParams() } -// ParamSetPairs get the params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} -} - // Validate validates the set of params func (p Params) Validate() error { return nil diff --git a/x/records/types/params.go b/x/records/types/params.go index 4f3215e3..874012a4 100644 --- a/x/records/types/params.go +++ b/x/records/types/params.go @@ -1,16 +1,5 @@ package types -import ( - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" -) - -var _ paramtypes.ParamSet = (*Params)(nil) - -// ParamKeyTable the param key table for launch module -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - // NewParams creates a new Params instance func NewParams() Params { return Params{} @@ -21,11 +10,6 @@ func DefaultParams() Params { return NewParams() } -// ParamSetPairs get the params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} -} - // Validate validates the set of params func (p Params) Validate() error { return nil diff --git a/x/stakeibc/types/codec.go b/x/stakeibc/types/codec.go index f656b220..0174ee21 100644 --- a/x/stakeibc/types/codec.go +++ b/x/stakeibc/types/codec.go @@ -6,7 +6,6 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) func RegisterCodec(cdc *codec.LegacyAmino) { @@ -19,8 +18,6 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgAddValidators{}, "stakeibc/AddValidators", nil) cdc.RegisterConcrete(&MsgChangeValidatorWeights{}, "stakeibc/ChangeValidatorWeights", nil) cdc.RegisterConcrete(&MsgDeleteValidator{}, "stakeibc/DeleteValidator", nil) - cdc.RegisterConcrete(&AddValidatorsProposal{}, "stakeibc/AddValidatorsProposal", nil) - cdc.RegisterConcrete(&ToggleLSMProposal{}, "stakeibc/ToggleLSMProposal", nil) cdc.RegisterConcrete(&MsgRestoreInterchainAccount{}, "stakeibc/RestoreInterchainAccount", nil) cdc.RegisterConcrete(&MsgUpdateValidatorSharesExchRate{}, "stakeibc/UpdateValidatorSharesExchRate", nil) cdc.RegisterConcrete(&MsgCalibrateDelegation{}, "stakeibc/CalibrateDelegation", nil) @@ -52,11 +49,6 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgUpdateHostZoneParams{}, ) - registry.RegisterImplementations((*govtypes.Content)(nil), - &AddValidatorsProposal{}, - &ToggleLSMProposal{}, - ) - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/stakeibc/types/gov.go b/x/stakeibc/types/gov.go deleted file mode 100644 index 77e90cb6..00000000 --- a/x/stakeibc/types/gov.go +++ /dev/null @@ -1,141 +0,0 @@ -package types - -import ( - "fmt" - "strings" - - errorsmod "cosmossdk.io/errors" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" -) - -// --------------------------- -// AddValidatorProposal -// --------------------------- -const ( - ProposalTypeAddValidators = "AddValidators" -) - -func init() { - govtypes.RegisterProposalType(ProposalTypeAddValidators) -} - -var ( - _ govtypes.Content = &AddValidatorsProposal{} -) - -func NewAddValidatorsProposal(title, description, hostZone string, validators []*Validator) govtypes.Content { - return &AddValidatorsProposal{ - Title: title, - Description: description, - HostZone: hostZone, - Validators: validators, - } -} - -func (p *AddValidatorsProposal) GetTitle() string { return p.Title } - -func (p *AddValidatorsProposal) GetDescription() string { return p.Description } - -func (p *AddValidatorsProposal) ProposalRoute() string { return RouterKey } - -func (p *AddValidatorsProposal) ProposalType() string { - return ProposalTypeAddValidators -} - -func (p *AddValidatorsProposal) ValidateBasic() error { - err := govtypes.ValidateAbstract(p) - if err != nil { - return err - } - - if len(p.Validators) == 0 { - return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "at least one validator must be provided") - } - - for i, validator := range p.Validators { - if len(strings.TrimSpace(validator.Name)) == 0 { - return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "validator name is required (index %d)", i) - } - if len(strings.TrimSpace(validator.Address)) == 0 { - return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "validator address is required (index %d)", i) - } - } - - return nil -} - -func (p AddValidatorsProposal) String() string { - return fmt.Sprintf(`Add Validators Proposal: - Title: %s - Description: %s - HostZone: %s - Validators: %+v - `, p.Title, p.Description, p.HostZone, p.Validators) -} - -func (v *Validator) Equal(other *Validator) bool { - if v == nil || other == nil { - return false - } - if v.Address != other.Address { - return false - } - if v.Name != other.Name { - return false - } - return true -} - -// --------------------------- -// ToggleLSMProposal -// --------------------------- - -const ( - ProposalTypeToggleLSMProposal = "ToggleLSMProposal" -) - -func init() { - govtypes.RegisterProposalType(ProposalTypeToggleLSMProposal) -} - -var ( - _ govtypes.Content = &ToggleLSMProposal{} -) - -func NewToggleLSMProposal(title, description, hostZone string, enabled bool) govtypes.Content { - return &ToggleLSMProposal{ - Title: title, - Description: description, - HostZone: hostZone, - Enabled: enabled, - } -} - -func (p *ToggleLSMProposal) GetTitle() string { return p.Title } - -func (p *ToggleLSMProposal) GetDescription() string { return p.Description } - -func (p *ToggleLSMProposal) ProposalRoute() string { return RouterKey } - -func (p *ToggleLSMProposal) ProposalType() string { - return ProposalTypeAddValidators -} - -func (p *ToggleLSMProposal) ValidateBasic() error { - err := govtypes.ValidateAbstract(p) - if err != nil { - return err - } - - return nil -} - -func (p ToggleLSMProposal) String() string { - return fmt.Sprintf(`Add Validators Proposal: - Title: %s - Description: %s - HostZone: %s - Enabled: %v - `, p.Title, p.Description, p.HostZone, p.Enabled) -} diff --git a/x/stakeibc/types/gov.pb.go b/x/stakeibc/types/gov.pb.go deleted file mode 100644 index 1757839f..00000000 --- a/x/stakeibc/types/gov.pb.go +++ /dev/null @@ -1,911 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: stride/stakeibc/gov.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 - -type AddValidatorsProposal struct { - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - HostZone string `protobuf:"bytes,3,opt,name=host_zone,json=hostZone,proto3" json:"host_zone,omitempty"` - Validators []*Validator `protobuf:"bytes,4,rep,name=validators,proto3" json:"validators,omitempty"` - Deposit string `protobuf:"bytes,5,opt,name=deposit,proto3" json:"deposit,omitempty" yaml:"deposit"` -} - -func (m *AddValidatorsProposal) Reset() { *m = AddValidatorsProposal{} } -func (*AddValidatorsProposal) ProtoMessage() {} -func (*AddValidatorsProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_8204317b384c5680, []int{0} -} -func (m *AddValidatorsProposal) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AddValidatorsProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AddValidatorsProposal.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 *AddValidatorsProposal) XXX_Merge(src proto.Message) { - xxx_messageInfo_AddValidatorsProposal.Merge(m, src) -} -func (m *AddValidatorsProposal) XXX_Size() int { - return m.Size() -} -func (m *AddValidatorsProposal) XXX_DiscardUnknown() { - xxx_messageInfo_AddValidatorsProposal.DiscardUnknown(m) -} - -var xxx_messageInfo_AddValidatorsProposal proto.InternalMessageInfo - -type ToggleLSMProposal struct { - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - HostZone string `protobuf:"bytes,3,opt,name=host_zone,json=hostZone,proto3" json:"host_zone,omitempty"` - Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` - Deposit string `protobuf:"bytes,5,opt,name=deposit,proto3" json:"deposit,omitempty" yaml:"deposit"` -} - -func (m *ToggleLSMProposal) Reset() { *m = ToggleLSMProposal{} } -func (*ToggleLSMProposal) ProtoMessage() {} -func (*ToggleLSMProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_8204317b384c5680, []int{1} -} -func (m *ToggleLSMProposal) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ToggleLSMProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ToggleLSMProposal.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 *ToggleLSMProposal) XXX_Merge(src proto.Message) { - xxx_messageInfo_ToggleLSMProposal.Merge(m, src) -} -func (m *ToggleLSMProposal) XXX_Size() int { - return m.Size() -} -func (m *ToggleLSMProposal) XXX_DiscardUnknown() { - xxx_messageInfo_ToggleLSMProposal.DiscardUnknown(m) -} - -var xxx_messageInfo_ToggleLSMProposal proto.InternalMessageInfo - -func init() { - proto.RegisterType((*AddValidatorsProposal)(nil), "stride.stakeibc.AddValidatorsProposal") - proto.RegisterType((*ToggleLSMProposal)(nil), "stride.stakeibc.ToggleLSMProposal") -} - -func init() { proto.RegisterFile("stride/stakeibc/gov.proto", fileDescriptor_8204317b384c5680) } - -var fileDescriptor_8204317b384c5680 = []byte{ - // 349 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0x2e, 0x29, 0xca, - 0x4c, 0x49, 0xd5, 0x2f, 0x2e, 0x49, 0xcc, 0x4e, 0xcd, 0x4c, 0x4a, 0xd6, 0x4f, 0xcf, 0x2f, 0xd3, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0x48, 0xe9, 0xc1, 0xa4, 0xa4, 0x44, 0xd2, 0xf3, - 0xd3, 0xf3, 0xc1, 0x72, 0xfa, 0x20, 0x16, 0x44, 0x99, 0x94, 0x3c, 0xba, 0x09, 0x65, 0x89, 0x39, - 0x99, 0x29, 0x89, 0x25, 0xf9, 0x45, 0x10, 0x05, 0x4a, 0x4f, 0x18, 0xb9, 0x44, 0x1d, 0x53, 0x52, - 0xc2, 0x60, 0xc2, 0xc5, 0x01, 0x45, 0xf9, 0x05, 0xf9, 0xc5, 0x89, 0x39, 0x42, 0x22, 0x5c, 0xac, - 0x25, 0x99, 0x25, 0x39, 0xa9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x10, 0x8e, 0x90, 0x02, - 0x17, 0x77, 0x4a, 0x6a, 0x71, 0x72, 0x51, 0x66, 0x41, 0x49, 0x66, 0x7e, 0x9e, 0x04, 0x13, 0x58, - 0x0e, 0x59, 0x48, 0x48, 0x9a, 0x8b, 0x33, 0x23, 0xbf, 0xb8, 0x24, 0xbe, 0x2a, 0x3f, 0x2f, 0x55, - 0x82, 0x19, 0x2c, 0xcf, 0x01, 0x12, 0x88, 0xca, 0xcf, 0x4b, 0x15, 0xb2, 0xe2, 0xe2, 0x82, 0xbb, - 0xa0, 0x58, 0x82, 0x45, 0x81, 0x59, 0x83, 0xdb, 0x48, 0x4a, 0x0f, 0xcd, 0x2f, 0x7a, 0x70, 0xd7, - 0x04, 0x21, 0xa9, 0x16, 0xd2, 0xe1, 0x62, 0x4f, 0x49, 0x2d, 0xc8, 0x2f, 0xce, 0x2c, 0x91, 0x60, - 0x05, 0x19, 0xeb, 0x24, 0xf4, 0xe9, 0x9e, 0x3c, 0x5f, 0x65, 0x62, 0x6e, 0x8e, 0x95, 0x12, 0x54, - 0x42, 0x29, 0x08, 0xa6, 0xc4, 0x8a, 0xa7, 0x63, 0x81, 0x3c, 0xc3, 0x8c, 0x05, 0xf2, 0x0c, 0x2f, - 0x16, 0xc8, 0x33, 0x2a, 0xed, 0x63, 0xe4, 0x12, 0x0c, 0xc9, 0x4f, 0x4f, 0xcf, 0x49, 0xf5, 0x09, - 0xf6, 0xa5, 0xad, 0x17, 0x25, 0xb8, 0xd8, 0x53, 0xf3, 0x12, 0x93, 0x72, 0x52, 0x53, 0x24, 0x58, - 0x14, 0x18, 0x35, 0x38, 0x82, 0x60, 0x5c, 0x4a, 0x3c, 0xe0, 0xe4, 0x73, 0xe2, 0x91, 0x1c, 0xe3, - 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, - 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x46, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, - 0xb9, 0xfa, 0xb9, 0x99, 0x39, 0xd9, 0x95, 0xe5, 0x89, 0x95, 0xba, 0x39, 0x89, 0x49, 0xc5, 0x70, - 0x9e, 0x7e, 0x05, 0x22, 0xfe, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x91, 0x6f, 0x0c, - 0x08, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x0e, 0xd7, 0x48, 0x61, 0x02, 0x00, 0x00, -} - -func (this *AddValidatorsProposal) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*AddValidatorsProposal) - if !ok { - that2, ok := that.(AddValidatorsProposal) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.Title != that1.Title { - return false - } - if this.Description != that1.Description { - return false - } - if this.HostZone != that1.HostZone { - return false - } - if len(this.Validators) != len(that1.Validators) { - return false - } - for i := range this.Validators { - if !this.Validators[i].Equal(that1.Validators[i]) { - return false - } - } - if this.Deposit != that1.Deposit { - return false - } - return true -} -func (this *ToggleLSMProposal) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*ToggleLSMProposal) - if !ok { - that2, ok := that.(ToggleLSMProposal) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.Title != that1.Title { - return false - } - if this.Description != that1.Description { - return false - } - if this.HostZone != that1.HostZone { - return false - } - if this.Enabled != that1.Enabled { - return false - } - if this.Deposit != that1.Deposit { - return false - } - return true -} -func (m *AddValidatorsProposal) 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 *AddValidatorsProposal) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AddValidatorsProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Deposit) > 0 { - i -= len(m.Deposit) - copy(dAtA[i:], m.Deposit) - i = encodeVarintGov(dAtA, i, uint64(len(m.Deposit))) - i-- - dAtA[i] = 0x2a - } - if len(m.Validators) > 0 { - for iNdEx := len(m.Validators) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Validators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGov(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if len(m.HostZone) > 0 { - i -= len(m.HostZone) - copy(dAtA[i:], m.HostZone) - i = encodeVarintGov(dAtA, i, uint64(len(m.HostZone))) - i-- - dAtA[i] = 0x1a - } - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x12 - } - if len(m.Title) > 0 { - i -= len(m.Title) - copy(dAtA[i:], m.Title) - i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ToggleLSMProposal) 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 *ToggleLSMProposal) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ToggleLSMProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Deposit) > 0 { - i -= len(m.Deposit) - copy(dAtA[i:], m.Deposit) - i = encodeVarintGov(dAtA, i, uint64(len(m.Deposit))) - i-- - dAtA[i] = 0x2a - } - if m.Enabled { - i-- - if m.Enabled { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x20 - } - if len(m.HostZone) > 0 { - i -= len(m.HostZone) - copy(dAtA[i:], m.HostZone) - i = encodeVarintGov(dAtA, i, uint64(len(m.HostZone))) - i-- - dAtA[i] = 0x1a - } - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x12 - } - if len(m.Title) > 0 { - i -= len(m.Title) - copy(dAtA[i:], m.Title) - i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintGov(dAtA []byte, offset int, v uint64) int { - offset -= sovGov(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *AddValidatorsProposal) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Title) - if l > 0 { - n += 1 + l + sovGov(uint64(l)) - } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovGov(uint64(l)) - } - l = len(m.HostZone) - if l > 0 { - n += 1 + l + sovGov(uint64(l)) - } - if len(m.Validators) > 0 { - for _, e := range m.Validators { - l = e.Size() - n += 1 + l + sovGov(uint64(l)) - } - } - l = len(m.Deposit) - if l > 0 { - n += 1 + l + sovGov(uint64(l)) - } - return n -} - -func (m *ToggleLSMProposal) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Title) - if l > 0 { - n += 1 + l + sovGov(uint64(l)) - } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovGov(uint64(l)) - } - l = len(m.HostZone) - if l > 0 { - n += 1 + l + sovGov(uint64(l)) - } - if m.Enabled { - n += 2 - } - l = len(m.Deposit) - if l > 0 { - n += 1 + l + sovGov(uint64(l)) - } - return n -} - -func sovGov(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozGov(x uint64) (n int) { - return sovGov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *AddValidatorsProposal) 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 ErrIntOverflowGov - } - 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: AddValidatorsProposal: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AddValidatorsProposal: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - 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 ErrInvalidLengthGov - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGov - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Title = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - 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 ErrInvalidLengthGov - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGov - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Description = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field HostZone", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - 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 ErrInvalidLengthGov - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGov - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.HostZone = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Validators", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGov - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGov - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Validators = append(m.Validators, &Validator{}) - if err := m.Validators[len(m.Validators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Deposit", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - 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 ErrInvalidLengthGov - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGov - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Deposit = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGov(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGov - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ToggleLSMProposal) 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 ErrIntOverflowGov - } - 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: ToggleLSMProposal: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ToggleLSMProposal: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - 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 ErrInvalidLengthGov - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGov - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Title = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - 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 ErrInvalidLengthGov - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGov - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Description = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field HostZone", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - 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 ErrInvalidLengthGov - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGov - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.HostZone = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Enabled = bool(v != 0) - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Deposit", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - 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 ErrInvalidLengthGov - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGov - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Deposit = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGov(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGov - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipGov(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, ErrIntOverflowGov - } - 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, ErrIntOverflowGov - } - 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, ErrIntOverflowGov - } - 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, ErrInvalidLengthGov - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupGov - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthGov - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthGov = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGov = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupGov = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/stakeibc/types/params.go b/x/stakeibc/types/params.go index 1973b4ec..a68dcf8d 100644 --- a/x/stakeibc/types/params.go +++ b/x/stakeibc/types/params.go @@ -1,9 +1,8 @@ package types import ( - fmt "fmt" + "fmt" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "gopkg.in/yaml.v2" ) @@ -27,35 +26,8 @@ var ( DefaultIBCTransferTimeoutNanos uint64 = 1800000000000 // 30 minutes DefaultValidatorSlashQueryThreshold uint64 = 1 // denominated in percentage of TVL (1 => 1%) DefaultValidatorWeightCap uint64 = 10 // percentage (10 => 10%) - - // KeyDepositInterval is store's key for the DepositInterval option - KeyDepositInterval = []byte("DepositInterval") - KeyDelegateInterval = []byte("DelegateInterval") - KeyReinvestInterval = []byte("ReinvestInterval") - KeyRewardsInterval = []byte("RewardsInterval") - KeyRedemptionRateInterval = []byte("RedemptionRateInterval") - KeyStrideCommission = []byte("StrideCommission") - KeyICATimeoutNanos = []byte("ICATimeoutNanos") - KeyFeeTransferTimeoutNanos = []byte("FeeTransferTimeoutNanos") - KeyBufferSize = []byte("BufferSize") - KeyIbcTimeoutBlocks = []byte("IBCTimeoutBlocks") - KeyDefaultMinRedemptionRateThreshold = []byte("DefaultMinRedemptionRateThreshold") - KeyDefaultMaxRedemptionRateThreshold = []byte("DefaultMaxRedemptionRateThreshold") - KeyMaxStakeICACallsPerEpoch = []byte("MaxStakeICACallsPerEpoch") - KeyIBCTransferTimeoutNanos = []byte("IBCTransferTimeoutNanos") - KeyMaxRedemptionRates = []byte("MaxRedemptionRates") - KeyMinRedemptionRates = []byte("MinRedemptionRates") - KeyValidatorSlashQueryThreshold = []byte("ValidatorSlashQueryThreshold") - KeyValidatorWeightCap = []byte("ValidatorWeightCap") ) -var _ paramtypes.ParamSet = (*Params)(nil) - -// ParamKeyTable the param key table for launch module -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - // NewParams creates a new Params instance func NewParams( depositInterval uint64, @@ -117,28 +89,6 @@ func DefaultParams() Params { ) } -// ParamSetPairs get the params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyDepositInterval, &p.DepositInterval, isPositive), - paramtypes.NewParamSetPair(KeyDelegateInterval, &p.DelegateInterval, isPositive), - paramtypes.NewParamSetPair(KeyRewardsInterval, &p.RewardsInterval, isPositive), - paramtypes.NewParamSetPair(KeyRedemptionRateInterval, &p.RedemptionRateInterval, isPositive), - paramtypes.NewParamSetPair(KeyStrideCommission, &p.StrideCommission, isCommission), - paramtypes.NewParamSetPair(KeyReinvestInterval, &p.ReinvestInterval, isPositive), - paramtypes.NewParamSetPair(KeyICATimeoutNanos, &p.IcaTimeoutNanos, isPositive), - paramtypes.NewParamSetPair(KeyBufferSize, &p.BufferSize, isPositive), - paramtypes.NewParamSetPair(KeyIbcTimeoutBlocks, &p.IbcTimeoutBlocks, isPositive), - paramtypes.NewParamSetPair(KeyFeeTransferTimeoutNanos, &p.FeeTransferTimeoutNanos, validTimeoutNanos), - paramtypes.NewParamSetPair(KeyMaxStakeICACallsPerEpoch, &p.MaxStakeIcaCallsPerEpoch, isPositive), - paramtypes.NewParamSetPair(KeyDefaultMinRedemptionRateThreshold, &p.DefaultMinRedemptionRateThreshold, validMinRedemptionRateThreshold), - paramtypes.NewParamSetPair(KeyDefaultMaxRedemptionRateThreshold, &p.DefaultMaxRedemptionRateThreshold, validMaxRedemptionRateThreshold), - paramtypes.NewParamSetPair(KeyIBCTransferTimeoutNanos, &p.IbcTransferTimeoutNanos, validTimeoutNanos), - paramtypes.NewParamSetPair(KeyValidatorSlashQueryThreshold, &p.ValidatorSlashQueryThreshold, isPositive), - paramtypes.NewParamSetPair(KeyValidatorWeightCap, &p.ValidatorWeightCap, validValidatorWeightCap), - } -} - func validTimeoutNanos(i interface{}) error { ival, ok := i.(uint64) if !ok { @@ -277,7 +227,7 @@ func (p Params) Validate() error { if err := validTimeoutNanos(p.IbcTransferTimeoutNanos); err != nil { return err } - if err := isPercentage(p.ValidatorWeightCap); err != nil { + if err := validValidatorWeightCap(p.ValidatorWeightCap); err != nil { return err } diff --git a/x/tokenfactory/types/params.go b/x/tokenfactory/types/params.go index 09d9cac7..19207637 100644 --- a/x/tokenfactory/types/params.go +++ b/x/tokenfactory/types/params.go @@ -4,23 +4,14 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) // Parameter store keys. var ( - KeyDenomCreationFee = []byte("DenomCreationFee") - KeyDenomCreationGasConsume = []byte("DenomCreationGasConsume") - // chosen as an arbitrary large number, less than the max_gas_wanted_per_tx in config. DefaultCreationGasFee = 1_000_000 ) -// ParamTable for gamm module. -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - func NewParams(denomCreationFee sdk.Coins, denomCreationGasConsume uint64) Params { return Params{ DenomCreationFee: denomCreationFee, @@ -42,18 +33,13 @@ func (p Params) Validate() error { if err := validateDenomCreationFee(p.DenomCreationFee); err != nil { return err } + if err := validateDenomCreationGasConsume(p.DenomCreationGasConsume); err != nil { + return err + } return nil } -// Implements params.ParamSet. -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyDenomCreationFee, &p.DenomCreationFee, validateDenomCreationFee), - paramtypes.NewParamSetPair(KeyDenomCreationGasConsume, &p.DenomCreationGasConsume, validateDenomCreationGasConsume), - } -} - func validateDenomCreationFee(i interface{}) error { v, ok := i.(sdk.Coins) if !ok {