From 460e0e6123f98bc08977f4b0c978d9b34efc8451 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:12:28 +0530 Subject: [PATCH 01/20] adding x/authority proto files --- docs/proto/proto-docs.md | 279 +------- .../stargaze/authority/v1/authority.proto | 0 .../stargaze/authority/v1/genesis.proto | 8 + .../stargaze/authority/v1/tx.proto | 26 + x/authority/types/genesis.pb.go | 268 ++++++++ x/authority/types/tx.pb.go | 599 ++++++++++++++++++ 6 files changed, 927 insertions(+), 253 deletions(-) create mode 100644 proto/publicawesome/stargaze/authority/v1/authority.proto create mode 100644 proto/publicawesome/stargaze/authority/v1/genesis.proto create mode 100644 proto/publicawesome/stargaze/authority/v1/tx.proto create mode 100644 x/authority/types/genesis.pb.go create mode 100644 x/authority/types/tx.pb.go diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index bb766e02b..0936d9bcb 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -4,57 +4,24 @@ ## Table of Contents -- [publicawesome/stargaze/cron/v1/cron.proto](#publicawesome/stargaze/cron/v1/cron.proto) - - [Params](#publicawesome.stargaze.cron.v1.Params) +- [publicawesome/stargaze/authority/v1/authority.proto](#publicawesome/stargaze/authority/v1/authority.proto) +- [publicawesome/stargaze/authority/v1/genesis.proto](#publicawesome/stargaze/authority/v1/genesis.proto) + - [GenesisState](#publicawesome.stargaze.authority.v1.GenesisState) -- [publicawesome/stargaze/cron/v1/genesis.proto](#publicawesome/stargaze/cron/v1/genesis.proto) - - [GenesisState](#publicawesome.stargaze.cron.v1.GenesisState) +- [publicawesome/stargaze/authority/v1/tx.proto](#publicawesome/stargaze/authority/v1/tx.proto) + - [MsgExecuteProposal](#publicawesome.stargaze.authority.v1.MsgExecuteProposal) + - [MsgExecuteProposalResponse](#publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse) -- [publicawesome/stargaze/cron/v1/proposal.proto](#publicawesome/stargaze/cron/v1/proposal.proto) - - [DemotePrivilegedContractProposal](#publicawesome.stargaze.cron.v1.DemotePrivilegedContractProposal) - - [PromoteToPrivilegedContractProposal](#publicawesome.stargaze.cron.v1.PromoteToPrivilegedContractProposal) - -- [publicawesome/stargaze/cron/v1/query.proto](#publicawesome/stargaze/cron/v1/query.proto) - - [QueryListPrivilegedRequest](#publicawesome.stargaze.cron.v1.QueryListPrivilegedRequest) - - [QueryListPrivilegedResponse](#publicawesome.stargaze.cron.v1.QueryListPrivilegedResponse) - - [QueryParamsRequest](#publicawesome.stargaze.cron.v1.QueryParamsRequest) - - [QueryParamsResponse](#publicawesome.stargaze.cron.v1.QueryParamsResponse) - - - [Query](#publicawesome.stargaze.cron.v1.Query) - -- [publicawesome/stargaze/cron/v1/tx.proto](#publicawesome/stargaze/cron/v1/tx.proto) - - [MsgDemoteFromPrivilegedContract](#publicawesome.stargaze.cron.v1.MsgDemoteFromPrivilegedContract) - - [MsgDemoteFromPrivilegedContractResponse](#publicawesome.stargaze.cron.v1.MsgDemoteFromPrivilegedContractResponse) - - [MsgPromoteToPrivilegedContract](#publicawesome.stargaze.cron.v1.MsgPromoteToPrivilegedContract) - - [MsgPromoteToPrivilegedContractResponse](#publicawesome.stargaze.cron.v1.MsgPromoteToPrivilegedContractResponse) - - [MsgUpdateParams](#publicawesome.stargaze.cron.v1.MsgUpdateParams) - - [MsgUpdateParamsResponse](#publicawesome.stargaze.cron.v1.MsgUpdateParamsResponse) - - - [Msg](#publicawesome.stargaze.cron.v1.Msg) + - [Msg](#publicawesome.stargaze.authority.v1.Msg) - [Scalar Value Types](#scalar-value-types) - +

Top

-## publicawesome/stargaze/cron/v1/cron.proto - - - - - -### Params -Params holds parameters for the cron module. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `admin_addresses` | [string](#string) | repeated | Addresses which act as admins of the module. They can promote and demote contracts without having to go via governance. | - - - +## publicawesome/stargaze/authority/v1/authority.proto @@ -67,252 +34,60 @@ Params holds parameters for the cron module. - +

Top

-## publicawesome/stargaze/cron/v1/genesis.proto +## publicawesome/stargaze/authority/v1/genesis.proto - + ### GenesisState -GenesisState defines the cron module's genesis state. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `privileged_contract_addresses` | [string](#string) | repeated | List of all the contracts that have been given the privilege status via governance. They can set up hooks to abci.EndBlocker | -| `params` | [Params](#publicawesome.stargaze.cron.v1.Params) | | Module params | - - - - - - - - - - - - - - - - -

Top

- -## publicawesome/stargaze/cron/v1/proposal.proto - - - - - -### DemotePrivilegedContractProposal -Deprecated: Do not use. To demote a contract, a -MsgDemoteFromPrivilegedContract can be invoked from the x/gov module via a v1 -governance proposal - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | Title is a short summary | -| `description` | [string](#string) | | Description is a human readable text | -| `contract` | [string](#string) | | Contract is the bech32 address of the smart contract | - - - - - - - - -### PromoteToPrivilegedContractProposal -Deprecated: Do not use. To promote a contract, a -MsgPromoteToPrivilegedContract can be invoked from the x/gov module via a v1 -governance proposal - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | Title is a short summary | -| `description` | [string](#string) | | Description is a human readable text | -| `contract` | [string](#string) | | Contract is the bech32 address of the smart contract | - - - - - - - - - - - - - - - - -

Top

- -## publicawesome/stargaze/cron/v1/query.proto - - - - - -### QueryListPrivilegedRequest -QueryListPrivilegedRequest is request type for the Query/ListPrivileged RPC -method. - - -### QueryListPrivilegedResponse -QueryListPrivilegedResponse is response type for the Query/ListPrivileged RPC -method. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `contract_addresses` | [string](#string) | repeated | contract_addresses holds all the smart contract addresses which have privilege status. | - - - - - - - - -### QueryParamsRequest -QueryParamsRequest is request type for the Query/Params RPC -method. - - - - - - - - -### QueryParamsResponse -QueryParamsResponse is response type for the Query/Params RPC -method. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `params` | [Params](#publicawesome.stargaze.cron.v1.Params) | | | - - - - - - - - -### Query -Query defines the gRPC querier service. - -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `ListPrivileged` | [QueryListPrivilegedRequest](#publicawesome.stargaze.cron.v1.QueryListPrivilegedRequest) | [QueryListPrivilegedResponse](#publicawesome.stargaze.cron.v1.QueryListPrivilegedResponse) | ListPrivileged queries the contracts which have the priviledge status | GET|/stargaze/cron/v1/list-privileged| -| `Params` | [QueryParamsRequest](#publicawesome.stargaze.cron.v1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.cron.v1.QueryParamsResponse) | | GET|/stargaze/cron/v1/params| - - +

Top

-## publicawesome/stargaze/cron/v1/tx.proto - - - - - -### MsgDemoteFromPrivilegedContract +## publicawesome/stargaze/authority/v1/tx.proto -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `authority` | [string](#string) | | Authority is the address of the governance account or any whitelisted address | -| `contract` | [string](#string) | | Contract is the bech32 address of the smart contract | - - - - - - - - -### MsgDemoteFromPrivilegedContractResponse - - - - - - - - - -### MsgPromoteToPrivilegedContract - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `authority` | [string](#string) | | Authority is the address of the governance account or any whitelisted address | -| `contract` | [string](#string) | | Contract is the bech32 address of the smart contract | - - - - - - - - -### MsgPromoteToPrivilegedContractResponse - - - - - - - - - -### MsgUpdateParams + +### MsgExecuteProposal +MsgExecuteProposal defines an sdk.Msg type that supports submitting arbitrary +proposal Content. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `authority` | [string](#string) | | Authority is the address of the governance account. | -| `params` | [Params](#publicawesome.stargaze.cron.v1.Params) | | NOTE: All parameters must be supplied. | - +| `authority` | [string](#string) | | | +| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | - -### MsgUpdateParamsResponse + +### MsgExecuteProposalResponse +MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. @@ -325,16 +100,14 @@ Query defines the gRPC querier service. - + ### Msg -Msg defines the alloc Msg service. +Msg defines the authority Msg service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `PromoteToPrivilegedContract` | [MsgPromoteToPrivilegedContract](#publicawesome.stargaze.cron.v1.MsgPromoteToPrivilegedContract) | [MsgPromoteToPrivilegedContractResponse](#publicawesome.stargaze.cron.v1.MsgPromoteToPrivilegedContractResponse) | | | -| `DemoteFromPrivilegedContract` | [MsgDemoteFromPrivilegedContract](#publicawesome.stargaze.cron.v1.MsgDemoteFromPrivilegedContract) | [MsgDemoteFromPrivilegedContractResponse](#publicawesome.stargaze.cron.v1.MsgDemoteFromPrivilegedContractResponse) | | | -| `UpdateParams` | [MsgUpdateParams](#publicawesome.stargaze.cron.v1.MsgUpdateParams) | [MsgUpdateParamsResponse](#publicawesome.stargaze.cron.v1.MsgUpdateParamsResponse) | | | +| `ExecuteProposal` | [MsgExecuteProposal](#publicawesome.stargaze.authority.v1.MsgExecuteProposal) | [MsgExecuteProposalResponse](#publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse) | | | diff --git a/proto/publicawesome/stargaze/authority/v1/authority.proto b/proto/publicawesome/stargaze/authority/v1/authority.proto new file mode 100644 index 000000000..e69de29bb diff --git a/proto/publicawesome/stargaze/authority/v1/genesis.proto b/proto/publicawesome/stargaze/authority/v1/genesis.proto new file mode 100644 index 000000000..336d3dcfb --- /dev/null +++ b/proto/publicawesome/stargaze/authority/v1/genesis.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +package publicawesome.stargaze.authority.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/public-awesome/stargaze/v13/x/authority/types"; + +message GenesisState {} \ No newline at end of file diff --git a/proto/publicawesome/stargaze/authority/v1/tx.proto b/proto/publicawesome/stargaze/authority/v1/tx.proto new file mode 100644 index 000000000..3d6dcaae9 --- /dev/null +++ b/proto/publicawesome/stargaze/authority/v1/tx.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package publicawesome.stargaze.authority.v1; + +import "gogoproto/gogo.proto"; +import "cosmos/msg/v1/msg.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/public-awesome/stargaze/v13/x/authority/types"; + +// Msg defines the authority Msg service. +service Msg { + rpc ExecuteProposal(MsgExecuteProposal) + returns (MsgExecuteProposalResponse); + } + +// MsgExecuteProposal defines an sdk.Msg type that supports submitting arbitrary +// proposal Content. +message MsgExecuteProposal { + option (cosmos.msg.v1.signer) = "authority"; + + string authority = 1; + repeated google.protobuf.Any messages = 2; + } + + // MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. + message MsgExecuteProposalResponse { } \ No newline at end of file diff --git a/x/authority/types/genesis.pb.go b/x/authority/types/genesis.pb.go new file mode 100644 index 000000000..023a19892 --- /dev/null +++ b/x/authority/types/genesis.pb.go @@ -0,0 +1,268 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: publicawesome/stargaze/authority/v1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type GenesisState struct { +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_f6ae0642d48c5a1e, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func init() { + proto.RegisterType((*GenesisState)(nil), "publicawesome.stargaze.authority.v1.GenesisState") +} + +func init() { + proto.RegisterFile("publicawesome/stargaze/authority/v1/genesis.proto", fileDescriptor_f6ae0642d48c5a1e) +} + +var fileDescriptor_f6ae0642d48c5a1e = []byte{ + // 177 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x2c, 0x28, 0x4d, 0xca, + 0xc9, 0x4c, 0x4e, 0x2c, 0x4f, 0x2d, 0xce, 0xcf, 0x4d, 0xd5, 0x2f, 0x2e, 0x49, 0x2c, 0x4a, 0x4f, + 0xac, 0x4a, 0xd5, 0x4f, 0x2c, 0x2d, 0xc9, 0xc8, 0x2f, 0xca, 0x2c, 0xa9, 0xd4, 0x2f, 0x33, 0xd4, + 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x46, + 0xd1, 0xa2, 0x07, 0xd3, 0xa2, 0x07, 0xd7, 0xa2, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, 0x9e, + 0x0f, 0x56, 0xaf, 0x0f, 0x62, 0x41, 0xb4, 0x2a, 0xf1, 0x71, 0xf1, 0xb8, 0x43, 0xcc, 0x0a, 0x2e, + 0x49, 0x2c, 0x49, 0x75, 0x0a, 0x3a, 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, + 0x8b, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x88, 0x7d, 0xba, 0x18, + 0x6e, 0x2c, 0x33, 0x34, 0xd6, 0xaf, 0x40, 0x72, 0x69, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, + 0xd8, 0x2a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x33, 0x62, 0xe5, 0xae, 0xda, 0x00, 0x00, + 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/authority/types/tx.pb.go b/x/authority/types/tx.pb.go new file mode 100644 index 000000000..2e554415a --- /dev/null +++ b/x/authority/types/tx.pb.go @@ -0,0 +1,599 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: publicawesome/stargaze/authority/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgExecuteProposal defines an sdk.Msg type that supports submitting arbitrary +// proposal Content. +type MsgExecuteProposal struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Messages []*types.Any `protobuf:"bytes,2,rep,name=messages,proto3" json:"messages,omitempty"` +} + +func (m *MsgExecuteProposal) Reset() { *m = MsgExecuteProposal{} } +func (m *MsgExecuteProposal) String() string { return proto.CompactTextString(m) } +func (*MsgExecuteProposal) ProtoMessage() {} +func (*MsgExecuteProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_a59b6a5ac2f6d30b, []int{0} +} +func (m *MsgExecuteProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExecuteProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExecuteProposal.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 *MsgExecuteProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExecuteProposal.Merge(m, src) +} +func (m *MsgExecuteProposal) XXX_Size() int { + return m.Size() +} +func (m *MsgExecuteProposal) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExecuteProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExecuteProposal proto.InternalMessageInfo + +func (m *MsgExecuteProposal) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgExecuteProposal) GetMessages() []*types.Any { + if m != nil { + return m.Messages + } + return nil +} + +// MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. +type MsgExecuteProposalResponse struct { +} + +func (m *MsgExecuteProposalResponse) Reset() { *m = MsgExecuteProposalResponse{} } +func (m *MsgExecuteProposalResponse) String() string { return proto.CompactTextString(m) } +func (*MsgExecuteProposalResponse) ProtoMessage() {} +func (*MsgExecuteProposalResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a59b6a5ac2f6d30b, []int{1} +} +func (m *MsgExecuteProposalResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExecuteProposalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExecuteProposalResponse.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 *MsgExecuteProposalResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExecuteProposalResponse.Merge(m, src) +} +func (m *MsgExecuteProposalResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgExecuteProposalResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExecuteProposalResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExecuteProposalResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgExecuteProposal)(nil), "publicawesome.stargaze.authority.v1.MsgExecuteProposal") + proto.RegisterType((*MsgExecuteProposalResponse)(nil), "publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse") +} + +func init() { + proto.RegisterFile("publicawesome/stargaze/authority/v1/tx.proto", fileDescriptor_a59b6a5ac2f6d30b) +} + +var fileDescriptor_a59b6a5ac2f6d30b = []byte{ + // 321 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x29, 0x28, 0x4d, 0xca, + 0xc9, 0x4c, 0x4e, 0x2c, 0x4f, 0x2d, 0xce, 0xcf, 0x4d, 0xd5, 0x2f, 0x2e, 0x49, 0x2c, 0x4a, 0x4f, + 0xac, 0x4a, 0xd5, 0x4f, 0x2c, 0x2d, 0xc9, 0xc8, 0x2f, 0xca, 0x2c, 0xa9, 0xd4, 0x2f, 0x33, 0xd4, + 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x46, 0x51, 0xad, 0x07, 0x53, 0xad, + 0x07, 0x57, 0xad, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xaf, 0x0f, 0x62, + 0x41, 0xb4, 0x4a, 0x89, 0x27, 0xe7, 0x17, 0xe7, 0xe6, 0x17, 0xeb, 0xe7, 0x16, 0xa7, 0x83, 0x8c, + 0xcc, 0x2d, 0x4e, 0x87, 0x4a, 0x48, 0xa6, 0xe7, 0xe7, 0xa7, 0xe7, 0xa4, 0xea, 0x83, 0x79, 0x49, + 0xa5, 0x69, 0xfa, 0x89, 0x79, 0x95, 0x10, 0x29, 0xa5, 0x12, 0x2e, 0x21, 0xdf, 0xe2, 0x74, 0xd7, + 0x8a, 0xd4, 0xe4, 0xd2, 0x92, 0xd4, 0x80, 0xa2, 0xfc, 0x82, 0xfc, 0xe2, 0xc4, 0x1c, 0x21, 0x19, + 0x2e, 0x4e, 0xb8, 0x7d, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x08, 0x01, 0x21, 0x03, 0x2e, + 0x8e, 0xdc, 0xd4, 0xe2, 0xe2, 0xc4, 0xf4, 0xd4, 0x62, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, + 0x11, 0x3d, 0x88, 0x0d, 0x7a, 0x30, 0x1b, 0xf4, 0x1c, 0xf3, 0x2a, 0x83, 0xe0, 0xaa, 0xac, 0xf8, + 0x9a, 0x9e, 0x6f, 0xd0, 0x42, 0x98, 0xa0, 0x24, 0xc3, 0x25, 0x85, 0x69, 0x6b, 0x50, 0x6a, 0x71, + 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0xd1, 0x64, 0x46, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x6e, 0x46, + 0x2e, 0x7e, 0x74, 0x97, 0x99, 0xeb, 0x11, 0x11, 0x3e, 0x7a, 0x98, 0x86, 0x4b, 0xd9, 0x93, 0xa9, + 0x11, 0xe6, 0x2a, 0xa7, 0xa0, 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, 0xb2, + 0x48, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x58, 0xa2, 0x8b, 0x11, + 0xd9, 0x65, 0x86, 0xc6, 0xfa, 0x15, 0x48, 0x51, 0x5e, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, + 0x0e, 0x2f, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf6, 0x1d, 0x1b, 0x44, 0x23, 0x02, 0x00, + 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + ExecuteProposal(ctx context.Context, in *MsgExecuteProposal, opts ...grpc.CallOption) (*MsgExecuteProposalResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) ExecuteProposal(ctx context.Context, in *MsgExecuteProposal, opts ...grpc.CallOption) (*MsgExecuteProposalResponse, error) { + out := new(MsgExecuteProposalResponse) + err := c.cc.Invoke(ctx, "/publicawesome.stargaze.authority.v1.Msg/ExecuteProposal", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + ExecuteProposal(context.Context, *MsgExecuteProposal) (*MsgExecuteProposalResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) ExecuteProposal(ctx context.Context, req *MsgExecuteProposal) (*MsgExecuteProposalResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExecuteProposal not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_ExecuteProposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgExecuteProposal) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ExecuteProposal(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/publicawesome.stargaze.authority.v1.Msg/ExecuteProposal", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ExecuteProposal(ctx, req.(*MsgExecuteProposal)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "publicawesome.stargaze.authority.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ExecuteProposal", + Handler: _Msg_ExecuteProposal_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "publicawesome/stargaze/authority/v1/tx.proto", +} + +func (m *MsgExecuteProposal) 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 *MsgExecuteProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecuteProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Messages) > 0 { + for iNdEx := len(m.Messages) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Messages[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgExecuteProposalResponse) 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 *MsgExecuteProposalResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecuteProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgExecuteProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Messages) > 0 { + for _, e := range m.Messages { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgExecuteProposalResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgExecuteProposal) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgExecuteProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecuteProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Messages", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Messages = append(m.Messages, &types.Any{}) + if err := m.Messages[len(m.Messages)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgExecuteProposalResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgExecuteProposalResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecuteProposalResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) From 155d57fbf06e1fb2dda0c0149f2ca732a2fff719 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Thu, 19 Oct 2023 13:14:29 +0530 Subject: [PATCH 02/20] adding basic authority features --- app/app.go | 25 +- docs/proto/proto-docs.md | 468 +++++++++++++++++++++++++++++-- x/authority/abci.go | 78 ++++++ x/authority/client/cli/tx.go | 93 ++++++ x/authority/genesis.go | 17 ++ x/authority/keeper/keeper.go | 57 ++++ x/authority/keeper/msg_server.go | 55 ++++ x/authority/keeper/proposal.go | 147 ++++++++++ x/authority/module.go | 148 ++++++++++ x/authority/types/codec.go | 35 +++ x/authority/types/genesis.go | 11 + x/authority/types/keys.go | 15 + x/authority/types/msgs.go | 100 +++++++ x/authority/types/types.go | 1 + 14 files changed, 1222 insertions(+), 28 deletions(-) create mode 100644 x/authority/abci.go create mode 100644 x/authority/client/cli/tx.go create mode 100644 x/authority/genesis.go create mode 100644 x/authority/keeper/keeper.go create mode 100644 x/authority/keeper/msg_server.go create mode 100644 x/authority/keeper/proposal.go create mode 100644 x/authority/module.go create mode 100644 x/authority/types/codec.go create mode 100644 x/authority/types/genesis.go create mode 100644 x/authority/types/keys.go create mode 100644 x/authority/types/msgs.go create mode 100644 x/authority/types/types.go diff --git a/app/app.go b/app/app.go index 7d3fc9be8..061bbadf1 100644 --- a/app/app.go +++ b/app/app.go @@ -118,6 +118,10 @@ import ( allocmoduletypes "github.com/public-awesome/stargaze/v13/x/alloc/types" allocwasm "github.com/public-awesome/stargaze/v13/x/alloc/wasm" + authoritymodule "github.com/public-awesome/stargaze/v13/x/authority" + authoritykeeper "github.com/public-awesome/stargaze/v13/x/authority/keeper" + authoritytypes "github.com/public-awesome/stargaze/v13/x/authority/types" + cronmodule "github.com/public-awesome/stargaze/v13/x/cron" cronmodulekeeper "github.com/public-awesome/stargaze/v13/x/cron/keeper" cronmoduletypes "github.com/public-awesome/stargaze/v13/x/cron/types" @@ -207,6 +211,7 @@ var ( transfer.AppModuleBasic{}, vesting.AppModuleBasic{}, allocmodule.AppModuleBasic{}, + authoritymodule.AppModuleBasic{}, cronmodule.AppModuleBasic{}, globalfeemodule.AppModuleBasic{}, tokenfactory.AppModuleBasic{}, @@ -228,6 +233,7 @@ var ( allocmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, allocmoduletypes.FairburnPoolName: nil, allocmoduletypes.SupplementPoolName: nil, + authoritytypes.ModuleName: {authtypes.Burner}, wasmtypes.ModuleName: {authtypes.Burner}, icatypes.ModuleName: nil, cronmoduletypes.ModuleName: nil, @@ -299,6 +305,7 @@ type App struct { // stargaze modules AllocKeeper allocmodulekeeper.Keeper + AuthorityKeeper authoritykeeper.Keeper CronKeeper cronmodulekeeper.Keeper GlobalFeeKeeper globalfeemodulekeeper.Keeper IBCHooksKeeper ibchookskeeper.Keeper @@ -346,6 +353,7 @@ func NewStargazeApp( govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, allocmoduletypes.StoreKey, + authoritytypes.StoreKey, authzkeeper.StoreKey, wasmtypes.StoreKey, cronmoduletypes.StoreKey, @@ -427,7 +435,7 @@ func NewStargazeApp( app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), + authtypes.NewModuleAddress(authoritytypes.ModuleName).String(), ) app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, @@ -583,6 +591,14 @@ func NewStargazeApp( ) // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper + app.AuthorityKeeper = authoritykeeper.NewKeeper( + appCodec, + keys[authoritytypes.StoreKey], + app.GetSubspace(authoritytypes.ModuleName), + bApp.MsgServiceRouter(), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + authoritymodule := authoritymodule.NewAppModule(appCodec, app.AuthorityKeeper) // wasm configuration @@ -621,7 +637,7 @@ func NewStargazeApp( wasmDir, wasmConfig, GetWasmCapabilities(), - authtypes.NewModuleAddress(govtypes.ModuleName).String(), + authtypes.NewModuleAddress(authoritytypes.ModuleName).String(), wasmOpts..., ) @@ -716,6 +732,7 @@ func NewStargazeApp( params.NewAppModule(app.ParamsKeeper), transfer.NewAppModule(app.TransferKeeper), allocModule, + authoritymodule, wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)), cronModule, globalfeeModule, @@ -743,6 +760,7 @@ func NewStargazeApp( group.ModuleName, authz.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, vestingtypes.ModuleName, consensusparamtypes.ModuleName, + authoritytypes.ModuleName, wasmtypes.ModuleName, cronmoduletypes.ModuleName, globalfeemoduletypes.ModuleName, @@ -762,6 +780,7 @@ func NewStargazeApp( ibcexported.ModuleName, ibctransfertypes.ModuleName, icatypes.ModuleName, allocmoduletypes.ModuleName, + authoritytypes.ModuleName, wasmtypes.ModuleName, cronmoduletypes.ModuleName, globalfeemoduletypes.ModuleName, @@ -795,6 +814,7 @@ func NewStargazeApp( authz.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, consensusparamtypes.ModuleName, + authoritytypes.ModuleName, allocmoduletypes.ModuleName, tokenfactorytypes.ModuleName, // wasm after ibc transfer @@ -1056,6 +1076,7 @@ func initParamsKeeper( paramsKeeper.Subspace(cronmoduletypes.ModuleName) paramsKeeper.Subspace(icahosttypes.SubModuleName) paramsKeeper.Subspace(globalfeemoduletypes.ModuleName) + paramsKeeper.Subspace(authoritytypes.ModuleName) paramsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable()) // this line is used by starport scaffolding # stargate/app/paramSubspace diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 0936d9bcb..15ffa2c82 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -4,24 +4,102 @@ ## Table of Contents -- [publicawesome/stargaze/authority/v1/authority.proto](#publicawesome/stargaze/authority/v1/authority.proto) -- [publicawesome/stargaze/authority/v1/genesis.proto](#publicawesome/stargaze/authority/v1/genesis.proto) - - [GenesisState](#publicawesome.stargaze.authority.v1.GenesisState) +- [publicawesome/stargaze/globalfee/v1/globalfee.proto](#publicawesome/stargaze/globalfee/v1/globalfee.proto) + - [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) + - [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) + - [Params](#publicawesome.stargaze.globalfee.v1.Params) -- [publicawesome/stargaze/authority/v1/tx.proto](#publicawesome/stargaze/authority/v1/tx.proto) - - [MsgExecuteProposal](#publicawesome.stargaze.authority.v1.MsgExecuteProposal) - - [MsgExecuteProposalResponse](#publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse) +- [publicawesome/stargaze/globalfee/v1/genesis.proto](#publicawesome/stargaze/globalfee/v1/genesis.proto) + - [GenesisState](#publicawesome.stargaze.globalfee.v1.GenesisState) - - [Msg](#publicawesome.stargaze.authority.v1.Msg) +- [publicawesome/stargaze/globalfee/v1/proposal.proto](#publicawesome/stargaze/globalfee/v1/proposal.proto) + - [RemoveCodeAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.RemoveCodeAuthorizationProposal) + - [RemoveContractAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.RemoveContractAuthorizationProposal) + - [SetCodeAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.SetCodeAuthorizationProposal) + - [SetContractAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.SetContractAuthorizationProposal) + +- [publicawesome/stargaze/globalfee/v1/query.proto](#publicawesome/stargaze/globalfee/v1/query.proto) + - [QueryAuthorizationsRequest](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsRequest) + - [QueryAuthorizationsResponse](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsResponse) + - [QueryCodeAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationRequest) + - [QueryCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationResponse) + - [QueryContractAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationRequest) + - [QueryContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationResponse) + - [QueryParamsRequest](#publicawesome.stargaze.globalfee.v1.QueryParamsRequest) + - [QueryParamsResponse](#publicawesome.stargaze.globalfee.v1.QueryParamsResponse) + + - [Query](#publicawesome.stargaze.globalfee.v1.Query) + +- [publicawesome/stargaze/globalfee/v1/tx.proto](#publicawesome/stargaze/globalfee/v1/tx.proto) + - [MsgRemoveCodeAuthorization](#publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorization) + - [MsgRemoveCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorizationResponse) + - [MsgRemoveContractAuthorization](#publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorization) + - [MsgRemoveContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorizationResponse) + - [MsgSetCodeAuthorization](#publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorization) + - [MsgSetCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorizationResponse) + - [MsgSetContractAuthorization](#publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorization) + - [MsgSetContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorizationResponse) + - [MsgUpdateParams](#publicawesome.stargaze.globalfee.v1.MsgUpdateParams) + - [MsgUpdateParamsResponse](#publicawesome.stargaze.globalfee.v1.MsgUpdateParamsResponse) + + - [Msg](#publicawesome.stargaze.globalfee.v1.Msg) - [Scalar Value Types](#scalar-value-types) - +

Top

-## publicawesome/stargaze/authority/v1/authority.proto +## publicawesome/stargaze/globalfee/v1/globalfee.proto + + + + + +### CodeAuthorization +Configuration for code Ids which can have zero gas operations + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `code_id` | [uint64](#uint64) | | authorized code ids | +| `methods` | [string](#string) | repeated | authorized contract operation methods | + + + + + + + + +### ContractAuthorization +Configuration for contract addresses which can have zero gas operations + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `contract_address` | [string](#string) | | authorized contract addresses | +| `methods` | [string](#string) | repeated | authorized contract operation methods | + + + + + + + + +### Params +Params holds parameters for the globalfee module. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `privileged_addresses` | [string](#string) | repeated | Addresses which are whitelisted to modify the gas free operations | +| `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | Minimum stores the minimum gas price(s) for all TX on the chain. | + + + @@ -34,18 +112,236 @@ - +

Top

-## publicawesome/stargaze/authority/v1/genesis.proto +## publicawesome/stargaze/globalfee/v1/genesis.proto - + ### GenesisState +GenesisState defines the globalfee module's genesis state. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#publicawesome.stargaze.globalfee.v1.Params) | | Module params | +| `code_authorizations` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | repeated | Authorizations configured by code id | +| `contract_authorizations` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | repeated | Authorizations configured by contract addresses | + + + + + + + + + + + + + + + + +

Top

+ +## publicawesome/stargaze/globalfee/v1/proposal.proto + + + + + +### RemoveCodeAuthorizationProposal + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | +| `code_id` | [uint64](#uint64) | | | + + + + + + + + +### RemoveContractAuthorizationProposal + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | +| `contract_address` | [string](#string) | | | + + + + + + + + +### SetCodeAuthorizationProposal + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | +| `code_authorization` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | | | + + + + + + + + +### SetContractAuthorizationProposal + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | +| `contract_authorization` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | | | + + + + + + + + + + + + + + + + +

Top

+ +## publicawesome/stargaze/globalfee/v1/query.proto + + + + + +### QueryAuthorizationsRequest + + + + + + + + + +### QueryAuthorizationsResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `code_authorizations` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | repeated | | +| `contract_authorizations` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | repeated | | + + + + + + + + +### QueryCodeAuthorizationRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `code_id` | [uint64](#uint64) | | | + + + + + + + + +### QueryCodeAuthorizationResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `methods` | [string](#string) | repeated | | + + + + + + +### QueryContractAuthorizationRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `contract_address` | [string](#string) | | | + + + + + + + + +### QueryContractAuthorizationResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `methods` | [string](#string) | repeated | | + + + + + + + + +### QueryParamsRequest + + + + + + + + + +### QueryParamsResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#publicawesome.stargaze.globalfee.v1.Params) | | | + @@ -56,38 +352,154 @@ + + + +### Query +Query defines the gRPC querier service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `CodeAuthorization` | [QueryCodeAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationRequest) | [QueryCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationResponse) | | GET|/stargaze/globalfee/v1/code_authorization/{code_id}| +| `ContractAuthorization` | [QueryContractAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationRequest) | [QueryContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationResponse) | | GET|/stargaze/globalfee/v1/contract_authorization/{contract_address}| +| `Params` | [QueryParamsRequest](#publicawesome.stargaze.globalfee.v1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.globalfee.v1.QueryParamsResponse) | | GET|/stargaze/globalfee/v1/params| +| `Authorizations` | [QueryAuthorizationsRequest](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsRequest) | [QueryAuthorizationsResponse](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsResponse) | | GET|/stargaze/globalfee/v1/authorizations| + - +

Top

