refactor: move legacy gov to v1beta1 (#10748)

Ref: #9810

Moves all legacy gov code to `v1beta1`. This preserves all existing behavior (i.e. everything still uses v1beta1). It's merely moving things around to get everything in the right place logistically (hence the large diff still)

---

### 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-13 19:48:44 +01:00 committed by GitHub
parent 4c31b3a735
commit c7e2305286
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
96 changed files with 13002 additions and 1717 deletions

View File

@ -58,14 +58,6 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#10507](https://github.com/cosmos/cosmos-sdk/pull/10507) Add middleware for tx priority.
* [\#10311](https://github.com/cosmos/cosmos-sdk/pull/10311) Adds cli to use tips transactions. It adds an `--aux` flag to all CLI tx commands to generate the aux signer data (with optional tip), and a new `tx aux-to-fee` subcommand to let the fee payer gather aux signer data and broadcast the tx
### Improvements
* (deps) [\#10210](https://github.com/cosmos/cosmos-sdk/pull/10210) Bump Tendermint to [v0.35.0](https://github.com/tendermint/tendermint/releases/tag/v0.35.0).
* [\#10486](https://github.com/cosmos/cosmos-sdk/pull/10486) store/cachekv's `Store.Write` conservatively looks up keys, but also uses the [map clearing idiom](https://bencher.orijtech.com/perfclinic/mapclearing/) to reduce the RAM usage, CPU time usage, and garbage collection pressure from clearing maps, instead of allocating new maps.
* (types) [\#10630](https://github.com/cosmos/cosmos-sdk/pull/10630) Add an `Events` field to the `TxResponse` type that captures _all_ events emitted by a transaction, unlike `Logs` which only contains events emitted during message execution.
* (deps) [\#10706](https://github.com/cosmos/cosmos-sdk/issues/10706) Bump rosetta-sdk-go to v0.7.2 and rosetta-cli to v0.7.3
* (module) [\#10711](https://github.com/cosmos/cosmos-sdk/pull/10711) Panic at startup if the app developer forgot to add modules in the `SetOrder{BeginBlocker, EndBlocker, InitGenesis, ExportGenesis}` functions. This means that all modules, even those who have empty implementations for those methods, need to be added to `SetOrder*`.
### API Breaking Changes
* (x/mint) [\#10441](https://github.com/cosmos/cosmos-sdk/pull/10441) The `NewAppModule` function now accepts an inflation calculation function as an argument.
@ -119,6 +111,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#10208](https://github.com/cosmos/cosmos-sdk/pull/10208) The `x/auth/signing.Tx` interface now also includes a new `GetTip() *tx.Tip` method for verifying tipped transactions. The `x/auth/types` expected BankKeeper interface now expects the `SendCoins` method too.
* [\#10612](https://github.com/cosmos/cosmos-sdk/pull/10612) `baseapp.NewBaseApp` constructor function doesn't take the `sdk.TxDecoder` anymore. This logic has been moved into the TxDecoderMiddleware.
* [\#10692](https://github.com/cosmos/cosmos-sdk/pull/10612) `SignerData` takes 2 new fields, `Address` and `PubKey`, which need to get populated when using SIGN_MODE_DIRECT_AUX.
* [\#10748](https://github.com/cosmos/cosmos-sdk/pull/10748) Move legacy `x/gov` api to `v1beta1` directory.
### Client Breaking Changes
@ -151,6 +144,11 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (cli) [\#10683](https://github.com/cosmos/cosmos-sdk/pull/10683) In CLI, allow 1 SIGN_MODE_DIRECT signer in transactions with multiple signers.
* (x/gov) [\#10740](https://github.com/cosmos/cosmos-sdk/pull/10740) Increase maximum proposal description size from 5k characters to 10k characters.
* (store) [\#10741](https://github.com/cosmos/cosmos-sdk/pull/10741) Significantly speedup iterator creation after delete heavy workloads. Significantly improves IBC migration times.
* (deps) [\#10210](https://github.com/cosmos/cosmos-sdk/pull/10210) Bump Tendermint to [v0.35.0](https://github.com/tendermint/tendermint/releases/tag/v0.35.0).
* [\#10486](https://github.com/cosmos/cosmos-sdk/pull/10486) store/cachekv's `Store.Write` conservatively looks up keys, but also uses the [map clearing idiom](https://bencher.orijtech.com/perfclinic/mapclearing/) to reduce the RAM usage, CPU time usage, and garbage collection pressure from clearing maps, instead of allocating new maps.
* (types) [\#10630](https://github.com/cosmos/cosmos-sdk/pull/10630) Add an `Events` field to the `TxResponse` type that captures _all_ events emitted by a transaction, unlike `Logs` which only contains events emitted during message execution.
* (deps) [\#10706](https://github.com/cosmos/cosmos-sdk/issues/10706) Bump rosetta-sdk-go to v0.7.2 and rosetta-cli to v0.7.3
* (module) [\#10711](https://github.com/cosmos/cosmos-sdk/pull/10711) Panic at startup if the app developer forgot to add modules in the `SetOrder{BeginBlocker, EndBlocker, InitGenesis, ExportGenesis}` functions. This means that all modules, even those who have empty implementations for those methods, need to be added to `SetOrder*`.
### Bug Fixes

View File

@ -5,7 +5,7 @@ package cosmos.gov.v1beta1;
import "gogoproto/gogo.proto";
import "cosmos/gov/v1beta1/gov.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1";
// 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";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.stringer_all) = false;

View File

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

View File

@ -7,7 +7,7 @@ import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1";
// Msg defines the bank Msg service.
service Msg {

View File

@ -66,6 +66,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
oldgovtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/group"
groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper"
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"
@ -295,8 +296,8 @@ func NewSimApp(
app.GroupKeeper = groupkeeper.NewKeeper(keys[group.StoreKey], appCodec, app.msgSvcRouter, app.AccountKeeper)
// register the proposal types
govRouter := govtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
govRouter := oldgovtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, oldgovtypes.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper))
@ -615,7 +616,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable())
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(oldgovtypes.ParamKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName)
return paramsKeeper

View File

@ -35,7 +35,7 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
govtestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
type IntegrationTestSuite struct {

View File

@ -13,7 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
)

View File

@ -19,7 +19,7 @@ import (
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
govtestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
stakingcli "github.com/cosmos/cosmos-sdk/x/staking/client/cli"
)

View File

@ -13,7 +13,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// Transaction flags for the x/distribution module

View File

@ -5,7 +5,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
func NewCommunityPoolSpendProposalHandler(k keeper.Keeper) govtypes.Handler {

View File

@ -6,7 +6,7 @@ import (
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// RegisterLegacyAminoCodec registers the necessary x/distribution interfaces and concrete types

View File

@ -5,7 +5,7 @@ import (
"strings"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
const (

View File

@ -21,7 +21,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/feegrant"
"github.com/cosmos/cosmos-sdk/x/feegrant/client/cli"
govtestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
const (

View File

@ -8,16 +8,17 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// EndBlocker called every block, process inflation, update validator set.
func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)
defer telemetry.ModuleMeasureSince(v1beta1.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)
logger := keeper.Logger(ctx)
// delete dead proposals from store and burn theirs deposits. A proposal is dead when it's inactive and didn't get enough deposit on time to get into voting phase.
keeper.IterateInactiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal types.Proposal) bool {
keeper.IterateInactiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal v1beta1.Proposal) bool {
keeper.DeleteProposal(ctx, proposal.ProposalId)
keeper.DeleteAndBurnDeposits(ctx, proposal.ProposalId)
@ -44,7 +45,7 @@ func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) {
})
// fetch active proposals whose voting periods have ended (are passed the block time)
keeper.IterateActiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal types.Proposal) bool {
keeper.IterateActiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal v1beta1.Proposal) bool {
var tagValue, logMsg string
passes, burnDeposits, tallyResults := keeper.Tally(ctx, proposal)
@ -64,7 +65,7 @@ func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) {
// is written and the error message is logged.
err := handler(cacheCtx, proposal.GetContent())
if err == nil {
proposal.Status = types.StatusPassed
proposal.Status = v1beta1.StatusPassed
tagValue = types.AttributeValueProposalPassed
logMsg = "passed"
@ -77,12 +78,12 @@ func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) {
// write state to the underlying multi-store
writeCache()
} else {
proposal.Status = types.StatusFailed
proposal.Status = v1beta1.StatusFailed
tagValue = types.AttributeValueProposalFailed
logMsg = fmt.Sprintf("passed, but failed on execution: %s", err)
}
} else {
proposal.Status = types.StatusRejected
proposal.Status = v1beta1.StatusRejected
tagValue = types.AttributeValueProposalRejected
logMsg = "rejected"
}

View File

@ -13,6 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
@ -32,8 +33,8 @@ func TestTickExpiredDepositPeriod(t *testing.T) {
require.False(t, inactiveQueue.Valid())
inactiveQueue.Close()
newProposalMsg, err := types.NewMsgSubmitProposal(
types.ContentFromProposalType("test", "test", types.ProposalTypeText),
newProposalMsg, err := v1beta1.NewMsgSubmitProposal(
v1beta1.ContentFromProposalType("test", "test", v1beta1.ProposalTypeText),
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
addrs[0],
)
@ -84,8 +85,8 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) {
require.False(t, inactiveQueue.Valid())
inactiveQueue.Close()
newProposalMsg, err := types.NewMsgSubmitProposal(
types.ContentFromProposalType("test", "test", types.ProposalTypeText),
newProposalMsg, err := v1beta1.NewMsgSubmitProposal(
v1beta1.ContentFromProposalType("test", "test", v1beta1.ProposalTypeText),
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
addrs[0],
)
@ -107,8 +108,8 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) {
require.False(t, inactiveQueue.Valid())
inactiveQueue.Close()
newProposalMsg2, err := types.NewMsgSubmitProposal(
types.ContentFromProposalType("test2", "test2", types.ProposalTypeText),
newProposalMsg2, err := v1beta1.NewMsgSubmitProposal(
v1beta1.ContentFromProposalType("test2", "test2", v1beta1.ProposalTypeText),
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
addrs[0],
)
@ -164,8 +165,8 @@ func TestTickPassedDepositPeriod(t *testing.T) {
require.False(t, activeQueue.Valid())
activeQueue.Close()
newProposalMsg, err := types.NewMsgSubmitProposal(
types.ContentFromProposalType("test2", "test2", types.ProposalTypeText),
newProposalMsg, err := v1beta1.NewMsgSubmitProposal(
v1beta1.ContentFromProposalType("test2", "test2", v1beta1.ProposalTypeText),
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
addrs[0],
)
@ -189,7 +190,7 @@ func TestTickPassedDepositPeriod(t *testing.T) {
require.False(t, inactiveQueue.Valid())
inactiveQueue.Close()
newDepositMsg := types.NewMsgDeposit(addrs[1], proposalID, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)})
newDepositMsg := v1beta1.NewMsgDeposit(addrs[1], proposalID, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)})
res1, err := govMsgSvr.Deposit(sdk.WrapSDKContext(ctx), newDepositMsg)
require.NoError(t, err)
@ -220,7 +221,7 @@ func TestTickPassedVotingPeriod(t *testing.T) {
activeQueue.Close()
proposalCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 5))}
newProposalMsg, err := types.NewMsgSubmitProposal(TestProposal, proposalCoins, addrs[0])
newProposalMsg, err := v1beta1.NewMsgSubmitProposal(TestProposal, proposalCoins, addrs[0])
require.NoError(t, err)
wrapCtx := sdk.WrapSDKContext(ctx)
@ -235,7 +236,7 @@ func TestTickPassedVotingPeriod(t *testing.T) {
newHeader.Time = ctx.BlockHeader().Time.Add(time.Duration(1) * time.Second)
ctx = ctx.WithBlockHeader(newHeader)
newDepositMsg := types.NewMsgDeposit(addrs[1], proposalID, proposalCoins)
newDepositMsg := v1beta1.NewMsgDeposit(addrs[1], proposalID, proposalCoins)
res1, err := govMsgSvr.Deposit(wrapCtx, newDepositMsg)
require.NoError(t, err)
@ -255,7 +256,7 @@ func TestTickPassedVotingPeriod(t *testing.T) {
activeProposalID := types.GetProposalIDFromBytes(activeQueue.Value())
proposal, ok := app.GovKeeper.GetProposal(ctx, activeProposalID)
require.True(t, ok)
require.Equal(t, types.StatusVotingPeriod, proposal.Status)
require.Equal(t, v1beta1.StatusVotingPeriod, proposal.Status)
activeQueue.Close()
@ -292,7 +293,7 @@ func TestProposalPassedEndblocker(t *testing.T) {
require.NoError(t, err)
proposalCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 10))}
newDepositMsg := types.NewMsgDeposit(addrs[0], proposal.ProposalId, proposalCoins)
newDepositMsg := v1beta1.NewMsgDeposit(addrs[0], proposal.ProposalId, proposalCoins)
res, err := govMsgSvr.Deposit(sdk.WrapSDKContext(ctx), newDepositMsg)
require.NoError(t, err)
@ -305,7 +306,7 @@ func TestProposalPassedEndblocker(t *testing.T) {
deposits := initialModuleAccCoins.Add(proposal.TotalDeposit...).Add(proposalCoins...)
require.True(t, moduleAccCoins.IsEqual(deposits))
err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], types.NewNonSplitVoteOption(types.OptionYes))
err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes))
require.NoError(t, err)
newHeader := ctx.BlockHeader()
@ -342,14 +343,14 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) {
require.NoError(t, err)
proposalCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 10)))
newDepositMsg := types.NewMsgDeposit(addrs[0], proposal.ProposalId, proposalCoins)
newDepositMsg := v1beta1.NewMsgDeposit(addrs[0], proposal.ProposalId, proposalCoins)
govMsgSvr := keeper.NewMsgServerImpl(app.GovKeeper)
res, err := govMsgSvr.Deposit(sdk.WrapSDKContext(ctx), newDepositMsg)
require.NoError(t, err)
require.NotNil(t, res)
err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], types.NewNonSplitVoteOption(types.OptionYes))
err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes))
require.NoError(t, err)
newHeader := ctx.BlockHeader()

View File

@ -12,6 +12,7 @@ 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"
)
@ -63,7 +64,7 @@ $ %s query gov proposal 1
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
queryClient := v1beta1.NewQueryClient(clientCtx)
// validate that the proposal id is a uint
proposalID, err := strconv.ParseUint(args[0], 10, 64)
@ -74,7 +75,7 @@ $ %s query gov proposal 1
// Query the proposal
res, err := queryClient.Proposal(
cmd.Context(),
&types.QueryProposalRequest{ProposalId: proposalID},
&v1beta1.QueryProposalRequest{ProposalId: proposalID},
)
if err != nil {
return err
@ -112,7 +113,7 @@ $ %s query gov proposals --page=2 --limit=100
bechVoterAddr, _ := cmd.Flags().GetString(flagVoter)
strProposalStatus, _ := cmd.Flags().GetString(flagStatus)
var proposalStatus types.ProposalStatus
var proposalStatus v1beta1.ProposalStatus
if len(bechDepositorAddr) != 0 {
_, err := sdk.AccAddressFromBech32(bechDepositorAddr)
@ -129,7 +130,7 @@ $ %s query gov proposals --page=2 --limit=100
}
if len(strProposalStatus) != 0 {
proposalStatus1, err := types.ProposalStatusFromString(gcutils.NormalizeProposalStatus(strProposalStatus))
proposalStatus1, err := v1beta1.ProposalStatusFromString(gcutils.NormalizeProposalStatus(strProposalStatus))
proposalStatus = proposalStatus1
if err != nil {
return err
@ -140,7 +141,7 @@ $ %s query gov proposals --page=2 --limit=100
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
queryClient := v1beta1.NewQueryClient(clientCtx)
pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
@ -149,7 +150,7 @@ $ %s query gov proposals --page=2 --limit=100
res, err := queryClient.Proposals(
cmd.Context(),
&types.QueryProposalsRequest{
&v1beta1.QueryProposalsRequest{
ProposalStatus: proposalStatus,
Voter: bechVoterAddr,
Depositor: bechDepositorAddr,
@ -198,7 +199,7 @@ $ %s query gov vote 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
queryClient := v1beta1.NewQueryClient(clientCtx)
// validate that the proposal id is a uint
proposalID, err := strconv.ParseUint(args[0], 10, 64)
@ -210,7 +211,7 @@ $ %s query gov vote 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
ctx := cmd.Context()
_, err = queryClient.Proposal(
ctx,
&types.QueryProposalRequest{ProposalId: proposalID},
&v1beta1.QueryProposalRequest{ProposalId: proposalID},
)
if err != nil {
return fmt.Errorf("failed to fetch proposal-id %d: %s", proposalID, err)
@ -223,7 +224,7 @@ $ %s query gov vote 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
res, err := queryClient.Vote(
ctx,
&types.QueryVoteRequest{ProposalId: proposalID, Voter: args[1]},
&v1beta1.QueryVoteRequest{ProposalId: proposalID, Voter: args[1]},
)
if err != nil {
return err
@ -231,7 +232,7 @@ $ %s query gov vote 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
vote := res.GetVote()
if vote.Empty() {
params := types.NewQueryVoteParams(proposalID, voterAddr)
params := v1beta1.NewQueryVoteParams(proposalID, voterAddr)
resByTxQuery, err := gcutils.QueryVoteByTxQuery(clientCtx, params)
if err != nil {
@ -273,7 +274,7 @@ $ %[1]s query gov votes 1 --page=2 --limit=100
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
queryClient := v1beta1.NewQueryClient(clientCtx)
// validate that the proposal id is a uint
proposalID, err := strconv.ParseUint(args[0], 10, 64)
@ -285,24 +286,24 @@ $ %[1]s query gov votes 1 --page=2 --limit=100
ctx := cmd.Context()
proposalRes, err := queryClient.Proposal(
ctx,
&types.QueryProposalRequest{ProposalId: proposalID},
&v1beta1.QueryProposalRequest{ProposalId: proposalID},
)
if err != nil {
return fmt.Errorf("failed to fetch proposal-id %d: %s", proposalID, err)
}
propStatus := proposalRes.GetProposal().Status
if !(propStatus == types.StatusVotingPeriod || propStatus == types.StatusDepositPeriod) {
if !(propStatus == v1beta1.StatusVotingPeriod || propStatus == v1beta1.StatusDepositPeriod) {
page, _ := cmd.Flags().GetInt(flags.FlagPage)
limit, _ := cmd.Flags().GetInt(flags.FlagLimit)
params := types.NewQueryProposalVotesParams(proposalID, page, limit)
params := v1beta1.NewQueryProposalVotesParams(proposalID, page, limit)
resByTxQuery, err := gcutils.QueryVotesByTxQuery(clientCtx, params)
if err != nil {
return err
}
var votes types.Votes
var votes v1beta1.Votes
// TODO migrate to use JSONCodec (implement MarshalJSONArray
// or wrap lists of proto.Message in some other message)
clientCtx.LegacyAmino.MustUnmarshalJSON(resByTxQuery, &votes)
@ -317,7 +318,7 @@ $ %[1]s query gov votes 1 --page=2 --limit=100
res, err := queryClient.Votes(
ctx,
&types.QueryVotesRequest{ProposalId: proposalID, Pagination: pageReq},
&v1beta1.QueryVotesRequest{ProposalId: proposalID, Pagination: pageReq},
)
if err != nil {
@ -356,7 +357,7 @@ $ %s query gov deposit 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
queryClient := v1beta1.NewQueryClient(clientCtx)
// validate that the proposal id is a uint
proposalID, err := strconv.ParseUint(args[0], 10, 64)
@ -368,7 +369,7 @@ $ %s query gov deposit 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
ctx := cmd.Context()
_, err = queryClient.Proposal(
ctx,
&types.QueryProposalRequest{ProposalId: proposalID},
&v1beta1.QueryProposalRequest{ProposalId: proposalID},
)
if err != nil {
return fmt.Errorf("failed to fetch proposal-id %d: %s", proposalID, err)
@ -376,7 +377,7 @@ $ %s query gov deposit 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
res, err := queryClient.Deposit(
ctx,
&types.QueryDepositRequest{ProposalId: proposalID, Depositor: args[1]},
&v1beta1.QueryDepositRequest{ProposalId: proposalID, Depositor: args[1]},
)
if err != nil {
return err
@ -412,7 +413,7 @@ $ %s query gov deposits 1
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
queryClient := v1beta1.NewQueryClient(clientCtx)
// validate that the proposal id is a uint
proposalID, err := strconv.ParseUint(args[0], 10, 64)
@ -424,7 +425,7 @@ $ %s query gov deposits 1
ctx := cmd.Context()
_, err = queryClient.Proposal(
ctx,
&types.QueryProposalRequest{ProposalId: proposalID},
&v1beta1.QueryProposalRequest{ProposalId: proposalID},
)
if err != nil {
return fmt.Errorf("failed to fetch proposal-id %d: %s", proposalID, err)
@ -437,7 +438,7 @@ $ %s query gov deposits 1
res, err := queryClient.Deposits(
ctx,
&types.QueryDepositsRequest{ProposalId: proposalID, Pagination: pageReq},
&v1beta1.QueryDepositsRequest{ProposalId: proposalID, Pagination: pageReq},
)
if err != nil {
@ -475,7 +476,7 @@ $ %s query gov tally 1
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
queryClient := v1beta1.NewQueryClient(clientCtx)
// validate that the proposal id is a uint
proposalID, err := strconv.ParseUint(args[0], 10, 64)
@ -487,7 +488,7 @@ $ %s query gov tally 1
ctx := cmd.Context()
_, err = queryClient.Proposal(
ctx,
&types.QueryProposalRequest{ProposalId: proposalID},
&v1beta1.QueryProposalRequest{ProposalId: proposalID},
)
if err != nil {
return fmt.Errorf("failed to fetch proposal-id %d: %s", proposalID, err)
@ -496,7 +497,7 @@ $ %s query gov tally 1
// Query store
res, err := queryClient.TallyResult(
ctx,
&types.QueryTallyResultRequest{ProposalId: proposalID},
&v1beta1.QueryTallyResultRequest{ProposalId: proposalID},
)
if err != nil {
return err
@ -531,13 +532,13 @@ $ %s query gov params
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
queryClient := v1beta1.NewQueryClient(clientCtx)
// Query store for all 3 params
ctx := cmd.Context()
votingRes, err := queryClient.Params(
ctx,
&types.QueryParamsRequest{ParamsType: "voting"},
&v1beta1.QueryParamsRequest{ParamsType: "voting"},
)
if err != nil {
return err
@ -545,7 +546,7 @@ $ %s query gov params
tallyRes, err := queryClient.Params(
ctx,
&types.QueryParamsRequest{ParamsType: "tallying"},
&v1beta1.QueryParamsRequest{ParamsType: "tallying"},
)
if err != nil {
return err
@ -553,13 +554,13 @@ $ %s query gov params
depositRes, err := queryClient.Params(
ctx,
&types.QueryParamsRequest{ParamsType: "deposit"},
&v1beta1.QueryParamsRequest{ParamsType: "deposit"},
)
if err != nil {
return err
}
params := types.NewParams(
params := v1beta1.NewParams(
votingRes.GetVotingParams(),
tallyRes.GetTallyParams(),
depositRes.GetDepositParams(),
@ -596,12 +597,12 @@ $ %s query gov param deposit
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
queryClient := v1beta1.NewQueryClient(clientCtx)
// Query store
res, err := queryClient.Params(
cmd.Context(),
&types.QueryParamsRequest{ParamsType: args[0]},
&v1beta1.QueryParamsRequest{ParamsType: args[0]},
)
if err != nil {
return err

View File

@ -13,7 +13,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
govutils "github.com/cosmos/cosmos-sdk/x/gov/client/utils"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// Proposal flags
@ -52,7 +52,7 @@ var ProposalFlags = []string{
// under the governance CLI (eg. parameter change proposals).
func NewTxCmd(propCmds []*cobra.Command) *cobra.Command {
govTxCmd := &cobra.Command{
Use: types.ModuleName,
Use: v1beta1.ModuleName,
Short: "Governance transactions subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
@ -119,9 +119,9 @@ $ %s tx gov submit-proposal --title="Test Proposal" --description="My awesome pr
return err
}
content := types.ContentFromProposalType(proposal.Title, proposal.Description, proposal.Type)
content := v1beta1.ContentFromProposalType(proposal.Title, proposal.Description, proposal.Type)
msg, err := types.NewMsgSubmitProposal(content, amount, clientCtx.GetFromAddress())
msg, err := v1beta1.NewMsgSubmitProposal(content, amount, clientCtx.GetFromAddress())
if err != nil {
return fmt.Errorf("invalid message: %w", err)
}
@ -177,7 +177,7 @@ $ %s tx gov deposit 1 10stake --from mykey
return err
}
msg := types.NewMsgDeposit(from, proposalID, amount)
msg := v1beta1.NewMsgDeposit(from, proposalID, amount)
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
@ -219,13 +219,13 @@ $ %s tx gov vote 1 yes --from mykey
}
// Find out which vote option user chose
byteVoteOption, err := types.VoteOptionFromString(govutils.NormalizeVoteOption(args[1]))
byteVoteOption, err := v1beta1.VoteOptionFromString(govutils.NormalizeVoteOption(args[1]))
if err != nil {
return err
}
// Build vote message and run basic validation
msg := types.NewMsgVote(from, proposalID, byteVoteOption)
msg := v1beta1.NewMsgVote(from, proposalID, byteVoteOption)
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
@ -268,13 +268,13 @@ $ %s tx gov weighted-vote 1 yes=0.6,no=0.3,abstain=0.05,no_with_veto=0.05 --from
}
// Figure out which vote options user chose
options, err := types.WeightedVoteOptionsFromString(govutils.NormalizeWeightedVoteOptions(args[1]))
options, err := v1beta1.WeightedVoteOptionsFromString(govutils.NormalizeWeightedVoteOptions(args[1]))
if err != nil {
return err
}
// Build vote message and run basic validation
msg := types.NewMsgVoteWeighted(from, proposalID, options)
msg := v1beta1.NewMsgVoteWeighted(from, proposalID, options)
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

View File

@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/network"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
type DepositTestSuite struct {
@ -41,7 +41,7 @@ func (s *DepositTestSuite) SetupSuite() {
deposits := sdk.Coins{
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(0)),
sdk.NewCoin(s.cfg.BondDenom, types.DefaultMinDepositTokens.Sub(sdk.NewInt(50))),
sdk.NewCoin(s.cfg.BondDenom, v1beta1.DefaultMinDepositTokens.Sub(sdk.NewInt(50))),
}
s.deposits = deposits
@ -78,7 +78,7 @@ func (s *DepositTestSuite) createProposal(val *network.Validator, initialDeposit
val.Address.String(),
fmt.Sprintf("Text Proposal %d", id),
"Where is the title!?",
types.ProposalTypeText,
v1beta1.ProposalTypeText,
exactArgs...,
)
@ -98,7 +98,7 @@ func (s *DepositTestSuite) TestQueryDepositsWithoutInitialDeposit() {
proposalID := s.proposalIDs[0]
// deposit amount
depositAmount := sdk.NewCoin(s.cfg.BondDenom, types.DefaultMinDepositTokens.Add(sdk.NewInt(50))).String()
depositAmount := sdk.NewCoin(s.cfg.BondDenom, v1beta1.DefaultMinDepositTokens.Add(sdk.NewInt(50))).String()
_, err := MsgDeposit(clientCtx, val.Address.String(), proposalID, depositAmount)
s.Require().NoError(err)
@ -146,14 +146,14 @@ func (s *DepositTestSuite) TestRejectedProposalDeposits() {
val := s.network.Validators[0]
clientCtx := val.ClientCtx
initialDeposit := sdk.NewCoin(s.cfg.BondDenom, types.DefaultMinDepositTokens)
initialDeposit := sdk.NewCoin(s.cfg.BondDenom, v1beta1.DefaultMinDepositTokens)
id := 1
proposalID := fmt.Sprintf("%d", id)
s.createProposal(val, initialDeposit, id)
// query deposits
var deposits types.QueryDepositsResponse
var deposits v1beta1.QueryDepositsResponse
args := []string{proposalID, fmt.Sprintf("--%s=json", tmcli.OutputFlag)}
cmd := cli.GetCmdQueryDeposits()
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
@ -183,9 +183,9 @@ func (s *DepositTestSuite) TestRejectedProposalDeposits() {
s.Require().Equal(depositsRes.Deposits[0].Amount.String(), initialDeposit.String())
}
func (s *DepositTestSuite) queryDeposits(val *network.Validator, proposalID string, exceptErr bool, message string) *types.QueryDepositsResponse {
func (s *DepositTestSuite) queryDeposits(val *network.Validator, proposalID string, exceptErr bool, message string) *v1beta1.QueryDepositsResponse {
args := []string{proposalID, fmt.Sprintf("--%s=json", tmcli.OutputFlag)}
var depositsRes *types.QueryDepositsResponse
var depositsRes *v1beta1.QueryDepositsResponse
cmd := cli.GetCmdQueryDeposits()
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
@ -200,9 +200,9 @@ func (s *DepositTestSuite) queryDeposits(val *network.Validator, proposalID stri
return depositsRes
}
func (s *DepositTestSuite) queryDeposit(val *network.Validator, proposalID string, exceptErr bool, message string) *types.Deposit {
func (s *DepositTestSuite) queryDeposit(val *network.Validator, proposalID string, exceptErr bool, message string) *v1beta1.Deposit {
args := []string{proposalID, val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}
var depositRes *types.Deposit
var depositRes *v1beta1.Deposit
cmd := cli.GetCmdQueryDeposit()
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
if exceptErr {

View File

@ -9,7 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/rest"
sdk "github.com/cosmos/cosmos-sdk/types"
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
func (s *IntegrationTestSuite) TestGetProposalGRPC() {
@ -43,7 +43,7 @@ func (s *IntegrationTestSuite) TestGetProposalGRPC() {
resp, err := rest.GetRequest(tc.url)
s.Require().NoError(err)
var proposal types.QueryProposalResponse
var proposal v1beta1.QueryProposalResponse
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &proposal)
if tc.expErr {
@ -97,7 +97,7 @@ func (s *IntegrationTestSuite) TestGetProposalsGRPC() {
resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers)
s.Require().NoError(err)
var proposals types.QueryProposalsResponse
var proposals v1beta1.QueryProposalsResponse
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &proposals)
if tc.expErr {
@ -119,41 +119,41 @@ func (s *IntegrationTestSuite) TestGetProposalVoteGRPC() {
name string
url string
expErr bool
expVoteOptions types.WeightedVoteOptions
expVoteOptions v1beta1.WeightedVoteOptions
}{
{
"empty proposal",
fmt.Sprintf("%s/cosmos/gov/v1beta1/proposals/%s/votes/%s", val.APIAddress, "", voterAddressBech32),
true,
types.NewNonSplitVoteOption(types.OptionYes),
v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes),
},
{
"get non existing proposal",
fmt.Sprintf("%s/cosmos/gov/v1beta1/proposals/%s/votes/%s", val.APIAddress, "10", voterAddressBech32),
true,
types.NewNonSplitVoteOption(types.OptionYes),
v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes),
},
{
"get proposal with wrong voter address",
fmt.Sprintf("%s/cosmos/gov/v1beta1/proposals/%s/votes/%s", val.APIAddress, "1", "wrongVoterAddress"),
true,
types.NewNonSplitVoteOption(types.OptionYes),
v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes),
},
{
"get proposal with id",
fmt.Sprintf("%s/cosmos/gov/v1beta1/proposals/%s/votes/%s", val.APIAddress, "1", voterAddressBech32),
false,
types.NewNonSplitVoteOption(types.OptionYes),
v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes),
},
{
"get proposal with id for split vote",
fmt.Sprintf("%s/cosmos/gov/v1beta1/proposals/%s/votes/%s", val.APIAddress, "3", voterAddressBech32),
false,
types.WeightedVoteOptions{
types.WeightedVoteOption{Option: types.OptionYes, Weight: sdk.NewDecWithPrec(60, 2)},
types.WeightedVoteOption{Option: types.OptionNo, Weight: sdk.NewDecWithPrec(30, 2)},
types.WeightedVoteOption{Option: types.OptionAbstain, Weight: sdk.NewDecWithPrec(5, 2)},
types.WeightedVoteOption{Option: types.OptionNoWithVeto, Weight: sdk.NewDecWithPrec(5, 2)},
v1beta1.WeightedVoteOptions{
v1beta1.WeightedVoteOption{Option: v1beta1.OptionYes, Weight: sdk.NewDecWithPrec(60, 2)},
v1beta1.WeightedVoteOption{Option: v1beta1.OptionNo, Weight: sdk.NewDecWithPrec(30, 2)},
v1beta1.WeightedVoteOption{Option: v1beta1.OptionAbstain, Weight: sdk.NewDecWithPrec(5, 2)},
v1beta1.WeightedVoteOption{Option: v1beta1.OptionNoWithVeto, Weight: sdk.NewDecWithPrec(5, 2)},
},
},
}
@ -164,7 +164,7 @@ func (s *IntegrationTestSuite) TestGetProposalVoteGRPC() {
resp, err := rest.GetRequest(tc.url)
s.Require().NoError(err)
var vote types.QueryVoteResponse
var vote v1beta1.QueryVoteResponse
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &vote)
if tc.expErr {
@ -208,7 +208,7 @@ func (s *IntegrationTestSuite) TestGetProposalVotesGRPC() {
resp, err := rest.GetRequest(tc.url)
s.Require().NoError(err)
var votes types.QueryVotesResponse
var votes v1beta1.QueryVotesResponse
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &votes)
if tc.expErr {
@ -257,7 +257,7 @@ func (s *IntegrationTestSuite) TestGetProposalDepositGRPC() {
resp, err := rest.GetRequest(tc.url)
s.Require().NoError(err)
var deposit types.QueryDepositResponse
var deposit v1beta1.QueryDepositResponse
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &deposit)
if tc.expErr {
@ -296,7 +296,7 @@ func (s *IntegrationTestSuite) TestGetProposalDepositsGRPC() {
resp, err := rest.GetRequest(tc.url)
s.Require().NoError(err)
var deposits types.QueryDepositsResponse
var deposits v1beta1.QueryDepositsResponse
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &deposits)
if tc.expErr {
@ -341,7 +341,7 @@ func (s *IntegrationTestSuite) TestGetTallyGRPC() {
resp, err := rest.GetRequest(tc.url)
s.Require().NoError(err)
var tally types.QueryTallyResultResponse
var tally v1beta1.QueryTallyResultResponse
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &tally)
if tc.expErr {
@ -371,29 +371,29 @@ func (s *IntegrationTestSuite) TestGetParamsGRPC() {
},
{
"get deposit params",
fmt.Sprintf("%s/cosmos/gov/v1beta1/params/%s", val.APIAddress, types.ParamDeposit),
fmt.Sprintf("%s/cosmos/gov/v1beta1/params/%s", val.APIAddress, v1beta1.ParamDeposit),
false,
&types.QueryParamsResponse{},
&types.QueryParamsResponse{
DepositParams: types.DefaultDepositParams(),
&v1beta1.QueryParamsResponse{},
&v1beta1.QueryParamsResponse{
DepositParams: v1beta1.DefaultDepositParams(),
},
},
{
"get vote params",
fmt.Sprintf("%s/cosmos/gov/v1beta1/params/%s", val.APIAddress, types.ParamVoting),
fmt.Sprintf("%s/cosmos/gov/v1beta1/params/%s", val.APIAddress, v1beta1.ParamVoting),
false,
&types.QueryParamsResponse{},
&types.QueryParamsResponse{
VotingParams: types.DefaultVotingParams(),
&v1beta1.QueryParamsResponse{},
&v1beta1.QueryParamsResponse{
VotingParams: v1beta1.DefaultVotingParams(),
},
},
{
"get tally params",
fmt.Sprintf("%s/cosmos/gov/v1beta1/params/%s", val.APIAddress, types.ParamTallying),
fmt.Sprintf("%s/cosmos/gov/v1beta1/params/%s", val.APIAddress, v1beta1.ParamTallying),
false,
&types.QueryParamsResponse{},
&types.QueryParamsResponse{
TallyParams: types.DefaultTallyParams(),
&v1beta1.QueryParamsResponse{},
&v1beta1.QueryParamsResponse{
TallyParams: v1beta1.DefaultTallyParams(),
},
},
}

View File

@ -16,7 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/network"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
type IntegrationTestSuite struct {
@ -44,8 +44,8 @@ func (s *IntegrationTestSuite) SetupSuite() {
// create a proposal with deposit
_, err = MsgSubmitProposal(val.ClientCtx, val.Address.String(),
"Text Proposal 1", "Where is the title!?", types.ProposalTypeText,
fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, types.DefaultMinDepositTokens).String()))
"Text Proposal 1", "Where is the title!?", v1beta1.ProposalTypeText,
fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, v1beta1.DefaultMinDepositTokens).String()))
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
@ -56,15 +56,15 @@ func (s *IntegrationTestSuite) SetupSuite() {
// create a proposal without deposit
_, err = MsgSubmitProposal(val.ClientCtx, val.Address.String(),
"Text Proposal 2", "Where is the title!?", types.ProposalTypeText)
"Text Proposal 2", "Where is the title!?", v1beta1.ProposalTypeText)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
// create a proposal3 with deposit
_, err = MsgSubmitProposal(val.ClientCtx, val.Address.String(),
"Text Proposal 3", "Where is the title!?", types.ProposalTypeText,
fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, types.DefaultMinDepositTokens).String()))
"Text Proposal 3", "Where is the title!?", v1beta1.ProposalTypeText,
fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, v1beta1.DefaultMinDepositTokens).String()))
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
@ -226,7 +226,7 @@ func (s *IntegrationTestSuite) TestCmdTally() {
name string
args []string
expectErr bool
expectedOutput types.TallyResult
expectedOutput v1beta1.TallyResult
}{
{
"without proposal id",
@ -234,7 +234,7 @@ func (s *IntegrationTestSuite) TestCmdTally() {
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
true,
types.TallyResult{},
v1beta1.TallyResult{},
},
{
"json output",
@ -243,7 +243,7 @@ func (s *IntegrationTestSuite) TestCmdTally() {
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
false,
types.NewTallyResult(sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0)),
v1beta1.NewTallyResult(sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0)),
},
{
"json output",
@ -252,7 +252,7 @@ func (s *IntegrationTestSuite) TestCmdTally() {
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
false,
types.NewTallyResult(s.cfg.BondedTokens, sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0)),
v1beta1.NewTallyResult(s.cfg.BondedTokens, sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0)),
},
}
@ -267,7 +267,7 @@ func (s *IntegrationTestSuite) TestCmdTally() {
if tc.expectErr {
s.Require().Error(err)
} else {
var tally types.TallyResult
var tally v1beta1.TallyResult
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &tally), out.String())
s.Require().Equal(tally, tc.expectedOutput)
}
@ -312,7 +312,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() {
"invalid proposal",
[]string{
fmt.Sprintf("--%s='Where is the title!?'", cli.FlagDescription),
fmt.Sprintf("--%s=%s", cli.FlagProposalType, types.ProposalTypeText),
fmt.Sprintf("--%s=%s", cli.FlagProposalType, v1beta1.ProposalTypeText),
fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)).String()),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
@ -336,7 +336,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() {
[]string{
fmt.Sprintf("--%s='Text Proposal'", cli.FlagTitle),
fmt.Sprintf("--%s='Where is the title!?'", cli.FlagDescription),
fmt.Sprintf("--%s=%s", cli.FlagProposalType, types.ProposalTypeText),
fmt.Sprintf("--%s=%s", cli.FlagProposalType, v1beta1.ProposalTypeText),
fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)).String()),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
@ -407,7 +407,7 @@ func (s *IntegrationTestSuite) TestCmdGetProposal() {
s.Require().Error(err)
} else {
s.Require().NoError(err)
var proposal types.Proposal
var proposal v1beta1.Proposal
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &proposal), out.String())
s.Require().Equal(title, proposal.GetTitle())
}
@ -452,7 +452,7 @@ func (s *IntegrationTestSuite) TestCmdGetProposals() {
s.Require().Error(err)
} else {
s.Require().NoError(err)
var proposals types.QueryProposalsResponse
var proposals v1beta1.QueryProposalsResponse
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &proposals), out.String())
s.Require().Len(proposals.Proposals, 3)
@ -499,7 +499,7 @@ func (s *IntegrationTestSuite) TestCmdQueryDeposits() {
} else {
s.Require().NoError(err)
var deposits types.QueryDepositsResponse
var deposits v1beta1.QueryDepositsResponse
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &deposits), out.String())
s.Require().Len(deposits.Deposits, 1)
}
@ -509,7 +509,7 @@ func (s *IntegrationTestSuite) TestCmdQueryDeposits() {
func (s *IntegrationTestSuite) TestCmdQueryDeposit() {
val := s.network.Validators[0]
depositAmount := sdk.NewCoin(s.cfg.BondDenom, types.DefaultMinDepositTokens)
depositAmount := sdk.NewCoin(s.cfg.BondDenom, v1beta1.DefaultMinDepositTokens)
testCases := []struct {
name string
@ -555,7 +555,7 @@ func (s *IntegrationTestSuite) TestCmdQueryDeposit() {
} else {
s.Require().NoError(err)
var deposit types.Deposit
var deposit v1beta1.Deposit
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &deposit), out.String())
s.Require().Equal(depositAmount.String(), deposit.Amount.String())
}
@ -684,7 +684,7 @@ func (s *IntegrationTestSuite) TestCmdQueryVotes() {
} else {
s.Require().NoError(err)
var votes types.QueryVotesResponse
var votes v1beta1.QueryVotesResponse
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &votes), out.String())
s.Require().Len(votes.Votes, 1)
}
@ -699,7 +699,7 @@ func (s *IntegrationTestSuite) TestCmdQueryVote() {
name string
args []string
expectErr bool
expVoteOptions types.WeightedVoteOptions
expVoteOptions v1beta1.WeightedVoteOptions
}{
{
"get vote of non existing proposal",
@ -708,7 +708,7 @@ func (s *IntegrationTestSuite) TestCmdQueryVote() {
val.Address.String(),
},
true,
types.NewNonSplitVoteOption(types.OptionYes),
v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes),
},
{
"get vote by wrong voter",
@ -717,7 +717,7 @@ func (s *IntegrationTestSuite) TestCmdQueryVote() {
"wrong address",
},
true,
types.NewNonSplitVoteOption(types.OptionYes),
v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes),
},
{
"vote for valid proposal",
@ -727,7 +727,7 @@ func (s *IntegrationTestSuite) TestCmdQueryVote() {
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
false,
types.NewNonSplitVoteOption(types.OptionYes),
v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes),
},
{
"split vote for valid proposal",
@ -737,11 +737,11 @@ func (s *IntegrationTestSuite) TestCmdQueryVote() {
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
false,
types.WeightedVoteOptions{
types.WeightedVoteOption{Option: types.OptionYes, Weight: sdk.NewDecWithPrec(60, 2)},
types.WeightedVoteOption{Option: types.OptionNo, Weight: sdk.NewDecWithPrec(30, 2)},
types.WeightedVoteOption{Option: types.OptionAbstain, Weight: sdk.NewDecWithPrec(5, 2)},
types.WeightedVoteOption{Option: types.OptionNoWithVeto, Weight: sdk.NewDecWithPrec(5, 2)},
v1beta1.WeightedVoteOptions{
v1beta1.WeightedVoteOption{Option: v1beta1.OptionYes, Weight: sdk.NewDecWithPrec(60, 2)},
v1beta1.WeightedVoteOption{Option: v1beta1.OptionNo, Weight: sdk.NewDecWithPrec(30, 2)},
v1beta1.WeightedVoteOption{Option: v1beta1.OptionAbstain, Weight: sdk.NewDecWithPrec(5, 2)},
v1beta1.WeightedVoteOption{Option: v1beta1.OptionNoWithVeto, Weight: sdk.NewDecWithPrec(5, 2)},
},
},
}
@ -759,7 +759,7 @@ func (s *IntegrationTestSuite) TestCmdQueryVote() {
} else {
s.Require().NoError(err)
var vote types.Vote
var vote v1beta1.Vote
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &vote), out.String())
s.Require().Equal(len(vote.Options), len(tc.expVoteOptions))
for i, option := range tc.expVoteOptions {

View File

@ -8,6 +8,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
const (
@ -37,8 +38,8 @@ func (p Proposer) String() string {
//
// NOTE: SearchTxs is used to facilitate the txs query which does not currently
// support configurable pagination.
func QueryDepositsByTxQuery(clientCtx client.Context, params types.QueryProposalParams) ([]byte, error) {
var deposits []types.Deposit
func QueryDepositsByTxQuery(clientCtx client.Context, params v1beta1.QueryProposalParams) ([]byte, error) {
var deposits []v1beta1.Deposit
// initial deposit was submitted with proposal, so must be queried separately
initialDeposit, err := queryInitialDepositByTxQuery(clientCtx, params.ProposalID)
@ -54,12 +55,12 @@ func QueryDepositsByTxQuery(clientCtx client.Context, params types.QueryProposal
clientCtx, defaultPage,
// Query legacy Msgs event action
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgDeposit),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, v1beta1.TypeMsgDeposit),
fmt.Sprintf("%s.%s='%d'", types.EventTypeProposalDeposit, types.AttributeKeyProposalID, params.ProposalID),
},
// Query proto Msgs event action
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgDeposit{})),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&v1beta1.MsgDeposit{})),
fmt.Sprintf("%s.%s='%d'", types.EventTypeProposalDeposit, types.AttributeKeyProposalID, params.ProposalID),
},
)
@ -69,8 +70,8 @@ func QueryDepositsByTxQuery(clientCtx client.Context, params types.QueryProposal
for _, info := range searchResult.Txs {
for _, msg := range info.GetTx().GetMsgs() {
if depMsg, ok := msg.(*types.MsgDeposit); ok {
deposits = append(deposits, types.Deposit{
if depMsg, ok := msg.(*v1beta1.MsgDeposit); ok {
deposits = append(deposits, v1beta1.Deposit{
Depositor: depMsg.Depositor,
ProposalId: params.ProposalID,
Amount: depMsg.Amount,
@ -90,9 +91,9 @@ func QueryDepositsByTxQuery(clientCtx client.Context, params types.QueryProposal
// QueryVotesByTxQuery will query for votes via a direct txs tags query. It
// will fetch and build votes directly from the returned txs and return a JSON
// marshalled result or any error that occurred.
func QueryVotesByTxQuery(clientCtx client.Context, params types.QueryProposalVotesParams) ([]byte, error) {
func QueryVotesByTxQuery(clientCtx client.Context, params v1beta1.QueryProposalVotesParams) ([]byte, error) {
var (
votes []types.Vote
votes []v1beta1.Vote
nextTxPage = defaultPage
totalLimit = params.Limit * params.Page
)
@ -104,22 +105,22 @@ func QueryVotesByTxQuery(clientCtx client.Context, params types.QueryProposalVot
clientCtx, nextTxPage,
// Query legacy Vote Msgs
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgVote),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, v1beta1.TypeMsgVote),
fmt.Sprintf("%s.%s='%d'", types.EventTypeProposalVote, types.AttributeKeyProposalID, params.ProposalID),
},
// Query Vote proto Msgs
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgVote{})),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&v1beta1.MsgVote{})),
fmt.Sprintf("%s.%s='%d'", types.EventTypeProposalVote, types.AttributeKeyProposalID, params.ProposalID),
},
// Query legacy VoteWeighted Msgs
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgVoteWeighted),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, v1beta1.TypeMsgVoteWeighted),
fmt.Sprintf("%s.%s='%d'", types.EventTypeProposalVote, types.AttributeKeyProposalID, params.ProposalID),
},
// Query VoteWeighted proto Msgs
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgVoteWeighted{})),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&v1beta1.MsgVoteWeighted{})),
fmt.Sprintf("%s.%s='%d'", types.EventTypeProposalVote, types.AttributeKeyProposalID, params.ProposalID),
},
)
@ -129,16 +130,16 @@ func QueryVotesByTxQuery(clientCtx client.Context, params types.QueryProposalVot
for _, info := range searchResult.Txs {
for _, msg := range info.GetTx().GetMsgs() {
if voteMsg, ok := msg.(*types.MsgVote); ok {
votes = append(votes, types.Vote{
if voteMsg, ok := msg.(*v1beta1.MsgVote); ok {
votes = append(votes, v1beta1.Vote{
Voter: voteMsg.Voter,
ProposalId: params.ProposalID,
Options: types.NewNonSplitVoteOption(voteMsg.Option),
Options: v1beta1.NewNonSplitVoteOption(voteMsg.Option),
})
}
if voteWeightedMsg, ok := msg.(*types.MsgVoteWeighted); ok {
votes = append(votes, types.Vote{
if voteWeightedMsg, ok := msg.(*v1beta1.MsgVoteWeighted); ok {
votes = append(votes, v1beta1.Vote{
Voter: voteWeightedMsg.Voter,
ProposalId: params.ProposalID,
Options: voteWeightedMsg.Options,
@ -154,7 +155,7 @@ func QueryVotesByTxQuery(clientCtx client.Context, params types.QueryProposalVot
}
start, end := client.Paginate(len(votes), params.Page, params.Limit, 100)
if start < 0 || end < 0 {
votes = []types.Vote{}
votes = []v1beta1.Vote{}
} else {
votes = votes[start:end]
}
@ -168,30 +169,30 @@ func QueryVotesByTxQuery(clientCtx client.Context, params types.QueryProposalVot
}
// QueryVoteByTxQuery will query for a single vote via a direct txs tags query.
func QueryVoteByTxQuery(clientCtx client.Context, params types.QueryVoteParams) ([]byte, error) {
func QueryVoteByTxQuery(clientCtx client.Context, params v1beta1.QueryVoteParams) ([]byte, error) {
searchResult, err := combineEvents(
clientCtx, defaultPage,
// Query legacy Vote Msgs
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgVote),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, v1beta1.TypeMsgVote),
fmt.Sprintf("%s.%s='%d'", types.EventTypeProposalVote, types.AttributeKeyProposalID, params.ProposalID),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeySender, params.Voter),
},
// Query Vote proto Msgs
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgVote{})),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&v1beta1.MsgVote{})),
fmt.Sprintf("%s.%s='%d'", types.EventTypeProposalVote, types.AttributeKeyProposalID, params.ProposalID),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeySender, params.Voter.String()),
},
// Query legacy VoteWeighted Msgs
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgVoteWeighted),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, v1beta1.TypeMsgVoteWeighted),
fmt.Sprintf("%s.%s='%d'", types.EventTypeProposalVote, types.AttributeKeyProposalID, params.ProposalID),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeySender, params.Voter.String()),
},
// Query VoteWeighted proto Msgs
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgVoteWeighted{})),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&v1beta1.MsgVoteWeighted{})),
fmt.Sprintf("%s.%s='%d'", types.EventTypeProposalVote, types.AttributeKeyProposalID, params.ProposalID),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeySender, params.Voter),
},
@ -203,17 +204,17 @@ func QueryVoteByTxQuery(clientCtx client.Context, params types.QueryVoteParams)
for _, info := range searchResult.Txs {
for _, msg := range info.GetTx().GetMsgs() {
// there should only be a single vote under the given conditions
var vote *types.Vote
if voteMsg, ok := msg.(*types.MsgVote); ok {
vote = &types.Vote{
var vote *v1beta1.Vote
if voteMsg, ok := msg.(*v1beta1.MsgVote); ok {
vote = &v1beta1.Vote{
Voter: voteMsg.Voter,
ProposalId: params.ProposalID,
Options: types.NewNonSplitVoteOption(voteMsg.Option),
Options: v1beta1.NewNonSplitVoteOption(voteMsg.Option),
}
}
if voteWeightedMsg, ok := msg.(*types.MsgVoteWeighted); ok {
vote = &types.Vote{
if voteWeightedMsg, ok := msg.(*v1beta1.MsgVoteWeighted); ok {
vote = &v1beta1.Vote{
Voter: voteWeightedMsg.Voter,
ProposalId: params.ProposalID,
Options: voteWeightedMsg.Options,
@ -236,7 +237,7 @@ func QueryVoteByTxQuery(clientCtx client.Context, params types.QueryVoteParams)
// QueryDepositByTxQuery will query for a single deposit via a direct txs tags
// query.
func QueryDepositByTxQuery(clientCtx client.Context, params types.QueryDepositParams) ([]byte, error) {
func QueryDepositByTxQuery(clientCtx client.Context, params v1beta1.QueryDepositParams) ([]byte, error) {
// initial deposit was submitted with proposal, so must be queried separately
initialDeposit, err := queryInitialDepositByTxQuery(clientCtx, params.ProposalID)
@ -257,13 +258,13 @@ func QueryDepositByTxQuery(clientCtx client.Context, params types.QueryDepositPa
clientCtx, defaultPage,
// Query legacy Msgs event action
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgDeposit),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, v1beta1.TypeMsgDeposit),
fmt.Sprintf("%s.%s='%d'", types.EventTypeProposalDeposit, types.AttributeKeyProposalID, params.ProposalID),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeySender, params.Depositor.String()),
},
// Query proto Msgs event action
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgDeposit{})),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&v1beta1.MsgDeposit{})),
fmt.Sprintf("%s.%s='%d'", types.EventTypeProposalDeposit, types.AttributeKeyProposalID, params.ProposalID),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeySender, params.Depositor.String()),
},
@ -275,8 +276,8 @@ func QueryDepositByTxQuery(clientCtx client.Context, params types.QueryDepositPa
for _, info := range searchResult.Txs {
for _, msg := range info.GetTx().GetMsgs() {
// there should only be a single deposit under the given conditions
if depMsg, ok := msg.(*types.MsgDeposit); ok {
deposit := types.Deposit{
if depMsg, ok := msg.(*v1beta1.MsgDeposit); ok {
deposit := v1beta1.Deposit{
Depositor: depMsg.Depositor,
ProposalId: params.ProposalID,
Amount: depMsg.Amount,
@ -303,12 +304,12 @@ func QueryProposerByTxQuery(clientCtx client.Context, proposalID uint64) (Propos
defaultPage,
// Query legacy Msgs event action
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgSubmitProposal),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, v1beta1.TypeMsgSubmitProposal),
fmt.Sprintf("%s.%s='%d'", types.EventTypeSubmitProposal, types.AttributeKeyProposalID, proposalID),
},
// Query proto Msgs event action
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgSubmitProposal{})),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&v1beta1.MsgSubmitProposal{})),
fmt.Sprintf("%s.%s='%d'", types.EventTypeSubmitProposal, types.AttributeKeyProposalID, proposalID),
},
)
@ -319,7 +320,7 @@ func QueryProposerByTxQuery(clientCtx client.Context, proposalID uint64) (Propos
for _, info := range searchResult.Txs {
for _, msg := range info.GetTx().GetMsgs() {
// there should only be a single proposal under the given conditions
if subMsg, ok := msg.(*types.MsgSubmitProposal); ok {
if subMsg, ok := msg.(*v1beta1.MsgSubmitProposal); ok {
return NewProposer(proposalID, subMsg.Proposer), nil
}
}
@ -330,7 +331,7 @@ func QueryProposerByTxQuery(clientCtx client.Context, proposalID uint64) (Propos
// QueryProposalByID takes a proposalID and returns a proposal
func QueryProposalByID(proposalID uint64, clientCtx client.Context, queryRoute string) ([]byte, error) {
params := types.NewQueryProposalParams(proposalID)
params := v1beta1.NewQueryProposalParams(proposalID)
bz, err := clientCtx.LegacyAmino.MarshalJSON(params)
if err != nil {
return nil, err
@ -368,30 +369,30 @@ func combineEvents(clientCtx client.Context, page int, eventGroups ...[]string)
// queryInitialDepositByTxQuery will query for a initial deposit of a governance proposal by
// ID.
func queryInitialDepositByTxQuery(clientCtx client.Context, proposalID uint64) (types.Deposit, error) {
func queryInitialDepositByTxQuery(clientCtx client.Context, proposalID uint64) (v1beta1.Deposit, error) {
searchResult, err := combineEvents(
clientCtx, defaultPage,
// Query legacy Msgs event action
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgSubmitProposal),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, v1beta1.TypeMsgSubmitProposal),
fmt.Sprintf("%s.%s='%d'", types.EventTypeSubmitProposal, types.AttributeKeyProposalID, proposalID),
},
// Query proto Msgs event action
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgSubmitProposal{})),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&v1beta1.MsgSubmitProposal{})),
fmt.Sprintf("%s.%s='%d'", types.EventTypeSubmitProposal, types.AttributeKeyProposalID, proposalID),
},
)
if err != nil {
return types.Deposit{}, err
return v1beta1.Deposit{}, err
}
for _, info := range searchResult.Txs {
for _, msg := range info.GetTx().GetMsgs() {
// there should only be a single proposal under the given conditions
if subMsg, ok := msg.(*types.MsgSubmitProposal); ok {
return types.Deposit{
if subMsg, ok := msg.(*v1beta1.MsgSubmitProposal); ok {
return v1beta1.Deposit{
ProposalId: proposalID,
Depositor: subMsg.Proposer,
Amount: subMsg.InitialDeposit,
@ -400,5 +401,5 @@ func queryInitialDepositByTxQuery(clientCtx client.Context, proposalID uint64) (
}
}
return types.Deposit{}, sdkerrors.ErrNotFound.Wrapf("failed to find the initial deposit for proposalID %d", proposalID)
return v1beta1.Deposit{}, sdkerrors.ErrNotFound.Wrapf("failed to find the initial deposit for proposalID %d", proposalID)
}

View File

@ -15,7 +15,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
"github.com/cosmos/cosmos-sdk/x/gov/client/utils"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
type TxSearchMock struct {
@ -81,19 +81,19 @@ func TestGetPaginatedVotes(t *testing.T) {
description string
page, limit int
msgs [][]sdk.Msg
votes []types.Vote
votes []v1beta1.Vote
}
acc1 := make(sdk.AccAddress, 20)
acc1[0] = 1
acc2 := make(sdk.AccAddress, 20)
acc2[0] = 2
acc1Msgs := []sdk.Msg{
types.NewMsgVote(acc1, 0, types.OptionYes),
types.NewMsgVote(acc1, 0, types.OptionYes),
v1beta1.NewMsgVote(acc1, 0, v1beta1.OptionYes),
v1beta1.NewMsgVote(acc1, 0, v1beta1.OptionYes),
}
acc2Msgs := []sdk.Msg{
types.NewMsgVote(acc2, 0, types.OptionYes),
types.NewMsgVoteWeighted(acc2, 0, types.NewNonSplitVoteOption(types.OptionYes)),
v1beta1.NewMsgVote(acc2, 0, v1beta1.OptionYes),
v1beta1.NewMsgVoteWeighted(acc2, 0, v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)),
}
for _, tc := range []testCase{
{
@ -104,9 +104,9 @@ func TestGetPaginatedVotes(t *testing.T) {
acc1Msgs[:1],
acc2Msgs[:1],
},
votes: []types.Vote{
types.NewVote(0, acc1, types.NewNonSplitVoteOption(types.OptionYes)),
types.NewVote(0, acc2, types.NewNonSplitVoteOption(types.OptionYes))},
votes: []v1beta1.Vote{
v1beta1.NewVote(0, acc1, v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)),
v1beta1.NewVote(0, acc2, v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes))},
},
{
description: "2MsgPerTx1Chunk",
@ -116,9 +116,9 @@ func TestGetPaginatedVotes(t *testing.T) {
acc1Msgs,
acc2Msgs,
},
votes: []types.Vote{
types.NewVote(0, acc1, types.NewNonSplitVoteOption(types.OptionYes)),
types.NewVote(0, acc1, types.NewNonSplitVoteOption(types.OptionYes)),
votes: []v1beta1.Vote{
v1beta1.NewVote(0, acc1, v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)),
v1beta1.NewVote(0, acc1, v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)),
},
},
{
@ -129,9 +129,9 @@ func TestGetPaginatedVotes(t *testing.T) {
acc1Msgs,
acc2Msgs,
},
votes: []types.Vote{
types.NewVote(0, acc2, types.NewNonSplitVoteOption(types.OptionYes)),
types.NewVote(0, acc2, types.NewNonSplitVoteOption(types.OptionYes)),
votes: []v1beta1.Vote{
v1beta1.NewVote(0, acc2, v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)),
v1beta1.NewVote(0, acc2, v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)),
},
},
{
@ -141,7 +141,7 @@ func TestGetPaginatedVotes(t *testing.T) {
msgs: [][]sdk.Msg{
acc1Msgs[:1],
},
votes: []types.Vote{types.NewVote(0, acc1, types.NewNonSplitVoteOption(types.OptionYes))},
votes: []v1beta1.Vote{v1beta1.NewVote(0, acc1, v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes))},
},
{
description: "InvalidPage",
@ -179,10 +179,10 @@ func TestGetPaginatedVotes(t *testing.T) {
marshalled[i] = tx
}
params := types.NewQueryProposalVotesParams(0, tc.page, tc.limit)
params := v1beta1.NewQueryProposalVotesParams(0, tc.page, tc.limit)
votesData, err := utils.QueryVotesByTxQuery(clientCtx, params)
require.NoError(t, err)
votes := []types.Vote{}
votes := []v1beta1.Vote{}
require.NoError(t, clientCtx.LegacyAmino.UnmarshalJSON(votesData, &votes))
require.Equal(t, len(tc.votes), len(votes))
for i := range votes {

View File

@ -3,23 +3,23 @@ package utils
import (
"strings"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// NormalizeVoteOption - normalize user specified vote option
func NormalizeVoteOption(option string) string {
switch option {
case "Yes", "yes":
return types.OptionYes.String()
return v1beta1.OptionYes.String()
case "Abstain", "abstain":
return types.OptionAbstain.String()
return v1beta1.OptionAbstain.String()
case "No", "no":
return types.OptionNo.String()
return v1beta1.OptionNo.String()
case "NoWithVeto", "no_with_veto":
return types.OptionNoWithVeto.String()
return v1beta1.OptionNoWithVeto.String()
default:
return option
@ -44,7 +44,7 @@ func NormalizeWeightedVoteOptions(options string) string {
func NormalizeProposalType(proposalType string) string {
switch proposalType {
case "Text", "text":
return types.ProposalTypeText
return v1beta1.ProposalTypeText
default:
return ""
@ -55,13 +55,13 @@ func NormalizeProposalType(proposalType string) string {
func NormalizeProposalStatus(status string) string {
switch status {
case "DepositPeriod", "deposit_period":
return types.StatusDepositPeriod.String()
return v1beta1.StatusDepositPeriod.String()
case "VotingPeriod", "voting_period":
return types.StatusVotingPeriod.String()
return v1beta1.StatusVotingPeriod.String()
case "Passed", "passed":
return types.StatusPassed.String()
return v1beta1.StatusPassed.String()
case "Rejected", "rejected":
return types.StatusRejected.String()
return v1beta1.StatusRejected.String()
default:
return status
}

View File

@ -8,13 +8,13 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
var (
valTokens = sdk.TokensFromConsensusPower(42, sdk.DefaultPowerReduction)
TestProposal = types.NewTextProposal("Test", "description")
TestProposal = v1beta1.NewTextProposal("Test", "description")
TestDescription = stakingtypes.NewDescription("T", "E", "S", "T", "Z")
TestCommissionRates = stakingtypes.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec())
)

View File

@ -6,10 +6,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// InitGenesis - store genesis parameters
func InitGenesis(ctx sdk.Context, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, data *types.GenesisState) {
func InitGenesis(ctx sdk.Context, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, data *v1beta1.GenesisState) {
k.SetProposalID(ctx, data.StartingProposalId)
k.SetDepositParams(ctx, data.DepositParams)
k.SetVotingParams(ctx, data.VotingParams)
@ -33,9 +34,9 @@ func InitGenesis(ctx sdk.Context, ak types.AccountKeeper, bk types.BankKeeper, k
for _, proposal := range data.Proposals {
switch proposal.Status {
case types.StatusDepositPeriod:
case v1beta1.StatusDepositPeriod:
k.InsertInactiveProposalQueue(ctx, proposal.ProposalId, proposal.DepositEndTime)
case types.StatusVotingPeriod:
case v1beta1.StatusVotingPeriod:
k.InsertActiveProposalQueue(ctx, proposal.ProposalId, proposal.VotingEndTime)
}
k.SetProposal(ctx, proposal)
@ -54,15 +55,15 @@ func InitGenesis(ctx sdk.Context, ak types.AccountKeeper, bk types.BankKeeper, k
}
// ExportGenesis - output genesis parameters
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *v1beta1.GenesisState {
startingProposalID, _ := k.GetProposalID(ctx)
depositParams := k.GetDepositParams(ctx)
votingParams := k.GetVotingParams(ctx)
tallyParams := k.GetTallyParams(ctx)
proposals := k.GetProposals(ctx)
var proposalsDeposits types.Deposits
var proposalsVotes types.Votes
var proposalsDeposits v1beta1.Deposits
var proposalsVotes v1beta1.Votes
for _, proposal := range proposals {
deposits := k.GetDeposits(ctx, proposal.ProposalId)
proposalsDeposits = append(proposalsDeposits, deposits...)
@ -71,7 +72,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
proposalsVotes = append(proposalsVotes, votes...)
}
return &types.GenesisState{
return &v1beta1.GenesisState{
StartingProposalId: startingProposalID,
Deposits: proposalsDeposits,
Votes: proposalsVotes,

View File

@ -18,6 +18,7 @@ import (
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -52,8 +53,8 @@ func TestImportExportQueues(t *testing.T) {
require.True(t, ok)
proposal2, ok = app.GovKeeper.GetProposal(ctx, proposalID2)
require.True(t, ok)
require.True(t, proposal1.Status == types.StatusDepositPeriod)
require.True(t, proposal2.Status == types.StatusVotingPeriod)
require.True(t, proposal1.Status == v1beta1.StatusDepositPeriod)
require.True(t, proposal2.Status == v1beta1.StatusVotingPeriod)
authGenState := auth.ExportGenesis(ctx, app.AccountKeeper)
bankGenState := app.BankKeeper.ExportGenesis(ctx)
@ -102,8 +103,8 @@ func TestImportExportQueues(t *testing.T) {
require.True(t, ok)
proposal2, ok = app2.GovKeeper.GetProposal(ctx2, proposalID2)
require.True(t, ok)
require.True(t, proposal1.Status == types.StatusDepositPeriod)
require.True(t, proposal2.Status == types.StatusVotingPeriod)
require.True(t, proposal1.Status == v1beta1.StatusDepositPeriod)
require.True(t, proposal2.Status == v1beta1.StatusVotingPeriod)
macc := app2.GovKeeper.GetGovernanceAccount(ctx2)
require.Equal(t, app2.GovKeeper.GetDepositParams(ctx2).MinDeposit, app2.BankKeeper.GetAllBalances(ctx2, macc.GetAddress()))
@ -116,15 +117,15 @@ func TestImportExportQueues(t *testing.T) {
proposal2, ok = app2.GovKeeper.GetProposal(ctx2, proposalID2)
require.True(t, ok)
require.True(t, proposal2.Status == types.StatusRejected)
require.True(t, proposal2.Status == v1beta1.StatusRejected)
}
func TestImportExportQueues_ErrorUnconsistentState(t *testing.T) {
app := simapp.Setup(t, false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
require.Panics(t, func() {
gov.InitGenesis(ctx, app.AccountKeeper, app.BankKeeper, app.GovKeeper, &types.GenesisState{
Deposits: types.Deposits{
gov.InitGenesis(ctx, app.AccountKeeper, app.BankKeeper, app.GovKeeper, &v1beta1.GenesisState{
Deposits: v1beta1.Deposits{
{
ProposalId: 1234,
Depositor: "me",
@ -163,8 +164,8 @@ func TestEqualProposals(t *testing.T) {
require.NotEqual(t, proposal1, proposal2)
// Now create two genesis blocks
state1 := types.GenesisState{Proposals: []types.Proposal{proposal1}}
state2 := types.GenesisState{Proposals: []types.Proposal{proposal2}}
state1 := v1beta1.GenesisState{Proposals: []v1beta1.Proposal{proposal1}}
state2 := v1beta1.GenesisState{Proposals: []v1beta1.Proposal{proposal2}}
require.NotEqual(t, state1, state2)
require.False(t, state1.Equal(state2))

View File

@ -7,14 +7,14 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
var (
TestProposal = types.NewTextProposal("Test", "description")
TestProposal = v1beta1.NewTextProposal("Test", "description")
)
func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers []int64) ([]sdk.AccAddress, []sdk.ValAddress) {

View File

@ -6,10 +6,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// GetDeposit gets the deposit of a specific depositor on a specific proposal
func (keeper Keeper) GetDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) (deposit types.Deposit, found bool) {
func (keeper Keeper) GetDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) (deposit v1beta1.Deposit, found bool) {
store := ctx.KVStore(keeper.storeKey)
bz := store.Get(types.DepositKey(proposalID, depositorAddr))
if bz == nil {
@ -22,7 +23,7 @@ func (keeper Keeper) GetDeposit(ctx sdk.Context, proposalID uint64, depositorAdd
}
// SetDeposit sets a Deposit to the gov store
func (keeper Keeper) SetDeposit(ctx sdk.Context, deposit types.Deposit) {
func (keeper Keeper) SetDeposit(ctx sdk.Context, deposit v1beta1.Deposit) {
store := ctx.KVStore(keeper.storeKey)
bz := keeper.cdc.MustMarshal(&deposit)
depositor, err := sdk.AccAddressFromBech32(deposit.Depositor)
@ -34,8 +35,8 @@ func (keeper Keeper) SetDeposit(ctx sdk.Context, deposit types.Deposit) {
}
// GetAllDeposits returns all the deposits from the store
func (keeper Keeper) GetAllDeposits(ctx sdk.Context) (deposits types.Deposits) {
keeper.IterateAllDeposits(ctx, func(deposit types.Deposit) bool {
func (keeper Keeper) GetAllDeposits(ctx sdk.Context) (deposits v1beta1.Deposits) {
keeper.IterateAllDeposits(ctx, func(deposit v1beta1.Deposit) bool {
deposits = append(deposits, deposit)
return false
})
@ -44,8 +45,8 @@ func (keeper Keeper) GetAllDeposits(ctx sdk.Context) (deposits types.Deposits) {
}
// GetDeposits returns all the deposits from a proposal
func (keeper Keeper) GetDeposits(ctx sdk.Context, proposalID uint64) (deposits types.Deposits) {
keeper.IterateDeposits(ctx, proposalID, func(deposit types.Deposit) bool {
func (keeper Keeper) GetDeposits(ctx sdk.Context, proposalID uint64) (deposits v1beta1.Deposits) {
keeper.IterateDeposits(ctx, proposalID, func(deposit v1beta1.Deposit) bool {
deposits = append(deposits, deposit)
return false
})
@ -57,8 +58,8 @@ func (keeper Keeper) GetDeposits(ctx sdk.Context, proposalID uint64) (deposits t
func (keeper Keeper) DeleteAndBurnDeposits(ctx sdk.Context, proposalID uint64) {
store := ctx.KVStore(keeper.storeKey)
keeper.IterateDeposits(ctx, proposalID, func(deposit types.Deposit) bool {
err := keeper.bankKeeper.BurnCoins(ctx, types.ModuleName, deposit.Amount)
keeper.IterateDeposits(ctx, proposalID, func(deposit v1beta1.Deposit) bool {
err := keeper.bankKeeper.BurnCoins(ctx, v1beta1.ModuleName, deposit.Amount)
if err != nil {
panic(err)
}
@ -73,14 +74,14 @@ func (keeper Keeper) DeleteAndBurnDeposits(ctx sdk.Context, proposalID uint64) {
}
// IterateAllDeposits iterates over the all the stored deposits and performs a callback function
func (keeper Keeper) IterateAllDeposits(ctx sdk.Context, cb func(deposit types.Deposit) (stop bool)) {
func (keeper Keeper) IterateAllDeposits(ctx sdk.Context, cb func(deposit v1beta1.Deposit) (stop bool)) {
store := ctx.KVStore(keeper.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.DepositsKeyPrefix)
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
var deposit types.Deposit
var deposit v1beta1.Deposit
keeper.cdc.MustUnmarshal(iterator.Value(), &deposit)
@ -91,14 +92,14 @@ func (keeper Keeper) IterateAllDeposits(ctx sdk.Context, cb func(deposit types.D
}
// IterateDeposits iterates over the all the proposals deposits and performs a callback function
func (keeper Keeper) IterateDeposits(ctx sdk.Context, proposalID uint64, cb func(deposit types.Deposit) (stop bool)) {
func (keeper Keeper) IterateDeposits(ctx sdk.Context, proposalID uint64, cb func(deposit v1beta1.Deposit) (stop bool)) {
store := ctx.KVStore(keeper.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.DepositsKey(proposalID))
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
var deposit types.Deposit
var deposit v1beta1.Deposit
keeper.cdc.MustUnmarshal(iterator.Value(), &deposit)
@ -118,12 +119,12 @@ func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAdd
}
// Check if proposal is still depositable
if (proposal.Status != types.StatusDepositPeriod) && (proposal.Status != types.StatusVotingPeriod) {
if (proposal.Status != v1beta1.StatusDepositPeriod) && (proposal.Status != v1beta1.StatusVotingPeriod) {
return false, sdkerrors.Wrapf(types.ErrInactiveProposal, "%d", proposalID)
}
// update the governance module's account coins pool
err := keeper.bankKeeper.SendCoinsFromAccountToModule(ctx, depositorAddr, types.ModuleName, depositAmount)
err := keeper.bankKeeper.SendCoinsFromAccountToModule(ctx, depositorAddr, v1beta1.ModuleName, depositAmount)
if err != nil {
return false, err
}
@ -135,7 +136,7 @@ func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAdd
// Check if deposit has provided sufficient total funds to transition the proposal into the voting period
activatedVotingPeriod := false
if proposal.Status == types.StatusDepositPeriod && proposal.TotalDeposit.IsAllGTE(keeper.GetDepositParams(ctx).MinDeposit) {
if proposal.Status == v1beta1.StatusDepositPeriod && proposal.TotalDeposit.IsAllGTE(keeper.GetDepositParams(ctx).MinDeposit) {
keeper.ActivateVotingPeriod(ctx, proposal)
activatedVotingPeriod = true
@ -147,7 +148,7 @@ func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAdd
if found {
deposit.Amount = deposit.Amount.Add(depositAmount...)
} else {
deposit = types.NewDeposit(proposalID, depositorAddr, depositAmount)
deposit = v1beta1.NewDeposit(proposalID, depositorAddr, depositAmount)
}
// called when deposit has been added to a proposal, however the proposal may not be active
@ -170,13 +171,13 @@ func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAdd
func (keeper Keeper) RefundAndDeleteDeposits(ctx sdk.Context, proposalID uint64) {
store := ctx.KVStore(keeper.storeKey)
keeper.IterateDeposits(ctx, proposalID, func(deposit types.Deposit) bool {
keeper.IterateDeposits(ctx, proposalID, func(deposit v1beta1.Deposit) bool {
depositor, err := sdk.AccAddressFromBech32(deposit.Depositor)
if err != nil {
panic(err)
}
err = keeper.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, depositor, deposit.Amount)
err = keeper.bankKeeper.SendCoinsFromModuleToAccount(ctx, v1beta1.ModuleName, depositor, deposit.Amount)
if err != nil {
panic(err)
}

View File

@ -10,12 +10,13 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
var _ types.QueryServer = Keeper{}
var _ v1beta1.QueryServer = Keeper{}
// Proposal returns proposal details based on ProposalID
func (q Keeper) Proposal(c context.Context, req *types.QueryProposalRequest) (*types.QueryProposalResponse, error) {
func (q Keeper) Proposal(c context.Context, req *v1beta1.QueryProposalRequest) (*v1beta1.QueryProposalResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
@ -31,19 +32,19 @@ func (q Keeper) Proposal(c context.Context, req *types.QueryProposalRequest) (*t
return nil, status.Errorf(codes.NotFound, "proposal %d doesn't exist", req.ProposalId)
}
return &types.QueryProposalResponse{Proposal: proposal}, nil
return &v1beta1.QueryProposalResponse{Proposal: proposal}, nil
}
// Proposals implements the Query/Proposals gRPC method
func (q Keeper) Proposals(c context.Context, req *types.QueryProposalsRequest) (*types.QueryProposalsResponse, error) {
var filteredProposals types.Proposals
func (q Keeper) Proposals(c context.Context, req *v1beta1.QueryProposalsRequest) (*v1beta1.QueryProposalsResponse, error) {
var filteredProposals v1beta1.Proposals
ctx := sdk.UnwrapSDKContext(c)
store := ctx.KVStore(q.storeKey)
proposalStore := prefix.NewStore(store, types.ProposalsKeyPrefix)
pageRes, err := query.FilteredPaginate(proposalStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) {
var p types.Proposal
var p v1beta1.Proposal
if err := q.cdc.Unmarshal(value, &p); err != nil {
return false, status.Error(codes.Internal, err.Error())
}
@ -51,7 +52,7 @@ func (q Keeper) Proposals(c context.Context, req *types.QueryProposalsRequest) (
matchVoter, matchDepositor, matchStatus := true, true, true
// match status (if supplied/valid)
if types.ValidProposalStatus(req.ProposalStatus) {
if v1beta1.ValidProposalStatus(req.ProposalStatus) {
matchStatus = p.Status == req.ProposalStatus
}
@ -89,11 +90,11 @@ func (q Keeper) Proposals(c context.Context, req *types.QueryProposalsRequest) (
return nil, status.Error(codes.Internal, err.Error())
}
return &types.QueryProposalsResponse{Proposals: filteredProposals, Pagination: pageRes}, nil
return &v1beta1.QueryProposalsResponse{Proposals: filteredProposals, Pagination: pageRes}, nil
}
// Vote returns Voted information based on proposalID, voterAddr
func (q Keeper) Vote(c context.Context, req *types.QueryVoteRequest) (*types.QueryVoteResponse, error) {
func (q Keeper) Vote(c context.Context, req *v1beta1.QueryVoteRequest) (*v1beta1.QueryVoteResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
@ -118,11 +119,11 @@ func (q Keeper) Vote(c context.Context, req *types.QueryVoteRequest) (*types.Que
"voter: %v not found for proposal: %v", req.Voter, req.ProposalId)
}
return &types.QueryVoteResponse{Vote: vote}, nil
return &v1beta1.QueryVoteResponse{Vote: vote}, nil
}
// Votes returns single proposal's votes
func (q Keeper) Votes(c context.Context, req *types.QueryVotesRequest) (*types.QueryVotesResponse, error) {
func (q Keeper) Votes(c context.Context, req *v1beta1.QueryVotesRequest) (*v1beta1.QueryVotesResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
@ -131,14 +132,14 @@ func (q Keeper) Votes(c context.Context, req *types.QueryVotesRequest) (*types.Q
return nil, status.Error(codes.InvalidArgument, "proposal id can not be 0")
}
var votes types.Votes
var votes v1beta1.Votes
ctx := sdk.UnwrapSDKContext(c)
store := ctx.KVStore(q.storeKey)
votesStore := prefix.NewStore(store, types.VotesKey(req.ProposalId))
pageRes, err := query.Paginate(votesStore, req.Pagination, func(key []byte, value []byte) error {
var vote types.Vote
var vote v1beta1.Vote
if err := q.cdc.Unmarshal(value, &vote); err != nil {
return err
}
@ -152,11 +153,11 @@ func (q Keeper) Votes(c context.Context, req *types.QueryVotesRequest) (*types.Q
return nil, status.Error(codes.Internal, err.Error())
}
return &types.QueryVotesResponse{Votes: votes, Pagination: pageRes}, nil
return &v1beta1.QueryVotesResponse{Votes: votes, Pagination: pageRes}, nil
}
// Params queries all params
func (q Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
func (q Keeper) Params(c context.Context, req *v1beta1.QueryParamsRequest) (*v1beta1.QueryParamsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
@ -164,17 +165,17 @@ func (q Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types
ctx := sdk.UnwrapSDKContext(c)
switch req.ParamsType {
case types.ParamDeposit:
case v1beta1.ParamDeposit:
depositParmas := q.GetDepositParams(ctx)
return &types.QueryParamsResponse{DepositParams: depositParmas}, nil
return &v1beta1.QueryParamsResponse{DepositParams: depositParmas}, nil
case types.ParamVoting:
case v1beta1.ParamVoting:
votingParmas := q.GetVotingParams(ctx)
return &types.QueryParamsResponse{VotingParams: votingParmas}, nil
return &v1beta1.QueryParamsResponse{VotingParams: votingParmas}, nil
case types.ParamTallying:
case v1beta1.ParamTallying:
tallyParams := q.GetTallyParams(ctx)
return &types.QueryParamsResponse{TallyParams: tallyParams}, nil
return &v1beta1.QueryParamsResponse{TallyParams: tallyParams}, nil
default:
return nil, status.Errorf(codes.InvalidArgument,
@ -183,7 +184,7 @@ func (q Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types
}
// Deposit queries single deposit information based proposalID, depositAddr
func (q Keeper) Deposit(c context.Context, req *types.QueryDepositRequest) (*types.QueryDepositResponse, error) {
func (q Keeper) Deposit(c context.Context, req *v1beta1.QueryDepositRequest) (*v1beta1.QueryDepositResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
@ -208,11 +209,11 @@ func (q Keeper) Deposit(c context.Context, req *types.QueryDepositRequest) (*typ
"depositer: %v not found for proposal: %v", req.Depositor, req.ProposalId)
}
return &types.QueryDepositResponse{Deposit: deposit}, nil
return &v1beta1.QueryDepositResponse{Deposit: deposit}, nil
}
// Deposits returns single proposal's all deposits
func (q Keeper) Deposits(c context.Context, req *types.QueryDepositsRequest) (*types.QueryDepositsResponse, error) {
func (q Keeper) Deposits(c context.Context, req *v1beta1.QueryDepositsRequest) (*v1beta1.QueryDepositsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
@ -221,14 +222,14 @@ func (q Keeper) Deposits(c context.Context, req *types.QueryDepositsRequest) (*t
return nil, status.Error(codes.InvalidArgument, "proposal id can not be 0")
}
var deposits types.Deposits
var deposits v1beta1.Deposits
ctx := sdk.UnwrapSDKContext(c)
store := ctx.KVStore(q.storeKey)
depositStore := prefix.NewStore(store, types.DepositsKey(req.ProposalId))
pageRes, err := query.Paginate(depositStore, req.Pagination, func(key []byte, value []byte) error {
var deposit types.Deposit
var deposit v1beta1.Deposit
if err := q.cdc.Unmarshal(value, &deposit); err != nil {
return err
}
@ -241,11 +242,11 @@ func (q Keeper) Deposits(c context.Context, req *types.QueryDepositsRequest) (*t
return nil, status.Error(codes.Internal, err.Error())
}
return &types.QueryDepositsResponse{Deposits: deposits, Pagination: pageRes}, nil
return &v1beta1.QueryDepositsResponse{Deposits: deposits, Pagination: pageRes}, nil
}
// TallyResult queries the tally of a proposal vote
func (q Keeper) TallyResult(c context.Context, req *types.QueryTallyResultRequest) (*types.QueryTallyResultResponse, error) {
func (q Keeper) TallyResult(c context.Context, req *v1beta1.QueryTallyResultRequest) (*v1beta1.QueryTallyResultResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
@ -261,13 +262,13 @@ func (q Keeper) TallyResult(c context.Context, req *types.QueryTallyResultReques
return nil, status.Errorf(codes.NotFound, "proposal %d doesn't exist", req.ProposalId)
}
var tallyResult types.TallyResult
var tallyResult v1beta1.TallyResult
switch {
case proposal.Status == types.StatusDepositPeriod:
tallyResult = types.EmptyTallyResult()
case proposal.Status == v1beta1.StatusDepositPeriod:
tallyResult = v1beta1.EmptyTallyResult()
case proposal.Status == types.StatusPassed || proposal.Status == types.StatusRejected:
case proposal.Status == v1beta1.StatusPassed || proposal.Status == v1beta1.StatusRejected:
tallyResult = proposal.FinalTallyResult
default:
@ -275,5 +276,5 @@ func (q Keeper) TallyResult(c context.Context, req *types.QueryTallyResultReques
_, _, tallyResult = q.Tally(ctx, proposal)
}
return &types.QueryTallyResultResponse{Tally: tallyResult}, nil
return &v1beta1.QueryTallyResultResponse{Tally: tallyResult}, nil
}

View File

@ -8,15 +8,15 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
func (suite *KeeperTestSuite) TestGRPCQueryProposal() {
app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient
var (
req *types.QueryProposalRequest
expProposal types.Proposal
req *v1beta1.QueryProposalRequest
expProposal v1beta1.Proposal
)
testCases := []struct {
@ -27,29 +27,29 @@ func (suite *KeeperTestSuite) TestGRPCQueryProposal() {
{
"empty request",
func() {
req = &types.QueryProposalRequest{}
req = &v1beta1.QueryProposalRequest{}
},
false,
},
{
"non existing proposal request",
func() {
req = &types.QueryProposalRequest{ProposalId: 3}
req = &v1beta1.QueryProposalRequest{ProposalId: 3}
},
false,
},
{
"zero proposal id request",
func() {
req = &types.QueryProposalRequest{ProposalId: 0}
req = &v1beta1.QueryProposalRequest{ProposalId: 0}
},
false,
},
{
"valid request",
func() {
req = &types.QueryProposalRequest{ProposalId: 1}
testProposal := types.NewTextProposal("Proposal", "testing proposal")
req = &v1beta1.QueryProposalRequest{ProposalId: 1}
testProposal := v1beta1.NewTextProposal("Proposal", "testing proposal")
submittedProposal, err := app.GovKeeper.SubmitProposal(ctx, testProposal)
suite.Require().NoError(err)
suite.Require().NotEmpty(submittedProposal)
@ -80,11 +80,11 @@ func (suite *KeeperTestSuite) TestGRPCQueryProposal() {
func (suite *KeeperTestSuite) TestGRPCQueryProposals() {
app, ctx, queryClient, addrs := suite.app, suite.ctx, suite.queryClient, suite.addrs
testProposals := []types.Proposal{}
testProposals := []v1beta1.Proposal{}
var (
req *types.QueryProposalsRequest
expRes *types.QueryProposalsResponse
req *v1beta1.QueryProposalsRequest
expRes *v1beta1.QueryProposalsResponse
)
testCases := []struct {
@ -95,7 +95,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryProposals() {
{
"empty state request",
func() {
req = &types.QueryProposalsRequest{}
req = &v1beta1.QueryProposalsRequest{}
},
true,
},
@ -105,18 +105,18 @@ func (suite *KeeperTestSuite) TestGRPCQueryProposals() {
// create 5 test proposals
for i := 0; i < 5; i++ {
num := strconv.Itoa(i + 1)
testProposal := types.NewTextProposal("Proposal"+num, "testing proposal "+num)
testProposal := v1beta1.NewTextProposal("Proposal"+num, "testing proposal "+num)
proposal, err := app.GovKeeper.SubmitProposal(ctx, testProposal)
suite.Require().NotEmpty(proposal)
suite.Require().NoError(err)
testProposals = append(testProposals, proposal)
}
req = &types.QueryProposalsRequest{
req = &v1beta1.QueryProposalsRequest{
Pagination: &query.PageRequest{Limit: 3},
}
expRes = &types.QueryProposalsResponse{
expRes = &v1beta1.QueryProposalsResponse{
Proposals: testProposals[:3],
}
},
@ -125,11 +125,11 @@ func (suite *KeeperTestSuite) TestGRPCQueryProposals() {
{
"request 2nd page with limit 4",
func() {
req = &types.QueryProposalsRequest{
req = &v1beta1.QueryProposalsRequest{
Pagination: &query.PageRequest{Offset: 3, Limit: 3},
}
expRes = &types.QueryProposalsResponse{
expRes = &v1beta1.QueryProposalsResponse{
Proposals: testProposals[3:],
}
},
@ -138,11 +138,11 @@ func (suite *KeeperTestSuite) TestGRPCQueryProposals() {
{
"request with limit 2 and count true",
func() {
req = &types.QueryProposalsRequest{
req = &v1beta1.QueryProposalsRequest{
Pagination: &query.PageRequest{Limit: 2, CountTotal: true},
}
expRes = &types.QueryProposalsResponse{
expRes = &v1beta1.QueryProposalsResponse{
Proposals: testProposals[:2],
}
},
@ -151,11 +151,11 @@ func (suite *KeeperTestSuite) TestGRPCQueryProposals() {
{
"request with filter of status deposit period",
func() {
req = &types.QueryProposalsRequest{
ProposalStatus: types.StatusDepositPeriod,
req = &v1beta1.QueryProposalsRequest{
ProposalStatus: v1beta1.StatusDepositPeriod,
}
expRes = &types.QueryProposalsResponse{
expRes = &v1beta1.QueryProposalsResponse{
Proposals: testProposals,
}
},
@ -165,14 +165,14 @@ func (suite *KeeperTestSuite) TestGRPCQueryProposals() {
"request with filter of deposit address",
func() {
depositCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 20)))
deposit := types.NewDeposit(testProposals[0].ProposalId, addrs[0], depositCoins)
deposit := v1beta1.NewDeposit(testProposals[0].ProposalId, addrs[0], depositCoins)
app.GovKeeper.SetDeposit(ctx, deposit)
req = &types.QueryProposalsRequest{
req = &v1beta1.QueryProposalsRequest{
Depositor: addrs[0].String(),
}
expRes = &types.QueryProposalsResponse{
expRes = &v1beta1.QueryProposalsResponse{
Proposals: testProposals[:1],
}
},
@ -181,15 +181,15 @@ func (suite *KeeperTestSuite) TestGRPCQueryProposals() {
{
"request with filter of deposit address",
func() {
testProposals[1].Status = types.StatusVotingPeriod
testProposals[1].Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, testProposals[1])
suite.Require().NoError(app.GovKeeper.AddVote(ctx, testProposals[1].ProposalId, addrs[0], types.NewNonSplitVoteOption(types.OptionAbstain)))
suite.Require().NoError(app.GovKeeper.AddVote(ctx, testProposals[1].ProposalId, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionAbstain)))
req = &types.QueryProposalsRequest{
req = &v1beta1.QueryProposalsRequest{
Voter: addrs[0].String(),
}
expRes = &types.QueryProposalsResponse{
expRes = &v1beta1.QueryProposalsResponse{
Proposals: testProposals[1:2],
}
},
@ -223,9 +223,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryVote() {
app, ctx, queryClient, addrs := suite.app, suite.ctx, suite.queryClient, suite.addrs
var (
req *types.QueryVoteRequest
expRes *types.QueryVoteResponse
proposal types.Proposal
req *v1beta1.QueryVoteRequest
expRes *v1beta1.QueryVoteResponse
proposal v1beta1.Proposal
)
testCases := []struct {
@ -236,14 +236,14 @@ func (suite *KeeperTestSuite) TestGRPCQueryVote() {
{
"empty request",
func() {
req = &types.QueryVoteRequest{}
req = &v1beta1.QueryVoteRequest{}
},
false,
},
{
"zero proposal id request",
func() {
req = &types.QueryVoteRequest{
req = &v1beta1.QueryVoteRequest{
ProposalId: 0,
Voter: addrs[0].String(),
}
@ -253,7 +253,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryVote() {
{
"empty voter request",
func() {
req = &types.QueryVoteRequest{
req = &v1beta1.QueryVoteRequest{
ProposalId: 1,
Voter: "",
}
@ -263,7 +263,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryVote() {
{
"non existed proposal",
func() {
req = &types.QueryVoteRequest{
req = &v1beta1.QueryVoteRequest{
ProposalId: 3,
Voter: addrs[0].String(),
}
@ -277,40 +277,40 @@ func (suite *KeeperTestSuite) TestGRPCQueryVote() {
proposal, err = app.GovKeeper.SubmitProposal(ctx, TestProposal)
suite.Require().NoError(err)
req = &types.QueryVoteRequest{
req = &v1beta1.QueryVoteRequest{
ProposalId: proposal.ProposalId,
Voter: addrs[0].String(),
}
expRes = &types.QueryVoteResponse{}
expRes = &v1beta1.QueryVoteResponse{}
},
false,
},
{
"valid request",
func() {
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
suite.Require().NoError(app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], types.NewNonSplitVoteOption(types.OptionAbstain)))
suite.Require().NoError(app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionAbstain)))
req = &types.QueryVoteRequest{
req = &v1beta1.QueryVoteRequest{
ProposalId: proposal.ProposalId,
Voter: addrs[0].String(),
}
expRes = &types.QueryVoteResponse{Vote: types.Vote{ProposalId: proposal.ProposalId, Voter: addrs[0].String(), Option: types.OptionAbstain, Options: []types.WeightedVoteOption{{Option: types.OptionAbstain, Weight: sdk.MustNewDecFromStr("1.0")}}}}
expRes = &v1beta1.QueryVoteResponse{Vote: v1beta1.Vote{ProposalId: proposal.ProposalId, Voter: addrs[0].String(), Option: v1beta1.OptionAbstain, Options: []v1beta1.WeightedVoteOption{{Option: v1beta1.OptionAbstain, Weight: sdk.MustNewDecFromStr("1.0")}}}}
},
true,
},
{
"wrong voter id request",
func() {
req = &types.QueryVoteRequest{
req = &v1beta1.QueryVoteRequest{
ProposalId: proposal.ProposalId,
Voter: addrs[1].String(),
}
expRes = &types.QueryVoteResponse{}
expRes = &v1beta1.QueryVoteResponse{}
},
false,
},
@ -339,10 +339,10 @@ func (suite *KeeperTestSuite) TestGRPCQueryVotes() {
addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(30000000))
var (
req *types.QueryVotesRequest
expRes *types.QueryVotesResponse
proposal types.Proposal
votes types.Votes
req *v1beta1.QueryVotesRequest
expRes *v1beta1.QueryVotesResponse
proposal v1beta1.Proposal
votes v1beta1.Votes
)
testCases := []struct {
@ -353,14 +353,14 @@ func (suite *KeeperTestSuite) TestGRPCQueryVotes() {
{
"empty request",
func() {
req = &types.QueryVotesRequest{}
req = &v1beta1.QueryVotesRequest{}
},
false,
},
{
"zero proposal id request",
func() {
req = &types.QueryVotesRequest{
req = &v1beta1.QueryVotesRequest{
ProposalId: 0,
}
},
@ -369,7 +369,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryVotes() {
{
"non existed proposals",
func() {
req = &types.QueryVotesRequest{
req = &v1beta1.QueryVotesRequest{
ProposalId: 2,
}
},
@ -382,7 +382,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryVotes() {
proposal, err = app.GovKeeper.SubmitProposal(ctx, TestProposal)
suite.Require().NoError(err)
req = &types.QueryVotesRequest{
req = &v1beta1.QueryVotesRequest{
ProposalId: proposal.ProposalId,
}
},
@ -391,12 +391,12 @@ func (suite *KeeperTestSuite) TestGRPCQueryVotes() {
{
"request after adding 2 votes",
func() {
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
votes = []types.Vote{
{ProposalId: proposal.ProposalId, Voter: addrs[0].String(), Option: types.OptionAbstain, Options: types.NewNonSplitVoteOption(types.OptionAbstain)},
{ProposalId: proposal.ProposalId, Voter: addrs[1].String(), Option: types.OptionYes, Options: types.NewNonSplitVoteOption(types.OptionYes)},
votes = []v1beta1.Vote{
{ProposalId: proposal.ProposalId, Voter: addrs[0].String(), Option: v1beta1.OptionAbstain, Options: v1beta1.NewNonSplitVoteOption(v1beta1.OptionAbstain)},
{ProposalId: proposal.ProposalId, Voter: addrs[1].String(), Option: v1beta1.OptionYes, Options: v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)},
}
accAddr1, err1 := sdk.AccAddressFromBech32(votes[0].Voter)
accAddr2, err2 := sdk.AccAddressFromBech32(votes[1].Voter)
@ -405,11 +405,11 @@ func (suite *KeeperTestSuite) TestGRPCQueryVotes() {
suite.Require().NoError(app.GovKeeper.AddVote(ctx, proposal.ProposalId, accAddr1, votes[0].Options))
suite.Require().NoError(app.GovKeeper.AddVote(ctx, proposal.ProposalId, accAddr2, votes[1].Options))
req = &types.QueryVotesRequest{
req = &v1beta1.QueryVotesRequest{
ProposalId: proposal.ProposalId,
}
expRes = &types.QueryVotesResponse{
expRes = &v1beta1.QueryVotesResponse{
Votes: votes,
}
},
@ -438,8 +438,8 @@ func (suite *KeeperTestSuite) TestGRPCQueryParams() {
queryClient := suite.queryClient
var (
req *types.QueryParamsRequest
expRes *types.QueryParamsResponse
req *v1beta1.QueryParamsRequest
expRes *v1beta1.QueryParamsResponse
)
testCases := []struct {
@ -450,17 +450,17 @@ func (suite *KeeperTestSuite) TestGRPCQueryParams() {
{
"empty request",
func() {
req = &types.QueryParamsRequest{}
req = &v1beta1.QueryParamsRequest{}
},
false,
},
{
"deposit params request",
func() {
req = &types.QueryParamsRequest{ParamsType: types.ParamDeposit}
expRes = &types.QueryParamsResponse{
DepositParams: types.DefaultDepositParams(),
TallyParams: types.NewTallyParams(sdk.NewDec(0), sdk.NewDec(0), sdk.NewDec(0)),
req = &v1beta1.QueryParamsRequest{ParamsType: v1beta1.ParamDeposit}
expRes = &v1beta1.QueryParamsResponse{
DepositParams: v1beta1.DefaultDepositParams(),
TallyParams: v1beta1.NewTallyParams(sdk.NewDec(0), sdk.NewDec(0), sdk.NewDec(0)),
}
},
true,
@ -468,10 +468,10 @@ func (suite *KeeperTestSuite) TestGRPCQueryParams() {
{
"voting params request",
func() {
req = &types.QueryParamsRequest{ParamsType: types.ParamVoting}
expRes = &types.QueryParamsResponse{
VotingParams: types.DefaultVotingParams(),
TallyParams: types.NewTallyParams(sdk.NewDec(0), sdk.NewDec(0), sdk.NewDec(0)),
req = &v1beta1.QueryParamsRequest{ParamsType: v1beta1.ParamVoting}
expRes = &v1beta1.QueryParamsResponse{
VotingParams: v1beta1.DefaultVotingParams(),
TallyParams: v1beta1.NewTallyParams(sdk.NewDec(0), sdk.NewDec(0), sdk.NewDec(0)),
}
},
true,
@ -479,9 +479,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryParams() {
{
"tally params request",
func() {
req = &types.QueryParamsRequest{ParamsType: types.ParamTallying}
expRes = &types.QueryParamsResponse{
TallyParams: types.DefaultTallyParams(),
req = &v1beta1.QueryParamsRequest{ParamsType: v1beta1.ParamTallying}
expRes = &v1beta1.QueryParamsResponse{
TallyParams: v1beta1.DefaultTallyParams(),
}
},
true,
@ -489,8 +489,8 @@ func (suite *KeeperTestSuite) TestGRPCQueryParams() {
{
"invalid request",
func() {
req = &types.QueryParamsRequest{ParamsType: "wrongPath"}
expRes = &types.QueryParamsResponse{}
req = &v1beta1.QueryParamsRequest{ParamsType: "wrongPath"}
expRes = &v1beta1.QueryParamsResponse{}
},
false,
},
@ -519,9 +519,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryDeposit() {
app, ctx, queryClient, addrs := suite.app, suite.ctx, suite.queryClient, suite.addrs
var (
req *types.QueryDepositRequest
expRes *types.QueryDepositResponse
proposal types.Proposal
req *v1beta1.QueryDepositRequest
expRes *v1beta1.QueryDepositResponse
proposal v1beta1.Proposal
)
testCases := []struct {
@ -532,14 +532,14 @@ func (suite *KeeperTestSuite) TestGRPCQueryDeposit() {
{
"empty request",
func() {
req = &types.QueryDepositRequest{}
req = &v1beta1.QueryDepositRequest{}
},
false,
},
{
"zero proposal id request",
func() {
req = &types.QueryDepositRequest{
req = &v1beta1.QueryDepositRequest{
ProposalId: 0,
Depositor: addrs[0].String(),
}
@ -549,7 +549,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryDeposit() {
{
"empty deposit address request",
func() {
req = &types.QueryDepositRequest{
req = &v1beta1.QueryDepositRequest{
ProposalId: 1,
Depositor: "",
}
@ -559,7 +559,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryDeposit() {
{
"non existed proposal",
func() {
req = &types.QueryDepositRequest{
req = &v1beta1.QueryDepositRequest{
ProposalId: 2,
Depositor: addrs[0].String(),
}
@ -574,7 +574,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryDeposit() {
suite.Require().NoError(err)
suite.Require().NotNil(proposal)
req = &types.QueryDepositRequest{
req = &v1beta1.QueryDepositRequest{
ProposalId: proposal.ProposalId,
Depositor: addrs[0].String(),
}
@ -585,15 +585,15 @@ func (suite *KeeperTestSuite) TestGRPCQueryDeposit() {
"valid request",
func() {
depositCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 20)))
deposit := types.NewDeposit(proposal.ProposalId, addrs[0], depositCoins)
deposit := v1beta1.NewDeposit(proposal.ProposalId, addrs[0], depositCoins)
app.GovKeeper.SetDeposit(ctx, deposit)
req = &types.QueryDepositRequest{
req = &v1beta1.QueryDepositRequest{
ProposalId: proposal.ProposalId,
Depositor: addrs[0].String(),
}
expRes = &types.QueryDepositResponse{Deposit: deposit}
expRes = &v1beta1.QueryDepositResponse{Deposit: deposit}
},
true,
},
@ -620,9 +620,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryDeposits() {
app, ctx, queryClient, addrs := suite.app, suite.ctx, suite.queryClient, suite.addrs
var (
req *types.QueryDepositsRequest
expRes *types.QueryDepositsResponse
proposal types.Proposal
req *v1beta1.QueryDepositsRequest
expRes *v1beta1.QueryDepositsResponse
proposal v1beta1.Proposal
)
testCases := []struct {
@ -633,14 +633,14 @@ func (suite *KeeperTestSuite) TestGRPCQueryDeposits() {
{
"empty request",
func() {
req = &types.QueryDepositsRequest{}
req = &v1beta1.QueryDepositsRequest{}
},
false,
},
{
"zero proposal id request",
func() {
req = &types.QueryDepositsRequest{
req = &v1beta1.QueryDepositsRequest{
ProposalId: 0,
}
},
@ -649,7 +649,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryDeposits() {
{
"non existed proposal",
func() {
req = &types.QueryDepositsRequest{
req = &v1beta1.QueryDepositsRequest{
ProposalId: 2,
}
},
@ -662,7 +662,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryDeposits() {
proposal, err = app.GovKeeper.SubmitProposal(ctx, TestProposal)
suite.Require().NoError(err)
req = &types.QueryDepositsRequest{
req = &v1beta1.QueryDepositsRequest{
ProposalId: proposal.ProposalId,
}
},
@ -672,20 +672,20 @@ func (suite *KeeperTestSuite) TestGRPCQueryDeposits() {
"get deposits with default limit",
func() {
depositAmount1 := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 20)))
deposit1 := types.NewDeposit(proposal.ProposalId, addrs[0], depositAmount1)
deposit1 := v1beta1.NewDeposit(proposal.ProposalId, addrs[0], depositAmount1)
app.GovKeeper.SetDeposit(ctx, deposit1)
depositAmount2 := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 30)))
deposit2 := types.NewDeposit(proposal.ProposalId, addrs[1], depositAmount2)
deposit2 := v1beta1.NewDeposit(proposal.ProposalId, addrs[1], depositAmount2)
app.GovKeeper.SetDeposit(ctx, deposit2)
deposits := types.Deposits{deposit1, deposit2}
deposits := v1beta1.Deposits{deposit1, deposit2}
req = &types.QueryDepositsRequest{
req = &v1beta1.QueryDepositsRequest{
ProposalId: proposal.ProposalId,
}
expRes = &types.QueryDepositsResponse{
expRes = &v1beta1.QueryDepositsResponse{
Deposits: deposits,
}
},
@ -716,9 +716,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryTally() {
addrs, _ := createValidators(suite.T(), ctx, app, []int64{5, 5, 5})
var (
req *types.QueryTallyResultRequest
expRes *types.QueryTallyResultResponse
proposal types.Proposal
req *v1beta1.QueryTallyResultRequest
expRes *v1beta1.QueryTallyResultResponse
proposal v1beta1.Proposal
)
testCases := []struct {
@ -729,21 +729,21 @@ func (suite *KeeperTestSuite) TestGRPCQueryTally() {
{
"empty request",
func() {
req = &types.QueryTallyResultRequest{}
req = &v1beta1.QueryTallyResultRequest{}
},
false,
},
{
"zero proposal id request",
func() {
req = &types.QueryTallyResultRequest{ProposalId: 0}
req = &v1beta1.QueryTallyResultRequest{ProposalId: 0}
},
false,
},
{
"query non existed proposal",
func() {
req = &types.QueryTallyResultRequest{ProposalId: 1}
req = &v1beta1.QueryTallyResultRequest{ProposalId: 1}
},
false,
},
@ -755,10 +755,10 @@ func (suite *KeeperTestSuite) TestGRPCQueryTally() {
suite.Require().NoError(err)
suite.Require().NotNil(proposal)
req = &types.QueryTallyResultRequest{ProposalId: proposal.ProposalId}
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.ProposalId}
expRes = &types.QueryTallyResultResponse{
Tally: types.EmptyTallyResult(),
expRes = &v1beta1.QueryTallyResultResponse{
Tally: v1beta1.EmptyTallyResult(),
}
},
true,
@ -766,17 +766,17 @@ func (suite *KeeperTestSuite) TestGRPCQueryTally() {
{
"request tally after few votes",
func() {
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
suite.Require().NoError(app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], types.NewNonSplitVoteOption(types.OptionYes)))
suite.Require().NoError(app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[1], types.NewNonSplitVoteOption(types.OptionYes)))
suite.Require().NoError(app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[2], types.NewNonSplitVoteOption(types.OptionYes)))
suite.Require().NoError(app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
suite.Require().NoError(app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[1], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
suite.Require().NoError(app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[2], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
req = &types.QueryTallyResultRequest{ProposalId: proposal.ProposalId}
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.ProposalId}
expRes = &types.QueryTallyResultResponse{
Tally: types.TallyResult{
expRes = &v1beta1.QueryTallyResultResponse{
Tally: v1beta1.TallyResult{
Yes: sdk.NewInt(3 * 5 * 1000000),
},
}
@ -786,13 +786,13 @@ func (suite *KeeperTestSuite) TestGRPCQueryTally() {
{
"request final tally after status changed",
func() {
proposal.Status = types.StatusPassed
proposal.Status = v1beta1.StatusPassed
app.GovKeeper.SetProposal(ctx, proposal)
proposal, _ = app.GovKeeper.GetProposal(ctx, proposal.ProposalId)
req = &types.QueryTallyResultRequest{ProposalId: proposal.ProposalId}
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.ProposalId}
expRes = &types.QueryTallyResultResponse{
expRes = &v1beta1.QueryTallyResultResponse{
Tally: proposal.FinalTallyResult,
}
},

View File

@ -12,6 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
var _ types.GovHooks = &MockGovHooksReceiver{}
@ -82,7 +83,7 @@ func TestHooks(t *testing.T) {
require.NoError(t, err)
require.True(t, govHooksReceiver.AfterProposalDepositValid)
err = app.GovKeeper.AddVote(ctx, p2.ProposalId, addrs[0], types.NewNonSplitVoteOption(types.OptionYes))
err = app.GovKeeper.AddVote(ctx, p2.ProposalId, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes))
require.NoError(t, err)
require.True(t, govHooksReceiver.AfterProposalVoteValid)

View File

@ -7,6 +7,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// RegisterInvariants registers all governance invariants
@ -27,7 +28,7 @@ func ModuleAccountInvariant(keeper Keeper, bk types.BankKeeper) sdk.Invariant {
return func(ctx sdk.Context) (string, bool) {
var expectedDeposits sdk.Coins
keeper.IterateAllDeposits(ctx, func(deposit types.Deposit) bool {
keeper.IterateAllDeposits(ctx, func(deposit v1beta1.Deposit) bool {
expectedDeposits = expectedDeposits.Add(deposit.Amount...)
return false
})

View File

@ -11,6 +11,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// Keeper defines the governance module Keeper
@ -34,7 +35,7 @@ type Keeper struct {
cdc codec.BinaryCodec
// Proposal router
router types.Router
router v1beta1.Router
}
// NewKeeper returns a governance keeper. It handles:
@ -46,7 +47,7 @@ type Keeper struct {
// CONTRACT: the parameter Subspace must have the param key table already initialized
func NewKeeper(
cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace types.ParamSubspace,
authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper, rtr types.Router,
authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper, rtr v1beta1.Router,
) Keeper {
// ensure governance module account is set
@ -87,7 +88,7 @@ func (keeper Keeper) Logger(ctx sdk.Context) log.Logger {
}
// Router returns the gov Keeper's Router
func (keeper Keeper) Router() types.Router {
func (keeper Keeper) Router() v1beta1.Router {
return keeper.router
}
@ -128,7 +129,7 @@ func (keeper Keeper) RemoveFromInactiveProposalQueue(ctx sdk.Context, proposalID
// IterateActiveProposalsQueue iterates over the proposals in the active proposal queue
// and performs a callback function
func (keeper Keeper) IterateActiveProposalsQueue(ctx sdk.Context, endTime time.Time, cb func(proposal types.Proposal) (stop bool)) {
func (keeper Keeper) IterateActiveProposalsQueue(ctx sdk.Context, endTime time.Time, cb func(proposal v1beta1.Proposal) (stop bool)) {
iterator := keeper.ActiveProposalQueueIterator(ctx, endTime)
defer iterator.Close()
@ -147,7 +148,7 @@ func (keeper Keeper) IterateActiveProposalsQueue(ctx sdk.Context, endTime time.T
// IterateInactiveProposalsQueue iterates over the proposals in the inactive proposal queue
// and performs a callback function
func (keeper Keeper) IterateInactiveProposalsQueue(ctx sdk.Context, endTime time.Time, cb func(proposal types.Proposal) (stop bool)) {
func (keeper Keeper) IterateInactiveProposalsQueue(ctx sdk.Context, endTime time.Time, cb func(proposal v1beta1.Proposal) (stop bool)) {
iterator := keeper.InactiveProposalQueueIterator(ctx, endTime)
defer iterator.Close()

View File

@ -11,6 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
type KeeperTestSuite struct {
@ -18,7 +19,7 @@ type KeeperTestSuite struct {
app *simapp.SimApp
ctx sdk.Context
queryClient types.QueryClient
queryClient v1beta1.QueryClient
addrs []sdk.AccAddress
}
@ -27,8 +28,8 @@ func (suite *KeeperTestSuite) SetupTest() {
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry())
types.RegisterQueryServer(queryHelper, app.GovKeeper)
queryClient := types.NewQueryClient(queryHelper)
v1beta1.RegisterQueryServer(queryHelper, app.GovKeeper)
queryClient := v1beta1.NewQueryClient(queryHelper)
suite.app = app
suite.ctx = ctx

View File

@ -11,6 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
type msgServer struct {
@ -19,13 +20,13 @@ type msgServer struct {
// NewMsgServerImpl returns an implementation of the gov MsgServer interface
// for the provided Keeper.
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
func NewMsgServerImpl(keeper Keeper) v1beta1.MsgServer {
return &msgServer{Keeper: keeper}
}
var _ types.MsgServer = msgServer{}
var _ v1beta1.MsgServer = msgServer{}
func (k msgServer) SubmitProposal(goCtx context.Context, msg *types.MsgSubmitProposal) (*types.MsgSubmitProposalResponse, error) {
func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1beta1.MsgSubmitProposal) (*v1beta1.MsgSubmitProposalResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
proposal, err := k.Keeper.SubmitProposal(ctx, msg.GetContent())
if err != nil {
@ -43,7 +44,7 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *types.MsgSubmitPro
"submit proposal",
)
defer telemetry.IncrCounter(1, types.ModuleName, "proposal")
defer telemetry.IncrCounter(1, v1beta1.ModuleName, "proposal")
votingStarted, err := k.Keeper.AddDeposit(ctx, proposal.ProposalId, msg.GetProposer(), msg.GetInitialDeposit())
if err != nil {
@ -66,24 +67,24 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *types.MsgSubmitPro
}
ctx.EventManager().EmitEvent(submitEvent)
return &types.MsgSubmitProposalResponse{
return &v1beta1.MsgSubmitProposalResponse{
ProposalId: proposal.ProposalId,
}, nil
}
func (k msgServer) Vote(goCtx context.Context, msg *types.MsgVote) (*types.MsgVoteResponse, error) {
func (k msgServer) Vote(goCtx context.Context, msg *v1beta1.MsgVote) (*v1beta1.MsgVoteResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
accAddr, accErr := sdk.AccAddressFromBech32(msg.Voter)
if accErr != nil {
return nil, accErr
}
err := k.Keeper.AddVote(ctx, msg.ProposalId, accAddr, types.NewNonSplitVoteOption(msg.Option))
err := k.Keeper.AddVote(ctx, msg.ProposalId, accAddr, v1beta1.NewNonSplitVoteOption(msg.Option))
if err != nil {
return nil, err
}
defer telemetry.IncrCounterWithLabels(
[]string{types.ModuleName, "vote"},
[]string{v1beta1.ModuleName, "vote"},
1,
[]metrics.Label{
telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))),
@ -98,10 +99,10 @@ func (k msgServer) Vote(goCtx context.Context, msg *types.MsgVote) (*types.MsgVo
),
)
return &types.MsgVoteResponse{}, nil
return &v1beta1.MsgVoteResponse{}, nil
}
func (k msgServer) VoteWeighted(goCtx context.Context, msg *types.MsgVoteWeighted) (*types.MsgVoteWeightedResponse, error) {
func (k msgServer) VoteWeighted(goCtx context.Context, msg *v1beta1.MsgVoteWeighted) (*v1beta1.MsgVoteWeightedResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
accAddr, accErr := sdk.AccAddressFromBech32(msg.Voter)
if accErr != nil {
@ -113,7 +114,7 @@ func (k msgServer) VoteWeighted(goCtx context.Context, msg *types.MsgVoteWeighte
}
defer telemetry.IncrCounterWithLabels(
[]string{types.ModuleName, "vote"},
[]string{v1beta1.ModuleName, "vote"},
1,
[]metrics.Label{
telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))),
@ -128,10 +129,10 @@ func (k msgServer) VoteWeighted(goCtx context.Context, msg *types.MsgVoteWeighte
),
)
return &types.MsgVoteWeightedResponse{}, nil
return &v1beta1.MsgVoteWeightedResponse{}, nil
}
func (k msgServer) Deposit(goCtx context.Context, msg *types.MsgDeposit) (*types.MsgDepositResponse, error) {
func (k msgServer) Deposit(goCtx context.Context, msg *v1beta1.MsgDeposit) (*v1beta1.MsgDepositResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
accAddr, err := sdk.AccAddressFromBech32(msg.Depositor)
if err != nil {
@ -143,7 +144,7 @@ func (k msgServer) Deposit(goCtx context.Context, msg *types.MsgDeposit) (*types
}
defer telemetry.IncrCounterWithLabels(
[]string{types.ModuleName, "deposit"},
[]string{v1beta1.ModuleName, "deposit"},
1,
[]metrics.Label{
telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))),
@ -167,5 +168,5 @@ func (k msgServer) Deposit(goCtx context.Context, msg *types.MsgDeposit) (*types
)
}
return &types.MsgDepositResponse{}, nil
return &v1beta1.MsgDepositResponse{}, nil
}

View File

@ -3,40 +3,41 @@ package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// GetDepositParams returns the current DepositParams from the global param store
func (keeper Keeper) GetDepositParams(ctx sdk.Context) types.DepositParams {
var depositParams types.DepositParams
func (keeper Keeper) GetDepositParams(ctx sdk.Context) v1beta1.DepositParams {
var depositParams v1beta1.DepositParams
keeper.paramSpace.Get(ctx, types.ParamStoreKeyDepositParams, &depositParams)
return depositParams
}
// GetVotingParams returns the current VotingParams from the global param store
func (keeper Keeper) GetVotingParams(ctx sdk.Context) types.VotingParams {
var votingParams types.VotingParams
func (keeper Keeper) GetVotingParams(ctx sdk.Context) v1beta1.VotingParams {
var votingParams v1beta1.VotingParams
keeper.paramSpace.Get(ctx, types.ParamStoreKeyVotingParams, &votingParams)
return votingParams
}
// GetTallyParams returns the current TallyParam from the global param store
func (keeper Keeper) GetTallyParams(ctx sdk.Context) types.TallyParams {
var tallyParams types.TallyParams
func (keeper Keeper) GetTallyParams(ctx sdk.Context) v1beta1.TallyParams {
var tallyParams v1beta1.TallyParams
keeper.paramSpace.Get(ctx, types.ParamStoreKeyTallyParams, &tallyParams)
return tallyParams
}
// SetDepositParams sets DepositParams to the global param store
func (keeper Keeper) SetDepositParams(ctx sdk.Context, depositParams types.DepositParams) {
func (keeper Keeper) SetDepositParams(ctx sdk.Context, depositParams v1beta1.DepositParams) {
keeper.paramSpace.Set(ctx, types.ParamStoreKeyDepositParams, &depositParams)
}
// SetVotingParams sets VotingParams to the global param store
func (keeper Keeper) SetVotingParams(ctx sdk.Context, votingParams types.VotingParams) {
func (keeper Keeper) SetVotingParams(ctx sdk.Context, votingParams v1beta1.VotingParams) {
keeper.paramSpace.Set(ctx, types.ParamStoreKeyVotingParams, &votingParams)
}
// SetTallyParams sets TallyParams to the global param store
func (keeper Keeper) SetTallyParams(ctx sdk.Context, tallyParams types.TallyParams) {
func (keeper Keeper) SetTallyParams(ctx sdk.Context, tallyParams v1beta1.TallyParams) {
keeper.paramSpace.Set(ctx, types.ParamStoreKeyTallyParams, &tallyParams)
}

View File

@ -7,12 +7,13 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// SubmitProposal create new proposal given a content
func (keeper Keeper) SubmitProposal(ctx sdk.Context, content types.Content) (types.Proposal, error) {
func (keeper Keeper) SubmitProposal(ctx sdk.Context, content v1beta1.Content) (v1beta1.Proposal, error) {
if !keeper.router.HasRoute(content.ProposalRoute()) {
return types.Proposal{}, sdkerrors.Wrap(types.ErrNoProposalHandlerExists, content.ProposalRoute())
return v1beta1.Proposal{}, sdkerrors.Wrap(types.ErrNoProposalHandlerExists, content.ProposalRoute())
}
// Execute the proposal content in a new context branch (with branched store)
@ -21,20 +22,20 @@ func (keeper Keeper) SubmitProposal(ctx sdk.Context, content types.Content) (typ
cacheCtx, _ := ctx.CacheContext()
handler := keeper.router.GetRoute(content.ProposalRoute())
if err := handler(cacheCtx, content); err != nil {
return types.Proposal{}, sdkerrors.Wrap(types.ErrInvalidProposalContent, err.Error())
return v1beta1.Proposal{}, sdkerrors.Wrap(v1beta1.ErrInvalidProposalContent, err.Error())
}
proposalID, err := keeper.GetProposalID(ctx)
if err != nil {
return types.Proposal{}, err
return v1beta1.Proposal{}, err
}
submitTime := ctx.BlockHeader().Time
depositPeriod := keeper.GetDepositParams(ctx).MaxDepositPeriod
proposal, err := types.NewProposal(content, proposalID, submitTime, submitTime.Add(depositPeriod))
proposal, err := v1beta1.NewProposal(content, proposalID, submitTime, submitTime.Add(depositPeriod))
if err != nil {
return types.Proposal{}, err
return v1beta1.Proposal{}, err
}
keeper.SetProposal(ctx, proposal)
@ -56,15 +57,15 @@ func (keeper Keeper) SubmitProposal(ctx sdk.Context, content types.Content) (typ
// GetProposal get proposal from store by ProposalID.
// Panics if can't unmarshal the proposal.
func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (types.Proposal, bool) {
func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (v1beta1.Proposal, bool) {
store := ctx.KVStore(keeper.storeKey)
bz := store.Get(types.ProposalKey(proposalID))
if bz == nil {
return types.Proposal{}, false
return v1beta1.Proposal{}, false
}
var proposal types.Proposal
var proposal v1beta1.Proposal
if err := keeper.UnmarshalProposal(bz, &proposal); err != nil {
panic(err)
}
@ -74,7 +75,7 @@ func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (types.Prop
// SetProposal set a proposal to store.
// Panics if can't marshal the proposal.
func (keeper Keeper) SetProposal(ctx sdk.Context, proposal types.Proposal) {
func (keeper Keeper) SetProposal(ctx sdk.Context, proposal v1beta1.Proposal) {
bz, err := keeper.MarshalProposal(proposal)
if err != nil {
panic(err)
@ -99,14 +100,14 @@ func (keeper Keeper) DeleteProposal(ctx sdk.Context, proposalID uint64) {
// IterateProposals iterates over the all the proposals and performs a callback function.
// Panics when the iterator encounters a proposal which can't be unmarshaled.
func (keeper Keeper) IterateProposals(ctx sdk.Context, cb func(proposal types.Proposal) (stop bool)) {
func (keeper Keeper) IterateProposals(ctx sdk.Context, cb func(proposal v1beta1.Proposal) (stop bool)) {
store := ctx.KVStore(keeper.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.ProposalsKeyPrefix)
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
var proposal types.Proposal
var proposal v1beta1.Proposal
err := keeper.UnmarshalProposal(iterator.Value(), &proposal)
if err != nil {
panic(err)
@ -119,8 +120,8 @@ func (keeper Keeper) IterateProposals(ctx sdk.Context, cb func(proposal types.Pr
}
// GetProposals returns all the proposals from store
func (keeper Keeper) GetProposals(ctx sdk.Context) (proposals types.Proposals) {
keeper.IterateProposals(ctx, func(proposal types.Proposal) bool {
func (keeper Keeper) GetProposals(ctx sdk.Context) (proposals v1beta1.Proposals) {
keeper.IterateProposals(ctx, func(proposal v1beta1.Proposal) bool {
proposals = append(proposals, proposal)
return false
})
@ -136,15 +137,15 @@ func (keeper Keeper) GetProposals(ctx sdk.Context) (proposals types.Proposals) {
//
// NOTE: If no filters are provided, all proposals will be returned in paginated
// form.
func (keeper Keeper) GetProposalsFiltered(ctx sdk.Context, params types.QueryProposalsParams) types.Proposals {
func (keeper Keeper) GetProposalsFiltered(ctx sdk.Context, params v1beta1.QueryProposalsParams) v1beta1.Proposals {
proposals := keeper.GetProposals(ctx)
filteredProposals := make([]types.Proposal, 0, len(proposals))
filteredProposals := make([]v1beta1.Proposal, 0, len(proposals))
for _, p := range proposals {
matchVoter, matchDepositor, matchStatus := true, true, true
// match status (if supplied/valid)
if types.ValidProposalStatus(params.ProposalStatus) {
if v1beta1.ValidProposalStatus(params.ProposalStatus) {
matchStatus = p.Status == params.ProposalStatus
}
@ -165,7 +166,7 @@ func (keeper Keeper) GetProposalsFiltered(ctx sdk.Context, params types.QueryPro
start, end := client.Paginate(len(filteredProposals), params.Page, params.Limit, 100)
if start < 0 || end < 0 {
filteredProposals = []types.Proposal{}
filteredProposals = []v1beta1.Proposal{}
} else {
filteredProposals = filteredProposals[start:end]
}
@ -191,18 +192,18 @@ func (keeper Keeper) SetProposalID(ctx sdk.Context, proposalID uint64) {
store.Set(types.ProposalIDKey, types.GetProposalIDBytes(proposalID))
}
func (keeper Keeper) ActivateVotingPeriod(ctx sdk.Context, proposal types.Proposal) {
func (keeper Keeper) ActivateVotingPeriod(ctx sdk.Context, proposal v1beta1.Proposal) {
proposal.VotingStartTime = ctx.BlockHeader().Time
votingPeriod := keeper.GetVotingParams(ctx).VotingPeriod
proposal.VotingEndTime = proposal.VotingStartTime.Add(votingPeriod)
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
keeper.SetProposal(ctx, proposal)
keeper.RemoveFromInactiveProposalQueue(ctx, proposal.ProposalId, proposal.DepositEndTime)
keeper.InsertActiveProposalQueue(ctx, proposal.ProposalId, proposal.VotingEndTime)
}
func (keeper Keeper) MarshalProposal(proposal types.Proposal) ([]byte, error) {
func (keeper Keeper) MarshalProposal(proposal v1beta1.Proposal) ([]byte, error) {
bz, err := keeper.cdc.Marshal(&proposal)
if err != nil {
return nil, err
@ -210,7 +211,7 @@ func (keeper Keeper) MarshalProposal(proposal types.Proposal) ([]byte, error) {
return bz, nil
}
func (keeper Keeper) UnmarshalProposal(bz []byte, proposal *types.Proposal) error {
func (keeper Keeper) UnmarshalProposal(bz []byte, proposal *v1beta1.Proposal) error {
err := keeper.cdc.Unmarshal(bz, proposal)
if err != nil {
return err

View File

@ -8,6 +8,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
func (suite *KeeperTestSuite) TestGetSetProposal() {
@ -44,21 +45,21 @@ func (suite *KeeperTestSuite) TestActivateVotingPeriod() {
activeIterator.Close()
}
type invalidProposalRoute struct{ types.TextProposal }
type invalidProposalRoute struct{ v1beta1.TextProposal }
func (invalidProposalRoute) ProposalRoute() string { return "nonexistingroute" }
func (suite *KeeperTestSuite) TestSubmitProposal() {
testCases := []struct {
content types.Content
content v1beta1.Content
expectedErr error
}{
{&types.TextProposal{Title: "title", Description: "description"}, nil},
{&v1beta1.TextProposal{Title: "title", Description: "description"}, nil},
// Keeper does not check the validity of title and description, no error
{&types.TextProposal{Title: "", Description: "description"}, nil},
{&types.TextProposal{Title: strings.Repeat("1234567890", 100), Description: "description"}, nil},
{&types.TextProposal{Title: "title", Description: ""}, nil},
{&types.TextProposal{Title: "title", Description: strings.Repeat("1234567890", 1000)}, nil},
{&v1beta1.TextProposal{Title: "", Description: "description"}, nil},
{&v1beta1.TextProposal{Title: strings.Repeat("1234567890", 100), Description: "description"}, nil},
{&v1beta1.TextProposal{Title: "title", Description: ""}, nil},
{&v1beta1.TextProposal{Title: "title", Description: strings.Repeat("1234567890", 1000)}, nil},
// error only when invalid route
{&invalidProposalRoute{}, types.ErrNoProposalHandlerExists},
}
@ -71,20 +72,20 @@ func (suite *KeeperTestSuite) TestSubmitProposal() {
func (suite *KeeperTestSuite) TestGetProposalsFiltered() {
proposalID := uint64(1)
status := []types.ProposalStatus{types.StatusDepositPeriod, types.StatusVotingPeriod}
status := []v1beta1.ProposalStatus{v1beta1.StatusDepositPeriod, v1beta1.StatusVotingPeriod}
addr1 := sdk.AccAddress("foo_________________")
for _, s := range status {
for i := 0; i < 50; i++ {
p, err := types.NewProposal(TestProposal, proposalID, time.Now(), time.Now())
p, err := v1beta1.NewProposal(TestProposal, proposalID, time.Now(), time.Now())
suite.Require().NoError(err)
p.Status = s
if i%2 == 0 {
d := types.NewDeposit(proposalID, addr1, nil)
v := types.NewVote(proposalID, addr1, types.NewNonSplitVoteOption(types.OptionYes))
d := v1beta1.NewDeposit(proposalID, addr1, nil)
v := v1beta1.NewVote(proposalID, addr1, v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes))
suite.app.GovKeeper.SetDeposit(suite.ctx, d)
suite.app.GovKeeper.SetVote(suite.ctx, v)
}
@ -95,21 +96,21 @@ func (suite *KeeperTestSuite) TestGetProposalsFiltered() {
}
testCases := []struct {
params types.QueryProposalsParams
params v1beta1.QueryProposalsParams
expectedNumResults int
}{
{types.NewQueryProposalsParams(1, 50, types.StatusNil, nil, nil), 50},
{types.NewQueryProposalsParams(1, 50, types.StatusDepositPeriod, nil, nil), 50},
{types.NewQueryProposalsParams(1, 50, types.StatusVotingPeriod, nil, nil), 50},
{types.NewQueryProposalsParams(1, 25, types.StatusNil, nil, nil), 25},
{types.NewQueryProposalsParams(2, 25, types.StatusNil, nil, nil), 25},
{types.NewQueryProposalsParams(1, 50, types.StatusRejected, nil, nil), 0},
{types.NewQueryProposalsParams(1, 50, types.StatusNil, addr1, nil), 50},
{types.NewQueryProposalsParams(1, 50, types.StatusNil, nil, addr1), 50},
{types.NewQueryProposalsParams(1, 50, types.StatusNil, addr1, addr1), 50},
{types.NewQueryProposalsParams(1, 50, types.StatusDepositPeriod, addr1, addr1), 25},
{types.NewQueryProposalsParams(1, 50, types.StatusDepositPeriod, nil, nil), 50},
{types.NewQueryProposalsParams(1, 50, types.StatusVotingPeriod, nil, nil), 50},
{v1beta1.NewQueryProposalsParams(1, 50, v1beta1.StatusNil, nil, nil), 50},
{v1beta1.NewQueryProposalsParams(1, 50, v1beta1.StatusDepositPeriod, nil, nil), 50},
{v1beta1.NewQueryProposalsParams(1, 50, v1beta1.StatusVotingPeriod, nil, nil), 50},
{v1beta1.NewQueryProposalsParams(1, 25, v1beta1.StatusNil, nil, nil), 25},
{v1beta1.NewQueryProposalsParams(2, 25, v1beta1.StatusNil, nil, nil), 25},
{v1beta1.NewQueryProposalsParams(1, 50, v1beta1.StatusRejected, nil, nil), 0},
{v1beta1.NewQueryProposalsParams(1, 50, v1beta1.StatusNil, addr1, nil), 50},
{v1beta1.NewQueryProposalsParams(1, 50, v1beta1.StatusNil, nil, addr1), 50},
{v1beta1.NewQueryProposalsParams(1, 50, v1beta1.StatusNil, addr1, addr1), 50},
{v1beta1.NewQueryProposalsParams(1, 50, v1beta1.StatusDepositPeriod, addr1, addr1), 25},
{v1beta1.NewQueryProposalsParams(1, 50, v1beta1.StatusDepositPeriod, nil, nil), 50},
{v1beta1.NewQueryProposalsParams(1, 50, v1beta1.StatusVotingPeriod, nil, nil), 50},
}
for i, tc := range testCases {
@ -118,7 +119,7 @@ func (suite *KeeperTestSuite) TestGetProposalsFiltered() {
suite.Require().Len(proposals, tc.expectedNumResults)
for _, p := range proposals {
if types.ValidProposalStatus(tc.params.ProposalStatus) {
if v1beta1.ValidProposalStatus(tc.params.ProposalStatus) {
suite.Require().Equal(tc.params.ProposalStatus, p.Status)
}
}

View File

@ -8,6 +8,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// NewQuerier creates a new gov Querier instance
@ -137,7 +138,7 @@ func queryDeposits(ctx sdk.Context, path []string, req abci.RequestQuery, keeper
deposits := keeper.GetDeposits(ctx, params.ProposalID)
if deposits == nil {
deposits = types.Deposits{}
deposits = v1beta1.Deposits{}
}
bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, deposits)
@ -163,13 +164,13 @@ func queryTally(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Ke
return nil, sdkerrors.Wrapf(types.ErrUnknownProposal, "%d", proposalID)
}
var tallyResult types.TallyResult
var tallyResult v1beta1.TallyResult
switch {
case proposal.Status == types.StatusDepositPeriod:
tallyResult = types.EmptyTallyResult()
case proposal.Status == v1beta1.StatusDepositPeriod:
tallyResult = v1beta1.EmptyTallyResult()
case proposal.Status == types.StatusPassed || proposal.Status == types.StatusRejected:
case proposal.Status == v1beta1.StatusPassed || proposal.Status == v1beta1.StatusRejected:
tallyResult = proposal.FinalTallyResult
default:
@ -187,7 +188,7 @@ func queryTally(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Ke
// nolint: unparam
func queryVotes(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
var params types.QueryProposalVotesParams
var params v1beta1.QueryProposalVotesParams
err := legacyQuerierCdc.UnmarshalJSON(req.Data, &params)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
@ -195,11 +196,11 @@ func queryVotes(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Ke
votes := keeper.GetVotes(ctx, params.ProposalID)
if votes == nil {
votes = types.Votes{}
votes = v1beta1.Votes{}
} else {
start, end := client.Paginate(len(votes), params.Page, params.Limit, 100)
if start < 0 || end < 0 {
votes = types.Votes{}
votes = v1beta1.Votes{}
} else {
votes = votes[start:end]
}
@ -214,7 +215,7 @@ func queryVotes(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Ke
}
func queryProposals(ctx sdk.Context, _ []string, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
var params types.QueryProposalsParams
var params v1beta1.QueryProposalsParams
err := legacyQuerierCdc.UnmarshalJSON(req.Data, &params)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
@ -222,7 +223,7 @@ func queryProposals(ctx sdk.Context, _ []string, req abci.RequestQuery, keeper K
proposals := keeper.GetProposalsFiltered(ctx, params)
if proposals == nil {
proposals = types.Proposals{}
proposals = v1beta1.Proposals{}
}
bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, proposals)

View File

@ -15,45 +15,46 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
const custom = "custom"
func getQueriedParams(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier) (types.DepositParams, types.VotingParams, types.TallyParams) {
func getQueriedParams(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier) (v1beta1.DepositParams, v1beta1.VotingParams, v1beta1.TallyParams) {
query := abci.RequestQuery{
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryParams, types.ParamDeposit}, "/"),
Path: strings.Join([]string{custom, types.QuerierRoute, v1beta1.QueryParams, v1beta1.ParamDeposit}, "/"),
Data: []byte{},
}
bz, err := querier(ctx, []string{types.QueryParams, types.ParamDeposit}, query)
bz, err := querier(ctx, []string{v1beta1.QueryParams, v1beta1.ParamDeposit}, query)
require.NoError(t, err)
require.NotNil(t, bz)
var depositParams types.DepositParams
var depositParams v1beta1.DepositParams
require.NoError(t, cdc.UnmarshalJSON(bz, &depositParams))
query = abci.RequestQuery{
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryParams, types.ParamVoting}, "/"),
Path: strings.Join([]string{custom, types.QuerierRoute, v1beta1.QueryParams, v1beta1.ParamVoting}, "/"),
Data: []byte{},
}
bz, err = querier(ctx, []string{types.QueryParams, types.ParamVoting}, query)
bz, err = querier(ctx, []string{v1beta1.QueryParams, v1beta1.ParamVoting}, query)
require.NoError(t, err)
require.NotNil(t, bz)
var votingParams types.VotingParams
var votingParams v1beta1.VotingParams
require.NoError(t, cdc.UnmarshalJSON(bz, &votingParams))
query = abci.RequestQuery{
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryParams, types.ParamTallying}, "/"),
Path: strings.Join([]string{custom, types.QuerierRoute, v1beta1.QueryParams, v1beta1.ParamTallying}, "/"),
Data: []byte{},
}
bz, err = querier(ctx, []string{types.QueryParams, types.ParamTallying}, query)
bz, err = querier(ctx, []string{v1beta1.QueryParams, v1beta1.ParamTallying}, query)
require.NoError(t, err)
require.NotNil(t, bz)
var tallyParams types.TallyParams
var tallyParams v1beta1.TallyParams
require.NoError(t, cdc.UnmarshalJSON(bz, &tallyParams))
return depositParams, votingParams, tallyParams
@ -61,84 +62,84 @@ func getQueriedParams(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, que
func getQueriedProposals(
t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier,
depositor, voter sdk.AccAddress, status types.ProposalStatus, page, limit int,
) []types.Proposal {
depositor, voter sdk.AccAddress, status v1beta1.ProposalStatus, page, limit int,
) []v1beta1.Proposal {
query := abci.RequestQuery{
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryProposals}, "/"),
Data: cdc.MustMarshalJSON(types.NewQueryProposalsParams(page, limit, status, voter, depositor)),
Path: strings.Join([]string{custom, types.QuerierRoute, v1beta1.QueryProposals}, "/"),
Data: cdc.MustMarshalJSON(v1beta1.NewQueryProposalsParams(page, limit, status, voter, depositor)),
}
bz, err := querier(ctx, []string{types.QueryProposals}, query)
bz, err := querier(ctx, []string{v1beta1.QueryProposals}, query)
require.NoError(t, err)
require.NotNil(t, bz)
var proposals types.Proposals
var proposals v1beta1.Proposals
require.NoError(t, cdc.UnmarshalJSON(bz, &proposals))
return proposals
}
func getQueriedDeposit(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, proposalID uint64, depositor sdk.AccAddress) types.Deposit {
func getQueriedDeposit(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, proposalID uint64, depositor sdk.AccAddress) v1beta1.Deposit {
query := abci.RequestQuery{
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryDeposit}, "/"),
Data: cdc.MustMarshalJSON(types.NewQueryDepositParams(proposalID, depositor)),
Path: strings.Join([]string{custom, types.QuerierRoute, v1beta1.QueryDeposit}, "/"),
Data: cdc.MustMarshalJSON(v1beta1.NewQueryDepositParams(proposalID, depositor)),
}
bz, err := querier(ctx, []string{types.QueryDeposit}, query)
bz, err := querier(ctx, []string{v1beta1.QueryDeposit}, query)
require.NoError(t, err)
require.NotNil(t, bz)
var deposit types.Deposit
var deposit v1beta1.Deposit
require.NoError(t, cdc.UnmarshalJSON(bz, &deposit))
return deposit
}
func getQueriedDeposits(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, proposalID uint64) []types.Deposit {
func getQueriedDeposits(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, proposalID uint64) []v1beta1.Deposit {
query := abci.RequestQuery{
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryDeposits}, "/"),
Data: cdc.MustMarshalJSON(types.NewQueryProposalParams(proposalID)),
Path: strings.Join([]string{custom, types.QuerierRoute, v1beta1.QueryDeposits}, "/"),
Data: cdc.MustMarshalJSON(v1beta1.NewQueryProposalParams(proposalID)),
}
bz, err := querier(ctx, []string{types.QueryDeposits}, query)
bz, err := querier(ctx, []string{v1beta1.QueryDeposits}, query)
require.NoError(t, err)
require.NotNil(t, bz)
var deposits []types.Deposit
var deposits []v1beta1.Deposit
require.NoError(t, cdc.UnmarshalJSON(bz, &deposits))
return deposits
}
func getQueriedVote(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, proposalID uint64, voter sdk.AccAddress) types.Vote {
func getQueriedVote(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, proposalID uint64, voter sdk.AccAddress) v1beta1.Vote {
query := abci.RequestQuery{
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryVote}, "/"),
Data: cdc.MustMarshalJSON(types.NewQueryVoteParams(proposalID, voter)),
Path: strings.Join([]string{custom, types.QuerierRoute, v1beta1.QueryVote}, "/"),
Data: cdc.MustMarshalJSON(v1beta1.NewQueryVoteParams(proposalID, voter)),
}
bz, err := querier(ctx, []string{types.QueryVote}, query)
bz, err := querier(ctx, []string{v1beta1.QueryVote}, query)
require.NoError(t, err)
require.NotNil(t, bz)
var vote types.Vote
var vote v1beta1.Vote
require.NoError(t, cdc.UnmarshalJSON(bz, &vote))
return vote
}
func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier,
proposalID uint64, page, limit int) []types.Vote {
proposalID uint64, page, limit int) []v1beta1.Vote {
query := abci.RequestQuery{
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryVote}, "/"),
Data: cdc.MustMarshalJSON(types.NewQueryProposalVotesParams(proposalID, page, limit)),
Path: strings.Join([]string{custom, types.QuerierRoute, v1beta1.QueryVote}, "/"),
Data: cdc.MustMarshalJSON(v1beta1.NewQueryProposalVotesParams(proposalID, page, limit)),
}
bz, err := querier(ctx, []string{types.QueryVotes}, query)
bz, err := querier(ctx, []string{v1beta1.QueryVotes}, query)
require.NoError(t, err)
require.NotNil(t, bz)
var votes []types.Vote
var votes []v1beta1.Vote
require.NoError(t, cdc.UnmarshalJSON(bz, &votes))
return votes
@ -162,7 +163,7 @@ func TestQueries(t *testing.T) {
// TestAddrs[0] proposes (and deposits) proposals #1 and #2
proposal1, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
deposit1 := types.NewDeposit(proposal1.ProposalId, TestAddrs[0], oneCoins)
deposit1 := v1beta1.NewDeposit(proposal1.ProposalId, TestAddrs[0], oneCoins)
depositer1, err := sdk.AccAddressFromBech32(deposit1.Depositor)
require.NoError(t, err)
_, err = app.GovKeeper.AddDeposit(ctx, deposit1.ProposalId, depositer1, deposit1.Amount)
@ -172,7 +173,7 @@ func TestQueries(t *testing.T) {
proposal2, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
deposit2 := types.NewDeposit(proposal2.ProposalId, TestAddrs[0], consCoins)
deposit2 := v1beta1.NewDeposit(proposal2.ProposalId, TestAddrs[0], consCoins)
depositer2, err := sdk.AccAddressFromBech32(deposit2.Depositor)
require.NoError(t, err)
_, err = app.GovKeeper.AddDeposit(ctx, deposit2.ProposalId, depositer2, deposit2.Amount)
@ -183,7 +184,7 @@ func TestQueries(t *testing.T) {
// TestAddrs[1] proposes (and deposits) on proposal #3
proposal3, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
deposit3 := types.NewDeposit(proposal3.ProposalId, TestAddrs[1], oneCoins)
deposit3 := v1beta1.NewDeposit(proposal3.ProposalId, TestAddrs[1], oneCoins)
depositer3, err := sdk.AccAddressFromBech32(deposit3.Depositor)
require.NoError(t, err)
@ -193,24 +194,24 @@ func TestQueries(t *testing.T) {
proposal3.TotalDeposit = proposal3.TotalDeposit.Add(deposit3.Amount...)
// TestAddrs[1] deposits on proposals #2 & #3
deposit4 := types.NewDeposit(proposal2.ProposalId, TestAddrs[1], depositParams.MinDeposit)
deposit4 := v1beta1.NewDeposit(proposal2.ProposalId, TestAddrs[1], depositParams.MinDeposit)
depositer4, err := sdk.AccAddressFromBech32(deposit4.Depositor)
require.NoError(t, err)
_, err = app.GovKeeper.AddDeposit(ctx, deposit4.ProposalId, depositer4, deposit4.Amount)
require.NoError(t, err)
proposal2.TotalDeposit = proposal2.TotalDeposit.Add(deposit4.Amount...)
proposal2.Status = types.StatusVotingPeriod
proposal2.Status = v1beta1.StatusVotingPeriod
proposal2.VotingEndTime = proposal2.VotingEndTime.Add(types.DefaultPeriod)
deposit5 := types.NewDeposit(proposal3.ProposalId, TestAddrs[1], depositParams.MinDeposit)
deposit5 := v1beta1.NewDeposit(proposal3.ProposalId, TestAddrs[1], depositParams.MinDeposit)
depositer5, err := sdk.AccAddressFromBech32(deposit5.Depositor)
require.NoError(t, err)
_, err = app.GovKeeper.AddDeposit(ctx, deposit5.ProposalId, depositer5, deposit5.Amount)
require.NoError(t, err)
proposal3.TotalDeposit = proposal3.TotalDeposit.Add(deposit5.Amount...)
proposal3.Status = types.StatusVotingPeriod
proposal3.Status = v1beta1.StatusVotingPeriod
proposal3.VotingEndTime = proposal3.VotingEndTime.Add(types.DefaultPeriod)
// total deposit of TestAddrs[1] on proposal #3 is worth the proposal deposit + individual deposit
deposit5.Amount = deposit5.Amount.Add(deposit3.Amount...)
@ -239,33 +240,33 @@ func TestQueries(t *testing.T) {
deposit = getQueriedDeposit(t, ctx, legacyQuerierCdc, querier, proposal3.ProposalId, TestAddrs[1])
require.Equal(t, deposit5, deposit)
// Only proposal #1 should be in types.Deposit Period
proposals := getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, nil, types.StatusDepositPeriod, 1, 0)
// Only proposal #1 should be in v1beta1.Deposit Period
proposals := getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, nil, v1beta1.StatusDepositPeriod, 1, 0)
require.Len(t, proposals, 1)
require.Equal(t, proposal1, proposals[0])
// Only proposals #2 and #3 should be in Voting Period
proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, nil, types.StatusVotingPeriod, 1, 0)
proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, nil, v1beta1.StatusVotingPeriod, 1, 0)
require.Len(t, proposals, 2)
require.Equal(t, proposal2, proposals[0])
require.Equal(t, proposal3, proposals[1])
// Addrs[0] votes on proposals #2 & #3
vote1 := types.NewVote(proposal2.ProposalId, TestAddrs[0], types.NewNonSplitVoteOption(types.OptionYes))
vote2 := types.NewVote(proposal3.ProposalId, TestAddrs[0], types.NewNonSplitVoteOption(types.OptionYes))
vote1 := v1beta1.NewVote(proposal2.ProposalId, TestAddrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes))
vote2 := v1beta1.NewVote(proposal3.ProposalId, TestAddrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes))
app.GovKeeper.SetVote(ctx, vote1)
app.GovKeeper.SetVote(ctx, vote2)
// Addrs[1] votes on proposal #3
vote3 := types.NewVote(proposal3.ProposalId, TestAddrs[1], types.NewNonSplitVoteOption(types.OptionYes))
vote3 := v1beta1.NewVote(proposal3.ProposalId, TestAddrs[1], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes))
app.GovKeeper.SetVote(ctx, vote3)
// Test query voted by TestAddrs[0]
proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, TestAddrs[0], types.StatusNil, 1, 0)
proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, TestAddrs[0], v1beta1.StatusNil, 1, 0)
require.Equal(t, proposal2, proposals[0])
require.Equal(t, proposal3, proposals[1])
// Test query votes on types.Proposal 2
// Test query votes on v1beta1.Proposal 2
votes := getQueriedVotes(t, ctx, legacyQuerierCdc, querier, proposal2.ProposalId, 1, 0)
require.Len(t, votes, 1)
checkEqualVotes(t, vote1, votes[0])
@ -273,33 +274,33 @@ func TestQueries(t *testing.T) {
vote := getQueriedVote(t, ctx, legacyQuerierCdc, querier, proposal2.ProposalId, TestAddrs[0])
checkEqualVotes(t, vote1, vote)
// Test query votes on types.Proposal 3
// Test query votes on v1beta1.Proposal 3
votes = getQueriedVotes(t, ctx, legacyQuerierCdc, querier, proposal3.ProposalId, 1, 0)
require.Len(t, votes, 2)
checkEqualVotes(t, vote2, votes[0])
checkEqualVotes(t, vote3, votes[1])
// Test query all proposals
proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, nil, types.StatusNil, 1, 0)
proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, nil, v1beta1.StatusNil, 1, 0)
require.Equal(t, proposal1, proposals[0])
require.Equal(t, proposal2, proposals[1])
require.Equal(t, proposal3, proposals[2])
// Test query voted by TestAddrs[1]
proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, TestAddrs[1], types.StatusNil, 1, 0)
proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, TestAddrs[1], v1beta1.StatusNil, 1, 0)
require.Equal(t, proposal3.ProposalId, proposals[0].ProposalId)
// Test query deposited by TestAddrs[0]
proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, TestAddrs[0], nil, types.StatusNil, 1, 0)
proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, TestAddrs[0], nil, v1beta1.StatusNil, 1, 0)
require.Equal(t, proposal1.ProposalId, proposals[0].ProposalId)
// Test query deposited by addr2
proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, TestAddrs[1], nil, types.StatusNil, 1, 0)
proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, TestAddrs[1], nil, v1beta1.StatusNil, 1, 0)
require.Equal(t, proposal2.ProposalId, proposals[0].ProposalId)
require.Equal(t, proposal3.ProposalId, proposals[1].ProposalId)
// Test query voted AND deposited by addr1
proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, TestAddrs[0], TestAddrs[0], types.StatusNil, 1, 0)
proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, TestAddrs[0], TestAddrs[0], v1beta1.StatusNil, 1, 0)
require.Equal(t, proposal2.ProposalId, proposals[0].ProposalId)
}
@ -308,14 +309,14 @@ func TestPaginatedVotesQuery(t *testing.T) {
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
legacyQuerierCdc := app.LegacyAmino()
proposal := types.Proposal{
proposal := v1beta1.Proposal{
ProposalId: 100,
Status: types.StatusVotingPeriod,
Status: v1beta1.StatusVotingPeriod,
}
app.GovKeeper.SetProposal(ctx, proposal)
votes := make([]types.Vote, 20)
votes := make([]v1beta1.Vote, 20)
random := rand.New(rand.NewSource(time.Now().UnixNano()))
addrMap := make(map[string]struct{})
genAddr := func() string {
@ -330,10 +331,10 @@ func TestPaginatedVotesQuery(t *testing.T) {
}
}
for i := range votes {
vote := types.Vote{
vote := v1beta1.Vote{
ProposalId: proposal.ProposalId,
Voter: genAddr(),
Options: types.NewNonSplitVoteOption(types.OptionYes),
Options: v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes),
}
votes[i] = vote
app.GovKeeper.SetVote(ctx, vote)
@ -349,7 +350,7 @@ func TestPaginatedVotesQuery(t *testing.T) {
description string
page int
limit int
votes []types.Vote
votes []v1beta1.Vote
}
for _, tc := range []testCase{
{
@ -390,7 +391,7 @@ func TestPaginatedVotesQuery(t *testing.T) {
// When querying, the keeper populates the `vote.Option` field when there's
// only 1 vote, this function checks equality of structs while skipping that
// field.
func checkEqualVotes(t *testing.T, vote1, vote2 types.Vote) {
func checkEqualVotes(t *testing.T, vote1, vote2 v1beta1.Vote) {
require.Equal(t, vote1.Options, vote2.Options)
require.Equal(t, vote1.Voter, vote2.Voter)
require.Equal(t, vote1.ProposalId, vote2.ProposalId)

View File

@ -2,7 +2,7 @@ package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -10,30 +10,30 @@ import (
// Tally iterates over the votes and updates the tally of a proposal based on the voting power of the
// voters
func (keeper Keeper) Tally(ctx sdk.Context, proposal types.Proposal) (passes bool, burnDeposits bool, tallyResults types.TallyResult) {
results := make(map[types.VoteOption]sdk.Dec)
results[types.OptionYes] = sdk.ZeroDec()
results[types.OptionAbstain] = sdk.ZeroDec()
results[types.OptionNo] = sdk.ZeroDec()
results[types.OptionNoWithVeto] = sdk.ZeroDec()
func (keeper Keeper) Tally(ctx sdk.Context, proposal v1beta1.Proposal) (passes bool, burnDeposits bool, tallyResults v1beta1.TallyResult) {
results := make(map[v1beta1.VoteOption]sdk.Dec)
results[v1beta1.OptionYes] = sdk.ZeroDec()
results[v1beta1.OptionAbstain] = sdk.ZeroDec()
results[v1beta1.OptionNo] = sdk.ZeroDec()
results[v1beta1.OptionNoWithVeto] = sdk.ZeroDec()
totalVotingPower := sdk.ZeroDec()
currValidators := make(map[string]types.ValidatorGovInfo)
currValidators := make(map[string]v1beta1.ValidatorGovInfo)
// fetch all the bonded validators, insert them into currValidators
keeper.sk.IterateBondedValidatorsByPower(ctx, func(index int64, validator stakingtypes.ValidatorI) (stop bool) {
currValidators[validator.GetOperator().String()] = types.NewValidatorGovInfo(
currValidators[validator.GetOperator().String()] = v1beta1.NewValidatorGovInfo(
validator.GetOperator(),
validator.GetBondedTokens(),
validator.GetDelegatorShares(),
sdk.ZeroDec(),
types.WeightedVoteOptions{},
v1beta1.WeightedVoteOptions{},
)
return false
})
keeper.IterateVotes(ctx, proposal.ProposalId, func(vote types.Vote) bool {
keeper.IterateVotes(ctx, proposal.ProposalId, func(vote v1beta1.Vote) bool {
// if validator, just record it in the map
voter, err := sdk.AccAddressFromBech32(vote.Voter)
@ -91,7 +91,7 @@ func (keeper Keeper) Tally(ctx sdk.Context, proposal types.Proposal) (passes boo
}
tallyParams := keeper.GetTallyParams(ctx)
tallyResults = types.NewTallyResultFromMap(results)
tallyResults = v1beta1.NewTallyResultFromMap(results)
// TODO: Upgrade the spec to cover all of these cases & remove pseudocode.
// If there is no staked coins, the proposal fails
@ -106,17 +106,17 @@ func (keeper Keeper) Tally(ctx sdk.Context, proposal types.Proposal) (passes boo
}
// If no one votes (everyone abstains), proposal fails
if totalVotingPower.Sub(results[types.OptionAbstain]).Equal(sdk.ZeroDec()) {
if totalVotingPower.Sub(results[v1beta1.OptionAbstain]).Equal(sdk.ZeroDec()) {
return false, false, tallyResults
}
// If more than 1/3 of voters veto, proposal fails
if results[types.OptionNoWithVeto].Quo(totalVotingPower).GT(tallyParams.VetoThreshold) {
if results[v1beta1.OptionNoWithVeto].Quo(totalVotingPower).GT(tallyParams.VetoThreshold) {
return false, true, tallyResults
}
// If more than 1/2 of non-abstaining voters vote Yes, proposal passes
if results[types.OptionYes].Quo(totalVotingPower.Sub(results[types.OptionAbstain])).GT(tallyParams.Threshold) {
if results[v1beta1.OptionYes].Quo(totalVotingPower.Sub(results[v1beta1.OptionAbstain])).GT(tallyParams.Threshold) {
return true, false, tallyResults
}

View File

@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -23,7 +23,7 @@ func TestTallyNoOneVotes(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
@ -32,7 +32,7 @@ func TestTallyNoOneVotes(t *testing.T) {
require.False(t, passes)
require.True(t, burnDeposits)
require.True(t, tallyResults.Equals(types.EmptyTallyResult()))
require.True(t, tallyResults.Equals(v1beta1.EmptyTallyResult()))
}
func TestTallyNoQuorum(t *testing.T) {
@ -47,10 +47,10 @@ func TestTallyNoQuorum(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
err = app.GovKeeper.AddVote(ctx, proposalID, addrs[0], types.NewNonSplitVoteOption(types.OptionYes))
err = app.GovKeeper.AddVote(ctx, proposalID, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes))
require.Nil(t, err)
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
@ -70,12 +70,12 @@ func TestTallyOnlyValidatorsAllYes(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[2], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[2], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
require.True(t, ok)
@ -83,7 +83,7 @@ func TestTallyOnlyValidatorsAllYes(t *testing.T) {
require.True(t, passes)
require.False(t, burnDeposits)
require.False(t, tallyResults.Equals(types.EmptyTallyResult()))
require.False(t, tallyResults.Equals(v1beta1.EmptyTallyResult()))
}
func TestTallyOnlyValidators51No(t *testing.T) {
@ -96,11 +96,11 @@ func TestTallyOnlyValidators51No(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[0], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[1], types.NewNonSplitVoteOption(types.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[1], v1beta1.NewNonSplitVoteOption(v1beta1.OptionNo)))
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
require.True(t, ok)
@ -120,11 +120,11 @@ func TestTallyOnlyValidators51Yes(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[0], types.NewNonSplitVoteOption(types.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[1], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[1], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
require.True(t, ok)
@ -132,7 +132,7 @@ func TestTallyOnlyValidators51Yes(t *testing.T) {
require.True(t, passes)
require.False(t, burnDeposits)
require.False(t, tallyResults.Equals(types.EmptyTallyResult()))
require.False(t, tallyResults.Equals(v1beta1.EmptyTallyResult()))
}
func TestTallyOnlyValidatorsVetoed(t *testing.T) {
@ -145,12 +145,12 @@ func TestTallyOnlyValidatorsVetoed(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[0], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[1], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[2], types.NewNonSplitVoteOption(types.OptionNoWithVeto)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[1], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[2], v1beta1.NewNonSplitVoteOption(v1beta1.OptionNoWithVeto)))
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
require.True(t, ok)
@ -158,7 +158,7 @@ func TestTallyOnlyValidatorsVetoed(t *testing.T) {
require.False(t, passes)
require.True(t, burnDeposits)
require.False(t, tallyResults.Equals(types.EmptyTallyResult()))
require.False(t, tallyResults.Equals(v1beta1.EmptyTallyResult()))
}
func TestTallyOnlyValidatorsAbstainPasses(t *testing.T) {
@ -171,12 +171,12 @@ func TestTallyOnlyValidatorsAbstainPasses(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[0], types.NewNonSplitVoteOption(types.OptionAbstain)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[1], types.NewNonSplitVoteOption(types.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[2], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionAbstain)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[1], v1beta1.NewNonSplitVoteOption(v1beta1.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[2], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
require.True(t, ok)
@ -184,7 +184,7 @@ func TestTallyOnlyValidatorsAbstainPasses(t *testing.T) {
require.True(t, passes)
require.False(t, burnDeposits)
require.False(t, tallyResults.Equals(types.EmptyTallyResult()))
require.False(t, tallyResults.Equals(v1beta1.EmptyTallyResult()))
}
func TestTallyOnlyValidatorsAbstainFails(t *testing.T) {
@ -197,12 +197,12 @@ func TestTallyOnlyValidatorsAbstainFails(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[0], types.NewNonSplitVoteOption(types.OptionAbstain)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[1], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[2], types.NewNonSplitVoteOption(types.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionAbstain)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[1], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddrs[2], v1beta1.NewNonSplitVoteOption(v1beta1.OptionNo)))
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
require.True(t, ok)
@ -210,7 +210,7 @@ func TestTallyOnlyValidatorsAbstainFails(t *testing.T) {
require.False(t, passes)
require.False(t, burnDeposits)
require.False(t, tallyResults.Equals(types.EmptyTallyResult()))
require.False(t, tallyResults.Equals(v1beta1.EmptyTallyResult()))
}
func TestTallyOnlyValidatorsNonVoter(t *testing.T) {
@ -224,11 +224,11 @@ func TestTallyOnlyValidatorsNonVoter(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddr1, types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddr2, types.NewNonSplitVoteOption(types.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddr1, v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddr2, v1beta1.NewNonSplitVoteOption(v1beta1.OptionNo)))
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
require.True(t, ok)
@ -236,7 +236,7 @@ func TestTallyOnlyValidatorsNonVoter(t *testing.T) {
require.False(t, passes)
require.False(t, burnDeposits)
require.False(t, tallyResults.Equals(types.EmptyTallyResult()))
require.False(t, tallyResults.Equals(v1beta1.EmptyTallyResult()))
}
func TestTallyDelgatorOverride(t *testing.T) {
@ -258,13 +258,13 @@ func TestTallyDelgatorOverride(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[2], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[3], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[4], types.NewNonSplitVoteOption(types.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[2], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[3], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[4], v1beta1.NewNonSplitVoteOption(v1beta1.OptionNo)))
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
require.True(t, ok)
@ -272,7 +272,7 @@ func TestTallyDelgatorOverride(t *testing.T) {
require.False(t, passes)
require.False(t, burnDeposits)
require.False(t, tallyResults.Equals(types.EmptyTallyResult()))
require.False(t, tallyResults.Equals(v1beta1.EmptyTallyResult()))
}
func TestTallyDelgatorInherit(t *testing.T) {
@ -294,12 +294,12 @@ func TestTallyDelgatorInherit(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], types.NewNonSplitVoteOption(types.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], types.NewNonSplitVoteOption(types.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[2], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], v1beta1.NewNonSplitVoteOption(v1beta1.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[2], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
require.True(t, ok)
@ -307,7 +307,7 @@ func TestTallyDelgatorInherit(t *testing.T) {
require.True(t, passes)
require.False(t, burnDeposits)
require.False(t, tallyResults.Equals(types.EmptyTallyResult()))
require.False(t, tallyResults.Equals(v1beta1.EmptyTallyResult()))
}
func TestTallyDelgatorMultipleOverride(t *testing.T) {
@ -333,13 +333,13 @@ func TestTallyDelgatorMultipleOverride(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[2], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[3], types.NewNonSplitVoteOption(types.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[2], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[3], v1beta1.NewNonSplitVoteOption(v1beta1.OptionNo)))
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
require.True(t, ok)
@ -347,7 +347,7 @@ func TestTallyDelgatorMultipleOverride(t *testing.T) {
require.False(t, passes)
require.False(t, burnDeposits)
require.False(t, tallyResults.Equals(types.EmptyTallyResult()))
require.False(t, tallyResults.Equals(v1beta1.EmptyTallyResult()))
}
func TestTallyDelgatorMultipleInherit(t *testing.T) {
@ -375,12 +375,12 @@ func TestTallyDelgatorMultipleInherit(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], types.NewNonSplitVoteOption(types.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[2], types.NewNonSplitVoteOption(types.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], v1beta1.NewNonSplitVoteOption(v1beta1.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[2], v1beta1.NewNonSplitVoteOption(v1beta1.OptionNo)))
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
require.True(t, ok)
@ -388,7 +388,7 @@ func TestTallyDelgatorMultipleInherit(t *testing.T) {
require.False(t, passes)
require.False(t, burnDeposits)
require.False(t, tallyResults.Equals(types.EmptyTallyResult()))
require.False(t, tallyResults.Equals(v1beta1.EmptyTallyResult()))
}
func TestTallyJailedValidator(t *testing.T) {
@ -418,12 +418,12 @@ func TestTallyJailedValidator(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], types.NewNonSplitVoteOption(types.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[2], types.NewNonSplitVoteOption(types.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], v1beta1.NewNonSplitVoteOption(v1beta1.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[2], v1beta1.NewNonSplitVoteOption(v1beta1.OptionNo)))
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
require.True(t, ok)
@ -431,7 +431,7 @@ func TestTallyJailedValidator(t *testing.T) {
require.True(t, passes)
require.False(t, burnDeposits)
require.False(t, tallyResults.Equals(types.EmptyTallyResult()))
require.False(t, tallyResults.Equals(v1beta1.EmptyTallyResult()))
}
func TestTallyValidatorMultipleDelegations(t *testing.T) {
@ -451,12 +451,12 @@ func TestTallyValidatorMultipleDelegations(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalId
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], types.NewNonSplitVoteOption(types.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[2], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], v1beta1.NewNonSplitVoteOption(v1beta1.OptionNo)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[2], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
require.True(t, ok)
@ -469,7 +469,7 @@ func TestTallyValidatorMultipleDelegations(t *testing.T) {
expectedAbstain := app.StakingKeeper.TokensFromConsensusPower(ctx, 0)
expectedNo := app.StakingKeeper.TokensFromConsensusPower(ctx, 10)
expectedNoWithVeto := app.StakingKeeper.TokensFromConsensusPower(ctx, 0)
expectedTallyResult := types.NewTallyResult(expectedYes, expectedAbstain, expectedNo, expectedNoWithVeto)
expectedTallyResult := v1beta1.NewTallyResult(expectedYes, expectedAbstain, expectedNo, expectedNoWithVeto)
require.True(t, tallyResults.Equals(expectedTallyResult))
}

View File

@ -6,25 +6,26 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// AddVote adds a vote on a specific proposal
func (keeper Keeper) AddVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress, options types.WeightedVoteOptions) error {
func (keeper Keeper) AddVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress, options v1beta1.WeightedVoteOptions) error {
proposal, ok := keeper.GetProposal(ctx, proposalID)
if !ok {
return sdkerrors.Wrapf(types.ErrUnknownProposal, "%d", proposalID)
}
if proposal.Status != types.StatusVotingPeriod {
if proposal.Status != v1beta1.StatusVotingPeriod {
return sdkerrors.Wrapf(types.ErrInactiveProposal, "%d", proposalID)
}
for _, option := range options {
if !types.ValidWeightedVoteOption(option) {
return sdkerrors.Wrap(types.ErrInvalidVote, option.String())
if !v1beta1.ValidWeightedVoteOption(option) {
return sdkerrors.Wrap(v1beta1.ErrInvalidVote, option.String())
}
}
vote := types.NewVote(proposalID, voterAddr, options)
vote := v1beta1.NewVote(proposalID, voterAddr, options)
keeper.SetVote(ctx, vote)
// called after a vote on a proposal is cast
@ -42,8 +43,8 @@ func (keeper Keeper) AddVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.A
}
// GetAllVotes returns all the votes from the store
func (keeper Keeper) GetAllVotes(ctx sdk.Context) (votes types.Votes) {
keeper.IterateAllVotes(ctx, func(vote types.Vote) bool {
func (keeper Keeper) GetAllVotes(ctx sdk.Context) (votes v1beta1.Votes) {
keeper.IterateAllVotes(ctx, func(vote v1beta1.Vote) bool {
populateLegacyOption(&vote)
votes = append(votes, vote)
return false
@ -52,8 +53,8 @@ func (keeper Keeper) GetAllVotes(ctx sdk.Context) (votes types.Votes) {
}
// GetVotes returns all the votes from a proposal
func (keeper Keeper) GetVotes(ctx sdk.Context, proposalID uint64) (votes types.Votes) {
keeper.IterateVotes(ctx, proposalID, func(vote types.Vote) bool {
func (keeper Keeper) GetVotes(ctx sdk.Context, proposalID uint64) (votes v1beta1.Votes) {
keeper.IterateVotes(ctx, proposalID, func(vote v1beta1.Vote) bool {
populateLegacyOption(&vote)
votes = append(votes, vote)
return false
@ -62,7 +63,7 @@ func (keeper Keeper) GetVotes(ctx sdk.Context, proposalID uint64) (votes types.V
}
// GetVote gets the vote from an address on a specific proposal
func (keeper Keeper) GetVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) (vote types.Vote, found bool) {
func (keeper Keeper) GetVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) (vote v1beta1.Vote, found bool) {
store := ctx.KVStore(keeper.storeKey)
bz := store.Get(types.VoteKey(proposalID, voterAddr))
if bz == nil {
@ -76,10 +77,10 @@ func (keeper Keeper) GetVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.A
}
// SetVote sets a Vote to the gov store
func (keeper Keeper) SetVote(ctx sdk.Context, vote types.Vote) {
func (keeper Keeper) SetVote(ctx sdk.Context, vote v1beta1.Vote) {
// vote.Option is a deprecated field, we don't set it in state
if vote.Option != types.OptionEmpty { // nolint
vote.Option = types.OptionEmpty // nolint
if vote.Option != v1beta1.OptionEmpty { // nolint
vote.Option = v1beta1.OptionEmpty // nolint
}
store := ctx.KVStore(keeper.storeKey)
@ -92,13 +93,13 @@ func (keeper Keeper) SetVote(ctx sdk.Context, vote types.Vote) {
}
// IterateAllVotes iterates over the all the stored votes and performs a callback function
func (keeper Keeper) IterateAllVotes(ctx sdk.Context, cb func(vote types.Vote) (stop bool)) {
func (keeper Keeper) IterateAllVotes(ctx sdk.Context, cb func(vote v1beta1.Vote) (stop bool)) {
store := ctx.KVStore(keeper.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.VotesKeyPrefix)
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
var vote types.Vote
var vote v1beta1.Vote
keeper.cdc.MustUnmarshal(iterator.Value(), &vote)
populateLegacyOption(&vote)
@ -109,13 +110,13 @@ func (keeper Keeper) IterateAllVotes(ctx sdk.Context, cb func(vote types.Vote) (
}
// IterateVotes iterates over the all the proposals votes and performs a callback function
func (keeper Keeper) IterateVotes(ctx sdk.Context, proposalID uint64, cb func(vote types.Vote) (stop bool)) {
func (keeper Keeper) IterateVotes(ctx sdk.Context, proposalID uint64, cb func(vote v1beta1.Vote) (stop bool)) {
store := ctx.KVStore(keeper.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.VotesKey(proposalID))
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
var vote types.Vote
var vote v1beta1.Vote
keeper.cdc.MustUnmarshal(iterator.Value(), &vote)
populateLegacyOption(&vote)
@ -133,7 +134,7 @@ func (keeper Keeper) deleteVote(ctx sdk.Context, proposalID uint64, voterAddr sd
// populateLegacyOption adds graceful fallback of deprecated `Option` field, in case
// there's only 1 VoteOption.
func populateLegacyOption(vote *types.Vote) {
func populateLegacyOption(vote *v1beta1.Vote) {
if len(vote.Options) == 1 && vote.Options[0].Weight.Equal(sdk.MustNewDecFromStr("1.0")) {
vote.Option = vote.Options[0].Option // nolint
}

View File

@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
func TestVotes(t *testing.T) {
@ -22,57 +22,57 @@ func TestVotes(t *testing.T) {
require.NoError(t, err)
proposalID := proposal.ProposalId
var invalidOption types.VoteOption = 0x10
var invalidOption v1beta1.VoteOption = 0x10
require.Error(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], types.NewNonSplitVoteOption(types.OptionYes)), "proposal not on voting period")
require.Error(t, app.GovKeeper.AddVote(ctx, 10, addrs[0], types.NewNonSplitVoteOption(types.OptionYes)), "invalid proposal ID")
require.Error(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)), "proposal not on voting period")
require.Error(t, app.GovKeeper.AddVote(ctx, 10, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)), "invalid proposal ID")
proposal.Status = types.StatusVotingPeriod
proposal.Status = v1beta1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
require.Error(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], types.NewNonSplitVoteOption(invalidOption)), "invalid option")
require.Error(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], v1beta1.NewNonSplitVoteOption(invalidOption)), "invalid option")
// Test first vote
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], types.NewNonSplitVoteOption(types.OptionAbstain)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionAbstain)))
vote, found := app.GovKeeper.GetVote(ctx, proposalID, addrs[0])
require.True(t, found)
require.Equal(t, addrs[0].String(), vote.Voter)
require.Equal(t, proposalID, vote.ProposalId)
require.True(t, len(vote.Options) == 1)
require.Equal(t, types.OptionAbstain, vote.Options[0].Option)
require.Equal(t, types.OptionAbstain, vote.Option)
require.Equal(t, v1beta1.OptionAbstain, vote.Options[0].Option)
require.Equal(t, v1beta1.OptionAbstain, vote.Option)
// Test change of vote
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], types.NewNonSplitVoteOption(types.OptionYes)))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)))
vote, found = app.GovKeeper.GetVote(ctx, proposalID, addrs[0])
require.True(t, found)
require.Equal(t, addrs[0].String(), vote.Voter)
require.Equal(t, proposalID, vote.ProposalId)
require.True(t, len(vote.Options) == 1)
require.Equal(t, types.OptionYes, vote.Options[0].Option)
require.Equal(t, types.OptionYes, vote.Option)
require.Equal(t, v1beta1.OptionYes, vote.Options[0].Option)
require.Equal(t, v1beta1.OptionYes, vote.Option)
// Test second vote
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], types.WeightedVoteOptions{
types.WeightedVoteOption{Option: types.OptionYes, Weight: sdk.NewDecWithPrec(60, 2)},
types.WeightedVoteOption{Option: types.OptionNo, Weight: sdk.NewDecWithPrec(30, 2)},
types.WeightedVoteOption{Option: types.OptionAbstain, Weight: sdk.NewDecWithPrec(5, 2)},
types.WeightedVoteOption{Option: types.OptionNoWithVeto, Weight: sdk.NewDecWithPrec(5, 2)},
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, addrs[1], v1beta1.WeightedVoteOptions{
v1beta1.WeightedVoteOption{Option: v1beta1.OptionYes, Weight: sdk.NewDecWithPrec(60, 2)},
v1beta1.WeightedVoteOption{Option: v1beta1.OptionNo, Weight: sdk.NewDecWithPrec(30, 2)},
v1beta1.WeightedVoteOption{Option: v1beta1.OptionAbstain, Weight: sdk.NewDecWithPrec(5, 2)},
v1beta1.WeightedVoteOption{Option: v1beta1.OptionNoWithVeto, Weight: sdk.NewDecWithPrec(5, 2)},
}))
vote, found = app.GovKeeper.GetVote(ctx, proposalID, addrs[1])
require.True(t, found)
require.Equal(t, addrs[1].String(), vote.Voter)
require.Equal(t, proposalID, vote.ProposalId)
require.True(t, len(vote.Options) == 4)
require.Equal(t, types.OptionYes, vote.Options[0].Option)
require.Equal(t, types.OptionNo, vote.Options[1].Option)
require.Equal(t, types.OptionAbstain, vote.Options[2].Option)
require.Equal(t, types.OptionNoWithVeto, vote.Options[3].Option)
require.Equal(t, v1beta1.OptionYes, vote.Options[0].Option)
require.Equal(t, v1beta1.OptionNo, vote.Options[1].Option)
require.Equal(t, v1beta1.OptionAbstain, vote.Options[2].Option)
require.Equal(t, v1beta1.OptionNoWithVeto, vote.Options[3].Option)
require.True(t, vote.Options[0].Weight.Equal(sdk.NewDecWithPrec(60, 2)))
require.True(t, vote.Options[1].Weight.Equal(sdk.NewDecWithPrec(30, 2)))
require.True(t, vote.Options[2].Weight.Equal(sdk.NewDecWithPrec(5, 2)))
require.True(t, vote.Options[3].Weight.Equal(sdk.NewDecWithPrec(5, 2)))
require.Equal(t, types.OptionEmpty, vote.Option)
require.Equal(t, v1beta1.OptionEmpty, vote.Option)
// Test vote iterator
// NOTE order of deposits is determined by the addresses
@ -82,7 +82,7 @@ func TestVotes(t *testing.T) {
require.Equal(t, addrs[0].String(), votes[0].Voter)
require.Equal(t, proposalID, votes[0].ProposalId)
require.True(t, len(votes[0].Options) == 1)
require.Equal(t, types.OptionYes, votes[0].Options[0].Option)
require.Equal(t, v1beta1.OptionYes, votes[0].Options[0].Option)
require.Equal(t, addrs[1].String(), votes[1].Voter)
require.Equal(t, proposalID, votes[1].ProposalId)
require.True(t, len(votes[1].Options) == 4)
@ -90,5 +90,5 @@ func TestVotes(t *testing.T) {
require.True(t, votes[1].Options[1].Weight.Equal(sdk.NewDecWithPrec(30, 2)))
require.True(t, votes[1].Options[2].Weight.Equal(sdk.NewDecWithPrec(5, 2)))
require.True(t, votes[1].Options[3].Weight.Equal(sdk.NewDecWithPrec(5, 2)))
require.Equal(t, types.OptionEmpty, vote.Option)
require.Equal(t, v1beta1.OptionEmpty, vote.Option)
}

View File

@ -10,7 +10,7 @@ import (
v040distr "github.com/cosmos/cosmos-sdk/x/distribution/types"
v034gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v034"
v036gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v036"
v040gov "github.com/cosmos/cosmos-sdk/x/gov/types"
v040gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
v036params "github.com/cosmos/cosmos-sdk/x/params/migrations/v036"
v040params "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
v038upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/migrations/v038"

View File

@ -24,6 +24,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
"github.com/cosmos/cosmos-sdk/x/gov/simulation"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
var (
@ -52,23 +53,23 @@ func (AppModuleBasic) Name() string {
// RegisterLegacyAminoCodec registers the gov module's types for the given codec.
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterLegacyAminoCodec(cdc)
v1beta1.RegisterLegacyAminoCodec(cdc)
}
// DefaultGenesis returns default genesis state as raw bytes for the gov
// module.
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
return cdc.MustMarshalJSON(types.DefaultGenesisState())
return cdc.MustMarshalJSON(v1beta1.DefaultGenesisState())
}
// ValidateGenesis performs genesis state validation for the gov module.
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
var data types.GenesisState
var data v1beta1.GenesisState
if err := cdc.UnmarshalJSON(bz, &data); err != nil {
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
}
return types.ValidateGenesis(&data)
return v1beta1.ValidateGenesis(&data)
}
// RegisterRESTRoutes registers the REST routes for the gov module.
@ -78,7 +79,7 @@ func (a AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Ro
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the gov module.
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil {
if err := v1beta1.RegisterQueryHandlerClient(context.Background(), mux, v1beta1.NewQueryClient(clientCtx)); err != nil {
panic(err)
}
}
@ -100,7 +101,7 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command {
// RegisterInterfaces implements InterfaceModule.RegisterInterfaces
func (a AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
types.RegisterInterfaces(registry)
v1beta1.RegisterInterfaces(registry)
}
// AppModule implements an application module for the gov module.
@ -149,8 +150,8 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
// RegisterServices registers module services.
func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
v1beta1.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
v1beta1.RegisterQueryServer(cfg.QueryServer(), am.keeper)
m := keeper.NewMigrator(am.keeper)
err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2)
@ -162,7 +163,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
// InitGenesis performs genesis initialization for the gov module. It returns
// no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
var genesisState types.GenesisState
var genesisState v1beta1.GenesisState
cdc.MustUnmarshalJSON(data, &genesisState)
InitGenesis(ctx, am.accountKeeper, am.bankKeeper, am.keeper, &genesisState)
return []abci.ValidatorUpdate{}

View File

@ -8,6 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's
@ -16,12 +17,12 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string {
return func(kvA, kvB kv.Pair) string {
switch {
case bytes.Equal(kvA.Key[:1], types.ProposalsKeyPrefix):
var proposalA types.Proposal
var proposalA v1beta1.Proposal
err := cdc.Unmarshal(kvA.Value, &proposalA)
if err != nil {
panic(err)
}
var proposalB types.Proposal
var proposalB v1beta1.Proposal
err = cdc.Unmarshal(kvB.Value, &proposalB)
if err != nil {
panic(err)
@ -36,13 +37,13 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string {
return fmt.Sprintf("proposalIDA: %d\nProposalIDB: %d", proposalIDA, proposalIDB)
case bytes.Equal(kvA.Key[:1], types.DepositsKeyPrefix):
var depositA, depositB types.Deposit
var depositA, depositB v1beta1.Deposit
cdc.MustUnmarshal(kvA.Value, &depositA)
cdc.MustUnmarshal(kvB.Value, &depositB)
return fmt.Sprintf("%v\n%v", depositA, depositB)
case bytes.Equal(kvA.Key[:1], types.VotesKeyPrefix):
var voteA, voteB types.Vote
var voteA, voteB v1beta1.Vote
cdc.MustUnmarshal(kvA.Value, &voteA)
cdc.MustUnmarshal(kvB.Value, &voteB)
return fmt.Sprintf("%v\n%v", voteA, voteB)

View File

@ -14,6 +14,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/cosmos/cosmos-sdk/x/gov/simulation"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
var (
@ -26,16 +27,16 @@ func TestDecodeStore(t *testing.T) {
dec := simulation.NewDecodeStore(cdc)
endTime := time.Now().UTC()
content := types.ContentFromProposalType("test", "test", types.ProposalTypeText)
proposalA, err := types.NewProposal(content, 1, endTime, endTime.Add(24*time.Hour))
content := v1beta1.ContentFromProposalType("test", "test", v1beta1.ProposalTypeText)
proposalA, err := v1beta1.NewProposal(content, 1, endTime, endTime.Add(24*time.Hour))
require.NoError(t, err)
proposalB, err := types.NewProposal(content, 2, endTime, endTime.Add(24*time.Hour))
proposalB, err := v1beta1.NewProposal(content, 2, endTime, endTime.Add(24*time.Hour))
require.NoError(t, err)
proposalIDBz := make([]byte, 8)
binary.LittleEndian.PutUint64(proposalIDBz, 1)
deposit := types.NewDeposit(1, delAddr1, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt())))
vote := types.NewVote(1, delAddr1, types.NewNonSplitVoteOption(types.OptionYes))
deposit := v1beta1.NewDeposit(1, delAddr1, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt())))
vote := v1beta1.NewVote(1, delAddr1, v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes))
proposalBzA, err := cdc.Marshal(&proposalA)
require.NoError(t, err)

View File

@ -13,6 +13,7 @@ import (
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/simulation"
)
@ -125,21 +126,21 @@ func SimulateMsgSubmitProposal(
// 1) submit proposal now
content := contentSim(r, ctx, accs)
if content == nil {
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSubmitProposal, "content is nil"), nil, nil
return simtypes.NoOpMsg(v1beta1.ModuleName, v1beta1.TypeMsgSubmitProposal, "content is nil"), nil, nil
}
simAccount, _ := simtypes.RandomAcc(r, accs)
deposit, skip, err := randomDeposit(r, ctx, ak, bk, k, simAccount.Address)
switch {
case skip:
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSubmitProposal, "skip deposit"), nil, nil
return simtypes.NoOpMsg(v1beta1.ModuleName, v1beta1.TypeMsgSubmitProposal, "skip deposit"), nil, nil
case err != nil:
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSubmitProposal, "unable to generate deposit"), nil, err
return simtypes.NoOpMsg(v1beta1.ModuleName, v1beta1.TypeMsgSubmitProposal, "unable to generate deposit"), nil, err
}
msg, err := types.NewMsgSubmitProposal(content, deposit, simAccount.Address)
msg, err := v1beta1.NewMsgSubmitProposal(content, deposit, simAccount.Address)
if err != nil {
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate a submit proposal msg"), nil, err
return simtypes.NoOpMsg(v1beta1.ModuleName, msg.Type(), "unable to generate a submit proposal msg"), nil, err
}
account := ak.GetAccount(ctx, simAccount.Address)
@ -150,7 +151,7 @@ func SimulateMsgSubmitProposal(
if !hasNeg {
fees, err = simtypes.RandomFees(r, ctx, coins)
if err != nil {
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate fees"), nil, err
return simtypes.NoOpMsg(v1beta1.ModuleName, msg.Type(), "unable to generate fees"), nil, err
}
}
@ -166,12 +167,12 @@ func SimulateMsgSubmitProposal(
simAccount.PrivKey,
)
if err != nil {
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err
return simtypes.NoOpMsg(v1beta1.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err
}
_, _, err = app.SimDeliver(txGen.TxEncoder(), tx)
if err != nil {
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err
return simtypes.NoOpMsg(v1beta1.ModuleName, msg.Type(), "unable to deliver tx"), nil, err
}
opMsg := simtypes.NewOperationMsg(msg, true, "", nil)
@ -179,7 +180,7 @@ func SimulateMsgSubmitProposal(
// get the submitted proposal ID
proposalID, err := k.GetProposalID(ctx)
if err != nil {
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate proposalID"), nil, err
return simtypes.NoOpMsg(v1beta1.ModuleName, msg.Type(), "unable to generate proposalID"), nil, err
}
// 2) Schedule operations for votes
@ -214,20 +215,20 @@ func SimulateMsgDeposit(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Ke
accs []simtypes.Account, chainID string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
simAccount, _ := simtypes.RandomAcc(r, accs)
proposalID, ok := randomProposalID(r, k, ctx, types.StatusDepositPeriod)
proposalID, ok := randomProposalID(r, k, ctx, v1beta1.StatusDepositPeriod)
if !ok {
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgDeposit, "unable to generate proposalID"), nil, nil
return simtypes.NoOpMsg(v1beta1.ModuleName, v1beta1.TypeMsgDeposit, "unable to generate proposalID"), nil, nil
}
deposit, skip, err := randomDeposit(r, ctx, ak, bk, k, simAccount.Address)
switch {
case skip:
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgDeposit, "skip deposit"), nil, nil
return simtypes.NoOpMsg(v1beta1.ModuleName, v1beta1.TypeMsgDeposit, "skip deposit"), nil, nil
case err != nil:
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgDeposit, "unable to generate deposit"), nil, err
return simtypes.NoOpMsg(v1beta1.ModuleName, v1beta1.TypeMsgDeposit, "unable to generate deposit"), nil, err
}
msg := types.NewMsgDeposit(simAccount.Address, proposalID, deposit)
msg := v1beta1.NewMsgDeposit(simAccount.Address, proposalID, deposit)
account := ak.GetAccount(ctx, simAccount.Address)
spendable := bk.SpendableCoins(ctx, account.GetAddress())
@ -237,7 +238,7 @@ func SimulateMsgDeposit(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Ke
if !hasNeg {
fees, err = simtypes.RandomFees(r, ctx, coins)
if err != nil {
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate fees"), nil, err
return simtypes.NoOpMsg(v1beta1.ModuleName, msg.Type(), "unable to generate fees"), nil, err
}
}
@ -250,7 +251,7 @@ func SimulateMsgDeposit(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Ke
Context: ctx,
SimAccount: simAccount,
AccountKeeper: ak,
ModuleName: types.ModuleName,
ModuleName: v1beta1.ModuleName,
}
return simulation.GenAndDeliverTx(txCtx, fees)
@ -277,16 +278,16 @@ func operationSimulateMsgVote(ak types.AccountKeeper, bk types.BankKeeper, k kee
switch {
case proposalIDInt < 0:
var ok bool
proposalID, ok = randomProposalID(r, k, ctx, types.StatusVotingPeriod)
proposalID, ok = randomProposalID(r, k, ctx, v1beta1.StatusVotingPeriod)
if !ok {
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgVote, "unable to generate proposalID"), nil, nil
return simtypes.NoOpMsg(v1beta1.ModuleName, v1beta1.TypeMsgVote, "unable to generate proposalID"), nil, nil
}
default:
proposalID = uint64(proposalIDInt)
}
option := randomVotingOption(r)
msg := types.NewMsgVote(simAccount.Address, proposalID, option)
msg := v1beta1.NewMsgVote(simAccount.Address, proposalID, option)
account := ak.GetAccount(ctx, simAccount.Address)
spendable := bk.SpendableCoins(ctx, account.GetAddress())
@ -302,7 +303,7 @@ func operationSimulateMsgVote(ak types.AccountKeeper, bk types.BankKeeper, k kee
SimAccount: simAccount,
AccountKeeper: ak,
Bankkeeper: bk,
ModuleName: types.ModuleName,
ModuleName: v1beta1.ModuleName,
CoinsSpentInMsg: spendable,
}
@ -330,16 +331,16 @@ func operationSimulateMsgVoteWeighted(ak types.AccountKeeper, bk types.BankKeepe
switch {
case proposalIDInt < 0:
var ok bool
proposalID, ok = randomProposalID(r, k, ctx, types.StatusVotingPeriod)
proposalID, ok = randomProposalID(r, k, ctx, v1beta1.StatusVotingPeriod)
if !ok {
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgVoteWeighted, "unable to generate proposalID"), nil, nil
return simtypes.NoOpMsg(v1beta1.ModuleName, v1beta1.TypeMsgVoteWeighted, "unable to generate proposalID"), nil, nil
}
default:
proposalID = uint64(proposalIDInt)
}
options := randomWeightedVotingOptions(r)
msg := types.NewMsgVoteWeighted(simAccount.Address, proposalID, options)
msg := v1beta1.NewMsgVoteWeighted(simAccount.Address, proposalID, options)
account := ak.GetAccount(ctx, simAccount.Address)
spendable := bk.SpendableCoins(ctx, account.GetAddress())
@ -355,7 +356,7 @@ func operationSimulateMsgVoteWeighted(ak types.AccountKeeper, bk types.BankKeepe
SimAccount: simAccount,
AccountKeeper: ak,
Bankkeeper: bk,
ModuleName: types.ModuleName,
ModuleName: v1beta1.ModuleName,
CoinsSpentInMsg: spendable,
}
@ -404,7 +405,7 @@ func randomDeposit(r *rand.Rand, ctx sdk.Context,
// that matches a given Status.
// It does not provide a default ID.
func randomProposalID(r *rand.Rand, k keeper.Keeper,
ctx sdk.Context, status types.ProposalStatus) (proposalID uint64, found bool) {
ctx sdk.Context, status v1beta1.ProposalStatus) (proposalID uint64, found bool) {
proposalID, _ = k.GetProposalID(ctx)
switch {
@ -427,49 +428,49 @@ func randomProposalID(r *rand.Rand, k keeper.Keeper,
}
// Pick a random voting option
func randomVotingOption(r *rand.Rand) types.VoteOption {
func randomVotingOption(r *rand.Rand) v1beta1.VoteOption {
switch r.Intn(4) {
case 0:
return types.OptionYes
return v1beta1.OptionYes
case 1:
return types.OptionAbstain
return v1beta1.OptionAbstain
case 2:
return types.OptionNo
return v1beta1.OptionNo
case 3:
return types.OptionNoWithVeto
return v1beta1.OptionNoWithVeto
default:
panic("invalid vote option")
}
}
// Pick a random weighted voting options
func randomWeightedVotingOptions(r *rand.Rand) types.WeightedVoteOptions {
func randomWeightedVotingOptions(r *rand.Rand) v1beta1.WeightedVoteOptions {
w1 := r.Intn(100 + 1)
w2 := r.Intn(100 - w1 + 1)
w3 := r.Intn(100 - w1 - w2 + 1)
w4 := 100 - w1 - w2 - w3
weightedVoteOptions := types.WeightedVoteOptions{}
weightedVoteOptions := v1beta1.WeightedVoteOptions{}
if w1 > 0 {
weightedVoteOptions = append(weightedVoteOptions, types.WeightedVoteOption{
Option: types.OptionYes,
weightedVoteOptions = append(weightedVoteOptions, v1beta1.WeightedVoteOption{
Option: v1beta1.OptionYes,
Weight: sdk.NewDecWithPrec(int64(w1), 2),
})
}
if w2 > 0 {
weightedVoteOptions = append(weightedVoteOptions, types.WeightedVoteOption{
Option: types.OptionAbstain,
weightedVoteOptions = append(weightedVoteOptions, v1beta1.WeightedVoteOption{
Option: v1beta1.OptionAbstain,
Weight: sdk.NewDecWithPrec(int64(w2), 2),
})
}
if w3 > 0 {
weightedVoteOptions = append(weightedVoteOptions, types.WeightedVoteOption{
Option: types.OptionNo,
weightedVoteOptions = append(weightedVoteOptions, v1beta1.WeightedVoteOption{
Option: v1beta1.OptionNo,
Weight: sdk.NewDecWithPrec(int64(w3), 2),
})
}
if w4 > 0 {
weightedVoteOptions = append(weightedVoteOptions, types.WeightedVoteOption{
Option: types.OptionNoWithVeto,
weightedVoteOptions = append(weightedVoteOptions, v1beta1.WeightedVoteOption{
Option: v1beta1.OptionNoWithVeto,
Weight: sdk.NewDecWithPrec(int64(w4), 2),
})
}

View File

@ -16,7 +16,7 @@ import (
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/gov/simulation"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
)
@ -34,7 +34,7 @@ func (m MockWeightedProposalContent) DefaultWeight() int {
func (m MockWeightedProposalContent) ContentSimulatorFn() simtypes.ContentSimulatorFn {
return func(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) simtypes.Content {
return types.NewTextProposal(
return v1beta1.NewTextProposal(
fmt.Sprintf("title-%d: %s", m.n, simtypes.RandStringOfLength(r, 100)),
fmt.Sprintf("description-%d: %s", m.n, simtypes.RandStringOfLength(r, 4000)),
)
@ -76,12 +76,12 @@ func TestWeightedOperations(t *testing.T) {
opMsgRoute string
opMsgName string
}{
{0, types.ModuleName, "submit_proposal"},
{1, types.ModuleName, "submit_proposal"},
{2, types.ModuleName, "submit_proposal"},
{simappparams.DefaultWeightMsgDeposit, types.ModuleName, types.TypeMsgDeposit},
{simappparams.DefaultWeightMsgVote, types.ModuleName, types.TypeMsgVote},
{simappparams.DefaultWeightMsgVoteWeighted, types.ModuleName, types.TypeMsgVoteWeighted},
{0, v1beta1.ModuleName, "submit_proposal"},
{1, v1beta1.ModuleName, "submit_proposal"},
{2, v1beta1.ModuleName, "submit_proposal"},
{simappparams.DefaultWeightMsgDeposit, v1beta1.ModuleName, v1beta1.TypeMsgDeposit},
{simappparams.DefaultWeightMsgVote, v1beta1.ModuleName, v1beta1.TypeMsgVote},
{simappparams.DefaultWeightMsgVoteWeighted, v1beta1.ModuleName, v1beta1.TypeMsgVoteWeighted},
}
for i, w := range weightesOps {
@ -113,8 +113,8 @@ func TestSimulateMsgSubmitProposal(t *testing.T) {
operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "")
require.NoError(t, err)
var msg types.MsgSubmitProposal
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
var msg v1beta1.MsgSubmitProposal
v1beta1.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.True(t, operationMsg.OK)
require.Equal(t, "cosmos1p8wcgrjr4pjju90xg6u9cgq55dxwq8j7u4x9a0", msg.Proposer)
@ -122,7 +122,7 @@ func TestSimulateMsgSubmitProposal(t *testing.T) {
require.Equal(t, "title-3: ZBSpYuLyYggwexjxusrBqDOTtGTOWeLrQKjLxzIivHSlcxgdXhhuTSkuxKGLwQvuyNhYFmBZHeAerqyNEUzXPFGkqEGqiQWIXnku", msg.GetContent().GetTitle())
require.Equal(t, "description-3: NJWzHdBNpAXKJPHWQdrGYcAHSctgVlqwqHoLfHsXUdStwfefwzqLuKEhmMyYLdbZrcPgYqjNHxPexsruwEGStAneKbWkQDDIlCWBLSiAASNhZqNF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FmoBhQqmkfbHVsgfHXDPJVyhwPllQpuYLRYvGodxKjkarnSNgsXoKEMlaSKxKdcVgvOkuLcfLFfdtXGTclqfPOfeoVLbqcjcXCUEBgAGplrkgsmIEhWRZLlGPGCwKWRaCKMkBHTAcypUrYjWwCLtOPVygMwMANGoQwFnCqFrUGMCRZUGJKTZIGPyldsifauoMnJPLTcDHmilcmahlqOELaAUYDBuzsVywnDQfwRLGIWozYaOAilMBcObErwgTDNGWnwQMUgFFSKtPDMEoEQCTKVREqrXZSGLqwTMcxHfWotDllNkIJPMbXzjDVjPOOjCFuIvTyhXKLyhUScOXvYthRXpPfKwMhptXaxIxgqBoUqzrWbaoLTVpQoottZyPFfNOoMioXHRuFwMRYUiKvcWPkrayyTLOCFJlAyslDameIuqVAuxErqFPEWIScKpBORIuZqoXlZuTvAjEdlEWDODFRregDTqGNoFBIHxvimmIZwLfFyKUfEWAnNBdtdzDmTPXtpHRGdIbuucfTjOygZsTxPjfweXhSUkMhPjMaxKlMIJMOXcnQfyzeOcbWwNbeH", msg.GetContent().GetDescription())
require.Equal(t, "gov", msg.Route())
require.Equal(t, types.TypeMsgSubmitProposal, msg.Type())
require.Equal(t, v1beta1.TypeMsgSubmitProposal, msg.Type())
}
// TestSimulateMsgDeposit tests the normal scenario of a valid message of type TypeMsgDeposit.
@ -138,12 +138,12 @@ func TestSimulateMsgDeposit(t *testing.T) {
accounts := getTestingAccounts(t, r, app, ctx, 3)
// setup a proposal
content := types.NewTextProposal("Test", "description")
content := v1beta1.NewTextProposal("Test", "description")
submitTime := ctx.BlockHeader().Time
depositPeriod := app.GovKeeper.GetDepositParams(ctx).MaxDepositPeriod
proposal, err := types.NewProposal(content, 1, submitTime, submitTime.Add(depositPeriod))
proposal, err := v1beta1.NewProposal(content, 1, submitTime, submitTime.Add(depositPeriod))
require.NoError(t, err)
app.GovKeeper.SetProposal(ctx, proposal)
@ -156,15 +156,15 @@ func TestSimulateMsgDeposit(t *testing.T) {
operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "")
require.NoError(t, err)
var msg types.MsgDeposit
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
var msg v1beta1.MsgDeposit
v1beta1.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.True(t, operationMsg.OK)
require.Equal(t, uint64(1), msg.ProposalId)
require.Equal(t, "cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.Depositor)
require.Equal(t, "560969stake", msg.Amount.String())
require.Equal(t, "gov", msg.Route())
require.Equal(t, types.TypeMsgDeposit, msg.Type())
require.Equal(t, v1beta1.TypeMsgDeposit, msg.Type())
}
// TestSimulateMsgVote tests the normal scenario of a valid message of type TypeMsgVote.
@ -180,12 +180,12 @@ func TestSimulateMsgVote(t *testing.T) {
accounts := getTestingAccounts(t, r, app, ctx, 3)
// setup a proposal
content := types.NewTextProposal("Test", "description")
content := v1beta1.NewTextProposal("Test", "description")
submitTime := ctx.BlockHeader().Time
depositPeriod := app.GovKeeper.GetDepositParams(ctx).MaxDepositPeriod
proposal, err := types.NewProposal(content, 1, submitTime, submitTime.Add(depositPeriod))
proposal, err := v1beta1.NewProposal(content, 1, submitTime, submitTime.Add(depositPeriod))
require.NoError(t, err)
app.GovKeeper.ActivateVotingPeriod(ctx, proposal)
@ -198,15 +198,15 @@ func TestSimulateMsgVote(t *testing.T) {
operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "")
require.NoError(t, err)
var msg types.MsgVote
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
var msg v1beta1.MsgVote
v1beta1.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.True(t, operationMsg.OK)
require.Equal(t, uint64(1), msg.ProposalId)
require.Equal(t, "cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.Voter)
require.Equal(t, types.OptionYes, msg.Option)
require.Equal(t, v1beta1.OptionYes, msg.Option)
require.Equal(t, "gov", msg.Route())
require.Equal(t, types.TypeMsgVote, msg.Type())
require.Equal(t, v1beta1.TypeMsgVote, msg.Type())
}
// TestSimulateMsgVoteWeighted tests the normal scenario of a valid message of type TypeMsgVoteWeighted.
@ -222,12 +222,12 @@ func TestSimulateMsgVoteWeighted(t *testing.T) {
accounts := getTestingAccounts(t, r, app, ctx, 3)
// setup a proposal
content := types.NewTextProposal("Test", "description")
content := v1beta1.NewTextProposal("Test", "description")
submitTime := ctx.BlockHeader().Time
depositPeriod := app.GovKeeper.GetDepositParams(ctx).MaxDepositPeriod
proposal, err := types.NewProposal(content, 1, submitTime, submitTime.Add(depositPeriod))
proposal, err := v1beta1.NewProposal(content, 1, submitTime, submitTime.Add(depositPeriod))
require.NoError(t, err)
app.GovKeeper.ActivateVotingPeriod(ctx, proposal)
@ -240,15 +240,15 @@ func TestSimulateMsgVoteWeighted(t *testing.T) {
operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "")
require.NoError(t, err)
var msg types.MsgVoteWeighted
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
var msg v1beta1.MsgVoteWeighted
v1beta1.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.True(t, operationMsg.OK)
require.Equal(t, uint64(1), msg.ProposalId)
require.Equal(t, "cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.Voter)
require.True(t, len(msg.Options) >= 1)
require.Equal(t, "gov", msg.Route())
require.Equal(t, types.TypeMsgVoteWeighted, msg.Type())
require.Equal(t, v1beta1.TypeMsgVoteWeighted, msg.Type())
}
// returns context and an app with updated mint keeper

View File

@ -6,7 +6,7 @@ import (
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/simulation"
)
@ -26,7 +26,7 @@ func ProposalContents() []simtypes.WeightedProposalContent {
// SimulateTextProposalContent returns a random text proposal content.
func SimulateTextProposalContent(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) simtypes.Content {
return types.NewTextProposal(
return v1beta1.NewTextProposal(
simtypes.RandStringOfLength(r, 140),
simtypes.RandStringOfLength(r, 5000),
)

View File

@ -11,12 +11,10 @@ import (
// RegisterLegacyAminoCodec registers all the necessary types and interfaces for the
// governance module.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterInterface((*Content)(nil), nil)
cdc.RegisterConcrete(&MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal", nil)
cdc.RegisterConcrete(&MsgDeposit{}, "cosmos-sdk/MsgDeposit", nil)
cdc.RegisterConcrete(&MsgVote{}, "cosmos-sdk/MsgVote", nil)
cdc.RegisterConcrete(&MsgVoteWeighted{}, "cosmos-sdk/MsgVoteWeighted", nil)
cdc.RegisterConcrete(&TextProposal{}, "cosmos-sdk/TextProposal", nil)
}
func RegisterInterfaces(registry types.InterfaceRegistry) {
@ -26,11 +24,6 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
&MsgVoteWeighted{},
&MsgDeposit{},
)
registry.RegisterInterface(
"cosmos.gov.v1beta1.Content",
(*Content)(nil),
&TextProposal{},
)
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

View File

@ -1,55 +0,0 @@
package types
import (
"strings"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
// Constants pertaining to a Content object
const (
MaxDescriptionLength int = 10000
MaxTitleLength int = 140
)
// Content defines an interface that a proposal must implement. It contains
// information such as the title and description along with the type and routing
// information for the appropriate handler to process the proposal. Content can
// have additional fields, which will handled by a proposal's Handler.
// TODO Try to unify this interface with types/module/simulation
// https://github.com/cosmos/cosmos-sdk/issues/5853
type Content interface {
GetTitle() string
GetDescription() string
ProposalRoute() string
ProposalType() string
ValidateBasic() error
String() string
}
// Handler defines a function that handles a proposal after it has passed the
// governance process.
type Handler func(ctx sdk.Context, content Content) error
// ValidateAbstract validates a proposal's abstract contents returning an error
// if invalid.
func ValidateAbstract(c Content) error {
title := c.GetTitle()
if len(strings.TrimSpace(title)) == 0 {
return sdkerrors.Wrap(ErrInvalidProposalContent, "proposal title cannot be blank")
}
if len(title) > MaxTitleLength {
return sdkerrors.Wrapf(ErrInvalidProposalContent, "proposal title is longer than max length of %d", MaxTitleLength)
}
description := c.GetDescription()
if len(description) == 0 {
return sdkerrors.Wrap(ErrInvalidProposalContent, "proposal description cannot be blank")
}
if len(description) > MaxDescriptionLength {
return sdkerrors.Wrapf(ErrInvalidProposalContent, "proposal description is longer than max length of %d", MaxDescriptionLength)
}
return nil
}

View File

@ -6,12 +6,17 @@ import (
// x/gov module sentinel errors
var (
ErrUnknownProposal = sdkerrors.Register(ModuleName, 2, "unknown proposal")
ErrInactiveProposal = sdkerrors.Register(ModuleName, 3, "inactive proposal")
ErrAlreadyActiveProposal = sdkerrors.Register(ModuleName, 4, "proposal already active")
ErrInvalidProposalContent = sdkerrors.Register(ModuleName, 5, "invalid proposal content")
ErrInvalidProposalType = sdkerrors.Register(ModuleName, 6, "invalid proposal type")
ErrInvalidVote = sdkerrors.Register(ModuleName, 7, "invalid vote option")
ErrUnknownProposal = sdkerrors.Register(ModuleName, 2, "unknown proposal")
ErrInactiveProposal = sdkerrors.Register(ModuleName, 3, "inactive proposal")
ErrAlreadyActiveProposal = sdkerrors.Register(ModuleName, 4, "proposal already active")
// Errors 5 & 6 are reserved as legacy errors
// See x/gov/types/v1beta1/errors.go
ErrInvalidGenesis = sdkerrors.Register(ModuleName, 8, "invalid genesis state")
ErrNoProposalHandlerExists = sdkerrors.Register(ModuleName, 9, "no handler exists for proposal type")
ErrUnroutableProposalMsg = sdkerrors.Register(ModuleName, 10, "proposal message not recognized by router")
ErrNoProposalMsgs = sdkerrors.Register(ModuleName, 11, "no messages proposed")
ErrInvalidProposalMsg = sdkerrors.Register(ModuleName, 12, "invalid proposal message")
ErrInvalidSigner = sdkerrors.Register(ModuleName, 13, "expected gov account as only signer for proposal message")
ErrInvalidSignalMsg = sdkerrors.Register(ModuleName, 14, "signal message is invalid")
ErrInvalidVote = sdkerrors.Register(ModuleName, 15, "invalid vote option")
)

View File

@ -7,6 +7,7 @@ const (
EventTypeProposalVote = "proposal_vote"
EventTypeInactiveProposal = "inactive_proposal"
EventTypeActiveProposal = "active_proposal"
EventTypeSignalProposal = "signal_proposal"
AttributeKeyProposalResult = "proposal_result"
AttributeKeyOption = "option"
@ -18,4 +19,6 @@ const (
AttributeValueProposalRejected = "proposal_rejected" // didn't meet vote quorum
AttributeValueProposalFailed = "proposal_failed" // error on proposal handler
AttributeKeyProposalType = "proposal_type"
AttributeSignalTitle = "signal_title"
AttributeSignalDescription = "signal_description"
)

View File

@ -1,5 +1,5 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: cosmos/gov/v1beta1/genesis.proto
// source: cosmos/gov/v1beta2/genesis.proto
package types
@ -26,7 +26,7 @@ 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"`
StartingProposalId uint64 `protobuf:"varint,1,opt,name=starting_proposal_id,json=startingProposalId,proto3" json:"starting_proposal_id,omitempty" yaml:"starting_proposal_id"`
// deposits defines all the deposits present at genesis.
Deposits Deposits `protobuf:"bytes,2,rep,name=deposits,proto3,castrepeated=Deposits" json:"deposits"`
// votes defines all the votes present at genesis.
@ -34,18 +34,18 @@ type GenesisState struct {
// proposals defines all the proposals present at genesis.
Proposals Proposals `protobuf:"bytes,4,rep,name=proposals,proto3,castrepeated=Proposals" json:"proposals"`
// params defines all the paramaters of related to deposit.
DepositParams DepositParams `protobuf:"bytes,5,opt,name=deposit_params,json=depositParams,proto3" json:"deposit_params"`
DepositParams DepositParams `protobuf:"bytes,5,opt,name=deposit_params,json=depositParams,proto3" json:"deposit_params" yaml:"deposit_params"`
// params defines all the paramaters of related to voting.
VotingParams VotingParams `protobuf:"bytes,6,opt,name=voting_params,json=votingParams,proto3" json:"voting_params"`
VotingParams VotingParams `protobuf:"bytes,6,opt,name=voting_params,json=votingParams,proto3" json:"voting_params" yaml:"voting_params"`
// params defines all the paramaters of related to tally.
TallyParams TallyParams `protobuf:"bytes,7,opt,name=tally_params,json=tallyParams,proto3" json:"tally_params"`
TallyParams TallyParams `protobuf:"bytes,7,opt,name=tally_params,json=tallyParams,proto3" json:"tally_params" yaml:"tally_params"`
}
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_43cd825e0fa7a627, []int{0}
return fileDescriptor_7915ab39bb5aa171, []int{0}
}
func (m *GenesisState) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -124,38 +124,40 @@ func (m *GenesisState) GetTallyParams() TallyParams {
}
func init() {
proto.RegisterType((*GenesisState)(nil), "cosmos.gov.v1beta1.GenesisState")
proto.RegisterType((*GenesisState)(nil), "cosmos.gov.v1beta2.GenesisState")
}
func init() { proto.RegisterFile("cosmos/gov/v1beta1/genesis.proto", fileDescriptor_43cd825e0fa7a627) }
func init() { proto.RegisterFile("cosmos/gov/v1beta2/genesis.proto", fileDescriptor_7915ab39bb5aa171) }
var fileDescriptor_43cd825e0fa7a627 = []byte{
// 389 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xc1, 0x6e, 0xda, 0x40,
0x14, 0x45, 0xed, 0x62, 0x28, 0x0c, 0x50, 0xb5, 0x23, 0x16, 0x16, 0x45, 0xc6, 0xed, 0xca, 0x9b,
0x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x1c, 0x01, 0x67, 0x6e, 0x37, 0x87,
0xd4, 0xb3, 0x13, 0x7a, 0xf2, 0x16, 0xfd, 0x43, 0x5a, 0x45, 0x65, 0xd4, 0x35, 0x81, 0x18, 0x54,
0x21, 0x8a, 0xf2, 0xee, 0x87, 0x1c, 0xd3, 0x2a, 0x14, 0xf4, 0x1e, 0x09, 0xf4, 0x2f, 0x79, 0x97,
0x37, 0x9b, 0xc5, 0x7e, 0xe2, 0xaf, 0x50, 0xaf, 0x9b, 0xaa, 0xd5, 0x1e, 0x7f, 0x7a, 0xe5, 0x79,
0x53, 0x11, 0x74, 0xb5, 0x0c, 0xec, 0x75, 0x83, 0xb2, 0x48, 0x7f, 0x93, 0x6e, 0x0a, 0x72, 0xb0,
0x12, 0xd7, 0x10, 0x38, 0xf3, 0x85, 0x57, 0x66, 0x53, 0x2e, 0xd3, 0x3a, 0x69, 0x49, 0xa3, 0xbf,
0x48, 0x87, 0xfb, 0xcb, 0xe5, 0xa6, 0x60, 0xbd, 0x15, 0xac, 0x61, 0x15, 0xeb, 0x7f, 0x96, 0x7b,
0x82, 0x6a, 0xf3, 0x92, 0xe4, 0x6e, 0xf7, 0x86, 0xba, 0xdb, 0x1b, 0xea, 0xdd, 0xde, 0x50, 0x2f,
0x0f, 0x86, 0xb2, 0x3b, 0x18, 0xca, 0xf5, 0xc1, 0x50, 0x8e, 0xad, 0x30, 0xe2, 0x27, 0x67, 0x73,
0x7b, 0x01, 0x2b, 0x27, 0xdf, 0x22, 0xf9, 0xf9, 0x82, 0xc1, 0xa9, 0x73, 0x2e, 0x56, 0x8a, 0x6f,
0x62, 0x86, 0xf3, 0x86, 0xd8, 0xa6, 0x6f, 0xf7, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2d, 0x3b, 0x1a,
0xbf, 0xb9, 0x02, 0x00, 0x00,
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, 0x50, 0x40, 0x15, 0x56, 0x4f, 0x56,
0x5c, 0xb2, 0x45, 0x28, 0xf8, 0x25, 0xc7, 0x14, 0x83, 0xa2, 0x04, 0x09, 0x94, 0xea, 0x44, 0x20,
0xa0, 0x0a, 0x4c, 0xe2, 0x6c, 0x22, 0x40, 0x80, 0x3a, 0x0e, 0xeb, 0x7f, 0x3a, 0x79, 0x36, 0xeb,
0x62, 0x41, 0xa5, 0x4f, 0xfd, 0x9f, 0x7d, 0x32, 0x7a, 0xa9, 0xc9, 0x6f, 0x24, 0x93, 0x9c, 0xbe,
0x26, 0x13, 0x94, 0xac, 0x94, 0xe9, 0xa5, 0x58, 0x16, 0x25, 0x14, 0x80, 0x2c, 0x5b, 0xa6, 0x89,
0x6d, 0x79, 0xd6, 0xbc, 0x1f, 0xb9, 0x37, 0x5b, 0x77, 0xba, 0x61, 0x79, 0xf6, 0xcc, 0xef, 0x4a,
0xf9, 0x31, 0x6d, 0xca, 0x17, 0xa6, 0x7a, 0x9e, 0xd0, 0x73, 0x72, 0x92, 0xf0, 0x02, 0x30, 0x95,
0x68, 0xdf,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7a, 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,
}
func (m *GenesisState) Marshal() (dAtA []byte, err error) {

View File

@ -1,5 +1,5 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: cosmos/gov/v1beta1/gov.proto
// source: cosmos/gov/v1beta2/gov.proto
package types
@ -69,7 +69,7 @@ func (x VoteOption) String() string {
}
func (VoteOption) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_6e82113c1a9a4b7c, []int{0}
return fileDescriptor_5abf7b8852811c49, []int{0}
}
// ProposalStatus enumerates the valid statuses of a proposal.
@ -118,21 +118,19 @@ func (x ProposalStatus) String() string {
}
func (ProposalStatus) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_6e82113c1a9a4b7c, []int{1}
return fileDescriptor_5abf7b8852811c49, []int{1}
}
// WeightedVoteOption defines a unit of vote for vote split.
//
// Since: cosmos-sdk 0.43
type WeightedVoteOption struct {
Option VoteOption `protobuf:"varint,1,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,omitempty"`
Option VoteOption `protobuf:"varint,1,opt,name=option,proto3,enum=cosmos.gov.v1beta2.VoteOption" json:"option,omitempty"`
Weight github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=weight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"weight"`
}
func (m *WeightedVoteOption) Reset() { *m = WeightedVoteOption{} }
func (*WeightedVoteOption) ProtoMessage() {}
func (*WeightedVoteOption) Descriptor() ([]byte, []int) {
return fileDescriptor_6e82113c1a9a4b7c, []int{0}
return fileDescriptor_5abf7b8852811c49, []int{0}
}
func (m *WeightedVoteOption) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -161,45 +159,6 @@ func (m *WeightedVoteOption) XXX_DiscardUnknown() {
var xxx_messageInfo_WeightedVoteOption proto.InternalMessageInfo
// TextProposal defines a standard text proposal whose changes need to be
// manually updated in case of approval.
type TextProposal struct {
Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
}
func (m *TextProposal) Reset() { *m = TextProposal{} }
func (*TextProposal) ProtoMessage() {}
func (*TextProposal) Descriptor() ([]byte, []int) {
return fileDescriptor_6e82113c1a9a4b7c, []int{1}
}
func (m *TextProposal) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *TextProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_TextProposal.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 *TextProposal) XXX_Merge(src proto.Message) {
xxx_messageInfo_TextProposal.Merge(m, src)
}
func (m *TextProposal) XXX_Size() int {
return m.Size()
}
func (m *TextProposal) XXX_DiscardUnknown() {
xxx_messageInfo_TextProposal.DiscardUnknown(m)
}
var xxx_messageInfo_TextProposal proto.InternalMessageInfo
// Deposit defines an amount deposited by an account address to an active
// proposal.
type Deposit struct {
@ -211,7 +170,7 @@ type Deposit struct {
func (m *Deposit) Reset() { *m = Deposit{} }
func (*Deposit) ProtoMessage() {}
func (*Deposit) Descriptor() ([]byte, []int) {
return fileDescriptor_6e82113c1a9a4b7c, []int{2}
return fileDescriptor_5abf7b8852811c49, []int{1}
}
func (m *Deposit) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -242,21 +201,21 @@ var xxx_messageInfo_Deposit proto.InternalMessageInfo
// Proposal defines the core field members of a governance proposal.
type Proposal struct {
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"id"`
Content *types1.Any `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
Status ProposalStatus `protobuf:"varint,3,opt,name=status,proto3,enum=cosmos.gov.v1beta1.ProposalStatus" json:"status,omitempty"`
FinalTallyResult TallyResult `protobuf:"bytes,4,opt,name=final_tally_result,json=finalTallyResult,proto3" json:"final_tally_result"`
SubmitTime time.Time `protobuf:"bytes,5,opt,name=submit_time,json=submitTime,proto3,stdtime" json:"submit_time"`
DepositEndTime time.Time `protobuf:"bytes,6,opt,name=deposit_end_time,json=depositEndTime,proto3,stdtime" json:"deposit_end_time"`
TotalDeposit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,7,rep,name=total_deposit,json=totalDeposit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"total_deposit"`
VotingStartTime time.Time `protobuf:"bytes,8,opt,name=voting_start_time,json=votingStartTime,proto3,stdtime" json:"voting_start_time"`
VotingEndTime time.Time `protobuf:"bytes,9,opt,name=voting_end_time,json=votingEndTime,proto3,stdtime" json:"voting_end_time"`
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"id" yaml:"id"`
Messages []*types1.Any `protobuf:"bytes,2,rep,name=messages,proto3" json:"messages,omitempty"`
Status ProposalStatus `protobuf:"varint,3,opt,name=status,proto3,enum=cosmos.gov.v1beta2.ProposalStatus" json:"status,omitempty" yaml:"proposal_status"`
FinalTallyResult TallyResult `protobuf:"bytes,4,opt,name=final_tally_result,json=finalTallyResult,proto3" json:"final_tally_result" yaml:"final_tally_result"`
SubmitTime time.Time `protobuf:"bytes,5,opt,name=submit_time,json=submitTime,proto3,stdtime" json:"submit_time" yaml:"submit_time"`
DepositEndTime time.Time `protobuf:"bytes,6,opt,name=deposit_end_time,json=depositEndTime,proto3,stdtime" json:"deposit_end_time" yaml:"deposit_end_time"`
TotalDeposit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,7,rep,name=total_deposit,json=totalDeposit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"total_deposit" yaml:"total_deposit"`
VotingStartTime time.Time `protobuf:"bytes,8,opt,name=voting_start_time,json=votingStartTime,proto3,stdtime" json:"voting_start_time" yaml:"voting_start_time"`
VotingEndTime time.Time `protobuf:"bytes,9,opt,name=voting_end_time,json=votingEndTime,proto3,stdtime" json:"voting_end_time" yaml:"voting_end_time"`
}
func (m *Proposal) Reset() { *m = Proposal{} }
func (*Proposal) ProtoMessage() {}
func (*Proposal) Descriptor() ([]byte, []int) {
return fileDescriptor_6e82113c1a9a4b7c, []int{3}
return fileDescriptor_5abf7b8852811c49, []int{2}
}
func (m *Proposal) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -296,7 +255,7 @@ type TallyResult struct {
func (m *TallyResult) Reset() { *m = TallyResult{} }
func (*TallyResult) ProtoMessage() {}
func (*TallyResult) Descriptor() ([]byte, []int) {
return fileDescriptor_6e82113c1a9a4b7c, []int{4}
return fileDescriptor_5abf7b8852811c49, []int{3}
}
func (m *TallyResult) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -333,15 +292,14 @@ type Vote struct {
// Deprecated: Prefer to use `options` instead. This field is set in queries
// if and only if `len(options) == 1` and that option has weight 1. In all
// other cases, this field will default to VOTE_OPTION_UNSPECIFIED.
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,omitempty"` // Deprecated: Do not use.
// Since: cosmos-sdk 0.43
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1beta2.VoteOption" json:"option,omitempty"` // Deprecated: Do not use.
Options []WeightedVoteOption `protobuf:"bytes,4,rep,name=options,proto3" json:"options"`
}
func (m *Vote) Reset() { *m = Vote{} }
func (*Vote) ProtoMessage() {}
func (*Vote) Descriptor() ([]byte, []int) {
return fileDescriptor_6e82113c1a9a4b7c, []int{5}
return fileDescriptor_5abf7b8852811c49, []int{4}
}
func (m *Vote) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -382,7 +340,7 @@ type DepositParams struct {
func (m *DepositParams) Reset() { *m = DepositParams{} }
func (*DepositParams) ProtoMessage() {}
func (*DepositParams) Descriptor() ([]byte, []int) {
return fileDescriptor_6e82113c1a9a4b7c, []int{6}
return fileDescriptor_5abf7b8852811c49, []int{5}
}
func (m *DepositParams) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -420,7 +378,7 @@ type VotingParams struct {
func (m *VotingParams) Reset() { *m = VotingParams{} }
func (*VotingParams) ProtoMessage() {}
func (*VotingParams) Descriptor() ([]byte, []int) {
return fileDescriptor_6e82113c1a9a4b7c, []int{7}
return fileDescriptor_5abf7b8852811c49, []int{6}
}
func (m *VotingParams) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -464,7 +422,7 @@ type TallyParams struct {
func (m *TallyParams) Reset() { *m = TallyParams{} }
func (*TallyParams) ProtoMessage() {}
func (*TallyParams) Descriptor() ([]byte, []int) {
return fileDescriptor_6e82113c1a9a4b7c, []int{8}
return fileDescriptor_5abf7b8852811c49, []int{7}
}
func (m *TallyParams) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -494,137 +452,111 @@ func (m *TallyParams) XXX_DiscardUnknown() {
var xxx_messageInfo_TallyParams proto.InternalMessageInfo
func init() {
proto.RegisterEnum("cosmos.gov.v1beta1.VoteOption", VoteOption_name, VoteOption_value)
proto.RegisterEnum("cosmos.gov.v1beta1.ProposalStatus", ProposalStatus_name, ProposalStatus_value)
proto.RegisterType((*WeightedVoteOption)(nil), "cosmos.gov.v1beta1.WeightedVoteOption")
proto.RegisterType((*TextProposal)(nil), "cosmos.gov.v1beta1.TextProposal")
proto.RegisterType((*Deposit)(nil), "cosmos.gov.v1beta1.Deposit")
proto.RegisterType((*Proposal)(nil), "cosmos.gov.v1beta1.Proposal")
proto.RegisterType((*TallyResult)(nil), "cosmos.gov.v1beta1.TallyResult")
proto.RegisterType((*Vote)(nil), "cosmos.gov.v1beta1.Vote")
proto.RegisterType((*DepositParams)(nil), "cosmos.gov.v1beta1.DepositParams")
proto.RegisterType((*VotingParams)(nil), "cosmos.gov.v1beta1.VotingParams")
proto.RegisterType((*TallyParams)(nil), "cosmos.gov.v1beta1.TallyParams")
proto.RegisterEnum("cosmos.gov.v1beta2.VoteOption", VoteOption_name, VoteOption_value)
proto.RegisterEnum("cosmos.gov.v1beta2.ProposalStatus", ProposalStatus_name, ProposalStatus_value)
proto.RegisterType((*WeightedVoteOption)(nil), "cosmos.gov.v1beta2.WeightedVoteOption")
proto.RegisterType((*Deposit)(nil), "cosmos.gov.v1beta2.Deposit")
proto.RegisterType((*Proposal)(nil), "cosmos.gov.v1beta2.Proposal")
proto.RegisterType((*TallyResult)(nil), "cosmos.gov.v1beta2.TallyResult")
proto.RegisterType((*Vote)(nil), "cosmos.gov.v1beta2.Vote")
proto.RegisterType((*DepositParams)(nil), "cosmos.gov.v1beta2.DepositParams")
proto.RegisterType((*VotingParams)(nil), "cosmos.gov.v1beta2.VotingParams")
proto.RegisterType((*TallyParams)(nil), "cosmos.gov.v1beta2.TallyParams")
}
func init() { proto.RegisterFile("cosmos/gov/v1beta1/gov.proto", fileDescriptor_6e82113c1a9a4b7c) }
func init() { proto.RegisterFile("cosmos/gov/v1beta2/gov.proto", fileDescriptor_5abf7b8852811c49) }
var fileDescriptor_6e82113c1a9a4b7c = []byte{
// 1352 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcf, 0x6f, 0x13, 0xc7,
0x17, 0xf7, 0xda, 0x8e, 0x93, 0x3c, 0x3b, 0xc9, 0x32, 0xe4, 0x0b, 0x8e,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xb2, 0x91, 0xe7, 0x6f, 0xb2, 0x91, 0x97, 0x6f, 0xb2, 0x91, 0xbb, 0x7f, 0x3f, 0xbf, 0x76, 0xd9,
0xff, 0x3c, 0xac, 0x6c, 0xb7, 0x12, 0x6c, 0x22, 0x7c, 0xfc, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff,
0x8c, 0x21, 0xa9, 0x1b, 0x0e, 0x0d, 0x00, 0x00,
var fileDescriptor_5abf7b8852811c49 = []byte{
// 1386 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0x4f, 0x6f, 0x13, 0x47,
0x1b, 0xf7, 0xda, 0xc6, 0x49, 0x26, 0x4e, 0x58, 0x26, 0x79, 0x93, 0x8d, 0x5f, 0xde, 0xdd, 0x7d,
0x97, 0x0a, 0x45, 0x08, 0x1c, 0x48, 0x2b, 0xa4, 0xa6, 0xbd, 0x78, 0xf1, 0xa6, 0x18, 0x21, 0xdb,
0x5a, 0x2f, 0x46, 0x50, 0xa9, 0xab, 0x8d, 0x77, 0x70, 0xb6, 0xf5, 0xee, 0x18, 0xef, 0x38, 0x90,
0x5b, 0x2f, 0x95, 0x90, 0x4f, 0x1c, 0xb9, 0x58, 0x42, 0xed, 0xad, 0x67, 0xbe, 0x40, 0x6f, 0x1c,
0x7a, 0xa0, 0x9c, 0x50, 0x0f, 0xa6, 0x04, 0xb5, 0xa2, 0xf4, 0xc6, 0x27, 0xa8, 0x76, 0x66, 0x36,
0xb1, 0x9d, 0xa8, 0x26, 0xe5, 0x94, 0xf5, 0xcc, 0xef, 0xcf, 0xf3, 0x3c, 0x3b, 0xcf, 0xb3, 0x13,
0x70, 0xba, 0x81, 0x43, 0x1f, 0x87, 0x6b, 0x4d, 0xbc, 0xb3, 0xb6, 0x73, 0x69, 0x0b, 0x11, 0x67,
0x3d, 0x7a, 0xce, 0xb7, 0x3b, 0x98, 0x60, 0x08, 0xd9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0xb7, 0xd4, 0xeb, 0xab,
0x90, 0x71, 0xeb, 0x43, 0xe7, 0x1c, 0x9e, 0x07, 0x4b, 0xe3, 0xd4, 0x6a, 0xa1, 0x56, 0x33, 0x8a,
0x62, 0x2a, 0x27, 0xf6, 0xfa, 0x6a, 0x96, 0x71, 0xaa, 0x4e, 0x18, 0xa2, 0xe8, 0x5a, 0x28, 0x8d,
0xa3, 0x4d, 0xe3, 0x9a, 0x71, 0xc5, 0x32, 0x8a, 0x62, 0x3a, 0x07, 0x7b, 0x7d, 0x75, 0x9e, 0xe1,
0x4d, 0xf4, 0x35, 0x6a, 0x10, 0x74, 0xa4, 0xfe, 0x66, 0xa1, 0x74, 0xdd, 0x28, 0x8a, 0x27, 0x86,
0xf5, 0x37, 0x1d, 0xaf, 0x85, 0x5c, 0x56, 0x4e, 0xbd, 0xfc, 0xf4, 0x95, 0x9c, 0x78, 0xf1, 0x4a,
0x4e, 0x7c, 0xbb, 0x27, 0x27, 0x9e, 0xee, 0xc9, 0xc2, 0xb3, 0x3d, 0x59, 0xf8, 0x6d, 0x4f, 0x16,
0x1e, 0xbe, 0x96, 0x13, 0xcf, 0x5e, 0xcb, 0x89, 0x17, 0xaf, 0xe5, 0xc4, 0xed, 0x7f, 0x9e, 0x5f,
0xf7, 0xe9, 0x7f, 0x55, 0xf4, 0xd8, 0x6e, 0x65, 0xe8, 0x44, 0xf8, 0xf8, 0xef, 0x00, 0x00, 0x00,
0xff, 0xff, 0x0c, 0xf2, 0xd0, 0x1b, 0x70, 0x0d, 0x00, 0x00,
}
func (this *TextProposal) Equal(that interface{}) bool {
if that == nil {
return this == nil
}
that1, ok := that.(*TextProposal)
if !ok {
that2, ok := that.(TextProposal)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
return this == nil
} else if this == nil {
return false
}
if this.Title != that1.Title {
return false
}
if this.Description != that1.Description {
return false
}
return true
}
func (this *Proposal) Equal(that interface{}) bool {
if that == nil {
return this == nil
@ -647,9 +579,14 @@ func (this *Proposal) Equal(that interface{}) bool {
if this.ProposalId != that1.ProposalId {
return false
}
if !this.Content.Equal(that1.Content) {
if len(this.Messages) != len(that1.Messages) {
return false
}
for i := range this.Messages {
if !this.Messages[i].Equal(that1.Messages[i]) {
return false
}
}
if this.Status != that1.Status {
return false
}
@ -749,43 +686,6 @@ func (m *WeightedVoteOption) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *TextProposal) 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 *TextProposal) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *TextProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Description) > 0 {
i -= len(m.Description)
copy(dAtA[i:], m.Description)
i = encodeVarintGov(dAtA, i, uint64(len(m.Description)))
i--
dAtA[i] = 0x12
}
if len(m.Title) > 0 {
i -= len(m.Title)
copy(dAtA[i:], m.Title)
i = encodeVarintGov(dAtA, i, uint64(len(m.Title)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *Deposit) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@ -916,17 +816,19 @@ func (m *Proposal) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i--
dAtA[i] = 0x18
}
if m.Content != nil {
{
size, err := m.Content.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if len(m.Messages) > 0 {
for iNdEx := len(m.Messages) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Messages[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGov(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintGov(dAtA, i, uint64(size))
i--
dAtA[i] = 0x12
}
i--
dAtA[i] = 0x12
}
if m.ProposalId != 0 {
i = encodeVarintGov(dAtA, i, uint64(m.ProposalId))
@ -1073,12 +975,12 @@ func (m *DepositParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
n7, err7 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxDepositPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxDepositPeriod):])
if err7 != nil {
return 0, err7
n6, err6 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxDepositPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxDepositPeriod):])
if err6 != nil {
return 0, err6
}
i -= n7
i = encodeVarintGov(dAtA, i, uint64(n7))
i -= n6
i = encodeVarintGov(dAtA, i, uint64(n6))
i--
dAtA[i] = 0x12
if len(m.MinDeposit) > 0 {
@ -1118,12 +1020,12 @@ func (m *VotingParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
n8, err8 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.VotingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.VotingPeriod):])
if err8 != nil {
return 0, err8
n7, err7 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.VotingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.VotingPeriod):])
if err7 != nil {
return 0, err7
}
i -= n8
i = encodeVarintGov(dAtA, i, uint64(n8))
i -= n7
i = encodeVarintGov(dAtA, i, uint64(n7))
i--
dAtA[i] = 0xa
return len(dAtA) - i, nil
@ -1207,23 +1109,6 @@ func (m *WeightedVoteOption) Size() (n int) {
return n
}
func (m *TextProposal) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Title)
if l > 0 {
n += 1 + l + sovGov(uint64(l))
}
l = len(m.Description)
if l > 0 {
n += 1 + l + sovGov(uint64(l))
}
return n
}
func (m *Deposit) Size() (n int) {
if m == nil {
return 0
@ -1255,9 +1140,11 @@ func (m *Proposal) Size() (n int) {
if m.ProposalId != 0 {
n += 1 + sovGov(uint64(m.ProposalId))
}
if m.Content != nil {
l = m.Content.Size()
n += 1 + l + sovGov(uint64(l))
if len(m.Messages) > 0 {
for _, e := range m.Messages {
l = e.Size()
n += 1 + l + sovGov(uint64(l))
}
}
if m.Status != 0 {
n += 1 + sovGov(uint64(m.Status))
@ -1475,120 +1362,6 @@ func (m *WeightedVoteOption) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *TextProposal) 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 ErrIntOverflowGov
}
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: TextProposal: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: TextProposal: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGov
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthGov
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthGov
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Title = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGov
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthGov
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthGov
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Description = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGov(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthGov
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *Deposit) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
@ -1774,7 +1547,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error {
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field Messages", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
@ -1801,10 +1574,8 @@ func (m *Proposal) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Content == nil {
m.Content = &types1.Any{}
}
if err := m.Content.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
m.Messages = append(m.Messages, &types1.Any{})
if err := m.Messages[len(m.Messages)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex

View File

@ -10,6 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
sdktx "github.com/cosmos/cosmos-sdk/types/tx"
)
// Governance message types and routes
@ -18,6 +19,7 @@ const (
TypeMsgVote = "vote"
TypeMsgVoteWeighted = "weighted_vote"
TypeMsgSubmitProposal = "submit_proposal"
TypeMsgSignal = "signal"
)
var (
@ -27,15 +29,16 @@ var (
// NewMsgSubmitProposal creates a new MsgSubmitProposal.
//nolint:interfacer
func NewMsgSubmitProposal(content Content, initialDeposit sdk.Coins, proposer sdk.AccAddress) (*MsgSubmitProposal, error) {
func NewMsgSubmitProposal(messages []sdk.Msg, initialDeposit sdk.Coins, proposer sdk.AccAddress) (*MsgSubmitProposal, error) {
m := &MsgSubmitProposal{
InitialDeposit: initialDeposit,
Proposer: proposer.String(),
}
err := m.SetContent(content)
if err != nil {
return nil, err
if err := m.SetMessages(messages); err != nil {
return &MsgSubmitProposal{}, err
}
return m, nil
}
@ -46,12 +49,8 @@ func (m *MsgSubmitProposal) GetProposer() sdk.AccAddress {
return proposer
}
func (m *MsgSubmitProposal) GetContent() Content {
content, ok := m.Content.GetCachedValue().(Content)
if !ok {
return nil
}
return content
func (m *MsgSubmitProposal) GetMessages() ([]sdk.Msg, error) {
return sdktx.GetMsgs(m.Messages, "sdk.MsgProposal")
}
func (m *MsgSubmitProposal) SetInitialDeposit(coins sdk.Coins) {
@ -62,16 +61,21 @@ func (m *MsgSubmitProposal) SetProposer(address fmt.Stringer) {
m.Proposer = address.String()
}
func (m *MsgSubmitProposal) SetContent(content Content) error {
msg, ok := content.(proto.Message)
if !ok {
return fmt.Errorf("can't proto marshal %T", msg)
func (m *MsgSubmitProposal) SetMessages(messages []sdk.Msg) error {
msgs := make([]*types.Any, len(messages))
for i, msg := range messages {
m, ok := msg.(proto.Message)
if !ok {
return fmt.Errorf("can't proto marshal %T", msg)
}
any, err := types.NewAnyWithValue(m)
if err != nil {
return err
}
msgs[i] = any
}
any, err := types.NewAnyWithValue(msg)
if err != nil {
return err
}
m.Content = any
m.Messages = msgs
return nil
}
@ -93,17 +97,24 @@ func (m MsgSubmitProposal) ValidateBasic() error {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.InitialDeposit.String())
}
content := m.GetContent()
if content == nil {
return sdkerrors.Wrap(ErrInvalidProposalContent, "missing content")
}
if !IsValidProposalType(content.ProposalType()) {
return sdkerrors.Wrap(ErrInvalidProposalType, content.ProposalType())
}
if err := content.ValidateBasic(); err != nil {
// Empty messages are not allowed
// TODO: ValidateBasic should check that either metadata or length is non nil
// if m.Messages == nil || len(m.Messages) == 0 {
// return ErrNoProposalMsgs
// }
msgs, err := m.GetMessages()
if err != nil {
return err
}
for idx, msg := range msgs {
if err := msg.ValidateBasic(); err != nil {
return sdkerrors.Wrap(ErrInvalidProposalMsg,
fmt.Sprintf("msg: %d, err: %s", idx, err.Error()))
}
}
return nil
}
@ -127,8 +138,7 @@ func (m MsgSubmitProposal) String() string {
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (m MsgSubmitProposal) UnpackInterfaces(unpacker types.AnyUnpacker) error {
var content Content
return unpacker.UnpackAny(m.Content, &content)
return sdktx.UnpackInterfaces(unpacker, m.Messages)
}
// NewMsgDeposit creates a new MsgDeposit instance

View File

@ -1,7 +1,6 @@
package types
import (
"strings"
"testing"
"github.com/stretchr/testify/require"
@ -23,42 +22,6 @@ func init() {
coinsMulti.Sort()
}
// test ValidateBasic for MsgCreateValidator
func TestMsgSubmitProposal(t *testing.T) {
tests := []struct {
title, description string
proposalType string
proposerAddr sdk.AccAddress
initialDeposit sdk.Coins
expectPass bool
}{
{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsPos, true},
{"", "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsPos, false},
{"Test Proposal", "", ProposalTypeText, addrs[0], coinsPos, false},
{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeText, sdk.AccAddress{}, coinsPos, false},
{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsZero, true},
{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsMulti, true},
{strings.Repeat("#", MaxTitleLength*2), "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsMulti, false},
{"Test Proposal", strings.Repeat("#", MaxDescriptionLength*2), ProposalTypeText, addrs[0], coinsMulti, false},
}
for i, tc := range tests {
msg, err := NewMsgSubmitProposal(
ContentFromProposalType(tc.title, tc.description, tc.proposalType),
tc.initialDeposit,
tc.proposerAddr,
)
require.NoError(t, err)
if tc.expectPass {
require.NoError(t, msg.ValidateBasic(), "test: %v", i)
} else {
require.Error(t, msg.ValidateBasic(), "test: %v", i)
}
}
}
func TestMsgDepositGetSignBytes(t *testing.T) {
addr := sdk.AccAddress("addr1")
msg := NewMsgDeposit(addr, 0, coinsPos)
@ -164,13 +127,13 @@ func TestMsgVoteWeighted(t *testing.T) {
// this tests that Amino JSON MsgSubmitProposal.GetSignBytes() still works with Content as Any using the ModuleCdc
func TestMsgSubmitProposal_GetSignBytes(t *testing.T) {
msg, err := NewMsgSubmitProposal(NewTextProposal("test", "abcd"), sdk.NewCoins(), sdk.AccAddress{})
proposal := []sdk.Msg{NewMsgVote(addrs[0], 1, OptionYes)}
msg, err := NewMsgSubmitProposal(proposal, sdk.NewCoins(), sdk.AccAddress{})
require.NoError(t, err)
var bz []byte
require.NotPanics(t, func() {
bz = msg.GetSignBytes()
})
require.Equal(t,
`{"type":"cosmos-sdk/MsgSubmitProposal","value":{"content":{"type":"cosmos-sdk/TextProposal","value":{"description":"abcd","title":"test"}},"initial_deposit":[]}}`,
require.Equal(t, "{\"type\":\"cosmos-sdk/MsgSubmitProposal\",\"value\":{\"initial_deposit\":[],\"messages\":[{\"type\":\"cosmos-sdk/MsgVote\",\"value\":{\"option\":1,\"proposal_id\":\"1\",\"voter\":\"cosmos1w3jhxap3gempvr\"}}]}}",
string(bz))
}

View File

@ -5,32 +5,27 @@ import (
"strings"
"time"
"github.com/gogo/protobuf/proto"
"sigs.k8s.io/yaml"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
sdktx "github.com/cosmos/cosmos-sdk/types/tx"
)
// DefaultStartingProposalID is 1
const DefaultStartingProposalID uint64 = 1
// NewProposal creates a new Proposal instance
func NewProposal(content Content, id uint64, submitTime, depositEndTime time.Time) (Proposal, error) {
msg, ok := content.(proto.Message)
if !ok {
return Proposal{}, fmt.Errorf("%T does not implement proto.Message", content)
}
func NewProposal(messages []sdk.Msg, id uint64, submitTime, depositEndTime time.Time) (Proposal, error) {
any, err := types.NewAnyWithValue(msg)
msgs, err := sdktx.SetMsgs(messages)
if err != nil {
return Proposal{}, err
}
p := Proposal{
Content: any,
ProposalId: id,
Messages: msgs,
Status: StatusDepositPeriod,
FinalTallyResult: EmptyTallyResult(),
TotalDeposit: sdk.NewCoins(),
@ -47,43 +42,14 @@ func (p Proposal) String() string {
return string(out)
}
// GetContent returns the proposal Content
func (p Proposal) GetContent() Content {
content, ok := p.Content.GetCachedValue().(Content)
if !ok {
return nil
}
return content
}
func (p Proposal) ProposalType() string {
content := p.GetContent()
if content == nil {
return ""
}
return content.ProposalType()
}
func (p Proposal) ProposalRoute() string {
content := p.GetContent()
if content == nil {
return ""
}
return content.ProposalRoute()
}
func (p Proposal) GetTitle() string {
content := p.GetContent()
if content == nil {
return ""
}
return content.GetTitle()
// GetMessages returns the proposal messages
func (p Proposal) GetMessages() ([]sdk.Msg, error) {
return sdktx.GetMsgs(p.Messages, "sdk.MsgProposal")
}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (p Proposal) UnpackInterfaces(unpacker types.AnyUnpacker) error {
var content Content
return unpacker.UnpackAny(p.Content, &content)
return sdktx.UnpackInterfaces(unpacker, p.Messages)
}
// Proposals is an array of proposal
@ -110,9 +76,8 @@ func (p Proposals) Equal(other Proposals) bool {
func (p Proposals) String() string {
out := "ID - (Status) [Type] Title\n"
for _, prop := range p {
out += fmt.Sprintf("%d - (%s) [%s] %s\n",
prop.ProposalId, prop.Status,
prop.ProposalType(), prop.GetTitle())
out += fmt.Sprintf("%d - %s\n",
prop.ProposalId, prop.Status)
}
return strings.TrimSpace(out)
}
@ -142,19 +107,6 @@ func ProposalStatusFromString(str string) (ProposalStatus, error) {
return ProposalStatus(num), nil
}
// ValidProposalStatus returns true if the proposal status is valid and false
// otherwise.
func ValidProposalStatus(status ProposalStatus) bool {
if status == StatusDepositPeriod ||
status == StatusVotingPeriod ||
status == StatusPassed ||
status == StatusRejected ||
status == StatusFailed {
return true
}
return false
}
// Marshal needed for protobuf compatibility
func (status ProposalStatus) Marshal() ([]byte, error) {
return []byte{byte(status)}, nil
@ -178,85 +130,15 @@ func (status ProposalStatus) Format(s fmt.State, verb rune) {
}
}
// Proposal types
const (
ProposalTypeText string = "Text"
)
// Implements Content Interface
var _ Content = &TextProposal{}
// NewTextProposal creates a text proposal Content
func NewTextProposal(title, description string) Content {
return &TextProposal{title, description}
}
// GetTitle returns the proposal title
func (tp *TextProposal) GetTitle() string { return tp.Title }
// GetDescription returns the proposal description
func (tp *TextProposal) GetDescription() string { return tp.Description }
// ProposalRoute returns the proposal router key
func (tp *TextProposal) ProposalRoute() string { return RouterKey }
// ProposalType is "Text"
func (tp *TextProposal) ProposalType() string { return ProposalTypeText }
// ValidateBasic validates the content's title and description of the proposal
func (tp *TextProposal) ValidateBasic() error { return ValidateAbstract(tp) }
// String implements Stringer interface
func (tp TextProposal) String() string {
out, _ := yaml.Marshal(tp)
return string(out)
}
var validProposalTypes = map[string]struct{}{
ProposalTypeText: {},
}
// RegisterProposalType registers a proposal type. It will panic if the type is
// already registered.
func RegisterProposalType(ty string) {
if _, ok := validProposalTypes[ty]; ok {
panic(fmt.Sprintf("already registered proposal type: %s", ty))
}
validProposalTypes[ty] = struct{}{}
}
// ContentFromProposalType returns a Content object based on the proposal type.
func ContentFromProposalType(title, desc, ty string) Content {
switch ty {
case ProposalTypeText:
return NewTextProposal(title, desc)
default:
return nil
}
}
// IsValidProposalType returns a boolean determining if the proposal type is
// valid.
//
// NOTE: Modules with their own proposal types must register them.
func IsValidProposalType(ty string) bool {
_, ok := validProposalTypes[ty]
return ok
}
// ProposalHandler implements the Handler interface for governance module-based
// proposals (ie. TextProposal ). Since these are
// merely signaling mechanisms at the moment and do not affect state, it
// performs a no-op.
func ProposalHandler(_ sdk.Context, c Content) error {
switch c.ProposalType() {
case ProposalTypeText:
// both proposal types do not change state so this performs a no-op
return nil
default:
return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized gov proposal type: %s", c.ProposalType())
// ValidProposalStatus returns true if the proposal status is valid and false
// otherwise.
func ValidProposalStatus(status ProposalStatus) bool {
if status == StatusDepositPeriod ||
status == StatusVotingPeriod ||
status == StatusPassed ||
status == StatusRejected ||
status == StatusFailed {
return true
}
return false
}

View File

@ -1,16 +1,17 @@
package types
package types_test
import (
"fmt"
"testing"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/stretchr/testify/require"
)
func TestProposalStatus_Format(t *testing.T) {
statusDepositPeriod, _ := ProposalStatusFromString("PROPOSAL_STATUS_DEPOSIT_PERIOD")
statusDepositPeriod, _ := types.ProposalStatusFromString("PROPOSAL_STATUS_DEPOSIT_PERIOD")
tests := []struct {
pt ProposalStatus
pt types.ProposalStatus
sprintFArgs string
expectedStringOutput string
}{

View File

@ -1,5 +1,5 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: cosmos/gov/v1beta1/query.proto
// source: cosmos/gov/v1beta2/query.proto
package types
@ -41,7 +41,7 @@ func (m *QueryProposalRequest) Reset() { *m = QueryProposalRequest{} }
func (m *QueryProposalRequest) String() string { return proto.CompactTextString(m) }
func (*QueryProposalRequest) ProtoMessage() {}
func (*QueryProposalRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{0}
return fileDescriptor_3efdc0c4615c3665, []int{0}
}
func (m *QueryProposalRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -86,7 +86,7 @@ func (m *QueryProposalResponse) Reset() { *m = QueryProposalResponse{} }
func (m *QueryProposalResponse) String() string { return proto.CompactTextString(m) }
func (*QueryProposalResponse) ProtoMessage() {}
func (*QueryProposalResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{1}
return fileDescriptor_3efdc0c4615c3665, []int{1}
}
func (m *QueryProposalResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -125,7 +125,7 @@ func (m *QueryProposalResponse) GetProposal() Proposal {
// QueryProposalsRequest is the request type for the Query/Proposals RPC method.
type QueryProposalsRequest struct {
// proposal_status defines the status of the proposals.
ProposalStatus ProposalStatus `protobuf:"varint,1,opt,name=proposal_status,json=proposalStatus,proto3,enum=cosmos.gov.v1beta1.ProposalStatus" json:"proposal_status,omitempty"`
ProposalStatus ProposalStatus `protobuf:"varint,1,opt,name=proposal_status,json=proposalStatus,proto3,enum=cosmos.gov.v1beta2.ProposalStatus" json:"proposal_status,omitempty"`
// voter defines the voter address for the proposals.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// depositor defines the deposit addresses from the proposals.
@ -138,7 +138,7 @@ func (m *QueryProposalsRequest) Reset() { *m = QueryProposalsRequest{} }
func (m *QueryProposalsRequest) String() string { return proto.CompactTextString(m) }
func (*QueryProposalsRequest) ProtoMessage() {}
func (*QueryProposalsRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{2}
return fileDescriptor_3efdc0c4615c3665, []int{2}
}
func (m *QueryProposalsRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -179,7 +179,7 @@ func (m *QueryProposalsResponse) Reset() { *m = QueryProposalsResponse{}
func (m *QueryProposalsResponse) String() string { return proto.CompactTextString(m) }
func (*QueryProposalsResponse) ProtoMessage() {}
func (*QueryProposalsResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{3}
return fileDescriptor_3efdc0c4615c3665, []int{3}
}
func (m *QueryProposalsResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -234,7 +234,7 @@ func (m *QueryVoteRequest) Reset() { *m = QueryVoteRequest{} }
func (m *QueryVoteRequest) String() string { return proto.CompactTextString(m) }
func (*QueryVoteRequest) ProtoMessage() {}
func (*QueryVoteRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{4}
return fileDescriptor_3efdc0c4615c3665, []int{4}
}
func (m *QueryVoteRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -273,7 +273,7 @@ func (m *QueryVoteResponse) Reset() { *m = QueryVoteResponse{} }
func (m *QueryVoteResponse) String() string { return proto.CompactTextString(m) }
func (*QueryVoteResponse) ProtoMessage() {}
func (*QueryVoteResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{5}
return fileDescriptor_3efdc0c4615c3665, []int{5}
}
func (m *QueryVoteResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -321,7 +321,7 @@ func (m *QueryVotesRequest) Reset() { *m = QueryVotesRequest{} }
func (m *QueryVotesRequest) String() string { return proto.CompactTextString(m) }
func (*QueryVotesRequest) ProtoMessage() {}
func (*QueryVotesRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{6}
return fileDescriptor_3efdc0c4615c3665, []int{6}
}
func (m *QueryVotesRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -376,7 +376,7 @@ func (m *QueryVotesResponse) Reset() { *m = QueryVotesResponse{} }
func (m *QueryVotesResponse) String() string { return proto.CompactTextString(m) }
func (*QueryVotesResponse) ProtoMessage() {}
func (*QueryVotesResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{7}
return fileDescriptor_3efdc0c4615c3665, []int{7}
}
func (m *QueryVotesResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -430,7 +430,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} }
func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) }
func (*QueryParamsRequest) ProtoMessage() {}
func (*QueryParamsRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{8}
return fileDescriptor_3efdc0c4615c3665, []int{8}
}
func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -480,7 +480,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} }
func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) }
func (*QueryParamsResponse) ProtoMessage() {}
func (*QueryParamsResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{9}
return fileDescriptor_3efdc0c4615c3665, []int{9}
}
func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -542,7 +542,7 @@ func (m *QueryDepositRequest) Reset() { *m = QueryDepositRequest{} }
func (m *QueryDepositRequest) String() string { return proto.CompactTextString(m) }
func (*QueryDepositRequest) ProtoMessage() {}
func (*QueryDepositRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{10}
return fileDescriptor_3efdc0c4615c3665, []int{10}
}
func (m *QueryDepositRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -581,7 +581,7 @@ func (m *QueryDepositResponse) Reset() { *m = QueryDepositResponse{} }
func (m *QueryDepositResponse) String() string { return proto.CompactTextString(m) }
func (*QueryDepositResponse) ProtoMessage() {}
func (*QueryDepositResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{11}
return fileDescriptor_3efdc0c4615c3665, []int{11}
}
func (m *QueryDepositResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -629,7 +629,7 @@ func (m *QueryDepositsRequest) Reset() { *m = QueryDepositsRequest{} }
func (m *QueryDepositsRequest) String() string { return proto.CompactTextString(m) }
func (*QueryDepositsRequest) ProtoMessage() {}
func (*QueryDepositsRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{12}
return fileDescriptor_3efdc0c4615c3665, []int{12}
}
func (m *QueryDepositsRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -683,7 +683,7 @@ func (m *QueryDepositsResponse) Reset() { *m = QueryDepositsResponse{} }
func (m *QueryDepositsResponse) String() string { return proto.CompactTextString(m) }
func (*QueryDepositsResponse) ProtoMessage() {}
func (*QueryDepositsResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{13}
return fileDescriptor_3efdc0c4615c3665, []int{13}
}
func (m *QueryDepositsResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -736,7 +736,7 @@ func (m *QueryTallyResultRequest) Reset() { *m = QueryTallyResultRequest
func (m *QueryTallyResultRequest) String() string { return proto.CompactTextString(m) }
func (*QueryTallyResultRequest) ProtoMessage() {}
func (*QueryTallyResultRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{14}
return fileDescriptor_3efdc0c4615c3665, []int{14}
}
func (m *QueryTallyResultRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -782,7 +782,7 @@ func (m *QueryTallyResultResponse) Reset() { *m = QueryTallyResultRespon
func (m *QueryTallyResultResponse) String() string { return proto.CompactTextString(m) }
func (*QueryTallyResultResponse) ProtoMessage() {}
func (*QueryTallyResultResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_e35c0d133e91c0a2, []int{15}
return fileDescriptor_3efdc0c4615c3665, []int{15}
}
func (m *QueryTallyResultResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -819,91 +819,91 @@ func (m *QueryTallyResultResponse) GetTally() TallyResult {
}
func init() {
proto.RegisterType((*QueryProposalRequest)(nil), "cosmos.gov.v1beta1.QueryProposalRequest")
proto.RegisterType((*QueryProposalResponse)(nil), "cosmos.gov.v1beta1.QueryProposalResponse")
proto.RegisterType((*QueryProposalsRequest)(nil), "cosmos.gov.v1beta1.QueryProposalsRequest")
proto.RegisterType((*QueryProposalsResponse)(nil), "cosmos.gov.v1beta1.QueryProposalsResponse")
proto.RegisterType((*QueryVoteRequest)(nil), "cosmos.gov.v1beta1.QueryVoteRequest")
proto.RegisterType((*QueryVoteResponse)(nil), "cosmos.gov.v1beta1.QueryVoteResponse")
proto.RegisterType((*QueryVotesRequest)(nil), "cosmos.gov.v1beta1.QueryVotesRequest")
proto.RegisterType((*QueryVotesResponse)(nil), "cosmos.gov.v1beta1.QueryVotesResponse")
proto.RegisterType((*QueryParamsRequest)(nil), "cosmos.gov.v1beta1.QueryParamsRequest")
proto.RegisterType((*QueryParamsResponse)(nil), "cosmos.gov.v1beta1.QueryParamsResponse")
proto.RegisterType((*QueryDepositRequest)(nil), "cosmos.gov.v1beta1.QueryDepositRequest")
proto.RegisterType((*QueryDepositResponse)(nil), "cosmos.gov.v1beta1.QueryDepositResponse")
proto.RegisterType((*QueryDepositsRequest)(nil), "cosmos.gov.v1beta1.QueryDepositsRequest")
proto.RegisterType((*QueryDepositsResponse)(nil), "cosmos.gov.v1beta1.QueryDepositsResponse")
proto.RegisterType((*QueryTallyResultRequest)(nil), "cosmos.gov.v1beta1.QueryTallyResultRequest")
proto.RegisterType((*QueryTallyResultResponse)(nil), "cosmos.gov.v1beta1.QueryTallyResultResponse")
proto.RegisterType((*QueryProposalRequest)(nil), "cosmos.gov.v1beta2.QueryProposalRequest")
proto.RegisterType((*QueryProposalResponse)(nil), "cosmos.gov.v1beta2.QueryProposalResponse")
proto.RegisterType((*QueryProposalsRequest)(nil), "cosmos.gov.v1beta2.QueryProposalsRequest")
proto.RegisterType((*QueryProposalsResponse)(nil), "cosmos.gov.v1beta2.QueryProposalsResponse")
proto.RegisterType((*QueryVoteRequest)(nil), "cosmos.gov.v1beta2.QueryVoteRequest")
proto.RegisterType((*QueryVoteResponse)(nil), "cosmos.gov.v1beta2.QueryVoteResponse")
proto.RegisterType((*QueryVotesRequest)(nil), "cosmos.gov.v1beta2.QueryVotesRequest")
proto.RegisterType((*QueryVotesResponse)(nil), "cosmos.gov.v1beta2.QueryVotesResponse")
proto.RegisterType((*QueryParamsRequest)(nil), "cosmos.gov.v1beta2.QueryParamsRequest")
proto.RegisterType((*QueryParamsResponse)(nil), "cosmos.gov.v1beta2.QueryParamsResponse")
proto.RegisterType((*QueryDepositRequest)(nil), "cosmos.gov.v1beta2.QueryDepositRequest")
proto.RegisterType((*QueryDepositResponse)(nil), "cosmos.gov.v1beta2.QueryDepositResponse")
proto.RegisterType((*QueryDepositsRequest)(nil), "cosmos.gov.v1beta2.QueryDepositsRequest")
proto.RegisterType((*QueryDepositsResponse)(nil), "cosmos.gov.v1beta2.QueryDepositsResponse")
proto.RegisterType((*QueryTallyResultRequest)(nil), "cosmos.gov.v1beta2.QueryTallyResultRequest")
proto.RegisterType((*QueryTallyResultResponse)(nil), "cosmos.gov.v1beta2.QueryTallyResultResponse")
}
func init() { proto.RegisterFile("cosmos/gov/v1beta1/query.proto", fileDescriptor_e35c0d133e91c0a2) }
func init() { proto.RegisterFile("cosmos/gov/v1beta2/query.proto", fileDescriptor_3efdc0c4615c3665) }
var fileDescriptor_e35c0d133e91c0a2 = []byte{
// 994 bytes of a gzipped FileDescriptorProto
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, 0x24, 0x4e, 0x6b, 0xbf, 0xb4, 0x01, 0x1e, 0x01, 0x8c, 0x29, 0x76, 0x58, 0xd1, 0xd6,
0xa4, 0xc4, 0x4b, 0x92, 0x52, 0xd4, 0x16, 0x50, 0x6b, 0xa1, 0xb6, 0xa8, 0x12, 0x2a, 0x4e, 0x05,
0x12, 0x97, 0x68, 0x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xb9, 0xb1, 0x89, 0x0f, 0xcf, 0xb9, 0xda, 0xab, 0xf9, 0xc0, 0xff, 0xa5, 0xf9, 0xe4, 0x58,
0x6b, 0xb7, 0x1f, 0xee, 0xd5, 0xc9, 0xa3, 0xbd, 0x3a, 0xf9, 0x73, 0xaf, 0x4e, 0xbe, 0xde, 0xaf,
0x17, 0x1e, 0xed, 0xd7, 0x0b, 0xbf, 0xef, 0xd7, 0x0b, 0x1f, 0x35, 0x5d, 0x4f, 0x7c, 0x3c, 0xd8,
0x34, 0x6f, 0xb3, 0x2d, 0x1d, 0x56, 0xfd, 0x59, 0xe6, 0xdd, 0x4f, 0xac, 0xbb, 0x32, 0x47, 0xd8,
0x32, 0x7c, 0xf3, 0x98, 0xfc, 0x1f, 0x68, 0xf5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xaf, 0xda,
0x91, 0x66, 0xd2, 0x0d, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -946,7 +946,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient {
func (c *queryClient) Proposal(ctx context.Context, in *QueryProposalRequest, opts ...grpc.CallOption) (*QueryProposalResponse, error) {
out := new(QueryProposalResponse)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Query/Proposal", in, out, opts...)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta2.Query/Proposal", in, out, opts...)
if err != nil {
return nil, err
}
@ -955,7 +955,7 @@ func (c *queryClient) Proposal(ctx context.Context, in *QueryProposalRequest, op
func (c *queryClient) Proposals(ctx context.Context, in *QueryProposalsRequest, opts ...grpc.CallOption) (*QueryProposalsResponse, error) {
out := new(QueryProposalsResponse)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Query/Proposals", in, out, opts...)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta2.Query/Proposals", in, out, opts...)
if err != nil {
return nil, err
}
@ -964,7 +964,7 @@ func (c *queryClient) Proposals(ctx context.Context, in *QueryProposalsRequest,
func (c *queryClient) Vote(ctx context.Context, in *QueryVoteRequest, opts ...grpc.CallOption) (*QueryVoteResponse, error) {
out := new(QueryVoteResponse)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Query/Vote", in, out, opts...)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta2.Query/Vote", in, out, opts...)
if err != nil {
return nil, err
}
@ -973,7 +973,7 @@ func (c *queryClient) Vote(ctx context.Context, in *QueryVoteRequest, opts ...gr
func (c *queryClient) Votes(ctx context.Context, in *QueryVotesRequest, opts ...grpc.CallOption) (*QueryVotesResponse, error) {
out := new(QueryVotesResponse)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Query/Votes", in, out, opts...)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta2.Query/Votes", in, out, opts...)
if err != nil {
return nil, err
}
@ -982,7 +982,7 @@ func (c *queryClient) Votes(ctx context.Context, in *QueryVotesRequest, opts ...
func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) {
out := new(QueryParamsResponse)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Query/Params", in, out, opts...)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta2.Query/Params", in, out, opts...)
if err != nil {
return nil, err
}
@ -991,7 +991,7 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts .
func (c *queryClient) Deposit(ctx context.Context, in *QueryDepositRequest, opts ...grpc.CallOption) (*QueryDepositResponse, error) {
out := new(QueryDepositResponse)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Query/Deposit", in, out, opts...)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta2.Query/Deposit", in, out, opts...)
if err != nil {
return nil, err
}
@ -1000,7 +1000,7 @@ func (c *queryClient) Deposit(ctx context.Context, in *QueryDepositRequest, opts
func (c *queryClient) Deposits(ctx context.Context, in *QueryDepositsRequest, opts ...grpc.CallOption) (*QueryDepositsResponse, error) {
out := new(QueryDepositsResponse)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Query/Deposits", in, out, opts...)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta2.Query/Deposits", in, out, opts...)
if err != nil {
return nil, err
}
@ -1009,7 +1009,7 @@ func (c *queryClient) Deposits(ctx context.Context, in *QueryDepositsRequest, op
func (c *queryClient) TallyResult(ctx context.Context, in *QueryTallyResultRequest, opts ...grpc.CallOption) (*QueryTallyResultResponse, error) {
out := new(QueryTallyResultResponse)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Query/TallyResult", in, out, opts...)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta2.Query/TallyResult", in, out, opts...)
if err != nil {
return nil, err
}
@ -1079,7 +1079,7 @@ func _Query_Proposal_Handler(srv interface{}, ctx context.Context, dec func(inte
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.gov.v1beta1.Query/Proposal",
FullMethod: "/cosmos.gov.v1beta2.Query/Proposal",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).Proposal(ctx, req.(*QueryProposalRequest))
@ -1097,7 +1097,7 @@ func _Query_Proposals_Handler(srv interface{}, ctx context.Context, dec func(int
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.gov.v1beta1.Query/Proposals",
FullMethod: "/cosmos.gov.v1beta2.Query/Proposals",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).Proposals(ctx, req.(*QueryProposalsRequest))
@ -1115,7 +1115,7 @@ func _Query_Vote_Handler(srv interface{}, ctx context.Context, dec func(interfac
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.gov.v1beta1.Query/Vote",
FullMethod: "/cosmos.gov.v1beta2.Query/Vote",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).Vote(ctx, req.(*QueryVoteRequest))
@ -1133,7 +1133,7 @@ func _Query_Votes_Handler(srv interface{}, ctx context.Context, dec func(interfa
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.gov.v1beta1.Query/Votes",
FullMethod: "/cosmos.gov.v1beta2.Query/Votes",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).Votes(ctx, req.(*QueryVotesRequest))
@ -1151,7 +1151,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.gov.v1beta1.Query/Params",
FullMethod: "/cosmos.gov.v1beta2.Query/Params",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest))
@ -1169,7 +1169,7 @@ func _Query_Deposit_Handler(srv interface{}, ctx context.Context, dec func(inter
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.gov.v1beta1.Query/Deposit",
FullMethod: "/cosmos.gov.v1beta2.Query/Deposit",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).Deposit(ctx, req.(*QueryDepositRequest))
@ -1187,7 +1187,7 @@ func _Query_Deposits_Handler(srv interface{}, ctx context.Context, dec func(inte
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.gov.v1beta1.Query/Deposits",
FullMethod: "/cosmos.gov.v1beta2.Query/Deposits",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).Deposits(ctx, req.(*QueryDepositsRequest))
@ -1205,7 +1205,7 @@ func _Query_TallyResult_Handler(srv interface{}, ctx context.Context, dec func(i
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.gov.v1beta1.Query/TallyResult",
FullMethod: "/cosmos.gov.v1beta2.Query/TallyResult",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).TallyResult(ctx, req.(*QueryTallyResultRequest))
@ -1214,7 +1214,7 @@ func _Query_TallyResult_Handler(srv interface{}, ctx context.Context, dec func(i
}
var _Query_serviceDesc = grpc.ServiceDesc{
ServiceName: "cosmos.gov.v1beta1.Query",
ServiceName: "cosmos.gov.v1beta2.Query",
HandlerType: (*QueryServer)(nil),
Methods: []grpc.MethodDesc{
{
@ -1251,7 +1251,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/gov/v1beta1/query.proto",
Metadata: "cosmos/gov/v1beta2/query.proto",
}
func (m *QueryProposalRequest) Marshal() (dAtA []byte, err error) {

View File

@ -1,5 +1,5 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: cosmos/gov/v1beta1/query.proto
// source: cosmos/gov/v1beta2/query.proto
/*
Package types is a reverse proxy.
@ -896,21 +896,21 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
}
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", "v1beta1", "proposals", "proposal_id"}, "", runtime.AssumeColonVerbOpt(false)))
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", "v1beta1", "proposals"}, "", 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", "v1beta1", "proposals", "proposal_id", "votes", "voter"}, "", 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", "v1beta1", "proposals", "proposal_id", "votes"}, "", 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", "v1beta1", "params", "params_type"}, "", 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", "v1beta1", "proposals", "proposal_id", "deposits", "depositor"}, "", 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", "v1beta1", "proposals", "proposal_id", "deposits"}, "", 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", "v1beta1", "proposals", "proposal_id", "tally"}, "", 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 (

View File

@ -1,5 +1,5 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: cosmos/gov/v1beta1/tx.proto
// source: cosmos/gov/v1beta2/tx.proto
package types
@ -35,7 +35,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary
// proposal Content.
type MsgSubmitProposal struct {
Content *types.Any `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"`
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"`
}
@ -43,7 +43,7 @@ type MsgSubmitProposal struct {
func (m *MsgSubmitProposal) Reset() { *m = MsgSubmitProposal{} }
func (*MsgSubmitProposal) ProtoMessage() {}
func (*MsgSubmitProposal) Descriptor() ([]byte, []int) {
return fileDescriptor_3c053992595e3dce, []int{0}
return fileDescriptor_4214261f6b3f9ed4, []int{0}
}
func (m *MsgSubmitProposal) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -81,7 +81,7 @@ func (m *MsgSubmitProposalResponse) Reset() { *m = MsgSubmitProposalResp
func (m *MsgSubmitProposalResponse) String() string { return proto.CompactTextString(m) }
func (*MsgSubmitProposalResponse) ProtoMessage() {}
func (*MsgSubmitProposalResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_3c053992595e3dce, []int{1}
return fileDescriptor_4214261f6b3f9ed4, []int{1}
}
func (m *MsgSubmitProposalResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -119,15 +119,15 @@ 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"`
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id" yaml:"proposal_id"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,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 (*MsgVote) Descriptor() ([]byte, []int) {
return fileDescriptor_3c053992595e3dce, []int{2}
return fileDescriptor_4214261f6b3f9ed4, []int{2}
}
func (m *MsgVote) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -164,7 +164,7 @@ func (m *MsgVoteResponse) Reset() { *m = MsgVoteResponse{} }
func (m *MsgVoteResponse) String() string { return proto.CompactTextString(m) }
func (*MsgVoteResponse) ProtoMessage() {}
func (*MsgVoteResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_3c053992595e3dce, []int{3}
return fileDescriptor_4214261f6b3f9ed4, []int{3}
}
func (m *MsgVoteResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -197,7 +197,7 @@ 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"`
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"`
}
@ -205,7 +205,7 @@ type MsgVoteWeighted struct {
func (m *MsgVoteWeighted) Reset() { *m = MsgVoteWeighted{} }
func (*MsgVoteWeighted) ProtoMessage() {}
func (*MsgVoteWeighted) Descriptor() ([]byte, []int) {
return fileDescriptor_3c053992595e3dce, []int{4}
return fileDescriptor_4214261f6b3f9ed4, []int{4}
}
func (m *MsgVoteWeighted) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -244,7 +244,7 @@ func (m *MsgVoteWeightedResponse) Reset() { *m = MsgVoteWeightedResponse
func (m *MsgVoteWeightedResponse) String() string { return proto.CompactTextString(m) }
func (*MsgVoteWeightedResponse) ProtoMessage() {}
func (*MsgVoteWeightedResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_3c053992595e3dce, []int{5}
return fileDescriptor_4214261f6b3f9ed4, []int{5}
}
func (m *MsgVoteWeightedResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -283,7 +283,7 @@ type MsgDeposit struct {
func (m *MsgDeposit) Reset() { *m = MsgDeposit{} }
func (*MsgDeposit) ProtoMessage() {}
func (*MsgDeposit) Descriptor() ([]byte, []int) {
return fileDescriptor_3c053992595e3dce, []int{6}
return fileDescriptor_4214261f6b3f9ed4, []int{6}
}
func (m *MsgDeposit) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -320,7 +320,7 @@ func (m *MsgDepositResponse) Reset() { *m = MsgDepositResponse{} }
func (m *MsgDepositResponse) String() string { return proto.CompactTextString(m) }
func (*MsgDepositResponse) ProtoMessage() {}
func (*MsgDepositResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_3c053992595e3dce, []int{7}
return fileDescriptor_4214261f6b3f9ed4, []int{7}
}
func (m *MsgDepositResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -350,61 +350,62 @@ func (m *MsgDepositResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_MsgDepositResponse proto.InternalMessageInfo
func init() {
proto.RegisterType((*MsgSubmitProposal)(nil), "cosmos.gov.v1beta1.MsgSubmitProposal")
proto.RegisterType((*MsgSubmitProposalResponse)(nil), "cosmos.gov.v1beta1.MsgSubmitProposalResponse")
proto.RegisterType((*MsgVote)(nil), "cosmos.gov.v1beta1.MsgVote")
proto.RegisterType((*MsgVoteResponse)(nil), "cosmos.gov.v1beta1.MsgVoteResponse")
proto.RegisterType((*MsgVoteWeighted)(nil), "cosmos.gov.v1beta1.MsgVoteWeighted")
proto.RegisterType((*MsgVoteWeightedResponse)(nil), "cosmos.gov.v1beta1.MsgVoteWeightedResponse")
proto.RegisterType((*MsgDeposit)(nil), "cosmos.gov.v1beta1.MsgDeposit")
proto.RegisterType((*MsgDepositResponse)(nil), "cosmos.gov.v1beta1.MsgDepositResponse")
proto.RegisterType((*MsgSubmitProposal)(nil), "cosmos.gov.v1beta2.MsgSubmitProposal")
proto.RegisterType((*MsgSubmitProposalResponse)(nil), "cosmos.gov.v1beta2.MsgSubmitProposalResponse")
proto.RegisterType((*MsgVote)(nil), "cosmos.gov.v1beta2.MsgVote")
proto.RegisterType((*MsgVoteResponse)(nil), "cosmos.gov.v1beta2.MsgVoteResponse")
proto.RegisterType((*MsgVoteWeighted)(nil), "cosmos.gov.v1beta2.MsgVoteWeighted")
proto.RegisterType((*MsgVoteWeightedResponse)(nil), "cosmos.gov.v1beta2.MsgVoteWeightedResponse")
proto.RegisterType((*MsgDeposit)(nil), "cosmos.gov.v1beta2.MsgDeposit")
proto.RegisterType((*MsgDepositResponse)(nil), "cosmos.gov.v1beta2.MsgDepositResponse")
}
func init() { proto.RegisterFile("cosmos/gov/v1beta1/tx.proto", fileDescriptor_3c053992595e3dce) }
func init() { proto.RegisterFile("cosmos/gov/v1beta2/tx.proto", fileDescriptor_4214261f6b3f9ed4) }
var fileDescriptor_3c053992595e3dce = []byte{
// 648 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xbf, 0x6f, 0xd3, 0x40,
0x14, 0xb6, 0x93, 0xd2, 0xd0, 0x17, 0xd4, 0x52, 0x2b, 0x12, 0x49, 0x8a, 0xec, 0x28, 0x88, 0x2a,
0x12, 0x8a, 0xdd, 0x06, 0xd4, 0x01, 0xa6, 0xba, 0x08, 0xc1, 0x10, 0x01, 0xae, 0x04, 0x12, 0x4b,
0x49, 0xe2, 0xeb, 0xd5, 0xa2, 0xf1, 0xb3, 0x72, 0x97, 0xa8, 0xdd, 0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xbb, 0x07, 0xa6, 0xf6, 0xf1, 0xc0, 0xd4, 0x9e, 0x8c, 0x3e, 0xe2, 0x8d,
0xf8, 0xab, 0x10, 0x1f, 0x74, 0x7b, 0x3c, 0x7e, 0x8e, 0xaf, 0xff, 0x0c, 0x00, 0x00, 0xff, 0xff,
0x8a, 0xac, 0xbf, 0x61, 0x81, 0x06, 0x00, 0x00,
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, 0x61, 0x17, 0xaa, 0xc1, 0x84, 0x1b, 0xd5, 0x10, 0x3d, 0x34, 0xea, 0x92, 0x68, 0xe2,
0x05, 0xb7, 0xdd, 0x61, 0x98, 0xd8, 0xee, 0x6c, 0x3a, 0xd3, 0x86, 0xde, 0x4c, 0xbc, 0x78, 0xf4,
0xe8, 0x91, 0xb3, 0x67, 0xff, 0x08, 0x12, 0x2f, 0xc4, 0x78, 0xf0, 0x60, 0xd0, 0xc0, 0xc5, 0x18,
0xbd, 0xf8, 0x17, 0x98, 0x9d, 0x9d, 0x5d, 0x10, 0x96, 0x82, 0x89, 0x9e, 0x60, 0xde, 0xe7, 0xf3,
0x79, 0xf3, 0x3e, 0x6f, 0xde, 0xdb, 0xc2, 0x6c, 0x8b, 0xf1, 0x0e, 0xe3, 0x0e, 0x61, 0x7d, 0xa7,
0xbf, 0xd4, 0xc4, 0xc2, 0xab, 0x39, 0x62, 0xdb, 0x0e, 0xbb, 0x4c, 0x30, 0x84, 0x62, 0xd0, 0x26,
0xac, 0x6f, 0x2b, 0xb0, 0x64, 0x2a, 0x41, 0xd3, 0xe3, 0x58, 0x29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, 0xc9, 0xe0, 0xfd, 0xf1, 0x4c, 0xa0,
0x65, 0x98, 0x50, 0x8b, 0xc1, 0xce, 0x77, 0x7a, 0x44, 0x45, 0x2d, 0x18, 0xf5, 0x3a, 0xac, 0x17,
0x08, 0x65, 0xf6, 0xaf, 0xee, 0x93, 0x4a, 0x9d, 0xd1, 0x8a, 0x02, 0xa0, 0x23, 0xbb, 0x49, 0x17,
0x6a, 0xdf, 0x73, 0x90, 0x6f, 0x70, 0x82, 0x36, 0x61, 0xea, 0xc4, 0x17, 0x63, 0x2e, 0xeb, 0x0d,
0x4e, 0xed, 0x54, 0x69, 0xe1, 0x42, 0xb4, 0x74, 0xf5, 0xee, 0xc2, 0x88, 0x5c, 0xa2, 0xd9, 0x33,
0x64, 0x11, 0x58, 0xba, 0x36, 0x04, 0x4c, 0x33, 0x3d, 0x85, 0xff, 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,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -441,7 +442,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient {
func (c *msgClient) SubmitProposal(ctx context.Context, in *MsgSubmitProposal, opts ...grpc.CallOption) (*MsgSubmitProposalResponse, error) {
out := new(MsgSubmitProposalResponse)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Msg/SubmitProposal", in, out, opts...)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta2.Msg/SubmitProposal", in, out, opts...)
if err != nil {
return nil, err
}
@ -450,7 +451,7 @@ func (c *msgClient) SubmitProposal(ctx context.Context, in *MsgSubmitProposal, o
func (c *msgClient) Vote(ctx context.Context, in *MsgVote, opts ...grpc.CallOption) (*MsgVoteResponse, error) {
out := new(MsgVoteResponse)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Msg/Vote", in, out, opts...)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta2.Msg/Vote", in, out, opts...)
if err != nil {
return nil, err
}
@ -459,7 +460,7 @@ func (c *msgClient) Vote(ctx context.Context, in *MsgVote, opts ...grpc.CallOpti
func (c *msgClient) VoteWeighted(ctx context.Context, in *MsgVoteWeighted, opts ...grpc.CallOption) (*MsgVoteWeightedResponse, error) {
out := new(MsgVoteWeightedResponse)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Msg/VoteWeighted", in, out, opts...)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta2.Msg/VoteWeighted", in, out, opts...)
if err != nil {
return nil, err
}
@ -468,7 +469,7 @@ func (c *msgClient) VoteWeighted(ctx context.Context, in *MsgVoteWeighted, opts
func (c *msgClient) Deposit(ctx context.Context, in *MsgDeposit, opts ...grpc.CallOption) (*MsgDepositResponse, error) {
out := new(MsgDepositResponse)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Msg/Deposit", in, out, opts...)
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta2.Msg/Deposit", in, out, opts...)
if err != nil {
return nil, err
}
@ -520,7 +521,7 @@ func _Msg_SubmitProposal_Handler(srv interface{}, ctx context.Context, dec func(
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.gov.v1beta1.Msg/SubmitProposal",
FullMethod: "/cosmos.gov.v1beta2.Msg/SubmitProposal",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).SubmitProposal(ctx, req.(*MsgSubmitProposal))
@ -538,7 +539,7 @@ func _Msg_Vote_Handler(srv interface{}, ctx context.Context, dec func(interface{
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.gov.v1beta1.Msg/Vote",
FullMethod: "/cosmos.gov.v1beta2.Msg/Vote",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).Vote(ctx, req.(*MsgVote))
@ -556,7 +557,7 @@ func _Msg_VoteWeighted_Handler(srv interface{}, ctx context.Context, dec func(in
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.gov.v1beta1.Msg/VoteWeighted",
FullMethod: "/cosmos.gov.v1beta2.Msg/VoteWeighted",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).VoteWeighted(ctx, req.(*MsgVoteWeighted))
@ -574,7 +575,7 @@ func _Msg_Deposit_Handler(srv interface{}, ctx context.Context, dec func(interfa
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.gov.v1beta1.Msg/Deposit",
FullMethod: "/cosmos.gov.v1beta2.Msg/Deposit",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).Deposit(ctx, req.(*MsgDeposit))
@ -583,7 +584,7 @@ func _Msg_Deposit_Handler(srv interface{}, ctx context.Context, dec func(interfa
}
var _Msg_serviceDesc = grpc.ServiceDesc{
ServiceName: "cosmos.gov.v1beta1.Msg",
ServiceName: "cosmos.gov.v1beta2.Msg",
HandlerType: (*MsgServer)(nil),
Methods: []grpc.MethodDesc{
{
@ -604,7 +605,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/gov/v1beta1/tx.proto",
Metadata: "cosmos/gov/v1beta2/tx.proto",
}
func (m *MsgSubmitProposal) Marshal() (dAtA []byte, err error) {
@ -648,17 +649,19 @@ func (m *MsgSubmitProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) {
dAtA[i] = 0x12
}
}
if m.Content != nil {
{
size, err := m.Content.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
if len(m.Messages) > 0 {
for iNdEx := len(m.Messages) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Messages[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintTx(dAtA, i, uint64(size))
}
i -= size
i = encodeVarintTx(dAtA, i, uint64(size))
i--
dAtA[i] = 0xa
}
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
@ -915,9 +918,11 @@ func (m *MsgSubmitProposal) Size() (n int) {
}
var l int
_ = l
if m.Content != nil {
l = m.Content.Size()
n += 1 + l + sovTx(uint64(l))
if len(m.Messages) > 0 {
for _, e := range m.Messages {
l = e.Size()
n += 1 + l + sovTx(uint64(l))
}
}
if len(m.InitialDeposit) > 0 {
for _, e := range m.InitialDeposit {
@ -1071,7 +1076,7 @@ func (m *MsgSubmitProposal) Unmarshal(dAtA []byte) error {
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field Messages", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
@ -1098,10 +1103,8 @@ func (m *MsgSubmitProposal) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Content == nil {
m.Content = &types.Any{}
}
if err := m.Content.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
m.Messages = append(m.Messages, &types.Any{})
if err := m.Messages[len(m.Messages)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex

View File

@ -0,0 +1,63 @@
package v1beta1
import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
// RegisterLegacyAminoCodec registers all the necessary types and interfaces for the
// governance module.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterInterface((*Content)(nil), nil)
cdc.RegisterConcrete(&MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal", nil)
cdc.RegisterConcrete(&MsgDeposit{}, "cosmos-sdk/MsgDeposit", nil)
cdc.RegisterConcrete(&MsgVote{}, "cosmos-sdk/MsgVote", nil)
cdc.RegisterConcrete(&MsgVoteWeighted{}, "cosmos-sdk/MsgVoteWeighted", nil)
cdc.RegisterConcrete(&TextProposal{}, "cosmos-sdk/TextProposal", nil)
}
func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgSubmitProposal{},
&MsgVote{},
&MsgVoteWeighted{},
&MsgDeposit{},
)
registry.RegisterInterface(
"cosmos.gov.v1beta1.Content",
(*Content)(nil),
&TextProposal{},
)
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
// RegisterProposalTypeCodec registers an external proposal content type defined
// in another module for the internal ModuleCdc. This allows the MsgSubmitProposal
// to be correctly Amino encoded and decoded.
//
// NOTE: This should only be used for applications that are still using a concrete
// Amino codec for serialization.
func RegisterProposalTypeCodec(o interface{}, name string) {
amino.RegisterConcrete(o, name, nil)
}
var (
amino = codec.NewLegacyAmino()
// ModuleCdc references the global x/gov module codec. Note, the codec should
// ONLY be used in certain instances of tests and for JSON encoding as Amino is
// still used for that purpose.
//
// The actual codec used for serialization should be provided to x/gov and
// defined at the application level.
ModuleCdc = codec.NewAminoCodec(amino)
)
func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
}

View File

@ -0,0 +1,27 @@
package v1beta1
import sdk "github.com/cosmos/cosmos-sdk/types"
// Copied over from /x/gov/types/keys.go to avoid circular imports
const (
ModuleName = "gov"
RouterKey = ModuleName
)
// Content defines an interface that a proposal must implement. It contains
// information such as the title and description along with the type and routing
// information for the appropriate handler to process the proposal. Content can
// have additional fields, which will handled by a proposal's Handler.
type Content interface {
GetTitle() string
GetDescription() string
ProposalRoute() string
ProposalType() string
ValidateBasic() error
String() string
}
// Handler defines a function that handles a proposal after it has passed the
// governance process.
type Handler func(ctx sdk.Context, content Content) error

View File

@ -0,0 +1,54 @@
package v1beta1
import (
"fmt"
"sigs.k8s.io/yaml"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// NewDeposit creates a new Deposit instance
//nolint:interfacer
func NewDeposit(proposalID uint64, depositor sdk.AccAddress, amount sdk.Coins) Deposit {
return Deposit{proposalID, depositor.String(), amount}
}
func (d Deposit) String() string {
out, _ := yaml.Marshal(d)
return string(out)
}
// Empty returns whether a deposit is empty.
func (d Deposit) Empty() bool {
return d.String() == Deposit{}.String()
}
// Deposits is a collection of Deposit objects
type Deposits []Deposit
// Equal returns true if two slices (order-dependant) of deposits are equal.
func (d Deposits) Equal(other Deposits) bool {
if len(d) != len(other) {
return false
}
for i, deposit := range d {
if deposit.String() != other[i].String() {
return false
}
}
return true
}
func (d Deposits) String() string {
if len(d) == 0 {
return "[]"
}
out := fmt.Sprintf("Deposits for Proposal %d:", d[0].ProposalId)
for _, dep := range d {
out += fmt.Sprintf("\n %s: %s", dep.Depositor, dep.Amount)
}
return out
}

View File

@ -0,0 +1,13 @@
package v1beta1
import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
var (
// Deprecated
ErrInvalidProposalContent = sdkerrors.Register(ModuleName, 5, "invalid proposal content")
// Deprecated
ErrInvalidProposalType = sdkerrors.Register(ModuleName, 6, "invalid proposal type")
ErrInvalidVote = sdkerrors.Register(ModuleName, 7, "invalid vote option")
)

View File

@ -0,0 +1,78 @@
package v1beta1
import (
"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,
}
}
// DefaultGenesisState defines the default governance genesis state
func DefaultGenesisState() *GenesisState {
return NewGenesisState(
DefaultStartingProposalID,
DefaultDepositParams(),
DefaultVotingParams(),
DefaultTallyParams(),
)
}
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{})
}
// 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())
}
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 !data.DepositParams.MinDeposit.IsValid() {
return fmt.Errorf("governance deposit amount must be a valid sdk.Coins amount, is %s",
data.DepositParams.MinDeposit.String())
}
return nil
}
var _ types.UnpackInterfacesMessage = GenesisState{}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (data GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error {
for _, p := range data.Proposals {
err := p.UnpackInterfaces(unpacker)
if err != nil {
return err
}
}
return nil
}

View File

@ -0,0 +1,667 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: cosmos/gov/v1beta1/genesis.proto
package v1beta1
import (
fmt "fmt"
_ "github.com/gogo/protobuf/gogoproto"
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 Deposits `protobuf:"bytes,2,rep,name=deposits,proto3,castrepeated=Deposits" json:"deposits"`
// votes defines all the votes present at genesis.
Votes Votes `protobuf:"bytes,3,rep,name=votes,proto3,castrepeated=Votes" json:"votes"`
// proposals defines all the proposals present at genesis.
Proposals Proposals `protobuf:"bytes,4,rep,name=proposals,proto3,castrepeated=Proposals" json:"proposals"`
// params defines all the paramaters of related to deposit.
DepositParams DepositParams `protobuf:"bytes,5,opt,name=deposit_params,json=depositParams,proto3" json:"deposit_params"`
// params defines all the paramaters of related to voting.
VotingParams VotingParams `protobuf:"bytes,6,opt,name=voting_params,json=votingParams,proto3" json:"voting_params"`
// params defines all the paramaters of related to tally.
TallyParams TallyParams `protobuf:"bytes,7,opt,name=tally_params,json=tallyParams,proto3" json:"tally_params"`
}
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_43cd825e0fa7a627, []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() Deposits {
if m != nil {
return m.Deposits
}
return nil
}
func (m *GenesisState) GetVotes() Votes {
if m != nil {
return m.Votes
}
return nil
}
func (m *GenesisState) GetProposals() Proposals {
if m != nil {
return m.Proposals
}
return nil
}
func (m *GenesisState) GetDepositParams() DepositParams {
if m != nil {
return m.DepositParams
}
return DepositParams{}
}
func (m *GenesisState) GetVotingParams() VotingParams {
if m != nil {
return m.VotingParams
}
return VotingParams{}
}
func (m *GenesisState) GetTallyParams() TallyParams {
if m != nil {
return m.TallyParams
}
return TallyParams{}
}
func init() {
proto.RegisterType((*GenesisState)(nil), "cosmos.gov.v1beta1.GenesisState")
}
func init() { proto.RegisterFile("cosmos/gov/v1beta1/genesis.proto", fileDescriptor_43cd825e0fa7a627) }
var fileDescriptor_43cd825e0fa7a627 = []byte{
// 391 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xc1, 0x6e, 0xda, 0x40,
0x14, 0x45, 0xed, 0x62, 0x28, 0x0c, 0x50, 0xb5, 0x23, 0x16, 0x16, 0x45, 0xc6, 0xed, 0x8a, 0x4d,
0x6d, 0xa0, 0xeb, 0x6e, 0xac, 0x4a, 0x2d, 0xad, 0x5a, 0x21, 0xb7, 0xca, 0x22, 0x1b, 0x64, 0xf0,
0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, 0xe4, 0x91, 0x51, 0xd7, 0x04, 0xa2, 0x57,
0x86, 0xc8, 0xc3, 0x3b, 0x1f, 0x32, 0x4c, 0x23, 0x57, 0xd0, 0x7d, 0x24, 0xd0, 0xbf, 0xe4, 0x5d,
0x96, 0x6c, 0x16, 0x79, 0xb1, 0xb7, 0x42, 0xbd, 0x6a, 0xaa, 0x83, 0xe6, 0xf8, 0xd3, 0x2b, 0xcf,
0x9b, 0x0a, 0xa3, 0xa3, 0xa5, 0x60, 0xb7, 0xed, 0x17, 0x45, 0xfa, 0x9b, 0xb4, 0x13, 0x90, 0x8b,
0x95, 0xb8, 0x9a, 0xc0, 0x99, 0x2f, 0xbc, 0x32, 0xdd, 0x72, 0x91, 0xd6, 0x4a, 0x0a, 0x1a, 0xfd,
0x49, 0x5a, 0xdc, 0x5b, 0x2e, 0x37, 0x39, 0xeb, 0xad, 0x60, 0xf5, 0xcb, 0x58, 0xff, 0x53, 0xdf,
0x13, 0x54, 0x93, 0x17, 0xa4, 0x5f, 0xdb, 0xbd, 0xa1, 0xee, 0xf6, 0x86, 0x7a, 0xb7, 0x37, 0xd4,
0xcb, 0x83, 0xa1, 0xec, 0x0e, 0x86, 0x72, 0x7d, 0x30, 0x94, 0xe3, 0x61, 0x10, 0xf2, 0x93, 0xb3,
0xb9, 0xb5, 0x80, 0x95, 0x9d, 0xb5, 0x48, 0x7e, 0xbe, 0xa0, 0x7f, 0x6a, 0x9f, 0x8b, 0x4a, 0xf1,
0x4d, 0xc4, 0x30, 0x2f, 0xd6, 0xbc, 0x26, 0x5a, 0xf5, 0xf5, 0x3e, 0x00, 0x00, 0xff, 0xff, 0x9c,
0xc0, 0x6c, 0xbd, 0xc1, 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
{
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
{
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
{
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))
}
}
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))
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 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 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 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

282
x/gov/types/v1beta1/msgs.go Normal file
View File

@ -0,0 +1,282 @@
package v1beta1
import (
"fmt"
"sigs.k8s.io/yaml"
"github.com/gogo/protobuf/proto"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
// Governance message types and routes
const (
TypeMsgDeposit = "deposit"
TypeMsgVote = "vote"
TypeMsgVoteWeighted = "weighted_vote"
TypeMsgSubmitProposal = "submit_proposal"
)
var (
_, _, _, _ sdk.Msg = &MsgSubmitProposal{}, &MsgDeposit{}, &MsgVote{}, &MsgVoteWeighted{}
_ types.UnpackInterfacesMessage = &MsgSubmitProposal{}
)
// NewMsgSubmitProposal creates a new MsgSubmitProposal.
//nolint:interfacer
func NewMsgSubmitProposal(content Content, initialDeposit sdk.Coins, proposer sdk.AccAddress) (*MsgSubmitProposal, error) {
m := &MsgSubmitProposal{
InitialDeposit: initialDeposit,
Proposer: proposer.String(),
}
err := m.SetContent(content)
if err != nil {
return nil, err
}
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) GetContent() Content {
content, ok := m.Content.GetCachedValue().(Content)
if !ok {
return nil
}
return content
}
func (m *MsgSubmitProposal) SetInitialDeposit(coins sdk.Coins) {
m.InitialDeposit = coins
}
func (m *MsgSubmitProposal) SetProposer(address fmt.Stringer) {
m.Proposer = address.String()
}
func (m *MsgSubmitProposal) SetContent(content Content) error {
msg, ok := content.(proto.Message)
if !ok {
return fmt.Errorf("can't proto marshal %T", msg)
}
any, err := types.NewAnyWithValue(msg)
if err != nil {
return err
}
m.Content = any
return nil
}
// Route implements Msg
func (m MsgSubmitProposal) Route() string { return RouterKey }
// Type implements Msg
func (m MsgSubmitProposal) Type() string { return TypeMsgSubmitProposal }
// ValidateBasic implements Msg
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())
}
if m.InitialDeposit.IsAnyNegative() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.InitialDeposit.String())
}
content := m.GetContent()
if content == nil {
return sdkerrors.Wrap(ErrInvalidProposalContent, "missing content")
}
if !IsValidProposalType(content.ProposalType()) {
return sdkerrors.Wrap(ErrInvalidProposalType, content.ProposalType())
}
if err := content.ValidateBasic(); err != nil {
return err
}
return nil
}
// GetSignBytes implements Msg
func (m MsgSubmitProposal) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(&m)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
func (m MsgSubmitProposal) GetSigners() []sdk.AccAddress {
proposer, _ := sdk.AccAddressFromBech32(m.Proposer)
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 {
var content Content
return unpacker.UnpackAny(m.Content, &content)
}
// NewMsgDeposit creates a new MsgDeposit instance
//nolint:interfacer
func NewMsgDeposit(depositor sdk.AccAddress, proposalID uint64, amount sdk.Coins) *MsgDeposit {
return &MsgDeposit{proposalID, depositor.String(), amount}
}
// Route implements Msg
func (msg MsgDeposit) Route() string { return RouterKey }
// Type implements Msg
func (msg MsgDeposit) Type() string { return TypeMsgDeposit }
// ValidateBasic implements Msg
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())
}
if msg.Amount.IsAnyNegative() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.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)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
func (msg MsgDeposit) GetSigners() []sdk.AccAddress {
depositor, _ := sdk.AccAddressFromBech32(msg.Depositor)
return []sdk.AccAddress{depositor}
}
// NewMsgVote creates a message to cast a vote on an active proposal
//nolint:interfacer
func NewMsgVote(voter sdk.AccAddress, proposalID uint64, option VoteOption) *MsgVote {
return &MsgVote{proposalID, voter.String(), option}
}
// Route implements Msg
func (msg MsgVote) Route() string { return RouterKey }
// Type implements Msg
func (msg MsgVote) Type() string { return TypeMsgVote }
// ValidateBasic implements Msg
func (msg MsgVote) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Voter); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid voter address: %s", err)
}
if !ValidVoteOption(msg.Option) {
return sdkerrors.Wrap(ErrInvalidVote, msg.Option.String())
}
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)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
func (msg MsgVote) GetSigners() []sdk.AccAddress {
voter, _ := sdk.AccAddressFromBech32(msg.Voter)
return []sdk.AccAddress{voter}
}
// NewMsgVoteWeighted creates a message to cast a vote on an active proposal
//nolint:interfacer
func NewMsgVoteWeighted(voter sdk.AccAddress, proposalID uint64, options WeightedVoteOptions) *MsgVoteWeighted {
return &MsgVoteWeighted{proposalID, voter.String(), options}
}
// Route implements Msg
func (msg MsgVoteWeighted) Route() string { return RouterKey }
// Type implements Msg
func (msg MsgVoteWeighted) Type() string { return TypeMsgVoteWeighted }
// ValidateBasic implements Msg
func (msg MsgVoteWeighted) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Voter); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid voter address: %s", err)
}
if len(msg.Options) == 0 {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, WeightedVoteOptions(msg.Options).String())
}
totalWeight := sdk.NewDec(0)
usedOptions := make(map[VoteOption]bool)
for _, option := range msg.Options {
if !ValidWeightedVoteOption(option) {
return sdkerrors.Wrap(ErrInvalidVote, option.String())
}
totalWeight = totalWeight.Add(option.Weight)
if usedOptions[option.Option] {
return sdkerrors.Wrap(ErrInvalidVote, "Duplicated vote option")
}
usedOptions[option.Option] = true
}
if totalWeight.GT(sdk.NewDec(1)) {
return sdkerrors.Wrap(ErrInvalidVote, "Total weight overflow 1.00")
}
if totalWeight.LT(sdk.NewDec(1)) {
return sdkerrors.Wrap(ErrInvalidVote, "Total weight lower than 1.00")
}
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)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
func (msg MsgVoteWeighted) GetSigners() []sdk.AccAddress {
voter, _ := sdk.AccAddressFromBech32(msg.Voter)
return []sdk.AccAddress{voter}
}

View File

@ -0,0 +1,176 @@
package v1beta1
import (
"strings"
"testing"
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
)
var (
coinsPos = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000))
coinsZero = sdk.NewCoins()
coinsMulti = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000), sdk.NewInt64Coin("foo", 10000))
addrs = []sdk.AccAddress{
sdk.AccAddress("test1"),
sdk.AccAddress("test2"),
}
)
func init() {
coinsMulti.Sort()
}
// test ValidateBasic for MsgCreateValidator
func TestMsgSubmitProposal(t *testing.T) {
tests := []struct {
title, description string
proposalType string
proposerAddr sdk.AccAddress
initialDeposit sdk.Coins
expectPass bool
}{
{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsPos, true},
{"", "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsPos, false},
{"Test Proposal", "", ProposalTypeText, addrs[0], coinsPos, false},
{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeText, sdk.AccAddress{}, coinsPos, false},
{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsZero, true},
{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsMulti, true},
{strings.Repeat("#", MaxTitleLength*2), "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsMulti, false},
{"Test Proposal", strings.Repeat("#", MaxDescriptionLength*2), ProposalTypeText, addrs[0], coinsMulti, false},
}
for i, tc := range tests {
msg, err := NewMsgSubmitProposal(
ContentFromProposalType(tc.title, tc.description, tc.proposalType),
tc.initialDeposit,
tc.proposerAddr,
)
require.NoError(t, err)
if tc.expectPass {
require.NoError(t, msg.ValidateBasic(), "test: %v", i)
} else {
require.Error(t, msg.ValidateBasic(), "test: %v", i)
}
}
}
func TestMsgDepositGetSignBytes(t *testing.T) {
addr := sdk.AccAddress("addr1")
msg := NewMsgDeposit(addr, 0, coinsPos)
res := msg.GetSignBytes()
expected := `{"type":"cosmos-sdk/MsgDeposit","value":{"amount":[{"amount":"1000","denom":"stake"}],"depositor":"cosmos1v9jxgu33kfsgr5","proposal_id":"0"}}`
require.Equal(t, expected, string(res))
}
// test ValidateBasic for MsgDeposit
func TestMsgDeposit(t *testing.T) {
tests := []struct {
proposalID uint64
depositorAddr sdk.AccAddress
depositAmount sdk.Coins
expectPass bool
}{
{0, addrs[0], coinsPos, true},
{1, sdk.AccAddress{}, coinsPos, false},
{1, addrs[0], coinsZero, true},
{1, addrs[0], coinsMulti, true},
}
for i, tc := range tests {
msg := NewMsgDeposit(tc.depositorAddr, tc.proposalID, tc.depositAmount)
if tc.expectPass {
require.NoError(t, msg.ValidateBasic(), "test: %v", i)
} else {
require.Error(t, msg.ValidateBasic(), "test: %v", i)
}
}
}
// test ValidateBasic for MsgVote
func TestMsgVote(t *testing.T) {
tests := []struct {
proposalID uint64
voterAddr sdk.AccAddress
option VoteOption
expectPass bool
}{
{0, addrs[0], OptionYes, true},
{0, sdk.AccAddress{}, OptionYes, false},
{0, addrs[0], OptionNo, true},
{0, addrs[0], OptionNoWithVeto, true},
{0, addrs[0], OptionAbstain, true},
{0, addrs[0], VoteOption(0x13), false},
}
for i, tc := range tests {
msg := NewMsgVote(tc.voterAddr, tc.proposalID, tc.option)
if tc.expectPass {
require.Nil(t, msg.ValidateBasic(), "test: %v", i)
} else {
require.NotNil(t, msg.ValidateBasic(), "test: %v", i)
}
}
}
// test ValidateBasic for MsgVoteWeighted
func TestMsgVoteWeighted(t *testing.T) {
tests := []struct {
proposalID uint64
voterAddr sdk.AccAddress
options WeightedVoteOptions
expectPass bool
}{
{0, addrs[0], NewNonSplitVoteOption(OptionYes), true},
{0, sdk.AccAddress{}, NewNonSplitVoteOption(OptionYes), false},
{0, addrs[0], NewNonSplitVoteOption(OptionNo), true},
{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)},
}, false},
{0, addrs[0], WeightedVoteOptions{ // duplicate option
WeightedVoteOption{Option: OptionYes, Weight: sdk.NewDecWithPrec(5, 1)},
WeightedVoteOption{Option: OptionYes, Weight: sdk.NewDecWithPrec(5, 1)},
}, false},
{0, addrs[0], WeightedVoteOptions{ // zero weight
WeightedVoteOption{Option: OptionYes, Weight: sdk.NewDec(0)},
}, false},
{0, addrs[0], WeightedVoteOptions{ // negative weight
WeightedVoteOption{Option: OptionYes, Weight: 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)},
}, false},
}
for i, tc := range tests {
msg := NewMsgVoteWeighted(tc.voterAddr, tc.proposalID, tc.options)
if tc.expectPass {
require.Nil(t, msg.ValidateBasic(), "test: %v", i)
} else {
require.NotNil(t, msg.ValidateBasic(), "test: %v", i)
}
}
}
// this tests that Amino JSON MsgSubmitProposal.GetSignBytes() still works with Content as Any using the ModuleCdc
func TestMsgSubmitProposal_GetSignBytes(t *testing.T) {
msg, err := NewMsgSubmitProposal(NewTextProposal("test", "abcd"), sdk.NewCoins(), sdk.AccAddress{})
require.NoError(t, err)
var bz []byte
require.NotPanics(t, func() {
bz = msg.GetSignBytes()
})
require.Equal(t,
`{"type":"cosmos-sdk/MsgSubmitProposal","value":{"content":{"type":"cosmos-sdk/TextProposal","value":{"description":"abcd","title":"test"}},"initial_deposit":[]}}`,
string(bz))
}

View File

@ -0,0 +1,198 @@
package v1beta1
import (
"fmt"
"time"
"sigs.k8s.io/yaml"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
// Default period for deposits & voting
const (
DefaultPeriod time.Duration = time.Hour * 24 * 2 // 2 days
)
// Default governance params
var (
DefaultMinDepositTokens = sdk.NewInt(10000000)
DefaultQuorum = sdk.NewDecWithPrec(334, 3)
DefaultThreshold = sdk.NewDecWithPrec(5, 1)
DefaultVetoThreshold = sdk.NewDecWithPrec(334, 3)
)
// Parameter store key
var (
ParamStoreKeyDepositParams = []byte("depositparams")
ParamStoreKeyVotingParams = []byte("votingparams")
ParamStoreKeyTallyParams = []byte("tallyparams")
)
// ParamKeyTable - Key declaration for parameters
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable(
paramtypes.NewParamSetPair(ParamStoreKeyDepositParams, DepositParams{}, validateDepositParams),
paramtypes.NewParamSetPair(ParamStoreKeyVotingParams, VotingParams{}, validateVotingParams),
paramtypes.NewParamSetPair(ParamStoreKeyTallyParams, TallyParams{}, validateTallyParams),
)
}
// NewDepositParams creates a new DepositParams object
func NewDepositParams(minDeposit sdk.Coins, maxDepositPeriod time.Duration) DepositParams {
return DepositParams{
MinDeposit: minDeposit,
MaxDepositPeriod: maxDepositPeriod,
}
}
// DefaultDepositParams default parameters for deposits
func DefaultDepositParams() DepositParams {
return NewDepositParams(
sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, DefaultMinDepositTokens)),
DefaultPeriod,
)
}
// 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
}
func validateDepositParams(i interface{}) error {
v, ok := i.(DepositParams)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if !v.MinDeposit.IsValid() {
return fmt.Errorf("invalid minimum deposit: %s", v.MinDeposit)
}
if v.MaxDepositPeriod <= 0 {
return fmt.Errorf("maximum deposit period must be positive: %d", v.MaxDepositPeriod)
}
return nil
}
// NewTallyParams creates a new TallyParams object
func NewTallyParams(quorum, threshold, vetoThreshold sdk.Dec) TallyParams {
return TallyParams{
Quorum: quorum,
Threshold: threshold,
VetoThreshold: vetoThreshold,
}
}
// DefaultTallyParams default parameters for tallying
func DefaultTallyParams() TallyParams {
return NewTallyParams(DefaultQuorum, DefaultThreshold, DefaultVetoThreshold)
}
// 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)
}
func validateTallyParams(i interface{}) error {
v, ok := i.(TallyParams)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if v.Quorum.IsNegative() {
return fmt.Errorf("quorom cannot be negative: %s", v.Quorum)
}
if v.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)
}
if v.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)
}
if v.VetoThreshold.GT(sdk.OneDec()) {
return fmt.Errorf("veto threshold too large: %s", v)
}
return nil
}
// NewVotingParams creates a new VotingParams object
func NewVotingParams(votingPeriod time.Duration) VotingParams {
return VotingParams{
VotingPeriod: votingPeriod,
}
}
// DefaultVotingParams default parameters for voting
func DefaultVotingParams() VotingParams {
return NewVotingParams(DefaultPeriod)
}
// Equal checks equality of TallyParams
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 {
return fmt.Errorf("voting period must be positive: %s", v.VotingPeriod)
}
return nil
}
// Params returns all of the governance params
type Params struct {
VotingParams VotingParams `json:"voting_params" yaml:"voting_params"`
TallyParams TallyParams `json:"tally_params" yaml:"tally_params"`
DepositParams DepositParams `json:"deposit_params" yaml:"deposit_params"`
}
func (gp Params) String() string {
return gp.VotingParams.String() + "\n" +
gp.TallyParams.String() + "\n" + gp.DepositParams.String()
}
// NewParams creates a new gov Params instance
func NewParams(vp VotingParams, tp TallyParams, dp DepositParams) Params {
return Params{
VotingParams: vp,
DepositParams: dp,
TallyParams: tp,
}
}
// DefaultParams default governance params
func DefaultParams() Params {
return NewParams(DefaultVotingParams(), DefaultTallyParams(), DefaultDepositParams())
}

View File

@ -0,0 +1,280 @@
package v1beta1
import (
"fmt"
"strings"
"time"
"github.com/gogo/protobuf/proto"
"sigs.k8s.io/yaml"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
// DefaultStartingProposalID is 1
const DefaultStartingProposalID uint64 = 1
func NewProposal(content Content, id uint64, submitTime, depositEndTime time.Time) (Proposal, error) {
msg, ok := content.(proto.Message)
if !ok {
return Proposal{}, fmt.Errorf("%T does not implement proto.Message", content)
}
any, err := types.NewAnyWithValue(msg)
if err != nil {
return Proposal{}, err
}
p := Proposal{
Content: any,
ProposalId: id,
Status: StatusDepositPeriod,
FinalTallyResult: EmptyTallyResult(),
TotalDeposit: sdk.NewCoins(),
SubmitTime: submitTime,
DepositEndTime: depositEndTime,
}
return p, nil
}
// String implements stringer interface
func (p Proposal) String() string {
out, _ := yaml.Marshal(p)
return string(out)
}
// GetContent returns the proposal Content
func (p Proposal) GetContent() Content {
content, ok := p.Content.GetCachedValue().(Content)
if !ok {
return nil
}
return content
}
func (p Proposal) ProposalType() string {
content := p.GetContent()
if content == nil {
return ""
}
return content.ProposalType()
}
func (p Proposal) ProposalRoute() string {
content := p.GetContent()
if content == nil {
return ""
}
return content.ProposalRoute()
}
func (p Proposal) GetTitle() string {
content := p.GetContent()
if content == nil {
return ""
}
return content.GetTitle()
}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (p Proposal) UnpackInterfaces(unpacker types.AnyUnpacker) error {
var content Content
return unpacker.UnpackAny(p.Content, &content)
}
// Proposals is an array of proposal
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"
for _, prop := range p {
out += fmt.Sprintf("%d - (%s) [%s] %s\n",
prop.ProposalId, prop.Status,
prop.ProposalType(), prop.GetTitle())
}
return strings.TrimSpace(out)
}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (p Proposals) UnpackInterfaces(unpacker types.AnyUnpacker) error {
for _, x := range p {
err := x.UnpackInterfaces(unpacker)
if err != nil {
return err
}
}
return nil
}
// ProposalStatusFromString turns a string into a ProposalStatus
func ProposalStatusFromString(str string) (ProposalStatus, error) {
num, ok := ProposalStatus_value[str]
if !ok {
return StatusNil, fmt.Errorf("'%s' is not a valid proposal status", str)
}
return ProposalStatus(num), nil
}
// Marshal needed for protobuf compatibility
func (status ProposalStatus) Marshal() ([]byte, error) {
return []byte{byte(status)}, nil
}
// Unmarshal needed for protobuf compatibility
func (status *ProposalStatus) Unmarshal(data []byte) error {
*status = ProposalStatus(data[0])
return nil
}
// Format implements the fmt.Formatter interface.
// nolint: errcheck
func (status ProposalStatus) Format(s fmt.State, verb rune) {
switch verb {
case 's':
s.Write([]byte(status.String()))
default:
// TODO: Do this conversion more directly
s.Write([]byte(fmt.Sprintf("%v", byte(status))))
}
}
// Proposal types
const (
ProposalTypeText string = "Text"
// Constants pertaining to a Content object
MaxDescriptionLength int = 10000
MaxTitleLength int = 140
)
// Implements Content Interface
var _ Content = &TextProposal{}
// NewTextProposal creates a text proposal Content
func NewTextProposal(title, description string) Content {
return &TextProposal{title, description}
}
// GetTitle returns the proposal title
func (tp *TextProposal) GetTitle() string { return tp.Title }
// GetDescription returns the proposal description
func (tp *TextProposal) GetDescription() string { return tp.Description }
// ProposalRoute returns the proposal router key
func (tp *TextProposal) ProposalRoute() string { return RouterKey }
// ProposalType is "Text"
func (tp *TextProposal) ProposalType() string { return ProposalTypeText }
// ValidateBasic validates the content's title and description of the proposal
func (tp *TextProposal) ValidateBasic() error { return ValidateAbstract(tp) }
// String implements Stringer interface
func (tp TextProposal) String() string {
out, _ := yaml.Marshal(tp)
return string(out)
}
func ValidProposalStatus(status ProposalStatus) bool {
if status == StatusDepositPeriod ||
status == StatusVotingPeriod ||
status == StatusPassed ||
status == StatusRejected ||
status == StatusFailed {
return true
}
return false
}
// ValidateAbstract validates a proposal's abstract contents returning an error
// if invalid.
func ValidateAbstract(c Content) error {
title := c.GetTitle()
if len(strings.TrimSpace(title)) == 0 {
return sdkerrors.Wrap(ErrInvalidProposalContent, "proposal title cannot be blank")
}
if len(title) > MaxTitleLength {
return sdkerrors.Wrapf(ErrInvalidProposalContent, "proposal title is longer than max length of %d", MaxTitleLength)
}
description := c.GetDescription()
if len(description) == 0 {
return sdkerrors.Wrap(ErrInvalidProposalContent, "proposal description cannot be blank")
}
if len(description) > MaxDescriptionLength {
return sdkerrors.Wrapf(ErrInvalidProposalContent, "proposal description is longer than max length of %d", MaxDescriptionLength)
}
return nil
}
var validProposalTypes = map[string]struct{}{
ProposalTypeText: {},
}
// RegisterProposalType registers a proposal type. It will panic if the type is
// already registered.
func RegisterProposalType(ty string) {
if _, ok := validProposalTypes[ty]; ok {
panic(fmt.Sprintf("already registered proposal type: %s", ty))
}
validProposalTypes[ty] = struct{}{}
}
// ContentFromProposalType returns a Content object based on the proposal type.
func ContentFromProposalType(title, desc, ty string) Content {
switch ty {
case ProposalTypeText:
return NewTextProposal(title, desc)
default:
return nil
}
}
// IsValidProposalType returns a boolean determining if the proposal type is
// valid.
//
// NOTE: Modules with their own proposal types must register them.
func IsValidProposalType(ty string) bool {
_, ok := validProposalTypes[ty]
return ok
}
// ProposalHandler implements the Handler interface for governance module-based
// proposals (ie. TextProposal ). Since these are
// merely signaling mechanisms at the moment and do not affect state, it
// performs a no-op.
func ProposalHandler(_ sdk.Context, c Content) error {
switch c.ProposalType() {
case ProposalTypeText:
// both proposal types do not change state so this performs a no-op
return nil
default:
return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized gov proposal type: %s", c.ProposalType())
}
}

View File

@ -0,0 +1,24 @@
package v1beta1
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
)
func TestProposalStatus_Format(t *testing.T) {
statusDepositPeriod, _ := ProposalStatusFromString("PROPOSAL_STATUS_DEPOSIT_PERIOD")
tests := []struct {
pt ProposalStatus
sprintFArgs string
expectedStringOutput string
}{
{statusDepositPeriod, "%s", "PROPOSAL_STATUS_DEPOSIT_PERIOD"},
{statusDepositPeriod, "%v", "1"},
}
for _, tt := range tests {
got := fmt.Sprintf(tt.sprintFArgs, tt.pt)
require.Equal(t, tt.expectedStringOutput, got)
}
}

View File

@ -0,0 +1,102 @@
package v1beta1
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// DONTCOVER
// query endpoints supported by the governance Querier
const (
QueryParams = "params"
QueryProposals = "proposals"
QueryProposal = "proposal"
QueryDeposits = "deposits"
QueryDeposit = "deposit"
QueryVotes = "votes"
QueryVote = "vote"
QueryTally = "tally"
ParamDeposit = "deposit"
ParamVoting = "voting"
ParamTallying = "tallying"
)
// QueryProposalParams Params for queries:
// - 'custom/gov/proposal'
// - 'custom/gov/deposits'
// - 'custom/gov/tally'
type QueryProposalParams struct {
ProposalID uint64
}
// NewQueryProposalParams creates a new instance of QueryProposalParams
func NewQueryProposalParams(proposalID uint64) QueryProposalParams {
return QueryProposalParams{
ProposalID: proposalID,
}
}
// QueryProposalVotesParams used for queries to 'custom/gov/votes'.
type QueryProposalVotesParams struct {
ProposalID uint64
Page int
Limit int
}
// NewQueryProposalVotesParams creates new instance of the QueryProposalVotesParams.
func NewQueryProposalVotesParams(proposalID uint64, page, limit int) QueryProposalVotesParams {
return QueryProposalVotesParams{
ProposalID: proposalID,
Page: page,
Limit: limit,
}
}
// QueryDepositParams params for query 'custom/gov/deposit'
type QueryDepositParams struct {
ProposalID uint64
Depositor sdk.AccAddress
}
// NewQueryDepositParams creates a new instance of QueryDepositParams
func NewQueryDepositParams(proposalID uint64, depositor sdk.AccAddress) QueryDepositParams {
return QueryDepositParams{
ProposalID: proposalID,
Depositor: depositor,
}
}
// QueryVoteParams Params for query 'custom/gov/vote'
type QueryVoteParams struct {
ProposalID uint64
Voter sdk.AccAddress
}
// NewQueryVoteParams creates a new instance of QueryVoteParams
func NewQueryVoteParams(proposalID uint64, voter sdk.AccAddress) QueryVoteParams {
return QueryVoteParams{
ProposalID: proposalID,
Voter: voter,
}
}
// QueryProposalsParams Params for query 'custom/gov/proposals'
type QueryProposalsParams struct {
Page int
Limit int
Voter sdk.AccAddress
Depositor sdk.AccAddress
ProposalStatus ProposalStatus
}
// NewQueryProposalsParams creates a new instance of QueryProposalsParams
func NewQueryProposalsParams(page, limit int, status ProposalStatus, voter, depositor sdk.AccAddress) QueryProposalsParams {
return QueryProposalsParams{
Page: page,
Limit: limit,
Voter: voter,
Depositor: depositor,
ProposalStatus: status,
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,932 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: cosmos/gov/v1beta1/query.proto
/*
Package v1beta1 is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package v1beta1
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", "v1beta1", "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", "v1beta1", "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", "v1beta1", "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", "v1beta1", "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", "v1beta1", "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", "v1beta1", "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", "v1beta1", "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", "v1beta1", "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
)

View File

@ -1,4 +1,4 @@
package types
package v1beta1
import (
"fmt"

View File

@ -0,0 +1,68 @@
package v1beta1
import (
"sigs.k8s.io/yaml"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// ValidatorGovInfo used for tallying
type ValidatorGovInfo struct {
Address sdk.ValAddress // address of the validator operator
BondedTokens sdk.Int // Power of a Validator
DelegatorShares sdk.Dec // Total outstanding delegator shares
DelegatorDeductions sdk.Dec // Delegator deductions from validator's delegators voting independently
Vote WeightedVoteOptions // Vote of the validator
}
// NewValidatorGovInfo creates a ValidatorGovInfo instance
func NewValidatorGovInfo(address sdk.ValAddress, bondedTokens sdk.Int, delegatorShares,
delegatorDeductions sdk.Dec, options WeightedVoteOptions) ValidatorGovInfo {
return ValidatorGovInfo{
Address: address,
BondedTokens: bondedTokens,
DelegatorShares: delegatorShares,
DelegatorDeductions: delegatorDeductions,
Vote: options,
}
}
// 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,
}
}
// NewTallyResultFromMap creates a new TallyResult instance from a Option -> Dec map
func NewTallyResultFromMap(results map[VoteOption]sdk.Dec) TallyResult {
return NewTallyResult(
results[OptionYes].TruncateInt(),
results[OptionAbstain].TruncateInt(),
results[OptionNo].TruncateInt(),
results[OptionNoWithVeto].TruncateInt(),
)
}
// EmptyTallyResult returns an empty TallyResult.
func EmptyTallyResult() TallyResult {
return NewTallyResult(sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt())
}
// Equals returns if two proposals 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)
}

1887
x/gov/types/v1beta1/tx.pb.go Normal file

File diff suppressed because it is too large Load Diff

149
x/gov/types/v1beta1/vote.go Normal file
View File

@ -0,0 +1,149 @@
package v1beta1
import (
"fmt"
"strings"
"sigs.k8s.io/yaml"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// 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 the string representation of the 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()
}
// Votes is an array of vote
type Votes []Vote
// Equal returns true if two slices (order-dependant) of votes are equal.
func (v Votes) Equal(other Votes) bool {
if len(v) != len(other) {
return false
}
for i, vote := range v {
if vote.String() != other[i].String() {
return false
}
}
return true
}
func (v Votes) String() string {
if len(v) == 0 {
return "[]"
}
out := fmt.Sprintf("Votes for Proposal %d:", v[0].ProposalId)
for _, vot := range v {
out += fmt.Sprintf("\n %s: %s", vot.Voter, vot.Options)
}
return out
}
// NewNonSplitVoteOption creates a single option vote with weight 1
func NewNonSplitVoteOption(option VoteOption) WeightedVoteOptions {
return WeightedVoteOptions{{option, sdk.NewDec(1)}}
}
func (v WeightedVoteOption) String() string {
out, _ := yaml.Marshal(v)
return string(out)
}
// WeightedVoteOptions describes array of WeightedVoteOptions
type WeightedVoteOptions []WeightedVoteOption
func (v WeightedVoteOptions) String() (out string) {
for _, opt := range v {
out += opt.String() + "\n"
}
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) {
option, ok := VoteOption_value[str]
if !ok {
return OptionEmpty, fmt.Errorf("'%s' is not a valid vote option, available options: yes/no/no_with_veto/abstain", str)
}
return VoteOption(option), nil
}
// WeightedVoteOptionsFromString returns weighted vote options from string. It returns an error
// if the string is invalid.
func WeightedVoteOptionsFromString(str string) (WeightedVoteOptions, error) {
options := WeightedVoteOptions{}
for _, option := range strings.Split(str, ",") {
fields := strings.Split(option, "=")
option, err := VoteOptionFromString(fields[0])
if err != nil {
return options, err
}
if len(fields) < 2 {
return options, fmt.Errorf("weight field does not exist for %s option", fields[0])
}
weight, err := sdk.NewDecFromStr(fields[1])
if err != nil {
return options, err
}
options = append(options, WeightedVoteOption{option, weight})
}
return options, nil
}
// ValidVoteOption returns true if the vote option is valid and false otherwise.
func ValidVoteOption(option VoteOption) bool {
if option == OptionYes ||
option == OptionAbstain ||
option == OptionNo ||
option == OptionNoWithVeto {
return true
}
return false
}
// Marshal needed for protobuf compatibility.
func (vo VoteOption) Marshal() ([]byte, error) {
return []byte{byte(vo)}, nil
}
// Unmarshal needed for protobuf compatibility.
func (vo *VoteOption) Unmarshal(data []byte) error {
*vo = VoteOption(data[0])
return nil
}
// Format implements the fmt.Formatter interface.
func (vo VoteOption) Format(s fmt.State, verb rune) {
switch verb {
case 's':
s.Write([]byte(vo.String()))
default:
s.Write([]byte(fmt.Sprintf("%v", byte(vo))))
}
}

View File

@ -16,11 +16,17 @@ func NewVote(proposalID uint64, voter sdk.AccAddress, options WeightedVoteOption
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()
}
// Votes is a collection of Vote objects
type Votes []Vote
@ -50,11 +56,6 @@ func (v Votes) String() string {
return out
}
// Empty returns whether a vote is empty.
func (v Vote) Empty() bool {
return v.String() == Vote{}.String()
}
// NewNonSplitVoteOption creates a single option vote with weight 1
func NewNonSplitVoteOption(option VoteOption) WeightedVoteOptions {
return WeightedVoteOptions{{option, sdk.NewDec(1)}}

View File

@ -10,7 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
paramscutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
)

View File

@ -5,7 +5,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/params/keeper"
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
)

View File

@ -9,7 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

View File

@ -3,7 +3,7 @@ package proposal
import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// RegisterLegacyAminoCodec registers all necessary param module types with a given LegacyAmino codec.

View File

@ -6,7 +6,7 @@ import (
"sigs.k8s.io/yaml"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
const (

View File

@ -17,7 +17,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/module"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/upgrade"
"github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"

View File

@ -10,7 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/upgrade/plan"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

View File

@ -3,7 +3,7 @@ package upgrade
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

View File

@ -3,7 +3,7 @@ package types
import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec

View File

@ -3,7 +3,7 @@ package types
import (
"fmt"
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
const (

View File

@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
)