Skip to content

Commit

Permalink
add metadata field to proposal proto
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Jan 20, 2022
1 parent 033e5f3 commit 7893de8
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 77 deletions.
3 changes: 3 additions & 0 deletions proto/cosmos/gov/v1beta2/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ message Proposal {
repeated cosmos.base.v1beta1.Coin total_deposit = 7 [(gogoproto.nullable) = false];
google.protobuf.Timestamp voting_start_time = 8 [(gogoproto.stdtime) = true];
google.protobuf.Timestamp voting_end_time = 9 [(gogoproto.stdtime) = true];

// metadata is any arbitrary metadata to attached to the proposal.
bytes metadata = 10;
}

// ProposalStatus enumerates the valid statuses of a proposal.
Expand Down
8 changes: 2 additions & 6 deletions proto/cosmos/gov/v1beta2/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ service Msg {
rpc Vote(MsgVote) returns (MsgVoteResponse);

// VoteWeighted defines a method to add a weighted vote on a specific proposal.
//
// Since: cosmos-sdk 0.43
rpc VoteWeighted(MsgVoteWeighted) returns (MsgVoteWeightedResponse);

// Deposit defines a method to add deposit on a specific proposal.
Expand All @@ -32,6 +30,8 @@ message MsgSubmitProposal {
repeated google.protobuf.Any messages = 1;
repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [(gogoproto.nullable) = false];
string proposer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// metadata is any arbitrary metadata to attached to the proposal.
bytes metadata = 4;
}

// MsgSubmitProposalResponse defines the Msg/SubmitProposal response type.
Expand All @@ -50,17 +50,13 @@ message MsgVote {
message MsgVoteResponse {}

// MsgVoteWeighted defines a message to cast a vote.
//
// Since: cosmos-sdk 0.43
message MsgVoteWeighted {
uint64 proposal_id = 1;
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated WeightedVoteOption options = 3;
}

// MsgVoteWeightedResponse defines the Msg/VoteWeighted response type.
//
// Since: cosmos-sdk 0.43
message MsgVoteWeightedResponse {}

// MsgDeposit defines a message to submit a deposit to an existing proposal.
Expand Down
19 changes: 12 additions & 7 deletions x/gov/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ type Keeper struct {

// Proposal router
router v1beta1.Router

// maxMetadataLen defines the maximum length of a proposal metadata.
maxMetadataLen uint64
}

// NewKeeper returns a governance keeper. It handles:
Expand All @@ -48,6 +51,7 @@ type Keeper struct {
func NewKeeper(
cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace types.ParamSubspace,
authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper, rtr v1beta1.Router,
maxMetadataLen uint64,
) Keeper {

// ensure governance module account is set
Expand All @@ -61,13 +65,14 @@ func NewKeeper(
rtr.Seal()

return Keeper{
storeKey: key,
paramSpace: paramSpace,
authKeeper: authKeeper,
bankKeeper: bankKeeper,
sk: sk,
cdc: cdc,
router: rtr,
storeKey: key,
paramSpace: paramSpace,
authKeeper: authKeeper,
bankKeeper: bankKeeper,
sk: sk,
cdc: cdc,
router: rtr,
maxMetadataLen: maxMetadataLen,
}
}

Expand Down
183 changes: 119 additions & 64 deletions x/gov/types/v1beta2/gov.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7893de8

Please sign in to comment.