-## publicawesome/stargaze/authority/v1/tx.proto +## publicawesome/stargaze/globalfee/v1/tx.proto + + + + + +### MsgRemoveCodeAuthorization + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `code_id` | [uint64](#uint64) | | | + + + + + + + + +### MsgRemoveCodeAuthorizationResponse + + + - -### MsgExecuteProposal -MsgExecuteProposal defines an sdk.Msg type that supports submitting arbitrary -proposal Content. + + +### MsgRemoveContractAuthorization + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `authority` | [string](#string) | | | -| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | +| `sender` | [string](#string) | | | +| `contract_address` | [string](#string) | | | + + + + + + + + +### MsgRemoveContractAuthorizationResponse + + + + + + + + + +### MsgSetCodeAuthorization + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `code_authorization` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | | | + + + + + + + + +### MsgSetCodeAuthorizationResponse + + + + + + + + + +### MsgSetContractAuthorization + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `contract_authorization` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | | | + + + + + + + + +### MsgSetContractAuthorizationResponse + + + + + + + + + +### MsgUpdateParams + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `params` | [Params](#publicawesome.stargaze.globalfee.v1.Params) | | NOTE: All parameters must be supplied. | + + - +### MsgUpdateParamsResponse -### MsgExecuteProposalResponse -MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. @@ -100,14 +512,18 @@ MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. - + ### Msg -Msg defines the authority Msg service. +Msg defines the alloc Msg service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `ExecuteProposal` | [MsgExecuteProposal](#publicawesome.stargaze.authority.v1.MsgExecuteProposal) | [MsgExecuteProposalResponse](#publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse) | | | +| `SetCodeAuthorization` | [MsgSetCodeAuthorization](#publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorization) | [MsgSetCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorizationResponse) | | | +| `RemoveCodeAuthorization` | [MsgRemoveCodeAuthorization](#publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorization) | [MsgRemoveCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorizationResponse) | | | +| `SetContractAuthorization` | [MsgSetContractAuthorization](#publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorization) | [MsgSetContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorizationResponse) | | | +| `RemoveContractAuthorization` | [MsgRemoveContractAuthorization](#publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorization) | [MsgRemoveContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorizationResponse) | | | +| `UpdateParams` | [MsgUpdateParams](#publicawesome.stargaze.globalfee.v1.MsgUpdateParams) | [MsgUpdateParamsResponse](#publicawesome.stargaze.globalfee.v1.MsgUpdateParamsResponse) | | | diff --git a/x/authority/abci.go b/x/authority/abci.go new file mode 100644 index 000000000..2e9a87156 --- /dev/null +++ b/x/authority/abci.go @@ -0,0 +1,78 @@ +package authority + +import ( + "fmt" + "time" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govV1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "github.com/public-awesome/stargaze/v13/x/authority/keeper" + "github.com/public-awesome/stargaze/v13/x/authority/types" +) + +// EndBlocker called every block, process inflation, update validator set. +func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) + logger := keeper.Logger(ctx) + + keeper.IterateActiveProposalsQueue(ctx, func(proposal govV1.Proposal) bool { + var logMsg, tagValue string + + var ( + idx int + events sdk.Events + msg sdk.Msg + ) + + cacheCtx, writeCache := ctx.CacheContext() + messages, err := proposal.GetMsgs() + if err == nil { + for idx, msg = range messages { + handler := keeper.Router().Handler(msg) + + var res *sdk.Result + res, err = handler(cacheCtx, msg) + if err != nil { + break + } + + events = append(events, res.GetEvents()...) + } + } + + if err == nil { + proposal.Status = govV1.StatusPassed + tagValue = govtypes.AttributeValueProposalPassed + logMsg = "passed" + + // write state to the underlying multi-store + writeCache() + + // propagate the msg events to the current context + ctx.EventManager().EmitEvents(events) + } else { + proposal.Status = govV1.StatusFailed + tagValue = govtypes.AttributeValueProposalFailed + logMsg = fmt.Sprintf("passed, but msg %d (%s) failed on execution: %s", idx, sdk.MsgTypeURL(msg), err) + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + govtypes.EventTypeActiveProposal, + sdk.NewAttribute(govtypes.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.Id)), + sdk.NewAttribute(govtypes.AttributeKeyProposalResult, tagValue), + ), + ) + + logger.Info( + "proposal tallied", + "proposal", proposal.Id, + "title", proposal.GetTitle(), + "result", logMsg, + ) + + return false + }) +} diff --git a/x/authority/client/cli/tx.go b/x/authority/client/cli/tx.go new file mode 100644 index 000000000..4a483d65d --- /dev/null +++ b/x/authority/client/cli/tx.go @@ -0,0 +1,93 @@ +package cli + +import ( + "encoding/json" + "fmt" + "os" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/public-awesome/stargaze/v13/x/authority/types" + "github.com/spf13/cobra" +) + +// GetTxCmd builds tx command group for the module. +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdSubmitProposal()) + return cmd +} + +func CmdSubmitProposal() *cobra.Command { + cmd := &cobra.Command{ + Use: "submit-proposal [path/to/proposal.json]", + Short: "Submit a proposal along with some messages", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msgs, err := parseSubmitProposal(clientCtx.Codec, args[0]) + if err != nil { + return err + } + + msg, err := types.NewMsgExecuteProposal(msgs, clientCtx.GetFromAddress().String()) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// proposal defines the new Msg-based proposal. +type proposal struct { + // Msgs defines an array of sdk.Msgs proto-JSON-encoded as Anys. + Messages []json.RawMessage `json:"messages,omitempty"` +} + +// parseSubmitProposal reads and parses the proposal. +func parseSubmitProposal(cdc codec.Codec, path string) ([]sdk.Msg, error) { + var proposal proposal + + contents, err := os.ReadFile(path) + if err != nil { + return nil, err + } + + err = json.Unmarshal(contents, &proposal) + if err != nil { + return nil, err + } + + msgs := make([]sdk.Msg, len(proposal.Messages)) + for i, anyJSON := range proposal.Messages { + var msg sdk.Msg + err := cdc.UnmarshalInterfaceJSON(anyJSON, &msg) + if err != nil { + return nil, err + } + + msgs[i] = msg + } + + return msgs, nil +} diff --git a/x/authority/genesis.go b/x/authority/genesis.go new file mode 100644 index 000000000..4e4030112 --- /dev/null +++ b/x/authority/genesis.go @@ -0,0 +1,17 @@ +package authority + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/public-awesome/stargaze/v13/x/authority/keeper" + "github.com/public-awesome/stargaze/v13/x/authority/types" +) + +// InitGenesis initializes the capability module's state from a provided genesis +// state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { +} + +// ExportGenesis returns the capability module's exported genesis. +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + return &types.GenesisState{} +} diff --git a/x/authority/keeper/keeper.go b/x/authority/keeper/keeper.go new file mode 100644 index 000000000..a013350db --- /dev/null +++ b/x/authority/keeper/keeper.go @@ -0,0 +1,57 @@ +package keeper + +import ( + "fmt" + + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/baseapp" + "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" + "github.com/public-awesome/stargaze/v13/x/authority/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + paramstore paramtypes.Subspace + router *baseapp.MsgServiceRouter + authority string // this should be the x/gov module account + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey storetypes.StoreKey, + ps paramtypes.Subspace, + router *baseapp.MsgServiceRouter, + authority string, +) Keeper { + return Keeper{ + cdc: cdc, + storeKey: storeKey, + paramstore: ps, + router: router, + authority: authority, + } +} + +// GetAuthority returns the x/wasm module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} + +// Router returns the adminmodule Keeper's Router +func (k Keeper) Router() *baseapp.MsgServiceRouter { + return k.router +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ModuleLogger(ctx) +} + +func ModuleLogger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/authority/keeper/msg_server.go b/x/authority/keeper/msg_server.go new file mode 100644 index 000000000..b691bc273 --- /dev/null +++ b/x/authority/keeper/msg_server.go @@ -0,0 +1,55 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/public-awesome/stargaze/v13/x/authority/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +// ExecuteProposal implements types.MsgServer. +func (m msgServer) ExecuteProposal(goCtx context.Context, msg *types.MsgExecuteProposal) (*types.MsgExecuteProposalResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + proposalMsgs, err := msg.GetMsgs() + if err != nil { + return nil, err + } + + proposer, err := sdk.AccAddressFromBech32(msg.GetAuthority()) + if err != nil { + return nil, err + } + + IsAuthorized(ctx, proposalMsgs) + + _, err = m.Keeper.SubmitProposal(ctx, proposalMsgs, proposer) + if err != nil { + return nil, err + } + + return &types.MsgExecuteProposalResponse{}, nil +} + +func IsAuthorized(ctx sdk.Context, msgs []sdk.Msg) bool { + // loop through msgs + for _, msg := range msgs { + test := sdk.MsgTypeURL(msg) + panic(test) + } + return false +} + +// /cosmos.distribution.v1beta1.MsgCommunityPoolSpend diff --git a/x/authority/keeper/proposal.go b/x/authority/keeper/proposal.go new file mode 100644 index 000000000..2a91b1e9f --- /dev/null +++ b/x/authority/keeper/proposal.go @@ -0,0 +1,147 @@ +package keeper + +import ( + "fmt" + + errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/gov/types" + govV1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" +) + +// IterateActiveProposalsQueue iterates over the proposals in the active proposal queue +// and performs a callback function +func (k Keeper) IterateActiveProposalsQueue(ctx sdk.Context, cb func(proposal govV1.Proposal) (stop bool)) { + iterator := k.ActiveProposalQueueIterator(ctx) + + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + proposalID := types.GetProposalIDFromBytes(iterator.Value()) + proposal, found := k.GetProposal(ctx, proposalID) + if !found { + panic(fmt.Sprintf("proposal %d does not exist", proposalID)) + } + + if cb(proposal) { + break + } + } +} + +// ActiveProposalQueueIterator returns an sdk.Iterator for all the proposals in the Active Queue +func (k Keeper) ActiveProposalQueueIterator(ctx sdk.Context) sdk.Iterator { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.ActiveProposalQueuePrefix) + return prefixStore.Iterator(nil, nil) +} + +// GetProposal get proposal from store by ProposalID +func (k Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (govV1.Proposal, bool) { + store := ctx.KVStore(k.storeKey) + + bz := store.Get(types.ProposalKey(proposalID)) + if bz == nil { + return govV1.Proposal{}, false + } + + var proposal govV1.Proposal + k.MustUnmarshalProposal(bz, &proposal) + + return proposal, true +} + +func (k Keeper) MustUnmarshalProposal(bz []byte, proposal *govV1.Proposal) { + err := k.UnmarshalProposal(bz, proposal) + if err != nil { + panic(err) + } +} + +func (k Keeper) UnmarshalProposal(bz []byte, proposal *govV1.Proposal) error { + err := k.cdc.Unmarshal(bz, proposal) + if err != nil { + return err + } + return nil +} + +// SubmitProposal creates a new proposal given an array of messages +func (keeper Keeper) SubmitProposal(ctx sdk.Context, messages []sdk.Msg, proposer sdk.AccAddress) (uint64, error) { + // Will hold a comma-separated string of all Msg type URLs. + msgsStr := "" + + var ( + events sdk.Events + ) + + // Loop through all messages and confirm that each has a handler and the gov module account + // as the only signer + for _, msg := range messages { + msgsStr += fmt.Sprintf(",%s", sdk.MsgTypeURL(msg)) + + // perform a basic validation of the message + if err := msg.ValidateBasic(); err != nil { + return 0, errorsmod.Wrap(types.ErrInvalidProposalMsg, err.Error()) + } + + signers := msg.GetSigners() + if len(signers) != 1 { + return 0, types.ErrInvalidSigner + } + + // // assert that the governance module account is the only signer of the messages + // if !signers[0].Equals(keeper.GetGovernanceAccount(ctx).GetAddress()) { + // return v1.Proposal{}, sdkerrors.Wrapf(types.ErrInvalidSigner, signers[0].String()) + // } + + // use the msg service router to see that there is a valid route for that message. + handler := keeper.router.Handler(msg) + if handler == nil { + return 0, errorsmod.Wrap(types.ErrUnroutableProposalMsg, sdk.MsgTypeURL(msg)) + } + + var res *sdk.Result + res, err := handler(ctx, msg) + if err != nil { + return 0, err + } + + events = append(events, res.GetEvents()...) + + } + + return 0, nil +} + +// // SetProposal set a proposal to store +// func (k Keeper) SetProposal(ctx sdk.Context, proposal govV1.Proposal) { +// store := ctx.KVStore(k.storeKey) + +// bz := k.MustMarshalProposal(proposal) + +// store.Set(types.ProposalKey(proposal.Id), bz) +// } + +// // GetProposalID gets the highest proposal ID +// func (k Keeper) GetProposalID(ctx sdk.Context) (proposalID uint64, err error) { +// store := ctx.KVStore(k.storeKey) +// bz := store.Get(types.ProposalIDKey) +// if bz == nil { +// return 0, errorsmod.Wrap(types.ErrInvalidGenesis, "initial proposal ID hasn't been set") +// } + +// proposalID = types.GetProposalIDFromBytes(bz) +// return proposalID, nil +// } + +// // SetProposalID sets the new proposal ID to the store +// func (k Keeper) SetProposalID(ctx sdk.Context, proposalID uint64) { +// store := ctx.KVStore(k.storeKey) +// store.Set(types.ProposalIDKey, types.GetProposalIDBytes(proposalID)) +// } + +// // InsertActiveProposalQueue inserts a ProposalID into the active proposal queue +// func (k Keeper) InsertActiveProposalQueue(ctx sdk.Context, proposalID uint64) { +// store := ctx.KVStore(k.storeKey) +// store.Set(types.ActiveProposalQueueKey(proposalID), types.GetProposalIDBytes(proposalID)) +// } diff --git a/x/authority/module.go b/x/authority/module.go new file mode 100644 index 000000000..693eaa1c9 --- /dev/null +++ b/x/authority/module.go @@ -0,0 +1,148 @@ +package authority + +import ( + "encoding/json" + "fmt" + + // this line is used by starport scaffolding # 1 + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/public-awesome/stargaze/v13/x/authority/client/cli" + "github.com/public-awesome/stargaze/v13/x/authority/keeper" + "github.com/public-awesome/stargaze/v13/x/authority/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + // err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + // if err != nil { + // panic(err) + // } +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return nil //cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + keeper keeper.Keeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Deprecated: use RegisterServices +func (AppModule) QuerierRoute() string { return types.RouterKey } + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + //types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + EndBlocker(ctx, am.keeper) + return []abci.ValidatorUpdate{} +} diff --git a/x/authority/types/codec.go b/x/authority/types/codec.go new file mode 100644 index 000000000..9c83443af --- /dev/null +++ b/x/authority/types/codec.go @@ -0,0 +1,35 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + cryptoCodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterLegacyAminoCodec registers the necessary interfaces and concrete types on the provided LegacyAmino codec. +// These types are used for Amino JSON serialization. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgExecuteProposal{}, "authority/MsgExecuteProposal", nil) +} + +// RegisterInterfaces registers interfaces types with the interface registry. +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgExecuteProposal{}, + ) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + ModuleCdc = codec.NewAminoCodec(Amino) + Amino = codec.NewLegacyAmino() +) + +func init() { + RegisterLegacyAminoCodec(Amino) + cryptoCodec.RegisterCrypto(Amino) + sdk.RegisterLegacyAminoCodec(Amino) + Amino.Seal() +} diff --git a/x/authority/types/genesis.go b/x/authority/types/genesis.go new file mode 100644 index 000000000..1f25c6546 --- /dev/null +++ b/x/authority/types/genesis.go @@ -0,0 +1,11 @@ +package types + +// DefaultGenesisState returns a default genesis state. +func DefaultGenesis() *GenesisState { + return &GenesisState{} +} + +// Validate perform object fields validation. +func (m GenesisState) Validate() error { + return nil +} diff --git a/x/authority/types/keys.go b/x/authority/types/keys.go new file mode 100644 index 000000000..487fedde6 --- /dev/null +++ b/x/authority/types/keys.go @@ -0,0 +1,15 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "authority" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_authority" +) diff --git a/x/authority/types/msgs.go b/x/authority/types/msgs.go new file mode 100644 index 000000000..f789b8c28 --- /dev/null +++ b/x/authority/types/msgs.go @@ -0,0 +1,100 @@ +package types + +import ( + "fmt" + + errorsmod "cosmossdk.io/errors" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + sdktx "github.com/cosmos/cosmos-sdk/types/tx" + "github.com/cosmos/cosmos-sdk/x/gov/codec" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" +) + +var ( + _ sdk.Msg = &MsgExecuteProposal{} + _ codectypes.UnpackInterfacesMessage = &MsgExecuteProposal{} +) + +// NewMsgExecuteProposal creates a new MsgExecuteProposal. +// +//nolint:interfacer +func NewMsgExecuteProposal(messages []sdk.Msg, authority string) (*MsgExecuteProposal, error) { + m := &MsgExecuteProposal{ + Authority: authority, + } + + anys, err := sdktx.SetMsgs(messages) + if err != nil { + return nil, err + } + + m.Messages = anys + + return m, nil +} + +// GetMsgs unpacks m.Messages Any's into sdk.Msg's +func (m *MsgExecuteProposal) GetMsgs() ([]sdk.Msg, error) { + return sdktx.GetMsgs(m.Messages, "sdk.MsgProposal") +} + +// SetMsgs packs sdk.Msg's into m.Messages Any's +// NOTE: this will overwrite any existing messages +func (m *MsgExecuteProposal) SetMsgs(msgs []sdk.Msg) error { + anys, err := sdktx.SetMsgs(msgs) + if err != nil { + return err + } + + m.Messages = anys + return nil +} + +// Type implements the sdk.Msg interface. +func (m MsgExecuteProposal) Type() string { return sdk.MsgTypeURL(&m) } + +// ValidateBasic implements the sdk.Msg interface. +func (m MsgExecuteProposal) ValidateBasic() error { + + if _, err := sdk.AccAddressFromBech32(m.GetAuthority()); err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf("invalid proposer address: %s", err) + } + + // Check that either metadata or Msgs length is non nil. + if len(m.Messages) == 0 { + return errorsmod.Wrap(govtypes.ErrNoProposalMsgs, "Msgs length must be non-nil") + } + + msgs, err := m.GetMsgs() + if err != nil { + return err + } + + for idx, msg := range msgs { + if err := msg.ValidateBasic(); err != nil { + return errorsmod.Wrap(govtypes.ErrInvalidProposalMsg, + fmt.Sprintf("msg: %d, err: %s", idx, err.Error())) + } + } + + return nil +} + +// GetSignBytes returns the message bytes to sign over. +func (m MsgExecuteProposal) GetSignBytes() []byte { + bz := codec.ModuleCdc.MustMarshalJSON(&m) + return sdk.MustSortJSON(bz) +} + +// GetSigners returns the expected signers for a MsgExecuteProposal. +func (m MsgExecuteProposal) GetSigners() []sdk.AccAddress { + proposer, _ := sdk.AccAddressFromBech32(m.GetAuthority()) + return []sdk.AccAddress{proposer} +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (m MsgExecuteProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + return sdktx.UnpackInterfaces(unpacker, m.Messages) +} diff --git a/x/authority/types/types.go b/x/authority/types/types.go new file mode 100644 index 000000000..ab1254f4c --- /dev/null +++ b/x/authority/types/types.go @@ -0,0 +1 @@ +package types From e0607a86759c88c81815572c8f4ec6075ff6b40b Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Thu, 19 Oct 2023 13:14:47 +0530 Subject: [PATCH 03/20] adding params proto --- .../stargaze/authority/v1/authority.proto | 17 + x/authority/types/authority.pb.go | 555 ++++++++++++++++++ 2 files changed, 572 insertions(+) create mode 100644 x/authority/types/authority.pb.go diff --git a/proto/publicawesome/stargaze/authority/v1/authority.proto b/proto/publicawesome/stargaze/authority/v1/authority.proto index e69de29bb..29f96b3df 100644 --- a/proto/publicawesome/stargaze/authority/v1/authority.proto +++ b/proto/publicawesome/stargaze/authority/v1/authority.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package publicawesome.stargaze.authority.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/public-awesome/stargaze/v13/x/authority/types"; + +// Params holds parameters for the authority module. +message Params { + option (gogoproto.goproto_stringer) = false; + repeated Authorization authorizations = 1; +} + +message Authorization { + string msgTypeUrl = 1; // The type url of a proposal sdk.Msg + string address = 2; // The address who is allowed to execute that proposal +} \ No newline at end of file diff --git a/x/authority/types/authority.pb.go b/x/authority/types/authority.pb.go new file mode 100644 index 000000000..7226106f5 --- /dev/null +++ b/x/authority/types/authority.pb.go @@ -0,0 +1,555 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: publicawesome/stargaze/authority/v1/authority.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params holds parameters for the authority module. +type Params struct { + Authorizations []*Authorization `protobuf:"bytes,1,rep,name=authorizations,proto3" json:"authorizations,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_6e13d9034052c38a, []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) GetAuthorizations() []*Authorization { + if m != nil { + return m.Authorizations + } + return nil +} + +type Authorization struct { + MsgTypeUrl string `protobuf:"bytes,1,opt,name=msgTypeUrl,proto3" json:"msgTypeUrl,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *Authorization) Reset() { *m = Authorization{} } +func (m *Authorization) String() string { return proto.CompactTextString(m) } +func (*Authorization) ProtoMessage() {} +func (*Authorization) Descriptor() ([]byte, []int) { + return fileDescriptor_6e13d9034052c38a, []int{1} +} +func (m *Authorization) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Authorization) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Authorization.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 *Authorization) XXX_Merge(src proto.Message) { + xxx_messageInfo_Authorization.Merge(m, src) +} +func (m *Authorization) XXX_Size() int { + return m.Size() +} +func (m *Authorization) XXX_DiscardUnknown() { + xxx_messageInfo_Authorization.DiscardUnknown(m) +} + +var xxx_messageInfo_Authorization proto.InternalMessageInfo + +func (m *Authorization) GetMsgTypeUrl() string { + if m != nil { + return m.MsgTypeUrl + } + return "" +} + +func (m *Authorization) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func init() { + proto.RegisterType((*Params)(nil), "publicawesome.stargaze.authority.v1.Params") + proto.RegisterType((*Authorization)(nil), "publicawesome.stargaze.authority.v1.Authorization") +} + +func init() { + proto.RegisterFile("publicawesome/stargaze/authority/v1/authority.proto", fileDescriptor_6e13d9034052c38a) +} + +var fileDescriptor_6e13d9034052c38a = []byte{ + // 252 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x2e, 0x28, 0x4d, 0xca, + 0xc9, 0x4c, 0x4e, 0x2c, 0x4f, 0x2d, 0xce, 0xcf, 0x4d, 0xd5, 0x2f, 0x2e, 0x49, 0x2c, 0x4a, 0x4f, + 0xac, 0x4a, 0xd5, 0x4f, 0x2c, 0x2d, 0xc9, 0xc8, 0x2f, 0xca, 0x2c, 0xa9, 0xd4, 0x2f, 0x33, 0x44, + 0x70, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x94, 0x51, 0x34, 0xe9, 0xc1, 0x34, 0xe9, 0x21, + 0xd4, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xd5, 0xeb, 0x83, 0x58, 0x10, 0xad, + 0x4a, 0x59, 0x5c, 0x6c, 0x01, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x42, 0x51, 0x5c, 0x7c, 0x50, 0xf5, + 0x55, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xc5, 0x12, 0x8c, 0x0a, 0xcc, 0x1a, 0xdc, 0x46, 0x46, 0x7a, + 0x44, 0x98, 0xae, 0xe7, 0x88, 0xac, 0x35, 0x08, 0xcd, 0x24, 0x2b, 0x96, 0x19, 0x0b, 0xe4, 0x19, + 0x94, 0x3c, 0xb9, 0x78, 0x51, 0x94, 0x09, 0xc9, 0x71, 0x71, 0xe5, 0x16, 0xa7, 0x87, 0x54, 0x16, + 0xa4, 0x86, 0x16, 0xe5, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x21, 0x89, 0x08, 0x49, 0x70, + 0xb1, 0x27, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x4b, 0x30, 0x81, 0x25, 0x61, 0x5c, 0xa7, 0xa0, + 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, 0xb2, 0x48, 0xcf, 0x2c, 0xc9, 0x28, + 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x38, 0x5c, 0x17, 0x23, 0x30, 0xcb, 0x0c, 0x8d, 0xf5, + 0x2b, 0x90, 0x82, 0xb4, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0x22, 0xc6, 0x80, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x9a, 0x2e, 0xd2, 0x5a, 0x83, 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 len(m.Authorizations) > 0 { + for iNdEx := len(m.Authorizations) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Authorizations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuthority(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Authorization) 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 *Authorization) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Authorization) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintAuthority(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.MsgTypeUrl) > 0 { + i -= len(m.MsgTypeUrl) + copy(dAtA[i:], m.MsgTypeUrl) + i = encodeVarintAuthority(dAtA, i, uint64(len(m.MsgTypeUrl))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintAuthority(dAtA []byte, offset int, v uint64) int { + offset -= sovAuthority(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 len(m.Authorizations) > 0 { + for _, e := range m.Authorizations { + l = e.Size() + n += 1 + l + sovAuthority(uint64(l)) + } + } + return n +} + +func (m *Authorization) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MsgTypeUrl) + if l > 0 { + n += 1 + l + sovAuthority(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovAuthority(uint64(l)) + } + return n +} + +func sovAuthority(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAuthority(x uint64) (n int) { + return sovAuthority(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 ErrIntOverflowAuthority + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authorizations", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthority + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAuthority + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAuthority + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authorizations = append(m.Authorizations, &Authorization{}) + if err := m.Authorizations[len(m.Authorizations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAuthority(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuthority + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Authorization) 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 ErrIntOverflowAuthority + } + 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: Authorization: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Authorization: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgTypeUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthority + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAuthority + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthority + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MsgTypeUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthority + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAuthority + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthority + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAuthority(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuthority + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAuthority(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, ErrIntOverflowAuthority + } + 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, ErrIntOverflowAuthority + } + 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, ErrIntOverflowAuthority + } + 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, ErrInvalidLengthAuthority + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAuthority + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAuthority + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAuthority = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAuthority = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAuthority = fmt.Errorf("proto: unexpected end of group") +) From 4a2084278dcea4d9b37f6eaf3697af5e041912d4 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Thu, 19 Oct 2023 20:56:44 +0530 Subject: [PATCH 04/20] adding params --- docs/proto/proto-docs.md | 375 +++++------------- .../stargaze/authority/v1/authority.proto | 2 +- x/authority/keeper/msg_server.go | 28 +- x/authority/keeper/params.go | 29 ++ x/authority/types/authority.pb.go | 44 +- x/authority/types/authorization.go | 41 ++ x/authority/types/errors.go | 13 + x/authority/types/keys.go | 4 + x/authority/types/params.go | 32 ++ x/authority/types/params_test.go | 93 +++++ 10 files changed, 349 insertions(+), 312 deletions(-) create mode 100644 x/authority/keeper/params.go create mode 100644 x/authority/types/authorization.go create mode 100644 x/authority/types/errors.go create mode 100644 x/authority/types/params.go create mode 100644 x/authority/types/params_test.go diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 15ffa2c82..bb766e02b 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -4,99 +4,54 @@ ## Table of Contents -- [publicawesome/stargaze/globalfee/v1/globalfee.proto](#publicawesome/stargaze/globalfee/v1/globalfee.proto) - - [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) - - [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) - - [Params](#publicawesome.stargaze.globalfee.v1.Params) +- [publicawesome/stargaze/cron/v1/cron.proto](#publicawesome/stargaze/cron/v1/cron.proto) + - [Params](#publicawesome.stargaze.cron.v1.Params) -- [publicawesome/stargaze/globalfee/v1/genesis.proto](#publicawesome/stargaze/globalfee/v1/genesis.proto) - - [GenesisState](#publicawesome.stargaze.globalfee.v1.GenesisState) +- [publicawesome/stargaze/cron/v1/genesis.proto](#publicawesome/stargaze/cron/v1/genesis.proto) + - [GenesisState](#publicawesome.stargaze.cron.v1.GenesisState) -- [publicawesome/stargaze/globalfee/v1/proposal.proto](#publicawesome/stargaze/globalfee/v1/proposal.proto) - - [RemoveCodeAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.RemoveCodeAuthorizationProposal) - - [RemoveContractAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.RemoveContractAuthorizationProposal) - - [SetCodeAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.SetCodeAuthorizationProposal) - - [SetContractAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.SetContractAuthorizationProposal) +- [publicawesome/stargaze/cron/v1/proposal.proto](#publicawesome/stargaze/cron/v1/proposal.proto) + - [DemotePrivilegedContractProposal](#publicawesome.stargaze.cron.v1.DemotePrivilegedContractProposal) + - [PromoteToPrivilegedContractProposal](#publicawesome.stargaze.cron.v1.PromoteToPrivilegedContractProposal) -- [publicawesome/stargaze/globalfee/v1/query.proto](#publicawesome/stargaze/globalfee/v1/query.proto) - - [QueryAuthorizationsRequest](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsRequest) - - [QueryAuthorizationsResponse](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsResponse) - - [QueryCodeAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationRequest) - - [QueryCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationResponse) - - [QueryContractAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationRequest) - - [QueryContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationResponse) - - [QueryParamsRequest](#publicawesome.stargaze.globalfee.v1.QueryParamsRequest) - - [QueryParamsResponse](#publicawesome.stargaze.globalfee.v1.QueryParamsResponse) +- [publicawesome/stargaze/cron/v1/query.proto](#publicawesome/stargaze/cron/v1/query.proto) + - [QueryListPrivilegedRequest](#publicawesome.stargaze.cron.v1.QueryListPrivilegedRequest) + - [QueryListPrivilegedResponse](#publicawesome.stargaze.cron.v1.QueryListPrivilegedResponse) + - [QueryParamsRequest](#publicawesome.stargaze.cron.v1.QueryParamsRequest) + - [QueryParamsResponse](#publicawesome.stargaze.cron.v1.QueryParamsResponse) - - [Query](#publicawesome.stargaze.globalfee.v1.Query) + - [Query](#publicawesome.stargaze.cron.v1.Query) -- [publicawesome/stargaze/globalfee/v1/tx.proto](#publicawesome/stargaze/globalfee/v1/tx.proto) - - [MsgRemoveCodeAuthorization](#publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorization) - - [MsgRemoveCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorizationResponse) - - [MsgRemoveContractAuthorization](#publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorization) - - [MsgRemoveContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorizationResponse) - - [MsgSetCodeAuthorization](#publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorization) - - [MsgSetCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorizationResponse) - - [MsgSetContractAuthorization](#publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorization) - - [MsgSetContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorizationResponse) - - [MsgUpdateParams](#publicawesome.stargaze.globalfee.v1.MsgUpdateParams) - - [MsgUpdateParamsResponse](#publicawesome.stargaze.globalfee.v1.MsgUpdateParamsResponse) +- [publicawesome/stargaze/cron/v1/tx.proto](#publicawesome/stargaze/cron/v1/tx.proto) + - [MsgDemoteFromPrivilegedContract](#publicawesome.stargaze.cron.v1.MsgDemoteFromPrivilegedContract) + - [MsgDemoteFromPrivilegedContractResponse](#publicawesome.stargaze.cron.v1.MsgDemoteFromPrivilegedContractResponse) + - [MsgPromoteToPrivilegedContract](#publicawesome.stargaze.cron.v1.MsgPromoteToPrivilegedContract) + - [MsgPromoteToPrivilegedContractResponse](#publicawesome.stargaze.cron.v1.MsgPromoteToPrivilegedContractResponse) + - [MsgUpdateParams](#publicawesome.stargaze.cron.v1.MsgUpdateParams) + - [MsgUpdateParamsResponse](#publicawesome.stargaze.cron.v1.MsgUpdateParamsResponse) - - [Msg](#publicawesome.stargaze.globalfee.v1.Msg) + - [Msg](#publicawesome.stargaze.cron.v1.Msg) - [Scalar Value Types](#scalar-value-types) - +

Top

-## publicawesome/stargaze/globalfee/v1/globalfee.proto +## publicawesome/stargaze/cron/v1/cron.proto - - -### CodeAuthorization -Configuration for code Ids which can have zero gas operations - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `code_id` | [uint64](#uint64) | | authorized code ids | -| `methods` | [string](#string) | repeated | authorized contract operation methods | - - - - - - - - -### ContractAuthorization -Configuration for contract addresses which can have zero gas operations - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `contract_address` | [string](#string) | | authorized contract addresses | -| `methods` | [string](#string) | repeated | authorized contract operation methods | - - - - - - - + ### Params -Params holds parameters for the globalfee module. +Params holds parameters for the cron module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `privileged_addresses` | [string](#string) | repeated | Addresses which are whitelisted to modify the gas free operations | -| `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | Minimum stores the minimum gas price(s) for all TX on the chain. | +| `admin_addresses` | [string](#string) | repeated | Addresses which act as admins of the module. They can promote and demote contracts without having to go via governance. | @@ -112,24 +67,23 @@ Params holds parameters for the globalfee module. - +

Top

-## publicawesome/stargaze/globalfee/v1/genesis.proto +## publicawesome/stargaze/cron/v1/genesis.proto - + ### GenesisState -GenesisState defines the globalfee module's genesis state. +GenesisState defines the cron module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#publicawesome.stargaze.globalfee.v1.Params) | | Module params | -| `code_authorizations` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | repeated | Authorizations configured by code id | -| `contract_authorizations` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | repeated | Authorizations configured by contract addresses | +| `privileged_contract_addresses` | [string](#string) | repeated | List of all the contracts that have been given the privilege status via governance. They can set up hooks to abci.EndBlocker | +| `params` | [Params](#publicawesome.stargaze.cron.v1.Params) | | Module params | @@ -145,75 +99,45 @@ GenesisState defines the globalfee module's genesis state. - +

Top

-## publicawesome/stargaze/globalfee/v1/proposal.proto - - - - - -### RemoveCodeAuthorizationProposal - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | -| `code_id` | [uint64](#uint64) | | | - - - - +## publicawesome/stargaze/cron/v1/proposal.proto - -### RemoveContractAuthorizationProposal + +### DemotePrivilegedContractProposal +Deprecated: Do not use. To demote a contract, a +MsgDemoteFromPrivilegedContract can be invoked from the x/gov module via a v1 +governance proposal | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | -| `contract_address` | [string](#string) | | | +| `title` | [string](#string) | | Title is a short summary | +| `description` | [string](#string) | | Description is a human readable text | +| `contract` | [string](#string) | | Contract is the bech32 address of the smart contract | - - -### SetCodeAuthorizationProposal - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | -| `code_authorization` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | | | - - - - - - - - -### SetContractAuthorizationProposal + +### PromoteToPrivilegedContractProposal +Deprecated: Do not use. To promote a contract, a +MsgPromoteToPrivilegedContract can be invoked from the x/gov module via a v1 +governance proposal | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | -| `contract_authorization` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | | | +| `title` | [string](#string) | | Title is a short summary | +| `description` | [string](#string) | | Description is a human readable text | +| `contract` | [string](#string) | | Contract is the bech32 address of the smart contract | @@ -229,118 +153,61 @@ GenesisState defines the globalfee module's genesis state. - +

Top

-## publicawesome/stargaze/globalfee/v1/query.proto - - - - - -### QueryAuthorizationsRequest - - - - - - - - - -### QueryAuthorizationsResponse - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `code_authorizations` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | repeated | | -| `contract_authorizations` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | repeated | | - - - - - +## publicawesome/stargaze/cron/v1/query.proto - -### QueryCodeAuthorizationRequest + +### QueryListPrivilegedRequest +QueryListPrivilegedRequest is request type for the Query/ListPrivileged RPC +method. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `code_id` | [uint64](#uint64) | | | - - - - - - - - -### QueryCodeAuthorizationResponse - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `methods` | [string](#string) | repeated | | + - - -### QueryContractAuthorizationRequest - +### QueryListPrivilegedResponse +QueryListPrivilegedResponse is response type for the Query/ListPrivileged RPC +method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `contract_address` | [string](#string) | | | - - +| `contract_addresses` | [string](#string) | repeated | contract_addresses holds all the smart contract addresses which have privilege status. | - -### QueryContractAuthorizationResponse - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `methods` | [string](#string) | repeated | | - - - - - - - + ### QueryParamsRequest +QueryParamsRequest is request type for the Query/Params RPC +method. - - + ### QueryParamsResponse - +QueryParamsResponse is response type for the Query/Params RPC +method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#publicawesome.stargaze.globalfee.v1.Params) | | | +| `params` | [Params](#publicawesome.stargaze.cron.v1.Params) | | | @@ -353,100 +220,46 @@ GenesisState defines the globalfee module's genesis state. - + ### Query Query defines the gRPC querier service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `CodeAuthorization` | [QueryCodeAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationRequest) | [QueryCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationResponse) | | GET|/stargaze/globalfee/v1/code_authorization/{code_id}| -| `ContractAuthorization` | [QueryContractAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationRequest) | [QueryContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationResponse) | | GET|/stargaze/globalfee/v1/contract_authorization/{contract_address}| -| `Params` | [QueryParamsRequest](#publicawesome.stargaze.globalfee.v1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.globalfee.v1.QueryParamsResponse) | | GET|/stargaze/globalfee/v1/params| -| `Authorizations` | [QueryAuthorizationsRequest](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsRequest) | [QueryAuthorizationsResponse](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsResponse) | | GET|/stargaze/globalfee/v1/authorizations| +| `ListPrivileged` | [QueryListPrivilegedRequest](#publicawesome.stargaze.cron.v1.QueryListPrivilegedRequest) | [QueryListPrivilegedResponse](#publicawesome.stargaze.cron.v1.QueryListPrivilegedResponse) | ListPrivileged queries the contracts which have the priviledge status | GET|/stargaze/cron/v1/list-privileged| +| `Params` | [QueryParamsRequest](#publicawesome.stargaze.cron.v1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.cron.v1.QueryParamsResponse) | | GET|/stargaze/cron/v1/params| - +

Top

-## publicawesome/stargaze/globalfee/v1/tx.proto - - - - - -### MsgRemoveCodeAuthorization - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `sender` | [string](#string) | | | -| `code_id` | [uint64](#uint64) | | | - - - - - - - - -### MsgRemoveCodeAuthorizationResponse - - - - - - - - - -### MsgRemoveContractAuthorization - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `sender` | [string](#string) | | | -| `contract_address` | [string](#string) | | | - - - - - - - - -### MsgRemoveContractAuthorizationResponse - - - - +## publicawesome/stargaze/cron/v1/tx.proto - + -### MsgSetCodeAuthorization +### MsgDemoteFromPrivilegedContract | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `sender` | [string](#string) | | | -| `code_authorization` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | | | +| `authority` | [string](#string) | | Authority is the address of the governance account or any whitelisted address | +| `contract` | [string](#string) | | Contract is the bech32 address of the smart contract | - + -### MsgSetCodeAuthorizationResponse +### MsgDemoteFromPrivilegedContractResponse @@ -454,25 +267,25 @@ Query defines the gRPC querier service. - + -### MsgSetContractAuthorization +### MsgPromoteToPrivilegedContract | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `sender` | [string](#string) | | | -| `contract_authorization` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | | | +| `authority` | [string](#string) | | Authority is the address of the governance account or any whitelisted address | +| `contract` | [string](#string) | | Contract is the bech32 address of the smart contract | - + -### MsgSetContractAuthorizationResponse +### MsgPromoteToPrivilegedContractResponse @@ -480,7 +293,7 @@ Query defines the gRPC querier service. - + ### MsgUpdateParams @@ -488,15 +301,15 @@ Query defines the gRPC querier service. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `sender` | [string](#string) | | | -| `params` | [Params](#publicawesome.stargaze.globalfee.v1.Params) | | NOTE: All parameters must be supplied. | +| `authority` | [string](#string) | | Authority is the address of the governance account. | +| `params` | [Params](#publicawesome.stargaze.cron.v1.Params) | | NOTE: All parameters must be supplied. | - + ### MsgUpdateParamsResponse @@ -512,18 +325,16 @@ Query defines the gRPC querier service. - + ### Msg Msg defines the alloc Msg service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `SetCodeAuthorization` | [MsgSetCodeAuthorization](#publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorization) | [MsgSetCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorizationResponse) | | | -| `RemoveCodeAuthorization` | [MsgRemoveCodeAuthorization](#publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorization) | [MsgRemoveCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorizationResponse) | | | -| `SetContractAuthorization` | [MsgSetContractAuthorization](#publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorization) | [MsgSetContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorizationResponse) | | | -| `RemoveContractAuthorization` | [MsgRemoveContractAuthorization](#publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorization) | [MsgRemoveContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorizationResponse) | | | -| `UpdateParams` | [MsgUpdateParams](#publicawesome.stargaze.globalfee.v1.MsgUpdateParams) | [MsgUpdateParamsResponse](#publicawesome.stargaze.globalfee.v1.MsgUpdateParamsResponse) | | | +| `PromoteToPrivilegedContract` | [MsgPromoteToPrivilegedContract](#publicawesome.stargaze.cron.v1.MsgPromoteToPrivilegedContract) | [MsgPromoteToPrivilegedContractResponse](#publicawesome.stargaze.cron.v1.MsgPromoteToPrivilegedContractResponse) | | | +| `DemoteFromPrivilegedContract` | [MsgDemoteFromPrivilegedContract](#publicawesome.stargaze.cron.v1.MsgDemoteFromPrivilegedContract) | [MsgDemoteFromPrivilegedContractResponse](#publicawesome.stargaze.cron.v1.MsgDemoteFromPrivilegedContractResponse) | | | +| `UpdateParams` | [MsgUpdateParams](#publicawesome.stargaze.cron.v1.MsgUpdateParams) | [MsgUpdateParamsResponse](#publicawesome.stargaze.cron.v1.MsgUpdateParamsResponse) | | | diff --git a/proto/publicawesome/stargaze/authority/v1/authority.proto b/proto/publicawesome/stargaze/authority/v1/authority.proto index 29f96b3df..3ae1b7499 100644 --- a/proto/publicawesome/stargaze/authority/v1/authority.proto +++ b/proto/publicawesome/stargaze/authority/v1/authority.proto @@ -13,5 +13,5 @@ message Params { message Authorization { string msgTypeUrl = 1; // The type url of a proposal sdk.Msg - string address = 2; // The address who is allowed to execute that proposal + repeated string addresses = 2; // The addresses who are allowed to execute that proposal } \ No newline at end of file diff --git a/x/authority/keeper/msg_server.go b/x/authority/keeper/msg_server.go index b691bc273..cf468e469 100644 --- a/x/authority/keeper/msg_server.go +++ b/x/authority/keeper/msg_server.go @@ -3,6 +3,7 @@ package keeper import ( "context" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/public-awesome/stargaze/v13/x/authority/types" ) @@ -33,7 +34,10 @@ func (m msgServer) ExecuteProposal(goCtx context.Context, msg *types.MsgExecuteP return nil, err } - IsAuthorized(ctx, proposalMsgs) + valid, err := m.Keeper.IsAuthorized(ctx, proposalMsgs, msg.GetAuthority()) + if !valid { + return nil, err + } _, err = m.Keeper.SubmitProposal(ctx, proposalMsgs, proposer) if err != nil { @@ -43,13 +47,19 @@ func (m msgServer) ExecuteProposal(goCtx context.Context, msg *types.MsgExecuteP return &types.MsgExecuteProposalResponse{}, nil } -func IsAuthorized(ctx sdk.Context, msgs []sdk.Msg) bool { - // loop through msgs - for _, msg := range msgs { - test := sdk.MsgTypeURL(msg) - panic(test) +func (keeper Keeper) IsAuthorized(ctx sdk.Context, msgs []sdk.Msg, proposer string) (bool, error) { + authorizations := keeper.GetParams(ctx).Authorizations + for _, msg := range msgs { // Checking authorizations for all the msgs in the proposal + msgType := sdk.MsgTypeURL(msg) + auth, found := types.GetMsgAuthorization(msgType, authorizations) + if !found { + return false, errorsmod.Wrap(types.ErrAuthorizationNotFound, "authorization not found for given msg type: "+msgType) + } + + if !auth.IsAuthorized(proposer) { + return false, errorsmod.Wrap(types.ErrUnauthorized, "authority address is not authorized address to ") + } + } - return false + return true, nil } - -// /cosmos.distribution.v1beta1.MsgCommunityPoolSpend diff --git a/x/authority/keeper/params.go b/x/authority/keeper/params.go new file mode 100644 index 000000000..3001df218 --- /dev/null +++ b/x/authority/keeper/params.go @@ -0,0 +1,29 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/public-awesome/stargaze/v13/x/authority/types" +) + +// SetParams sets the total set of minting parameters. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { + store := ctx.KVStore(k.storeKey) + bz, err := k.cdc.Marshal(¶ms) + if err != nil { + return err + } + store.Set(types.ParamsKey, bz) + return nil +} + +// GetParams returns the total set of minting parameters. +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) + if bz == nil { + return params + } + + k.cdc.MustUnmarshal(bz, ¶ms) + return params +} diff --git a/x/authority/types/authority.pb.go b/x/authority/types/authority.pb.go index 7226106f5..6ec041330 100644 --- a/x/authority/types/authority.pb.go +++ b/x/authority/types/authority.pb.go @@ -68,8 +68,8 @@ func (m *Params) GetAuthorizations() []*Authorization { } type Authorization struct { - MsgTypeUrl string `protobuf:"bytes,1,opt,name=msgTypeUrl,proto3" json:"msgTypeUrl,omitempty"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + MsgTypeUrl string `protobuf:"bytes,1,opt,name=msgTypeUrl,proto3" json:"msgTypeUrl,omitempty"` + Address []string `protobuf:"bytes,2,rep,name=address,proto3" json:"address,omitempty"` } func (m *Authorization) Reset() { *m = Authorization{} } @@ -112,11 +112,11 @@ func (m *Authorization) GetMsgTypeUrl() string { return "" } -func (m *Authorization) GetAddress() string { +func (m *Authorization) GetAddress() []string { if m != nil { return m.Address } - return "" + return nil } func init() { @@ -129,7 +129,7 @@ func init() { } var fileDescriptor_6e13d9034052c38a = []byte{ - // 252 bytes of a gzipped FileDescriptorProto + // 255 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x2e, 0x28, 0x4d, 0xca, 0xc9, 0x4c, 0x4e, 0x2c, 0x4f, 0x2d, 0xce, 0xcf, 0x4d, 0xd5, 0x2f, 0x2e, 0x49, 0x2c, 0x4a, 0x4f, 0xac, 0x4a, 0xd5, 0x4f, 0x2c, 0x2d, 0xc9, 0xc8, 0x2f, 0xca, 0x2c, 0xa9, 0xd4, 0x2f, 0x33, 0x44, @@ -140,12 +140,12 @@ var fileDescriptor_6e13d9034052c38a = []byte{ 0x44, 0x98, 0xae, 0xe7, 0x88, 0xac, 0x35, 0x08, 0xcd, 0x24, 0x2b, 0x96, 0x19, 0x0b, 0xe4, 0x19, 0x94, 0x3c, 0xb9, 0x78, 0x51, 0x94, 0x09, 0xc9, 0x71, 0x71, 0xe5, 0x16, 0xa7, 0x87, 0x54, 0x16, 0xa4, 0x86, 0x16, 0xe5, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x21, 0x89, 0x08, 0x49, 0x70, - 0xb1, 0x27, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x4b, 0x30, 0x81, 0x25, 0x61, 0x5c, 0xa7, 0xa0, - 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, 0xb2, 0x48, 0xcf, 0x2c, 0xc9, 0x28, - 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x38, 0x5c, 0x17, 0x23, 0x30, 0xcb, 0x0c, 0x8d, 0xf5, - 0x2b, 0x90, 0x82, 0xb4, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0x22, 0xc6, 0x80, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x9a, 0x2e, 0xd2, 0x5a, 0x83, 0x01, 0x00, 0x00, + 0xb1, 0x27, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x4b, 0x30, 0x29, 0x30, 0x6b, 0x70, 0x06, 0xc1, + 0xb8, 0x4e, 0x41, 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, 0x91, 0x9e, + 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x71, 0xb8, 0x2e, 0x46, 0x60, 0x96, + 0x19, 0x1a, 0xeb, 0x57, 0x20, 0x05, 0x69, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x44, + 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x40, 0xaf, 0xaf, 0x43, 0x83, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -206,11 +206,13 @@ func (m *Authorization) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintAuthority(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0x12 + for iNdEx := len(m.Address) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Address[iNdEx]) + copy(dAtA[i:], m.Address[iNdEx]) + i = encodeVarintAuthority(dAtA, i, uint64(len(m.Address[iNdEx]))) + i-- + dAtA[i] = 0x12 + } } if len(m.MsgTypeUrl) > 0 { i -= len(m.MsgTypeUrl) @@ -258,9 +260,11 @@ func (m *Authorization) Size() (n int) { if l > 0 { n += 1 + l + sovAuthority(uint64(l)) } - l = len(m.Address) - if l > 0 { - n += 1 + l + sovAuthority(uint64(l)) + if len(m.Address) > 0 { + for _, s := range m.Address { + l = len(s) + n += 1 + l + sovAuthority(uint64(l)) + } } return n } @@ -446,7 +450,7 @@ func (m *Authorization) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.Address = append(m.Address, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/authority/types/authorization.go b/x/authority/types/authorization.go new file mode 100644 index 000000000..4b1415417 --- /dev/null +++ b/x/authority/types/authorization.go @@ -0,0 +1,41 @@ +package types + +import ( + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func GetMsgAuthorization(msgTypeUrl string, authorizations []*Authorization) (*Authorization, bool) { + for _, auth := range authorizations { + if auth.MsgTypeUrl == msgTypeUrl { + return auth, true + } + } + return &Authorization{}, false +} + +func (a Authorization) IsAuthorized(proposer string) bool { + for _, addr := range a.Address { + if addr == proposer { + return true + } + } + return false +} + +func (a Authorization) Validate() error { + if len(a.Address) == 0 { + return fmt.Errorf("addresses cannot be empty") + } + for _, addr := range a.Address { + _, err := sdk.AccAddressFromBech32(addr) + if err != nil { + return err + } + } + if len(a.MsgTypeUrl) == 0 { + return fmt.Errorf("msg type url cannot be empty") + } + return nil +} diff --git a/x/authority/types/errors.go b/x/authority/types/errors.go new file mode 100644 index 000000000..db9a3fff8 --- /dev/null +++ b/x/authority/types/errors.go @@ -0,0 +1,13 @@ +package types + +// DONTCOVER + +import ( + errorsmod "cosmossdk.io/errors" +) + +// x/cron module sentinel errors +var ( + ErrUnauthorized = errorsmod.Register(ModuleName, 2, "sender is unauthorized to perform the operation") + ErrAuthorizationNotFound = errorsmod.Register(ModuleName, 3, "") +) diff --git a/x/authority/types/keys.go b/x/authority/types/keys.go index 487fedde6..7ea00103c 100644 --- a/x/authority/types/keys.go +++ b/x/authority/types/keys.go @@ -13,3 +13,7 @@ const ( // MemStoreKey defines the in-memory store key MemStoreKey = "mem_authority" ) + +var ( + ParamsKey = []byte{0x01} +) diff --git a/x/authority/types/params.go b/x/authority/types/params.go new file mode 100644 index 000000000..6d69672e5 --- /dev/null +++ b/x/authority/types/params.go @@ -0,0 +1,32 @@ +package types + +import ( + "gopkg.in/yaml.v2" +) + +// default module parameters +func DefaultParams() Params { + return Params{ + Authorizations: []*Authorization{}, + } +} + +func NewParams(authorizations []*Authorization) Params { + return Params{ + Authorizations: authorizations, + } +} + +func (p Params) Validate() error { + for _, auth := range p.GetAuthorizations() { + if err := auth.Validate(); err != nil { + return err + } + } + return nil +} + +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/authority/types/params_test.go b/x/authority/types/params_test.go new file mode 100644 index 000000000..3a7269704 --- /dev/null +++ b/x/authority/types/params_test.go @@ -0,0 +1,93 @@ +package types_test + +import ( + "testing" + + "github.com/public-awesome/stargaze/v13/x/authority/types" + "github.com/stretchr/testify/require" +) + +func TestParamsValidate(t *testing.T) { + testCases := []struct { + testCase string + p types.Params + expectError bool + }{ + { + "ok: empty params", + types.Params{}, + false, + }, + { + "fail: no addrs", + types.Params{ + Authorizations: []*types.Authorization{ + { + Address: []string{}, + MsgTypeUrl: "/cosmos.distribution.v1beta1.MsgCommunityPoolSpend", + }, + }, + }, + true, + }, + { + "fail: invalid addr", + types.Params{ + Authorizations: []*types.Authorization{ + { + Address: []string{ + "👻", + }, + MsgTypeUrl: "/cosmos.distribution.v1beta1.MsgCommunityPoolSpend", + }, + }, + }, + true, + }, + { + "fail: valid addr but empty msg type url", + types.Params{ + Authorizations: []*types.Authorization{ + { + Address: []string{ + "cosmos1c4k24jzduc365kywrsvf5ujz4ya6mwymy8vq4q", + }, + MsgTypeUrl: "", + }, + }, + }, + true, + }, + { + "ok: all valid input", + types.Params{ + Authorizations: []*types.Authorization{ + { + Address: []string{ + "cosmos1c4k24jzduc365kywrsvf5ujz4ya6mwymy8vq4q", + }, + MsgTypeUrl: "/cosmos.distribution.v1beta1.MsgCommunityPoolSpend", + }, + }, + }, + false, + }, + { + "ok: default params", + types.DefaultParams(), + false, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.testCase, func(t *testing.T) { + err := tc.p.Validate() + if tc.expectError { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} From cc225c72830f249582c459610acb205d4086bc3b Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 20 Oct 2023 21:31:41 +0530 Subject: [PATCH 05/20] adding params and query --- docs/proto/proto-docs.md | 238 +++----- .../stargaze/authority/v1/query.proto | 18 + x/authority/client/cli/query.go | 56 ++ x/authority/keeper/grpc_query.go | 27 + x/authority/keeper/msg_server.go | 23 - x/authority/keeper/params.go | 15 +- x/authority/keeper/proposal.go | 38 +- x/authority/module.go | 13 +- x/authority/types/authority.pb.go | 43 +- x/authority/types/authorization.go | 6 +- x/authority/types/params.go | 11 +- x/authority/types/params_test.go | 8 +- x/authority/types/query.pb.go | 538 ++++++++++++++++++ x/authority/types/query.pb.gw.go | 153 +++++ 14 files changed, 957 insertions(+), 230 deletions(-) create mode 100644 proto/publicawesome/stargaze/authority/v1/query.proto create mode 100644 x/authority/client/cli/query.go create mode 100644 x/authority/keeper/grpc_query.go create mode 100644 x/authority/types/query.pb.go create mode 100644 x/authority/types/query.pb.gw.go diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index bb766e02b..f0e20217d 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -4,86 +4,84 @@ ## Table of Contents -- [publicawesome/stargaze/cron/v1/cron.proto](#publicawesome/stargaze/cron/v1/cron.proto) - - [Params](#publicawesome.stargaze.cron.v1.Params) +- [publicawesome/stargaze/alloc/v1beta1/params.proto](#publicawesome/stargaze/alloc/v1beta1/params.proto) + - [DistributionProportions](#publicawesome.stargaze.alloc.v1beta1.DistributionProportions) + - [Params](#publicawesome.stargaze.alloc.v1beta1.Params) + - [WeightedAddress](#publicawesome.stargaze.alloc.v1beta1.WeightedAddress) -- [publicawesome/stargaze/cron/v1/genesis.proto](#publicawesome/stargaze/cron/v1/genesis.proto) - - [GenesisState](#publicawesome.stargaze.cron.v1.GenesisState) +- [publicawesome/stargaze/alloc/v1beta1/genesis.proto](#publicawesome/stargaze/alloc/v1beta1/genesis.proto) + - [GenesisState](#publicawesome.stargaze.alloc.v1beta1.GenesisState) -- [publicawesome/stargaze/cron/v1/proposal.proto](#publicawesome/stargaze/cron/v1/proposal.proto) - - [DemotePrivilegedContractProposal](#publicawesome.stargaze.cron.v1.DemotePrivilegedContractProposal) - - [PromoteToPrivilegedContractProposal](#publicawesome.stargaze.cron.v1.PromoteToPrivilegedContractProposal) +- [publicawesome/stargaze/alloc/v1beta1/query.proto](#publicawesome/stargaze/alloc/v1beta1/query.proto) + - [QueryParamsRequest](#publicawesome.stargaze.alloc.v1beta1.QueryParamsRequest) + - [QueryParamsResponse](#publicawesome.stargaze.alloc.v1beta1.QueryParamsResponse) -- [publicawesome/stargaze/cron/v1/query.proto](#publicawesome/stargaze/cron/v1/query.proto) - - [QueryListPrivilegedRequest](#publicawesome.stargaze.cron.v1.QueryListPrivilegedRequest) - - [QueryListPrivilegedResponse](#publicawesome.stargaze.cron.v1.QueryListPrivilegedResponse) - - [QueryParamsRequest](#publicawesome.stargaze.cron.v1.QueryParamsRequest) - - [QueryParamsResponse](#publicawesome.stargaze.cron.v1.QueryParamsResponse) + - [Query](#publicawesome.stargaze.alloc.v1beta1.Query) - - [Query](#publicawesome.stargaze.cron.v1.Query) +- [publicawesome/stargaze/alloc/v1beta1/tx.proto](#publicawesome/stargaze/alloc/v1beta1/tx.proto) + - [MsgCreateVestingAccount](#publicawesome.stargaze.alloc.v1beta1.MsgCreateVestingAccount) + - [MsgCreateVestingAccountResponse](#publicawesome.stargaze.alloc.v1beta1.MsgCreateVestingAccountResponse) + - [MsgFundFairburnPool](#publicawesome.stargaze.alloc.v1beta1.MsgFundFairburnPool) + - [MsgFundFairburnPoolResponse](#publicawesome.stargaze.alloc.v1beta1.MsgFundFairburnPoolResponse) -- [publicawesome/stargaze/cron/v1/tx.proto](#publicawesome/stargaze/cron/v1/tx.proto) - - [MsgDemoteFromPrivilegedContract](#publicawesome.stargaze.cron.v1.MsgDemoteFromPrivilegedContract) - - [MsgDemoteFromPrivilegedContractResponse](#publicawesome.stargaze.cron.v1.MsgDemoteFromPrivilegedContractResponse) - - [MsgPromoteToPrivilegedContract](#publicawesome.stargaze.cron.v1.MsgPromoteToPrivilegedContract) - - [MsgPromoteToPrivilegedContractResponse](#publicawesome.stargaze.cron.v1.MsgPromoteToPrivilegedContractResponse) - - [MsgUpdateParams](#publicawesome.stargaze.cron.v1.MsgUpdateParams) - - [MsgUpdateParamsResponse](#publicawesome.stargaze.cron.v1.MsgUpdateParamsResponse) - - - [Msg](#publicawesome.stargaze.cron.v1.Msg) + - [Msg](#publicawesome.stargaze.alloc.v1beta1.Msg) - [Scalar Value Types](#scalar-value-types) - +

Top

-## publicawesome/stargaze/cron/v1/cron.proto +## publicawesome/stargaze/alloc/v1beta1/params.proto - + + +### DistributionProportions -### Params -Params holds parameters for the cron module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `admin_addresses` | [string](#string) | repeated | Addresses which act as admins of the module. They can promote and demote contracts without having to go via governance. | +| `nft_incentives` | [string](#string) | | | +| `developer_rewards` | [string](#string) | | | +| `community_pool` | [string](#string) | | | - - + - +### Params - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `distribution_proportions` | [DistributionProportions](#publicawesome.stargaze.alloc.v1beta1.DistributionProportions) | | distribution_proportions defines the proportion of the minted denom | +| `weighted_developer_rewards_receivers` | [WeightedAddress](#publicawesome.stargaze.alloc.v1beta1.WeightedAddress) | repeated | addresses to receive developer rewards | +| `weighted_incentives_rewards_receivers` | [WeightedAddress](#publicawesome.stargaze.alloc.v1beta1.WeightedAddress) | repeated | addresses to receive incentive rewards | +| `supplement_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | SupplementAmount is the amount to be supplemented from the pool on top of newly minted coins. | - -

Top

-## publicawesome/stargaze/cron/v1/genesis.proto - -### GenesisState -GenesisState defines the cron module's genesis state. + + +### WeightedAddress + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `privileged_contract_addresses` | [string](#string) | repeated | List of all the contracts that have been given the privilege status via governance. They can set up hooks to abci.EndBlocker | -| `params` | [Params](#publicawesome.stargaze.cron.v1.Params) | | Module params | +| `address` | [string](#string) | | | +| `weight` | [string](#string) | | | @@ -99,45 +97,22 @@ GenesisState defines the cron module's genesis state. - +

Top

-## publicawesome/stargaze/cron/v1/proposal.proto - - - - - -### DemotePrivilegedContractProposal -Deprecated: Do not use. To demote a contract, a -MsgDemoteFromPrivilegedContract can be invoked from the x/gov module via a v1 -governance proposal - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | Title is a short summary | -| `description` | [string](#string) | | Description is a human readable text | -| `contract` | [string](#string) | | Contract is the bech32 address of the smart contract | +## publicawesome/stargaze/alloc/v1beta1/genesis.proto + - - - - -### PromoteToPrivilegedContractProposal -Deprecated: Do not use. To promote a contract, a -MsgPromoteToPrivilegedContract can be invoked from the x/gov module via a v1 -governance proposal +### GenesisState +GenesisState defines the alloc module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | Title is a short summary | -| `description` | [string](#string) | | Description is a human readable text | -| `contract` | [string](#string) | | Contract is the bech32 address of the smart contract | +| `params` | [Params](#publicawesome.stargaze.alloc.v1beta1.Params) | | this line is used by starport scaffolding # genesis/proto/state | @@ -153,61 +128,32 @@ governance proposal - +

Top

-## publicawesome/stargaze/cron/v1/query.proto - - - - - -### QueryListPrivilegedRequest -QueryListPrivilegedRequest is request type for the Query/ListPrivileged RPC -method. - - - - +## publicawesome/stargaze/alloc/v1beta1/query.proto - -### QueryListPrivilegedResponse -QueryListPrivilegedResponse is response type for the Query/ListPrivileged RPC -method. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `contract_addresses` | [string](#string) | repeated | contract_addresses holds all the smart contract addresses which have privilege status. | - - - - - - - + ### QueryParamsRequest -QueryParamsRequest is request type for the Query/Params RPC -method. +QueryParamsRequest is the request type for the Query/Params RPC method. - + ### QueryParamsResponse -QueryParamsResponse is response type for the Query/Params RPC -method. +QueryParamsResponse is the response type for the Query/Params RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#publicawesome.stargaze.cron.v1.Params) | | | +| `params` | [Params](#publicawesome.stargaze.alloc.v1beta1.Params) | | params defines the parameters of the module. | @@ -220,99 +166,80 @@ method. - + ### Query Query defines the gRPC querier service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `ListPrivileged` | [QueryListPrivilegedRequest](#publicawesome.stargaze.cron.v1.QueryListPrivilegedRequest) | [QueryListPrivilegedResponse](#publicawesome.stargaze.cron.v1.QueryListPrivilegedResponse) | ListPrivileged queries the contracts which have the priviledge status | GET|/stargaze/cron/v1/list-privileged| -| `Params` | [QueryParamsRequest](#publicawesome.stargaze.cron.v1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.cron.v1.QueryParamsResponse) | | GET|/stargaze/cron/v1/params| +| `Params` | [QueryParamsRequest](#publicawesome.stargaze.alloc.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.alloc.v1beta1.QueryParamsResponse) | this line is used by starport scaffolding # 2 | GET|/stargaze/alloc/v1beta1/params| - +

Top

-## publicawesome/stargaze/cron/v1/tx.proto - - - - - -### MsgDemoteFromPrivilegedContract - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `authority` | [string](#string) | | Authority is the address of the governance account or any whitelisted address | -| `contract` | [string](#string) | | Contract is the bech32 address of the smart contract | - - - - - - - - -### MsgDemoteFromPrivilegedContractResponse +## publicawesome/stargaze/alloc/v1beta1/tx.proto + - - - - - -### MsgPromoteToPrivilegedContract - +### MsgCreateVestingAccount +MsgCreateVestingAccount defines a message that enables creating a vesting +account. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `authority` | [string](#string) | | Authority is the address of the governance account or any whitelisted address | -| `contract` | [string](#string) | | Contract is the bech32 address of the smart contract | - +| `from_address` | [string](#string) | | | +| `to_address` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `start_time` | [int64](#int64) | | | +| `end_time` | [int64](#int64) | | | +| `delayed` | [bool](#bool) | | | - -### MsgPromoteToPrivilegedContractResponse + +### MsgCreateVestingAccountResponse +MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response +type. - - -### MsgUpdateParams + +### MsgFundFairburnPool +MsgFundFairburnPool allows an account to directly +fund the fee collector pool. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `authority` | [string](#string) | | Authority is the address of the governance account. | -| `params` | [Params](#publicawesome.stargaze.cron.v1.Params) | | NOTE: All parameters must be supplied. | - +| `sender` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | - -### MsgUpdateParamsResponse + +### MsgFundFairburnPoolResponse +MsgFundFairburnPoolResponse defines the Msg/MsgFundFairburnPool response +type. @@ -325,16 +252,15 @@ Query defines the gRPC querier service. - + ### Msg Msg defines the alloc Msg service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `PromoteToPrivilegedContract` | [MsgPromoteToPrivilegedContract](#publicawesome.stargaze.cron.v1.MsgPromoteToPrivilegedContract) | [MsgPromoteToPrivilegedContractResponse](#publicawesome.stargaze.cron.v1.MsgPromoteToPrivilegedContractResponse) | | | -| `DemoteFromPrivilegedContract` | [MsgDemoteFromPrivilegedContract](#publicawesome.stargaze.cron.v1.MsgDemoteFromPrivilegedContract) | [MsgDemoteFromPrivilegedContractResponse](#publicawesome.stargaze.cron.v1.MsgDemoteFromPrivilegedContractResponse) | | | -| `UpdateParams` | [MsgUpdateParams](#publicawesome.stargaze.cron.v1.MsgUpdateParams) | [MsgUpdateParamsResponse](#publicawesome.stargaze.cron.v1.MsgUpdateParamsResponse) | | | +| `CreateVestingAccount` | [MsgCreateVestingAccount](#publicawesome.stargaze.alloc.v1beta1.MsgCreateVestingAccount) | [MsgCreateVestingAccountResponse](#publicawesome.stargaze.alloc.v1beta1.MsgCreateVestingAccountResponse) | CreateVestingAccount defines a method that enables creating a vesting account. | | +| `FundFairburnPool` | [MsgFundFairburnPool](#publicawesome.stargaze.alloc.v1beta1.MsgFundFairburnPool) | [MsgFundFairburnPoolResponse](#publicawesome.stargaze.alloc.v1beta1.MsgFundFairburnPoolResponse) | FundFairburnPool defines a method to allow an account to directly fund the fee collector module account. | | diff --git a/proto/publicawesome/stargaze/authority/v1/query.proto b/proto/publicawesome/stargaze/authority/v1/query.proto new file mode 100644 index 000000000..9671a4770 --- /dev/null +++ b/proto/publicawesome/stargaze/authority/v1/query.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package publicawesome.stargaze.authority.v1; + +import "google/api/annotations.proto"; +import "publicawesome/stargaze/authority/v1/authority.proto"; + +option go_package = "github.com/public-awesome/stargaze/v13/x/authority/types"; + +// Query defines the gRPC querier service. +service Query { + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/stargaze/authority/v1/params"; + } +} + +message QueryParamsRequest {} + +message QueryParamsResponse { Params params = 1; } \ No newline at end of file diff --git a/x/authority/client/cli/query.go b/x/authority/client/cli/query.go new file mode 100644 index 000000000..21c7eab77 --- /dev/null +++ b/x/authority/client/cli/query.go @@ -0,0 +1,56 @@ +package cli + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + + "github.com/public-awesome/stargaze/v13/x/authority/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(_ string) *cobra.Command { + // Group cron queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(GetCmdParams()) + // this line is used by starport scaffolding # 1 + + return cmd +} + +// GetCmdParams displays the module params +func GetCmdParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "Query the module params", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.Params( + cmd.Context(), + &types.QueryParamsRequest{}, + ) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} diff --git a/x/authority/keeper/grpc_query.go b/x/authority/keeper/grpc_query.go new file mode 100644 index 000000000..d0d54651d --- /dev/null +++ b/x/authority/keeper/grpc_query.go @@ -0,0 +1,27 @@ +package keeper + +import ( + "context" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/public-awesome/stargaze/v13/x/authority/types" +) + +var _ types.QueryServer = Keeper{} + +// Params fetches all the params of x/authority module +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) + params := k.GetParams(ctx) + + return &types.QueryParamsResponse{ + Params: ¶ms, + }, nil +} diff --git a/x/authority/keeper/msg_server.go b/x/authority/keeper/msg_server.go index cf468e469..f579edf4c 100644 --- a/x/authority/keeper/msg_server.go +++ b/x/authority/keeper/msg_server.go @@ -3,7 +3,6 @@ package keeper import ( "context" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/public-awesome/stargaze/v13/x/authority/types" ) @@ -34,11 +33,6 @@ func (m msgServer) ExecuteProposal(goCtx context.Context, msg *types.MsgExecuteP return nil, err } - valid, err := m.Keeper.IsAuthorized(ctx, proposalMsgs, msg.GetAuthority()) - if !valid { - return nil, err - } - _, err = m.Keeper.SubmitProposal(ctx, proposalMsgs, proposer) if err != nil { return nil, err @@ -46,20 +40,3 @@ func (m msgServer) ExecuteProposal(goCtx context.Context, msg *types.MsgExecuteP return &types.MsgExecuteProposalResponse{}, nil } - -func (keeper Keeper) IsAuthorized(ctx sdk.Context, msgs []sdk.Msg, proposer string) (bool, error) { - authorizations := keeper.GetParams(ctx).Authorizations - for _, msg := range msgs { // Checking authorizations for all the msgs in the proposal - msgType := sdk.MsgTypeURL(msg) - auth, found := types.GetMsgAuthorization(msgType, authorizations) - if !found { - return false, errorsmod.Wrap(types.ErrAuthorizationNotFound, "authorization not found for given msg type: "+msgType) - } - - if !auth.IsAuthorized(proposer) { - return false, errorsmod.Wrap(types.ErrUnauthorized, "authority address is not authorized address to ") - } - - } - return true, nil -} diff --git a/x/authority/keeper/params.go b/x/authority/keeper/params.go index 3001df218..84510af40 100644 --- a/x/authority/keeper/params.go +++ b/x/authority/keeper/params.go @@ -18,12 +18,13 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { // GetParams returns the total set of minting parameters. func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ParamsKey) - if bz == nil { - return params - } + // store := ctx.KVStore(k.storeKey) + // bz := store.Get(types.ParamsKey) + // if bz == nil { + // return params + // } - k.cdc.MustUnmarshal(bz, ¶ms) - return params + // k.cdc.MustUnmarshal(bz, ¶ms) + //return params + return types.DefaultParams() } diff --git a/x/authority/keeper/proposal.go b/x/authority/keeper/proposal.go index 2a91b1e9f..8ce60167d 100644 --- a/x/authority/keeper/proposal.go +++ b/x/authority/keeper/proposal.go @@ -6,8 +6,9 @@ import ( errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/gov/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govV1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "github.com/public-awesome/stargaze/v13/x/authority/types" ) // IterateActiveProposalsQueue iterates over the proposals in the active proposal queue @@ -17,7 +18,7 @@ func (k Keeper) IterateActiveProposalsQueue(ctx sdk.Context, cb func(proposal go defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - proposalID := types.GetProposalIDFromBytes(iterator.Value()) + proposalID := govtypes.GetProposalIDFromBytes(iterator.Value()) proposal, found := k.GetProposal(ctx, proposalID) if !found { panic(fmt.Sprintf("proposal %d does not exist", proposalID)) @@ -31,7 +32,7 @@ func (k Keeper) IterateActiveProposalsQueue(ctx sdk.Context, cb func(proposal go // ActiveProposalQueueIterator returns an sdk.Iterator for all the proposals in the Active Queue func (k Keeper) ActiveProposalQueueIterator(ctx sdk.Context) sdk.Iterator { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.ActiveProposalQueuePrefix) + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), govtypes.ActiveProposalQueuePrefix) return prefixStore.Iterator(nil, nil) } @@ -39,7 +40,7 @@ func (k Keeper) ActiveProposalQueueIterator(ctx sdk.Context) sdk.Iterator { func (k Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (govV1.Proposal, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ProposalKey(proposalID)) + bz := store.Get(govtypes.ProposalKey(proposalID)) if bz == nil { return govV1.Proposal{}, false } @@ -81,27 +82,32 @@ func (keeper Keeper) SubmitProposal(ctx sdk.Context, messages []sdk.Msg, propose // perform a basic validation of the message if err := msg.ValidateBasic(); err != nil { - return 0, errorsmod.Wrap(types.ErrInvalidProposalMsg, err.Error()) + return 0, errorsmod.Wrap(govtypes.ErrInvalidProposalMsg, err.Error()) } signers := msg.GetSigners() if len(signers) != 1 { - return 0, types.ErrInvalidSigner + return 0, govtypes.ErrInvalidSigner } - // // assert that the governance module account is the only signer of the messages + // // assert that the authority module account is the only signer of the messages // if !signers[0].Equals(keeper.GetGovernanceAccount(ctx).GetAddress()) { // return v1.Proposal{}, sdkerrors.Wrapf(types.ErrInvalidSigner, signers[0].String()) // } + valid, err := keeper.IsAuthorized(ctx, msg, proposer.String()) + if !valid { + return 0, err + } + // use the msg service router to see that there is a valid route for that message. handler := keeper.router.Handler(msg) if handler == nil { - return 0, errorsmod.Wrap(types.ErrUnroutableProposalMsg, sdk.MsgTypeURL(msg)) + return 0, errorsmod.Wrap(govtypes.ErrUnroutableProposalMsg, sdk.MsgTypeURL(msg)) } var res *sdk.Result - res, err := handler(ctx, msg) + res, err = handler(ctx, msg) if err != nil { return 0, err } @@ -113,6 +119,20 @@ func (keeper Keeper) SubmitProposal(ctx sdk.Context, messages []sdk.Msg, propose return 0, nil } +func (keeper Keeper) IsAuthorized(ctx sdk.Context, msg sdk.Msg, proposer string) (bool, error) { + authorizations := keeper.GetParams(ctx).Authorizations + msgType := sdk.MsgTypeURL(msg) + auth, found := types.GetMsgAuthorization(msgType, authorizations) + if !found { + return false, errorsmod.Wrap(types.ErrAuthorizationNotFound, "authorization not found for given msg type: "+msgType) + } + + if !auth.IsAuthorized(proposer) { + return false, errorsmod.Wrap(govtypes.ErrInvalidSigner, "sender address"+proposer+" is not authorized address to execute"+msgType) + } + return true, nil +} + // // SetProposal set a proposal to store // func (k Keeper) SetProposal(ctx sdk.Context, proposal govV1.Proposal) { // store := ctx.KVStore(k.storeKey) diff --git a/x/authority/module.go b/x/authority/module.go index 693eaa1c9..27f4a376e 100644 --- a/x/authority/module.go +++ b/x/authority/module.go @@ -1,6 +1,7 @@ package authority import ( + "context" "encoding/json" "fmt" @@ -70,10 +71,10 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingCo // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - // err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) - // if err != nil { - // panic(err) - // } + err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err != nil { + panic(err) + } } // GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module @@ -83,7 +84,7 @@ func (a AppModuleBasic) GetTxCmd() *cobra.Command { // GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return nil //cli.GetQueryCmd(types.StoreKey) + return cli.GetQueryCmd(types.StoreKey) } // ---------------------------------------------------------------------------- @@ -111,7 +112,7 @@ func (AppModule) QuerierRoute() string { return types.RouterKey } // RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries func (am AppModule) RegisterServices(cfg module.Configurator) { - //types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) } diff --git a/x/authority/types/authority.pb.go b/x/authority/types/authority.pb.go index 6ec041330..62bdf05e4 100644 --- a/x/authority/types/authority.pb.go +++ b/x/authority/types/authority.pb.go @@ -69,7 +69,7 @@ func (m *Params) GetAuthorizations() []*Authorization { type Authorization struct { MsgTypeUrl string `protobuf:"bytes,1,opt,name=msgTypeUrl,proto3" json:"msgTypeUrl,omitempty"` - Address []string `protobuf:"bytes,2,rep,name=address,proto3" json:"address,omitempty"` + Addresses []string `protobuf:"bytes,2,rep,name=addresses,proto3" json:"addresses,omitempty"` } func (m *Authorization) Reset() { *m = Authorization{} } @@ -112,9 +112,9 @@ func (m *Authorization) GetMsgTypeUrl() string { return "" } -func (m *Authorization) GetAddress() []string { +func (m *Authorization) GetAddresses() []string { if m != nil { - return m.Address + return m.Addresses } return nil } @@ -129,7 +129,7 @@ func init() { } var fileDescriptor_6e13d9034052c38a = []byte{ - // 255 bytes of a gzipped FileDescriptorProto + // 257 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x2e, 0x28, 0x4d, 0xca, 0xc9, 0x4c, 0x4e, 0x2c, 0x4f, 0x2d, 0xce, 0xcf, 0x4d, 0xd5, 0x2f, 0x2e, 0x49, 0x2c, 0x4a, 0x4f, 0xac, 0x4a, 0xd5, 0x4f, 0x2c, 0x2d, 0xc9, 0xc8, 0x2f, 0xca, 0x2c, 0xa9, 0xd4, 0x2f, 0x33, 0x44, @@ -138,14 +138,15 @@ var fileDescriptor_6e13d9034052c38a = []byte{ 0x4a, 0x59, 0x5c, 0x6c, 0x01, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x42, 0x51, 0x5c, 0x7c, 0x50, 0xf5, 0x55, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xc5, 0x12, 0x8c, 0x0a, 0xcc, 0x1a, 0xdc, 0x46, 0x46, 0x7a, 0x44, 0x98, 0xae, 0xe7, 0x88, 0xac, 0x35, 0x08, 0xcd, 0x24, 0x2b, 0x96, 0x19, 0x0b, 0xe4, 0x19, - 0x94, 0x3c, 0xb9, 0x78, 0x51, 0x94, 0x09, 0xc9, 0x71, 0x71, 0xe5, 0x16, 0xa7, 0x87, 0x54, 0x16, - 0xa4, 0x86, 0x16, 0xe5, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x21, 0x89, 0x08, 0x49, 0x70, - 0xb1, 0x27, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x4b, 0x30, 0x29, 0x30, 0x6b, 0x70, 0x06, 0xc1, - 0xb8, 0x4e, 0x41, 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, 0x91, 0x9e, - 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x71, 0xb8, 0x2e, 0x46, 0x60, 0x96, - 0x19, 0x1a, 0xeb, 0x57, 0x20, 0x05, 0x69, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x44, - 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x40, 0xaf, 0xaf, 0x43, 0x83, 0x01, 0x00, 0x00, + 0x94, 0x7c, 0xb9, 0x78, 0x51, 0x94, 0x09, 0xc9, 0x71, 0x71, 0xe5, 0x16, 0xa7, 0x87, 0x54, 0x16, + 0xa4, 0x86, 0x16, 0xe5, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x21, 0x89, 0x08, 0xc9, 0x70, + 0x71, 0x26, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0xa7, 0x16, 0x4b, 0x30, 0x29, 0x30, 0x6b, 0x70, + 0x06, 0x21, 0x04, 0x9c, 0x82, 0x4e, 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, + 0x22, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xe2, 0x78, 0x5d, 0x8c, + 0x00, 0x2d, 0x33, 0x34, 0xd6, 0xaf, 0x40, 0x0a, 0xd6, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, + 0x70, 0xa8, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xad, 0x2e, 0x16, 0xa1, 0x87, 0x01, 0x00, + 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -205,11 +206,11 @@ func (m *Authorization) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Address) > 0 { - for iNdEx := len(m.Address) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Address[iNdEx]) - copy(dAtA[i:], m.Address[iNdEx]) - i = encodeVarintAuthority(dAtA, i, uint64(len(m.Address[iNdEx]))) + if len(m.Addresses) > 0 { + for iNdEx := len(m.Addresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Addresses[iNdEx]) + copy(dAtA[i:], m.Addresses[iNdEx]) + i = encodeVarintAuthority(dAtA, i, uint64(len(m.Addresses[iNdEx]))) i-- dAtA[i] = 0x12 } @@ -260,8 +261,8 @@ func (m *Authorization) Size() (n int) { if l > 0 { n += 1 + l + sovAuthority(uint64(l)) } - if len(m.Address) > 0 { - for _, s := range m.Address { + if len(m.Addresses) > 0 { + for _, s := range m.Addresses { l = len(s) n += 1 + l + sovAuthority(uint64(l)) } @@ -422,7 +423,7 @@ func (m *Authorization) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Addresses", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -450,7 +451,7 @@ func (m *Authorization) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = append(m.Address, string(dAtA[iNdEx:postIndex])) + m.Addresses = append(m.Addresses, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/authority/types/authorization.go b/x/authority/types/authorization.go index 4b1415417..1df854b5f 100644 --- a/x/authority/types/authorization.go +++ b/x/authority/types/authorization.go @@ -16,7 +16,7 @@ func GetMsgAuthorization(msgTypeUrl string, authorizations []*Authorization) (*A } func (a Authorization) IsAuthorized(proposer string) bool { - for _, addr := range a.Address { + for _, addr := range a.GetAddresses() { if addr == proposer { return true } @@ -25,10 +25,10 @@ func (a Authorization) IsAuthorized(proposer string) bool { } func (a Authorization) Validate() error { - if len(a.Address) == 0 { + if len(a.GetAddresses()) == 0 { return fmt.Errorf("addresses cannot be empty") } - for _, addr := range a.Address { + for _, addr := range a.GetAddresses() { _, err := sdk.AccAddressFromBech32(addr) if err != nil { return err diff --git a/x/authority/types/params.go b/x/authority/types/params.go index 6d69672e5..5b7be16ed 100644 --- a/x/authority/types/params.go +++ b/x/authority/types/params.go @@ -7,7 +7,16 @@ import ( // default module parameters func DefaultParams() Params { return Params{ - Authorizations: []*Authorization{}, + Authorizations: []*Authorization{ + { + MsgTypeUrl: "/cosmos.distribution.v1beta1.MsgCommunityPoolSpend", + Addresses: []string{"stars1x394ype3x8nt9wz0j78m8c8kcezpslrcjmmrc0"}, + }, + { + MsgTypeUrl: "/cosmwasm.wasm.v1.MsgUpdateParams", + Addresses: []string{"stars1mzgucqnfr2l8cj5apvdpllhzt4zeuh2cyt4fdd"}, + }, + }, } } diff --git a/x/authority/types/params_test.go b/x/authority/types/params_test.go index 3a7269704..05b9f5397 100644 --- a/x/authority/types/params_test.go +++ b/x/authority/types/params_test.go @@ -23,7 +23,7 @@ func TestParamsValidate(t *testing.T) { types.Params{ Authorizations: []*types.Authorization{ { - Address: []string{}, + Addresses: []string{}, MsgTypeUrl: "/cosmos.distribution.v1beta1.MsgCommunityPoolSpend", }, }, @@ -35,7 +35,7 @@ func TestParamsValidate(t *testing.T) { types.Params{ Authorizations: []*types.Authorization{ { - Address: []string{ + Addresses: []string{ "👻", }, MsgTypeUrl: "/cosmos.distribution.v1beta1.MsgCommunityPoolSpend", @@ -49,7 +49,7 @@ func TestParamsValidate(t *testing.T) { types.Params{ Authorizations: []*types.Authorization{ { - Address: []string{ + Addresses: []string{ "cosmos1c4k24jzduc365kywrsvf5ujz4ya6mwymy8vq4q", }, MsgTypeUrl: "", @@ -63,7 +63,7 @@ func TestParamsValidate(t *testing.T) { types.Params{ Authorizations: []*types.Authorization{ { - Address: []string{ + Addresses: []string{ "cosmos1c4k24jzduc365kywrsvf5ujz4ya6mwymy8vq4q", }, MsgTypeUrl: "/cosmos.distribution.v1beta1.MsgCommunityPoolSpend", diff --git a/x/authority/types/query.pb.go b/x/authority/types/query.pb.go new file mode 100644 index 000000000..f84dedbe3 --- /dev/null +++ b/x/authority/types/query.pb.go @@ -0,0 +1,538 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: publicawesome/stargaze/authority/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type 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_fabfb73dd8f1f863, []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 + +type QueryParamsResponse struct { + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` +} + +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_fabfb73dd8f1f863, []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 nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "publicawesome.stargaze.authority.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "publicawesome.stargaze.authority.v1.QueryParamsResponse") +} + +func init() { + proto.RegisterFile("publicawesome/stargaze/authority/v1/query.proto", fileDescriptor_fabfb73dd8f1f863) +} + +var fileDescriptor_fabfb73dd8f1f863 = []byte{ + // 283 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2f, 0x28, 0x4d, 0xca, + 0xc9, 0x4c, 0x4e, 0x2c, 0x4f, 0x2d, 0xce, 0xcf, 0x4d, 0xd5, 0x2f, 0x2e, 0x49, 0x2c, 0x4a, 0x4f, + 0xac, 0x4a, 0xd5, 0x4f, 0x2c, 0x2d, 0xc9, 0xc8, 0x2f, 0xca, 0x2c, 0xa9, 0xd4, 0x2f, 0x33, 0xd4, + 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x46, 0xd1, 0xa0, + 0x07, 0xd3, 0xa0, 0x07, 0xd7, 0xa0, 0x57, 0x66, 0x28, 0x25, 0x93, 0x9e, 0x9f, 0x9f, 0x9e, 0x93, + 0xaa, 0x9f, 0x58, 0x90, 0xa9, 0x9f, 0x98, 0x97, 0x97, 0x5f, 0x92, 0x58, 0x92, 0x99, 0x9f, 0x57, + 0x0c, 0x31, 0x42, 0xca, 0x98, 0x18, 0x3b, 0x11, 0xe6, 0x81, 0x35, 0x29, 0x89, 0x70, 0x09, 0x05, + 0x82, 0x9c, 0x11, 0x90, 0x58, 0x94, 0x98, 0x5b, 0x1c, 0x94, 0x5a, 0x58, 0x9a, 0x5a, 0x5c, 0xa2, + 0x14, 0xc5, 0x25, 0x8c, 0x22, 0x5a, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x2a, 0xe4, 0xcc, 0xc5, 0x56, + 0x00, 0x16, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x36, 0xd2, 0xd6, 0x23, 0xc2, 0xd5, 0x7a, 0x50, + 0x43, 0xa0, 0x5a, 0x8d, 0xd6, 0x30, 0x72, 0xb1, 0x82, 0x0d, 0x17, 0x5a, 0xc4, 0xc8, 0xc5, 0x06, + 0x91, 0x14, 0x32, 0x27, 0xca, 0x24, 0x4c, 0x97, 0x4a, 0x59, 0x90, 0xae, 0x11, 0xe2, 0x19, 0x25, + 0xd5, 0xa6, 0xcb, 0x4f, 0x26, 0x33, 0xc9, 0x0b, 0xc9, 0xe2, 0x08, 0x29, 0x88, 0x73, 0x9d, 0x82, + 0x4e, 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, 0x22, 0x3d, 0xb3, 0x24, 0xa3, + 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x17, 0x1a, 0xdd, 0xba, 0x18, 0x61, 0x5f, 0x66, 0x68, 0xac, 0x5f, + 0x81, 0x64, 0x6e, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0xec, 0x8d, 0x01, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x59, 0xf5, 0xcf, 0xa5, 0x26, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/publicawesome.stargaze.authority.v1.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: "/publicawesome.stargaze.authority.v1.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: "publicawesome.stargaze.authority.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "publicawesome/stargaze/authority/v1/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 + if m.Params != nil { + { + 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 + if m.Params != nil { + 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 m.Params == nil { + m.Params = &Params{} + } + 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/authority/types/query.pb.gw.go b/x/authority/types/query.pb.gw.go new file mode 100644 index 000000000..49c32c073 --- /dev/null +++ b/x/authority/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: publicawesome/stargaze/authority/v1/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, 2, 2, 2, 3}, []string{"stargaze", "authority", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) From c6d85185d24a614d328b951226e45e0fcca80353 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Thu, 2 Nov 2023 18:19:40 +0000 Subject: [PATCH 06/20] adding genesis --- docs/proto/proto-docs.md | 157 ++++++------------ .../stargaze/authority/v1/genesis.proto | 8 +- x/authority/client/cli/query.go | 1 - x/authority/types/genesis.pb.go | 72 +++++++- 4 files changed, 121 insertions(+), 117 deletions(-) diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index f0e20217d..89de7a7b2 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -4,84 +4,61 @@ ## Table of Contents -- [publicawesome/stargaze/alloc/v1beta1/params.proto](#publicawesome/stargaze/alloc/v1beta1/params.proto) - - [DistributionProportions](#publicawesome.stargaze.alloc.v1beta1.DistributionProportions) - - [Params](#publicawesome.stargaze.alloc.v1beta1.Params) - - [WeightedAddress](#publicawesome.stargaze.alloc.v1beta1.WeightedAddress) +- [publicawesome/stargaze/authority/v1/authority.proto](#publicawesome/stargaze/authority/v1/authority.proto) + - [Authorization](#publicawesome.stargaze.authority.v1.Authorization) + - [Params](#publicawesome.stargaze.authority.v1.Params) -- [publicawesome/stargaze/alloc/v1beta1/genesis.proto](#publicawesome/stargaze/alloc/v1beta1/genesis.proto) - - [GenesisState](#publicawesome.stargaze.alloc.v1beta1.GenesisState) +- [publicawesome/stargaze/authority/v1/genesis.proto](#publicawesome/stargaze/authority/v1/genesis.proto) + - [GenesisState](#publicawesome.stargaze.authority.v1.GenesisState) -- [publicawesome/stargaze/alloc/v1beta1/query.proto](#publicawesome/stargaze/alloc/v1beta1/query.proto) - - [QueryParamsRequest](#publicawesome.stargaze.alloc.v1beta1.QueryParamsRequest) - - [QueryParamsResponse](#publicawesome.stargaze.alloc.v1beta1.QueryParamsResponse) +- [publicawesome/stargaze/authority/v1/query.proto](#publicawesome/stargaze/authority/v1/query.proto) + - [QueryParamsRequest](#publicawesome.stargaze.authority.v1.QueryParamsRequest) + - [QueryParamsResponse](#publicawesome.stargaze.authority.v1.QueryParamsResponse) - - [Query](#publicawesome.stargaze.alloc.v1beta1.Query) + - [Query](#publicawesome.stargaze.authority.v1.Query) -- [publicawesome/stargaze/alloc/v1beta1/tx.proto](#publicawesome/stargaze/alloc/v1beta1/tx.proto) - - [MsgCreateVestingAccount](#publicawesome.stargaze.alloc.v1beta1.MsgCreateVestingAccount) - - [MsgCreateVestingAccountResponse](#publicawesome.stargaze.alloc.v1beta1.MsgCreateVestingAccountResponse) - - [MsgFundFairburnPool](#publicawesome.stargaze.alloc.v1beta1.MsgFundFairburnPool) - - [MsgFundFairburnPoolResponse](#publicawesome.stargaze.alloc.v1beta1.MsgFundFairburnPoolResponse) +- [publicawesome/stargaze/authority/v1/tx.proto](#publicawesome/stargaze/authority/v1/tx.proto) + - [MsgExecuteProposal](#publicawesome.stargaze.authority.v1.MsgExecuteProposal) + - [MsgExecuteProposalResponse](#publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse) - - [Msg](#publicawesome.stargaze.alloc.v1beta1.Msg) + - [Msg](#publicawesome.stargaze.authority.v1.Msg) - [Scalar Value Types](#scalar-value-types) - +

Top

-## publicawesome/stargaze/alloc/v1beta1/params.proto +## publicawesome/stargaze/authority/v1/authority.proto - + -### DistributionProportions +### Authorization | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `nft_incentives` | [string](#string) | | | -| `developer_rewards` | [string](#string) | | | -| `community_pool` | [string](#string) | | | +| `msgTypeUrl` | [string](#string) | | The type url of a proposal sdk.Msg | +| `addresses` | [string](#string) | repeated | The addresses who are allowed to execute that proposal | - + ### Params - +Params holds parameters for the authority module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `distribution_proportions` | [DistributionProportions](#publicawesome.stargaze.alloc.v1beta1.DistributionProportions) | | distribution_proportions defines the proportion of the minted denom | -| `weighted_developer_rewards_receivers` | [WeightedAddress](#publicawesome.stargaze.alloc.v1beta1.WeightedAddress) | repeated | addresses to receive developer rewards | -| `weighted_incentives_rewards_receivers` | [WeightedAddress](#publicawesome.stargaze.alloc.v1beta1.WeightedAddress) | repeated | addresses to receive incentive rewards | -| `supplement_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | SupplementAmount is the amount to be supplemented from the pool on top of newly minted coins. | - - - - - - - - -### WeightedAddress - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | | -| `weight` | [string](#string) | | | +| `authorizations` | [Authorization](#publicawesome.stargaze.authority.v1.Authorization) | repeated | | @@ -97,22 +74,22 @@ - +

Top

-## publicawesome/stargaze/alloc/v1beta1/genesis.proto +## publicawesome/stargaze/authority/v1/genesis.proto - + ### GenesisState -GenesisState defines the alloc module's genesis state. + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#publicawesome.stargaze.alloc.v1beta1.Params) | | this line is used by starport scaffolding # genesis/proto/state | +| `params` | [Params](#publicawesome.stargaze.authority.v1.Params) | | | @@ -128,32 +105,32 @@ GenesisState defines the alloc module's genesis state. - +

Top

-## publicawesome/stargaze/alloc/v1beta1/query.proto +## publicawesome/stargaze/authority/v1/query.proto - + ### QueryParamsRequest -QueryParamsRequest is the request type for the Query/Params RPC method. - + + ### QueryParamsResponse -QueryParamsResponse is the response type for the Query/Params RPC method. + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#publicawesome.stargaze.alloc.v1beta1.Params) | | params defines the parameters of the module. | +| `params` | [Params](#publicawesome.stargaze.authority.v1.Params) | | | @@ -166,80 +143,47 @@ QueryParamsResponse is the response type for the Query/Params RPC method. - + ### Query Query defines the gRPC querier service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Params` | [QueryParamsRequest](#publicawesome.stargaze.alloc.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.alloc.v1beta1.QueryParamsResponse) | this line is used by starport scaffolding # 2 | GET|/stargaze/alloc/v1beta1/params| +| `Params` | [QueryParamsRequest](#publicawesome.stargaze.authority.v1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.authority.v1.QueryParamsResponse) | | GET|/stargaze/authority/v1/params| - +

Top

-## publicawesome/stargaze/alloc/v1beta1/tx.proto - - - - - -### MsgCreateVestingAccount -MsgCreateVestingAccount defines a message that enables creating a vesting -account. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `from_address` | [string](#string) | | | -| `to_address` | [string](#string) | | | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | -| `start_time` | [int64](#int64) | | | -| `end_time` | [int64](#int64) | | | -| `delayed` | [bool](#bool) | | | - - - - - - - - -### MsgCreateVestingAccountResponse -MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response -type. - - - +## publicawesome/stargaze/authority/v1/tx.proto - + -### MsgFundFairburnPool -MsgFundFairburnPool allows an account to directly -fund the fee collector pool. +### MsgExecuteProposal +MsgExecuteProposal defines an sdk.Msg type that supports submitting arbitrary +proposal Content. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `sender` | [string](#string) | | | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `authority` | [string](#string) | | | +| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | - + -### MsgFundFairburnPoolResponse -MsgFundFairburnPoolResponse defines the Msg/MsgFundFairburnPool response -type. +### MsgExecuteProposalResponse +MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. @@ -252,15 +196,14 @@ type. - + ### Msg -Msg defines the alloc Msg service. +Msg defines the authority Msg service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `CreateVestingAccount` | [MsgCreateVestingAccount](#publicawesome.stargaze.alloc.v1beta1.MsgCreateVestingAccount) | [MsgCreateVestingAccountResponse](#publicawesome.stargaze.alloc.v1beta1.MsgCreateVestingAccountResponse) | CreateVestingAccount defines a method that enables creating a vesting account. | | -| `FundFairburnPool` | [MsgFundFairburnPool](#publicawesome.stargaze.alloc.v1beta1.MsgFundFairburnPool) | [MsgFundFairburnPoolResponse](#publicawesome.stargaze.alloc.v1beta1.MsgFundFairburnPoolResponse) | FundFairburnPool defines a method to allow an account to directly fund the fee collector module account. | | +| `ExecuteProposal` | [MsgExecuteProposal](#publicawesome.stargaze.authority.v1.MsgExecuteProposal) | [MsgExecuteProposalResponse](#publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse) | | | diff --git a/proto/publicawesome/stargaze/authority/v1/genesis.proto b/proto/publicawesome/stargaze/authority/v1/genesis.proto index 336d3dcfb..57674db2c 100644 --- a/proto/publicawesome/stargaze/authority/v1/genesis.proto +++ b/proto/publicawesome/stargaze/authority/v1/genesis.proto @@ -2,7 +2,13 @@ syntax = "proto3"; package publicawesome.stargaze.authority.v1; import "gogoproto/gogo.proto"; +import "publicawesome/stargaze/authority/v1/authority.proto"; option go_package = "github.com/public-awesome/stargaze/v13/x/authority/types"; -message GenesisState {} \ No newline at end of file +message GenesisState { + Params params = 1 [ + (gogoproto.jsontag) = "params,omitempty", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/x/authority/client/cli/query.go b/x/authority/client/cli/query.go index 21c7eab77..e1e802ba4 100644 --- a/x/authority/client/cli/query.go +++ b/x/authority/client/cli/query.go @@ -23,7 +23,6 @@ func GetQueryCmd(_ string) *cobra.Command { } cmd.AddCommand(GetCmdParams()) - // this line is used by starport scaffolding # 1 return cmd } diff --git a/x/authority/types/genesis.pb.go b/x/authority/types/genesis.pb.go index 023a19892..53f979f30 100644 --- a/x/authority/types/genesis.pb.go +++ b/x/authority/types/genesis.pb.go @@ -24,6 +24,7 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -59,6 +60,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), "publicawesome.stargaze.authority.v1.GenesisState") } @@ -68,19 +76,22 @@ func init() { } var fileDescriptor_f6ae0642d48c5a1e = []byte{ - // 177 bytes of a gzipped FileDescriptorProto + // 237 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x2c, 0x28, 0x4d, 0xca, 0xc9, 0x4c, 0x4e, 0x2c, 0x4f, 0x2d, 0xce, 0xcf, 0x4d, 0xd5, 0x2f, 0x2e, 0x49, 0x2c, 0x4a, 0x4f, 0xac, 0x4a, 0xd5, 0x4f, 0x2c, 0x2d, 0xc9, 0xc8, 0x2f, 0xca, 0x2c, 0xa9, 0xd4, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x46, 0xd1, 0xa2, 0x07, 0xd3, 0xa2, 0x07, 0xd7, 0xa2, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, 0x9e, - 0x0f, 0x56, 0xaf, 0x0f, 0x62, 0x41, 0xb4, 0x2a, 0xf1, 0x71, 0xf1, 0xb8, 0x43, 0xcc, 0x0a, 0x2e, - 0x49, 0x2c, 0x49, 0x75, 0x0a, 0x3a, 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, - 0x8b, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x88, 0x7d, 0xba, 0x18, - 0x6e, 0x2c, 0x33, 0x34, 0xd6, 0xaf, 0x40, 0x72, 0x69, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, - 0xd8, 0x2a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x33, 0x62, 0xe5, 0xae, 0xda, 0x00, 0x00, - 0x00, + 0x0f, 0x56, 0xaf, 0x0f, 0x62, 0x41, 0xb4, 0x4a, 0x19, 0x13, 0x63, 0x1b, 0xc2, 0x1c, 0xb0, 0x26, + 0xa5, 0x5c, 0x2e, 0x1e, 0x77, 0x88, 0x03, 0x82, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0x62, 0xb9, 0xd8, + 0x0a, 0x12, 0x8b, 0x12, 0x73, 0x8b, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0xb4, 0xf5, 0x88, + 0x70, 0x90, 0x5e, 0x00, 0x58, 0x8b, 0x93, 0xc4, 0x89, 0x7b, 0xf2, 0x0c, 0xaf, 0xee, 0xc9, 0x0b, + 0x40, 0x8c, 0xd0, 0xc9, 0xcf, 0xcd, 0x2c, 0x49, 0xcd, 0x2d, 0x28, 0xa9, 0x0c, 0x82, 0x1a, 0xea, + 0x14, 0x74, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, + 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x16, 0xe9, 0x99, 0x25, + 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x10, 0x2b, 0x75, 0x31, 0x7c, 0x52, 0x66, 0x68, + 0xac, 0x5f, 0x81, 0xe4, 0x9f, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x4f, 0x8c, 0x01, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x0e, 0xa5, 0xee, 0xe8, 0x6e, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -103,6 +114,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 } @@ -123,6 +144,8 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -161,6 +184,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:]) From 753446d703c7f09e39259404a2b42b9916671475 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Thu, 2 Nov 2023 18:23:23 +0000 Subject: [PATCH 07/20] implement init/export genesis --- x/authority/genesis.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/x/authority/genesis.go b/x/authority/genesis.go index 4e4030112..50b5d9ce7 100644 --- a/x/authority/genesis.go +++ b/x/authority/genesis.go @@ -6,12 +6,20 @@ import ( "github.com/public-awesome/stargaze/v13/x/authority/types" ) -// InitGenesis initializes the capability module's state from a provided genesis +// InitGenesis initializes the authority module's state from a provided genesis // state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + params := genState.Params + err := k.SetParams(ctx, params) + if err != nil { + panic(err) + } } -// ExportGenesis returns the capability module's exported genesis. +// ExportGenesis returns the authority module's exported genesis. func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { - return &types.GenesisState{} + params := k.GetParams(ctx) + return &types.GenesisState{ + Params: params, + } } From 4eba7016102eb5acc03ad8835a45e9e7fa30ae2b Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Thu, 2 Nov 2023 21:03:48 +0000 Subject: [PATCH 08/20] cleaning up unused code --- x/authority/abci.go | 78 --------------------- x/authority/keeper/msg_server.go | 2 +- x/authority/keeper/proposal.go | 117 ++----------------------------- x/authority/module.go | 1 - 4 files changed, 7 insertions(+), 191 deletions(-) delete mode 100644 x/authority/abci.go diff --git a/x/authority/abci.go b/x/authority/abci.go deleted file mode 100644 index 2e9a87156..000000000 --- a/x/authority/abci.go +++ /dev/null @@ -1,78 +0,0 @@ -package authority - -import ( - "fmt" - "time" - - "github.com/cosmos/cosmos-sdk/telemetry" - sdk "github.com/cosmos/cosmos-sdk/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - govV1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - "github.com/public-awesome/stargaze/v13/x/authority/keeper" - "github.com/public-awesome/stargaze/v13/x/authority/types" -) - -// EndBlocker called every block, process inflation, update validator set. -func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) { - defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) - logger := keeper.Logger(ctx) - - keeper.IterateActiveProposalsQueue(ctx, func(proposal govV1.Proposal) bool { - var logMsg, tagValue string - - var ( - idx int - events sdk.Events - msg sdk.Msg - ) - - cacheCtx, writeCache := ctx.CacheContext() - messages, err := proposal.GetMsgs() - if err == nil { - for idx, msg = range messages { - handler := keeper.Router().Handler(msg) - - var res *sdk.Result - res, err = handler(cacheCtx, msg) - if err != nil { - break - } - - events = append(events, res.GetEvents()...) - } - } - - if err == nil { - proposal.Status = govV1.StatusPassed - tagValue = govtypes.AttributeValueProposalPassed - logMsg = "passed" - - // write state to the underlying multi-store - writeCache() - - // propagate the msg events to the current context - ctx.EventManager().EmitEvents(events) - } else { - proposal.Status = govV1.StatusFailed - tagValue = govtypes.AttributeValueProposalFailed - logMsg = fmt.Sprintf("passed, but msg %d (%s) failed on execution: %s", idx, sdk.MsgTypeURL(msg), err) - } - - ctx.EventManager().EmitEvent( - sdk.NewEvent( - govtypes.EventTypeActiveProposal, - sdk.NewAttribute(govtypes.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.Id)), - sdk.NewAttribute(govtypes.AttributeKeyProposalResult, tagValue), - ), - ) - - logger.Info( - "proposal tallied", - "proposal", proposal.Id, - "title", proposal.GetTitle(), - "result", logMsg, - ) - - return false - }) -} diff --git a/x/authority/keeper/msg_server.go b/x/authority/keeper/msg_server.go index f579edf4c..cbabcaa9f 100644 --- a/x/authority/keeper/msg_server.go +++ b/x/authority/keeper/msg_server.go @@ -33,7 +33,7 @@ func (m msgServer) ExecuteProposal(goCtx context.Context, msg *types.MsgExecuteP return nil, err } - _, err = m.Keeper.SubmitProposal(ctx, proposalMsgs, proposer) + _, err = m.Keeper.ExecuteProposalMessages(ctx, proposalMsgs, proposer) if err != nil { return nil, err } diff --git a/x/authority/keeper/proposal.go b/x/authority/keeper/proposal.go index 8ce60167d..7a41f13a7 100644 --- a/x/authority/keeper/proposal.go +++ b/x/authority/keeper/proposal.go @@ -1,85 +1,18 @@ package keeper import ( - "fmt" - errorsmod "cosmossdk.io/errors" - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - govV1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/public-awesome/stargaze/v13/x/authority/types" ) -// IterateActiveProposalsQueue iterates over the proposals in the active proposal queue -// and performs a callback function -func (k Keeper) IterateActiveProposalsQueue(ctx sdk.Context, cb func(proposal govV1.Proposal) (stop bool)) { - iterator := k.ActiveProposalQueueIterator(ctx) - - defer iterator.Close() - for ; iterator.Valid(); iterator.Next() { - proposalID := govtypes.GetProposalIDFromBytes(iterator.Value()) - proposal, found := k.GetProposal(ctx, proposalID) - if !found { - panic(fmt.Sprintf("proposal %d does not exist", proposalID)) - } - - if cb(proposal) { - break - } - } -} - -// ActiveProposalQueueIterator returns an sdk.Iterator for all the proposals in the Active Queue -func (k Keeper) ActiveProposalQueueIterator(ctx sdk.Context) sdk.Iterator { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), govtypes.ActiveProposalQueuePrefix) - return prefixStore.Iterator(nil, nil) -} +// ExecuteProposalMessages executes the array of messages in the proposal if their authorization matches +func (keeper Keeper) ExecuteProposalMessages(ctx sdk.Context, messages []sdk.Msg, proposer sdk.AccAddress) (uint64, error) { + var events sdk.Events -// GetProposal get proposal from store by ProposalID -func (k Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (govV1.Proposal, bool) { - store := ctx.KVStore(k.storeKey) - - bz := store.Get(govtypes.ProposalKey(proposalID)) - if bz == nil { - return govV1.Proposal{}, false - } - - var proposal govV1.Proposal - k.MustUnmarshalProposal(bz, &proposal) - - return proposal, true -} - -func (k Keeper) MustUnmarshalProposal(bz []byte, proposal *govV1.Proposal) { - err := k.UnmarshalProposal(bz, proposal) - if err != nil { - panic(err) - } -} - -func (k Keeper) UnmarshalProposal(bz []byte, proposal *govV1.Proposal) error { - err := k.cdc.Unmarshal(bz, proposal) - if err != nil { - return err - } - return nil -} - -// SubmitProposal creates a new proposal given an array of messages -func (keeper Keeper) SubmitProposal(ctx sdk.Context, messages []sdk.Msg, proposer sdk.AccAddress) (uint64, error) { - // Will hold a comma-separated string of all Msg type URLs. - msgsStr := "" - - var ( - events sdk.Events - ) - - // Loop through all messages and confirm that each has a handler and the gov module account - // as the only signer + // Loop through all messages and confirm that each has a handler and the authorizations for the msg are valid for _, msg := range messages { - msgsStr += fmt.Sprintf(",%s", sdk.MsgTypeURL(msg)) - // perform a basic validation of the message if err := msg.ValidateBasic(); err != nil { return 0, errorsmod.Wrap(govtypes.ErrInvalidProposalMsg, err.Error()) @@ -90,11 +23,6 @@ func (keeper Keeper) SubmitProposal(ctx sdk.Context, messages []sdk.Msg, propose return 0, govtypes.ErrInvalidSigner } - // // assert that the authority module account is the only signer of the messages - // if !signers[0].Equals(keeper.GetGovernanceAccount(ctx).GetAddress()) { - // return v1.Proposal{}, sdkerrors.Wrapf(types.ErrInvalidSigner, signers[0].String()) - // } - valid, err := keeper.IsAuthorized(ctx, msg, proposer.String()) if !valid { return 0, err @@ -113,9 +41,9 @@ func (keeper Keeper) SubmitProposal(ctx sdk.Context, messages []sdk.Msg, propose } events = append(events, res.GetEvents()...) - } + ctx.EventManager().EmitEvents(events) return 0, nil } @@ -128,40 +56,7 @@ func (keeper Keeper) IsAuthorized(ctx sdk.Context, msg sdk.Msg, proposer string) } if !auth.IsAuthorized(proposer) { - return false, errorsmod.Wrap(govtypes.ErrInvalidSigner, "sender address"+proposer+" is not authorized address to execute"+msgType) + return false, errorsmod.Wrap(govtypes.ErrInvalidSigner, "sender address "+proposer+" is not authorized to execute this proposal"+msgType) } return true, nil } - -// // SetProposal set a proposal to store -// func (k Keeper) SetProposal(ctx sdk.Context, proposal govV1.Proposal) { -// store := ctx.KVStore(k.storeKey) - -// bz := k.MustMarshalProposal(proposal) - -// store.Set(types.ProposalKey(proposal.Id), bz) -// } - -// // GetProposalID gets the highest proposal ID -// func (k Keeper) GetProposalID(ctx sdk.Context) (proposalID uint64, err error) { -// store := ctx.KVStore(k.storeKey) -// bz := store.Get(types.ProposalIDKey) -// if bz == nil { -// return 0, errorsmod.Wrap(types.ErrInvalidGenesis, "initial proposal ID hasn't been set") -// } - -// proposalID = types.GetProposalIDFromBytes(bz) -// return proposalID, nil -// } - -// // SetProposalID sets the new proposal ID to the store -// func (k Keeper) SetProposalID(ctx sdk.Context, proposalID uint64) { -// store := ctx.KVStore(k.storeKey) -// store.Set(types.ProposalIDKey, types.GetProposalIDBytes(proposalID)) -// } - -// // InsertActiveProposalQueue inserts a ProposalID into the active proposal queue -// func (k Keeper) InsertActiveProposalQueue(ctx sdk.Context, proposalID uint64) { -// store := ctx.KVStore(k.storeKey) -// store.Set(types.ActiveProposalQueueKey(proposalID), types.GetProposalIDBytes(proposalID)) -// } diff --git a/x/authority/module.go b/x/authority/module.go index 27f4a376e..837e9a4b6 100644 --- a/x/authority/module.go +++ b/x/authority/module.go @@ -144,6 +144,5 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {} // EndBlock contains the logic that is automatically triggered at the end of each block func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - EndBlocker(ctx, am.keeper) return []abci.ValidatorUpdate{} } From 09af932032d5dad72e98a120c909295b5adc6212 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 3 Nov 2023 11:43:59 +0000 Subject: [PATCH 09/20] adding MsgUpdateParams --- docs/proto/proto-docs.md | 334 +++++++++++--- .../stargaze/authority/v1/tx.proto | 20 +- x/authority/keeper/msg_server.go | 29 ++ x/authority/keeper/params.go | 19 +- x/authority/module.go | 2 - x/authority/types/errors.go | 2 +- x/authority/types/msgs.go | 40 ++ x/authority/types/tx.pb.go | 430 +++++++++++++++++- 8 files changed, 787 insertions(+), 89 deletions(-) diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 89de7a7b2..24f67b25c 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -4,61 +4,78 @@ ## Table of Contents -- [publicawesome/stargaze/authority/v1/authority.proto](#publicawesome/stargaze/authority/v1/authority.proto) - - [Authorization](#publicawesome.stargaze.authority.v1.Authorization) - - [Params](#publicawesome.stargaze.authority.v1.Params) +- [osmosis/tokenfactory/v1beta1/tokenfactory.proto](#osmosis/tokenfactory/v1beta1/tokenfactory.proto) + - [DenomAuthorityMetadata](#osmosis.tokenfactory.v1beta1.DenomAuthorityMetadata) + - [Params](#osmosis.tokenfactory.v1beta1.Params) -- [publicawesome/stargaze/authority/v1/genesis.proto](#publicawesome/stargaze/authority/v1/genesis.proto) - - [GenesisState](#publicawesome.stargaze.authority.v1.GenesisState) +- [osmosis/tokenfactory/v1beta1/genesis.proto](#osmosis/tokenfactory/v1beta1/genesis.proto) + - [GenesisDenom](#osmosis.tokenfactory.v1beta1.GenesisDenom) + - [GenesisState](#osmosis.tokenfactory.v1beta1.GenesisState) -- [publicawesome/stargaze/authority/v1/query.proto](#publicawesome/stargaze/authority/v1/query.proto) - - [QueryParamsRequest](#publicawesome.stargaze.authority.v1.QueryParamsRequest) - - [QueryParamsResponse](#publicawesome.stargaze.authority.v1.QueryParamsResponse) +- [osmosis/tokenfactory/v1beta1/query.proto](#osmosis/tokenfactory/v1beta1/query.proto) + - [QueryDenomAuthorityMetadataRequest](#osmosis.tokenfactory.v1beta1.QueryDenomAuthorityMetadataRequest) + - [QueryDenomAuthorityMetadataResponse](#osmosis.tokenfactory.v1beta1.QueryDenomAuthorityMetadataResponse) + - [QueryDenomsFromCreatorRequest](#osmosis.tokenfactory.v1beta1.QueryDenomsFromCreatorRequest) + - [QueryDenomsFromCreatorResponse](#osmosis.tokenfactory.v1beta1.QueryDenomsFromCreatorResponse) + - [QueryParamsRequest](#osmosis.tokenfactory.v1beta1.QueryParamsRequest) + - [QueryParamsResponse](#osmosis.tokenfactory.v1beta1.QueryParamsResponse) - - [Query](#publicawesome.stargaze.authority.v1.Query) + - [Query](#osmosis.tokenfactory.v1beta1.Query) -- [publicawesome/stargaze/authority/v1/tx.proto](#publicawesome/stargaze/authority/v1/tx.proto) - - [MsgExecuteProposal](#publicawesome.stargaze.authority.v1.MsgExecuteProposal) - - [MsgExecuteProposalResponse](#publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse) +- [osmosis/tokenfactory/v1beta1/tx.proto](#osmosis/tokenfactory/v1beta1/tx.proto) + - [MsgBurn](#osmosis.tokenfactory.v1beta1.MsgBurn) + - [MsgBurnResponse](#osmosis.tokenfactory.v1beta1.MsgBurnResponse) + - [MsgChangeAdmin](#osmosis.tokenfactory.v1beta1.MsgChangeAdmin) + - [MsgChangeAdminResponse](#osmosis.tokenfactory.v1beta1.MsgChangeAdminResponse) + - [MsgCreateDenom](#osmosis.tokenfactory.v1beta1.MsgCreateDenom) + - [MsgCreateDenomResponse](#osmosis.tokenfactory.v1beta1.MsgCreateDenomResponse) + - [MsgMint](#osmosis.tokenfactory.v1beta1.MsgMint) + - [MsgMintResponse](#osmosis.tokenfactory.v1beta1.MsgMintResponse) + - [MsgSetDenomMetadata](#osmosis.tokenfactory.v1beta1.MsgSetDenomMetadata) + - [MsgSetDenomMetadataResponse](#osmosis.tokenfactory.v1beta1.MsgSetDenomMetadataResponse) - - [Msg](#publicawesome.stargaze.authority.v1.Msg) + - [Msg](#osmosis.tokenfactory.v1beta1.Msg) - [Scalar Value Types](#scalar-value-types) - +

Top

-## publicawesome/stargaze/authority/v1/authority.proto +## osmosis/tokenfactory/v1beta1/tokenfactory.proto - - -### Authorization + +### DenomAuthorityMetadata +DenomAuthorityMetadata specifies metadata for addresses that have specific +capabilities over a token factory denom. Right now there is only one Admin +permission, but is planned to be extended to the future. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `msgTypeUrl` | [string](#string) | | The type url of a proposal sdk.Msg | -| `addresses` | [string](#string) | repeated | The addresses who are allowed to execute that proposal | +| `admin` | [string](#string) | | Can be empty for no admin, or a valid stargaze address | - + ### Params -Params holds parameters for the authority module. +Params defines the parameters for the tokenfactory module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `authorizations` | [Authorization](#publicawesome.stargaze.authority.v1.Authorization) | repeated | | +| `denom_creation_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | DenomCreationFee defines the fee to be charged on the creation of a new denom. The fee is drawn from the MsgCreateDenom's sender account, and transferred to the community pool. | +| `denom_creation_gas_consume` | [uint64](#uint64) | | DenomCreationGasConsume defines the gas cost for creating a new denom. This is intended as a spam deterrence mechanism. + +See: https://github.com/CosmWasm/token-factory/issues/11 | @@ -74,22 +91,41 @@ Params holds parameters for the authority module. - +

Top

-## publicawesome/stargaze/authority/v1/genesis.proto +## osmosis/tokenfactory/v1beta1/genesis.proto - + + +### GenesisDenom +GenesisDenom defines a tokenfactory denom that is defined within genesis +state. The structure contains DenomAuthorityMetadata which defines the +denom's admin. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `denom` | [string](#string) | | | +| `authority_metadata` | [DenomAuthorityMetadata](#osmosis.tokenfactory.v1beta1.DenomAuthorityMetadata) | | | + -### GenesisState + + + +### GenesisState +GenesisState defines the tokenfactory module's genesis state. + + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#publicawesome.stargaze.authority.v1.Params) | | | +| `params` | [Params](#osmosis.tokenfactory.v1beta1.Params) | | params defines the paramaters of the module. | +| `factory_denoms` | [GenesisDenom](#osmosis.tokenfactory.v1beta1.GenesisDenom) | repeated | | @@ -105,32 +141,96 @@ Params holds parameters for the authority module. - +

Top

-## publicawesome/stargaze/authority/v1/query.proto +## osmosis/tokenfactory/v1beta1/query.proto - + -### QueryParamsRequest +### QueryDenomAuthorityMetadataRequest +QueryDenomAuthorityMetadataRequest defines the request structure for the +DenomAuthorityMetadata gRPC query. +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `denom` | [string](#string) | | | - -### QueryParamsResponse + + +### QueryDenomAuthorityMetadataResponse +QueryDenomAuthorityMetadataResponse defines the response structure for the +DenomAuthorityMetadata gRPC query. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authority_metadata` | [DenomAuthorityMetadata](#osmosis.tokenfactory.v1beta1.DenomAuthorityMetadata) | | | + + + + + + + + +### QueryDenomsFromCreatorRequest +QueryDenomsFromCreatorRequest defines the request structure for the +DenomsFromCreator gRPC query. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `creator` | [string](#string) | | | + + + + + +### QueryDenomsFromCreatorResponse +QueryDenomsFromCreatorRequest defines the response structure for the +DenomsFromCreator gRPC query. + + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#publicawesome.stargaze.authority.v1.Params) | | | +| `denoms` | [string](#string) | repeated | | + + + + + + + + +### QueryParamsRequest +QueryParamsRequest is the request type for the Query/Params RPC method. + + + + + + + + +### QueryParamsResponse +QueryParamsResponse is the response type for the Query/Params RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#osmosis.tokenfactory.v1beta1.Params) | | params defines the parameters of the module. | @@ -143,47 +243,175 @@ Params holds parameters for the authority module. - + ### Query Query defines the gRPC querier service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Params` | [QueryParamsRequest](#publicawesome.stargaze.authority.v1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.authority.v1.QueryParamsResponse) | | GET|/stargaze/authority/v1/params| +| `Params` | [QueryParamsRequest](#osmosis.tokenfactory.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#osmosis.tokenfactory.v1beta1.QueryParamsResponse) | Params defines a gRPC query method that returns the tokenfactory module's parameters. | GET|/stargaze/tokenfactory/v1/params| +| `DenomAuthorityMetadata` | [QueryDenomAuthorityMetadataRequest](#osmosis.tokenfactory.v1beta1.QueryDenomAuthorityMetadataRequest) | [QueryDenomAuthorityMetadataResponse](#osmosis.tokenfactory.v1beta1.QueryDenomAuthorityMetadataResponse) | DenomAuthorityMetadata defines a gRPC query method for fetching DenomAuthorityMetadata for a particular denom. | GET|/stargaze/tokenfactory/v1/denoms/{denom}/authority_metadata| +| `DenomsFromCreator` | [QueryDenomsFromCreatorRequest](#osmosis.tokenfactory.v1beta1.QueryDenomsFromCreatorRequest) | [QueryDenomsFromCreatorResponse](#osmosis.tokenfactory.v1beta1.QueryDenomsFromCreatorResponse) | DenomsFromCreator defines a gRPC query method for fetching all denominations created by a specific admin/creator. | GET|/stargaze/tokenfactory/v1/denoms_from_creator/{creator}| - +

Top

-## publicawesome/stargaze/authority/v1/tx.proto +## osmosis/tokenfactory/v1beta1/tx.proto + + + + + +### MsgBurn +MsgBurn is the sdk.Msg type for allowing an admin account to burn +a token. For now, we only support burning from the sender account. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | +| `burnFromAddress` | [string](#string) | | | + + + + + + + + +### MsgBurnResponse + + + + + + + + + +### MsgChangeAdmin +MsgChangeAdmin is the sdk.Msg type for allowing an admin account to reassign +adminship of a denom to a new account + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `denom` | [string](#string) | | | +| `new_admin` | [string](#string) | | | + + + + + + + + +### MsgChangeAdminResponse +MsgChangeAdminResponse defines the response structure for an executed +MsgChangeAdmin message. + + + + + + + + +### MsgCreateDenom +MsgCreateDenom defines the message structure for the CreateDenom gRPC service +method. It allows an account to create a new denom. It requires a sender +address and a sub denomination. The (sender_address, sub_denomination) tuple +must be unique and cannot be re-used. + +The resulting denom created is defined as +. The resulting denom's admin is +originally set to be the creator, but this can be changed later. The token +denom does not indicate the current admin. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `subdenom` | [string](#string) | | subdenom can be up to 44 "alphanumeric" characters long. | + + + + + + + + +### MsgCreateDenomResponse +MsgCreateDenomResponse is the return value of MsgCreateDenom +It returns the full string of the newly created denom + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `new_token_denom` | [string](#string) | | | + + + + + + + + +### MsgMint +MsgMint is the sdk.Msg type for allowing an admin account to mint +more of a token. For now, we only support minting to the sender account + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | +| `mintToAddress` | [string](#string) | | | + + + + + + + + +### MsgMintResponse + + + + - + -### MsgExecuteProposal -MsgExecuteProposal defines an sdk.Msg type that supports submitting arbitrary -proposal Content. +### MsgSetDenomMetadata +MsgSetDenomMetadata is the sdk.Msg type for allowing an admin account to set +the denom's bank metadata | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `authority` | [string](#string) | | | -| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | +| `sender` | [string](#string) | | | +| `metadata` | [cosmos.bank.v1beta1.Metadata](#cosmos.bank.v1beta1.Metadata) | | | - + -### MsgExecuteProposalResponse -MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. +### MsgSetDenomMetadataResponse +MsgSetDenomMetadataResponse defines the response structure for an executed +MsgSetDenomMetadata message. @@ -196,14 +424,18 @@ MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. - + ### Msg -Msg defines the authority Msg service. +Msg defines the tokefactory module's gRPC message service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `ExecuteProposal` | [MsgExecuteProposal](#publicawesome.stargaze.authority.v1.MsgExecuteProposal) | [MsgExecuteProposalResponse](#publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse) | | | +| `CreateDenom` | [MsgCreateDenom](#osmosis.tokenfactory.v1beta1.MsgCreateDenom) | [MsgCreateDenomResponse](#osmosis.tokenfactory.v1beta1.MsgCreateDenomResponse) | | | +| `Mint` | [MsgMint](#osmosis.tokenfactory.v1beta1.MsgMint) | [MsgMintResponse](#osmosis.tokenfactory.v1beta1.MsgMintResponse) | | | +| `Burn` | [MsgBurn](#osmosis.tokenfactory.v1beta1.MsgBurn) | [MsgBurnResponse](#osmosis.tokenfactory.v1beta1.MsgBurnResponse) | | | +| `ChangeAdmin` | [MsgChangeAdmin](#osmosis.tokenfactory.v1beta1.MsgChangeAdmin) | [MsgChangeAdminResponse](#osmosis.tokenfactory.v1beta1.MsgChangeAdminResponse) | | | +| `SetDenomMetadata` | [MsgSetDenomMetadata](#osmosis.tokenfactory.v1beta1.MsgSetDenomMetadata) | [MsgSetDenomMetadataResponse](#osmosis.tokenfactory.v1beta1.MsgSetDenomMetadataResponse) | | | diff --git a/proto/publicawesome/stargaze/authority/v1/tx.proto b/proto/publicawesome/stargaze/authority/v1/tx.proto index 3d6dcaae9..bbf9cd591 100644 --- a/proto/publicawesome/stargaze/authority/v1/tx.proto +++ b/proto/publicawesome/stargaze/authority/v1/tx.proto @@ -4,13 +4,14 @@ package publicawesome.stargaze.authority.v1; import "gogoproto/gogo.proto"; import "cosmos/msg/v1/msg.proto"; import "google/protobuf/any.proto"; +import "publicawesome/stargaze/authority/v1/authority.proto"; option go_package = "github.com/public-awesome/stargaze/v13/x/authority/types"; // Msg defines the authority Msg service. service Msg { - rpc ExecuteProposal(MsgExecuteProposal) - returns (MsgExecuteProposalResponse); + rpc ExecuteProposal(MsgExecuteProposal) returns (MsgExecuteProposalResponse); + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } // MsgExecuteProposal defines an sdk.Msg type that supports submitting arbitrary @@ -23,4 +24,17 @@ message MsgExecuteProposal { } // MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. - message MsgExecuteProposalResponse { } \ No newline at end of file +message MsgExecuteProposalResponse { } + +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + // Authority is the address of the governance account. + string authority = 1; + // NOTE: All parameters must be supplied. + Params params = 2 [ + (gogoproto.jsontag) = "params,omitempty", + (gogoproto.nullable) = false + ]; +} + +message MsgUpdateParamsResponse {} \ No newline at end of file diff --git a/x/authority/keeper/msg_server.go b/x/authority/keeper/msg_server.go index cbabcaa9f..e70fae09f 100644 --- a/x/authority/keeper/msg_server.go +++ b/x/authority/keeper/msg_server.go @@ -3,6 +3,7 @@ package keeper import ( "context" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/public-awesome/stargaze/v13/x/authority/types" ) @@ -40,3 +41,31 @@ func (m msgServer) ExecuteProposal(goCtx context.Context, msg *types.MsgExecuteP return &types.MsgExecuteProposalResponse{}, nil } + +// UpdateParams implements types.MsgServer. +func (m msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + senderAddr, err := sdk.AccAddressFromBech32(msg.GetAuthority()) + if err != nil { + return nil, err + } + + authorityAddr := sdk.MustAccAddressFromBech32(m.Keeper.GetAuthority()) + + if !senderAddr.Equals(authorityAddr) { + return nil, errorsmod.Wrap(types.ErrUnauthorized, "sender address is not authorized address to update module params") + } + + err = msg.GetParams().Validate() // need to explicitly validate as x/gov invokes this msg and it does not validate + if err != nil { + return nil, err + } + + err = m.SetParams(ctx, msg.GetParams()) + if err != nil { + return nil, err + } + + return &types.MsgUpdateParamsResponse{}, nil +} diff --git a/x/authority/keeper/params.go b/x/authority/keeper/params.go index 84510af40..aa014b85f 100644 --- a/x/authority/keeper/params.go +++ b/x/authority/keeper/params.go @@ -5,7 +5,7 @@ import ( "github.com/public-awesome/stargaze/v13/x/authority/types" ) -// SetParams sets the total set of minting parameters. +// SetParams sets the total set of authority parameters. func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { store := ctx.KVStore(k.storeKey) bz, err := k.cdc.Marshal(¶ms) @@ -16,15 +16,14 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { return nil } -// GetParams returns the total set of minting parameters. +// GetParams returns the total set of authority parameters. func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { - // store := ctx.KVStore(k.storeKey) - // bz := store.Get(types.ParamsKey) - // if bz == nil { - // return params - // } + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) + if bz == nil { + return params + } - // k.cdc.MustUnmarshal(bz, ¶ms) - //return params - return types.DefaultParams() + k.cdc.MustUnmarshal(bz, ¶ms) + return params } diff --git a/x/authority/module.go b/x/authority/module.go index 837e9a4b6..1567f3114 100644 --- a/x/authority/module.go +++ b/x/authority/module.go @@ -5,8 +5,6 @@ import ( "encoding/json" "fmt" - // this line is used by starport scaffolding # 1 - "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" diff --git a/x/authority/types/errors.go b/x/authority/types/errors.go index db9a3fff8..a7b227e4d 100644 --- a/x/authority/types/errors.go +++ b/x/authority/types/errors.go @@ -6,7 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" ) -// x/cron module sentinel errors +// x/authority module sentinel errors var ( ErrUnauthorized = errorsmod.Register(ModuleName, 2, "sender is unauthorized to perform the operation") ErrAuthorizationNotFound = errorsmod.Register(ModuleName, 3, "") diff --git a/x/authority/types/msgs.go b/x/authority/types/msgs.go index f789b8c28..e8ca26a54 100644 --- a/x/authority/types/msgs.go +++ b/x/authority/types/msgs.go @@ -15,6 +15,7 @@ import ( var ( _ sdk.Msg = &MsgExecuteProposal{} _ codectypes.UnpackInterfacesMessage = &MsgExecuteProposal{} + _ sdk.Msg = &MsgUpdateParams{} ) // NewMsgExecuteProposal creates a new MsgExecuteProposal. @@ -98,3 +99,42 @@ func (m MsgExecuteProposal) GetSigners() []sdk.AccAddress { func (m MsgExecuteProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { return sdktx.UnpackInterfaces(unpacker, m.Messages) } + +// NewMsgUpdateParams creates a new MsgUpdateParams. +// +//nolint:interfacer +func NewMsgUpdateParams(messages []sdk.Msg, authority string) (*MsgUpdateParams, error) { + m := &MsgUpdateParams{ + Authority: authority, + } + + return m, nil +} + +// Type implements the sdk.Msg interface. +func (m MsgUpdateParams) Type() string { return sdk.MsgTypeURL(&m) } + +// ValidateBasic implements the sdk.Msg interface. +func (m MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.GetAuthority()); err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf("invalid proposer address: %s", err) + } + + if err := m.Params.Validate(); err != nil { + return err + } + + return nil +} + +// GetSignBytes returns the message bytes to sign over. +func (m MsgUpdateParams) GetSignBytes() []byte { + bz := codec.ModuleCdc.MustMarshalJSON(&m) + return sdk.MustSortJSON(bz) +} + +// GetSigners returns the expected signers for a MsgExecuteProposal. +func (m MsgUpdateParams) GetSigners() []sdk.AccAddress { + proposer, _ := sdk.AccAddressFromBech32(m.GetAuthority()) + return []sdk.AccAddress{proposer} +} diff --git a/x/authority/types/tx.pb.go b/x/authority/types/tx.pb.go index 2e554415a..de09c9a02 100644 --- a/x/authority/types/tx.pb.go +++ b/x/authority/types/tx.pb.go @@ -121,9 +121,101 @@ func (m *MsgExecuteProposalResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgExecuteProposalResponse proto.InternalMessageInfo +type MsgUpdateParams struct { + // Authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_a59b6a5ac2f6d30b, []int{2} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a59b6a5ac2f6d30b, []int{3} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgExecuteProposal)(nil), "publicawesome.stargaze.authority.v1.MsgExecuteProposal") proto.RegisterType((*MsgExecuteProposalResponse)(nil), "publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "publicawesome.stargaze.authority.v1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "publicawesome.stargaze.authority.v1.MsgUpdateParamsResponse") } func init() { @@ -131,28 +223,34 @@ func init() { } var fileDescriptor_a59b6a5ac2f6d30b = []byte{ - // 321 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x29, 0x28, 0x4d, 0xca, - 0xc9, 0x4c, 0x4e, 0x2c, 0x4f, 0x2d, 0xce, 0xcf, 0x4d, 0xd5, 0x2f, 0x2e, 0x49, 0x2c, 0x4a, 0x4f, - 0xac, 0x4a, 0xd5, 0x4f, 0x2c, 0x2d, 0xc9, 0xc8, 0x2f, 0xca, 0x2c, 0xa9, 0xd4, 0x2f, 0x33, 0xd4, - 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x46, 0x51, 0xad, 0x07, 0x53, 0xad, - 0x07, 0x57, 0xad, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xaf, 0x0f, 0x62, - 0x41, 0xb4, 0x4a, 0x89, 0x27, 0xe7, 0x17, 0xe7, 0xe6, 0x17, 0xeb, 0xe7, 0x16, 0xa7, 0x83, 0x8c, - 0xcc, 0x2d, 0x4e, 0x87, 0x4a, 0x48, 0xa6, 0xe7, 0xe7, 0xa7, 0xe7, 0xa4, 0xea, 0x83, 0x79, 0x49, - 0xa5, 0x69, 0xfa, 0x89, 0x79, 0x95, 0x10, 0x29, 0xa5, 0x12, 0x2e, 0x21, 0xdf, 0xe2, 0x74, 0xd7, - 0x8a, 0xd4, 0xe4, 0xd2, 0x92, 0xd4, 0x80, 0xa2, 0xfc, 0x82, 0xfc, 0xe2, 0xc4, 0x1c, 0x21, 0x19, - 0x2e, 0x4e, 0xb8, 0x7d, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x08, 0x01, 0x21, 0x03, 0x2e, - 0x8e, 0xdc, 0xd4, 0xe2, 0xe2, 0xc4, 0xf4, 0xd4, 0x62, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, - 0x11, 0x3d, 0x88, 0x0d, 0x7a, 0x30, 0x1b, 0xf4, 0x1c, 0xf3, 0x2a, 0x83, 0xe0, 0xaa, 0xac, 0xf8, - 0x9a, 0x9e, 0x6f, 0xd0, 0x42, 0x98, 0xa0, 0x24, 0xc3, 0x25, 0x85, 0x69, 0x6b, 0x50, 0x6a, 0x71, - 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0xd1, 0x64, 0x46, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x6e, 0x46, - 0x2e, 0x7e, 0x74, 0x97, 0x99, 0xeb, 0x11, 0x11, 0x3e, 0x7a, 0x98, 0x86, 0x4b, 0xd9, 0x93, 0xa9, - 0x11, 0xe6, 0x2a, 0xa7, 0xa0, 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, 0xb2, - 0x48, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x58, 0xa2, 0x8b, 0x11, - 0xd9, 0x65, 0x86, 0xc6, 0xfa, 0x15, 0x48, 0x51, 0x5e, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, - 0x0e, 0x2f, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf6, 0x1d, 0x1b, 0x44, 0x23, 0x02, 0x00, - 0x00, + // 422 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x4f, 0x8b, 0xd3, 0x40, + 0x18, 0xc6, 0x33, 0x5d, 0x58, 0xdc, 0x59, 0x71, 0x25, 0x2c, 0x6c, 0x36, 0x2c, 0xd9, 0x52, 0x2f, + 0x45, 0xd7, 0x19, 0xdb, 0x0a, 0x8a, 0x08, 0xe2, 0x82, 0xc7, 0xc2, 0x12, 0xf0, 0x22, 0x78, 0x98, + 0xc4, 0x71, 0x36, 0xd0, 0xe9, 0x0c, 0x79, 0x27, 0xb5, 0xf1, 0xd8, 0xab, 0x17, 0x8f, 0x9e, 0xfc, + 0x0c, 0x7e, 0x8c, 0x1e, 0x7b, 0xf4, 0x54, 0xa4, 0x3d, 0x08, 0x7e, 0x0a, 0x69, 0xd2, 0xf4, 0x5f, + 0x0e, 0x1b, 0x7a, 0x4b, 0xe6, 0x7d, 0x9e, 0xe7, 0xfd, 0xf1, 0xf0, 0xe2, 0x2b, 0x9d, 0x04, 0xbd, + 0x28, 0x64, 0x5f, 0x38, 0x28, 0xc9, 0x29, 0x18, 0x16, 0x0b, 0xf6, 0x95, 0x53, 0x96, 0x98, 0x5b, + 0x15, 0x47, 0x26, 0xa5, 0x83, 0x16, 0x35, 0x43, 0xa2, 0x63, 0x65, 0x94, 0xfd, 0x68, 0x4b, 0x4d, + 0x0a, 0x35, 0x59, 0xa9, 0xc9, 0xa0, 0xe5, 0x9e, 0x0a, 0x25, 0x54, 0xa6, 0xa7, 0x8b, 0xaf, 0xdc, + 0xea, 0x9e, 0x85, 0x0a, 0xa4, 0x02, 0x2a, 0x41, 0x2c, 0x22, 0x25, 0x88, 0xe5, 0xe0, 0x5c, 0x28, + 0x25, 0x7a, 0x9c, 0x66, 0x7f, 0x41, 0xf2, 0x99, 0xb2, 0x7e, 0xba, 0x1c, 0x75, 0xaa, 0xc0, 0xad, + 0x77, 0x67, 0xa6, 0x86, 0xc1, 0x76, 0x17, 0xc4, 0xbb, 0x21, 0x0f, 0x13, 0xc3, 0x6f, 0x62, 0xa5, + 0x15, 0xb0, 0x9e, 0x7d, 0x81, 0x8f, 0x56, 0x42, 0x07, 0xd5, 0x51, 0xf3, 0xc8, 0x5f, 0x3f, 0xd8, + 0xcf, 0xf0, 0x3d, 0xc9, 0x01, 0x98, 0xe0, 0xe0, 0xd4, 0xea, 0x07, 0xcd, 0xe3, 0xf6, 0x29, 0xc9, + 0xb1, 0x48, 0x81, 0x45, 0xde, 0xf6, 0x53, 0x7f, 0xa5, 0x7a, 0xf5, 0x60, 0xf4, 0xf7, 0xd7, 0xe3, + 0x75, 0x42, 0xe3, 0x02, 0xbb, 0xe5, 0xad, 0x3e, 0x07, 0xad, 0xfa, 0xc0, 0x1b, 0x3f, 0x11, 0x3e, + 0xe9, 0x82, 0x78, 0xaf, 0x3f, 0x31, 0xc3, 0x6f, 0x58, 0xcc, 0x24, 0xdc, 0x41, 0xf4, 0x11, 0x1f, + 0xea, 0x4c, 0xe7, 0xd4, 0xea, 0xa8, 0x79, 0xdc, 0x7e, 0x42, 0x2a, 0x54, 0x4f, 0xf2, 0xe8, 0x6b, + 0x67, 0x3c, 0xbd, 0xb4, 0xfe, 0x4d, 0x2f, 0x1f, 0xe6, 0x11, 0x57, 0x4a, 0x46, 0x86, 0x4b, 0x6d, + 0x52, 0x7f, 0x19, 0x5a, 0xc2, 0x3f, 0xc7, 0x67, 0x3b, 0x7c, 0x05, 0x7b, 0xfb, 0x47, 0x0d, 0x1f, + 0x74, 0x41, 0xd8, 0xdf, 0x10, 0x3e, 0xd9, 0x6d, 0xf5, 0x45, 0x25, 0xaa, 0x72, 0x31, 0xee, 0x9b, + 0x3d, 0x8d, 0x05, 0x95, 0x3d, 0x42, 0xf8, 0xfe, 0x56, 0x9d, 0xcf, 0xab, 0x26, 0x6e, 0xba, 0xdc, + 0xd7, 0xfb, 0xb8, 0x0a, 0x88, 0x6b, 0x7f, 0x3c, 0xf3, 0xd0, 0x64, 0xe6, 0xa1, 0x3f, 0x33, 0x0f, + 0x7d, 0x9f, 0x7b, 0xd6, 0x64, 0xee, 0x59, 0xbf, 0xe7, 0x9e, 0xf5, 0xe1, 0xa5, 0x88, 0xcc, 0x6d, + 0x12, 0x90, 0x50, 0x49, 0x9a, 0x6f, 0x78, 0x5a, 0xba, 0xe2, 0x41, 0xab, 0x43, 0x87, 0x1b, 0xb7, + 0x6c, 0x52, 0xcd, 0x21, 0x38, 0xcc, 0x0e, 0xae, 0xf3, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x5f, 0xdb, + 0x02, 0xfe, 0x99, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -168,6 +266,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 MsgClient interface { ExecuteProposal(ctx context.Context, in *MsgExecuteProposal, opts ...grpc.CallOption) (*MsgExecuteProposalResponse, error) + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) } type msgClient struct { @@ -187,9 +286,19 @@ func (c *msgClient) ExecuteProposal(ctx context.Context, in *MsgExecuteProposal, return out, nil } +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/publicawesome.stargaze.authority.v1.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { ExecuteProposal(context.Context, *MsgExecuteProposal) (*MsgExecuteProposalResponse, error) + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -199,6 +308,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) ExecuteProposal(ctx context.Context, req *MsgExecuteProposal) (*MsgExecuteProposalResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ExecuteProposal not implemented") } +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -222,6 +334,24 @@ func _Msg_ExecuteProposal_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/publicawesome.stargaze.authority.v1.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "publicawesome.stargaze.authority.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -230,6 +360,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "ExecuteProposal", Handler: _Msg_ExecuteProposal_Handler, }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "publicawesome/stargaze/authority/v1/tx.proto", @@ -302,6 +436,69 @@ func (m *MsgExecuteProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } +func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -341,6 +538,30 @@ func (m *MsgExecuteProposalResponse) Size() (n int) { return n } +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -513,6 +734,171 @@ func (m *MsgExecuteProposalResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From 868994a04c53d90f66d024b081a9664dace0c60e Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 3 Nov 2023 12:51:18 +0000 Subject: [PATCH 10/20] lint fix --- app/app.go | 4 ++-- x/authority/client/cli/tx.go | 4 ++++ x/authority/module.go | 4 ++-- x/authority/types/authorization.go | 4 ++-- x/authority/types/codec.go | 2 ++ x/authority/types/errors.go | 2 +- x/authority/types/genesis.go | 8 +++++--- x/authority/types/keys.go | 4 +--- x/authority/types/msgs.go | 10 +++------- x/authority/types/params.go | 13 +------------ 10 files changed, 23 insertions(+), 32 deletions(-) diff --git a/app/app.go b/app/app.go index 061bbadf1..52745ac7a 100644 --- a/app/app.go +++ b/app/app.go @@ -435,7 +435,7 @@ func NewStargazeApp( app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName, - authtypes.NewModuleAddress(authoritytypes.ModuleName).String(), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, @@ -637,7 +637,7 @@ func NewStargazeApp( wasmDir, wasmConfig, GetWasmCapabilities(), - authtypes.NewModuleAddress(authoritytypes.ModuleName).String(), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), wasmOpts..., ) diff --git a/x/authority/client/cli/tx.go b/x/authority/client/cli/tx.go index 4a483d65d..8a6ce398f 100644 --- a/x/authority/client/cli/tx.go +++ b/x/authority/client/cli/tx.go @@ -33,6 +33,7 @@ func CmdSubmitProposal() *cobra.Command { cmd := &cobra.Command{ Use: "submit-proposal [path/to/proposal.json]", Short: "Submit a proposal along with some messages", + Long: "Submit a proposal along with some messages. All the nessages in the proposal should have their authoriazation set in the module params and the modules the msg belongs to should be using x/authority module as its authority account", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) @@ -46,6 +47,9 @@ func CmdSubmitProposal() *cobra.Command { } msg, err := types.NewMsgExecuteProposal(msgs, clientCtx.GetFromAddress().String()) + if err != nil { + return err + } if err := msg.ValidateBasic(); err != nil { return err } diff --git a/x/authority/module.go b/x/authority/module.go index 1567f3114..3ccf362a7 100644 --- a/x/authority/module.go +++ b/x/authority/module.go @@ -138,9 +138,9 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block -func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {} +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} // EndBlock contains the logic that is automatically triggered at the end of each block -func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} } diff --git a/x/authority/types/authorization.go b/x/authority/types/authorization.go index 1df854b5f..0ff9e110e 100644 --- a/x/authority/types/authorization.go +++ b/x/authority/types/authorization.go @@ -6,9 +6,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func GetMsgAuthorization(msgTypeUrl string, authorizations []*Authorization) (*Authorization, bool) { +func GetMsgAuthorization(msgTypeURL string, authorizations []*Authorization) (*Authorization, bool) { for _, auth := range authorizations { - if auth.MsgTypeUrl == msgTypeUrl { + if auth.MsgTypeUrl == msgTypeURL { return auth, true } } diff --git a/x/authority/types/codec.go b/x/authority/types/codec.go index 9c83443af..9665063b0 100644 --- a/x/authority/types/codec.go +++ b/x/authority/types/codec.go @@ -12,12 +12,14 @@ import ( // These types are used for Amino JSON serialization. func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgExecuteProposal{}, "authority/MsgExecuteProposal", nil) + cdc.RegisterConcrete(&MsgUpdateParams{}, "authority/MsgUpdateParams", nil) } // RegisterInterfaces registers interfaces types with the interface registry. func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgExecuteProposal{}, + &MsgUpdateParams{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/authority/types/errors.go b/x/authority/types/errors.go index a7b227e4d..de1faa957 100644 --- a/x/authority/types/errors.go +++ b/x/authority/types/errors.go @@ -9,5 +9,5 @@ import ( // x/authority module sentinel errors var ( ErrUnauthorized = errorsmod.Register(ModuleName, 2, "sender is unauthorized to perform the operation") - ErrAuthorizationNotFound = errorsmod.Register(ModuleName, 3, "") + ErrAuthorizationNotFound = errorsmod.Register(ModuleName, 3, "authorization was not found for given msg type url") ) diff --git a/x/authority/types/genesis.go b/x/authority/types/genesis.go index 1f25c6546..ef80e0fa9 100644 --- a/x/authority/types/genesis.go +++ b/x/authority/types/genesis.go @@ -2,10 +2,12 @@ package types // DefaultGenesisState returns a default genesis state. func DefaultGenesis() *GenesisState { - return &GenesisState{} + return &GenesisState{ + Params: DefaultParams(), + } } // Validate perform object fields validation. -func (m GenesisState) Validate() error { - return nil +func (g GenesisState) Validate() error { + return g.Params.Validate() } diff --git a/x/authority/types/keys.go b/x/authority/types/keys.go index 7ea00103c..e92639eba 100644 --- a/x/authority/types/keys.go +++ b/x/authority/types/keys.go @@ -14,6 +14,4 @@ const ( MemStoreKey = "mem_authority" ) -var ( - ParamsKey = []byte{0x01} -) +var ParamsKey = []byte{0x01} diff --git a/x/authority/types/msgs.go b/x/authority/types/msgs.go index e8ca26a54..39bf9c6fe 100644 --- a/x/authority/types/msgs.go +++ b/x/authority/types/msgs.go @@ -58,7 +58,6 @@ func (m MsgExecuteProposal) Type() string { return sdk.MsgTypeURL(&m) } // ValidateBasic implements the sdk.Msg interface. func (m MsgExecuteProposal) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.GetAuthority()); err != nil { return sdkerrors.ErrInvalidAddress.Wrapf("invalid proposer address: %s", err) } @@ -103,9 +102,10 @@ func (m MsgExecuteProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) er // NewMsgUpdateParams creates a new MsgUpdateParams. // //nolint:interfacer -func NewMsgUpdateParams(messages []sdk.Msg, authority string) (*MsgUpdateParams, error) { +func NewMsgUpdateParams(params Params, authority string) (*MsgUpdateParams, error) { m := &MsgUpdateParams{ Authority: authority, + Params: params, } return m, nil @@ -120,11 +120,7 @@ func (m MsgUpdateParams) ValidateBasic() error { return sdkerrors.ErrInvalidAddress.Wrapf("invalid proposer address: %s", err) } - if err := m.Params.Validate(); err != nil { - return err - } - - return nil + return m.Params.Validate() } // GetSignBytes returns the message bytes to sign over. diff --git a/x/authority/types/params.go b/x/authority/types/params.go index 5b7be16ed..9edd6ca6f 100644 --- a/x/authority/types/params.go +++ b/x/authority/types/params.go @@ -6,18 +6,7 @@ import ( // default module parameters func DefaultParams() Params { - return Params{ - Authorizations: []*Authorization{ - { - MsgTypeUrl: "/cosmos.distribution.v1beta1.MsgCommunityPoolSpend", - Addresses: []string{"stars1x394ype3x8nt9wz0j78m8c8kcezpslrcjmmrc0"}, - }, - { - MsgTypeUrl: "/cosmwasm.wasm.v1.MsgUpdateParams", - Addresses: []string{"stars1mzgucqnfr2l8cj5apvdpllhzt4zeuh2cyt4fdd"}, - }, - }, - } + return Params{Authorizations: []*Authorization{}} } func NewParams(authorizations []*Authorization) Params { From 604dc96549a932e2a093eea8ed8bfa1a4b8743e9 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 3 Nov 2023 14:46:14 +0000 Subject: [PATCH 11/20] adding spec --- x/authority/README.md | 125 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 x/authority/README.md diff --git a/x/authority/README.md b/x/authority/README.md new file mode 100644 index 000000000..0886fd18a --- /dev/null +++ b/x/authority/README.md @@ -0,0 +1,125 @@ +# Authority + +## Abstract + +This module enables governance functionality to be delegated to addresses and not have to rely on the sdk x/gov module. +E.g A wallet or multisig or a smart contract can be given the authority to execute a governance operation without going through on-chain governance proposal. + +## Concepts + +With SDK 47, modules take in a string address of their "authority". This authority has the power to execute "authority-gated" operations. E.g Updating the module parameters. By default all the modules are configured with x/gov module as their authority. + +Our custom x/authority module allows replacement of the x/gov module from the authority role. The module also allows configuration of authority not just at a per module basis but at a per Msg basis. + +e.g x/wasmd has many authority gated operations. Using x/authority module instead of x/gov allows us to have different admins for each of the operations. + +`UpdateParams` authorization could be given to the dev team multisig + +`SudoContract` authorization could be given to a smart contract DAO + +> **Note** +> +> The way the authority mechanism works, if a module has x/authority as its authority, then all its gov msgs should be explicitly authorized at the x/authority module params. It a particular msg does not have authorization, it cannot be executed at all. + + +## Params + +- Authorizations + + This is a list of all the msg type URLs and the addresses that can execute them + +## Client + +### CLI - Query + +#### **params** + +```sh +starsd q authority params --output json | jq +``` + +```json +starsd q authority params +{ + "params": { + "authorizations": [ + { + "msgTypeUrl": "/cosmos.distribution.v1beta1.MsgCommunityPoolSpend", + "addresses": [ + "stars1x394ype3x8nt9wz0j78m8c8kcezpslrcjmmrc0" + ] + }, + { + "msgTypeUrl": "/cosmwasm.wasm.v1.MsgUpdateParams", + "addresses": [ + "stars1mzgucqnfr2l8cj5apvdpllhzt4zeuh2cyt4fdd" + ] + } + ] + } +} +``` + +### CLI - Gov + +``` +starsd tx gov submit-proposal proposal.json --from {user} +``` + +You will need the x/gov module address to set as authority for the proposal. You can fetch it by running: + +```starsd q auth module-account gov``` + +This will get you the following response +```jsonc +account: + '@type': /cosmos.auth.v1beta1.ModuleAccount + base_account: + account_number: "7" + address: stars10d07y265gmmuvt4z0w9aw880jnsr700jw7ycaz // This is the address you need to use for authority value + pub_key: null + sequence: "0" + name: gov + permissions: + - burner +``` +The expected format of the proposal.json is below. + +#### Update Params + +```jsonc +{ + "messages": [ + { + "@type": "/publicawesome.stargaze.authority.v1.MsgUpdateParams", + "authority": "stars10d07y265gmmuvt4z0w9aw880jnsr700jw7ycaz", // x/gov address + "params": { + "authorizations": [ + { + "msgTypeUrl": "/cosmos.distribution.v1beta1.MsgCommunityPoolSpend", + "addresses": [ + "stars1x394ype3x8nt9wz0j78m8c8kcezpslrcjmmrc0" + ] + } + ] + } + } + ], + "metadata": "metadata", + "deposit": "1000stake", + "title": "Update Authority Params", + "summary": "" +} +``` + +### CLI - Tx + +#### **submit-proposal** + +``` +starsd tx authority submit-proposal [path/to/proposal.json] +``` + +The format of proposal.json is same as the one used for x/gov module to keep the parity in usage. + +Ensure you are setting the "authority" or "sender" value to x/authority address and not x/gov address \ No newline at end of file From 582ca819fafc0f72e3deda0a37fdc7a91d0a2c9b Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 23 Feb 2024 11:39:56 +0000 Subject: [PATCH 12/20] regenerate proto --- docs/proto/proto-docs.md | 348 +++++++++++++-------------------------- 1 file changed, 116 insertions(+), 232 deletions(-) diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 26a369722..7aecfd768 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -1,116 +1,70 @@ - # Protobuf Documentation - ## Table of Contents -- [publicawesome/stargaze/globalfee/v1/globalfee.proto](#publicawesome/stargaze/globalfee/v1/globalfee.proto) - - [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) - - [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) - - [Params](#publicawesome.stargaze.globalfee.v1.Params) -- [publicawesome/stargaze/globalfee/v1/genesis.proto](#publicawesome/stargaze/globalfee/v1/genesis.proto) - - [GenesisState](#publicawesome.stargaze.globalfee.v1.GenesisState) -- [publicawesome/stargaze/globalfee/v1/proposal.proto](#publicawesome/stargaze/globalfee/v1/proposal.proto) - - [RemoveCodeAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.RemoveCodeAuthorizationProposal) - - [RemoveContractAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.RemoveContractAuthorizationProposal) - - [SetCodeAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.SetCodeAuthorizationProposal) - - [SetContractAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.SetContractAuthorizationProposal) -- [publicawesome/stargaze/globalfee/v1/query.proto](#publicawesome/stargaze/globalfee/v1/query.proto) - - - [QueryAuthorizationsRequest](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsRequest) - - [QueryAuthorizationsResponse](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsResponse) - - [QueryCodeAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationRequest) - - [QueryCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationResponse) - - [QueryContractAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationRequest) - - [QueryContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationResponse) - - [QueryParamsRequest](#publicawesome.stargaze.globalfee.v1.QueryParamsRequest) - - [QueryParamsResponse](#publicawesome.stargaze.globalfee.v1.QueryParamsResponse) - - - [Query](#publicawesome.stargaze.globalfee.v1.Query) - -- [publicawesome/stargaze/globalfee/v1/tx.proto](#publicawesome/stargaze/globalfee/v1/tx.proto) - - - [MsgRemoveCodeAuthorization](#publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorization) - - [MsgRemoveCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorizationResponse) - - [MsgRemoveContractAuthorization](#publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorization) - - [MsgRemoveContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorizationResponse) - - [MsgSetCodeAuthorization](#publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorization) - - [MsgSetCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorizationResponse) - - [MsgSetContractAuthorization](#publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorization) - - [MsgSetContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorizationResponse) - - [MsgUpdateParams](#publicawesome.stargaze.globalfee.v1.MsgUpdateParams) - - [MsgUpdateParamsResponse](#publicawesome.stargaze.globalfee.v1.MsgUpdateParamsResponse) - - - [Msg](#publicawesome.stargaze.globalfee.v1.Msg) - +- [publicawesome/stargaze/authority/v1/authority.proto](#publicawesome/stargaze/authority/v1/authority.proto) + - [Authorization](#publicawesome.stargaze.authority.v1.Authorization) + - [Params](#publicawesome.stargaze.authority.v1.Params) + +- [publicawesome/stargaze/authority/v1/genesis.proto](#publicawesome/stargaze/authority/v1/genesis.proto) + - [GenesisState](#publicawesome.stargaze.authority.v1.GenesisState) + +- [publicawesome/stargaze/authority/v1/query.proto](#publicawesome/stargaze/authority/v1/query.proto) + - [QueryParamsRequest](#publicawesome.stargaze.authority.v1.QueryParamsRequest) + - [QueryParamsResponse](#publicawesome.stargaze.authority.v1.QueryParamsResponse) + + - [Query](#publicawesome.stargaze.authority.v1.Query) + +- [publicawesome/stargaze/authority/v1/tx.proto](#publicawesome/stargaze/authority/v1/tx.proto) + - [MsgExecuteProposal](#publicawesome.stargaze.authority.v1.MsgExecuteProposal) + - [MsgExecuteProposalResponse](#publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse) + - [MsgUpdateParams](#publicawesome.stargaze.authority.v1.MsgUpdateParams) + - [MsgUpdateParamsResponse](#publicawesome.stargaze.authority.v1.MsgUpdateParamsResponse) + + - [Msg](#publicawesome.stargaze.authority.v1.Msg) + - [Scalar Value Types](#scalar-value-types) - - -

