refactor!: move v1beta2 gov types into types dir (#10763)

closes #9865 

To be merged after #10748

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
This commit is contained in:
Callum Waters 2021-12-16 19:23:47 +01:00 committed by GitHub
parent a3371e3597
commit 350f9169fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 1257 additions and 11269 deletions

2
.gitignore vendored
View File

@ -33,6 +33,8 @@ client/lcd/keys/*
coverage.txt
profile.out
sim_log_file
x/genutil/config
x/genutil/data
# Vagrant
.vagrant/

View File

@ -191,6 +191,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/upgrade) [\#10189](https://github.com/cosmos/cosmos-sdk/issues/10189) Removed potential sources of non-determinism in upgrades
* [\#10393](https://github.com/cosmos/cosmos-sdk/pull/10422) Add `MinCommissionRate` param to `x/staking` module.
* [#10725](https://github.com/cosmos/cosmos-sdk/pull/10725) populate `ctx.ConsensusParams` for begin/end blockers.
* [#10763](https://github.com/cosmos/cosmos-sdk/pull/10763) modify the fields in `TallyParams` to use `string` instead of `bytes`
### Deprecated

View File

@ -6165,9 +6165,9 @@ TallyParams defines the params for tallying votes on governance proposals.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `quorum` | [bytes](#bytes) | | Minimum percentage of total stake needed to vote for a result to be considered valid. |
| `threshold` | [bytes](#bytes) | | Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. |
| `veto_threshold` | [bytes](#bytes) | | Minimum value of Veto votes to Total votes ratio for proposal to be vetoed. Default value: 1/3. |
| `quorum` | [string](#string) | | Minimum percentage of total stake needed to vote for a result to be considered valid. |
| `threshold` | [string](#string) | | Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. |
| `veto_threshold` | [string](#string) | | Minimum value of Veto votes to Total votes ratio for proposal to be vetoed. Default value: 1/3. |

View File

@ -4,7 +4,7 @@ package cosmos.gov.v1beta2;
import "cosmos/gov/v1beta2/gov.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta2";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
// GenesisState defines the gov module's genesis state.
message GenesisState {

View File

@ -8,7 +8,7 @@ import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
import "cosmos_proto/cosmos.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta2";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
// VoteOption enumerates the valid vote options for a given governance proposal.
enum VoteOption {
@ -35,7 +35,7 @@ message WeightedVoteOption {
message Deposit {
uint64 proposal_id = 1;
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated cosmos.base.v1beta1.Coin amount = 3;
repeated cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
// Proposal defines the core field members of a governance proposal.
@ -46,7 +46,7 @@ message Proposal {
TallyResult final_tally_result = 4;
google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true];
google.protobuf.Timestamp deposit_end_time = 6 [(gogoproto.stdtime) = true];
repeated cosmos.base.v1beta1.Coin total_deposit = 7;
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];
}
@ -95,7 +95,7 @@ message Vote {
// DepositParams defines the params for deposits on governance proposals.
message DepositParams {
// Minimum deposit for a proposal to enter voting period.
repeated cosmos.base.v1beta1.Coin min_deposit = 1;
repeated cosmos.base.v1beta1.Coin min_deposit = 1 [(gogoproto.nullable) = false];
// Maximum period for Atom holders to deposit on a proposal. Initial value: 2
// months.
@ -112,12 +112,12 @@ message VotingParams {
message TallyParams {
// Minimum percentage of total stake needed to vote for a result to be
// considered valid.
bytes quorum = 1;
string quorum = 1 [(cosmos_proto.scalar) = "cosmos.Dec"];
// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
bytes threshold = 2;
string threshold = 2 [(cosmos_proto.scalar) = "cosmos.Dec"];
// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
bytes veto_threshold = 3;
string veto_threshold = 3 [(cosmos_proto.scalar) = "cosmos.Dec"];
}

View File

@ -6,7 +6,7 @@ import "google/api/annotations.proto";
import "cosmos/gov/v1beta2/gov.proto";
import "cosmos_proto/cosmos.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta2";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
// Query defines the gRPC querier service for gov module
service Query {

View File

@ -3,10 +3,11 @@ package cosmos.gov.v1beta2;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/gov/v1beta2/gov.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "google/protobuf/any.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta2";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
// Msg defines the gov Msg service.
service Msg {
@ -29,7 +30,7 @@ service Msg {
// proposal Content.
message MsgSubmitProposal {
repeated google.protobuf.Any messages = 1;
repeated cosmos.base.v1beta1.Coin initial_deposit = 2;
repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [(gogoproto.nullable) = false];
string proposer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
@ -66,7 +67,7 @@ message MsgVoteWeightedResponse {}
message MsgDeposit {
uint64 proposal_id = 1;
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated cosmos.base.v1beta1.Coin amount = 3;
repeated cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
// MsgDepositResponse defines the Msg/Deposit response type.

View File

@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil/types"
v040gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v040"
v043gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v043"
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// Migrate migrates exported state from v0.40 to a v0.43 genesis state.

View File

@ -12,8 +12,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
gcutils "github.com/cosmos/cosmos-sdk/x/gov/client/utils"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// GetQueryCmd returns the cli query commands for this module

View File

@ -17,9 +17,11 @@ func TestIntegrationTestSuite(t *testing.T) {
cfg.NumValidators = 1
suite.Run(t, NewIntegrationTestSuite(cfg))
dp := types.NewDepositParams(sdk.NewCoins(sdk.NewCoin(cfg.BondDenom, types.DefaultMinDepositTokens)), time.Duration(15)*time.Second)
vp := types.NewVotingParams(time.Duration(5) * time.Second)
genesisState := types.DefaultGenesisState()
genesisState.DepositParams = types.NewDepositParams(sdk.NewCoins(sdk.NewCoin(cfg.BondDenom, types.DefaultMinDepositTokens)), time.Duration(15)*time.Second)
genesisState.VotingParams = types.NewVotingParams(time.Duration(5) * time.Second)
genesisState.DepositParams = &dp
genesisState.VotingParams = &vp
bz, err := cfg.Codec.MarshalJSON(genesisState)
require.NoError(t, err)
cfg.GenesisState["gov"] = bz

View File

@ -1,12 +1,12 @@
package v043
import (
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// migrateWeightedVotes migrates the ADR-037 weighted votes.
func migrateJSONWeightedVotes(oldVotes types.Votes) types.Votes {
newVotes := make(types.Votes, len(oldVotes))
func migrateJSONWeightedVotes(oldVotes v1beta1.Votes) v1beta1.Votes {
newVotes := make(v1beta1.Votes, len(oldVotes))
for i, oldVote := range oldVotes {
newVotes[i] = migrateVote(oldVote)
}
@ -18,8 +18,8 @@ func migrateJSONWeightedVotes(oldVotes types.Votes) types.Votes {
// v0.43 x/gov genesis state. The migration includes:
//
// - Gov weighted votes.
func MigrateJSON(oldState *types.GenesisState) *types.GenesisState {
return &types.GenesisState{
func MigrateJSON(oldState *v1beta1.GenesisState) *v1beta1.GenesisState {
return &v1beta1.GenesisState{
StartingProposalId: oldState.StartingProposalId,
Deposits: oldState.Deposits,
Votes: migrateJSONWeightedVotes(oldState.Votes),

View File

@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
v043gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v043"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
func TestMigrateJSON(t *testing.T) {
@ -23,13 +23,13 @@ func TestMigrateJSON(t *testing.T) {
voter, err := sdk.AccAddressFromBech32("cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh")
require.NoError(t, err)
govGenState := &types.GenesisState{
Votes: types.Votes{
types.Vote{ProposalId: 1, Voter: voter.String(), Option: types.OptionAbstain},
types.Vote{ProposalId: 2, Voter: voter.String(), Option: types.OptionEmpty},
types.Vote{ProposalId: 3, Voter: voter.String(), Option: types.OptionNo},
types.Vote{ProposalId: 4, Voter: voter.String(), Option: types.OptionNoWithVeto},
types.Vote{ProposalId: 5, Voter: voter.String(), Option: types.OptionYes},
govGenState := &v1beta1.GenesisState{
Votes: v1beta1.Votes{
v1beta1.Vote{ProposalId: 1, Voter: voter.String(), Option: v1beta1.OptionAbstain},
v1beta1.Vote{ProposalId: 2, Voter: voter.String(), Option: v1beta1.OptionEmpty},
v1beta1.Vote{ProposalId: 3, Voter: voter.String(), Option: v1beta1.OptionNo},
v1beta1.Vote{ProposalId: 4, Voter: voter.String(), Option: v1beta1.OptionNoWithVeto},
v1beta1.Vote{ProposalId: 5, Voter: voter.String(), Option: v1beta1.OptionYes},
},
}

View File

@ -9,6 +9,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
const proposalIDLen = 8
@ -37,11 +38,11 @@ func migratePrefixProposalAddress(store sdk.KVStore, prefixBz []byte) {
// migrateStoreWeightedVotes migrates a legacy vote to an ADR-037 weighted vote.
// Important: the `oldVote` has its `Option` field set, whereas the new weighted
// vote has its `Options` field set.
func migrateVote(oldVote types.Vote) types.Vote {
return types.Vote{
func migrateVote(oldVote v1beta1.Vote) v1beta1.Vote {
return v1beta1.Vote{
ProposalId: oldVote.ProposalId,
Voter: oldVote.Voter,
Options: types.NewNonSplitVoteOption(oldVote.Option),
Options: v1beta1.NewNonSplitVoteOption(oldVote.Option),
}
}
@ -51,7 +52,7 @@ func migrateStoreWeightedVotes(store sdk.KVStore, cdc codec.BinaryCodec) error {
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
var oldVote types.Vote
var oldVote v1beta1.Vote
err := cdc.Unmarshal(iterator.Value(), &oldVote)
if err != nil {
return err

View File

@ -14,6 +14,7 @@ import (
v040gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v040"
v043gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v043"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
func TestMigrateStore(t *testing.T) {
@ -28,9 +29,9 @@ func TestMigrateStore(t *testing.T) {
// Use dummy value for keys where we don't test values.
dummyValue := []byte("foo")
// Use real values for votes, as we're testing weighted votes.
oldVote := types.Vote{ProposalId: 1, Voter: "foobar", Option: types.OptionNoWithVeto}
oldVote := v1beta1.Vote{ProposalId: 1, Voter: "foobar", Option: v1beta1.OptionNoWithVeto}
oldVoteValue := cdc.MustMarshal(&oldVote)
newVote := types.Vote{ProposalId: 1, Voter: "foobar", Options: types.WeightedVoteOptions{{Option: types.OptionNoWithVeto, Weight: sdk.NewDec(1)}}}
newVote := v1beta1.Vote{ProposalId: 1, Voter: "foobar", Options: v1beta1.WeightedVoteOptions{{Option: v1beta1.OptionNoWithVeto, Weight: sdk.NewDec(1)}}}
newVoteValue := cdc.MustMarshal(&newVote)
testCases := []struct {

View File

@ -44,16 +44,16 @@ func TestRandomizedGenState(t *testing.T) {
dec2, _ := sdk.NewDecFromStr("0.512000000000000000")
dec3, _ := sdk.NewDecFromStr("0.267000000000000000")
require.Equal(t, "905stake", govGenesis.DepositParams.MinDeposit.String())
require.Equal(t, "905stake", govGenesis.DepositParams.MinDeposit[0].String())
require.Equal(t, "77h26m10s", govGenesis.DepositParams.MaxDepositPeriod.String())
require.Equal(t, float64(148296), govGenesis.VotingParams.VotingPeriod.Seconds())
require.Equal(t, dec1, govGenesis.TallyParams.Quorum)
require.Equal(t, dec2, govGenesis.TallyParams.Threshold)
require.Equal(t, dec3, govGenesis.TallyParams.VetoThreshold)
require.Equal(t, dec1.String(), govGenesis.TallyParams.Quorum)
require.Equal(t, dec2.String(), govGenesis.TallyParams.Threshold)
require.Equal(t, dec3.String(), govGenesis.TallyParams.VetoThreshold)
require.Equal(t, uint64(0x28), govGenesis.StartingProposalId)
require.Equal(t, types.Deposits{}, govGenesis.Deposits)
require.Equal(t, types.Votes{}, govGenesis.Votes)
require.Equal(t, types.Proposals{}, govGenesis.Proposals)
require.Equal(t, []*types.Deposit{}, govGenesis.Deposits)
require.Equal(t, []*types.Vote{}, govGenesis.Votes)
require.Equal(t, []*types.Proposal{}, govGenesis.Proposals)
}
// TestRandomizedGenState tests abnormal scenarios of applying RandomizedGenState.

View File

@ -3,8 +3,6 @@ package types
import (
"fmt"
"sigs.k8s.io/yaml"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -14,11 +12,6 @@ func NewDeposit(proposalID uint64, depositor sdk.AccAddress, amount sdk.Coins) D
return Deposit{proposalID, depositor.String(), amount}
}
func (d Deposit) String() string {
out, _ := yaml.Marshal(d)
return string(out)
}
// Deposits is a collection of Deposit objects
type Deposits []Deposit
@ -47,8 +40,3 @@ func (d Deposits) String() string {
}
return out
}
// Empty returns whether a deposit is empty.
func (d Deposit) Empty() bool {
return d.String() == Deposit{}.String()
}

View File

@ -1,19 +1,19 @@
package types
import (
"errors"
"fmt"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// NewGenesisState creates a new genesis state for the governance module
func NewGenesisState(startingProposalID uint64, dp DepositParams, vp VotingParams, tp TallyParams) *GenesisState {
return &GenesisState{
StartingProposalId: startingProposalID,
DepositParams: dp,
VotingParams: vp,
TallyParams: tp,
DepositParams: &dp,
VotingParams: &vp,
TallyParams: &tp,
}
}
@ -27,38 +27,30 @@ func DefaultGenesisState() *GenesisState {
)
}
func (data GenesisState) Equal(other GenesisState) bool {
return data.StartingProposalId == other.StartingProposalId &&
data.Deposits.Equal(other.Deposits) &&
data.Votes.Equal(other.Votes) &&
data.Proposals.Equal(other.Proposals) &&
data.DepositParams.Equal(other.DepositParams) &&
data.TallyParams.Equal(other.TallyParams) &&
data.VotingParams.Equal(other.VotingParams)
}
// Empty returns true if a GenesisState is empty
func (data GenesisState) Empty() bool {
return data.Equal(GenesisState{})
return data.StartingProposalId == 0 ||
data.DepositParams == nil ||
data.VotingParams == nil ||
data.TallyParams == nil
}
// ValidateGenesis checks if parameters are within valid ranges
func ValidateGenesis(data *GenesisState) error {
threshold := data.TallyParams.Threshold
if threshold.IsNegative() || threshold.GT(sdk.OneDec()) {
return fmt.Errorf("governance vote threshold should be positive and less or equal to one, is %s",
threshold.String())
if data.StartingProposalId == 0 {
return errors.New("Starting proposal id must be greater than 0")
}
veto := data.TallyParams.VetoThreshold
if veto.IsNegative() || veto.GT(sdk.OneDec()) {
return fmt.Errorf("governance vote veto threshold should be positive and less or equal to one, is %s",
veto.String())
if err := validateTallyParams(data.TallyParams); err != nil {
return fmt.Errorf("invalid tally params: %w", err)
}
if !data.DepositParams.MinDeposit.IsValid() {
return fmt.Errorf("governance deposit amount must be a valid sdk.Coins amount, is %s",
data.DepositParams.MinDeposit.String())
if err := validateVotingParams(data.VotingParams); err != nil {
return fmt.Errorf("invalid voting params: %w", err)
}
if err := validateDepositParams(data.DepositParams); err != nil {
return fmt.Errorf("invalid deposit params: %w", err)
}
return nil

View File

@ -5,7 +5,6 @@ package types
import (
fmt "fmt"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
@ -26,19 +25,19 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// GenesisState defines the gov module's genesis state.
type GenesisState struct {
// starting_proposal_id is the ID of the starting proposal.
StartingProposalId uint64 `protobuf:"varint,1,opt,name=starting_proposal_id,json=startingProposalId,proto3" json:"starting_proposal_id,omitempty" yaml:"starting_proposal_id"`
StartingProposalId uint64 `protobuf:"varint,1,opt,name=starting_proposal_id,json=startingProposalId,proto3" json:"starting_proposal_id,omitempty"`
// deposits defines all the deposits present at genesis.
Deposits Deposits `protobuf:"bytes,2,rep,name=deposits,proto3,castrepeated=Deposits" json:"deposits"`
Deposits []*Deposit `protobuf:"bytes,2,rep,name=deposits,proto3" json:"deposits,omitempty"`
// votes defines all the votes present at genesis.
Votes Votes `protobuf:"bytes,3,rep,name=votes,proto3,castrepeated=Votes" json:"votes"`
Votes []*Vote `protobuf:"bytes,3,rep,name=votes,proto3" json:"votes,omitempty"`
// proposals defines all the proposals present at genesis.
Proposals Proposals `protobuf:"bytes,4,rep,name=proposals,proto3,castrepeated=Proposals" json:"proposals"`
Proposals []*Proposal `protobuf:"bytes,4,rep,name=proposals,proto3" json:"proposals,omitempty"`
// params defines all the paramaters of related to deposit.
DepositParams DepositParams `protobuf:"bytes,5,opt,name=deposit_params,json=depositParams,proto3" json:"deposit_params" yaml:"deposit_params"`
DepositParams *DepositParams `protobuf:"bytes,5,opt,name=deposit_params,json=depositParams,proto3" json:"deposit_params,omitempty"`
// params defines all the paramaters of related to voting.
VotingParams VotingParams `protobuf:"bytes,6,opt,name=voting_params,json=votingParams,proto3" json:"voting_params" yaml:"voting_params"`
VotingParams *VotingParams `protobuf:"bytes,6,opt,name=voting_params,json=votingParams,proto3" json:"voting_params,omitempty"`
// params defines all the paramaters of related to tally.
TallyParams TallyParams `protobuf:"bytes,7,opt,name=tally_params,json=tallyParams,proto3" json:"tally_params" yaml:"tally_params"`
TallyParams *TallyParams `protobuf:"bytes,7,opt,name=tally_params,json=tallyParams,proto3" json:"tally_params,omitempty"`
}
func (m *GenesisState) Reset() { *m = GenesisState{} }
@ -81,46 +80,46 @@ func (m *GenesisState) GetStartingProposalId() uint64 {
return 0
}
func (m *GenesisState) GetDeposits() Deposits {
func (m *GenesisState) GetDeposits() []*Deposit {
if m != nil {
return m.Deposits
}
return nil
}
func (m *GenesisState) GetVotes() Votes {
func (m *GenesisState) GetVotes() []*Vote {
if m != nil {
return m.Votes
}
return nil
}
func (m *GenesisState) GetProposals() Proposals {
func (m *GenesisState) GetProposals() []*Proposal {
if m != nil {
return m.Proposals
}
return nil
}
func (m *GenesisState) GetDepositParams() DepositParams {
func (m *GenesisState) GetDepositParams() *DepositParams {
if m != nil {
return m.DepositParams
}
return DepositParams{}
return nil
}
func (m *GenesisState) GetVotingParams() VotingParams {
func (m *GenesisState) GetVotingParams() *VotingParams {
if m != nil {
return m.VotingParams
}
return VotingParams{}
return nil
}
func (m *GenesisState) GetTallyParams() TallyParams {
func (m *GenesisState) GetTallyParams() *TallyParams {
if m != nil {
return m.TallyParams
}
return TallyParams{}
return nil
}
func init() {
@ -130,34 +129,29 @@ func init() {
func init() { proto.RegisterFile("cosmos/gov/v1beta2/genesis.proto", fileDescriptor_7915ab39bb5aa171) }
var fileDescriptor_7915ab39bb5aa171 = []byte{
// 430 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xb1, 0x8e, 0xd3, 0x40,
0x10, 0x86, 0x63, 0x2e, 0x39, 0xee, 0x36, 0x09, 0x82, 0x25, 0x48, 0xd6, 0x25, 0xd8, 0xc6, 0x55,
0x1a, 0x6c, 0x11, 0x3a, 0x24, 0x1a, 0x0b, 0x09, 0x5d, 0x81, 0x74, 0x18, 0x44, 0x41, 0x13, 0x6d,
0xe2, 0xd5, 0x62, 0x61, 0xdf, 0x58, 0x9e, 0xc5, 0x22, 0x6f, 0xc1, 0x73, 0xf0, 0x24, 0x57, 0x5e,
0x49, 0x15, 0x50, 0x52, 0xd1, 0xde, 0x13, 0x20, 0xef, 0xae, 0xc1, 0x11, 0x86, 0x2a, 0xf1, 0xec,
0xbf, 0xdf, 0x37, 0x3b, 0x1a, 0xe2, 0xad, 0x01, 0x73, 0xc0, 0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2, 0x1c, 0xed, 0x81, 0x67, 0xcd, 0x87, 0x8b, 0x47, 0xff, 0x79, 0xde, 0x85,
0x0a, 0x46, 0x0f, 0x6b, 0xf0, 0xcd, 0xd6, 0x7d, 0xa0, 0x87, 0x79, 0x88, 0xf1, 0xe3, 0x71, 0xd2,
0x4e, 0xd3, 0x35, 0x19, 0x57, 0xa0, 0x87, 0xad, 0x3d, 0xc7, 0xca, 0xe3, 0xfd, 0xe3, 0xf9, 0xf5,
0xf8, 0xb5, 0x66, 0x66, 0x34, 0x13, 0xad, 0x39, 0x80, 0xf8, 0xf1, 0xa8, 0x6a, 0x65, 0xe9, 0x92,
0x8c, 0x24, 0xcb, 0xb2, 0x4d, 0xe3, 0xb8, 0xad, 0x1c, 0x6e, 0x97, 0xe3, 0x6d, 0x9d, 0x33, 0x8a,
0xa9, 0x51, 0xdc, 0xd7, 0x8a, 0x36, 0xc2, 0x8f, 0x87, 0xb2, 0x95, 0x8c, 0xae, 0x76, 0x8e, 0x75,
0xbd, 0x73, 0xac, 0x1f, 0x3b, 0xc7, 0xfa, 0xb2, 0x77, 0x7a, 0xd7, 0x7b, 0xa7, 0xf7, 0x6d, 0xef,
0xf4, 0xde, 0xcf, 0x45, 0x2a, 0x3f, 0x7c, 0x5a, 0x05, 0x6b, 0xc8, 0x43, 0xb3, 0xae, 0xfa, 0xe7,
0x31, 0x26, 0x1f, 0xc3, 0xcf, 0x6a, 0x77, 0xe5, 0xa6, 0xe0, 0xb8, 0x3a, 0x56, 0x6b, 0xfb, 0xf4,
0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x59, 0xfd, 0x9f, 0x57, 0x22, 0x03, 0x00, 0x00,
// 341 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xbd, 0x4e, 0xc3, 0x30,
0x14, 0x85, 0x1b, 0xfa, 0x03, 0xb8, 0x2d, 0x83, 0xc5, 0x10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xe4, 0xff, 0x1d, 0x24, 0x3c, 0xe5, 0x13, 0x69, 0xd7, 0x5d, 0xcb, 0x6b,
0x76, 0x0f, 0xff, 0xa9, 0xda, 0xd7, 0x60, 0xd0, 0x0e, 0xd7, 0x47, 0x7a, 0x45, 0xda, 0x0a, 0xcc,
0xf5, 0x18, 0x51, 0x43, 0x8b, 0xdc, 0x3f, 0xda, 0x2f, 0xef, 0xca, 0x78, 0x5a, 0x6a, 0x6d, 0xa2,
0x3d, 0xd2, 0x42, 0x3e, 0x1e, 0xcf, 0x0a, 0xcb, 0xa6, 0xb6, 0x1c, 0x94, 0x59, 0xee, 0x97, 0x5c,
0x2e, 0x69, 0xe2, 0x6a, 0xe8, 0xf5, 0x3e, 0x16, 0x8e, 0x35, 0x5f, 0x38, 0xd6, 0xd7, 0xc2, 0xb1,
0xde, 0x32, 0xa7, 0x32, 0xcf, 0x9c, 0xca, 0x67, 0xe6, 0x54, 0x1e, 0xbd, 0x28, 0xc6, 0xa7, 0x97,
0x21, 0x1b, 0xc1, 0xc4, 0xcf, 0xdf, 0xdf, 0x7c, 0x8e, 0x65, 0xf8, 0xec, 0xbf, 0xea, 0x65, 0xc0,
0x59, 0x22, 0xe4, 0xb0, 0xa1, 0xf7, 0xe0, 0xec, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x5f, 0x73, 0x78,
0xdf, 0x5d, 0x02, 0x00, 0x00,
}
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
@ -180,36 +174,42 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
{
size, err := m.TallyParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if m.TallyParams != nil {
{
size, err := m.TallyParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
i--
dAtA[i] = 0x3a
}
i--
dAtA[i] = 0x3a
{
size, err := m.VotingParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if m.VotingParams != nil {
{
size, err := m.VotingParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
i--
dAtA[i] = 0x32
}
i--
dAtA[i] = 0x32
{
size, err := m.DepositParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if m.DepositParams != nil {
{
size, err := m.DepositParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
i--
dAtA[i] = 0x2a
}
i--
dAtA[i] = 0x2a
if len(m.Proposals) > 0 {
for iNdEx := len(m.Proposals) - 1; iNdEx >= 0; iNdEx-- {
{
@ -298,12 +298,18 @@ func (m *GenesisState) Size() (n int) {
n += 1 + l + sovGenesis(uint64(l))
}
}
l = m.DepositParams.Size()
n += 1 + l + sovGenesis(uint64(l))
l = m.VotingParams.Size()
n += 1 + l + sovGenesis(uint64(l))
l = m.TallyParams.Size()
n += 1 + l + sovGenesis(uint64(l))
if m.DepositParams != nil {
l = m.DepositParams.Size()
n += 1 + l + sovGenesis(uint64(l))
}
if m.VotingParams != nil {
l = m.VotingParams.Size()
n += 1 + l + sovGenesis(uint64(l))
}
if m.TallyParams != nil {
l = m.TallyParams.Size()
n += 1 + l + sovGenesis(uint64(l))
}
return n
}
@ -390,7 +396,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Deposits = append(m.Deposits, Deposit{})
m.Deposits = append(m.Deposits, &Deposit{})
if err := m.Deposits[len(m.Deposits)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -424,7 +430,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Votes = append(m.Votes, Vote{})
m.Votes = append(m.Votes, &Vote{})
if err := m.Votes[len(m.Votes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -458,7 +464,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Proposals = append(m.Proposals, Proposal{})
m.Proposals = append(m.Proposals, &Proposal{})
if err := m.Proposals[len(m.Proposals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -492,6 +498,9 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.DepositParams == nil {
m.DepositParams = &DepositParams{}
}
if err := m.DepositParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -525,6 +534,9 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.VotingParams == nil {
m.VotingParams = &VotingParams{}
}
if err := m.VotingParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -558,6 +570,9 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.TallyParams == nil {
m.TallyParams = &TallyParams{}
}
if err := m.TallyParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}

View File

@ -6,17 +6,10 @@ import (
"github.com/stretchr/testify/require"
)
func TestEqualProposalID(t *testing.T) {
func TestEmptyGenesis(t *testing.T) {
state1 := GenesisState{}
state2 := GenesisState{}
require.Equal(t, state1, state2)
require.True(t, state1.Empty())
// Proposals
state1.StartingProposalId = 1
require.NotEqual(t, state1, state2)
require.False(t, state1.Equal(state2))
state2.StartingProposalId = 1
require.Equal(t, state1, state2)
require.True(t, state1.Equal(state2))
state2 := DefaultGenesisState()
require.False(t, state2.Empty())
}

File diff suppressed because it is too large Load Diff

View File

@ -3,8 +3,6 @@ package types
import (
"fmt"
"sigs.k8s.io/yaml"
"github.com/gogo/protobuf/proto"
"github.com/cosmos/cosmos-sdk/codec/types"
@ -42,14 +40,7 @@ func NewMsgSubmitProposal(messages []sdk.Msg, initialDeposit sdk.Coins, proposer
return m, nil
}
func (m *MsgSubmitProposal) GetInitialDeposit() sdk.Coins { return m.InitialDeposit }
func (m *MsgSubmitProposal) GetProposer() sdk.AccAddress {
proposer, _ := sdk.AccAddressFromBech32(m.Proposer)
return proposer
}
func (m *MsgSubmitProposal) GetMessages() ([]sdk.Msg, error) {
func (m *MsgSubmitProposal) GetMsgs() ([]sdk.Msg, error) {
return sdktx.GetMsgs(m.Messages, "sdk.MsgProposal")
}
@ -90,11 +81,14 @@ func (m MsgSubmitProposal) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Proposer); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid proposer address: %s", err)
}
if !m.InitialDeposit.IsValid() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.InitialDeposit.String())
deposit := sdk.NewCoins(m.InitialDeposit...)
if !deposit.IsValid() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, deposit.String())
}
if m.InitialDeposit.IsAnyNegative() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.InitialDeposit.String())
if deposit.IsAnyNegative() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, deposit.String())
}
// Empty messages are not allowed
@ -103,7 +97,7 @@ func (m MsgSubmitProposal) ValidateBasic() error {
// return ErrNoProposalMsgs
// }
msgs, err := m.GetMessages()
msgs, err := m.GetMsgs()
if err != nil {
return err
}
@ -130,12 +124,6 @@ func (m MsgSubmitProposal) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{proposer}
}
// String implements the Stringer interface
func (m MsgSubmitProposal) String() string {
out, _ := yaml.Marshal(m)
return string(out)
}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (m MsgSubmitProposal) UnpackInterfaces(unpacker types.AnyUnpacker) error {
return sdktx.UnpackInterfaces(unpacker, m.Messages)
@ -158,22 +146,17 @@ func (msg MsgDeposit) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Depositor); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid depositor address: %s", err)
}
if !msg.Amount.IsValid() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.Amount.String())
amount := sdk.NewCoins(msg.Amount...)
if !amount.IsValid() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, amount.String())
}
if msg.Amount.IsAnyNegative() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.Amount.String())
if amount.IsAnyNegative() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, amount.String())
}
return nil
}
// String implements the Stringer interface
func (msg MsgDeposit) String() string {
out, _ := yaml.Marshal(msg)
return string(out)
}
// GetSignBytes implements Msg
func (msg MsgDeposit) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(&msg)
@ -210,12 +193,6 @@ func (msg MsgVote) ValidateBasic() error {
return nil
}
// String implements the Stringer interface
func (msg MsgVote) String() string {
out, _ := yaml.Marshal(msg)
return string(out)
}
// GetSignBytes implements Msg
func (msg MsgVote) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(&msg)
@ -252,10 +229,14 @@ func (msg MsgVoteWeighted) ValidateBasic() error {
totalWeight := sdk.NewDec(0)
usedOptions := make(map[VoteOption]bool)
for _, option := range msg.Options {
if !ValidWeightedVoteOption(option) {
if !option.IsValid() {
return sdkerrors.Wrap(ErrInvalidVote, option.String())
}
totalWeight = totalWeight.Add(option.Weight)
weight, err := sdk.NewDecFromStr(option.Weight)
if err != nil {
return sdkerrors.Wrapf(ErrInvalidVote, "Invalid weight: %s", err)
}
totalWeight = totalWeight.Add(weight)
if usedOptions[option.Option] {
return sdkerrors.Wrap(ErrInvalidVote, "Duplicated vote option")
}
@ -273,12 +254,6 @@ func (msg MsgVoteWeighted) ValidateBasic() error {
return nil
}
// String implements the Stringer interface
func (msg MsgVoteWeighted) String() string {
out, _ := yaml.Marshal(msg)
return string(out)
}
// GetSignBytes implements Msg
func (msg MsgVoteWeighted) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(&msg)

View File

@ -27,7 +27,7 @@ func TestMsgDepositGetSignBytes(t *testing.T) {
msg := NewMsgDeposit(addr, 0, coinsPos)
res := msg.GetSignBytes()
expected := `{"type":"cosmos-sdk/MsgDeposit","value":{"amount":[{"amount":"1000","denom":"stake"}],"depositor":"cosmos1v9jxgu33kfsgr5","proposal_id":"0"}}`
expected := `{"type":"cosmos-sdk/MsgDeposit","value":{"amount":[{"amount":"1000","denom":"stake"}],"depositor":"cosmos1v9jxgu33kfsgr5"}}`
require.Equal(t, expected, string(res))
}
@ -95,23 +95,23 @@ func TestMsgVoteWeighted(t *testing.T) {
{0, addrs[0], NewNonSplitVoteOption(OptionNoWithVeto), true},
{0, addrs[0], NewNonSplitVoteOption(OptionAbstain), true},
{0, addrs[0], WeightedVoteOptions{ // weight sum > 1
WeightedVoteOption{Option: OptionYes, Weight: sdk.NewDec(1)},
WeightedVoteOption{Option: OptionAbstain, Weight: sdk.NewDec(1)},
NewWeightedVoteOption(OptionYes, sdk.NewDec(1)),
NewWeightedVoteOption(OptionAbstain, sdk.NewDec(1)),
}, false},
{0, addrs[0], WeightedVoteOptions{ // duplicate option
WeightedVoteOption{Option: OptionYes, Weight: sdk.NewDecWithPrec(5, 1)},
WeightedVoteOption{Option: OptionYes, Weight: sdk.NewDecWithPrec(5, 1)},
NewWeightedVoteOption(OptionYes, sdk.NewDecWithPrec(5, 1)),
NewWeightedVoteOption(OptionYes, sdk.NewDecWithPrec(5, 1)),
}, false},
{0, addrs[0], WeightedVoteOptions{ // zero weight
WeightedVoteOption{Option: OptionYes, Weight: sdk.NewDec(0)},
NewWeightedVoteOption(OptionYes, sdk.NewDec(0)),
}, false},
{0, addrs[0], WeightedVoteOptions{ // negative weight
WeightedVoteOption{Option: OptionYes, Weight: sdk.NewDec(-1)},
NewWeightedVoteOption(OptionYes, sdk.NewDec(-1)),
}, false},
{0, addrs[0], WeightedVoteOptions{}, false},
{0, addrs[0], NewNonSplitVoteOption(VoteOption(0x13)), false},
{0, addrs[0], WeightedVoteOptions{ // weight sum <1
WeightedVoteOption{Option: OptionYes, Weight: sdk.NewDecWithPrec(5, 1)},
NewWeightedVoteOption(OptionYes, sdk.NewDecWithPrec(5, 1)),
}, false},
}

View File

@ -1,11 +1,10 @@
package types
import (
"errors"
"fmt"
"time"
"sigs.k8s.io/yaml"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
@ -43,7 +42,7 @@ func ParamKeyTable() paramtypes.KeyTable {
func NewDepositParams(minDeposit sdk.Coins, maxDepositPeriod time.Duration) DepositParams {
return DepositParams{
MinDeposit: minDeposit,
MaxDepositPeriod: maxDepositPeriod,
MaxDepositPeriod: &maxDepositPeriod,
}
}
@ -55,15 +54,9 @@ func DefaultDepositParams() DepositParams {
)
}
// String implements stringer insterface
func (dp DepositParams) String() string {
out, _ := yaml.Marshal(dp)
return string(out)
}
// Equal checks equality of DepositParams
func (dp DepositParams) Equal(dp2 DepositParams) bool {
return dp.MinDeposit.IsEqual(dp2.MinDeposit) && dp.MaxDepositPeriod == dp2.MaxDepositPeriod
return sdk.NewCoins(dp.MinDeposit...).IsEqual(sdk.NewCoins(dp2.MinDeposit...)) && dp.MaxDepositPeriod == dp2.MaxDepositPeriod
}
func validateDepositParams(i interface{}) error {
@ -72,10 +65,11 @@ func validateDepositParams(i interface{}) error {
return fmt.Errorf("invalid parameter type: %T", i)
}
if !v.MinDeposit.IsValid() {
minDeposit := sdk.NewCoins(v.MinDeposit...)
if !minDeposit.IsValid() {
return fmt.Errorf("invalid minimum deposit: %s", v.MinDeposit)
}
if v.MaxDepositPeriod <= 0 {
if v.MaxDepositPeriod == nil || v.MaxDepositPeriod.Seconds() <= 0 {
return fmt.Errorf("maximum deposit period must be positive: %d", v.MaxDepositPeriod)
}
@ -85,9 +79,9 @@ func validateDepositParams(i interface{}) error {
// NewTallyParams creates a new TallyParams object
func NewTallyParams(quorum, threshold, vetoThreshold sdk.Dec) TallyParams {
return TallyParams{
Quorum: quorum,
Threshold: threshold,
VetoThreshold: vetoThreshold,
Quorum: quorum.String(),
Threshold: threshold.String(),
VetoThreshold: vetoThreshold.String(),
}
}
@ -98,13 +92,7 @@ func DefaultTallyParams() TallyParams {
// Equal checks equality of TallyParams
func (tp TallyParams) Equal(other TallyParams) bool {
return tp.Quorum.Equal(other.Quorum) && tp.Threshold.Equal(other.Threshold) && tp.VetoThreshold.Equal(other.VetoThreshold)
}
// String implements stringer insterface
func (tp TallyParams) String() string {
out, _ := yaml.Marshal(tp)
return string(out)
return tp.Quorum == other.Quorum && tp.Threshold == other.Threshold && tp.VetoThreshold == other.VetoThreshold
}
func validateTallyParams(i interface{}) error {
@ -113,22 +101,36 @@ func validateTallyParams(i interface{}) error {
return fmt.Errorf("invalid parameter type: %T", i)
}
if v.Quorum.IsNegative() {
return fmt.Errorf("quorom cannot be negative: %s", v.Quorum)
quorum, err := sdk.NewDecFromStr(v.Quorum)
if err != nil {
return fmt.Errorf("invalid quorum string: %w", err)
}
if v.Quorum.GT(sdk.OneDec()) {
if quorum.IsNegative() {
return fmt.Errorf("quorom cannot be negative: %s", quorum)
}
if quorum.GT(sdk.OneDec()) {
return fmt.Errorf("quorom too large: %s", v)
}
if !v.Threshold.IsPositive() {
return fmt.Errorf("vote threshold must be positive: %s", v.Threshold)
threshold, err := sdk.NewDecFromStr(v.Threshold)
if err != nil {
return fmt.Errorf("invalid threshold string: %w", err)
}
if v.Threshold.GT(sdk.OneDec()) {
if !threshold.IsPositive() {
return fmt.Errorf("vote threshold must be positive: %s", threshold)
}
if threshold.GT(sdk.OneDec()) {
return fmt.Errorf("vote threshold too large: %s", v)
}
if !v.VetoThreshold.IsPositive() {
return fmt.Errorf("veto threshold must be positive: %s", v.Threshold)
vetoThreshold, err := sdk.NewDecFromStr(v.VetoThreshold)
if err != nil {
return fmt.Errorf("invalid vetoThreshold string: %w", err)
}
if v.VetoThreshold.GT(sdk.OneDec()) {
if !vetoThreshold.IsPositive() {
return fmt.Errorf("veto threshold must be positive: %s", vetoThreshold)
}
if vetoThreshold.GT(sdk.OneDec()) {
return fmt.Errorf("veto threshold too large: %s", v)
}
@ -138,7 +140,7 @@ func validateTallyParams(i interface{}) error {
// NewVotingParams creates a new VotingParams object
func NewVotingParams(votingPeriod time.Duration) VotingParams {
return VotingParams{
VotingPeriod: votingPeriod,
VotingPeriod: &votingPeriod,
}
}
@ -152,19 +154,17 @@ func (vp VotingParams) Equal(other VotingParams) bool {
return vp.VotingPeriod == other.VotingPeriod
}
// String implements stringer interface
func (vp VotingParams) String() string {
out, _ := yaml.Marshal(vp)
return string(out)
}
func validateVotingParams(i interface{}) error {
v, ok := i.(VotingParams)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if v.VotingPeriod <= 0 {
if v.VotingPeriod == nil {
return errors.New("voting period must not be nil")
}
if v.VotingPeriod.Seconds() <= 0 {
return fmt.Errorf("voting period must be positive: %s", v.VotingPeriod)
}

View File

@ -5,15 +5,22 @@ import (
"strings"
"time"
"sigs.k8s.io/yaml"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdktx "github.com/cosmos/cosmos-sdk/types/tx"
)
// DefaultStartingProposalID is 1
const DefaultStartingProposalID uint64 = 1
const (
// DefaultStartingProposalID is 1
DefaultStartingProposalID uint64 = 1
StatusNil = ProposalStatus_PROPOSAL_STATUS_UNSPECIFIED
StatusDepositPeriod = ProposalStatus_PROPOSAL_STATUS_DEPOSIT_PERIOD
StatusVotingPeriod = ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD
StatusPassed = ProposalStatus_PROPOSAL_STATUS_PASSED
StatusRejected = ProposalStatus_PROPOSAL_STATUS_REJECTED
StatusFailed = ProposalStatus_PROPOSAL_STATUS_FAILED
)
// NewProposal creates a new Proposal instance
func NewProposal(messages []sdk.Msg, id uint64, submitTime, depositEndTime time.Time) (Proposal, error) {
@ -29,21 +36,15 @@ func NewProposal(messages []sdk.Msg, id uint64, submitTime, depositEndTime time.
Status: StatusDepositPeriod,
FinalTallyResult: EmptyTallyResult(),
TotalDeposit: sdk.NewCoins(),
SubmitTime: submitTime,
DepositEndTime: depositEndTime,
SubmitTime: &submitTime,
DepositEndTime: &depositEndTime,
}
return p, nil
}
// String implements stringer interface
func (p Proposal) String() string {
out, _ := yaml.Marshal(p)
return string(out)
}
// GetMessages returns the proposal messages
func (p Proposal) GetMessages() ([]sdk.Msg, error) {
func (p Proposal) GetMsgs() ([]sdk.Msg, error) {
return sdktx.GetMsgs(p.Messages, "sdk.MsgProposal")
}
@ -57,21 +58,6 @@ type Proposals []Proposal
var _ types.UnpackInterfacesMessage = Proposals{}
// Equal returns true if two slices (order-dependant) of proposals are equal.
func (p Proposals) Equal(other Proposals) bool {
if len(p) != len(other) {
return false
}
for i, proposal := range p {
if !proposal.Equal(other[i]) {
return false
}
}
return true
}
// String implements stringer interface
func (p Proposals) String() string {
out := "ID - (Status) [Type] Title\n"

View File

@ -8,7 +8,6 @@ import (
fmt "fmt"
_ "github.com/cosmos/cosmos-proto"
query "github.com/cosmos/cosmos-sdk/types/query"
_ "github.com/gogo/protobuf/gogoproto"
grpc1 "github.com/gogo/protobuf/grpc"
proto "github.com/gogo/protobuf/proto"
_ "google.golang.org/genproto/googleapis/api/annotations"
@ -79,7 +78,7 @@ func (m *QueryProposalRequest) GetProposalId() uint64 {
// QueryProposalResponse is the response type for the Query/Proposal RPC method.
type QueryProposalResponse struct {
Proposal Proposal `protobuf:"bytes,1,opt,name=proposal,proto3" json:"proposal"`
Proposal *Proposal `protobuf:"bytes,1,opt,name=proposal,proto3" json:"proposal,omitempty"`
}
func (m *QueryProposalResponse) Reset() { *m = QueryProposalResponse{} }
@ -115,11 +114,11 @@ func (m *QueryProposalResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryProposalResponse proto.InternalMessageInfo
func (m *QueryProposalResponse) GetProposal() Proposal {
func (m *QueryProposalResponse) GetProposal() *Proposal {
if m != nil {
return m.Proposal
}
return Proposal{}
return nil
}
// QueryProposalsRequest is the request type for the Query/Proposals RPC method.
@ -167,10 +166,38 @@ func (m *QueryProposalsRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryProposalsRequest proto.InternalMessageInfo
func (m *QueryProposalsRequest) GetProposalStatus() ProposalStatus {
if m != nil {
return m.ProposalStatus
}
return ProposalStatus_PROPOSAL_STATUS_UNSPECIFIED
}
func (m *QueryProposalsRequest) GetVoter() string {
if m != nil {
return m.Voter
}
return ""
}
func (m *QueryProposalsRequest) GetDepositor() string {
if m != nil {
return m.Depositor
}
return ""
}
func (m *QueryProposalsRequest) GetPagination() *query.PageRequest {
if m != nil {
return m.Pagination
}
return nil
}
// QueryProposalsResponse is the response type for the Query/Proposals RPC
// method.
type QueryProposalsResponse struct {
Proposals []Proposal `protobuf:"bytes,1,rep,name=proposals,proto3" json:"proposals"`
Proposals []*Proposal `protobuf:"bytes,1,rep,name=proposals,proto3" json:"proposals,omitempty"`
// pagination defines the pagination in the response.
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}
@ -208,7 +235,7 @@ func (m *QueryProposalsResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryProposalsResponse proto.InternalMessageInfo
func (m *QueryProposalsResponse) GetProposals() []Proposal {
func (m *QueryProposalsResponse) GetProposals() []*Proposal {
if m != nil {
return m.Proposals
}
@ -263,10 +290,24 @@ func (m *QueryVoteRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryVoteRequest proto.InternalMessageInfo
func (m *QueryVoteRequest) GetProposalId() uint64 {
if m != nil {
return m.ProposalId
}
return 0
}
func (m *QueryVoteRequest) GetVoter() string {
if m != nil {
return m.Voter
}
return ""
}
// QueryVoteResponse is the response type for the Query/Vote RPC method.
type QueryVoteResponse struct {
// vote defined the queried vote.
Vote Vote `protobuf:"bytes,1,opt,name=vote,proto3" json:"vote"`
Vote *Vote `protobuf:"bytes,1,opt,name=vote,proto3" json:"vote,omitempty"`
}
func (m *QueryVoteResponse) Reset() { *m = QueryVoteResponse{} }
@ -302,11 +343,11 @@ func (m *QueryVoteResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryVoteResponse proto.InternalMessageInfo
func (m *QueryVoteResponse) GetVote() Vote {
func (m *QueryVoteResponse) GetVote() *Vote {
if m != nil {
return m.Vote
}
return Vote{}
return nil
}
// QueryVotesRequest is the request type for the Query/Votes RPC method.
@ -367,7 +408,7 @@ func (m *QueryVotesRequest) GetPagination() *query.PageRequest {
// QueryVotesResponse is the response type for the Query/Votes RPC method.
type QueryVotesResponse struct {
// votes defined the queried votes.
Votes []Vote `protobuf:"bytes,1,rep,name=votes,proto3" json:"votes"`
Votes []*Vote `protobuf:"bytes,1,rep,name=votes,proto3" json:"votes,omitempty"`
// pagination defines the pagination in the response.
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}
@ -405,7 +446,7 @@ func (m *QueryVotesResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryVotesResponse proto.InternalMessageInfo
func (m *QueryVotesResponse) GetVotes() []Vote {
func (m *QueryVotesResponse) GetVotes() []*Vote {
if m != nil {
return m.Votes
}
@ -469,11 +510,11 @@ func (m *QueryParamsRequest) GetParamsType() string {
// QueryParamsResponse is the response type for the Query/Params RPC method.
type QueryParamsResponse struct {
// voting_params defines the parameters related to voting.
VotingParams VotingParams `protobuf:"bytes,1,opt,name=voting_params,json=votingParams,proto3" json:"voting_params"`
VotingParams *VotingParams `protobuf:"bytes,1,opt,name=voting_params,json=votingParams,proto3" json:"voting_params,omitempty"`
// deposit_params defines the parameters related to deposit.
DepositParams DepositParams `protobuf:"bytes,2,opt,name=deposit_params,json=depositParams,proto3" json:"deposit_params"`
DepositParams *DepositParams `protobuf:"bytes,2,opt,name=deposit_params,json=depositParams,proto3" json:"deposit_params,omitempty"`
// tally_params defines the parameters related to tally.
TallyParams TallyParams `protobuf:"bytes,3,opt,name=tally_params,json=tallyParams,proto3" json:"tally_params"`
TallyParams *TallyParams `protobuf:"bytes,3,opt,name=tally_params,json=tallyParams,proto3" json:"tally_params,omitempty"`
}
func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} }
@ -509,25 +550,25 @@ func (m *QueryParamsResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo
func (m *QueryParamsResponse) GetVotingParams() VotingParams {
func (m *QueryParamsResponse) GetVotingParams() *VotingParams {
if m != nil {
return m.VotingParams
}
return VotingParams{}
return nil
}
func (m *QueryParamsResponse) GetDepositParams() DepositParams {
func (m *QueryParamsResponse) GetDepositParams() *DepositParams {
if m != nil {
return m.DepositParams
}
return DepositParams{}
return nil
}
func (m *QueryParamsResponse) GetTallyParams() TallyParams {
func (m *QueryParamsResponse) GetTallyParams() *TallyParams {
if m != nil {
return m.TallyParams
}
return TallyParams{}
return nil
}
// QueryDepositRequest is the request type for the Query/Deposit RPC method.
@ -571,10 +612,24 @@ func (m *QueryDepositRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryDepositRequest proto.InternalMessageInfo
func (m *QueryDepositRequest) GetProposalId() uint64 {
if m != nil {
return m.ProposalId
}
return 0
}
func (m *QueryDepositRequest) GetDepositor() string {
if m != nil {
return m.Depositor
}
return ""
}
// QueryDepositResponse is the response type for the Query/Deposit RPC method.
type QueryDepositResponse struct {
// deposit defines the requested deposit.
Deposit Deposit `protobuf:"bytes,1,opt,name=deposit,proto3" json:"deposit"`
Deposit *Deposit `protobuf:"bytes,1,opt,name=deposit,proto3" json:"deposit,omitempty"`
}
func (m *QueryDepositResponse) Reset() { *m = QueryDepositResponse{} }
@ -610,11 +665,11 @@ func (m *QueryDepositResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryDepositResponse proto.InternalMessageInfo
func (m *QueryDepositResponse) GetDeposit() Deposit {
func (m *QueryDepositResponse) GetDeposit() *Deposit {
if m != nil {
return m.Deposit
}
return Deposit{}
return nil
}
// QueryDepositsRequest is the request type for the Query/Deposits RPC method.
@ -674,7 +729,7 @@ func (m *QueryDepositsRequest) GetPagination() *query.PageRequest {
// QueryDepositsResponse is the response type for the Query/Deposits RPC method.
type QueryDepositsResponse struct {
Deposits []Deposit `protobuf:"bytes,1,rep,name=deposits,proto3" json:"deposits"`
Deposits []*Deposit `protobuf:"bytes,1,rep,name=deposits,proto3" json:"deposits,omitempty"`
// pagination defines the pagination in the response.
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}
@ -712,7 +767,7 @@ func (m *QueryDepositsResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryDepositsResponse proto.InternalMessageInfo
func (m *QueryDepositsResponse) GetDeposits() []Deposit {
func (m *QueryDepositsResponse) GetDeposits() []*Deposit {
if m != nil {
return m.Deposits
}
@ -775,7 +830,7 @@ func (m *QueryTallyResultRequest) GetProposalId() uint64 {
// QueryTallyResultResponse is the response type for the Query/Tally RPC method.
type QueryTallyResultResponse struct {
// tally defines the requested tally.
Tally TallyResult `protobuf:"bytes,1,opt,name=tally,proto3" json:"tally"`
Tally *TallyResult `protobuf:"bytes,1,opt,name=tally,proto3" json:"tally,omitempty"`
}
func (m *QueryTallyResultResponse) Reset() { *m = QueryTallyResultResponse{} }
@ -811,11 +866,11 @@ func (m *QueryTallyResultResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryTallyResultResponse proto.InternalMessageInfo
func (m *QueryTallyResultResponse) GetTally() TallyResult {
func (m *QueryTallyResultResponse) GetTally() *TallyResult {
if m != nil {
return m.Tally
}
return TallyResult{}
return nil
}
func init() {
@ -840,70 +895,67 @@ func init() {
func init() { proto.RegisterFile("cosmos/gov/v1beta2/query.proto", fileDescriptor_3efdc0c4615c3665) }
var fileDescriptor_3efdc0c4615c3665 = []byte{
// 998 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x41, 0x6f, 0x1b, 0x45,
0x14, 0xf6, 0x38, 0x4e, 0x6b, 0x4f, 0xda, 0x00, 0x8f, 0x00, 0xc6, 0x14, 0x3b, 0xac, 0x68, 0x6b,
0x52, 0xb2, 0x4b, 0x9c, 0x52, 0xd4, 0x16, 0x50, 0x6b, 0xa1, 0xb6, 0xa8, 0x12, 0x0a, 0x4e, 0x05,
0x12, 0x97, 0x68, 0x53, 0xaf, 0x96, 0x15, 0x8e, 0x67, 0xbb, 0x33, 0xb6, 0x1a, 0x85, 0x08, 0x89,
0x13, 0x88, 0x0b, 0xa8, 0x88, 0x1b, 0x50, 0xa9, 0x12, 0xbf, 0x80, 0x1f, 0xd1, 0x63, 0x05, 0x1c,
0x38, 0x21, 0x94, 0x70, 0xe0, 0x47, 0x70, 0x40, 0x3b, 0xf3, 0x66, 0xbd, 0x9b, 0xac, 0xbd, 0xeb,
0x12, 0x71, 0x8a, 0x3d, 0xf3, 0x7d, 0xef, 0x7d, 0xef, 0x9b, 0x37, 0x6f, 0x1c, 0x5a, 0xbf, 0xcd,
0xf8, 0x16, 0xe3, 0x96, 0xcb, 0x86, 0xd6, 0x70, 0x65, 0xd3, 0x11, 0x76, 0xcb, 0xba, 0x33, 0x70,
0x82, 0x6d, 0xd3, 0x0f, 0x98, 0x60, 0x00, 0x6a, 0xdf, 0x74, 0xd9, 0xd0, 0xc4, 0xfd, 0xda, 0x12,
0x72, 0x36, 0x6d, 0xee, 0x28, 0x30, 0x52, 0x57, 0x2c, 0xdf, 0x76, 0xbd, 0xbe, 0x2d, 0x3c, 0xd6,
0x57, 0xfc, 0xda, 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0x2b, 0xb8,
0xd5, 0x7a, 0x31, 0x90, 0x08, 0xdd, 0x56, 0x84, 0x1a, 0xf8, 0xce, 0x24, 0x75, 0x32, 0xe2, 0xe2,
0xec, 0x27, 0x52, 0x7c, 0x80, 0x0f, 0x19, 0xcc, 0x19, 0xd9, 0xc2, 0x42, 0x02, 0xa2, 0xf8, 0x33,
0x1c, 0xd4, 0x40, 0xeb, 0x6d, 0xc5, 0xf5, 0x1a, 0xbe, 0xf1, 0x38, 0x5c, 0xf1, 0x67, 0x06, 0xf3,
0x29, 0x1d, 0xc1, 0xcb, 0x43, 0x03, 0x1f, 0x57, 0xb8, 0xea, 0x95, 0xf1, 0xc0, 0xff, 0x67, 0xf8,
0x94, 0xac, 0x35, 0x1a, 0xbf, 0x1d, 0xd6, 0xd8, 0xa3, 0xc3, 0x1a, 0xfb, 0xfb, 0xb0, 0xc6, 0xbe,
0x3b, 0xaa, 0x4d, 0x3d, 0x3a, 0xaa, 0x4d, 0xfd, 0x75, 0x54, 0x9b, 0xfa, 0xa4, 0xee, 0x07, 0xf2,
0xd3, 0xee, 0xb6, 0xbd, 0xc3, 0x77, 0x8d, 0x5b, 0xfd, 0x67, 0x45, 0xb4, 0x3e, 0x73, 0x3e, 0x57,
0x31, 0xe2, 0x91, 0x11, 0xdb, 0xa7, 0xd4, 0x2f, 0x95, 0xf5, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff,
0x6d, 0xa1, 0x92, 0x20, 0x62, 0x0d, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -1302,16 +1354,18 @@ func (m *QueryProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
{
size, err := m.Proposal.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if m.Proposal != nil {
{
size, err := m.Proposal.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
i--
dAtA[i] = 0xa
}
i--
dAtA[i] = 0xa
return len(dAtA) - i, nil
}
@ -1473,16 +1527,18 @@ func (m *QueryVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
{
size, err := m.Vote.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if m.Vote != nil {
{
size, err := m.Vote.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
i--
dAtA[i] = 0xa
}
i--
dAtA[i] = 0xa
return len(dAtA) - i, nil
}
@ -1625,36 +1681,42 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
{
size, err := m.TallyParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if m.TallyParams != nil {
{
size, err := m.TallyParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
i--
dAtA[i] = 0x1a
}
i--
dAtA[i] = 0x1a
{
size, err := m.DepositParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if m.DepositParams != nil {
{
size, err := m.DepositParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
i--
dAtA[i] = 0x12
}
i--
dAtA[i] = 0x12
{
size, err := m.VotingParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if m.VotingParams != nil {
{
size, err := m.VotingParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
i--
dAtA[i] = 0xa
}
i--
dAtA[i] = 0xa
return len(dAtA) - i, nil
}
@ -1713,16 +1775,18 @@ func (m *QueryDepositResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
{
size, err := m.Deposit.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if m.Deposit != nil {
{
size, err := m.Deposit.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
i--
dAtA[i] = 0xa
}
i--
dAtA[i] = 0xa
return len(dAtA) - i, nil
}
@ -1863,16 +1927,18 @@ func (m *QueryTallyResultResponse) MarshalToSizedBuffer(dAtA []byte) (int, error
_ = i
var l int
_ = l
{
size, err := m.Tally.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if m.Tally != nil {
{
size, err := m.Tally.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
i--
dAtA[i] = 0xa
}
i--
dAtA[i] = 0xa
return len(dAtA) - i, nil
}
@ -1905,8 +1971,10 @@ func (m *QueryProposalResponse) Size() (n int) {
}
var l int
_ = l
l = m.Proposal.Size()
n += 1 + l + sovQuery(uint64(l))
if m.Proposal != nil {
l = m.Proposal.Size()
n += 1 + l + sovQuery(uint64(l))
}
return n
}
@ -1975,8 +2043,10 @@ func (m *QueryVoteResponse) Size() (n int) {
}
var l int
_ = l
l = m.Vote.Size()
n += 1 + l + sovQuery(uint64(l))
if m.Vote != nil {
l = m.Vote.Size()
n += 1 + l + sovQuery(uint64(l))
}
return n
}
@ -2034,12 +2104,18 @@ func (m *QueryParamsResponse) Size() (n int) {
}
var l int
_ = l
l = m.VotingParams.Size()
n += 1 + l + sovQuery(uint64(l))
l = m.DepositParams.Size()
n += 1 + l + sovQuery(uint64(l))
l = m.TallyParams.Size()
n += 1 + l + sovQuery(uint64(l))
if m.VotingParams != nil {
l = m.VotingParams.Size()
n += 1 + l + sovQuery(uint64(l))
}
if m.DepositParams != nil {
l = m.DepositParams.Size()
n += 1 + l + sovQuery(uint64(l))
}
if m.TallyParams != nil {
l = m.TallyParams.Size()
n += 1 + l + sovQuery(uint64(l))
}
return n
}
@ -2065,8 +2141,10 @@ func (m *QueryDepositResponse) Size() (n int) {
}
var l int
_ = l
l = m.Deposit.Size()
n += 1 + l + sovQuery(uint64(l))
if m.Deposit != nil {
l = m.Deposit.Size()
n += 1 + l + sovQuery(uint64(l))
}
return n
}
@ -2123,8 +2201,10 @@ func (m *QueryTallyResultResponse) Size() (n int) {
}
var l int
_ = l
l = m.Tally.Size()
n += 1 + l + sovQuery(uint64(l))
if m.Tally != nil {
l = m.Tally.Size()
n += 1 + l + sovQuery(uint64(l))
}
return n
}
@ -2261,6 +2341,9 @@ func (m *QueryProposalResponse) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Proposal == nil {
m.Proposal = &Proposal{}
}
if err := m.Proposal.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -2513,7 +2596,7 @@ func (m *QueryProposalsResponse) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Proposals = append(m.Proposals, Proposal{})
m.Proposals = append(m.Proposals, &Proposal{})
if err := m.Proposals[len(m.Proposals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -2734,6 +2817,9 @@ func (m *QueryVoteResponse) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Vote == nil {
m.Vote = &Vote{}
}
if err := m.Vote.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -2922,7 +3008,7 @@ func (m *QueryVotesResponse) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Votes = append(m.Votes, Vote{})
m.Votes = append(m.Votes, &Vote{})
if err := m.Votes[len(m.Votes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -3124,6 +3210,9 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.VotingParams == nil {
m.VotingParams = &VotingParams{}
}
if err := m.VotingParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -3157,6 +3246,9 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.DepositParams == nil {
m.DepositParams = &DepositParams{}
}
if err := m.DepositParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -3190,6 +3282,9 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.TallyParams == nil {
m.TallyParams = &TallyParams{}
}
if err := m.TallyParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -3374,6 +3469,9 @@ func (m *QueryDepositResponse) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Deposit == nil {
m.Deposit = &Deposit{}
}
if err := m.Deposit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -3562,7 +3660,7 @@ func (m *QueryDepositsResponse) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Deposits = append(m.Deposits, Deposit{})
m.Deposits = append(m.Deposits, &Deposit{})
if err := m.Deposits[len(m.Deposits)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -3751,6 +3849,9 @@ func (m *QueryTallyResultResponse) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Tally == nil {
m.Tally = &TallyResult{}
}
if err := m.Tally.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}

View File

@ -1,8 +1,6 @@
package types
import (
"sigs.k8s.io/yaml"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -29,17 +27,17 @@ func NewValidatorGovInfo(address sdk.ValAddress, bondedTokens sdk.Int, delegator
}
// NewTallyResult creates a new TallyResult instance
func NewTallyResult(yes, abstain, no, noWithVeto sdk.Int) TallyResult {
return TallyResult{
Yes: yes,
Abstain: abstain,
No: no,
NoWithVeto: noWithVeto,
func NewTallyResult(yes, abstain, no, noWithVeto sdk.Int) *TallyResult {
return &TallyResult{
Yes: yes.String(),
Abstain: abstain.String(),
No: no.String(),
NoWithVeto: noWithVeto.String(),
}
}
// NewTallyResultFromMap creates a new TallyResult instance from a Option -> Dec map
func NewTallyResultFromMap(results map[VoteOption]sdk.Dec) TallyResult {
func NewTallyResultFromMap(results map[VoteOption]sdk.Dec) *TallyResult {
return NewTallyResult(
results[OptionYes].TruncateInt(),
results[OptionAbstain].TruncateInt(),
@ -49,20 +47,14 @@ func NewTallyResultFromMap(results map[VoteOption]sdk.Dec) TallyResult {
}
// EmptyTallyResult returns an empty TallyResult.
func EmptyTallyResult() TallyResult {
func EmptyTallyResult() *TallyResult {
return NewTallyResult(sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt())
}
// Equals returns if two proposals are equal.
// Equals returns if two tally results are equal.
func (tr TallyResult) Equals(comp TallyResult) bool {
return tr.Yes.Equal(comp.Yes) &&
tr.Abstain.Equal(comp.Abstain) &&
tr.No.Equal(comp.No) &&
tr.NoWithVeto.Equal(comp.NoWithVeto)
}
// String implements stringer interface
func (tr TallyResult) String() string {
out, _ := yaml.Marshal(tr)
return string(out)
return tr.Yes == comp.Yes &&
tr.Abstain == comp.Abstain &&
tr.No == comp.No &&
tr.NoWithVeto == comp.NoWithVeto
}

View File

@ -8,7 +8,6 @@ import (
fmt "fmt"
_ "github.com/cosmos/cosmos-proto"
types "github.com/cosmos/cosmos-sdk/codec/types"
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
types1 "github.com/cosmos/cosmos-sdk/types"
_ "github.com/gogo/protobuf/gogoproto"
grpc1 "github.com/gogo/protobuf/grpc"
@ -35,13 +34,14 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary
// proposal Content.
type MsgSubmitProposal struct {
Messages []*types.Any `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
InitialDeposit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=initial_deposit,json=initialDeposit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"initial_deposit"`
Proposer string `protobuf:"bytes,3,opt,name=proposer,proto3" json:"proposer,omitempty"`
Messages []*types.Any `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
InitialDeposit []types1.Coin `protobuf:"bytes,2,rep,name=initial_deposit,json=initialDeposit,proto3" json:"initial_deposit"`
Proposer string `protobuf:"bytes,3,opt,name=proposer,proto3" json:"proposer,omitempty"`
}
func (m *MsgSubmitProposal) Reset() { *m = MsgSubmitProposal{} }
func (*MsgSubmitProposal) ProtoMessage() {}
func (m *MsgSubmitProposal) Reset() { *m = MsgSubmitProposal{} }
func (m *MsgSubmitProposal) String() string { return proto.CompactTextString(m) }
func (*MsgSubmitProposal) ProtoMessage() {}
func (*MsgSubmitProposal) Descriptor() ([]byte, []int) {
return fileDescriptor_4214261f6b3f9ed4, []int{0}
}
@ -72,9 +72,30 @@ func (m *MsgSubmitProposal) XXX_DiscardUnknown() {
var xxx_messageInfo_MsgSubmitProposal proto.InternalMessageInfo
func (m *MsgSubmitProposal) GetMessages() []*types.Any {
if m != nil {
return m.Messages
}
return nil
}
func (m *MsgSubmitProposal) GetInitialDeposit() []types1.Coin {
if m != nil {
return m.InitialDeposit
}
return nil
}
func (m *MsgSubmitProposal) GetProposer() string {
if m != nil {
return m.Proposer
}
return ""
}
// MsgSubmitProposalResponse defines the Msg/SubmitProposal response type.
type MsgSubmitProposalResponse struct {
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id"`
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
}
func (m *MsgSubmitProposalResponse) Reset() { *m = MsgSubmitProposalResponse{} }
@ -119,13 +140,14 @@ func (m *MsgSubmitProposalResponse) GetProposalId() uint64 {
// MsgVote defines a message to cast a vote.
type MsgVote struct {
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id" yaml:"proposal_id"`
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1beta2.VoteOption" json:"option,omitempty"`
}
func (m *MsgVote) Reset() { *m = MsgVote{} }
func (*MsgVote) ProtoMessage() {}
func (m *MsgVote) Reset() { *m = MsgVote{} }
func (m *MsgVote) String() string { return proto.CompactTextString(m) }
func (*MsgVote) ProtoMessage() {}
func (*MsgVote) Descriptor() ([]byte, []int) {
return fileDescriptor_4214261f6b3f9ed4, []int{2}
}
@ -156,6 +178,27 @@ func (m *MsgVote) XXX_DiscardUnknown() {
var xxx_messageInfo_MsgVote proto.InternalMessageInfo
func (m *MsgVote) GetProposalId() uint64 {
if m != nil {
return m.ProposalId
}
return 0
}
func (m *MsgVote) GetVoter() string {
if m != nil {
return m.Voter
}
return ""
}
func (m *MsgVote) GetOption() VoteOption {
if m != nil {
return m.Option
}
return VoteOption_VOTE_OPTION_UNSPECIFIED
}
// MsgVoteResponse defines the Msg/Vote response type.
type MsgVoteResponse struct {
}
@ -197,13 +240,14 @@ var xxx_messageInfo_MsgVoteResponse proto.InternalMessageInfo
//
// Since: cosmos-sdk 0.43
type MsgVoteWeighted struct {
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"`
Options []WeightedVoteOption `protobuf:"bytes,3,rep,name=options,proto3" json:"options"`
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
Options []*WeightedVoteOption `protobuf:"bytes,3,rep,name=options,proto3" json:"options,omitempty"`
}
func (m *MsgVoteWeighted) Reset() { *m = MsgVoteWeighted{} }
func (*MsgVoteWeighted) ProtoMessage() {}
func (m *MsgVoteWeighted) Reset() { *m = MsgVoteWeighted{} }
func (m *MsgVoteWeighted) String() string { return proto.CompactTextString(m) }
func (*MsgVoteWeighted) ProtoMessage() {}
func (*MsgVoteWeighted) Descriptor() ([]byte, []int) {
return fileDescriptor_4214261f6b3f9ed4, []int{4}
}
@ -234,6 +278,27 @@ func (m *MsgVoteWeighted) XXX_DiscardUnknown() {
var xxx_messageInfo_MsgVoteWeighted proto.InternalMessageInfo
func (m *MsgVoteWeighted) GetProposalId() uint64 {
if m != nil {
return m.ProposalId
}
return 0
}
func (m *MsgVoteWeighted) GetVoter() string {
if m != nil {
return m.Voter
}
return ""
}
func (m *MsgVoteWeighted) GetOptions() []*WeightedVoteOption {
if m != nil {
return m.Options
}
return nil
}
// MsgVoteWeightedResponse defines the Msg/VoteWeighted response type.
//
// Since: cosmos-sdk 0.43
@ -275,13 +340,14 @@ var xxx_messageInfo_MsgVoteWeightedResponse proto.InternalMessageInfo
// MsgDeposit defines a message to submit a deposit to an existing proposal.
type MsgDeposit struct {
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id"`
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"`
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
Amount []types1.Coin `protobuf:"bytes,3,rep,name=amount,proto3" json:"amount"`
}
func (m *MsgDeposit) Reset() { *m = MsgDeposit{} }
func (*MsgDeposit) ProtoMessage() {}
func (m *MsgDeposit) Reset() { *m = MsgDeposit{} }
func (m *MsgDeposit) String() string { return proto.CompactTextString(m) }
func (*MsgDeposit) ProtoMessage() {}
func (*MsgDeposit) Descriptor() ([]byte, []int) {
return fileDescriptor_4214261f6b3f9ed4, []int{6}
}
@ -312,6 +378,27 @@ func (m *MsgDeposit) XXX_DiscardUnknown() {
var xxx_messageInfo_MsgDeposit proto.InternalMessageInfo
func (m *MsgDeposit) GetProposalId() uint64 {
if m != nil {
return m.ProposalId
}
return 0
}
func (m *MsgDeposit) GetDepositor() string {
if m != nil {
return m.Depositor
}
return ""
}
func (m *MsgDeposit) GetAmount() []types1.Coin {
if m != nil {
return m.Amount
}
return nil
}
// MsgDepositResponse defines the Msg/Deposit response type.
type MsgDepositResponse struct {
}
@ -363,49 +450,44 @@ func init() {
func init() { proto.RegisterFile("cosmos/gov/v1beta2/tx.proto", fileDescriptor_4214261f6b3f9ed4) }
var fileDescriptor_4214261f6b3f9ed4 = []byte{
// 667 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcf, 0x4f, 0x13, 0x4f,
0x14, 0xdf, 0x6d, 0xf9, 0xf2, 0xe3, 0xf1, 0x0d, 0xc8, 0xa4, 0xd1, 0x6d, 0x31, 0xbb, 0x4d, 0x0d,
0xa4, 0x89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xff, 0x7f, 0x9b, 0xd6, 0x61, 0xa2,
0x84, 0x54, 0xba, 0x7e, 0x01, 0x52, 0x7a, 0xc3, 0x43, 0x18, 0x4b, 0xa6, 0xc3, 0x3c, 0x43, 0xa7,
0xf0, 0xd2, 0xfc, 0x70, 0x3c, 0x49, 0x59, 0xaf, 0xef, 0x1e, 0x98, 0xfa, 0xde, 0x81, 0xa9, 0x7f,
0x39, 0x30, 0xf5, 0x57, 0x87, 0xa6, 0xb6, 0x77, 0x68, 0x6a, 0x1f, 0x0f, 0x4d, 0xed, 0xc9, 0xf0,
0x27, 0xde, 0x96, 0x3f, 0x1c, 0xf2, 0xa1, 0x9b, 0xa3, 0xf2, 0x83, 0x7d, 0xe3, 0x57, 0x00, 0x00,
0x00, 0xff, 0xff, 0x5d, 0x24, 0xb4, 0x1c, 0xa4, 0x06, 0x00, 0x00,
// 585 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x4c,
0x14, 0x8d, 0x9b, 0x7e, 0xfd, 0xb9, 0xfd, 0x94, 0xaa, 0x56, 0x24, 0x1c, 0x17, 0xb9, 0x91, 0x11,
0x55, 0x24, 0x94, 0x31, 0x09, 0xa8, 0x6c, 0x58, 0xd0, 0xc0, 0xa2, 0x2c, 0x22, 0xc0, 0x95, 0x40,
0x62, 0x13, 0xec, 0x78, 0x3a, 0x1d, 0x91, 0xf8, 0x5a, 0x9e, 0x49, 0xd4, 0xbc, 0x05, 0xe2, 0x01,
0x58, 0xf1, 0x08, 0xbc, 0x02, 0x52, 0x97, 0x15, 0x2b, 0x56, 0x08, 0x25, 0x5b, 0x1e, 0x02, 0xc5,
0x1e, 0xbb, 0xd0, 0xa4, 0x49, 0x17, 0xac, 0xe2, 0xdc, 0x73, 0xce, 0xbd, 0xe7, 0x7a, 0x8e, 0x07,
0x76, 0xbb, 0x28, 0xfa, 0x28, 0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5, 0x1b, 0xd1, 0xf2, 0xc4, 0x1e, 0xc1, 0x6a, 0x12, 0xc6, 0xdd, 0x6b,
0x64, 0x53, 0xd0, 0xbc, 0xb3, 0x00, 0xcc, 0x3b, 0xbd, 0x83, 0xff, 0xff, 0x8a, 0xcb, 0x22, 0x51,
0x46, 0x32, 0xef, 0xdd, 0x80, 0x94, 0x4f, 0x78, 0x05, 0xeb, 0xd9, 0x71, 0x5a, 0xd7, 0xe8, 0x14,
0x6e, 0xee, 0x2f, 0xc6, 0xb3, 0x96, 0xad, 0xd6, 0xf9, 0xd8, 0xd2, 0x2e, 0xc6, 0x96, 0xf6, 0x73,
0x6c, 0x69, 0x1f, 0x26, 0x56, 0xe1, 0x62, 0x62, 0x15, 0xbe, 0x4f, 0xac, 0xc2, 0xdb, 0x1a, 0xe3,
0xf2, 0x74, 0xe0, 0x93, 0x2e, 0xf6, 0xd5, 0x1d, 0xa7, 0x7e, 0xea, 0x22, 0x78, 0xef, 0x9c, 0x25,
0x37, 0xa6, 0x1c, 0x45, 0x54, 0xf8, 0x6b, 0xc9, 0x4d, 0xf5, 0xe0, 0x77, 0x00, 0x00, 0x00, 0xff,
0xff, 0xe7, 0x3b, 0xf1, 0xb1, 0x9d, 0x05, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -1543,7 +1625,7 @@ func (m *MsgVoteWeighted) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Options = append(m.Options, WeightedVoteOption{})
m.Options = append(m.Options, &WeightedVoteOption{})
if err := m.Options[len(m.Options)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}

View File

@ -1,684 +0,0 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: cosmos/gov/v1beta2/genesis.proto
package v1beta2
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// GenesisState defines the gov module's genesis state.
type GenesisState struct {
// starting_proposal_id is the ID of the starting proposal.
StartingProposalId uint64 `protobuf:"varint,1,opt,name=starting_proposal_id,json=startingProposalId,proto3" json:"starting_proposal_id,omitempty"`
// deposits defines all the deposits present at genesis.
Deposits []*Deposit `protobuf:"bytes,2,rep,name=deposits,proto3" json:"deposits,omitempty"`
// votes defines all the votes present at genesis.
Votes []*Vote `protobuf:"bytes,3,rep,name=votes,proto3" json:"votes,omitempty"`
// proposals defines all the proposals present at genesis.
Proposals []*Proposal `protobuf:"bytes,4,rep,name=proposals,proto3" json:"proposals,omitempty"`
// params defines all the paramaters of related to deposit.
DepositParams *DepositParams `protobuf:"bytes,5,opt,name=deposit_params,json=depositParams,proto3" json:"deposit_params,omitempty"`
// params defines all the paramaters of related to voting.
VotingParams *VotingParams `protobuf:"bytes,6,opt,name=voting_params,json=votingParams,proto3" json:"voting_params,omitempty"`
// params defines all the paramaters of related to tally.
TallyParams *TallyParams `protobuf:"bytes,7,opt,name=tally_params,json=tallyParams,proto3" json:"tally_params,omitempty"`
}
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_7915ab39bb5aa171, []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 (m *GenesisState) GetStartingProposalId() uint64 {
if m != nil {
return m.StartingProposalId
}
return 0
}
func (m *GenesisState) GetDeposits() []*Deposit {
if m != nil {
return m.Deposits
}
return nil
}
func (m *GenesisState) GetVotes() []*Vote {
if m != nil {
return m.Votes
}
return nil
}
func (m *GenesisState) GetProposals() []*Proposal {
if m != nil {
return m.Proposals
}
return nil
}
func (m *GenesisState) GetDepositParams() *DepositParams {
if m != nil {
return m.DepositParams
}
return nil
}
func (m *GenesisState) GetVotingParams() *VotingParams {
if m != nil {
return m.VotingParams
}
return nil
}
func (m *GenesisState) GetTallyParams() *TallyParams {
if m != nil {
return m.TallyParams
}
return nil
}
func init() {
proto.RegisterType((*GenesisState)(nil), "cosmos.gov.v1beta2.GenesisState")
}
func init() { proto.RegisterFile("cosmos/gov/v1beta2/genesis.proto", fileDescriptor_7915ab39bb5aa171) }
var fileDescriptor_7915ab39bb5aa171 = []byte{
// 345 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xbb, 0x4e, 0xc3, 0x30,
0x14, 0x86, 0x1b, 0x7a, 0x01, 0xdc, 0x96, 0xc1, 0x62, 0x88, 0xa0, 0x0a, 0x81, 0xa9, 0x0b, 0x4e,
0x29, 0x03, 0x12, 0x63, 0x05, 0xe2, 0x32, 0x55, 0x01, 0x31, 0xb0, 0x54, 0x6e, 0x63, 0x85, 0x88,
0xb6, 0x27, 0x8a, 0x0f, 0x16, 0x7d, 0x0b, 0x9e, 0x87, 0x27, 0x60, 0xec, 0xc8, 0x88, 0x9a, 0x17,
0x41, 0xb5, 0x13, 0x5a, 0x89, 0xc0, 0x14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
0xd1, 0x1e, 0x69, 0x20, 0x1f, 0x8f, 0x67, 0xb9, 0x65, 0x53, 0x5b, 0x0e, 0x8a, 0x2c, 0xf7, 0x4b,
0x2e, 0x93, 0xd4, 0x71, 0x35, 0xf4, 0x6e, 0x3f, 0x16, 0x8e, 0x35, 0x5f, 0x38, 0xd6, 0xd7, 0xc2,
0xb1, 0xde, 0x52, 0xa7, 0x34, 0x4f, 0x9d, 0xd2, 0x67, 0xea, 0x94, 0x1e, 0x3b, 0x61, 0x84, 0x4f,
0x2f, 0x43, 0x36, 0x82, 0x89, 0x97, 0xbd, 0xbf, 0xf9, 0x1c, 0xcb, 0xe0, 0xd9, 0x7b, 0xd5, 0xcb,
0x80, 0xb3, 0x58, 0xc8, 0x7c, 0x25, 0x86, 0x35, 0xbd, 0x0f, 0xa7, 0xdf, 0x01, 0x00, 0x00, 0xff,
0xff, 0xb6, 0x88, 0x7e, 0xc1, 0x65, 0x02, 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
if m.TallyParams != nil {
{
size, err := m.TallyParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x3a
}
if m.VotingParams != nil {
{
size, err := m.VotingParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x32
}
if m.DepositParams != nil {
{
size, err := m.DepositParams.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x2a
}
if len(m.Proposals) > 0 {
for iNdEx := len(m.Proposals) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Proposals[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x22
}
}
if len(m.Votes) > 0 {
for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Votes[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x1a
}
}
if len(m.Deposits) > 0 {
for iNdEx := len(m.Deposits) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Deposits[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
}
}
if m.StartingProposalId != 0 {
i = encodeVarintGenesis(dAtA, i, uint64(m.StartingProposalId))
i--
dAtA[i] = 0x8
}
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
if m.StartingProposalId != 0 {
n += 1 + sovGenesis(uint64(m.StartingProposalId))
}
if len(m.Deposits) > 0 {
for _, e := range m.Deposits {
l = e.Size()
n += 1 + l + sovGenesis(uint64(l))
}
}
if len(m.Votes) > 0 {
for _, e := range m.Votes {
l = e.Size()
n += 1 + l + sovGenesis(uint64(l))
}
}
if len(m.Proposals) > 0 {
for _, e := range m.Proposals {
l = e.Size()
n += 1 + l + sovGenesis(uint64(l))
}
}
if m.DepositParams != nil {
l = m.DepositParams.Size()
n += 1 + l + sovGenesis(uint64(l))
}
if m.VotingParams != nil {
l = m.VotingParams.Size()
n += 1 + l + sovGenesis(uint64(l))
}
if m.TallyParams != nil {
l = m.TallyParams.Size()
n += 1 + l + sovGenesis(uint64(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 {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field StartingProposalId", wireType)
}
m.StartingProposalId = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.StartingProposalId |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Deposits", 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
}
m.Deposits = append(m.Deposits, &Deposit{})
if err := m.Deposits[len(m.Deposits)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Votes", 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
}
m.Votes = append(m.Votes, &Vote{})
if err := m.Votes[len(m.Votes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Proposals", 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
}
m.Proposals = append(m.Proposals, &Proposal{})
if err := m.Proposals[len(m.Proposals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field DepositParams", 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 m.DepositParams == nil {
m.DepositParams = &DepositParams{}
}
if err := m.DepositParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 6:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field VotingParams", 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 m.VotingParams == nil {
m.VotingParams = &VotingParams{}
}
if err := m.VotingParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 7:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field TallyParams", 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 m.TallyParams == nil {
m.TallyParams = &TallyParams{}
}
if err := m.TallyParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
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")
)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,932 +0,0 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: cosmos/gov/v1beta2/query.proto
/*
Package v1beta2 is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package v1beta2
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/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
func request_Query_Proposal_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryProposalRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["proposal_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "proposal_id")
}
protoReq.ProposalId, err = runtime.Uint64(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "proposal_id", err)
}
msg, err := client.Proposal(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_Proposal_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryProposalRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["proposal_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "proposal_id")
}
protoReq.ProposalId, err = runtime.Uint64(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "proposal_id", err)
}
msg, err := server.Proposal(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_Query_Proposals_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_Query_Proposals_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryProposalsRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Proposals_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.Proposals(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_Proposals_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryProposalsRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Proposals_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Proposals(ctx, &protoReq)
return msg, metadata, err
}
func request_Query_Vote_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryVoteRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["proposal_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "proposal_id")
}
protoReq.ProposalId, err = runtime.Uint64(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "proposal_id", err)
}
val, ok = pathParams["voter"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "voter")
}
protoReq.Voter, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "voter", err)
}
msg, err := client.Vote(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_Vote_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryVoteRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["proposal_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "proposal_id")
}
protoReq.ProposalId, err = runtime.Uint64(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "proposal_id", err)
}
val, ok = pathParams["voter"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "voter")
}
protoReq.Voter, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "voter", err)
}
msg, err := server.Vote(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_Query_Votes_0 = &utilities.DoubleArray{Encoding: map[string]int{"proposal_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
)
func request_Query_Votes_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryVotesRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["proposal_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "proposal_id")
}
protoReq.ProposalId, err = runtime.Uint64(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "proposal_id", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Votes_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.Votes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_Votes_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryVotesRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["proposal_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "proposal_id")
}
protoReq.ProposalId, err = runtime.Uint64(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "proposal_id", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Votes_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Votes(ctx, &protoReq)
return msg, metadata, err
}
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
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["params_type"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "params_type")
}
protoReq.ParamsType, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "params_type", err)
}
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
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["params_type"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "params_type")
}
protoReq.ParamsType, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "params_type", err)
}
msg, err := server.Params(ctx, &protoReq)
return msg, metadata, err
}
func request_Query_Deposit_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryDepositRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["proposal_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "proposal_id")
}
protoReq.ProposalId, err = runtime.Uint64(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "proposal_id", err)
}
val, ok = pathParams["depositor"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "depositor")
}
protoReq.Depositor, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "depositor", err)
}
msg, err := client.Deposit(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_Deposit_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryDepositRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["proposal_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "proposal_id")
}
protoReq.ProposalId, err = runtime.Uint64(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "proposal_id", err)
}
val, ok = pathParams["depositor"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "depositor")
}
protoReq.Depositor, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "depositor", err)
}
msg, err := server.Deposit(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_Query_Deposits_0 = &utilities.DoubleArray{Encoding: map[string]int{"proposal_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
)
func request_Query_Deposits_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryDepositsRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["proposal_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "proposal_id")
}
protoReq.ProposalId, err = runtime.Uint64(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "proposal_id", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Deposits_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.Deposits(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_Deposits_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryDepositsRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["proposal_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "proposal_id")
}
protoReq.ProposalId, err = runtime.Uint64(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "proposal_id", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Deposits_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Deposits(ctx, &protoReq)
return msg, metadata, err
}
func request_Query_TallyResult_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryTallyResultRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["proposal_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "proposal_id")
}
protoReq.ProposalId, err = runtime.Uint64(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "proposal_id", err)
}
msg, err := client.TallyResult(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_TallyResult_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryTallyResultRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["proposal_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "proposal_id")
}
protoReq.ProposalId, err = runtime.Uint64(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "proposal_id", err)
}
msg, err := server.TallyResult(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 (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
mux.Handle("GET", pattern_Query_Proposal_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.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_Proposal_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Proposal_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_Proposals_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.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_Proposals_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Proposals_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_Vote_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.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_Vote_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Vote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_Votes_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.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_Votes_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Votes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
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.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)
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()...)
})
mux.Handle("GET", pattern_Query_Deposit_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.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_Deposit_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Deposit_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_Deposits_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.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_Deposits_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Deposits_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_TallyResult_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.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_TallyResult_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_TallyResult_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_Proposal_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_Proposal_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_Proposal_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_Proposals_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_Proposals_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_Proposals_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_Vote_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_Vote_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_Vote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_Votes_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_Votes_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_Votes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
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()...)
})
mux.Handle("GET", pattern_Query_Deposit_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_Deposit_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_Deposit_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_Deposits_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_Deposits_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_Deposits_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_TallyResult_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_TallyResult_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_TallyResult_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Query_Proposal_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "gov", "v1beta2", "proposals", "proposal_id"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_Proposals_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "gov", "v1beta2", "proposals"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_Vote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"cosmos", "gov", "v1beta2", "proposals", "proposal_id", "votes", "voter"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_Votes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"cosmos", "gov", "v1beta2", "proposals", "proposal_id", "votes"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "gov", "v1beta2", "params", "params_type"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_Deposit_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"cosmos", "gov", "v1beta2", "proposals", "proposal_id", "deposits", "depositor"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_Deposits_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"cosmos", "gov", "v1beta2", "proposals", "proposal_id", "deposits"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_TallyResult_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"cosmos", "gov", "v1beta2", "proposals", "proposal_id", "tally"}, "", runtime.AssumeColonVerbOpt(false)))
)
var (
forward_Query_Proposal_0 = runtime.ForwardResponseMessage
forward_Query_Proposals_0 = runtime.ForwardResponseMessage
forward_Query_Vote_0 = runtime.ForwardResponseMessage
forward_Query_Votes_0 = runtime.ForwardResponseMessage
forward_Query_Params_0 = runtime.ForwardResponseMessage
forward_Query_Deposit_0 = runtime.ForwardResponseMessage
forward_Query_Deposits_0 = runtime.ForwardResponseMessage
forward_Query_TallyResult_0 = runtime.ForwardResponseMessage
)

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +1,33 @@
package types
import (
"encoding/json"
"fmt"
"strings"
"sigs.k8s.io/yaml"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
OptionEmpty = VoteOption_VOTE_OPTION_UNSPECIFIED
OptionYes = VoteOption_VOTE_OPTION_YES
OptionNo = VoteOption_VOTE_OPTION_NO
OptionNoWithVeto = VoteOption_VOTE_OPTION_NO_WITH_VETO
OptionAbstain = VoteOption_VOTE_OPTION_ABSTAIN
)
// NewVote creates a new Vote instance
//nolint:interfacer
func NewVote(proposalID uint64, voter sdk.AccAddress, options WeightedVoteOptions) Vote {
return Vote{ProposalId: proposalID, Voter: voter.String(), Options: options}
}
// String returns a string representation of Vote
func (v Vote) String() string {
out, _ := yaml.Marshal(v)
return string(out)
}
// Empty returns whether a vote is empty.
func (v Vote) Empty() bool {
return v.String() == Vote{}.String()
return v.ProposalId == 0 || v.Voter == "" || len(v.Options) == 0
}
// Votes is a collection of Vote objects
type Votes []Vote
type Votes []*Vote
// Equal returns true if two slices (order-dependant) of votes are equal.
func (v Votes) Equal(other Votes) bool {
@ -56,18 +55,31 @@ func (v Votes) String() string {
return out
}
// NewNonSplitVoteOption creates a single option vote with weight 1
func NewNonSplitVoteOption(option VoteOption) WeightedVoteOptions {
return WeightedVoteOptions{{option, sdk.NewDec(1)}}
func NewWeightedVoteOption(option VoteOption, weight sdk.Dec) *WeightedVoteOption {
return &WeightedVoteOption{Option: option, Weight: weight.String()}
}
func (v WeightedVoteOption) String() string {
out, _ := json.Marshal(v)
return string(out)
// IsValid returns true if the sub vote is valid and false otherwise.
func (w *WeightedVoteOption) IsValid() bool {
weight, err := sdk.NewDecFromStr(w.Weight)
if err != nil {
return false
}
if !weight.IsPositive() || weight.GT(sdk.NewDec(1)) {
return false
}
return ValidVoteOption(w.Option)
}
// NewNonSplitVoteOption creates a single option vote with weight 1
func NewNonSplitVoteOption(option VoteOption) WeightedVoteOptions {
return WeightedVoteOptions{{option, sdk.NewDec(1).String()}}
}
// WeightedVoteOptions describes array of WeightedVoteOptions
type WeightedVoteOptions []WeightedVoteOption
type WeightedVoteOptions []*WeightedVoteOption
func (v WeightedVoteOptions) String() (out string) {
for _, opt := range v {
@ -77,14 +89,6 @@ func (v WeightedVoteOptions) String() (out string) {
return strings.TrimSpace(out)
}
// ValidWeightedVoteOption returns true if the sub vote is valid and false otherwise.
func ValidWeightedVoteOption(option WeightedVoteOption) bool {
if !option.Weight.IsPositive() || option.Weight.GT(sdk.NewDec(1)) {
return false
}
return ValidVoteOption(option.Option)
}
// VoteOptionFromString returns a VoteOption from a string. It returns an error
// if the string is invalid.
func VoteOptionFromString(str string) (VoteOption, error) {
@ -112,7 +116,7 @@ func WeightedVoteOptionsFromString(str string) (WeightedVoteOptions, error) {
if err != nil {
return options, err
}
options = append(options, WeightedVoteOption{option, weight})
options = append(options, NewWeightedVoteOption(option, weight))
}
return options, nil
}