From 51faebfdc501029b16d042bb0ed58aa8032273a6 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Thu, 20 Oct 2022 23:32:40 +1100 Subject: [PATCH 01/38] feat: define protobuf file for params --- proto/payment/params.proto | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 proto/payment/params.proto diff --git a/proto/payment/params.proto b/proto/payment/params.proto new file mode 100644 index 0000000000..faad8f870b --- /dev/null +++ b/proto/payment/params.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package payment; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/celestiaorg/celestia-app/x/payment/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + + int32 minSquareSize = 1 [(gogoproto.moretags) = "yaml:\"min_square_size\""]; + int32 maxSqaureSize = 2 [(gogoproto.moretags) = "yaml:\"max_sqaure_size\""]; +} \ No newline at end of file From 38a689759e70a9b69cfc8f38c2897a731d51173c Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Thu, 20 Oct 2022 23:33:05 +1100 Subject: [PATCH 02/38] feat: define protobuf file for querying params --- proto/payment/query.proto | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/proto/payment/query.proto b/proto/payment/query.proto index ebdae3cc26..643fd050a4 100644 --- a/proto/payment/query.proto +++ b/proto/payment/query.proto @@ -1,12 +1,24 @@ syntax = "proto3"; package payment; +import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; +import "payment/params.proto"; option go_package = "github.com/celestiaorg/celestia-app/x/payment/types"; // Query defines the gRPC querier service. service Query { + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/payment/params"; + } } +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + Params params = 1 [(gogoproto.nullable) = false]; +} From 5b3d188db610f4f351b447d9a9bfc173716722ca Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Thu, 20 Oct 2022 23:33:35 +1100 Subject: [PATCH 03/38] feat: define protobuf file for genesis value for params --- proto/payment/genesis.proto | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/proto/payment/genesis.proto b/proto/payment/genesis.proto index 76c8bab730..aa0f34d34f 100644 --- a/proto/payment/genesis.proto +++ b/proto/payment/genesis.proto @@ -1,7 +1,12 @@ syntax = "proto3"; package payment; +import "gogoproto/gogo.proto"; +import "payment/params.proto"; + option go_package = "github.com/celestiaorg/celestia-app/x/payment/types"; // GenesisState defines the capability module's genesis state. -message GenesisState {} +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; +} From fe5726c6e0b6371d56cbbf00da2e9463e7443e37 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Thu, 20 Oct 2022 23:43:07 +1100 Subject: [PATCH 04/38] feat: type defs for params and relevant protobuf generated files --- x/payment/types/genesis.pb.go | 73 ++++- x/payment/types/params.go | 99 +++++++ x/payment/types/params.pb.go | 339 +++++++++++++++++++++++ x/payment/types/query.pb.go | 480 +++++++++++++++++++++++++++++++-- x/payment/types/query.pb.gw.go | 153 +++++++++++ 5 files changed, 1120 insertions(+), 24 deletions(-) create mode 100644 x/payment/types/params.go create mode 100644 x/payment/types/params.pb.go create mode 100644 x/payment/types/query.pb.gw.go diff --git a/x/payment/types/genesis.pb.go b/x/payment/types/genesis.pb.go index 3b25078113..a9ca50153d 100644 --- a/x/payment/types/genesis.pb.go +++ b/x/payment/types/genesis.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -24,6 +25,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the capability module's genesis state. type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -59,6 +61,13 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + func init() { proto.RegisterType((*GenesisState)(nil), "payment.GenesisState") } @@ -66,16 +75,19 @@ func init() { func init() { proto.RegisterFile("payment/genesis.proto", fileDescriptor_ded92bd505296f58) } var fileDescriptor_ded92bd505296f58 = []byte{ - // 135 bytes of a gzipped FileDescriptorProto + // 189 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x48, 0xac, 0xcc, 0x4d, 0xcd, 0x2b, 0xd1, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0x62, 0x87, 0x0a, 0x2b, 0xf1, 0x71, 0xf1, 0xb8, 0x43, 0x64, 0x82, 0x4b, 0x12, 0x4b, - 0x52, 0x9d, 0x7c, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, - 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x38, 0x3d, - 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0x39, 0x35, 0x27, 0xb5, 0xb8, 0x24, - 0x33, 0x31, 0xbf, 0x28, 0x1d, 0xce, 0xd6, 0x4d, 0x2c, 0x28, 0xd0, 0xaf, 0xd0, 0x87, 0xd9, 0x57, - 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0xb6, 0xce, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x12, - 0x51, 0x3e, 0xf3, 0x87, 0x00, 0x00, 0x00, + 0xc9, 0x17, 0x62, 0x87, 0x0a, 0x4b, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xc5, 0xf4, 0x41, 0x2c, + 0x88, 0xb4, 0x94, 0x08, 0x4c, 0x57, 0x41, 0x62, 0x51, 0x62, 0x2e, 0x54, 0x93, 0x92, 0x2d, 0x17, + 0x8f, 0x3b, 0xc4, 0x94, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x5d, 0x2e, 0x36, 0x88, 0xbc, 0x04, + 0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x11, 0xbf, 0x1e, 0x54, 0x9b, 0x5e, 0x00, 0x58, 0xd8, 0x89, 0xe5, + 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x22, 0x27, 0xdf, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, + 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, + 0x96, 0x63, 0x88, 0x32, 0x4e, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, + 0x4e, 0xcd, 0x49, 0x2d, 0x2e, 0xc9, 0x4c, 0xcc, 0x2f, 0x4a, 0x87, 0xb3, 0x75, 0x13, 0x0b, 0x0a, + 0xf4, 0x2b, 0xf4, 0x61, 0x8e, 0x2a, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x3b, 0xca, 0x18, + 0x10, 0x00, 0x00, 0xff, 0xff, 0x68, 0xc3, 0x75, 0x3c, 0xe2, 0x00, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -98,6 +110,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -118,6 +140,8 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -156,6 +180,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/payment/types/params.go b/x/payment/types/params.go new file mode 100644 index 0000000000..960ef1efee --- /dev/null +++ b/x/payment/types/params.go @@ -0,0 +1,99 @@ +package types + +import ( + "fmt" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +var ( + KeyMinSquareSize = []byte("MinSquareSize") + // TODO: Determine the default value + DefaultMinSquareSize int32 = 0 +) + +var ( + KeyMaxSqaureSize = []byte("MaxSqaureSize") + // TODO: Determine the default value + DefaultMaxSqaureSize int32 = 0 +) + +// 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( + minSquareSize int32, + maxSqaureSize int32, +) Params { + return Params{ + MinSquareSize: minSquareSize, + MaxSqaureSize: maxSqaureSize, + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams( + DefaultMinSquareSize, + DefaultMaxSqaureSize, + ) +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyMinSquareSize, &p.MinSquareSize, validateMinSquareSize), + paramtypes.NewParamSetPair(KeyMaxSqaureSize, &p.MaxSqaureSize, validateMaxSqaureSize), + } +} + +// Validate validates the set of params +func (p Params) Validate() error { + if err := validateMinSquareSize(p.MinSquareSize); err != nil { + return err + } + + if err := validateMaxSqaureSize(p.MaxSqaureSize); err != nil { + return err + } + + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} + +// validateMinSquareSize validates the MinSquareSize param +func validateMinSquareSize(v interface{}) error { + minSquareSize, ok := v.(int32) + if !ok { + return fmt.Errorf("invalid parameter type: %T", v) + } + + // TODO implement validation + _ = minSquareSize + + return nil +} + +// validateMaxSqaureSize validates the MaxSqaureSize param +func validateMaxSqaureSize(v interface{}) error { + maxSqaureSize, ok := v.(int32) + if !ok { + return fmt.Errorf("invalid parameter type: %T", v) + } + + // TODO implement validation + _ = maxSqaureSize + + return nil +} diff --git a/x/payment/types/params.pb.go b/x/payment/types/params.pb.go new file mode 100644 index 0000000000..e7a42bf2b7 --- /dev/null +++ b/x/payment/types/params.pb.go @@ -0,0 +1,339 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: payment/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/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 parameters for the module. +type Params struct { + MinSquareSize int32 `protobuf:"varint,1,opt,name=minSquareSize,proto3" json:"minSquareSize,omitempty" yaml:"min_square_size"` + MaxSqaureSize int32 `protobuf:"varint,2,opt,name=maxSqaureSize,proto3" json:"maxSqaureSize,omitempty" yaml:"max_sqaure_size"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_12d54b052075926a, []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) GetMinSquareSize() int32 { + if m != nil { + return m.MinSquareSize + } + return 0 +} + +func (m *Params) GetMaxSqaureSize() int32 { + if m != nil { + return m.MaxSqaureSize + } + return 0 +} + +func init() { + proto.RegisterType((*Params)(nil), "payment.Params") +} + +func init() { proto.RegisterFile("payment/params.proto", fileDescriptor_12d54b052075926a) } + +var fileDescriptor_12d54b052075926a = []byte{ + // 225 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x29, 0x48, 0xac, 0xcc, + 0x4d, 0xcd, 0x2b, 0xd1, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x62, 0x87, 0x8a, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xc5, 0xf4, 0x41, 0x2c, 0x88, + 0xb4, 0xd2, 0x24, 0x46, 0x2e, 0xb6, 0x00, 0xb0, 0x7a, 0x21, 0x07, 0x2e, 0xde, 0xdc, 0xcc, 0xbc, + 0xe0, 0xc2, 0xd2, 0xc4, 0xa2, 0xd4, 0xe0, 0xcc, 0xaa, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x56, + 0x27, 0xa9, 0x4f, 0xf7, 0xe4, 0xc5, 0x2a, 0x13, 0x73, 0x73, 0xac, 0x94, 0x72, 0x33, 0xf3, 0xe2, + 0x8b, 0xc1, 0xf2, 0xf1, 0xc5, 0x99, 0x55, 0xa9, 0x4a, 0x41, 0xa8, 0x1a, 0xc0, 0x26, 0x24, 0x56, + 0x04, 0x17, 0x26, 0x96, 0x42, 0x4d, 0x60, 0xc2, 0x30, 0x21, 0xb1, 0x22, 0xbe, 0x18, 0x2c, 0x0f, + 0x37, 0x01, 0x59, 0x83, 0x15, 0xcb, 0x8c, 0x05, 0xf2, 0x0c, 0x4e, 0xbe, 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, 0x9c, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, + 0x9f, 0xab, 0x9f, 0x9c, 0x9a, 0x93, 0x5a, 0x5c, 0x92, 0x99, 0x98, 0x5f, 0x94, 0x0e, 0x67, 0xeb, + 0x26, 0x16, 0x14, 0xe8, 0x57, 0xe8, 0xc3, 0x42, 0xa2, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, + 0xec, 0x55, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x4e, 0x10, 0x17, 0x21, 0x01, 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 m.MaxSqaureSize != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxSqaureSize)) + i-- + dAtA[i] = 0x10 + } + if m.MinSquareSize != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MinSquareSize)) + i-- + dAtA[i] = 0x8 + } + 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 + if m.MinSquareSize != 0 { + n += 1 + sovParams(uint64(m.MinSquareSize)) + } + if m.MaxSqaureSize != 0 { + n += 1 + sovParams(uint64(m.MaxSqaureSize)) + } + 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 != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinSquareSize", wireType) + } + m.MinSquareSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinSquareSize |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxSqaureSize", wireType) + } + m.MaxSqaureSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxSqaureSize |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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/payment/types/query.pb.go b/x/payment/types/query.pb.go index 04022eb22e..d4e3531f2a 100644 --- a/x/payment/types/query.pb.go +++ b/x/payment/types/query.pb.go @@ -7,11 +7,16 @@ import ( context "context" fmt "fmt" _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/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. @@ -25,22 +30,116 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0d907c42280cbd58, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0d907c42280cbd58, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "payment.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "payment.QueryParamsResponse") +} + func init() { proto.RegisterFile("payment/query.proto", fileDescriptor_0d907c42280cbd58) } var fileDescriptor_0d907c42280cbd58 = []byte{ - // 187 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0xce, 0xb1, 0x8e, 0x82, 0x40, - 0x10, 0x06, 0x60, 0x28, 0xee, 0x48, 0x28, 0xef, 0x3a, 0x72, 0xd9, 0x07, 0xb8, 0x44, 0x26, 0xc8, - 0x1b, 0xd8, 0x5b, 0xd8, 0xda, 0xcd, 0x92, 0xc9, 0xba, 0x09, 0xec, 0xac, 0xec, 0x60, 0xe4, 0x2d, - 0x7c, 0x2c, 0x4b, 0x4a, 0x4b, 0x03, 0x2f, 0x62, 0x04, 0xb5, 0x9b, 0x4c, 0xbe, 0xff, 0xcf, 0x9f, - 0xfe, 0x7a, 0xec, 0x1b, 0x72, 0x02, 0xc7, 0x8e, 0xda, 0x3e, 0xf7, 0x2d, 0x0b, 0xff, 0x24, 0xaf, - 0x67, 0xf6, 0x67, 0x98, 0x4d, 0x4d, 0x80, 0xde, 0x02, 0x3a, 0xc7, 0x82, 0x62, 0xd9, 0x85, 0x85, - 0x65, 0xff, 0x15, 0x87, 0x86, 0x03, 0x68, 0x0c, 0xb4, 0xe4, 0xe1, 0x54, 0x68, 0x12, 0x2c, 0xc0, - 0xa3, 0xb1, 0x6e, 0xc6, 0x8b, 0x5d, 0x27, 0xe9, 0xd7, 0xee, 0x29, 0x36, 0xdb, 0xeb, 0xa8, 0xe2, - 0x61, 0x54, 0xf1, 0x7d, 0x54, 0xf1, 0x65, 0x52, 0xd1, 0x30, 0xa9, 0xe8, 0x36, 0xa9, 0x68, 0x5f, - 0x1a, 0x2b, 0x87, 0x4e, 0xe7, 0x15, 0x37, 0x50, 0x51, 0x4d, 0x41, 0x2c, 0x72, 0x6b, 0x3e, 0xf7, - 0x0a, 0xbd, 0x87, 0x33, 0xbc, 0x07, 0x4b, 0xef, 0x29, 0xe8, 0xef, 0xb9, 0xbe, 0x7c, 0x04, 0x00, - 0x00, 0xff, 0xff, 0x99, 0xff, 0xee, 0xed, 0xc8, 0x00, 0x00, 0x00, + // 291 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x4f, 0x4b, 0xc3, 0x30, + 0x18, 0xc6, 0x5b, 0xd1, 0x09, 0xf1, 0x30, 0xcc, 0x06, 0xca, 0x1c, 0x51, 0x76, 0x12, 0x61, 0x0d, + 0xdb, 0xbe, 0xc1, 0xf0, 0x2a, 0xe8, 0x8e, 0xe2, 0x25, 0x2d, 0x2f, 0xb1, 0xb0, 0xe6, 0xcd, 0x9a, + 0x54, 0xec, 0xd5, 0x4f, 0x20, 0xf8, 0xa5, 0x76, 0x1c, 0x78, 0xf1, 0x24, 0xd2, 0xfa, 0x41, 0x64, + 0x4d, 0x2c, 0x0c, 0xbd, 0xbd, 0x3c, 0x7f, 0x7e, 0x0f, 0x09, 0xe9, 0x69, 0x51, 0x66, 0xa0, 0x2c, + 0x5f, 0x15, 0x90, 0x97, 0x91, 0xce, 0xd1, 0x22, 0x3d, 0xf4, 0xe2, 0xa0, 0x2f, 0x51, 0x62, 0xa3, + 0xf1, 0xed, 0xe5, 0xec, 0xc1, 0x50, 0x22, 0xca, 0x25, 0x70, 0xa1, 0x53, 0x2e, 0x94, 0x42, 0x2b, + 0x6c, 0x8a, 0xca, 0x78, 0xf7, 0x2a, 0x41, 0x93, 0xa1, 0xe1, 0xb1, 0x30, 0xe0, 0xa8, 0xfc, 0x69, + 0x12, 0x83, 0x15, 0x13, 0xae, 0x85, 0x4c, 0x55, 0x13, 0xf6, 0xd9, 0xfe, 0xef, 0xba, 0x16, 0xb9, + 0xc8, 0x3c, 0x61, 0xd4, 0x27, 0xf4, 0x6e, 0xdb, 0xbb, 0x6d, 0xc4, 0x05, 0xac, 0x0a, 0x30, 0x76, + 0x74, 0x4d, 0x7a, 0x3b, 0xaa, 0xd1, 0xa8, 0x0c, 0xd0, 0x31, 0xe9, 0xb8, 0xf2, 0x69, 0x78, 0x11, + 0x5e, 0x1e, 0x4d, 0xbb, 0x91, 0x67, 0x46, 0x2e, 0x38, 0xdf, 0x5f, 0x7f, 0x9e, 0x07, 0x0b, 0x1f, + 0x9a, 0x02, 0x39, 0x68, 0x28, 0xf4, 0x81, 0x74, 0x5c, 0x80, 0x9e, 0xb5, 0x8d, 0xbf, 0xab, 0x83, + 0xe1, 0xff, 0xa6, 0x1b, 0x1f, 0x9d, 0xbc, 0xbc, 0x7f, 0xbf, 0xed, 0x1d, 0xd3, 0x2e, 0xdf, 0x7d, + 0xc8, 0xfc, 0x66, 0x5d, 0xb1, 0x70, 0x53, 0xb1, 0xf0, 0xab, 0x62, 0xe1, 0x6b, 0xcd, 0x82, 0x4d, + 0xcd, 0x82, 0x8f, 0x9a, 0x05, 0xf7, 0x33, 0x99, 0xda, 0xc7, 0x22, 0x8e, 0x12, 0xcc, 0x78, 0x02, + 0x4b, 0x30, 0x36, 0x15, 0x98, 0xcb, 0xf6, 0x1e, 0x0b, 0xad, 0xf9, 0x73, 0xcb, 0xb3, 0xa5, 0x06, + 0x13, 0x77, 0x9a, 0x8f, 0x99, 0xfd, 0x04, 0x00, 0x00, 0xff, 0xff, 0x13, 0xfe, 0x9d, 0xcc, 0xae, + 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -55,6 +154,7 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) } type queryClient struct { @@ -65,22 +165,370 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/payment.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/payment.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "payment.Query", HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "payment/query.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "payment/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/payment/types/query.pb.gw.go b/x/payment/types/query.pb.gw.go new file mode 100644 index 0000000000..c8bf5a63fb --- /dev/null +++ b/x/payment/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: payment/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"payment", "params"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) From 4617ccde7cace6ca60550b37f16cd6d807d245ef Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Thu, 20 Oct 2022 23:44:55 +1100 Subject: [PATCH 05/38] feat: add cli command to query params --- x/payment/client/cli/query.go | 2 ++ x/payment/client/cli/query_params.go | 34 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 x/payment/client/cli/query_params.go diff --git a/x/payment/client/cli/query.go b/x/payment/client/cli/query.go index 93113b2d6e..81f036a105 100644 --- a/x/payment/client/cli/query.go +++ b/x/payment/client/cli/query.go @@ -19,5 +19,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { RunE: client.ValidateCmd, } + cmd.AddCommand(CmdQueryParams()) + return cmd } diff --git a/x/payment/client/cli/query_params.go b/x/payment/client/cli/query_params.go new file mode 100644 index 0000000000..b6aeabfa11 --- /dev/null +++ b/x/payment/client/cli/query_params.go @@ -0,0 +1,34 @@ +package cli + +import ( + "context" + + "github.com/celestiaorg/celestia-app/x/payment/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} From e4bed13823790419371679dac466a8be3de07cd1 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Thu, 20 Oct 2022 23:45:50 +1100 Subject: [PATCH 06/38] feat: getter and setter methods to get/set params from keeper --- x/payment/keeper/params.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 x/payment/keeper/params.go diff --git a/x/payment/keeper/params.go b/x/payment/keeper/params.go new file mode 100644 index 0000000000..5b5dac7260 --- /dev/null +++ b/x/payment/keeper/params.go @@ -0,0 +1,31 @@ +package keeper + +import ( + "github.com/celestiaorg/celestia-app/x/payment/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + return types.NewParams( + k.MinSquareSize(ctx), + k.MaxSqaureSize(ctx), + ) +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramstore.SetParamSet(ctx, ¶ms) +} + +// MinSquareSize returns the MinSquareSize param +func (k Keeper) MinSquareSize(ctx sdk.Context) (res int32) { + k.paramstore.Get(ctx, types.KeyMinSquareSize, &res) + return +} + +// MaxSqaureSize returns the MaxSqaureSize param +func (k Keeper) MaxSqaureSize(ctx sdk.Context) (res int32) { + k.paramstore.Get(ctx, types.KeyMaxSqaureSize, &res) + return +} From 03ede00314d4313b5c6e3446687557db7ca13d9a Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Thu, 20 Oct 2022 23:52:27 +1100 Subject: [PATCH 07/38] feat: define param stores in keeper --- x/payment/keeper/keeper.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/x/payment/keeper/keeper.go b/x/payment/keeper/keeper.go index e7b01884cd..5154e2ffcf 100644 --- a/x/payment/keeper/keeper.go +++ b/x/payment/keeper/keeper.go @@ -10,7 +10,9 @@ import ( "github.com/celestiaorg/celestia-app/pkg/shares" "github.com/celestiaorg/celestia-app/x/payment/types" "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) const ( @@ -24,12 +26,22 @@ const ( // Keeper handles all the state changes for the payment module. type Keeper struct { - cdc codec.BinaryCodec + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace } -func NewKeeper(cdc codec.BinaryCodec) *Keeper { +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + ps paramtypes.Subspace, + +) *Keeper { return &Keeper{ - cdc: cdc, + cdc: cdc, + paramstore: ps, } } From 7b77addf00218c6f82851802d579367cd75d5255 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Thu, 20 Oct 2022 23:53:00 +1100 Subject: [PATCH 08/38] chore: pass releavnt stores when initializing payment keeper --- app/app.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/app.go b/app/app.go index b1ea0e8e0f..5bea30e7f4 100644 --- a/app/app.go +++ b/app/app.go @@ -367,6 +367,9 @@ func New( app.PaymentKeeper = *paymentmodulekeeper.NewKeeper( appCodec, + keys[paymentmoduletypes.StoreKey], + keys[paymentmoduletypes.MemStoreKey], + app.GetSubspace(paymentmoduletypes.ModuleName), ) paymentmod := paymentmodule.NewAppModule(appCodec, app.PaymentKeeper) From f4bc0b2f1e5ef2fe51e229962e3339e99a5926b4 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 00:20:26 +1100 Subject: [PATCH 09/38] feat: implement callback to query params --- x/payment/keeper/grpc_query_params.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 x/payment/keeper/grpc_query_params.go diff --git a/x/payment/keeper/grpc_query_params.go b/x/payment/keeper/grpc_query_params.go new file mode 100644 index 0000000000..51930666a8 --- /dev/null +++ b/x/payment/keeper/grpc_query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + "github.com/celestiaorg/celestia-app/x/payment/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} From 7b2936aa711181ce7c483dce9194731ec6732ff8 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 00:46:37 +1100 Subject: [PATCH 10/38] chore: typo --- proto/payment/params.proto | 2 +- x/payment/keeper/params.go | 8 ++++---- x/payment/types/params.go | 22 +++++++++++----------- x/payment/types/params.pb.go | 20 ++++++++++---------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/proto/payment/params.proto b/proto/payment/params.proto index faad8f870b..51ffe2db11 100644 --- a/proto/payment/params.proto +++ b/proto/payment/params.proto @@ -10,5 +10,5 @@ message Params { option (gogoproto.goproto_stringer) = false; int32 minSquareSize = 1 [(gogoproto.moretags) = "yaml:\"min_square_size\""]; - int32 maxSqaureSize = 2 [(gogoproto.moretags) = "yaml:\"max_sqaure_size\""]; + int32 maxSquareSize = 2 [(gogoproto.moretags) = "yaml:\"max_square_size\""]; } \ No newline at end of file diff --git a/x/payment/keeper/params.go b/x/payment/keeper/params.go index 5b5dac7260..579a7fe6f8 100644 --- a/x/payment/keeper/params.go +++ b/x/payment/keeper/params.go @@ -9,7 +9,7 @@ import ( func (k Keeper) GetParams(ctx sdk.Context) types.Params { return types.NewParams( k.MinSquareSize(ctx), - k.MaxSqaureSize(ctx), + k.MaxSquareSize(ctx), ) } @@ -24,8 +24,8 @@ func (k Keeper) MinSquareSize(ctx sdk.Context) (res int32) { return } -// MaxSqaureSize returns the MaxSqaureSize param -func (k Keeper) MaxSqaureSize(ctx sdk.Context) (res int32) { - k.paramstore.Get(ctx, types.KeyMaxSqaureSize, &res) +// MaxSquareSize returns the MaxSquareSize param +func (k Keeper) MaxSquareSize(ctx sdk.Context) (res int32) { + k.paramstore.Get(ctx, types.KeyMaxSquareSize, &res) return } diff --git a/x/payment/types/params.go b/x/payment/types/params.go index 960ef1efee..ba8256dcd3 100644 --- a/x/payment/types/params.go +++ b/x/payment/types/params.go @@ -16,9 +16,9 @@ var ( ) var ( - KeyMaxSqaureSize = []byte("MaxSqaureSize") + KeyMaxSquareSize = []byte("MaxSquareSize") // TODO: Determine the default value - DefaultMaxSqaureSize int32 = 0 + DefaultMaxSquareSize int32 = 0 ) // ParamKeyTable the param key table for launch module @@ -29,11 +29,11 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams( minSquareSize int32, - maxSqaureSize int32, + maxSquareSize int32, ) Params { return Params{ MinSquareSize: minSquareSize, - MaxSqaureSize: maxSqaureSize, + MaxSquareSize: maxSquareSize, } } @@ -41,7 +41,7 @@ func NewParams( func DefaultParams() Params { return NewParams( DefaultMinSquareSize, - DefaultMaxSqaureSize, + DefaultMaxSquareSize, ) } @@ -49,7 +49,7 @@ func DefaultParams() Params { func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMinSquareSize, &p.MinSquareSize, validateMinSquareSize), - paramtypes.NewParamSetPair(KeyMaxSqaureSize, &p.MaxSqaureSize, validateMaxSqaureSize), + paramtypes.NewParamSetPair(KeyMaxSquareSize, &p.MaxSquareSize, validateMaxSquareSize), } } @@ -59,7 +59,7 @@ func (p Params) Validate() error { return err } - if err := validateMaxSqaureSize(p.MaxSqaureSize); err != nil { + if err := validateMaxSquareSize(p.MaxSquareSize); err != nil { return err } @@ -85,15 +85,15 @@ func validateMinSquareSize(v interface{}) error { return nil } -// validateMaxSqaureSize validates the MaxSqaureSize param -func validateMaxSqaureSize(v interface{}) error { - maxSqaureSize, ok := v.(int32) +// validateMaxSquareSize validates the MaxSquareSize param +func validateMaxSquareSize(v interface{}) error { + maxSquareSize, ok := v.(int32) if !ok { return fmt.Errorf("invalid parameter type: %T", v) } // TODO implement validation - _ = maxSqaureSize + _ = maxSquareSize return nil } diff --git a/x/payment/types/params.pb.go b/x/payment/types/params.pb.go index e7a42bf2b7..1ee5abae68 100644 --- a/x/payment/types/params.pb.go +++ b/x/payment/types/params.pb.go @@ -26,7 +26,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { MinSquareSize int32 `protobuf:"varint,1,opt,name=minSquareSize,proto3" json:"minSquareSize,omitempty" yaml:"min_square_size"` - MaxSqaureSize int32 `protobuf:"varint,2,opt,name=maxSqaureSize,proto3" json:"maxSqaureSize,omitempty" yaml:"max_sqaure_size"` + MaxSquareSize int32 `protobuf:"varint,2,opt,name=maxSquareSize,proto3" json:"maxSquareSize,omitempty" yaml:"max_square_size"` } func (m *Params) Reset() { *m = Params{} } @@ -68,9 +68,9 @@ func (m *Params) GetMinSquareSize() int32 { return 0 } -func (m *Params) GetMaxSqaureSize() int32 { +func (m *Params) GetMaxSquareSize() int32 { if m != nil { - return m.MaxSqaureSize + return m.MaxSquareSize } return 0 } @@ -120,8 +120,8 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.MaxSqaureSize != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.MaxSqaureSize)) + if m.MaxSquareSize != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxSquareSize)) i-- dAtA[i] = 0x10 } @@ -153,8 +153,8 @@ func (m *Params) Size() (n int) { if m.MinSquareSize != 0 { n += 1 + sovParams(uint64(m.MinSquareSize)) } - if m.MaxSqaureSize != 0 { - n += 1 + sovParams(uint64(m.MaxSqaureSize)) + if m.MaxSquareSize != 0 { + n += 1 + sovParams(uint64(m.MaxSquareSize)) } return n } @@ -215,9 +215,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { } case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxSqaureSize", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MaxSquareSize", wireType) } - m.MaxSqaureSize = 0 + m.MaxSquareSize = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -227,7 +227,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MaxSqaureSize |= int32(b&0x7F) << shift + m.MaxSquareSize |= int32(b&0x7F) << shift if b < 0x80 { break } From 7f7e6fb76c6d02186fab235e5afbdc543bc42fcf Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 00:48:38 +1100 Subject: [PATCH 11/38] chore: grammar --- proto/payment/query.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proto/payment/query.proto b/proto/payment/query.proto index 643fd050a4..283385d5f2 100644 --- a/proto/payment/query.proto +++ b/proto/payment/query.proto @@ -15,10 +15,10 @@ service Query { } } -// QueryParamsRequest is request type for the Query/Params RPC method. +// QueryParamsRequest is the request type for the Query/Params RPC method. message QueryParamsRequest {} -// QueryParamsResponse is response type for the Query/Params RPC method. +// QueryParamsResponse is the response type for the Query/Params RPC method. message QueryParamsResponse { Params params = 1 [(gogoproto.nullable) = false]; } From fb951c9adb041ded5e4c69480ddfea130b0b225f Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 00:49:31 +1100 Subject: [PATCH 12/38] chore: line ending --- proto/payment/params.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/payment/params.proto b/proto/payment/params.proto index 51ffe2db11..b29e1a3411 100644 --- a/proto/payment/params.proto +++ b/proto/payment/params.proto @@ -11,4 +11,4 @@ message Params { int32 minSquareSize = 1 [(gogoproto.moretags) = "yaml:\"min_square_size\""]; int32 maxSquareSize = 2 [(gogoproto.moretags) = "yaml:\"max_square_size\""]; -} \ No newline at end of file +} From 9c13d2cbcc17291b9c1b3623eb603367009d45c0 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 00:55:22 +1100 Subject: [PATCH 13/38] fix: assign storeKey and memKey --- x/payment/keeper/keeper.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/payment/keeper/keeper.go b/x/payment/keeper/keeper.go index 5154e2ffcf..3eb0c01784 100644 --- a/x/payment/keeper/keeper.go +++ b/x/payment/keeper/keeper.go @@ -41,6 +41,8 @@ func NewKeeper( ) *Keeper { return &Keeper{ cdc: cdc, + storeKey: storeKey, + memKey: memKey, paramstore: ps, } } From cb55e9ff47e6ad2336a6cacee12a57a51518e4b9 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 00:58:18 +1100 Subject: [PATCH 14/38] fix: follow standard while naming proto var --- proto/payment/params.proto | 4 ++-- x/payment/types/params.pb.go | 29 ++++++++++++++--------------- x/payment/types/query.pb.go | 4 ++-- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/proto/payment/params.proto b/proto/payment/params.proto index b29e1a3411..4e8bcebd9c 100644 --- a/proto/payment/params.proto +++ b/proto/payment/params.proto @@ -9,6 +9,6 @@ option go_package = "github.com/celestiaorg/celestia-app/x/payment/types"; message Params { option (gogoproto.goproto_stringer) = false; - int32 minSquareSize = 1 [(gogoproto.moretags) = "yaml:\"min_square_size\""]; - int32 maxSquareSize = 2 [(gogoproto.moretags) = "yaml:\"max_square_size\""]; + int32 min_square_size = 1 [(gogoproto.moretags) = "yaml:\"min_square_size\""]; + int32 max_square_size = 2 [(gogoproto.moretags) = "yaml:\"max_square_size\""]; } diff --git a/x/payment/types/params.pb.go b/x/payment/types/params.pb.go index 1ee5abae68..1f0bb389f3 100644 --- a/x/payment/types/params.pb.go +++ b/x/payment/types/params.pb.go @@ -25,8 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - MinSquareSize int32 `protobuf:"varint,1,opt,name=minSquareSize,proto3" json:"minSquareSize,omitempty" yaml:"min_square_size"` - MaxSquareSize int32 `protobuf:"varint,2,opt,name=maxSquareSize,proto3" json:"maxSquareSize,omitempty" yaml:"max_square_size"` + MinSquareSize int32 `protobuf:"varint,1,opt,name=min_square_size,json=minSquareSize,proto3" json:"min_square_size,omitempty" yaml:"min_square_size"` + MaxSquareSize int32 `protobuf:"varint,2,opt,name=max_square_size,json=maxSquareSize,proto3" json:"max_square_size,omitempty" yaml:"max_square_size"` } func (m *Params) Reset() { *m = Params{} } @@ -82,22 +82,21 @@ func init() { func init() { proto.RegisterFile("payment/params.proto", fileDescriptor_12d54b052075926a) } var fileDescriptor_12d54b052075926a = []byte{ - // 225 bytes of a gzipped FileDescriptorProto + // 220 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x29, 0x48, 0xac, 0xcc, 0x4d, 0xcd, 0x2b, 0xd1, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x87, 0x8a, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xc5, 0xf4, 0x41, 0x2c, 0x88, - 0xb4, 0xd2, 0x24, 0x46, 0x2e, 0xb6, 0x00, 0xb0, 0x7a, 0x21, 0x07, 0x2e, 0xde, 0xdc, 0xcc, 0xbc, - 0xe0, 0xc2, 0xd2, 0xc4, 0xa2, 0xd4, 0xe0, 0xcc, 0xaa, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x56, - 0x27, 0xa9, 0x4f, 0xf7, 0xe4, 0xc5, 0x2a, 0x13, 0x73, 0x73, 0xac, 0x94, 0x72, 0x33, 0xf3, 0xe2, - 0x8b, 0xc1, 0xf2, 0xf1, 0xc5, 0x99, 0x55, 0xa9, 0x4a, 0x41, 0xa8, 0x1a, 0xc0, 0x26, 0x24, 0x56, - 0x04, 0x17, 0x26, 0x96, 0x42, 0x4d, 0x60, 0xc2, 0x30, 0x21, 0xb1, 0x22, 0xbe, 0x18, 0x2c, 0x0f, - 0x37, 0x01, 0x59, 0x83, 0x15, 0xcb, 0x8c, 0x05, 0xf2, 0x0c, 0x4e, 0xbe, 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, 0x9c, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, - 0x9f, 0xab, 0x9f, 0x9c, 0x9a, 0x93, 0x5a, 0x5c, 0x92, 0x99, 0x98, 0x5f, 0x94, 0x0e, 0x67, 0xeb, - 0x26, 0x16, 0x14, 0xe8, 0x57, 0xe8, 0xc3, 0x42, 0xa2, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, - 0xec, 0x55, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x4e, 0x10, 0x17, 0x21, 0x01, 0x00, - 0x00, + 0xb4, 0xd2, 0x34, 0x46, 0x2e, 0xb6, 0x00, 0xb0, 0x7a, 0x21, 0x27, 0x2e, 0xfe, 0xdc, 0xcc, 0xbc, + 0xf8, 0xe2, 0xc2, 0xd2, 0xc4, 0xa2, 0xd4, 0xf8, 0xe2, 0xcc, 0xaa, 0x54, 0x09, 0x46, 0x05, 0x46, + 0x0d, 0x56, 0x27, 0xa9, 0x4f, 0xf7, 0xe4, 0xc5, 0x2a, 0x13, 0x73, 0x73, 0xac, 0x94, 0xd0, 0x14, + 0x28, 0x05, 0xf1, 0xe6, 0x66, 0xe6, 0x05, 0x83, 0x05, 0x82, 0x33, 0xab, 0x52, 0xc1, 0x66, 0x24, + 0x56, 0xa0, 0x98, 0xc1, 0x84, 0x61, 0x06, 0xaa, 0x02, 0x90, 0x19, 0x89, 0x15, 0x08, 0x33, 0xac, + 0x58, 0x66, 0x2c, 0x90, 0x67, 0x70, 0xf2, 0x3d, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, + 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, + 0x86, 0x28, 0xe3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xe4, 0xd4, + 0x9c, 0xd4, 0xe2, 0x92, 0xcc, 0xc4, 0xfc, 0xa2, 0x74, 0x38, 0x5b, 0x37, 0xb1, 0xa0, 0x40, 0xbf, + 0x42, 0x1f, 0x16, 0x1a, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0xef, 0x1a, 0x03, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x1c, 0x79, 0x91, 0x12, 0x25, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/payment/types/query.pb.go b/x/payment/types/query.pb.go index d4e3531f2a..06cec8fd4b 100644 --- a/x/payment/types/query.pb.go +++ b/x/payment/types/query.pb.go @@ -30,7 +30,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryParamsRequest is request type for the Query/Params RPC method. +// QueryParamsRequest is the request type for the Query/Params RPC method. type QueryParamsRequest struct { } @@ -67,7 +67,7 @@ func (m *QueryParamsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo -// QueryParamsResponse is response type for the Query/Params RPC method. +// QueryParamsResponse is the response type for the Query/Params RPC method. type QueryParamsResponse struct { Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` } From ec06af53fd13aa1f35f941fb0fef01bbad1c0ac0 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 00:59:40 +1100 Subject: [PATCH 15/38] chore: documentation comment --- proto/payment/query.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/proto/payment/query.proto b/proto/payment/query.proto index 283385d5f2..3c6c76d8a0 100644 --- a/proto/payment/query.proto +++ b/proto/payment/query.proto @@ -10,6 +10,7 @@ option go_package = "github.com/celestiaorg/celestia-app/x/payment/types"; // Query defines the gRPC querier service. service Query { + // Params queries the parameters of the module. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/payment/params"; } From a51a379f03fda6379b784733af48563ee0330d85 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 02:47:24 +1100 Subject: [PATCH 16/38] chore: run gofumpt --- x/payment/keeper/keeper.go | 1 - 1 file changed, 1 deletion(-) diff --git a/x/payment/keeper/keeper.go b/x/payment/keeper/keeper.go index 3eb0c01784..5a88dcbfaa 100644 --- a/x/payment/keeper/keeper.go +++ b/x/payment/keeper/keeper.go @@ -37,7 +37,6 @@ func NewKeeper( storeKey, memKey storetypes.StoreKey, ps paramtypes.Subspace, - ) *Keeper { return &Keeper{ cdc: cdc, From 85d8b6981f21cbf592e4b6fb38e5fb4098d48b63 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 02:59:48 +1100 Subject: [PATCH 17/38] fix: generate pb files using correct version --- x/payment/types/query.pb.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/payment/types/query.pb.go b/x/payment/types/query.pb.go index 06cec8fd4b..9f454c3ebf 100644 --- a/x/payment/types/query.pb.go +++ b/x/payment/types/query.pb.go @@ -154,6 +154,7 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { + // Params queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) } @@ -176,6 +177,7 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . // QueryServer is the server API for Query service. type QueryServer interface { + // Params queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) } From 4aeac7466bb363f0b08ab3c704734d53e25fc695 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 04:14:05 +1100 Subject: [PATCH 18/38] chore: make params uint32 instead of int32 and set default values --- proto/payment/params.proto | 4 ++-- x/payment/keeper/params.go | 4 ++-- x/payment/types/params.go | 14 ++++++-------- x/payment/types/params.pb.go | 16 ++++++++-------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/proto/payment/params.proto b/proto/payment/params.proto index 4e8bcebd9c..8e0cf13159 100644 --- a/proto/payment/params.proto +++ b/proto/payment/params.proto @@ -9,6 +9,6 @@ option go_package = "github.com/celestiaorg/celestia-app/x/payment/types"; message Params { option (gogoproto.goproto_stringer) = false; - int32 min_square_size = 1 [(gogoproto.moretags) = "yaml:\"min_square_size\""]; - int32 max_square_size = 2 [(gogoproto.moretags) = "yaml:\"max_square_size\""]; + uint32 min_square_size = 1 [(gogoproto.moretags) = "yaml:\"min_square_size\""]; + uint32 max_square_size = 2 [(gogoproto.moretags) = "yaml:\"max_square_size\""]; } diff --git a/x/payment/keeper/params.go b/x/payment/keeper/params.go index 579a7fe6f8..6d2d6739ba 100644 --- a/x/payment/keeper/params.go +++ b/x/payment/keeper/params.go @@ -19,13 +19,13 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { } // MinSquareSize returns the MinSquareSize param -func (k Keeper) MinSquareSize(ctx sdk.Context) (res int32) { +func (k Keeper) MinSquareSize(ctx sdk.Context) (res uint32) { k.paramstore.Get(ctx, types.KeyMinSquareSize, &res) return } // MaxSquareSize returns the MaxSquareSize param -func (k Keeper) MaxSquareSize(ctx sdk.Context) (res int32) { +func (k Keeper) MaxSquareSize(ctx sdk.Context) (res uint32) { k.paramstore.Get(ctx, types.KeyMaxSquareSize, &res) return } diff --git a/x/payment/types/params.go b/x/payment/types/params.go index ba8256dcd3..d7d457a555 100644 --- a/x/payment/types/params.go +++ b/x/payment/types/params.go @@ -10,15 +10,13 @@ import ( var _ paramtypes.ParamSet = (*Params)(nil) var ( - KeyMinSquareSize = []byte("MinSquareSize") - // TODO: Determine the default value - DefaultMinSquareSize int32 = 0 + KeyMinSquareSize = []byte("MinSquareSize") + DefaultMinSquareSize uint32 = 1 ) var ( - KeyMaxSquareSize = []byte("MaxSquareSize") - // TODO: Determine the default value - DefaultMaxSquareSize int32 = 0 + KeyMaxSquareSize = []byte("MaxSquareSize") + DefaultMaxSquareSize uint32 = 128 ) // ParamKeyTable the param key table for launch module @@ -28,8 +26,8 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams( - minSquareSize int32, - maxSquareSize int32, + minSquareSize uint32, + maxSquareSize uint32, ) Params { return Params{ MinSquareSize: minSquareSize, diff --git a/x/payment/types/params.pb.go b/x/payment/types/params.pb.go index 1f0bb389f3..6b9de7bb7a 100644 --- a/x/payment/types/params.pb.go +++ b/x/payment/types/params.pb.go @@ -25,8 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - MinSquareSize int32 `protobuf:"varint,1,opt,name=min_square_size,json=minSquareSize,proto3" json:"min_square_size,omitempty" yaml:"min_square_size"` - MaxSquareSize int32 `protobuf:"varint,2,opt,name=max_square_size,json=maxSquareSize,proto3" json:"max_square_size,omitempty" yaml:"max_square_size"` + MinSquareSize uint32 `protobuf:"varint,1,opt,name=min_square_size,json=minSquareSize,proto3" json:"min_square_size,omitempty" yaml:"min_square_size"` + MaxSquareSize uint32 `protobuf:"varint,2,opt,name=max_square_size,json=maxSquareSize,proto3" json:"max_square_size,omitempty" yaml:"max_square_size"` } func (m *Params) Reset() { *m = Params{} } @@ -61,14 +61,14 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetMinSquareSize() int32 { +func (m *Params) GetMinSquareSize() uint32 { if m != nil { return m.MinSquareSize } return 0 } -func (m *Params) GetMaxSquareSize() int32 { +func (m *Params) GetMaxSquareSize() uint32 { if m != nil { return m.MaxSquareSize } @@ -88,7 +88,7 @@ var fileDescriptor_12d54b052075926a = []byte{ 0x17, 0x62, 0x87, 0x8a, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xc5, 0xf4, 0x41, 0x2c, 0x88, 0xb4, 0xd2, 0x34, 0x46, 0x2e, 0xb6, 0x00, 0xb0, 0x7a, 0x21, 0x27, 0x2e, 0xfe, 0xdc, 0xcc, 0xbc, 0xf8, 0xe2, 0xc2, 0xd2, 0xc4, 0xa2, 0xd4, 0xf8, 0xe2, 0xcc, 0xaa, 0x54, 0x09, 0x46, 0x05, 0x46, - 0x0d, 0x56, 0x27, 0xa9, 0x4f, 0xf7, 0xe4, 0xc5, 0x2a, 0x13, 0x73, 0x73, 0xac, 0x94, 0xd0, 0x14, + 0x0d, 0x5e, 0x27, 0xa9, 0x4f, 0xf7, 0xe4, 0xc5, 0x2a, 0x13, 0x73, 0x73, 0xac, 0x94, 0xd0, 0x14, 0x28, 0x05, 0xf1, 0xe6, 0x66, 0xe6, 0x05, 0x83, 0x05, 0x82, 0x33, 0xab, 0x52, 0xc1, 0x66, 0x24, 0x56, 0xa0, 0x98, 0xc1, 0x84, 0x61, 0x06, 0xaa, 0x02, 0x90, 0x19, 0x89, 0x15, 0x08, 0x33, 0xac, 0x58, 0x66, 0x2c, 0x90, 0x67, 0x70, 0xf2, 0x3d, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, @@ -96,7 +96,7 @@ var fileDescriptor_12d54b052075926a = []byte{ 0x86, 0x28, 0xe3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xe4, 0xd4, 0x9c, 0xd4, 0xe2, 0x92, 0xcc, 0xc4, 0xfc, 0xa2, 0x74, 0x38, 0x5b, 0x37, 0xb1, 0xa0, 0x40, 0xbf, 0x42, 0x1f, 0x16, 0x1a, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0xef, 0x1a, 0x03, 0x02, - 0x00, 0x00, 0xff, 0xff, 0x1c, 0x79, 0x91, 0x12, 0x25, 0x01, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x05, 0x68, 0x47, 0xac, 0x25, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -207,7 +207,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MinSquareSize |= int32(b&0x7F) << shift + m.MinSquareSize |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -226,7 +226,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MaxSquareSize |= int32(b&0x7F) << shift + m.MaxSquareSize |= uint32(b&0x7F) << shift if b < 0x80 { break } From 1d6b38e6aac30809f1b71989bbf6c3cb8ec8978b Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 04:14:57 +1100 Subject: [PATCH 19/38] chore: typo --- x/payment/types/params.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/payment/types/params.go b/x/payment/types/params.go index d7d457a555..ba953f358f 100644 --- a/x/payment/types/params.go +++ b/x/payment/types/params.go @@ -19,7 +19,7 @@ var ( DefaultMaxSquareSize uint32 = 128 ) -// ParamKeyTable the param key table for launch module +// ParamKeyTable the param key table for the payment module func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } From 092cc395bf47a08c312fed621c45f5e9c848ca71 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 04:16:16 +1100 Subject: [PATCH 20/38] chore: better comment --- x/payment/types/params.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/payment/types/params.go b/x/payment/types/params.go index ba953f358f..27569cdf78 100644 --- a/x/payment/types/params.go +++ b/x/payment/types/params.go @@ -43,7 +43,7 @@ func DefaultParams() Params { ) } -// ParamSetPairs get the params.ParamSet +// ParamSetPairs gets the list of param key-pair values func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMinSquareSize, &p.MinSquareSize, validateMinSquareSize), From 499fe6f5c79102e9a8f4f0b3d184e62f34b299b7 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 04:18:14 +1100 Subject: [PATCH 21/38] fix: min/max square size validation --- x/payment/types/params.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/x/payment/types/params.go b/x/payment/types/params.go index 27569cdf78..7bf806f524 100644 --- a/x/payment/types/params.go +++ b/x/payment/types/params.go @@ -72,26 +72,20 @@ func (p Params) String() string { // validateMinSquareSize validates the MinSquareSize param func validateMinSquareSize(v interface{}) error { - minSquareSize, ok := v.(int32) + _, ok := v.(uint32) if !ok { return fmt.Errorf("invalid parameter type: %T", v) } - // TODO implement validation - _ = minSquareSize - return nil } // validateMaxSquareSize validates the MaxSquareSize param func validateMaxSquareSize(v interface{}) error { - maxSquareSize, ok := v.(int32) + _, ok := v.(uint32) if !ok { return fmt.Errorf("invalid parameter type: %T", v) } - // TODO implement validation - _ = maxSquareSize - return nil } From 500a6f5d9753df2200756887fdd6a7a7c05ef502 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 05:03:33 +1100 Subject: [PATCH 22/38] chore: define genesis state params --- x/payment/genesis.go | 2 ++ x/payment/types/genesis.go | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/x/payment/genesis.go b/x/payment/genesis.go index df9fdab9d0..5ddfdf7fe3 100644 --- a/x/payment/genesis.go +++ b/x/payment/genesis.go @@ -9,11 +9,13 @@ import ( // InitGenesis initializes the capability module's state from a provided genesis // state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + k.SetParams(ctx, genState.Params) } // ExportGenesis returns the capability module's exported genesis. func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) return genesis } diff --git a/x/payment/types/genesis.go b/x/payment/types/genesis.go index 094d1119cc..0785224ae9 100644 --- a/x/payment/types/genesis.go +++ b/x/payment/types/genesis.go @@ -5,11 +5,13 @@ const DefaultIndex uint64 = 1 // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { - return &GenesisState{} + return &GenesisState{ + Params: DefaultParams(), + } } // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - return nil + return gs.Params.Validate() } From b30879b4614bd00f409b0eed95eb27541ad25580 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Fri, 21 Oct 2022 05:32:30 +1100 Subject: [PATCH 23/38] chore: set key table for subspace if not already set --- x/payment/genesis.go | 1 - x/payment/keeper/grpc_query.go | 7 +++++++ x/payment/keeper/keeper.go | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 x/payment/keeper/grpc_query.go diff --git a/x/payment/genesis.go b/x/payment/genesis.go index 5ddfdf7fe3..e496c6e908 100644 --- a/x/payment/genesis.go +++ b/x/payment/genesis.go @@ -16,6 +16,5 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) - return genesis } diff --git a/x/payment/keeper/grpc_query.go b/x/payment/keeper/grpc_query.go new file mode 100644 index 0000000000..f5e93a4906 --- /dev/null +++ b/x/payment/keeper/grpc_query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/celestiaorg/celestia-app/x/payment/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/payment/keeper/keeper.go b/x/payment/keeper/keeper.go index 5a88dcbfaa..7705deaf79 100644 --- a/x/payment/keeper/keeper.go +++ b/x/payment/keeper/keeper.go @@ -38,6 +38,10 @@ func NewKeeper( memKey storetypes.StoreKey, ps paramtypes.Subspace, ) *Keeper { + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + return &Keeper{ cdc: cdc, storeKey: storeKey, From 2085c1bb6c6760621cce05f8a4c6da2b74831d7d Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Tue, 25 Oct 2022 11:02:48 +0530 Subject: [PATCH 24/38] test: define dummy payment keeper for testing --- testutil/keeper/payment.go | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 testutil/keeper/payment.go diff --git a/testutil/keeper/payment.go b/testutil/keeper/payment.go new file mode 100644 index 0000000000..1b0aba0571 --- /dev/null +++ b/testutil/keeper/payment.go @@ -0,0 +1,53 @@ +package keeper + +import ( + "testing" + + "github.com/celestiaorg/celestia-app/testutil" + "github.com/celestiaorg/celestia-app/x/payment/keeper" + "github.com/celestiaorg/celestia-app/x/payment/types" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmdb "github.com/tendermint/tm-db" +) + +func PaymentKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + paramsSubspace := typesparams.NewSubspace(cdc, + testutil.MakeTestCodec(), + storeKey, + memStoreKey, + "Payment", + ) + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + paramsSubspace, + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + return k, ctx +} From aedb534622a7cdcbf345291284f16ba83947c83b Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Tue, 25 Oct 2022 11:03:12 +0530 Subject: [PATCH 25/38] test: define nullify module to set data to nil --- testutil/nullify/nullify.go | 57 +++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 testutil/nullify/nullify.go diff --git a/testutil/nullify/nullify.go b/testutil/nullify/nullify.go new file mode 100644 index 0000000000..3b968c09c1 --- /dev/null +++ b/testutil/nullify/nullify.go @@ -0,0 +1,57 @@ +// Package nullify provides methods to init nil values structs for test assertion. +package nullify + +import ( + "reflect" + "unsafe" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + coinType = reflect.TypeOf(sdk.Coin{}) + coinsType = reflect.TypeOf(sdk.Coins{}) +) + +// Fill analyze all struct fields and slices with +// reflection and initialize the nil and empty slices, +// structs, and pointers. +func Fill(x interface{}) interface{} { + v := reflect.Indirect(reflect.ValueOf(x)) + switch v.Kind() { + case reflect.Slice: + for i := 0; i < v.Len(); i++ { + obj := v.Index(i) + objPt := reflect.NewAt(obj.Type(), unsafe.Pointer(obj.UnsafeAddr())).Interface() + objPt = Fill(objPt) + obj.Set(reflect.ValueOf(objPt)) + } + case reflect.Struct: + for i := 0; i < v.NumField(); i++ { + f := reflect.Indirect(v.Field(i)) + if !f.CanSet() { + continue + } + switch f.Kind() { + case reflect.Slice: + f.Set(reflect.MakeSlice(f.Type(), 0, 0)) + case reflect.Struct: + switch f.Type() { + case coinType: + coin := reflect.New(coinType).Interface() + s := reflect.ValueOf(coin).Elem() + f.Set(s) + case coinsType: + coins := reflect.New(coinsType).Interface() + s := reflect.ValueOf(coins).Elem() + f.Set(s) + default: + objPt := reflect.NewAt(f.Type(), unsafe.Pointer(f.UnsafeAddr())).Interface() + s := Fill(objPt) + f.Set(reflect.ValueOf(s)) + } + } + } + } + return reflect.Indirect(v).Interface() +} From e89cab313e6fedc66e0111c3c56bc7bda1e4280d Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Tue, 25 Oct 2022 11:03:28 +0530 Subject: [PATCH 26/38] test: params query test --- x/payment/keeper/grpc_query_params_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 x/payment/keeper/grpc_query_params_test.go diff --git a/x/payment/keeper/grpc_query_params_test.go b/x/payment/keeper/grpc_query_params_test.go new file mode 100644 index 0000000000..950adc390f --- /dev/null +++ b/x/payment/keeper/grpc_query_params_test.go @@ -0,0 +1,21 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/celestiaorg/celestia-app/testutil/keeper" + "github.com/celestiaorg/celestia-app/x/payment/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx := testkeeper.PaymentKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() + keeper.SetParams(ctx, params) + + response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} From 9f7ed516bd51a58b905926c2f8f236767e16c321 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Tue, 25 Oct 2022 11:03:37 +0530 Subject: [PATCH 27/38] test: genesis test --- x/payment/genesis_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 x/payment/genesis_test.go diff --git a/x/payment/genesis_test.go b/x/payment/genesis_test.go new file mode 100644 index 0000000000..5e90a38c61 --- /dev/null +++ b/x/payment/genesis_test.go @@ -0,0 +1,25 @@ +package payment_test + +import ( + "testing" + + keepertest "github.com/celestiaorg/celestia-app/testutil/keeper" + "github.com/celestiaorg/celestia-app/testutil/nullify" + "github.com/celestiaorg/celestia-app/x/payment" + "github.com/celestiaorg/celestia-app/x/payment/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + } + + k, ctx := keepertest.PaymentKeeper(t) + payment.InitGenesis(ctx, *k, genesisState) + got := payment.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) +} From beeb454e50e3a4acb252ee6039cb38b1eb639a92 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Tue, 25 Oct 2022 13:05:50 +0530 Subject: [PATCH 28/38] test: add params keeper test --- x/payment/keeper/params_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 x/payment/keeper/params_test.go diff --git a/x/payment/keeper/params_test.go b/x/payment/keeper/params_test.go new file mode 100644 index 0000000000..eb5c44a75b --- /dev/null +++ b/x/payment/keeper/params_test.go @@ -0,0 +1,20 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/celestiaorg/celestia-app/testutil/keeper" + "github.com/celestiaorg/celestia-app/x/payment/types" + "github.com/stretchr/testify/require" +) + +func TestGetParams(t *testing.T) { + k, ctx := testkeeper.PaymentKeeper(t) + params := types.DefaultParams() + + k.SetParams(ctx, params) + + require.EqualValues(t, params, k.GetParams(ctx)) + require.EqualValues(t, params.MinSquareSize, k.MinSquareSize(ctx)) + require.EqualValues(t, params.MaxSquareSize, k.MaxSquareSize(ctx)) +} From 45e6ff3274e005772f89231759472d5eae145e26 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Mon, 31 Oct 2022 21:00:57 +0530 Subject: [PATCH 29/38] chore: cleanup --- testutil/nullify/nullify.go | 6 +++--- x/payment/keeper/keeper.go | 4 ++-- x/payment/keeper/params.go | 8 ++++---- x/payment/types/params.go | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/testutil/nullify/nullify.go b/testutil/nullify/nullify.go index 3b968c09c1..e646027769 100644 --- a/testutil/nullify/nullify.go +++ b/testutil/nullify/nullify.go @@ -1,4 +1,4 @@ -// Package nullify provides methods to init nil values structs for test assertion. +// Package nullify provides methods to init nil value structs for test assertion. package nullify import ( @@ -13,8 +13,8 @@ var ( coinsType = reflect.TypeOf(sdk.Coins{}) ) -// Fill analyze all struct fields and slices with -// reflection and initialize the nil and empty slices, +// Fill analyzes all struct fields and slices with +// reflection and initializes the nil and empty slices, // structs, and pointers. func Fill(x interface{}) interface{} { v := reflect.Indirect(reflect.ValueOf(x)) diff --git a/x/payment/keeper/keeper.go b/x/payment/keeper/keeper.go index 7705deaf79..1032de742d 100644 --- a/x/payment/keeper/keeper.go +++ b/x/payment/keeper/keeper.go @@ -29,7 +29,7 @@ type Keeper struct { cdc codec.BinaryCodec storeKey storetypes.StoreKey memKey storetypes.StoreKey - paramstore paramtypes.Subspace + paramStore paramtypes.Subspace } func NewKeeper( @@ -46,7 +46,7 @@ func NewKeeper( cdc: cdc, storeKey: storeKey, memKey: memKey, - paramstore: ps, + paramStore: ps, } } diff --git a/x/payment/keeper/params.go b/x/payment/keeper/params.go index 6d2d6739ba..3607bbf413 100644 --- a/x/payment/keeper/params.go +++ b/x/payment/keeper/params.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// GetParams get all parameters as types.Params +// GetParams gets all parameters as types.Params func (k Keeper) GetParams(ctx sdk.Context) types.Params { return types.NewParams( k.MinSquareSize(ctx), @@ -15,17 +15,17 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params { // SetParams set the params func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { - k.paramstore.SetParamSet(ctx, ¶ms) + k.paramStore.SetParamSet(ctx, ¶ms) } // MinSquareSize returns the MinSquareSize param func (k Keeper) MinSquareSize(ctx sdk.Context) (res uint32) { - k.paramstore.Get(ctx, types.KeyMinSquareSize, &res) + k.paramStore.Get(ctx, types.KeyMinSquareSize, &res) return } // MaxSquareSize returns the MaxSquareSize param func (k Keeper) MaxSquareSize(ctx sdk.Context) (res uint32) { - k.paramstore.Get(ctx, types.KeyMaxSquareSize, &res) + k.paramStore.Get(ctx, types.KeyMaxSquareSize, &res) return } diff --git a/x/payment/types/params.go b/x/payment/types/params.go index 7bf806f524..42f0860f78 100644 --- a/x/payment/types/params.go +++ b/x/payment/types/params.go @@ -19,7 +19,7 @@ var ( DefaultMaxSquareSize uint32 = 128 ) -// ParamKeyTable the param key table for the payment module +// ParamKeyTable returns the param key table for the payment module func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } @@ -43,7 +43,7 @@ func DefaultParams() Params { ) } -// ParamSetPairs gets the list of param key-pair values +// ParamSetPairs gets the list of param key-value pairs func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMinSquareSize, &p.MinSquareSize, validateMinSquareSize), From cd3e995fc3035fef6c92165ef95e8ef83753256e Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Thu, 3 Nov 2022 13:55:48 +0530 Subject: [PATCH 30/38] test: removing fill assertions and unsafe code --- testutil/nullify/nullify.go | 57 ------------------------------------- x/payment/genesis_test.go | 4 --- 2 files changed, 61 deletions(-) delete mode 100644 testutil/nullify/nullify.go diff --git a/testutil/nullify/nullify.go b/testutil/nullify/nullify.go deleted file mode 100644 index e646027769..0000000000 --- a/testutil/nullify/nullify.go +++ /dev/null @@ -1,57 +0,0 @@ -// Package nullify provides methods to init nil value structs for test assertion. -package nullify - -import ( - "reflect" - "unsafe" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var ( - coinType = reflect.TypeOf(sdk.Coin{}) - coinsType = reflect.TypeOf(sdk.Coins{}) -) - -// Fill analyzes all struct fields and slices with -// reflection and initializes the nil and empty slices, -// structs, and pointers. -func Fill(x interface{}) interface{} { - v := reflect.Indirect(reflect.ValueOf(x)) - switch v.Kind() { - case reflect.Slice: - for i := 0; i < v.Len(); i++ { - obj := v.Index(i) - objPt := reflect.NewAt(obj.Type(), unsafe.Pointer(obj.UnsafeAddr())).Interface() - objPt = Fill(objPt) - obj.Set(reflect.ValueOf(objPt)) - } - case reflect.Struct: - for i := 0; i < v.NumField(); i++ { - f := reflect.Indirect(v.Field(i)) - if !f.CanSet() { - continue - } - switch f.Kind() { - case reflect.Slice: - f.Set(reflect.MakeSlice(f.Type(), 0, 0)) - case reflect.Struct: - switch f.Type() { - case coinType: - coin := reflect.New(coinType).Interface() - s := reflect.ValueOf(coin).Elem() - f.Set(s) - case coinsType: - coins := reflect.New(coinsType).Interface() - s := reflect.ValueOf(coins).Elem() - f.Set(s) - default: - objPt := reflect.NewAt(f.Type(), unsafe.Pointer(f.UnsafeAddr())).Interface() - s := Fill(objPt) - f.Set(reflect.ValueOf(s)) - } - } - } - } - return reflect.Indirect(v).Interface() -} diff --git a/x/payment/genesis_test.go b/x/payment/genesis_test.go index 5e90a38c61..e494439ff9 100644 --- a/x/payment/genesis_test.go +++ b/x/payment/genesis_test.go @@ -4,7 +4,6 @@ import ( "testing" keepertest "github.com/celestiaorg/celestia-app/testutil/keeper" - "github.com/celestiaorg/celestia-app/testutil/nullify" "github.com/celestiaorg/celestia-app/x/payment" "github.com/celestiaorg/celestia-app/x/payment/types" "github.com/stretchr/testify/require" @@ -19,7 +18,4 @@ func TestGenesis(t *testing.T) { payment.InitGenesis(ctx, *k, genesisState) got := payment.ExportGenesis(ctx, *k) require.NotNil(t, got) - - nullify.Fill(&genesisState) - nullify.Fill(got) } From 6e44517c5a7e1d3134925e0df7010b07b77df00e Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Thu, 3 Nov 2022 14:00:15 +0530 Subject: [PATCH 31/38] chore: assert that min/max sqaure size is not 0 --- x/payment/types/params.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/x/payment/types/params.go b/x/payment/types/params.go index 42f0860f78..ec82857ed4 100644 --- a/x/payment/types/params.go +++ b/x/payment/types/params.go @@ -72,20 +72,28 @@ func (p Params) String() string { // validateMinSquareSize validates the MinSquareSize param func validateMinSquareSize(v interface{}) error { - _, ok := v.(uint32) + minSquareSize, ok := v.(uint32) if !ok { return fmt.Errorf("invalid parameter type: %T", v) } + if minSquareSize == 0 { + return fmt.Errorf("min square size cannot be 0") + } + return nil } // validateMaxSquareSize validates the MaxSquareSize param func validateMaxSquareSize(v interface{}) error { - _, ok := v.(uint32) + maxSquareSize, ok := v.(uint32) if !ok { return fmt.Errorf("invalid parameter type: %T", v) } + if maxSquareSize == 0 { + return fmt.Errorf("max square size cannot be 0") + } + return nil } From f66f6df7a4c3bbacf965b794ed4c47540188ff3b Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Thu, 3 Nov 2022 14:35:39 +0530 Subject: [PATCH 32/38] test: add equality check for genesis params --- x/payment/genesis_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/payment/genesis_test.go b/x/payment/genesis_test.go index e494439ff9..c5e5d8433c 100644 --- a/x/payment/genesis_test.go +++ b/x/payment/genesis_test.go @@ -18,4 +18,5 @@ func TestGenesis(t *testing.T) { payment.InitGenesis(ctx, *k, genesisState) got := payment.ExportGenesis(ctx, *k) require.NotNil(t, got) + require.Equal(t, types.DefaultParams(), got.Params) } From a53051e23fe1d3d906abfdcd8865453a286684fb Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Thu, 3 Nov 2022 15:03:54 +0530 Subject: [PATCH 33/38] chore update dependency --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 67ddd7a09d..ee1834a89b 100644 --- a/go.mod +++ b/go.mod @@ -32,6 +32,7 @@ require ( github.com/regen-network/cosmos-proto v0.3.1 github.com/tendermint/tendermint v0.34.20 golang.org/x/exp v0.0.0-20221012211006-4de253d81b95 + gopkg.in/yaml.v2 v2.4.0 ) require ( @@ -173,7 +174,6 @@ require ( google.golang.org/protobuf v1.28.1 // indirect gopkg.in/ini.v1 v1.66.6 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.6 // indirect sigs.k8s.io/yaml v1.3.0 // indirect From a7452740236a82689bdfd044eb385cce6f189808 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Thu, 3 Nov 2022 15:04:14 +0530 Subject: [PATCH 34/38] test: fix test by defining min/max square size --- x/payment/types/genesis_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/x/payment/types/genesis_test.go b/x/payment/types/genesis_test.go index 56a870f7ff..4e7ad402d2 100644 --- a/x/payment/types/genesis_test.go +++ b/x/payment/types/genesis_test.go @@ -19,9 +19,14 @@ func TestGenesisState_Validate(t *testing.T) { valid: true, }, { - desc: "valid genesis state", - genState: &types.GenesisState{}, - valid: true, + desc: "valid genesis state", + genState: &types.GenesisState{ + Params: types.Params{ + MinSquareSize: 512, + MaxSquareSize: 1024, + }, + }, + valid: true, }, } { t.Run(tc.desc, func(t *testing.T) { From 14034e56e4fd0a71b4666df3b4291a291f8f8bb8 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Tue, 8 Nov 2022 15:51:42 +0530 Subject: [PATCH 35/38] feat: define skeletal simulation package --- x/payment/simulation/simapp.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 x/payment/simulation/simapp.go diff --git a/x/payment/simulation/simapp.go b/x/payment/simulation/simapp.go new file mode 100644 index 0000000000..92c437c0d1 --- /dev/null +++ b/x/payment/simulation/simapp.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} From f3bfa344849ec68fb1739fcf5363f48c7f023c50 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Tue, 8 Nov 2022 15:52:11 +0530 Subject: [PATCH 36/38] feat: define methods used for module simulation --- x/payment/module_simulation.go | 70 ++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 x/payment/module_simulation.go diff --git a/x/payment/module_simulation.go b/x/payment/module_simulation.go new file mode 100644 index 0000000000..3dbdae7768 --- /dev/null +++ b/x/payment/module_simulation.go @@ -0,0 +1,70 @@ +package payment + +import ( + "github.com/cosmos/cosmos-sdk/x/authz/codec" + "math/rand" + + paymentsimulation "github.com/celestiaorg/celestia-app/x/payment/simulation" + "github.com/celestiaorg/celestia-app/x/payment/types" + "github.com/cosmos/cosmos-sdk/baseapp" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +// avoid unused import issue +var ( + _ = paymentsimulation.FindAccount + _ = simappparams.StakePerAccount + _ = simulation.MsgEntryKind + _ = baseapp.Paramspace +) + +const ( +// this line is used by starport scaffolding # simapp/module/const +) + +// GenerateGenesisState creates a randomized GenState of the module +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + accs := make([]string, len(simState.Accounts)) + for i, acc := range simState.Accounts { + accs[i] = acc.Address.String() + } + loanGenesis := types.GenesisState{ + Params: types.DefaultParams(), + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&loanGenesis) +} + +// ProposalContents doesn't return any content functions for governance proposals +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized param changes for the simulator +func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { + paymentParams := types.DefaultParams() + return []simtypes.ParamChange{ + simulation.NewSimParamChange(types.ModuleName, string(types.KeyMinSquareSize), func(r *rand.Rand) string { + return string(codec.Amino.MustMarshalJSON(paymentParams.MinSquareSize)) + }), + simulation.NewSimParamChange(types.ModuleName, string(types.KeyMaxSquareSize), func(r *rand.Rand) string { + return string(codec.Amino.MustMarshalJSON(paymentParams.MaxSquareSize)) + }), + } +} + +// RegisterStoreDecoder registers a decoder +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + operations := make([]simtypes.WeightedOperation, 0) + + // this line is used by starport scaffolding # simapp/module/operation + + return operations +} From bb00bef70a5d988364f29138046cde5259952ba8 Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Tue, 8 Nov 2022 17:11:59 +0530 Subject: [PATCH 37/38] chore: remove unnecessary comments --- x/payment/module_simulation.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x/payment/module_simulation.go b/x/payment/module_simulation.go index 3dbdae7768..d8a7d6fc44 100644 --- a/x/payment/module_simulation.go +++ b/x/payment/module_simulation.go @@ -22,9 +22,7 @@ var ( _ = baseapp.Paramspace ) -const ( -// this line is used by starport scaffolding # simapp/module/const -) +const () // GenerateGenesisState creates a randomized GenState of the module func (AppModule) GenerateGenesisState(simState *module.SimulationState) { @@ -34,7 +32,6 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { } loanGenesis := types.GenesisState{ Params: types.DefaultParams(), - // this line is used by starport scaffolding # simapp/module/genesisState } simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&loanGenesis) } From ac6d74c69756ce5a60c6a24bc66ce3a2f633fd1e Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Wed, 9 Nov 2022 16:59:04 +0530 Subject: [PATCH 38/38] chore: gofumpted --- x/payment/module_simulation.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/x/payment/module_simulation.go b/x/payment/module_simulation.go index d8a7d6fc44..cdb8f77bed 100644 --- a/x/payment/module_simulation.go +++ b/x/payment/module_simulation.go @@ -1,7 +1,6 @@ package payment import ( - "github.com/cosmos/cosmos-sdk/x/authz/codec" "math/rand" paymentsimulation "github.com/celestiaorg/celestia-app/x/payment/simulation" @@ -11,6 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/authz/codec" "github.com/cosmos/cosmos-sdk/x/simulation" ) @@ -22,8 +22,6 @@ var ( _ = baseapp.Paramspace ) -const () - // GenerateGenesisState creates a randomized GenState of the module func (AppModule) GenerateGenesisState(simState *module.SimulationState) { accs := make([]string, len(simState.Accounts))