Top

- -## publicawesome/stargaze/globalfee/v1/globalfee.proto - -### CodeAuthorization + +

Top

-Configuration for code Ids which can have zero gas operations +## publicawesome/stargaze/authority/v1/authority.proto -| Field | Type | Label | Description | -| --------- | ----------------- | -------- | ------------------------------------- | -| `code_id` | [uint64](#uint64) | | authorized code ids | -| `methods` | [string](#string) | repeated | authorized contract operation methods | - -### ContractAuthorization + -Configuration for contract addresses which can have zero gas operations +### Authorization -| Field | Type | Label | Description | -| ------------------ | ----------------- | -------- | ------------------------------------- | -| `contract_address` | [string](#string) | | authorized contract addresses | -| `methods` | [string](#string) | repeated | authorized contract operation methods | - -### Params +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `msgTypeUrl` | [string](#string) | | The type url of a proposal sdk.Msg | +| `addresses` | [string](#string) | repeated | The addresses who are allowed to execute that proposal | -Params holds parameters for the globalfee module. -| Field | Type | Label | Description | -| ---------------------- | ----------------------------------------------------------- | -------- | ----------------------------------------------------------------- | -| `privileged_addresses` | [string](#string) | repeated | Addresses which are whitelisted to modify the gas free operations | -| `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | Minimum stores the minimum gas price(s) for all TX on the chain. | - - - - + - +### Params +Params holds parameters for the authority module. -

Top

-## publicawesome/stargaze/globalfee/v1/genesis.proto +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authorizations` | [Authorization](#publicawesome.stargaze.authority.v1.Authorization) | repeated | | - -### GenesisState -GenesisState defines the globalfee module's genesis state. -| Field | Type | Label | Description | -| ------------------------- | ----------------------------------------------------------------------------------- | -------- | ----------------------------------------------- | -| `params` | [Params](#publicawesome.stargaze.globalfee.v1.Params) | | Module params | -| `code_authorizations` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | repeated | Authorizations configured by code id | -| `contract_authorizations` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | repeated | Authorizations configured by contract addresses | @@ -120,51 +74,28 @@ GenesisState defines the globalfee module's genesis state. - -

Top

-## publicawesome/stargaze/globalfee/v1/proposal.proto + +

Top

- +## publicawesome/stargaze/authority/v1/genesis.proto -### RemoveCodeAuthorizationProposal -| Field | Type | Label | Description | -| ------------- | ----------------- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | -| `code_id` | [uint64](#uint64) | | | - + -### RemoveContractAuthorizationProposal +### GenesisState -| Field | Type | Label | Description | -| ------------------ | ----------------- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | -| `contract_address` | [string](#string) | | | - -### SetCodeAuthorizationProposal +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#publicawesome.stargaze.authority.v1.Params) | | | -| Field | Type | Label | Description | -| -------------------- | --------------------------------------------------------------------------- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | -| `code_authorization` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | | | - -### SetContractAuthorizationProposal -| Field | Type | Label | Description | -| ------------------------ | ----------------------------------------------------------------------------------- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | -| `contract_authorization` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | | | @@ -174,68 +105,38 @@ GenesisState defines the globalfee module's genesis state. - - -

Top

-## publicawesome/stargaze/globalfee/v1/query.proto - - -### QueryAuthorizationsRequest + +

Top

- +## publicawesome/stargaze/authority/v1/query.proto -### QueryAuthorizationsResponse -| Field | Type | Label | Description | -| ------------------------- | ----------------------------------------------------------------------------------- | -------- | ----------- | -| `code_authorizations` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | repeated | | -| `contract_authorizations` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | repeated | | - + -### QueryCodeAuthorizationRequest +### QueryParamsRequest -| Field | Type | Label | Description | -| --------- | ----------------- | ----- | ----------- | -| `code_id` | [uint64](#uint64) | | | - -### QueryCodeAuthorizationResponse -| Field | Type | Label | Description | -| --------- | ----------------- | -------- | ----------- | -| `methods` | [string](#string) | repeated | | - -### QueryContractAuthorizationRequest -| Field | Type | Label | Description | -| ------------------ | ----------------- | ----- | ----------- | -| `contract_address` | [string](#string) | | | + - +### QueryParamsResponse -### QueryContractAuthorizationResponse -| Field | Type | Label | Description | -| --------- | ----------------- | -------- | ----------- | -| `methods` | [string](#string) | repeated | | - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#publicawesome.stargaze.authority.v1.Params) | | | -### QueryParamsRequest - -### QueryParamsResponse -| Field | Type | Label | Description | -| -------- | ----------------------------------------------------- | ----- | ----------- | -| `params` | [Params](#publicawesome.stargaze.globalfee.v1.Params) | | | @@ -243,97 +144,78 @@ GenesisState defines the globalfee module's genesis state. - -### Query + +### Query Query defines the gRPC querier service. -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ----------- | --------- | ---------------------------------------------------------------- | -| `CodeAuthorization` | [QueryCodeAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationRequest) | [QueryCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationResponse) | | GET | /stargaze/globalfee/v1/code_authorization/{code_id} | -| `ContractAuthorization` | [QueryContractAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationRequest) | [QueryContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationResponse) | | GET | /stargaze/globalfee/v1/contract_authorization/{contract_address} | -| `Params` | [QueryParamsRequest](#publicawesome.stargaze.globalfee.v1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.globalfee.v1.QueryParamsResponse) | | GET | /stargaze/globalfee/v1/params | -| `Authorizations` | [QueryAuthorizationsRequest](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsRequest) | [QueryAuthorizationsResponse](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsResponse) | | GET | /stargaze/globalfee/v1/authorizations | +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Params` | [QueryParamsRequest](#publicawesome.stargaze.authority.v1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.authority.v1.QueryParamsResponse) | | GET|/stargaze/authority/v1/params| - + +

Top

