fix: Correctly populate legacy Vote.Option field (#9583)
This commit is contained in:
parent
7679820276
commit
7c0e6939c1
|
@ -162,6 +162,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||||
* (x/bank) [\#9229](https://github.com/cosmos/cosmos-sdk/pull/9229) Now zero coin balances cannot be added to balances & supply stores. If any denom becomes zero corresponding key gets deleted from store.
|
* (x/bank) [\#9229](https://github.com/cosmos/cosmos-sdk/pull/9229) Now zero coin balances cannot be added to balances & supply stores. If any denom becomes zero corresponding key gets deleted from store.
|
||||||
* (types) [\#9511](https://github.com/cosmos/cosmos-sdk/pull/9511) Change `maxBitLen` of `sdk.Int` and `sdk.Dec` to handle max ERC20 value.
|
* (types) [\#9511](https://github.com/cosmos/cosmos-sdk/pull/9511) Change `maxBitLen` of `sdk.Int` and `sdk.Dec` to handle max ERC20 value.
|
||||||
* (keyring) [\#9562](https://github.com/cosmos/cosmos-sdk/pull/9563) fix keyring kwallet backend when using with empty wallet.
|
* (keyring) [\#9562](https://github.com/cosmos/cosmos-sdk/pull/9563) fix keyring kwallet backend when using with empty wallet.
|
||||||
|
* (keyring) [\#9583](https://github.com/cosmos/cosmos-sdk/pull/9583) Fix correct population of legacy `Vote.Option` field for votes with 1 VoteOption of weight 1.
|
||||||
|
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
|
@ -4987,7 +4987,7 @@ A Vote consists of a proposal ID, the voter, and the vote option.
|
||||||
| ----- | ---- | ----- | ----------- |
|
| ----- | ---- | ----- | ----------- |
|
||||||
| `proposal_id` | [uint64](#uint64) | | |
|
| `proposal_id` | [uint64](#uint64) | | |
|
||||||
| `voter` | [string](#string) | | |
|
| `voter` | [string](#string) | | |
|
||||||
| `option` | [VoteOption](#cosmos.gov.v1beta1.VoteOption) | | **Deprecated.** Deprecated: Prefer to use `options` instead. This field is set in queries if an only if `len(options) == 1` and that option has weight 1. In all other cases, this field will default to OptionEmpty. |
|
| `option` | [VoteOption](#cosmos.gov.v1beta1.VoteOption) | | **Deprecated.** Deprecated: Prefer to use `options` instead. This field is set in queries if and only if `len(options) == 1` and that option has weight 1. In all other cases, this field will default to VOTE_OPTION_UNSPECIFIED. |
|
||||||
| `options` | [WeightedVoteOption](#cosmos.gov.v1beta1.WeightedVoteOption) | repeated | |
|
| `options` | [WeightedVoteOption](#cosmos.gov.v1beta1.WeightedVoteOption) | repeated | |
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ message Vote {
|
||||||
string voter = 2;
|
string voter = 2;
|
||||||
// Deprecated: Prefer to use `options` instead. This field is set in queries
|
// Deprecated: Prefer to use `options` instead. This field is set in queries
|
||||||
// if and only if `len(options) == 1` and that option has weight 1. In all
|
// if and only if `len(options) == 1` and that option has weight 1. In all
|
||||||
// other cases, this field will default to OptionEmpty.
|
// other cases, this field will default to VOTE_OPTION_UNSPECIFIED.
|
||||||
VoteOption option = 3 [deprecated = true];
|
VoteOption option = 3 [deprecated = true];
|
||||||
repeated WeightedVoteOption options = 4 [(gogoproto.nullable) = false];
|
repeated WeightedVoteOption options = 4 [(gogoproto.nullable) = false];
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,7 @@ func (q Keeper) Votes(c context.Context, req *types.QueryVotesRequest) (*types.Q
|
||||||
if err := q.cdc.Unmarshal(value, &vote); err != nil {
|
if err := q.cdc.Unmarshal(value, &vote); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
populateLegacyOption(&vote)
|
||||||
|
|
||||||
votes = append(votes, vote)
|
votes = append(votes, vote)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -395,8 +395,8 @@ func (suite *KeeperTestSuite) TestGRPCQueryVotes() {
|
||||||
app.GovKeeper.SetProposal(ctx, proposal)
|
app.GovKeeper.SetProposal(ctx, proposal)
|
||||||
|
|
||||||
votes = []types.Vote{
|
votes = []types.Vote{
|
||||||
{ProposalId: proposal.ProposalId, Voter: addrs[0].String(), Options: types.NewNonSplitVoteOption(types.OptionAbstain)},
|
{ProposalId: proposal.ProposalId, Voter: addrs[0].String(), Option: types.OptionAbstain, Options: types.NewNonSplitVoteOption(types.OptionAbstain)},
|
||||||
{ProposalId: proposal.ProposalId, Voter: addrs[1].String(), Options: types.NewNonSplitVoteOption(types.OptionYes)},
|
{ProposalId: proposal.ProposalId, Voter: addrs[1].String(), Option: types.OptionYes, Options: types.NewNonSplitVoteOption(types.OptionYes)},
|
||||||
}
|
}
|
||||||
accAddr1, err1 := sdk.AccAddressFromBech32(votes[0].Voter)
|
accAddr1, err1 := sdk.AccAddressFromBech32(votes[0].Voter)
|
||||||
accAddr2, err2 := sdk.AccAddressFromBech32(votes[1].Voter)
|
accAddr2, err2 := sdk.AccAddressFromBech32(votes[1].Voter)
|
||||||
|
|
|
@ -329,8 +329,8 @@ type Vote struct {
|
||||||
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty" yaml:"proposal_id"`
|
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty" yaml:"proposal_id"`
|
||||||
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
|
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
|
||||||
// Deprecated: Prefer to use `options` instead. This field is set in queries
|
// Deprecated: Prefer to use `options` instead. This field is set in queries
|
||||||
// if an only if `len(options) == 1` and that option has weight 1. In all
|
// if and only if `len(options) == 1` and that option has weight 1. In all
|
||||||
// other cases, this field will default to OptionEmpty.
|
// other cases, this field will default to VOTE_OPTION_UNSPECIFIED.
|
||||||
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,omitempty"` // Deprecated: Do not use.
|
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,omitempty"` // Deprecated: Do not use.
|
||||||
Options []WeightedVoteOption `protobuf:"bytes,4,rep,name=options,proto3" json:"options"`
|
Options []WeightedVoteOption `protobuf:"bytes,4,rep,name=options,proto3" json:"options"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue