From 0275b21173f159ab9485368827fb5c123704c4e2 Mon Sep 17 00:00:00 2001 From: rhuairahrighairigh Date: Sat, 21 Mar 2020 20:21:43 +0000 Subject: [PATCH] add struct tags everywhere --- x/committee/types/codec.go | 3 +++ x/committee/types/genesis.go | 8 ++++---- x/committee/types/gov_proposal.go | 12 ++++++------ x/committee/types/msg.go | 2 +- x/committee/types/permissions.go | 2 +- x/committee/types/querier.go | 8 ++++---- x/committee/types/types.go | 18 +++++++++--------- 7 files changed, 28 insertions(+), 25 deletions(-) diff --git a/x/committee/types/codec.go b/x/committee/types/codec.go index 57d700b0..294068df 100644 --- a/x/committee/types/codec.go +++ b/x/committee/types/codec.go @@ -37,4 +37,7 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*Permission)(nil), nil) cdc.RegisterConcrete(GodPermission{}, "kava/GodPermission", nil) + + cdc.RegisterConcrete(MsgSubmitProposal{}, "kava/MsgSubmitProposal", nil) + cdc.RegisterConcrete(MsgVote{}, "kava/MsgVote", nil) } diff --git a/x/committee/types/genesis.go b/x/committee/types/genesis.go index fe9a85c0..fda51064 100644 --- a/x/committee/types/genesis.go +++ b/x/committee/types/genesis.go @@ -10,10 +10,10 @@ const DefaultNextProposalID uint64 = 1 // GenesisState is state that must be provided at chain genesis. type GenesisState struct { - NextProposalID uint64 - Committees []Committee - Proposals []Proposal - Votes []Vote + NextProposalID uint64 `json:"next_proposal_id" yaml:"next_proposal_id"` + Committees []Committee `json:"committees" yaml:"committees"` + Proposals []Proposal `json:"proposals" yaml:"proposals"` + Votes []Vote `json:"votes" yaml:"votes"` } // NewGenesisState returns a new genesis state object for the module. diff --git a/x/committee/types/gov_proposal.go b/x/committee/types/gov_proposal.go index c444d16a..ed7dfe86 100644 --- a/x/committee/types/gov_proposal.go +++ b/x/committee/types/gov_proposal.go @@ -14,9 +14,9 @@ const ( // CommitteeChangeProposal is a gov proposal for creating a new committee or modifying an existing one. type CommitteeChangeProposal struct { - Title string - Description string - NewCommittee Committee + Title string `json:"title" yaml:"title"` + Description string `json:"description" yaml:"description"` + NewCommittee Committee `json:"new_committee" yaml:"new_committee"` } var _ govtypes.Content = CommitteeChangeProposal{} @@ -69,9 +69,9 @@ func (ccp CommitteeChangeProposal) String() string { // CommitteeDeleteProposal is a gov proposal for removing a committee. type CommitteeDeleteProposal struct { - Title string - Description string - CommitteeID uint64 + Title string `json:"title" yaml:"title"` + Description string `json:"description" yaml:"description"` + CommitteeID uint64 `json:"committee_id" yaml:"committee_id"` } var _ govtypes.Content = CommitteeDeleteProposal{} diff --git a/x/committee/types/msg.go b/x/committee/types/msg.go index dd34e727..273a4654 100644 --- a/x/committee/types/msg.go +++ b/x/committee/types/msg.go @@ -15,7 +15,7 @@ var _, _ sdk.Msg = MsgSubmitProposal{}, MsgVote{} type MsgSubmitProposal struct { PubProposal PubProposal `json:"pub_proposal" yaml:"pub_proposal"` Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` - CommitteeID uint64 + CommitteeID uint64 `json:"committee_id" yaml:"committee_id"` } // NewMsgSubmitProposal creates a new MsgSubmitProposal instance diff --git a/x/committee/types/permissions.go b/x/committee/types/permissions.go index 068fadc3..807fc1f4 100644 --- a/x/committee/types/permissions.go +++ b/x/committee/types/permissions.go @@ -50,7 +50,7 @@ func (ShutdownCDPDepsitPermission) Allows(p gov.Content) bool { // Same as above but the route isn't static type GeneralShutdownPermission struct { - MsgRoute sdtypes.MsgRoute + MsgRoute sdtypes.MsgRoute `json:"msg_route" yaml:"msg_route"` } var _ Permission = GeneralShutdownPermission{} diff --git a/x/committee/types/querier.go b/x/committee/types/querier.go index 5f8a4988..f58ed338 100644 --- a/x/committee/types/querier.go +++ b/x/committee/types/querier.go @@ -17,7 +17,7 @@ const ( ) type QueryCommitteeParams struct { - CommitteeID uint64 + CommitteeID uint64 `json:"committee_id" yaml:"committee_id"` } func NewQueryCommitteeParams(committeeID uint64) QueryCommitteeParams { @@ -27,7 +27,7 @@ func NewQueryCommitteeParams(committeeID uint64) QueryCommitteeParams { } type QueryProposalParams struct { - ProposalID uint64 + ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` } func NewQueryProposalParams(proposalID uint64) QueryProposalParams { @@ -37,8 +37,8 @@ func NewQueryProposalParams(proposalID uint64) QueryProposalParams { } type QueryVoteParams struct { - ProposalID uint64 - Voter sdk.AccAddress + ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` + Voter sdk.AccAddress `json:"voter" yaml:"voter"` } func NewQueryVoteParams(proposalID uint64, voter sdk.AccAddress) QueryVoteParams { diff --git a/x/committee/types/types.go b/x/committee/types/types.go index 0d91d979..391d3b69 100644 --- a/x/committee/types/types.go +++ b/x/committee/types/types.go @@ -19,9 +19,9 @@ var ( // A Committee is a collection of addresses that are allowed to vote and enact any governance proposal that passes their permissions. type Committee struct { - ID uint64 // TODO or a name? - Members []sdk.AccAddress - Permissions []Permission + ID uint64 `json:"id" yaml:"id"` // TODO or a name? + Members []sdk.AccAddress `json:"members" yaml:"members"` + Permissions []Permission `json:"permissions" yaml:"permissions"` } func (c Committee) HasMember(addr sdk.AccAddress) bool { @@ -77,10 +77,10 @@ type Permission interface { type PubProposal = gov.Content // TODO find a better name type Proposal struct { - PubProposal - ID uint64 - CommitteeID uint64 - Deadline time.Time + PubProposal `json:"pub_proposal" yaml:"pub_proposal"` + ID uint64 `json:"id" yaml:"id"` + CommitteeID uint64 `json:"committee_id" yaml:"committee_id"` + Deadline time.Time `json:"deadline" yaml:"deadline"` } // HasExpiredBy calculates if the proposal will have expired by a certain time. @@ -105,7 +105,7 @@ func (p Proposal) String() string { } type Vote struct { - ProposalID uint64 - Voter sdk.AccAddress + ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` + Voter sdk.AccAddress `json:"voter" yaml:"voter"` // Option byte // TODO for now don't need more than just a yes as options }