-## publicawesome/stargaze/globalfee/v1/tx.proto +## publicawesome/stargaze/authority/v1/tx.proto - -### MsgRemoveCodeAuthorization -| Field | Type | Label | Description | -| --------- | ----------------- | ----- | ----------- | -| `sender` | [string](#string) | | | -| `code_id` | [uint64](#uint64) | | | + - +### MsgExecuteProposal +MsgExecuteProposal defines an sdk.Msg type that supports submitting arbitrary +proposal Content. -### MsgRemoveCodeAuthorizationResponse - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authority` | [string](#string) | | | +| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | -### MsgRemoveContractAuthorization -| Field | Type | Label | Description | -| ------------------ | ----------------- | ----- | ----------- | -| `sender` | [string](#string) | | | -| `contract_address` | [string](#string) | | | - -### MsgRemoveContractAuthorizationResponse - -### MsgSetCodeAuthorization + -| Field | Type | Label | Description | -| -------------------- | --------------------------------------------------------------------------- | ----- | ----------- | -| `sender` | [string](#string) | | | -| `code_authorization` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | | | +### MsgExecuteProposalResponse +MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. - -### MsgSetCodeAuthorizationResponse - -### MsgPromoteToPrivilegedContract -MsgPromoteToPrivilegedContract defines the Msg/PromoteToPrivilegedContract -### MsgSetContractAuthorization + -| Field | Type | Label | Description | -| ------------------------ | ----------------------------------------------------------------------------------- | ----- | ----------- | -| `sender` | [string](#string) | | | -| `contract_authorization` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | | | +### MsgUpdateParams - -### MsgSetContractAuthorizationResponse - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authority` | [string](#string) | | Authority is the address of the governance account. | +| `params` | [Params](#publicawesome.stargaze.authority.v1.Params) | | NOTE: All parameters must be supplied. | + + + + + + + + +### MsgUpdateParamsResponse + -### MsgUpdateParams -| Field | Type | Label | Description | -| -------- | ----------------------------------------------------- | ----- | -------------------------------------- | -| `sender` | [string](#string) | | | -| `params` | [Params](#publicawesome.stargaze.globalfee.v1.Params) | | NOTE: All parameters must be supplied. | - -### MsgCreateDenomResponse -MsgCreateDenomResponse is the return value of MsgCreateDenom -It returns the full string of the newly created denom @@ -341,36 +223,38 @@ It returns the full string of the newly created denom - -### Msg + -Msg defines the alloc Msg service. +### Msg +Msg defines the authority Msg service. -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ------------------------------ | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------- | --------- | -------- | -| `PromoteToPrivilegedContract` | [MsgPromoteToPrivilegedContract](#publicawesome.stargaze.cron.v1.MsgPromoteToPrivilegedContract) | [MsgPromoteToPrivilegedContractResponse](#publicawesome.stargaze.cron.v1.MsgPromoteToPrivilegedContractResponse) | PromoteToPrivilegedContract promotes a contract to privileged status. | | -| `DemoteFromPrivilegedContract` | [MsgDemoteFromPrivilegedContract](#publicawesome.stargaze.cron.v1.MsgDemoteFromPrivilegedContract) | [MsgDemoteFromPrivilegedContractResponse](#publicawesome.stargaze.cron.v1.MsgDemoteFromPrivilegedContractResponse) | DemoteFromPrivilegedContract demotes a contract from privileged status. | | -| `UpdateParams` | [MsgUpdateParams](#publicawesome.stargaze.cron.v1.MsgUpdateParams) | [MsgUpdateParamsResponse](#publicawesome.stargaze.cron.v1.MsgUpdateParamsResponse) | UpdateParams updates the cron module's parameters. | | +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `ExecuteProposal` | [MsgExecuteProposal](#publicawesome.stargaze.authority.v1.MsgExecuteProposal) | [MsgExecuteProposalResponse](#publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse) | | | +| `UpdateParams` | [MsgUpdateParams](#publicawesome.stargaze.authority.v1.MsgUpdateParams) | [MsgUpdateParamsResponse](#publicawesome.stargaze.authority.v1.MsgUpdateParamsResponse) | | | + + ## Scalar Value Types -| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | -| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ---------- | ----------- | ------- | ---------- | -------------- | ------------------------------ | -| double | | double | double | float | float64 | double | float | Float | -| float | | float | float | float | float32 | float | float | Float | -| int32 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | -| int64 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. | int64 | long | int/long | int64 | long | integer/string | Bignum | -| uint32 | Uses variable-length encoding. | uint32 | int | int/long | uint32 | uint | integer | Bignum or Fixnum (as required) | -| uint64 | Uses variable-length encoding. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum or Fixnum (as required) | -| sint32 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | -| sint64 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. | int64 | long | int/long | int64 | long | integer/string | Bignum | -| fixed32 | Always four bytes. More efficient than uint32 if values are often greater than 2^28. | uint32 | int | int | uint32 | uint | integer | Bignum or Fixnum (as required) | -| fixed64 | Always eight bytes. More efficient than uint64 if values are often greater than 2^56. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum | -| sfixed32 | Always four bytes. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | -| sfixed64 | Always eight bytes. | int64 | long | int/long | int64 | long | integer/string | Bignum | -| bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass | -| string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) | -| bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) | +| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | +| ----------- | ----- | --- | ---- | ------ | -- | -- | --- | ---- | +| double | | double | double | float | float64 | double | float | Float | +| float | | float | float | float | float32 | float | float | Float | +| int32 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | +| int64 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. | int64 | long | int/long | int64 | long | integer/string | Bignum | +| uint32 | Uses variable-length encoding. | uint32 | int | int/long | uint32 | uint | integer | Bignum or Fixnum (as required) | +| uint64 | Uses variable-length encoding. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum or Fixnum (as required) | +| sint32 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | +| sint64 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. | int64 | long | int/long | int64 | long | integer/string | Bignum | +| fixed32 | Always four bytes. More efficient than uint32 if values are often greater than 2^28. | uint32 | int | int | uint32 | uint | integer | Bignum or Fixnum (as required) | +| fixed64 | Always eight bytes. More efficient than uint64 if values are often greater than 2^56. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum | +| sfixed32 | Always four bytes. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | +| sfixed64 | Always eight bytes. | int64 | long | int/long | int64 | long | integer/string | Bignum | +| bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass | +| string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) | +| bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) | + From 2aa3a869c65e436c03519d54b11ac973e287a801 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 23 Feb 2024 15:38:56 +0000 Subject: [PATCH 13/20] proto cleanup --- app/app.go | 1 - docs/proto/proto-docs.md | 31 +-- docs/swagger-ui/swagger.yaml | 181 +++--------------- go.mod | 4 +- go.sum | 9 +- .../stargaze/authority/v1/authority.proto | 10 +- .../stargaze/authority/v1/genesis.proto | 4 +- .../stargaze/authority/v1/query.proto | 3 + .../stargaze/authority/v1/tx.proto | 28 +-- .../stargaze/cron/v1/proposal.proto | 12 +- .../stargaze/cron/v1/query.proto | 6 +- .../stargaze/globalfee/v1/proposal.proto | 25 +-- .../stargaze/globalfee/v1/tx.proto | 2 +- .../stargaze/mint/v1beta1/tx.proto | 4 +- x/authority/keeper/keeper.go | 8 +- x/authority/keeper/proposal.go | 10 - x/authority/module.go | 10 +- x/authority/types/authority.pb.go | 30 +-- x/authority/types/genesis.pb.go | 2 + x/authority/types/msgs.go | 22 +-- x/authority/types/query.pb.go | 4 + x/authority/types/tx.pb.go | 12 +- 22 files changed, 153 insertions(+), 265 deletions(-) diff --git a/app/app.go b/app/app.go index 1f8c6ee3b..fd45c5041 100644 --- a/app/app.go +++ b/app/app.go @@ -1227,7 +1227,6 @@ func initParamsKeeper( paramsKeeper.Subspace(cronmoduletypes.ModuleName) paramsKeeper.Subspace(icahosttypes.SubModuleName) paramsKeeper.Subspace(globalfeemoduletypes.ModuleName) - paramsKeeper.Subspace(authoritytypes.ModuleName) paramsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable()) return paramsKeeper diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 7aecfd768..bb1173a00 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -39,13 +39,14 @@ ### Authorization - +Authorization is a struct that holds the addresses that are allowed to +execute a proposal | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `msgTypeUrl` | [string](#string) | | The type url of a proposal sdk.Msg | -| `addresses` | [string](#string) | repeated | The addresses who are allowed to execute that proposal | +| `msg_type_url` | [string](#string) | | msgTypeUrl is the type url of a proposal sdk.Msg | +| `addresses` | [string](#string) | repeated | addresses is a list of addresses that are allowed to execute the proposal | @@ -60,7 +61,7 @@ Params holds parameters for the authority module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `authorizations` | [Authorization](#publicawesome.stargaze.authority.v1.Authorization) | repeated | | +| `authorizations` | [Authorization](#publicawesome.stargaze.authority.v1.Authorization) | repeated | authorizations is a list of authorizations that are allowed to execute a proposal | @@ -86,12 +87,12 @@ Params holds parameters for the authority module. ### GenesisState - +GenesisState defines the authority module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#publicawesome.stargaze.authority.v1.Params) | | | +| `params` | [Params](#publicawesome.stargaze.authority.v1.Params) | | params defines all the parameters of the module. | @@ -117,7 +118,7 @@ Params holds parameters for the authority module. ### QueryParamsRequest - +QueryParamsRequest is the request type for the Query/Params RPC method. @@ -127,7 +128,7 @@ Params holds parameters for the authority module. ### QueryParamsResponse - +QueryParamsResponse is the response type for the Query/Params RPC method. | Field | Type | Label | Description | @@ -152,7 +153,7 @@ Query defines the gRPC querier service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Params` | [QueryParamsRequest](#publicawesome.stargaze.authority.v1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.authority.v1.QueryParamsResponse) | | GET|/stargaze/authority/v1/params| +| `Params` | [QueryParamsRequest](#publicawesome.stargaze.authority.v1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.authority.v1.QueryParamsResponse) | Params queries the parameters of the authority module. | GET|/stargaze/authority/v1/params| @@ -174,8 +175,8 @@ proposal Content. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `authority` | [string](#string) | | | -| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | +| `authority` | [string](#string) | | authority is the address of the account authorized to execute the proposal. | +| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | messages is the list of messages to execute. | @@ -195,7 +196,7 @@ MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. ### MsgUpdateParams - +MsgUpdateParams defines an sdk.Msg type that supports updating the authority | Field | Type | Label | Description | @@ -211,7 +212,7 @@ MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. ### MsgUpdateParamsResponse - +MsgUpdateParamsResponse defines the Msg/UpdateParams response type. @@ -231,8 +232,8 @@ Msg defines the authority Msg service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `ExecuteProposal` | [MsgExecuteProposal](#publicawesome.stargaze.authority.v1.MsgExecuteProposal) | [MsgExecuteProposalResponse](#publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse) | | | -| `UpdateParams` | [MsgUpdateParams](#publicawesome.stargaze.authority.v1.MsgUpdateParams) | [MsgUpdateParamsResponse](#publicawesome.stargaze.authority.v1.MsgUpdateParamsResponse) | | | +| `ExecuteProposal` | [MsgExecuteProposal](#publicawesome.stargaze.authority.v1.MsgExecuteProposal) | [MsgExecuteProposalResponse](#publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse) | ExecuteProposal defines a method to execute a proposal. | | +| `UpdateParams` | [MsgUpdateParams](#publicawesome.stargaze.authority.v1.MsgUpdateParams) | [MsgUpdateParamsResponse](#publicawesome.stargaze.authority.v1.MsgUpdateParamsResponse) | UpdateParams defines a method to update the authority parameters. | | diff --git a/docs/swagger-ui/swagger.yaml b/docs/swagger-ui/swagger.yaml index 13d51790a..0ad01ec9f 100644 --- a/docs/swagger-ui/swagger.yaml +++ b/docs/swagger-ui/swagger.yaml @@ -72,11 +72,7 @@ paths: custom method signatures required by gogoproto. - description: >- - SupplementAmount is the amount to be supplemented from the - pool on top of - - newly minted coins. + description: "SupplementAmount is the amount to be supplemented from the pool on top of\r\nnewly minted coins." description: >- QueryParamsResponse is the response type for the Query/Params RPC method. @@ -118,16 +114,8 @@ paths: type: array items: type: string - description: >- - contract_addresses holds all the smart contract addresses - which have - - privilege status. - description: >- - QueryListPrivilegedResponse is response type for the - Query/ListPrivileged RPC - - method. + description: "contract_addresses holds all the smart contract addresses which have\r\nprivilege status." + description: "QueryListPrivilegedResponse is response type for the Query/ListPrivileged RPC\r\nmethod." default: description: An unexpected error response. schema: @@ -168,15 +156,9 @@ paths: type: array items: type: string - description: >- - Addresses which act as admins of the module. They can - promote and demote - - contracts without having to go via governance. + description: "Addresses which act as admins of the module. They can promote and demote\r\ncontracts without having to go via governance." description: Params holds parameters for the cron module. - description: |- - QueryParamsResponse is response type for the Query/Params RPC - method. + description: "QueryParamsResponse is response type for the Query/Params RPC\r\nmethod." default: description: An unexpected error response. schema: @@ -433,9 +415,7 @@ paths: description: >- annual_provisions is the current minting annual provisions value. - description: |- - QueryAnnualProvisionsResponse is the response type for the - Query/AnnualProvisions RPC method. + description: "QueryAnnualProvisionsResponse is the response type for the\r\nQuery/AnnualProvisions RPC method." default: description: An unexpected error response. schema: @@ -520,9 +500,7 @@ paths: - Query /stargaze/tokenfactory/v1/denoms/{denom}/authority_metadata: get: - summary: |- - DenomAuthorityMetadata defines a gRPC query method for fetching - DenomAuthorityMetadata for a particular denom. + summary: "DenomAuthorityMetadata defines a gRPC query method for fetching\r\nDenomAuthorityMetadata for a particular denom." operationId: DenomAuthorityMetadata responses: '200': @@ -536,19 +514,8 @@ paths: admin: type: string title: Can be empty for no admin, or a valid stargaze address - description: >- - DenomAuthorityMetadata specifies metadata for addresses that - have specific - - capabilities over a token factory denom. Right now there is - only one Admin - - permission, but is planned to be extended to the future. - description: >- - QueryDenomAuthorityMetadataResponse defines the response structure - for the - - DenomAuthorityMetadata gRPC query. + description: "DenomAuthorityMetadata specifies metadata for addresses that have specific\r\ncapabilities over a token factory denom. Right now there is only one Admin\r\npermission, but is planned to be extended to the future." + description: "QueryDenomAuthorityMetadataResponse defines the response structure for the\r\nDenomAuthorityMetadata gRPC query." default: description: An unexpected error response. schema: @@ -580,9 +547,7 @@ paths: - Query /stargaze/tokenfactory/v1/denoms_from_creator/{creator}: get: - summary: |- - DenomsFromCreator defines a gRPC query method for fetching all - denominations created by a specific admin/creator. + summary: "DenomsFromCreator defines a gRPC query method for fetching all\r\ndenominations created by a specific admin/creator." operationId: DenomsFromCreator responses: '200': @@ -594,11 +559,7 @@ paths: type: array items: type: string - description: >- - QueryDenomsFromCreatorRequest defines the response structure for - the - - DenomsFromCreator gRPC query. + description: "QueryDenomsFromCreatorRequest defines the response structure for the\r\nDenomsFromCreator gRPC query." default: description: An unexpected error response. schema: @@ -630,11 +591,7 @@ paths: - Query /stargaze/tokenfactory/v1/params: get: - summary: >- - Params defines a gRPC query method that returns the tokenfactory - module's - - parameters. + summary: "Params defines a gRPC query method that returns the tokenfactory module's\r\nparameters." operationId: TokenFactoryParams responses: '200': @@ -663,25 +620,11 @@ paths: custom method signatures required by gogoproto. - description: >- - DenomCreationFee defines the fee to be charged on the - creation of a new - - denom. The fee is drawn from the MsgCreateDenom's sender - account, and - - transferred to the community pool. + description: "DenomCreationFee defines the fee to be charged on the creation of a new\r\ndenom. The fee is drawn from the MsgCreateDenom's sender account, and\r\ntransferred to the community pool." denom_creation_gas_consume: type: string format: uint64 - description: >- - DenomCreationGasConsume defines the gas cost for creating - a new denom. - - This is intended as a spam deterrence mechanism. - - - See: https://github.com/CosmWasm/token-factory/issues/11 + title: "DenomCreationGasConsume defines the gas cost for creating a new denom.\r\nThis is intended as a spam deterrence mechanism.\r\n\r\nSee: https://github.com/CosmWasm/token-factory/issues/11" description: >- QueryParamsResponse is the response type for the Query/Params RPC method. @@ -48173,11 +48116,7 @@ definitions: NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. - description: >- - SupplementAmount is the amount to be supplemented from the pool on top - of - - newly minted coins. + description: "SupplementAmount is the amount to be supplemented from the pool on top of\r\nnewly minted coins." description: Params defines the parameters for the alloc module. publicawesome.stargaze.alloc.v1beta1.QueryParamsResponse: type: object @@ -48240,11 +48179,7 @@ definitions: method signatures required by gogoproto. - description: >- - SupplementAmount is the amount to be supplemented from the pool on - top of - - newly minted coins. + description: "SupplementAmount is the amount to be supplemented from the pool on top of\r\nnewly minted coins." description: QueryParamsResponse is the response type for the Query/Params RPC method. publicawesome.stargaze.alloc.v1beta1.WeightedAddress: type: object @@ -48261,11 +48196,7 @@ definitions: type: array items: type: string - description: >- - Addresses which act as admins of the module. They can promote and - demote - - contracts without having to go via governance. + description: "Addresses which act as admins of the module. They can promote and demote\r\ncontracts without having to go via governance." description: Params holds parameters for the cron module. publicawesome.stargaze.cron.v1.QueryListPrivilegedResponse: type: object @@ -48274,14 +48205,8 @@ definitions: type: array items: type: string - description: |- - contract_addresses holds all the smart contract addresses which have - privilege status. - description: >- - QueryListPrivilegedResponse is response type for the Query/ListPrivileged - RPC - - method. + description: "contract_addresses holds all the smart contract addresses which have\r\nprivilege status." + description: "QueryListPrivilegedResponse is response type for the Query/ListPrivileged RPC\r\nmethod." publicawesome.stargaze.cron.v1.QueryParamsResponse: type: object properties: @@ -48292,15 +48217,9 @@ definitions: type: array items: type: string - description: >- - Addresses which act as admins of the module. They can promote and - demote - - contracts without having to go via governance. + description: "Addresses which act as admins of the module. They can promote and demote\r\ncontracts without having to go via governance." description: Params holds parameters for the cron module. - description: |- - QueryParamsResponse is response type for the Query/Params RPC - method. + description: "QueryParamsResponse is response type for the Query/Params RPC\r\nmethod." cosmos.base.v1beta1.DecCoin: type: object properties: @@ -48469,9 +48388,7 @@ definitions: type: string format: byte description: annual_provisions is the current minting annual provisions value. - description: |- - QueryAnnualProvisionsResponse is the response type for the - Query/AnnualProvisions RPC method. + description: "QueryAnnualProvisionsResponse is the response type for the\r\nQuery/AnnualProvisions RPC method." publicawesome.stargaze.mint.v1beta1.QueryParamsResponse: type: object properties: @@ -48503,10 +48420,7 @@ definitions: admin: type: string title: Can be empty for no admin, or a valid stargaze address - description: |- - DenomAuthorityMetadata specifies metadata for addresses that have specific - capabilities over a token factory denom. Right now there is only one Admin - permission, but is planned to be extended to the future. + description: "DenomAuthorityMetadata specifies metadata for addresses that have specific\r\ncapabilities over a token factory denom. Right now there is only one Admin\r\npermission, but is planned to be extended to the future." osmosis.tokenfactory.v1beta1.Params: type: object properties: @@ -48524,21 +48438,11 @@ definitions: NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. - description: >- - DenomCreationFee defines the fee to be charged on the creation of a - new - - denom. The fee is drawn from the MsgCreateDenom's sender account, and - - transferred to the community pool. + description: "DenomCreationFee defines the fee to be charged on the creation of a new\r\ndenom. The fee is drawn from the MsgCreateDenom's sender account, and\r\ntransferred to the community pool." denom_creation_gas_consume: type: string format: uint64 - description: |- - DenomCreationGasConsume defines the gas cost for creating a new denom. - This is intended as a spam deterrence mechanism. - - See: https://github.com/CosmWasm/token-factory/issues/11 + title: "DenomCreationGasConsume defines the gas cost for creating a new denom.\r\nThis is intended as a spam deterrence mechanism.\r\n\r\nSee: https://github.com/CosmWasm/token-factory/issues/11" description: Params defines the parameters for the tokenfactory module. osmosis.tokenfactory.v1beta1.QueryDenomAuthorityMetadataResponse: type: object @@ -48549,17 +48453,8 @@ definitions: admin: type: string title: Can be empty for no admin, or a valid stargaze address - description: >- - DenomAuthorityMetadata specifies metadata for addresses that have - specific - - capabilities over a token factory denom. Right now there is only one - Admin - - permission, but is planned to be extended to the future. - description: |- - QueryDenomAuthorityMetadataResponse defines the response structure for the - DenomAuthorityMetadata gRPC query. + description: "DenomAuthorityMetadata specifies metadata for addresses that have specific\r\ncapabilities over a token factory denom. Right now there is only one Admin\r\npermission, but is planned to be extended to the future." + description: "QueryDenomAuthorityMetadataResponse defines the response structure for the\r\nDenomAuthorityMetadata gRPC query." osmosis.tokenfactory.v1beta1.QueryDenomsFromCreatorResponse: type: object properties: @@ -48567,9 +48462,7 @@ definitions: type: array items: type: string - description: |- - QueryDenomsFromCreatorRequest defines the response structure for the - DenomsFromCreator gRPC query. + description: "QueryDenomsFromCreatorRequest defines the response structure for the\r\nDenomsFromCreator gRPC query." osmosis.tokenfactory.v1beta1.QueryParamsResponse: type: object properties: @@ -48594,25 +48487,11 @@ definitions: method signatures required by gogoproto. - description: >- - DenomCreationFee defines the fee to be charged on the creation of - a new - - denom. The fee is drawn from the MsgCreateDenom's sender account, - and - - transferred to the community pool. + description: "DenomCreationFee defines the fee to be charged on the creation of a new\r\ndenom. The fee is drawn from the MsgCreateDenom's sender account, and\r\ntransferred to the community pool." denom_creation_gas_consume: type: string format: uint64 - description: >- - DenomCreationGasConsume defines the gas cost for creating a new - denom. - - This is intended as a spam deterrence mechanism. - - - See: https://github.com/CosmWasm/token-factory/issues/11 + title: "DenomCreationGasConsume defines the gas cost for creating a new denom.\r\nThis is intended as a spam deterrence mechanism.\r\n\r\nSee: https://github.com/CosmWasm/token-factory/issues/11" description: QueryParamsResponse is the response type for the Query/Params RPC method. cosmos.base.query.v1beta1.PageRequest: type: object diff --git a/go.mod b/go.mod index d45f950bc..2c6ba03d9 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,6 @@ require ( cosmossdk.io/x/feegrant v0.1.0 cosmossdk.io/x/tx v0.13.0 cosmossdk.io/x/upgrade v0.1.1 - github.com/cometbft/cometbft-db v0.9.1 github.com/cosmos/cosmos-db v1.0.0 github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.0-20231226225155-84a39dda1805 github.com/cosmos/ibc-apps/modules/ibc-hooks/v8 v8.0.0-00010101000000-000000000000 @@ -78,6 +77,7 @@ require ( github.com/cockroachdb/pebble v1.1.0 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/cometbft/cometbft-db v0.9.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect @@ -102,8 +102,6 @@ require ( github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect - github.com/go-logr/logr v1.2.4 // indirect - github.com/go-logr/stdr v1.2.2 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect diff --git a/go.sum b/go.sum index 279b08a3f..d32bdc736 100644 --- a/go.sum +++ b/go.sum @@ -1459,6 +1459,7 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= @@ -1788,14 +1789,6 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs= -go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY= -go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE= -go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8= -go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o= -go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= -go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg= -go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= diff --git a/proto/publicawesome/stargaze/authority/v1/authority.proto b/proto/publicawesome/stargaze/authority/v1/authority.proto index 3ae1b7499..3b5c62917 100644 --- a/proto/publicawesome/stargaze/authority/v1/authority.proto +++ b/proto/publicawesome/stargaze/authority/v1/authority.proto @@ -8,10 +8,16 @@ option go_package = "github.com/public-awesome/stargaze/v13/x/authority/types"; // Params holds parameters for the authority module. message Params { option (gogoproto.goproto_stringer) = false; + // authorizations is a list of authorizations that are allowed to execute a + // proposal repeated Authorization authorizations = 1; } +// Authorization is a struct that holds the addresses that are allowed to +// execute a proposal message Authorization { - string msgTypeUrl = 1; // The type url of a proposal sdk.Msg - repeated string addresses = 2; // The addresses who are allowed to execute that proposal + // msgTypeUrl is the type url of a proposal sdk.Msg + string msg_type_url = 1; + // addresses is a list of addresses that are allowed to execute the proposal + repeated string addresses = 2; } \ No newline at end of file diff --git a/proto/publicawesome/stargaze/authority/v1/genesis.proto b/proto/publicawesome/stargaze/authority/v1/genesis.proto index 57674db2c..186c1fbab 100644 --- a/proto/publicawesome/stargaze/authority/v1/genesis.proto +++ b/proto/publicawesome/stargaze/authority/v1/genesis.proto @@ -6,8 +6,10 @@ import "publicawesome/stargaze/authority/v1/authority.proto"; option go_package = "github.com/public-awesome/stargaze/v13/x/authority/types"; +// GenesisState defines the authority module's genesis state. message GenesisState { - Params params = 1 [ + // params defines all the parameters of the module. + Params params = 1 [ (gogoproto.jsontag) = "params,omitempty", (gogoproto.nullable) = false ]; diff --git a/proto/publicawesome/stargaze/authority/v1/query.proto b/proto/publicawesome/stargaze/authority/v1/query.proto index 9671a4770..708ced15d 100644 --- a/proto/publicawesome/stargaze/authority/v1/query.proto +++ b/proto/publicawesome/stargaze/authority/v1/query.proto @@ -8,11 +8,14 @@ option go_package = "github.com/public-awesome/stargaze/v13/x/authority/types"; // Query defines the gRPC querier service. service Query { + // Params queries the parameters of the authority module. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/stargaze/authority/v1/params"; } } +// QueryParamsRequest is the request type for the Query/Params RPC method. message QueryParamsRequest {} +// QueryParamsResponse is the response type for the Query/Params RPC method. message QueryParamsResponse { Params params = 1; } \ No newline at end of file diff --git a/proto/publicawesome/stargaze/authority/v1/tx.proto b/proto/publicawesome/stargaze/authority/v1/tx.proto index bbf9cd591..64a507a33 100644 --- a/proto/publicawesome/stargaze/authority/v1/tx.proto +++ b/proto/publicawesome/stargaze/authority/v1/tx.proto @@ -10,22 +10,27 @@ option go_package = "github.com/public-awesome/stargaze/v13/x/authority/types"; // Msg defines the authority Msg service. service Msg { - rpc ExecuteProposal(MsgExecuteProposal) returns (MsgExecuteProposalResponse); - rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); - } + // ExecuteProposal defines a method to execute a proposal. + rpc ExecuteProposal(MsgExecuteProposal) returns (MsgExecuteProposalResponse); + // UpdateParams defines a method to update the authority parameters. + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); +} // MsgExecuteProposal defines an sdk.Msg type that supports submitting arbitrary // proposal Content. message MsgExecuteProposal { - option (cosmos.msg.v1.signer) = "authority"; - - string authority = 1; - repeated google.protobuf.Any messages = 2; - } - - // MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. -message MsgExecuteProposalResponse { } + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address of the account authorized to execute the proposal. + string authority = 1; + // messages is the list of messages to execute. + repeated google.protobuf.Any messages = 2; +} + +// MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. +message MsgExecuteProposalResponse {} +// MsgUpdateParams defines an sdk.Msg type that supports updating the authority message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; // Authority is the address of the governance account. @@ -37,4 +42,5 @@ message MsgUpdateParams { ]; } +// MsgUpdateParamsResponse defines the Msg/UpdateParams response type. message MsgUpdateParamsResponse {} \ No newline at end of file diff --git a/proto/publicawesome/stargaze/cron/v1/proposal.proto b/proto/publicawesome/stargaze/cron/v1/proposal.proto index cf9fb8003..81fbf891e 100644 --- a/proto/publicawesome/stargaze/cron/v1/proposal.proto +++ b/proto/publicawesome/stargaze/cron/v1/proposal.proto @@ -16,11 +16,11 @@ message PromoteToPrivilegedContractProposal { option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary - string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; + string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; // Description is a human readable text - string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; + string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; // Contract is the bech32 address of the smart contract - string contract = 3 [(gogoproto.moretags) = "yaml:\"contract\""]; + string contract = 3 [ (gogoproto.moretags) = "yaml:\"contract\"" ]; } // Deprecated: Do not use. To demote a contract, a @@ -32,9 +32,9 @@ message DemotePrivilegedContractProposal { option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary - string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; + string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; // Description is a human readable text - string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; + string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; // Contract is the bech32 address of the smart contract - string contract = 3 [(gogoproto.moretags) = "yaml:\"contract\""]; + string contract = 3 [ (gogoproto.moretags) = "yaml:\"contract\"" ]; } diff --git a/proto/publicawesome/stargaze/cron/v1/query.proto b/proto/publicawesome/stargaze/cron/v1/query.proto index 7ffad1b7c..40c8396ee 100644 --- a/proto/publicawesome/stargaze/cron/v1/query.proto +++ b/proto/publicawesome/stargaze/cron/v1/query.proto @@ -10,7 +10,8 @@ option go_package = "github.com/public-awesome/stargaze/v13/x/cron/types"; // Query defines the gRPC querier service. service Query { // ListPrivileged queries the contracts which have the priviledge status - rpc ListPrivileged(QueryListPrivilegedRequest) returns (QueryListPrivilegedResponse) { + rpc ListPrivileged(QueryListPrivilegedRequest) + returns (QueryListPrivilegedResponse) { option (google.api.http).get = "/stargaze/cron/v1/list-privileged"; } @@ -28,7 +29,8 @@ message QueryListPrivilegedRequest {} message QueryListPrivilegedResponse { // contract_addresses holds all the smart contract addresses which have // privilege status. - repeated string contract_addresses = 1 [(gogoproto.jsontag) = "privileged_contract_addresses,omitempty"]; + repeated string contract_addresses = 1 + [ (gogoproto.jsontag) = "privileged_contract_addresses,omitempty" ]; } // QueryParamsRequest is request type for the Query/Params RPC diff --git a/proto/publicawesome/stargaze/globalfee/v1/proposal.proto b/proto/publicawesome/stargaze/globalfee/v1/proposal.proto index 5f521a682..27812e42b 100644 --- a/proto/publicawesome/stargaze/globalfee/v1/proposal.proto +++ b/proto/publicawesome/stargaze/globalfee/v1/proposal.proto @@ -14,9 +14,10 @@ message SetCodeAuthorizationProposal { option (amino.name) = "globalfee/SetCodeAuthorizationProposal"; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; - string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; - string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; - CodeAuthorization code_authorization = 3 [(gogoproto.moretags) = "yaml:\"code_authorization\""]; + string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; + string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + CodeAuthorization code_authorization = 3 + [ (gogoproto.moretags) = "yaml:\"code_authorization\"" ]; } // RemoveCodeAuthorizationProposal @@ -25,8 +26,8 @@ message RemoveCodeAuthorizationProposal { option (amino.name) = "globalfee/RemoveCodeAuthorizationProposal"; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; - string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; - string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; + string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; + string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; uint64 code_id = 3 [ (gogoproto.customname) = "CodeID", (gogoproto.moretags) = "yaml:\"code_id\"" @@ -39,9 +40,10 @@ message SetContractAuthorizationProposal { option (amino.name) = "globalfee/SetContractAuthorizationProposal"; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; - string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; - string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; - ContractAuthorization contract_authorization = 3 [(gogoproto.moretags) = "yaml:\"contract_authorization\""]; + string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; + string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + ContractAuthorization contract_authorization = 3 + [ (gogoproto.moretags) = "yaml:\"contract_authorization\"" ]; } // RemoveCodeAuthorizationProposal ... @@ -50,7 +52,8 @@ message RemoveContractAuthorizationProposal { option (amino.name) = "globalfee/RemoveContractAuthorizationProposal"; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; - string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; - string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; - string contract_address = 3 [(gogoproto.moretags) = "yaml:\"contract_address\""]; + string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; + string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + string contract_address = 3 + [ (gogoproto.moretags) = "yaml:\"contract_address\"" ]; } diff --git a/proto/publicawesome/stargaze/globalfee/v1/tx.proto b/proto/publicawesome/stargaze/globalfee/v1/tx.proto index a0c58956c..2948eeef6 100644 --- a/proto/publicawesome/stargaze/globalfee/v1/tx.proto +++ b/proto/publicawesome/stargaze/globalfee/v1/tx.proto @@ -10,7 +10,7 @@ option go_package = "github.com/public-awesome/stargaze/v13/x/globalfee/types"; // Msg defines the alloc Msg service. service Msg { option (cosmos.msg.v1.service) = true; - + rpc SetCodeAuthorization(MsgSetCodeAuthorization) returns (MsgSetCodeAuthorizationResponse); diff --git a/proto/publicawesome/stargaze/mint/v1beta1/tx.proto b/proto/publicawesome/stargaze/mint/v1beta1/tx.proto index 86b61a1dc..4f5c75043 100644 --- a/proto/publicawesome/stargaze/mint/v1beta1/tx.proto +++ b/proto/publicawesome/stargaze/mint/v1beta1/tx.proto @@ -6,6 +6,4 @@ import "cosmos/msg/v1/msg.proto"; option go_package = "github.com/public-awesome/stargaze/v13/x/mint/types"; // Msg defines the mint Msg service. -service Msg { - option (cosmos.msg.v1.service) = true; -} +service Msg { option (cosmos.msg.v1.service) = true; } diff --git a/x/authority/keeper/keeper.go b/x/authority/keeper/keeper.go index a013350db..5f7f645af 100644 --- a/x/authority/keeper/keeper.go +++ b/x/authority/keeper/keeper.go @@ -3,10 +3,10 @@ package keeper import ( "fmt" - "github.com/cometbft/cometbft/libs/log" + log "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/baseapp" "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" "github.com/public-awesome/stargaze/v13/x/authority/types" @@ -49,9 +49,5 @@ func (k Keeper) Router() *baseapp.MsgServiceRouter { } func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ModuleLogger(ctx) -} - -func ModuleLogger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } diff --git a/x/authority/keeper/proposal.go b/x/authority/keeper/proposal.go index 7a41f13a7..a290a7bbc 100644 --- a/x/authority/keeper/proposal.go +++ b/x/authority/keeper/proposal.go @@ -13,16 +13,6 @@ func (keeper Keeper) ExecuteProposalMessages(ctx sdk.Context, messages []sdk.Msg // Loop through all messages and confirm that each has a handler and the authorizations for the msg are valid for _, msg := range messages { - // perform a basic validation of the message - if err := msg.ValidateBasic(); err != nil { - return 0, errorsmod.Wrap(govtypes.ErrInvalidProposalMsg, err.Error()) - } - - signers := msg.GetSigners() - if len(signers) != 1 { - return 0, govtypes.ErrInvalidSigner - } - valid, err := keeper.IsAuthorized(ctx, msg, proposer.String()) if !valid { return 0, err diff --git a/x/authority/module.go b/x/authority/module.go index 3ccf362a7..5c35b7635 100644 --- a/x/authority/module.go +++ b/x/authority/module.go @@ -138,9 +138,15 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block -func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} +func (am AppModule) BeginBlock(_ sdk.Context) {} // EndBlock contains the logic that is automatically triggered at the end of each block -func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { +func (am AppModule) EndBlock(_ sdk.Context) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} } + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (a AppModule) IsOnePerModuleType() {} + +// IsAppModule implements the appmodule.AppModule interface. +func (a AppModule) IsAppModule() {} diff --git a/x/authority/types/authority.pb.go b/x/authority/types/authority.pb.go index 62bdf05e4..3a2176737 100644 --- a/x/authority/types/authority.pb.go +++ b/x/authority/types/authority.pb.go @@ -25,6 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params holds parameters for the authority module. type Params struct { + // authorizations is a list of authorizations that are allowed to execute a + // proposal Authorizations []*Authorization `protobuf:"bytes,1,rep,name=authorizations,proto3" json:"authorizations,omitempty"` } @@ -67,9 +69,13 @@ func (m *Params) GetAuthorizations() []*Authorization { return nil } +// Authorization is a struct that holds the addresses that are allowed to +// execute a proposal type Authorization struct { - MsgTypeUrl string `protobuf:"bytes,1,opt,name=msgTypeUrl,proto3" json:"msgTypeUrl,omitempty"` - Addresses []string `protobuf:"bytes,2,rep,name=addresses,proto3" json:"addresses,omitempty"` + // msgTypeUrl is the type url of a proposal sdk.Msg + MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` + // addresses is a list of addresses that are allowed to execute the proposal + Addresses []string `protobuf:"bytes,2,rep,name=addresses,proto3" json:"addresses,omitempty"` } func (m *Authorization) Reset() { *m = Authorization{} } @@ -129,7 +135,7 @@ func init() { } var fileDescriptor_6e13d9034052c38a = []byte{ - // 257 bytes of a gzipped FileDescriptorProto + // 266 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x2e, 0x28, 0x4d, 0xca, 0xc9, 0x4c, 0x4e, 0x2c, 0x4f, 0x2d, 0xce, 0xcf, 0x4d, 0xd5, 0x2f, 0x2e, 0x49, 0x2c, 0x4a, 0x4f, 0xac, 0x4a, 0xd5, 0x4f, 0x2c, 0x2d, 0xc9, 0xc8, 0x2f, 0xca, 0x2c, 0xa9, 0xd4, 0x2f, 0x33, 0x44, @@ -138,15 +144,15 @@ var fileDescriptor_6e13d9034052c38a = []byte{ 0x4a, 0x59, 0x5c, 0x6c, 0x01, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x42, 0x51, 0x5c, 0x7c, 0x50, 0xf5, 0x55, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xc5, 0x12, 0x8c, 0x0a, 0xcc, 0x1a, 0xdc, 0x46, 0x46, 0x7a, 0x44, 0x98, 0xae, 0xe7, 0x88, 0xac, 0x35, 0x08, 0xcd, 0x24, 0x2b, 0x96, 0x19, 0x0b, 0xe4, 0x19, - 0x94, 0x7c, 0xb9, 0x78, 0x51, 0x94, 0x09, 0xc9, 0x71, 0x71, 0xe5, 0x16, 0xa7, 0x87, 0x54, 0x16, - 0xa4, 0x86, 0x16, 0xe5, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x21, 0x89, 0x08, 0xc9, 0x70, - 0x71, 0x26, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0xa7, 0x16, 0x4b, 0x30, 0x29, 0x30, 0x6b, 0x70, - 0x06, 0x21, 0x04, 0x9c, 0x82, 0x4e, 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, - 0x22, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xe2, 0x78, 0x5d, 0x8c, - 0x00, 0x2d, 0x33, 0x34, 0xd6, 0xaf, 0x40, 0x0a, 0xd6, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, - 0x70, 0xa8, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xad, 0x2e, 0x16, 0xa1, 0x87, 0x01, 0x00, - 0x00, + 0x94, 0xfc, 0xb9, 0x78, 0x51, 0x94, 0x09, 0x29, 0x70, 0xf1, 0xe4, 0x16, 0xa7, 0xc7, 0x97, 0x54, + 0x16, 0xa4, 0xc6, 0x97, 0x16, 0xe5, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x71, 0xe5, 0x16, + 0xa7, 0x87, 0x54, 0x16, 0xa4, 0x86, 0x16, 0xe5, 0x08, 0xc9, 0x70, 0x71, 0x26, 0xa6, 0xa4, 0x14, + 0xa5, 0x16, 0x17, 0xa7, 0x16, 0x4b, 0x30, 0x29, 0x30, 0x6b, 0x70, 0x06, 0x21, 0x04, 0x9c, 0x82, + 0x4e, 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, 0x22, 0x3d, 0xb3, 0x24, 0xa3, + 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xe2, 0x7c, 0x5d, 0x8c, 0x20, 0x2d, 0x33, 0x34, 0xd6, + 0xaf, 0x40, 0x0a, 0x58, 0x90, 0x33, 0x8a, 0x93, 0xd8, 0xc0, 0xe1, 0x62, 0x0c, 0x08, 0x00, 0x00, + 0xff, 0xff, 0x7e, 0x7b, 0x6f, 0x4d, 0x89, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/authority/types/genesis.pb.go b/x/authority/types/genesis.pb.go index 53f979f30..2d1c1f764 100644 --- a/x/authority/types/genesis.pb.go +++ b/x/authority/types/genesis.pb.go @@ -23,7 +23,9 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// GenesisState defines the authority module's genesis state. type GenesisState struct { + // params defines all the parameters of the module. Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` } diff --git a/x/authority/types/msgs.go b/x/authority/types/msgs.go index 39bf9c6fe..122386054 100644 --- a/x/authority/types/msgs.go +++ b/x/authority/types/msgs.go @@ -1,14 +1,11 @@ package types import ( - "fmt" - errorsmod "cosmossdk.io/errors" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdktx "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/gov/codec" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -67,24 +64,13 @@ func (m MsgExecuteProposal) ValidateBasic() error { return errorsmod.Wrap(govtypes.ErrNoProposalMsgs, "Msgs length must be non-nil") } - msgs, err := m.GetMsgs() - if err != nil { - return err - } - - for idx, msg := range msgs { - if err := msg.ValidateBasic(); err != nil { - return errorsmod.Wrap(govtypes.ErrInvalidProposalMsg, - fmt.Sprintf("msg: %d, err: %s", idx, err.Error())) - } - } - - return nil + _, err := m.GetMsgs() + return err } // GetSignBytes returns the message bytes to sign over. func (m MsgExecuteProposal) GetSignBytes() []byte { - bz := codec.ModuleCdc.MustMarshalJSON(&m) + bz := Amino.MustMarshalJSON(&m) return sdk.MustSortJSON(bz) } @@ -125,7 +111,7 @@ func (m MsgUpdateParams) ValidateBasic() error { // GetSignBytes returns the message bytes to sign over. func (m MsgUpdateParams) GetSignBytes() []byte { - bz := codec.ModuleCdc.MustMarshalJSON(&m) + bz := Amino.MustMarshalJSON(&m) return sdk.MustSortJSON(bz) } diff --git a/x/authority/types/query.pb.go b/x/authority/types/query.pb.go index f84dedbe3..f5649ec88 100644 --- a/x/authority/types/query.pb.go +++ b/x/authority/types/query.pb.go @@ -28,6 +28,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// QueryParamsRequest is the request type for the Query/Params RPC method. type QueryParamsRequest struct { } @@ -64,6 +65,7 @@ func (m *QueryParamsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo +// 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,omitempty"` } @@ -151,6 +153,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 authority module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) } @@ -173,6 +176,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 authority module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) } diff --git a/x/authority/types/tx.pb.go b/x/authority/types/tx.pb.go index de09c9a02..299a7e9d6 100644 --- a/x/authority/types/tx.pb.go +++ b/x/authority/types/tx.pb.go @@ -33,8 +33,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgExecuteProposal defines an sdk.Msg type that supports submitting arbitrary // proposal Content. type MsgExecuteProposal struct { - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - Messages []*types.Any `protobuf:"bytes,2,rep,name=messages,proto3" json:"messages,omitempty"` + // authority is the address of the account authorized to execute the proposal. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // messages is the list of messages to execute. + Messages []*types.Any `protobuf:"bytes,2,rep,name=messages,proto3" json:"messages,omitempty"` } func (m *MsgExecuteProposal) Reset() { *m = MsgExecuteProposal{} } @@ -121,6 +123,7 @@ func (m *MsgExecuteProposalResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgExecuteProposalResponse proto.InternalMessageInfo +// MsgUpdateParams defines an sdk.Msg type that supports updating the authority type MsgUpdateParams struct { // Authority is the address of the governance account. Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` @@ -175,6 +178,7 @@ func (m *MsgUpdateParams) GetParams() Params { return Params{} } +// MsgUpdateParamsResponse defines the Msg/UpdateParams response type. type MsgUpdateParamsResponse struct { } @@ -265,7 +269,9 @@ 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 MsgClient interface { + // ExecuteProposal defines a method to execute a proposal. ExecuteProposal(ctx context.Context, in *MsgExecuteProposal, opts ...grpc.CallOption) (*MsgExecuteProposalResponse, error) + // UpdateParams defines a method to update the authority parameters. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) } @@ -297,7 +303,9 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts // MsgServer is the server API for Msg service. type MsgServer interface { + // ExecuteProposal defines a method to execute a proposal. ExecuteProposal(context.Context, *MsgExecuteProposal) (*MsgExecuteProposalResponse, error) + // UpdateParams defines a method to update the authority parameters. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) } From 96b6a2b636c796f5e53f60513cb6b0ba8507ea5e Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 23 Feb 2024 15:47:37 +0000 Subject: [PATCH 14/20] adding upgrade handler --- app/upgrades.go | 184 +++++++++++------------------------------------- 1 file changed, 40 insertions(+), 144 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index dd9ae0b29..0d3f56074 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -1,146 +1,42 @@ package app -// import ( -// "fmt" - -// wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" -// "github.com/cosmos/cosmos-sdk/baseapp" -// store "cosmossdk.io/store/types" -// sdk "github.com/cosmos/cosmos-sdk/types" -// "github.com/cosmos/cosmos-sdk/types/module" -// authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" -// banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" -// consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" -// crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" -// distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" -// govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" -// govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" -// paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" -// slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" -// stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" -// upgradetypes "cosmossdk.io/x/upgrade/types" -// icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" -// icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" -// ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" - -// ibctmmigrations "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint/migrations" - -// alloctypes "github.com/public-awesome/stargaze/v13/x/alloc/types" -// globalfeetypes "github.com/public-awesome/stargaze/v13/x/globalfee/types" -// minttypes "github.com/public-awesome/stargaze/v13/x/mint/types" -// tokenfactorytypes "github.com/public-awesome/stargaze/v13/x/tokenfactory/types" -// ) - -// // next upgrade name -// const upgradeName = "v13" - -// const claimModuleName = "claim" - -// // RegisterUpgradeHandlers returns upgrade handlers -// func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) { -// // Set param key table for params module migration -// for _, subspace := range app.ParamsKeeper.GetSubspaces() { -// subspace := subspace - -// var keyTable paramstypes.KeyTable -// switch subspace.Name() { -// case authtypes.ModuleName: -// keyTable = authtypes.ParamKeyTable() //nolint:staticcheck -// case banktypes.ModuleName: -// keyTable = banktypes.ParamKeyTable() //nolint:staticcheck -// case stakingtypes.ModuleName: -// keyTable = stakingtypes.ParamKeyTable() -// case distrtypes.ModuleName: -// keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck -// case slashingtypes.ModuleName: -// keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck -// case govtypes.ModuleName: -// keyTable = govv1.ParamKeyTable() //nolint:staticcheck -// case crisistypes.ModuleName: -// keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck -// // ibc types -// case ibctransfertypes.ModuleName: -// keyTable = ibctransfertypes.ParamKeyTable() -// case icahosttypes.SubModuleName: -// keyTable = icahosttypes.ParamKeyTable() -// case icacontrollertypes.SubModuleName: -// keyTable = icacontrollertypes.ParamKeyTable() -// // wasm -// case wasmtypes.ModuleName: -// keyTable = wasmtypes.ParamKeyTable() //nolint - -// // stargaze modules -// case alloctypes.ModuleName: -// keyTable = alloctypes.ParamKeyTable() -// case globalfeetypes.ModuleName: -// keyTable = globalfeetypes.ParamKeyTable() -// case minttypes.ModuleName: -// keyTable = minttypes.ParamKeyTable() -// case tokenfactorytypes.ModuleName: -// keyTable = tokenfactorytypes.ParamKeyTable() -// default: -// continue -// } - -// if !subspace.HasKeyTable() { -// subspace.WithKeyTable(keyTable) -// } -// } - -// baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) - -// app.UpgradeKeeper.SetUpgradeHandler(upgradeName, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { -// // Migrate Tendermint consensus parameters from x/params module to a dedicated x/consensus module. -// baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper) - -// _, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, app.appCodec, app.IBCKeeper.ClientKeeper) -// if err != nil { -// return nil, err -// } - -// // run migrations before modifying state -// migrations, err := app.mm.RunMigrations(ctx, cfg, fromVM) -// if err != nil { -// return nil, err -// } -// // set min deposit ratio to 20% -// govParams := app.GovKeeper.GetParams(ctx) -// govParams.BurnProposalDepositPrevote = true -// govParams.BurnVoteQuorum = true -// govParams.BurnVoteVeto = true -// govParams.MinInitialDepositRatio = sdk.NewDecWithPrec(20, 2).String() -// err = app.GovKeeper.SetParams(ctx, govParams) -// if err != nil { -// return nil, err -// } - -// // set min commission to 5% -// stakingParams := app.StakingKeeper.GetParams(ctx) -// stakingParams.MinCommissionRate = sdk.NewDecWithPrec(5, 2) -// err = app.StakingKeeper.SetParams(ctx, stakingParams) -// if err != nil { -// return nil, err -// } - -// return migrations, nil -// }) - -// upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() -// if err != nil { -// panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) -// } - -// if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { -// storeUpgrades := store.StoreUpgrades{ -// Added: []string{ -// consensustypes.ModuleName, -// crisistypes.ModuleName, -// }, -// Deleted: []string{ -// claimModuleName, -// }, -// } -// // configure store loader that checks if version == upgradeHeight and applies store upgrades -// app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) -// } -// } +import ( + "context" + "fmt" + + store "cosmossdk.io/store/types" + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/types/module" + authoritytypes "github.com/public-awesome/stargaze/v13/x/authority/types" +) + +// next upgrade name +const upgradeName = "v13" + +const claimModuleName = "claim" + +// RegisterUpgradeHandlers returns upgrade handlers +func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) { + + app.UpgradeKeeper.SetUpgradeHandler(upgradeName, func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return app.ModuleManager.RunMigrations(ctx, cfg, fromVM) + }) + + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() + if err != nil { + panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) + } + + if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + storeUpgrades := store.StoreUpgrades{ + Added: []string{ + authoritytypes.ModuleName, + }, + Deleted: []string{ + claimModuleName, + }, + } + // configure store loader that checks if version == upgradeHeight and applies store upgrades + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) + } +} From d73004db79c451ae2aca66d5c045f20d758c22ab Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 23 Feb 2024 16:00:35 +0000 Subject: [PATCH 15/20] Update interchaintest.yml --- .github/workflows/interchaintest.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/interchaintest.yml b/.github/workflows/interchaintest.yml index 918bca9f8..d322d0424 100644 --- a/.github/workflows/interchaintest.yml +++ b/.github/workflows/interchaintest.yml @@ -2,8 +2,6 @@ name: Run InterchainTest on: pull_request: - branches: - - main release: types: published From 6a7125b5c5a5e4cc3fd2f3f5346fbf5e42183bf1 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 1 Mar 2024 16:31:24 +0000 Subject: [PATCH 16/20] Update upgrades.go --- app/upgrades.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/upgrades.go b/app/upgrades.go index 0d3f56074..05308e5b7 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -6,6 +6,7 @@ import ( store "cosmossdk.io/store/types" upgradetypes "cosmossdk.io/x/upgrade/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" authoritytypes "github.com/public-awesome/stargaze/v13/x/authority/types" ) @@ -19,7 +20,10 @@ const claimModuleName = "claim" func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) { app.UpgradeKeeper.SetUpgradeHandler(upgradeName, func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - return app.ModuleManager.RunMigrations(ctx, cfg, fromVM) + migrations, err := app.ModuleManager.RunMigrations(ctx, cfg, fromVM) + + app.AuthorityKeeper.SetParams(sdk.UnwrapSDKContext(ctx), authoritytypes.DefaultParams()) + return migrations, err }) upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() From 0b311a796d25d3fcf9f12698aff77328f6792431 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:07:41 +0530 Subject: [PATCH 17/20] moving authority keeper to new keeper file --- app/keepers/keepers.go | 2 ++ app/upgrades/v14/upgrade.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index a69b841d5..572117ac4 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -9,6 +9,7 @@ import ( icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" allocmodulekeeper "github.com/public-awesome/stargaze/v14/x/alloc/keeper" + authoritykeeper "github.com/public-awesome/stargaze/v14/x/authority/keeper" cronmodulekeeper "github.com/public-awesome/stargaze/v14/x/cron/keeper" globalfeemodulekeeper "github.com/public-awesome/stargaze/v14/x/globalfee/keeper" mintkeeper "github.com/public-awesome/stargaze/v14/x/mint/keeper" @@ -75,4 +76,5 @@ type StargazeKeepers struct { GlobalFeeKeeper globalfeemodulekeeper.Keeper MintKeeper mintkeeper.Keeper TokenFactoryKeeper tokenfactorykeeper.Keeper + AuthorityKeeper authoritykeeper.Keeper } diff --git a/app/upgrades/v14/upgrade.go b/app/upgrades/v14/upgrade.go index fe6853ea7..c620ec223 100644 --- a/app/upgrades/v14/upgrade.go +++ b/app/upgrades/v14/upgrade.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" wasmlctypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" + authoritytypes "github.com/public-awesome/stargaze/v13/x/authority/types" "github.com/public-awesome/stargaze/v14/app/keepers" "github.com/public-awesome/stargaze/v14/app/upgrades" ) @@ -29,12 +30,15 @@ var Upgrade = upgrades.Upgrade{ params := keepers.IBCKeeper.ClientKeeper.GetParams(wctx) params.AllowedClients = append(params.AllowedClients, wasmlctypes.Wasm) keepers.IBCKeeper.ClientKeeper.SetParams(wctx, params) + + app.AuthorityKeeper.SetParams(sdk.UnwrapSDKContext(ctx), authoritytypes.DefaultParams()) return migrations, nil } }, StoreUpgrades: storetypes.StoreUpgrades{ Added: []string{ wasmlctypes.ModuleName, + authoritytypes.ModuleName, }, }, } From 6a59329feee70b3d97843594dd35f403f4f8fac5 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:19:28 +0530 Subject: [PATCH 18/20] moving the authority module to v14 --- app/app.go | 2 +- app/upgrades/v14/upgrade.go | 4 +- docs/proto/proto-docs.md | 237 +++++++++++++++++- .../stargaze/authority/v1/authority.proto | 2 +- .../stargaze/authority/v1/genesis.proto | 2 +- .../stargaze/authority/v1/query.proto | 2 +- .../stargaze/authority/v1/tx.proto | 2 +- x/authority/client/cli/query.go | 2 +- x/authority/client/cli/tx.go | 2 +- x/authority/genesis.go | 4 +- x/authority/keeper/grpc_query.go | 2 +- x/authority/keeper/keeper.go | 2 +- x/authority/keeper/msg_server.go | 2 +- x/authority/keeper/params.go | 2 +- x/authority/keeper/proposal.go | 2 +- x/authority/module.go | 6 +- x/authority/types/authority.pb.go | 4 +- x/authority/types/genesis.pb.go | 4 +- x/authority/types/params_test.go | 2 +- x/authority/types/query.pb.go | 4 +- x/authority/types/tx.pb.go | 48 ++-- 21 files changed, 281 insertions(+), 56 deletions(-) diff --git a/app/app.go b/app/app.go index ee1b2d57f..28c756cb6 100644 --- a/app/app.go +++ b/app/app.go @@ -644,7 +644,7 @@ func NewStargazeApp( bApp.MsgServiceRouter(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - authoritymodule := authoritymodule.NewAppModule(appCodec, app.AuthorityKeeper) + authoritymodule := authoritymodule.NewAppModule(appCodec, app.Keepers.AuthorityKeeper) // IBC Wasm Client wasmDir := filepath.Join(homePath, "wasm") diff --git a/app/upgrades/v14/upgrade.go b/app/upgrades/v14/upgrade.go index c620ec223..490145e86 100644 --- a/app/upgrades/v14/upgrade.go +++ b/app/upgrades/v14/upgrade.go @@ -8,9 +8,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" wasmlctypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" - authoritytypes "github.com/public-awesome/stargaze/v13/x/authority/types" "github.com/public-awesome/stargaze/v14/app/keepers" "github.com/public-awesome/stargaze/v14/app/upgrades" + authoritytypes "github.com/public-awesome/stargaze/v14/x/authority/types" ) // next upgrade name @@ -31,7 +31,7 @@ var Upgrade = upgrades.Upgrade{ params.AllowedClients = append(params.AllowedClients, wasmlctypes.Wasm) keepers.IBCKeeper.ClientKeeper.SetParams(wctx, params) - app.AuthorityKeeper.SetParams(sdk.UnwrapSDKContext(ctx), authoritytypes.DefaultParams()) + keepers.AuthorityKeeper.SetParams(sdk.UnwrapSDKContext(ctx), authoritytypes.DefaultParams()) return migrations, nil } }, diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 652fc2116..f80cfb312 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -60,6 +60,27 @@ - [Msg](#publicawesome.stargaze.alloc.v1beta1.Msg) +- [publicawesome/stargaze/authority/v1/authority.proto](#publicawesome/stargaze/authority/v1/authority.proto) + - [Authorization](#publicawesome.stargaze.authority.v1.Authorization) + - [Params](#publicawesome.stargaze.authority.v1.Params) + +- [publicawesome/stargaze/authority/v1/genesis.proto](#publicawesome/stargaze/authority/v1/genesis.proto) + - [GenesisState](#publicawesome.stargaze.authority.v1.GenesisState) + +- [publicawesome/stargaze/authority/v1/query.proto](#publicawesome/stargaze/authority/v1/query.proto) + - [QueryParamsRequest](#publicawesome.stargaze.authority.v1.QueryParamsRequest) + - [QueryParamsResponse](#publicawesome.stargaze.authority.v1.QueryParamsResponse) + + - [Query](#publicawesome.stargaze.authority.v1.Query) + +- [publicawesome/stargaze/authority/v1/tx.proto](#publicawesome/stargaze/authority/v1/tx.proto) + - [MsgExecuteProposal](#publicawesome.stargaze.authority.v1.MsgExecuteProposal) + - [MsgExecuteProposalResponse](#publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse) + - [MsgUpdateParams](#publicawesome.stargaze.authority.v1.MsgUpdateParams) + - [MsgUpdateParamsResponse](#publicawesome.stargaze.authority.v1.MsgUpdateParamsResponse) + + - [Msg](#publicawesome.stargaze.authority.v1.Msg) + - [publicawesome/stargaze/cron/v1/cron.proto](#publicawesome/stargaze/cron/v1/cron.proto) - [Params](#publicawesome.stargaze.cron.v1.Params) @@ -820,6 +841,216 @@ Msg defines the alloc Msg service. + +

Top

+ +## publicawesome/stargaze/authority/v1/authority.proto + + + + + +### Authorization +Authorization is a struct that holds the addresses that are allowed to +execute a proposal + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `msg_type_url` | [string](#string) | | msgTypeUrl is the type url of a proposal sdk.Msg | +| `addresses` | [string](#string) | repeated | addresses is a list of addresses that are allowed to execute the proposal | + + + + + + + + +### Params +Params holds parameters for the authority module. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authorizations` | [Authorization](#publicawesome.stargaze.authority.v1.Authorization) | repeated | authorizations is a list of authorizations that are allowed to execute a proposal | + + + + + + + + + + + + + + + + +

Top

+ +## publicawesome/stargaze/authority/v1/genesis.proto + + + + + +### GenesisState +GenesisState defines the authority module's genesis state. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#publicawesome.stargaze.authority.v1.Params) | | params defines all the parameters of the module. | + + + + + + + + + + + + + + + + +

Top

+ +## publicawesome/stargaze/authority/v1/query.proto + + + + + +### QueryParamsRequest +QueryParamsRequest is the request type for the Query/Params RPC method. + + + + + + + + +### QueryParamsResponse +QueryParamsResponse is the response type for the Query/Params RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#publicawesome.stargaze.authority.v1.Params) | | | + + + + + + + + + + + + + + +### Query +Query defines the gRPC querier service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Params` | [QueryParamsRequest](#publicawesome.stargaze.authority.v1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.authority.v1.QueryParamsResponse) | Params queries the parameters of the authority module. | GET|/stargaze/authority/v1/params| + + + + + + +

Top

+ +## publicawesome/stargaze/authority/v1/tx.proto + + + + + +### MsgExecuteProposal +MsgExecuteProposal defines an sdk.Msg type that supports submitting arbitrary +proposal Content. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authority` | [string](#string) | | authority is the address of the account authorized to execute the proposal. | +| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | messages is the list of messages to execute. | + + + + + + + + +### MsgExecuteProposalResponse +MsgExecuteProposalResponse defines the Msg/ExecuteProposal response type. + + + + + + + + +### MsgUpdateParams +MsgUpdateParams defines an sdk.Msg type that supports updating the authority + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authority` | [string](#string) | | Authority is the address of the governance account. | +| `params` | [Params](#publicawesome.stargaze.authority.v1.Params) | | NOTE: All parameters must be supplied. | + + + + + + + + +### MsgUpdateParamsResponse +MsgUpdateParamsResponse defines the Msg/UpdateParams response type. + + + + + + + + + + + + + + +### Msg +Msg defines the authority Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `ExecuteProposal` | [MsgExecuteProposal](#publicawesome.stargaze.authority.v1.MsgExecuteProposal) | [MsgExecuteProposalResponse](#publicawesome.stargaze.authority.v1.MsgExecuteProposalResponse) | ExecuteProposal defines a method to execute a proposal. | | +| `UpdateParams` | [MsgUpdateParams](#publicawesome.stargaze.authority.v1.MsgUpdateParams) | [MsgUpdateParamsResponse](#publicawesome.stargaze.authority.v1.MsgUpdateParamsResponse) | UpdateParams defines a method to update the authority parameters. | | + + + + +

Top

@@ -1080,7 +1311,6 @@ MsgPromoteToPrivilegedContract defines the Msg/PromoteToPrivilegedContract ### MsgUpdateParams -MsgUpdateParams defines an sdk.Msg type that supports updating the authority @@ -1097,11 +1327,6 @@ MsgUpdateParams defines an sdk.Msg type that supports updating the authority ### MsgUpdateParamsResponse -MsgUpdateParamsResponse defines the Msg/UpdateParams response type. - - - - diff --git a/proto/publicawesome/stargaze/authority/v1/authority.proto b/proto/publicawesome/stargaze/authority/v1/authority.proto index 3b5c62917..aaf310aa7 100644 --- a/proto/publicawesome/stargaze/authority/v1/authority.proto +++ b/proto/publicawesome/stargaze/authority/v1/authority.proto @@ -3,7 +3,7 @@ package publicawesome.stargaze.authority.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/public-awesome/stargaze/v13/x/authority/types"; +option go_package = "github.com/public-awesome/stargaze/v14/x/authority/types"; // Params holds parameters for the authority module. message Params { diff --git a/proto/publicawesome/stargaze/authority/v1/genesis.proto b/proto/publicawesome/stargaze/authority/v1/genesis.proto index 186c1fbab..b13bba7fc 100644 --- a/proto/publicawesome/stargaze/authority/v1/genesis.proto +++ b/proto/publicawesome/stargaze/authority/v1/genesis.proto @@ -4,7 +4,7 @@ package publicawesome.stargaze.authority.v1; import "gogoproto/gogo.proto"; import "publicawesome/stargaze/authority/v1/authority.proto"; -option go_package = "github.com/public-awesome/stargaze/v13/x/authority/types"; +option go_package = "github.com/public-awesome/stargaze/v14/x/authority/types"; // GenesisState defines the authority module's genesis state. message GenesisState { diff --git a/proto/publicawesome/stargaze/authority/v1/query.proto b/proto/publicawesome/stargaze/authority/v1/query.proto index 708ced15d..5546c874d 100644 --- a/proto/publicawesome/stargaze/authority/v1/query.proto +++ b/proto/publicawesome/stargaze/authority/v1/query.proto @@ -4,7 +4,7 @@ package publicawesome.stargaze.authority.v1; import "google/api/annotations.proto"; import "publicawesome/stargaze/authority/v1/authority.proto"; -option go_package = "github.com/public-awesome/stargaze/v13/x/authority/types"; +option go_package = "github.com/public-awesome/stargaze/v14/x/authority/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/publicawesome/stargaze/authority/v1/tx.proto b/proto/publicawesome/stargaze/authority/v1/tx.proto index 64a507a33..4ffff769d 100644 --- a/proto/publicawesome/stargaze/authority/v1/tx.proto +++ b/proto/publicawesome/stargaze/authority/v1/tx.proto @@ -6,7 +6,7 @@ import "cosmos/msg/v1/msg.proto"; import "google/protobuf/any.proto"; import "publicawesome/stargaze/authority/v1/authority.proto"; -option go_package = "github.com/public-awesome/stargaze/v13/x/authority/types"; +option go_package = "github.com/public-awesome/stargaze/v14/x/authority/types"; // Msg defines the authority Msg service. service Msg { diff --git a/x/authority/client/cli/query.go b/x/authority/client/cli/query.go index e1e802ba4..3f3dec1cc 100644 --- a/x/authority/client/cli/query.go +++ b/x/authority/client/cli/query.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/public-awesome/stargaze/v13/x/authority/types" + "github.com/public-awesome/stargaze/v14/x/authority/types" ) // GetQueryCmd returns the cli query commands for this module diff --git a/x/authority/client/cli/tx.go b/x/authority/client/cli/tx.go index 8a6ce398f..a8c20a81f 100644 --- a/x/authority/client/cli/tx.go +++ b/x/authority/client/cli/tx.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/public-awesome/stargaze/v13/x/authority/types" + "github.com/public-awesome/stargaze/v14/x/authority/types" "github.com/spf13/cobra" ) diff --git a/x/authority/genesis.go b/x/authority/genesis.go index 50b5d9ce7..a14f68a7a 100644 --- a/x/authority/genesis.go +++ b/x/authority/genesis.go @@ -2,8 +2,8 @@ package authority import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/public-awesome/stargaze/v13/x/authority/keeper" - "github.com/public-awesome/stargaze/v13/x/authority/types" + "github.com/public-awesome/stargaze/v14/x/authority/keeper" + "github.com/public-awesome/stargaze/v14/x/authority/types" ) // InitGenesis initializes the authority module's state from a provided genesis diff --git a/x/authority/keeper/grpc_query.go b/x/authority/keeper/grpc_query.go index d0d54651d..6fafcc408 100644 --- a/x/authority/keeper/grpc_query.go +++ b/x/authority/keeper/grpc_query.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/public-awesome/stargaze/v13/x/authority/types" + "github.com/public-awesome/stargaze/v14/x/authority/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/authority/keeper/keeper.go b/x/authority/keeper/keeper.go index 5f7f645af..00569b0c5 100644 --- a/x/authority/keeper/keeper.go +++ b/x/authority/keeper/keeper.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/public-awesome/stargaze/v13/x/authority/types" + "github.com/public-awesome/stargaze/v14/x/authority/types" ) type ( diff --git a/x/authority/keeper/msg_server.go b/x/authority/keeper/msg_server.go index e70fae09f..0aeffb6c5 100644 --- a/x/authority/keeper/msg_server.go +++ b/x/authority/keeper/msg_server.go @@ -5,7 +5,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/public-awesome/stargaze/v13/x/authority/types" + "github.com/public-awesome/stargaze/v14/x/authority/types" ) type msgServer struct { diff --git a/x/authority/keeper/params.go b/x/authority/keeper/params.go index aa014b85f..96cd71ed5 100644 --- a/x/authority/keeper/params.go +++ b/x/authority/keeper/params.go @@ -2,7 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/public-awesome/stargaze/v13/x/authority/types" + "github.com/public-awesome/stargaze/v14/x/authority/types" ) // SetParams sets the total set of authority parameters. diff --git a/x/authority/keeper/proposal.go b/x/authority/keeper/proposal.go index a290a7bbc..b69b0492f 100644 --- a/x/authority/keeper/proposal.go +++ b/x/authority/keeper/proposal.go @@ -4,7 +4,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/public-awesome/stargaze/v13/x/authority/types" + "github.com/public-awesome/stargaze/v14/x/authority/types" ) // ExecuteProposalMessages executes the array of messages in the proposal if their authorization matches diff --git a/x/authority/module.go b/x/authority/module.go index 5c35b7635..5efdee473 100644 --- a/x/authority/module.go +++ b/x/authority/module.go @@ -15,9 +15,9 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/public-awesome/stargaze/v13/x/authority/client/cli" - "github.com/public-awesome/stargaze/v13/x/authority/keeper" - "github.com/public-awesome/stargaze/v13/x/authority/types" + "github.com/public-awesome/stargaze/v14/x/authority/client/cli" + "github.com/public-awesome/stargaze/v14/x/authority/keeper" + "github.com/public-awesome/stargaze/v14/x/authority/types" ) var ( diff --git a/x/authority/types/authority.pb.go b/x/authority/types/authority.pb.go index 3a2176737..46ff792c0 100644 --- a/x/authority/types/authority.pb.go +++ b/x/authority/types/authority.pb.go @@ -150,9 +150,9 @@ var fileDescriptor_6e13d9034052c38a = []byte{ 0xa5, 0x16, 0x17, 0xa7, 0x16, 0x4b, 0x30, 0x29, 0x30, 0x6b, 0x70, 0x06, 0x21, 0x04, 0x9c, 0x82, 0x4e, 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, 0x22, 0x3d, 0xb3, 0x24, 0xa3, - 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xe2, 0x7c, 0x5d, 0x8c, 0x20, 0x2d, 0x33, 0x34, 0xd6, + 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xe2, 0x7c, 0x5d, 0x8c, 0x20, 0x2d, 0x33, 0x34, 0xd1, 0xaf, 0x40, 0x0a, 0x58, 0x90, 0x33, 0x8a, 0x93, 0xd8, 0xc0, 0xe1, 0x62, 0x0c, 0x08, 0x00, 0x00, - 0xff, 0xff, 0x7e, 0x7b, 0x6f, 0x4d, 0x89, 0x01, 0x00, 0x00, + 0xff, 0xff, 0xf8, 0x3d, 0xba, 0x9f, 0x89, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/authority/types/genesis.pb.go b/x/authority/types/genesis.pb.go index 2d1c1f764..a61f092a9 100644 --- a/x/authority/types/genesis.pb.go +++ b/x/authority/types/genesis.pb.go @@ -92,8 +92,8 @@ var fileDescriptor_f6ae0642d48c5a1e = []byte{ 0x14, 0x74, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x16, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x10, 0x2b, 0x75, 0x31, 0x7c, 0x52, 0x66, 0x68, - 0xac, 0x5f, 0x81, 0xe4, 0x9f, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x4f, 0x8c, 0x01, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x0e, 0xa5, 0xee, 0xe8, 0x6e, 0x01, 0x00, 0x00, + 0xa2, 0x5f, 0x81, 0xe4, 0x9f, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x4f, 0x8c, 0x01, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x88, 0xe3, 0x3b, 0x3a, 0x6e, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/authority/types/params_test.go b/x/authority/types/params_test.go index 05b9f5397..9f0f8f050 100644 --- a/x/authority/types/params_test.go +++ b/x/authority/types/params_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/public-awesome/stargaze/v13/x/authority/types" + "github.com/public-awesome/stargaze/v14/x/authority/types" "github.com/stretchr/testify/require" ) diff --git a/x/authority/types/query.pb.go b/x/authority/types/query.pb.go index f5649ec88..b56afa810 100644 --- a/x/authority/types/query.pb.go +++ b/x/authority/types/query.pb.go @@ -136,9 +136,9 @@ var fileDescriptor_fabfb73dd8f1f863 = []byte{ 0xd5, 0xa6, 0xcb, 0x4f, 0x26, 0x33, 0xc9, 0x0b, 0xc9, 0xe2, 0x08, 0x29, 0x88, 0x73, 0x9d, 0x82, 0x4e, 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, 0x22, 0x3d, 0xb3, 0x24, 0xa3, - 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x17, 0x1a, 0xdd, 0xba, 0x18, 0x61, 0x5f, 0x66, 0x68, 0xac, 0x5f, + 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x17, 0x1a, 0xdd, 0xba, 0x18, 0x61, 0x5f, 0x66, 0x68, 0xa2, 0x5f, 0x81, 0x64, 0x6e, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0xec, 0x8d, 0x01, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x59, 0xf5, 0xcf, 0xa5, 0x26, 0x02, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xdf, 0xb3, 0x1a, 0x77, 0x26, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/authority/types/tx.pb.go b/x/authority/types/tx.pb.go index 299a7e9d6..93b972308 100644 --- a/x/authority/types/tx.pb.go +++ b/x/authority/types/tx.pb.go @@ -227,34 +227,34 @@ func init() { } var fileDescriptor_a59b6a5ac2f6d30b = []byte{ - // 422 bytes of a gzipped FileDescriptorProto + // 423 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x4f, 0x8b, 0xd3, 0x40, 0x18, 0xc6, 0x33, 0x5d, 0x58, 0xdc, 0x59, 0x71, 0x25, 0x2c, 0x6c, 0x36, 0x2c, 0xd9, 0x52, 0x2f, - 0x45, 0xd7, 0x19, 0xdb, 0x0a, 0x8a, 0x08, 0xe2, 0x82, 0xc7, 0xc2, 0x12, 0xf0, 0x22, 0x78, 0x98, - 0xc4, 0x71, 0x36, 0xd0, 0xe9, 0x0c, 0x79, 0x27, 0xb5, 0xf1, 0xd8, 0xab, 0x17, 0x8f, 0x9e, 0xfc, - 0x0c, 0x7e, 0x8c, 0x1e, 0x7b, 0xf4, 0x54, 0xa4, 0x3d, 0x08, 0x7e, 0x0a, 0x69, 0xd2, 0xf4, 0x5f, - 0x0e, 0x1b, 0x7a, 0x4b, 0xe6, 0x7d, 0x9e, 0xe7, 0xfd, 0xf1, 0xf0, 0xe2, 0x2b, 0x9d, 0x04, 0xbd, - 0x28, 0x64, 0x5f, 0x38, 0x28, 0xc9, 0x29, 0x18, 0x16, 0x0b, 0xf6, 0x95, 0x53, 0x96, 0x98, 0x5b, - 0x15, 0x47, 0x26, 0xa5, 0x83, 0x16, 0x35, 0x43, 0xa2, 0x63, 0x65, 0x94, 0xfd, 0x68, 0x4b, 0x4d, - 0x0a, 0x35, 0x59, 0xa9, 0xc9, 0xa0, 0xe5, 0x9e, 0x0a, 0x25, 0x54, 0xa6, 0xa7, 0x8b, 0xaf, 0xdc, - 0xea, 0x9e, 0x85, 0x0a, 0xa4, 0x02, 0x2a, 0x41, 0x2c, 0x22, 0x25, 0x88, 0xe5, 0xe0, 0x5c, 0x28, - 0x25, 0x7a, 0x9c, 0x66, 0x7f, 0x41, 0xf2, 0x99, 0xb2, 0x7e, 0xba, 0x1c, 0x75, 0xaa, 0xc0, 0xad, - 0x77, 0x67, 0xa6, 0x86, 0xc1, 0x76, 0x17, 0xc4, 0xbb, 0x21, 0x0f, 0x13, 0xc3, 0x6f, 0x62, 0xa5, + 0x45, 0xd7, 0x19, 0xdb, 0x5d, 0x50, 0x44, 0x10, 0x17, 0x3c, 0x16, 0x96, 0x80, 0x17, 0xc1, 0xc3, + 0x24, 0x8e, 0xd3, 0x40, 0xa7, 0x33, 0xe4, 0x9d, 0xd4, 0xc6, 0x63, 0xaf, 0x5e, 0x3c, 0x7a, 0xf2, + 0x33, 0xf8, 0x31, 0x7a, 0xec, 0xd1, 0x53, 0x91, 0xf6, 0x20, 0xf8, 0x29, 0xa4, 0x49, 0xd3, 0x7f, + 0x39, 0x18, 0x7a, 0x4b, 0xe6, 0x7d, 0x9e, 0xe7, 0xfd, 0xf1, 0xf0, 0xe2, 0x2b, 0x9d, 0x04, 0xbd, + 0x28, 0x64, 0x9f, 0x39, 0x28, 0xc9, 0x29, 0x18, 0x16, 0x0b, 0xf6, 0x85, 0x53, 0x96, 0x98, 0xae, + 0x8a, 0x23, 0x93, 0xd2, 0x41, 0x8b, 0x9a, 0x21, 0xd1, 0xb1, 0x32, 0xca, 0x7e, 0xb4, 0xa5, 0x26, + 0x85, 0x9a, 0xac, 0xd4, 0x64, 0xd0, 0x72, 0x4f, 0x85, 0x12, 0x2a, 0xd3, 0xd3, 0xc5, 0x57, 0x6e, + 0x75, 0xcf, 0x42, 0x05, 0x52, 0x01, 0x95, 0x20, 0x16, 0x91, 0x12, 0xc4, 0x72, 0x70, 0x2e, 0x94, + 0x12, 0x3d, 0x4e, 0xb3, 0xbf, 0x20, 0xf9, 0x44, 0x59, 0x3f, 0x5d, 0x8e, 0xae, 0xab, 0xc0, 0xad, + 0x77, 0x67, 0xa6, 0x86, 0xc1, 0x76, 0x07, 0xc4, 0xdb, 0x21, 0x0f, 0x13, 0xc3, 0xef, 0x62, 0xa5, 0x15, 0xb0, 0x9e, 0x7d, 0x81, 0x8f, 0x56, 0x42, 0x07, 0xd5, 0x51, 0xf3, 0xc8, 0x5f, 0x3f, 0xd8, 0xcf, 0xf0, 0x3d, 0xc9, 0x01, 0x98, 0xe0, 0xe0, 0xd4, 0xea, 0x07, 0xcd, 0xe3, 0xf6, 0x29, 0xc9, - 0xb1, 0x48, 0x81, 0x45, 0xde, 0xf6, 0x53, 0x7f, 0xa5, 0x7a, 0xf5, 0x60, 0xf4, 0xf7, 0xd7, 0xe3, - 0x75, 0x42, 0xe3, 0x02, 0xbb, 0xe5, 0xad, 0x3e, 0x07, 0xad, 0xfa, 0xc0, 0x1b, 0x3f, 0x11, 0x3e, - 0xe9, 0x82, 0x78, 0xaf, 0x3f, 0x31, 0xc3, 0x6f, 0x58, 0xcc, 0x24, 0xdc, 0x41, 0xf4, 0x11, 0x1f, - 0xea, 0x4c, 0xe7, 0xd4, 0xea, 0xa8, 0x79, 0xdc, 0x7e, 0x42, 0x2a, 0x54, 0x4f, 0xf2, 0xe8, 0x6b, - 0x67, 0x3c, 0xbd, 0xb4, 0xfe, 0x4d, 0x2f, 0x1f, 0xe6, 0x11, 0x57, 0x4a, 0x46, 0x86, 0x4b, 0x6d, - 0x52, 0x7f, 0x19, 0x5a, 0xc2, 0x3f, 0xc7, 0x67, 0x3b, 0x7c, 0x05, 0x7b, 0xfb, 0x47, 0x0d, 0x1f, - 0x74, 0x41, 0xd8, 0xdf, 0x10, 0x3e, 0xd9, 0x6d, 0xf5, 0x45, 0x25, 0xaa, 0x72, 0x31, 0xee, 0x9b, - 0x3d, 0x8d, 0x05, 0x95, 0x3d, 0x42, 0xf8, 0xfe, 0x56, 0x9d, 0xcf, 0xab, 0x26, 0x6e, 0xba, 0xdc, - 0xd7, 0xfb, 0xb8, 0x0a, 0x88, 0x6b, 0x7f, 0x3c, 0xf3, 0xd0, 0x64, 0xe6, 0xa1, 0x3f, 0x33, 0x0f, - 0x7d, 0x9f, 0x7b, 0xd6, 0x64, 0xee, 0x59, 0xbf, 0xe7, 0x9e, 0xf5, 0xe1, 0xa5, 0x88, 0xcc, 0x6d, - 0x12, 0x90, 0x50, 0x49, 0x9a, 0x6f, 0x78, 0x5a, 0xba, 0xe2, 0x41, 0xab, 0x43, 0x87, 0x1b, 0xb7, - 0x6c, 0x52, 0xcd, 0x21, 0x38, 0xcc, 0x0e, 0xae, 0xf3, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x5f, 0xdb, - 0x02, 0xfe, 0x99, 0x03, 0x00, 0x00, + 0xb1, 0x48, 0x81, 0x45, 0xde, 0xf4, 0x53, 0x7f, 0xa5, 0x7a, 0xf9, 0x60, 0xf4, 0xe7, 0xe7, 0xe3, + 0x75, 0x42, 0xe3, 0x02, 0xbb, 0xe5, 0xad, 0x3e, 0x07, 0xad, 0xfa, 0xc0, 0x1b, 0x3f, 0x10, 0x3e, + 0xe9, 0x80, 0x78, 0xa7, 0x3f, 0x32, 0xc3, 0xef, 0x58, 0xcc, 0x24, 0xfc, 0x87, 0xe8, 0x03, 0x3e, + 0xd4, 0x99, 0xce, 0xa9, 0xd5, 0x51, 0xf3, 0xb8, 0xfd, 0x84, 0x54, 0xa8, 0x9e, 0xe4, 0xd1, 0xb7, + 0xce, 0x78, 0x7a, 0x69, 0xfd, 0x9d, 0x5e, 0x3e, 0xcc, 0x23, 0xae, 0x94, 0x8c, 0x0c, 0x97, 0xda, + 0xa4, 0xfe, 0x32, 0xb4, 0x84, 0x7f, 0x8e, 0xcf, 0x76, 0xf8, 0x0a, 0xf6, 0xf6, 0xf7, 0x1a, 0x3e, + 0xe8, 0x80, 0xb0, 0xbf, 0x22, 0x7c, 0xb2, 0xdb, 0xea, 0xf3, 0x4a, 0x54, 0xe5, 0x62, 0xdc, 0xd7, + 0x7b, 0x1a, 0x0b, 0x2a, 0x7b, 0x84, 0xf0, 0xfd, 0xad, 0x3a, 0x6f, 0xaa, 0x26, 0x6e, 0xba, 0xdc, + 0x57, 0xfb, 0xb8, 0x0a, 0x88, 0x5b, 0x7f, 0x3c, 0xf3, 0xd0, 0x64, 0xe6, 0xa1, 0xdf, 0x33, 0x0f, + 0x7d, 0x9b, 0x7b, 0xd6, 0x64, 0xee, 0x59, 0xbf, 0xe6, 0x9e, 0xf5, 0xfe, 0x85, 0x88, 0x4c, 0x37, + 0x09, 0x48, 0xa8, 0x24, 0xcd, 0x37, 0x3c, 0x2d, 0x5d, 0xf1, 0xa0, 0x75, 0x43, 0x87, 0x1b, 0xb7, + 0x6c, 0x52, 0xcd, 0x21, 0x38, 0xcc, 0x0e, 0xee, 0xfa, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd9, + 0x9d, 0xd7, 0x2c, 0x99, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. From be02e0841f01b88b16097267f101d6989a451fcf Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:33:27 +0530 Subject: [PATCH 19/20] =?UTF-8?q?linting=20=F0=9F=A7=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/upgrades/v14/upgrade.go | 5 ++++- x/authority/module.go | 4 ++-- x/authority/types/codec.go | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/upgrades/v14/upgrade.go b/app/upgrades/v14/upgrade.go index 490145e86..5847e190a 100644 --- a/app/upgrades/v14/upgrade.go +++ b/app/upgrades/v14/upgrade.go @@ -31,7 +31,10 @@ var Upgrade = upgrades.Upgrade{ params.AllowedClients = append(params.AllowedClients, wasmlctypes.Wasm) keepers.IBCKeeper.ClientKeeper.SetParams(wctx, params) - keepers.AuthorityKeeper.SetParams(sdk.UnwrapSDKContext(ctx), authoritytypes.DefaultParams()) + err = keepers.AuthorityKeeper.SetParams(sdk.UnwrapSDKContext(ctx), authoritytypes.DefaultParams()) + if err != nil { + return nil, err + } return migrations, nil } }, diff --git a/x/authority/module.go b/x/authority/module.go index 5efdee473..d288d9de4 100644 --- a/x/authority/module.go +++ b/x/authority/module.go @@ -146,7 +146,7 @@ func (am AppModule) EndBlock(_ sdk.Context) []abci.ValidatorUpdate { } // IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (a AppModule) IsOnePerModuleType() {} +func (am AppModule) IsOnePerModuleType() {} // IsAppModule implements the appmodule.AppModule interface. -func (a AppModule) IsAppModule() {} +func (am AppModule) IsAppModule() {} diff --git a/x/authority/types/codec.go b/x/authority/types/codec.go index 9665063b0..3ff335d6f 100644 --- a/x/authority/types/codec.go +++ b/x/authority/types/codec.go @@ -25,8 +25,8 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { } var ( - ModuleCdc = codec.NewAminoCodec(Amino) Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(types.NewInterfaceRegistry()) ) func init() { From de9bfc0800bbf05a8b6f8aec969e118f60111687 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:16:46 +0530 Subject: [PATCH 20/20] =?UTF-8?q?linting=20=F0=9F=A7=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- x/authority/client/cli/query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/authority/client/cli/query.go b/x/authority/client/cli/query.go index 3f3dec1cc..67cb3fd76 100644 --- a/x/authority/client/cli/query.go +++ b/x/authority/client/cli/query.go @@ -33,7 +33,7 @@ func GetCmdParams() *cobra.Command { Use: "params", Short: "Query the module params", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err