Update x/gov to use Any (#6147)
* Update x/gov to use Any * Fixes * Remove MsgSubmitProposalLegacy * Update CHANGELOG.md * Add RegisterInterfaces for x/distribution, x/params, & x/upgrade * Fix query JSON issue * Fix gov tests * Revert custom Any Equals * Re-remove types * Rename receivers * Fix imports in gov * Sort imports * Make amino JSON signing work with Any * Run proto-gen * Create full amino wrapper * Fix errors * Fixes * Fix tests * Test fixes * Fix tests * Linting * Update ADR 019 and CHANGELOG * Updated ADR 019 * Extract Marshal/UnmarshalProposal * fix error * lint * linting * linting * Update client/keys/parse.go Co-authored-by: Marko <marbar3778@yahoo.com> * linting * Update docs/architecture/adr-019-protobuf-state-encoding.md Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> * Update docs/architecture/adr-019-protobuf-state-encoding.md Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> * Address review feedback * Add godocs * Fix errors * fix errors * revert file * Address review feedback * Address review feedback * Stacktrace debug flag * Fix tests * Address review feedback Co-authored-by: sahith-narahari <sahithnarahari@gmail.com> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
parent
d7677e0871
commit
70767c87c4
@ -97,6 +97,11 @@ information on how to implement the new `Keyring` interface.
|
||||
* [\#5858](https://github.com/cosmos/cosmos-sdk/pull/5858) Make Keyring store keys by name and address's hexbytes representation.
|
||||
* (x/evidence) [\#5952](https://github.com/cosmos/cosmos-sdk/pull/5952) Remove APIs for getting and setting `x/evidence` parameters. `BaseApp` now uses a `ParamStore` to manage Tendermint consensus parameters which is managed via the `x/params` `Substore` type.
|
||||
* (export) [\#5952](https://github.com/cosmos/cosmos-sdk/pull/5952) `AppExporter` now returns ABCI consensus parameters to be included in marshaled exported state. These parameters must be returned from the application via the `BaseApp`.
|
||||
* (codec) `*codec.Codec` is now a wrapper around Amino which provides backwards compatibility with protobuf `Any`.
|
||||
ALL legacy code should use `*codec.Codec` instead of `*amino.Codec` directly
|
||||
* (x/gov) [\#6147](https://github.com/cosmos/cosmos-sdk/pull/6147) The `Content` field on `Proposal` and `MsgSubmitProposal`
|
||||
is now `Any` in concordance with [ADR 019](docs/architecture/adr-019-protobuf-state-encoding.md) and `GetContent` should now
|
||||
be used to retrieve the actual proposal `Content`. Also the `NewMsgSubmitProposal` constructor now may return an `error`
|
||||
|
||||
### Features
|
||||
|
||||
|
||||
2
Makefile
2
Makefile
@ -124,7 +124,7 @@ test-race:
|
||||
@VERSION=$(VERSION) go test -mod=readonly -race $(PACKAGES_NOSIMULATION)
|
||||
|
||||
test-integration: build-sim
|
||||
BUILDDIR=$(BUILDDIR) go test -mod=readonly -p 4 -tags=-tags='ledger test_ledger_mock cli_test' -run ^TestCLI `go list ./.../cli/...`
|
||||
BUILDDIR=$(BUILDDIR) go test -mod=readonly -p 4 -tags='ledger test_ledger_mock cli_test' -run ^TestCLI `go list ./.../cli/...`
|
||||
|
||||
.PHONY: test test-all test-ledger-mock test-ledger test-unit test-race
|
||||
|
||||
|
||||
158
codec/amino.go
158
codec/amino.go
@ -8,6 +8,8 @@ import (
|
||||
amino "github.com/tendermint/go-amino"
|
||||
cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
)
|
||||
|
||||
// Cdc defines a global generic sealed Amino codec to be used throughout sdk. It
|
||||
@ -17,29 +19,38 @@ import (
|
||||
var Cdc *Codec
|
||||
|
||||
func init() {
|
||||
cdc := New()
|
||||
RegisterCrypto(cdc)
|
||||
RegisterEvidences(cdc)
|
||||
Cdc = cdc.Seal()
|
||||
Cdc = New()
|
||||
RegisterCrypto(Cdc)
|
||||
RegisterEvidences(Cdc)
|
||||
Cdc.Seal()
|
||||
}
|
||||
|
||||
// Codec defines a type alias for an Amino codec.
|
||||
type Codec = amino.Codec
|
||||
// deprecated: Codec defines a wrapper for an Amino codec that properly handles protobuf
|
||||
// types with Any's
|
||||
type Codec struct {
|
||||
Amino *amino.Codec
|
||||
}
|
||||
|
||||
var _ JSONMarshaler = &Codec{}
|
||||
|
||||
func (cdc *Codec) Seal() {
|
||||
cdc.Amino.Seal()
|
||||
}
|
||||
|
||||
func New() *Codec {
|
||||
return amino.NewCodec()
|
||||
return &Codec{amino.NewCodec()}
|
||||
}
|
||||
|
||||
// RegisterCrypto registers all crypto dependency types with the provided Amino
|
||||
// codec.
|
||||
func RegisterCrypto(cdc *Codec) {
|
||||
cryptoamino.RegisterAmino(cdc)
|
||||
cryptoamino.RegisterAmino(cdc.Amino)
|
||||
}
|
||||
|
||||
// RegisterEvidences registers Tendermint evidence types with the provided Amino
|
||||
// codec.
|
||||
func RegisterEvidences(cdc *Codec) {
|
||||
tmtypes.RegisterEvidences(cdc)
|
||||
tmtypes.RegisterEvidences(cdc.Amino)
|
||||
}
|
||||
|
||||
// MarshalJSONIndent provides a utility for indented JSON encoding of an object
|
||||
@ -68,3 +79,132 @@ func MustMarshalJSONIndent(m JSONMarshaler, obj interface{}) []byte {
|
||||
|
||||
return bz
|
||||
}
|
||||
|
||||
func (cdc *Codec) marshalAnys(o interface{}) error {
|
||||
return types.UnpackInterfaces(o, types.AminoPacker{Cdc: cdc.Amino})
|
||||
}
|
||||
|
||||
func (cdc *Codec) unmarshalAnys(o interface{}) error {
|
||||
return types.UnpackInterfaces(o, types.AminoUnpacker{Cdc: cdc.Amino})
|
||||
}
|
||||
|
||||
func (cdc *Codec) jsonMarshalAnys(o interface{}) error {
|
||||
return types.UnpackInterfaces(o, types.AminoJSONPacker{Cdc: cdc.Amino})
|
||||
}
|
||||
|
||||
func (cdc *Codec) jsonUnmarshalAnys(o interface{}) error {
|
||||
return types.UnpackInterfaces(o, types.AminoJSONUnpacker{Cdc: cdc.Amino})
|
||||
}
|
||||
|
||||
func (cdc *Codec) MarshalBinaryBare(o interface{}) ([]byte, error) {
|
||||
err := cdc.marshalAnys(o)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cdc.Amino.MarshalBinaryBare(o)
|
||||
}
|
||||
|
||||
func (cdc *Codec) MustMarshalBinaryBare(o interface{}) []byte {
|
||||
bz, err := cdc.MarshalBinaryBare(o)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return bz
|
||||
}
|
||||
|
||||
func (cdc *Codec) MarshalBinaryLengthPrefixed(o interface{}) ([]byte, error) {
|
||||
err := cdc.marshalAnys(o)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cdc.Amino.MarshalBinaryLengthPrefixed(o)
|
||||
}
|
||||
|
||||
func (cdc *Codec) MustMarshalBinaryLengthPrefixed(o interface{}) []byte {
|
||||
bz, err := cdc.MarshalBinaryLengthPrefixed(o)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return bz
|
||||
}
|
||||
|
||||
func (cdc *Codec) UnmarshalBinaryBare(bz []byte, ptr interface{}) error {
|
||||
err := cdc.Amino.UnmarshalBinaryBare(bz, ptr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cdc.unmarshalAnys(ptr)
|
||||
}
|
||||
|
||||
func (cdc *Codec) MustUnmarshalBinaryBare(bz []byte, ptr interface{}) {
|
||||
err := cdc.UnmarshalBinaryBare(bz, ptr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (cdc *Codec) UnmarshalBinaryLengthPrefixed(bz []byte, ptr interface{}) error {
|
||||
err := cdc.Amino.UnmarshalBinaryLengthPrefixed(bz, ptr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cdc.unmarshalAnys(ptr)
|
||||
}
|
||||
|
||||
func (cdc *Codec) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr interface{}) {
|
||||
err := cdc.UnmarshalBinaryLengthPrefixed(bz, ptr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (cdc *Codec) MarshalJSON(o interface{}) ([]byte, error) {
|
||||
err := cdc.jsonMarshalAnys(o)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cdc.Amino.MarshalJSON(o)
|
||||
}
|
||||
|
||||
func (cdc *Codec) MustMarshalJSON(o interface{}) []byte {
|
||||
bz, err := cdc.MarshalJSON(o)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return bz
|
||||
}
|
||||
|
||||
func (cdc *Codec) UnmarshalJSON(bz []byte, ptr interface{}) error {
|
||||
err := cdc.Amino.UnmarshalJSON(bz, ptr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cdc.jsonUnmarshalAnys(ptr)
|
||||
}
|
||||
|
||||
func (cdc *Codec) MustUnmarshalJSON(bz []byte, ptr interface{}) {
|
||||
err := cdc.UnmarshalJSON(bz, ptr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (*Codec) UnpackAny(*types.Any, interface{}) error {
|
||||
return fmt.Errorf("AminoCodec can't handle unpack protobuf Any's")
|
||||
}
|
||||
|
||||
func (cdc *Codec) RegisterInterface(ptr interface{}, iopts *amino.InterfaceOptions) {
|
||||
cdc.Amino.RegisterInterface(ptr, iopts)
|
||||
}
|
||||
|
||||
func (cdc *Codec) RegisterConcrete(o interface{}, name string, copts *amino.ConcreteOptions) {
|
||||
cdc.Amino.RegisterConcrete(o, name, copts)
|
||||
}
|
||||
|
||||
func (cdc *Codec) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byte, error) {
|
||||
err := cdc.jsonMarshalAnys(o)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return cdc.Amino.MarshalJSONIndent(o, prefix, indent)
|
||||
}
|
||||
|
||||
@ -1,133 +1,45 @@
|
||||
package codec
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
)
|
||||
|
||||
// AminoCodec defines a codec that utilizes Amino for both binary and JSON
|
||||
// AminoCodec defines a codec that utilizes Codec for both binary and JSON
|
||||
// encoding.
|
||||
type AminoCodec struct {
|
||||
amino *Codec
|
||||
*Codec
|
||||
}
|
||||
|
||||
func NewAminoCodec(amino *Codec) Marshaler {
|
||||
return &AminoCodec{amino}
|
||||
}
|
||||
var _ Marshaler = &AminoCodec{}
|
||||
|
||||
func (ac *AminoCodec) marshalAnys(o ProtoMarshaler) error {
|
||||
return types.UnpackInterfaces(o, types.AminoPacker{Cdc: ac.amino})
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) unmarshalAnys(o ProtoMarshaler) error {
|
||||
return types.UnpackInterfaces(o, types.AminoUnpacker{Cdc: ac.amino})
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) jsonMarshalAnys(o interface{}) error {
|
||||
return types.UnpackInterfaces(o, types.AminoJSONPacker{Cdc: ac.amino})
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) jsonUnmarshalAnys(o interface{}) error {
|
||||
return types.UnpackInterfaces(o, types.AminoJSONUnpacker{Cdc: ac.amino})
|
||||
func NewAminoCodec(codec *Codec) *AminoCodec {
|
||||
return &AminoCodec{Codec: codec}
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) MarshalBinaryBare(o ProtoMarshaler) ([]byte, error) {
|
||||
err := ac.marshalAnys(o)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ac.amino.MarshalBinaryBare(o)
|
||||
return ac.Codec.MarshalBinaryBare(o)
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) MustMarshalBinaryBare(o ProtoMarshaler) []byte {
|
||||
err := ac.marshalAnys(o)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ac.amino.MustMarshalBinaryBare(o)
|
||||
return ac.Codec.MustMarshalBinaryBare(o)
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) MarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error) {
|
||||
err := ac.marshalAnys(o)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ac.amino.MarshalBinaryLengthPrefixed(o)
|
||||
return ac.Codec.MarshalBinaryLengthPrefixed(o)
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) MustMarshalBinaryLengthPrefixed(o ProtoMarshaler) []byte {
|
||||
err := ac.marshalAnys(o)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ac.amino.MustMarshalBinaryLengthPrefixed(o)
|
||||
return ac.Codec.MustMarshalBinaryLengthPrefixed(o)
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error {
|
||||
err := ac.amino.UnmarshalBinaryBare(bz, ptr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ac.unmarshalAnys(ptr)
|
||||
return ac.Codec.UnmarshalBinaryBare(bz, ptr)
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) MustUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) {
|
||||
ac.amino.MustUnmarshalBinaryBare(bz, ptr)
|
||||
err := ac.unmarshalAnys(ptr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ac.Codec.MustUnmarshalBinaryBare(bz, ptr)
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error {
|
||||
err := ac.amino.UnmarshalBinaryLengthPrefixed(bz, ptr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ac.unmarshalAnys(ptr)
|
||||
return ac.Codec.UnmarshalBinaryLengthPrefixed(bz, ptr)
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) {
|
||||
ac.amino.MustUnmarshalBinaryLengthPrefixed(bz, ptr)
|
||||
err := ac.unmarshalAnys(ptr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) MarshalJSON(o interface{}) ([]byte, error) {
|
||||
err := ac.jsonMarshalAnys(o)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ac.amino.MarshalJSON(o)
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) MustMarshalJSON(o interface{}) []byte {
|
||||
err := ac.jsonMarshalAnys(o)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ac.amino.MustMarshalJSON(o)
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) UnmarshalJSON(bz []byte, ptr interface{}) error {
|
||||
err := ac.amino.UnmarshalJSON(bz, ptr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ac.jsonUnmarshalAnys(ptr)
|
||||
}
|
||||
|
||||
func (ac *AminoCodec) MustUnmarshalJSON(bz []byte, ptr interface{}) {
|
||||
ac.amino.MustUnmarshalJSON(bz, ptr)
|
||||
err := ac.jsonUnmarshalAnys(ptr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (*AminoCodec) UnpackAny(*types.Any, interface{}) error {
|
||||
return fmt.Errorf("AminoCodec can't handle unpack protobuf Any's")
|
||||
ac.Codec.MustUnmarshalBinaryLengthPrefixed(bz, ptr)
|
||||
}
|
||||
|
||||
@ -6,14 +6,13 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
amino "github.com/tendermint/go-amino"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/testdata"
|
||||
)
|
||||
|
||||
func createTestCodec() *amino.Codec {
|
||||
cdc := amino.NewCodec()
|
||||
func createTestCodec() *codec.Codec {
|
||||
cdc := codec.New()
|
||||
|
||||
cdc.RegisterInterface((*testdata.Animal)(nil), nil)
|
||||
cdc.RegisterConcrete(testdata.Dog{}, "testdata/Dog", nil)
|
||||
|
||||
@ -3,6 +3,9 @@ package types
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime/debug"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
|
||||
amino "github.com/tendermint/go-amino"
|
||||
)
|
||||
@ -13,10 +16,27 @@ type aminoCompat struct {
|
||||
err error
|
||||
}
|
||||
|
||||
var Debug = false
|
||||
|
||||
func aminoCompatError(errType string, x interface{}) error {
|
||||
if Debug {
|
||||
debug.PrintStack()
|
||||
}
|
||||
return fmt.Errorf(
|
||||
"amino %s Any marshaling error for %+v, this is likely because "+
|
||||
"amino is being used directly (instead of codec.Codec which is preferred) "+
|
||||
"or UnpackInterfacesMessage is not defined for some type which contains "+
|
||||
"a protobuf Any either directly or via one of its members. To see a "+
|
||||
"stacktrace of where the error is coming from, set the var Debug = true "+
|
||||
"in codec/types/amino_compat.go",
|
||||
errType, x,
|
||||
)
|
||||
}
|
||||
|
||||
func (any Any) MarshalAmino() ([]byte, error) {
|
||||
ac := any.aminoCompat
|
||||
if ac == nil {
|
||||
return nil, fmt.Errorf("can't amino unmarshal")
|
||||
return nil, aminoCompatError("binary unmarshal", any)
|
||||
}
|
||||
return ac.bz, ac.err
|
||||
}
|
||||
@ -32,7 +52,7 @@ func (any *Any) UnmarshalAmino(bz []byte) error {
|
||||
func (any Any) MarshalJSON() ([]byte, error) {
|
||||
ac := any.aminoCompat
|
||||
if ac == nil {
|
||||
return nil, fmt.Errorf("can't JSON marshal")
|
||||
return nil, aminoCompatError("JSON marshal", any)
|
||||
}
|
||||
return ac.jsonBz, ac.err
|
||||
}
|
||||
@ -56,7 +76,7 @@ var _ AnyUnpacker = AminoUnpacker{}
|
||||
func (a AminoUnpacker) UnpackAny(any *Any, iface interface{}) error {
|
||||
ac := any.aminoCompat
|
||||
if ac == nil {
|
||||
return fmt.Errorf("can't amino unmarshal %T", iface)
|
||||
return aminoCompatError("binary unmarshal", reflect.TypeOf(iface))
|
||||
}
|
||||
err := a.Cdc.UnmarshalBinaryBare(ac.bz, iface)
|
||||
if err != nil {
|
||||
@ -67,7 +87,19 @@ func (a AminoUnpacker) UnpackAny(any *Any, iface interface{}) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
any.cachedValue = val
|
||||
if m, ok := val.(proto.Message); ok {
|
||||
err := any.Pack(m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
any.cachedValue = val
|
||||
}
|
||||
|
||||
// this is necessary for tests that use reflect.DeepEqual and compare
|
||||
// proto vs amino marshaled values
|
||||
any.aminoCompat = nil
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -103,7 +135,7 @@ var _ AnyUnpacker = AminoJSONUnpacker{}
|
||||
func (a AminoJSONUnpacker) UnpackAny(any *Any, iface interface{}) error {
|
||||
ac := any.aminoCompat
|
||||
if ac == nil {
|
||||
return fmt.Errorf("can't amino unmarshal %T", iface)
|
||||
return aminoCompatError("JSON unmarshal", reflect.TypeOf(iface))
|
||||
}
|
||||
err := a.Cdc.UnmarshalJSON(ac.jsonBz, iface)
|
||||
if err != nil {
|
||||
@ -114,7 +146,19 @@ func (a AminoJSONUnpacker) UnpackAny(any *Any, iface interface{}) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
any.cachedValue = val
|
||||
if m, ok := val.(proto.Message); ok {
|
||||
err := any.Pack(m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
any.cachedValue = val
|
||||
}
|
||||
|
||||
// this is necessary for tests that use reflect.DeepEqual and compare
|
||||
// proto vs amino marshaled values
|
||||
any.aminoCompat = nil
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -112,6 +112,11 @@ func (registry *interfaceRegistry) RegisterImplementations(iface interface{}, im
|
||||
}
|
||||
|
||||
func (registry *interfaceRegistry) UnpackAny(any *Any, iface interface{}) error {
|
||||
if any.TypeUrl == "" {
|
||||
// if TypeUrl is empty return nil because without it we can't actually unpack anything
|
||||
return nil
|
||||
}
|
||||
|
||||
rv := reflect.ValueOf(iface)
|
||||
if rv.Kind() != reflect.Ptr {
|
||||
return fmt.Errorf("UnpackAny expects a pointer")
|
||||
|
||||
@ -12,7 +12,7 @@ var CryptoCdc *codec.Codec
|
||||
|
||||
func init() {
|
||||
CryptoCdc = codec.New()
|
||||
cryptoAmino.RegisterAmino(CryptoCdc)
|
||||
cryptoAmino.RegisterAmino(CryptoCdc.Amino)
|
||||
RegisterCodec(CryptoCdc)
|
||||
CryptoCdc.Seal()
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
- 2020 Feb 15: Initial Draft
|
||||
- 2020 Feb 24: Updates to handle messages with interface fields
|
||||
- 2020 Apr 27: Convert usages of `oneof` for interfaces to `Any`
|
||||
- 2020 May 15: Describe `cosmos_proto` extensions and amino compatibility
|
||||
|
||||
## Status
|
||||
|
||||
@ -176,6 +177,14 @@ type InterfaceRegistry interface {
|
||||
In addition to serving as a whitelist, `InterfaceRegistry` can also serve
|
||||
to communicate the list of concrete types that satisfy an interface to clients.
|
||||
|
||||
In .proto files:
|
||||
* fields which accept interfaces should be annotated with `cosmos_proto.accepts_interface`
|
||||
using the same full-qualified name passed as `protoName` to `InterfaceRegistry.RegisterInterface`
|
||||
* interface implementations should be annotated with `cosmos_proto.implements_interface`
|
||||
using the same full-qualified name passed as `protoName` to `InterfaceRegistry.RegisterInterface`
|
||||
|
||||
In the future, `protoName`, `cosmos_proto.accepts_interface`, `cosmos_proto.implements_interface`
|
||||
may be used via code generation, reflection &/or static linting.
|
||||
|
||||
The same struct that implements `InterfaceRegistry` will also implement an
|
||||
interface `InterfaceUnpacker` to be used for unpacking `Any`s:
|
||||
@ -299,6 +308,21 @@ func (msg MsgSubmitEvidence) GetEvidence() eviexported.Evidence {
|
||||
}
|
||||
```
|
||||
|
||||
### Amino Compatibility
|
||||
|
||||
Our custom implementation of `Any` can be used transparently with Amino if used
|
||||
with the proper codec instance. What this means is that interfaces packed within
|
||||
`Any`s will be amino marshaled like regular Amino interfaces (assuming they
|
||||
have been registered properly with Amino).
|
||||
|
||||
In order for this functionality to work:
|
||||
* **all legacy code must use `*codec.Codec` instead of `*amino.Codec` which is
|
||||
now a wrapper which properly handles `Any`**
|
||||
* **all new code should use `Marshaler` which is compatible with both amino and
|
||||
protobuf**
|
||||
|
||||
Also, before v0.39, `codec.Codec` will be renamed to `codec.LegacyAmino`.
|
||||
|
||||
### Why Wasn't X Chosen Instead
|
||||
|
||||
For a more complete comparison to alternative protocols, see [here](https://codeburst.io/json-vs-protocol-buffers-vs-flatbuffers-a4247f8bda6f).
|
||||
|
||||
@ -5,9 +5,10 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/tendermint/go-amino"
|
||||
"github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -81,7 +82,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func queryCmd(cdc *amino.Codec) *cobra.Command {
|
||||
func queryCmd(cdc *codec.Codec) *cobra.Command {
|
||||
queryCmd := &cobra.Command{
|
||||
Use: "query",
|
||||
Aliases: []string{"q"},
|
||||
@ -107,7 +108,7 @@ func queryCmd(cdc *amino.Codec) *cobra.Command {
|
||||
return queryCmd
|
||||
}
|
||||
|
||||
func txCmd(cdc *amino.Codec) *cobra.Command {
|
||||
func txCmd(cdc *codec.Codec) *cobra.Command {
|
||||
txCmd := &cobra.Command{
|
||||
Use: "tx",
|
||||
Short: "Transactions subcommands",
|
||||
|
||||
@ -5,12 +5,13 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/std"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/go-amino"
|
||||
"github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
@ -33,7 +34,7 @@ const (
|
||||
|
||||
// AddGenesisAccountCmd returns add-genesis-account cobra Command.
|
||||
func AddGenesisAccountCmd(
|
||||
ctx *server.Context, depCdc *amino.Codec, cdc *std.Codec, defaultNodeHome, defaultClientHome string,
|
||||
ctx *server.Context, depCdc *codec.Codec, cdc *std.Codec, defaultNodeHome, defaultClientHome string,
|
||||
) *cobra.Command {
|
||||
|
||||
cmd := &cobra.Command{
|
||||
|
||||
29
std/codec.go
29
std/codec.go
@ -8,12 +8,10 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
|
||||
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
)
|
||||
|
||||
var (
|
||||
_ auth.Codec = (*Codec)(nil)
|
||||
_ gov.Codec = (*Codec)(nil)
|
||||
)
|
||||
|
||||
// Codec defines the application-level codec. This codec contains all the
|
||||
@ -71,33 +69,6 @@ func (c *Codec) UnmarshalAccountJSON(bz []byte) (authexported.Account, error) {
|
||||
return acc.GetAccount(), nil
|
||||
}
|
||||
|
||||
// MarshalProposal marshals a Proposal. It accepts a Proposal defined by the x/gov
|
||||
// module and uses the application-level Proposal type which has the concrete
|
||||
// Content implementation to serialize.
|
||||
func (c *Codec) MarshalProposal(p gov.Proposal) ([]byte, error) {
|
||||
proposal := &Proposal{ProposalBase: p.ProposalBase}
|
||||
if err := proposal.Content.SetContent(p.Content); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return c.Marshaler.MarshalBinaryBare(proposal)
|
||||
}
|
||||
|
||||
// UnmarshalProposal decodes a Proposal defined by the x/gov module and uses the
|
||||
// application-level Proposal type which has the concrete Content implementation
|
||||
// to deserialize.
|
||||
func (c *Codec) UnmarshalProposal(bz []byte) (gov.Proposal, error) {
|
||||
proposal := &Proposal{}
|
||||
if err := c.Marshaler.UnmarshalBinaryBare(bz, proposal); err != nil {
|
||||
return gov.Proposal{}, err
|
||||
}
|
||||
|
||||
return gov.Proposal{
|
||||
Content: proposal.Content.GetContent(),
|
||||
ProposalBase: proposal.ProposalBase,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// necessary types and interfaces registered. This codec is provided to all the
|
||||
// modules the application depends on.
|
||||
|
||||
1678
std/codec.pb.go
1678
std/codec.pb.go
File diff suppressed because it is too large
Load Diff
@ -12,8 +12,6 @@ import "x/distribution/types/types.proto";
|
||||
import "x/gov/types/types.proto";
|
||||
import "x/slashing/types/types.proto";
|
||||
import "x/staking/types/types.proto";
|
||||
import "x/params/types/proposal/types.proto";
|
||||
import "x/upgrade/types/types.proto";
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/std";
|
||||
|
||||
@ -31,41 +29,6 @@ message Account {
|
||||
}
|
||||
}
|
||||
|
||||
// MsgSubmitProposal defines the application-level message type for handling
|
||||
// governance proposals.
|
||||
message MsgSubmitProposal {
|
||||
option (gogoproto.equal) = true;
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
cosmos_sdk.x.gov.v1.MsgSubmitProposalBase base = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
|
||||
Content content = 2;
|
||||
}
|
||||
|
||||
// Proposal defines the application-level concrete proposal type used in
|
||||
// governance proposals.
|
||||
message Proposal {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
cosmos_sdk.x.gov.v1.ProposalBase base = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
|
||||
Content content = 2 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// Content defines the application-level allowed Content to be included in a
|
||||
// governance proposal.
|
||||
message Content {
|
||||
option (gogoproto.equal) = true;
|
||||
option (cosmos_proto.interface_type) = "*github.com/cosmos/cosmos-sdk/x/gov/types.Content";
|
||||
|
||||
// sum defines a set of all acceptable concrete governance proposal Content
|
||||
// types.
|
||||
oneof sum {
|
||||
cosmos_sdk.x.gov.v1.TextProposal text = 1;
|
||||
cosmos_sdk.x.params.v1.ParameterChangeProposal parameter_change = 2;
|
||||
cosmos_sdk.x.upgrade.v1.SoftwareUpgradeProposal software_upgrade = 3;
|
||||
cosmos_sdk.x.upgrade.v1.CancelSoftwareUpgradeProposal cancel_software_upgrade = 4;
|
||||
cosmos_sdk.x.distribution.v1.CommunityPoolSpendProposal community_pool_spend = 5;
|
||||
}
|
||||
}
|
||||
|
||||
// Transaction defines the application-level transaction that can be signed and
|
||||
// processed by the state-machine. It contains a base of common fields and
|
||||
@ -91,7 +54,6 @@ message Message {
|
||||
cosmos_sdk.x.distribution.v1.MsgWithdrawDelegatorReward msg_withdraw_delegator_reward = 5;
|
||||
cosmos_sdk.x.distribution.v1.MsgWithdrawValidatorCommission msg_withdraw_validator_commission = 6;
|
||||
cosmos_sdk.x.distribution.v1.MsgFundCommunityPool msg_fund_community_pool = 7;
|
||||
MsgSubmitProposal msg_submit_proposal = 9;
|
||||
cosmos_sdk.x.gov.v1.MsgVote msg_vote = 10;
|
||||
cosmos_sdk.x.gov.v1.MsgDeposit msg_deposit = 11;
|
||||
cosmos_sdk.x.slashing.v1.MsgUnjail msg_unjail = 12;
|
||||
|
||||
54
std/msgs.go
54
std/msgs.go
@ -1,54 +0,0 @@
|
||||
package std
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
)
|
||||
|
||||
var (
|
||||
_ gov.MsgSubmitProposalI = &MsgSubmitProposal{}
|
||||
)
|
||||
|
||||
// NewMsgSubmitProposal returns a new MsgSubmitProposal.
|
||||
func NewMsgSubmitProposal(c gov.Content, d sdk.Coins, p sdk.AccAddress) (gov.MsgSubmitProposalI, error) {
|
||||
content := &Content{}
|
||||
if err := content.SetContent(c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MsgSubmitProposal{
|
||||
Content: content,
|
||||
MsgSubmitProposalBase: gov.NewMsgSubmitProposalBase(d, p),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ValidateBasic performs basic (non-state-dependant) validation on a
|
||||
// MsgSubmitProposal.
|
||||
func (msg MsgSubmitProposal) ValidateBasic() error {
|
||||
if err := msg.MsgSubmitProposalBase.ValidateBasic(); err != nil {
|
||||
return nil
|
||||
}
|
||||
if msg.Content == nil {
|
||||
return sdkerrors.Wrap(gov.ErrInvalidProposalContent, "missing content")
|
||||
}
|
||||
if !gov.IsValidProposalType(msg.Content.GetContent().ProposalType()) {
|
||||
return sdkerrors.Wrap(gov.ErrInvalidProposalType, msg.Content.GetContent().ProposalType())
|
||||
}
|
||||
if err := msg.Content.GetContent().ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (msg *MsgSubmitProposal) GetContent() gov.Content { return msg.Content.GetContent() }
|
||||
func (msg *MsgSubmitProposal) SetContent(content gov.Content) error {
|
||||
stdContent := &Content{}
|
||||
err := stdContent.SetContent(content)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
msg.Content = stdContent
|
||||
return nil
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
package std_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/std"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
type invalidProposal struct {
|
||||
*gov.TextProposal
|
||||
}
|
||||
|
||||
func TestMsgSubmitProposal(t *testing.T) {
|
||||
p := sdk.AccAddress("foo")
|
||||
d := sdk.NewCoins(sdk.NewInt64Coin("stake", 1000))
|
||||
c := gov.NewTextProposal("title", "description")
|
||||
|
||||
//
|
||||
// test constructor
|
||||
//
|
||||
|
||||
msg, err := std.NewMsgSubmitProposal(c, d, p)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, msg.GetContent(), c)
|
||||
require.Equal(t, msg.GetProposer(), p)
|
||||
require.Equal(t, msg.GetInitialDeposit(), d)
|
||||
require.NoError(t, msg.ValidateBasic())
|
||||
|
||||
_, err = std.NewMsgSubmitProposal(invalidProposal{}, d, p)
|
||||
require.Error(t, err)
|
||||
|
||||
//
|
||||
// test setter methods
|
||||
//
|
||||
|
||||
msg = &std.MsgSubmitProposal{}
|
||||
msg.SetProposer(p)
|
||||
msg.SetInitialDeposit(d)
|
||||
err = msg.SetContent(c)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, msg.GetContent(), c)
|
||||
require.Equal(t, msg.GetProposer(), p)
|
||||
require.Equal(t, msg.GetInitialDeposit(), d)
|
||||
require.NoError(t, msg.ValidateBasic())
|
||||
|
||||
msg = &std.MsgSubmitProposal{}
|
||||
err = msg.SetContent(invalidProposal{})
|
||||
require.Error(t, err)
|
||||
|
||||
}
|
||||
@ -229,7 +229,7 @@ func NewTestCaseDir(t NamedTestingT) (string, func()) {
|
||||
var cdc = codec.New()
|
||||
|
||||
func init() {
|
||||
ctypes.RegisterAmino(cdc)
|
||||
ctypes.RegisterAmino(cdc.Amino)
|
||||
}
|
||||
|
||||
//DONTCOVER
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
)
|
||||
@ -264,3 +265,24 @@ func ParseABCILogs(logs string) (res ABCIMessageLogs, err error) {
|
||||
err = json.Unmarshal([]byte(logs), &res)
|
||||
return res, err
|
||||
}
|
||||
|
||||
var _, _ types.UnpackInterfacesMessage = SearchTxsResult{}, TxResponse{}
|
||||
|
||||
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
|
||||
//
|
||||
// types.UnpackInterfaces needs to be called for each nested Tx because
|
||||
// there are generally interfaces to unpack in Tx's
|
||||
func (s SearchTxsResult) UnpackInterfaces(unpacker types.AnyUnpacker) error {
|
||||
for _, tx := range s.Txs {
|
||||
err := types.UnpackInterfaces(tx, unpacker)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
|
||||
func (r TxResponse) UnpackInterfaces(unpacker types.AnyUnpacker) error {
|
||||
return types.UnpackInterfaces(r.Tx, unpacker)
|
||||
}
|
||||
|
||||
@ -7,15 +7,15 @@ import (
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/go-amino"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/tests"
|
||||
)
|
||||
|
||||
func TestGetBroadcastCommand_OfflineFlag(t *testing.T) {
|
||||
codec := amino.NewCodec()
|
||||
cmd := GetBroadcastCommand(codec)
|
||||
cdc := codec.New()
|
||||
cmd := GetBroadcastCommand(cdc)
|
||||
|
||||
viper.Set(flags.FlagOffline, true)
|
||||
|
||||
@ -24,8 +24,8 @@ func TestGetBroadcastCommand_OfflineFlag(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetBroadcastCommand_WithoutOfflineFlag(t *testing.T) {
|
||||
codec := amino.NewCodec()
|
||||
cmd := GetBroadcastCommand(codec)
|
||||
cdc := codec.New()
|
||||
cmd := GetBroadcastCommand(cdc)
|
||||
|
||||
viper.Set(flags.FlagOffline, false)
|
||||
|
||||
|
||||
@ -6,10 +6,10 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/tendermint/go-amino"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
)
|
||||
|
||||
@ -17,7 +17,7 @@ const flagHex = "hex"
|
||||
|
||||
// GetDecodeCommand returns the decode command to take Amino-serialized bytes
|
||||
// and turn it into a JSONified transaction.
|
||||
func GetDecodeCommand(codec *amino.Codec) *cobra.Command {
|
||||
func GetDecodeCommand(codec *codec.Codec) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "decode [amino-byte-string]",
|
||||
Short: "Decode an amino-encoded transaction string.",
|
||||
@ -29,7 +29,7 @@ func GetDecodeCommand(codec *amino.Codec) *cobra.Command {
|
||||
return flags.PostCommands(cmd)[0]
|
||||
}
|
||||
|
||||
func runDecodeTxString(codec *amino.Codec) func(cmd *cobra.Command, args []string) (err error) {
|
||||
func runDecodeTxString(codec *codec.Codec) func(cmd *cobra.Command, args []string) (err error) {
|
||||
return func(cmd *cobra.Command, args []string) (err error) {
|
||||
cliCtx := context.NewCLIContext().WithCodec(codec).WithOutput(cmd.OutOrStdout())
|
||||
var txBytes []byte
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@ -20,3 +21,15 @@ type StdSignMsg struct {
|
||||
func (msg StdSignMsg) Bytes() []byte {
|
||||
return StdSignBytes(msg.ChainID, msg.AccountNumber, msg.Sequence, msg.Fee, msg.Msgs, msg.Memo)
|
||||
}
|
||||
|
||||
var _ types.UnpackInterfacesMessage = StdSignMsg{}
|
||||
|
||||
func (msg StdSignMsg) UnpackInterfaces(unpacker types.AnyUnpacker) error {
|
||||
for _, m := range msg.Msgs {
|
||||
err := types.UnpackInterfaces(m, unpacker)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||
@ -343,3 +344,15 @@ func DefaultTxEncoder(cdc *codec.Codec) sdk.TxEncoder {
|
||||
return cdc.MarshalBinaryBare(tx)
|
||||
}
|
||||
}
|
||||
|
||||
var _ codectypes.UnpackInterfacesMessage = StdTx{}
|
||||
|
||||
func (tx StdTx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
|
||||
for _, m := range tx.Msgs {
|
||||
err := codectypes.UnpackInterfaces(m, unpacker)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ func NonnegativeBalanceInvariant(k ViewKeeper) sdk.Invariant {
|
||||
// TotalSupply checks that the total supply reflects all the coins held in accounts
|
||||
func TotalSupply(k Keeper) sdk.Invariant {
|
||||
return func(ctx sdk.Context) (string, bool) {
|
||||
var expectedTotal sdk.Coins
|
||||
expectedTotal := sdk.Coins{}
|
||||
supply := k.GetSupply(ctx)
|
||||
|
||||
k.IterateAllBalances(ctx, func(_ sdk.AccAddress, balance sdk.Coin) bool {
|
||||
|
||||
@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -13,7 +15,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
var _ Keeper = (*BaseKeeper)(nil)
|
||||
|
||||
@ -481,7 +481,10 @@ Where proposal.json contains:
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
msg := gov.NewMsgSubmitProposal(content, deposit, from)
|
||||
msg, err := gov.NewMsgSubmitProposal(content, deposit, from)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -50,7 +50,10 @@ func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
|
||||
content := types.NewCommunityPoolSpendProposal(req.Title, req.Description, req.Recipient, req.Amount)
|
||||
|
||||
msg := gov.NewMsgSubmitProposal(content, req.Deposit, req.Proposer)
|
||||
msg, err := gov.NewMsgSubmitProposal(content, req.Deposit, req.Proposer)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
if rest.CheckBadRequestError(w, msg.ValidateBasic()) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/spf13/cobra"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
@ -25,6 +27,7 @@ var (
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ module.InterfaceModule = AppModuleBasic{}
|
||||
)
|
||||
|
||||
// AppModuleBasic defines the basic application module used by the distribution module.
|
||||
@ -73,6 +76,11 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command {
|
||||
return cli.GetQueryCmd(StoreKey, cdc)
|
||||
}
|
||||
|
||||
// RegisterInterfaceTypes implements InterfaceModule
|
||||
func (b AppModuleBasic) RegisterInterfaceTypes(registry cdctypes.InterfaceRegistry) {
|
||||
types.RegisterInterfaces(registry)
|
||||
}
|
||||
|
||||
//____________________________________________________________________________
|
||||
|
||||
// AppModule implements an application module for the distribution module.
|
||||
|
||||
@ -3,6 +3,8 @@ package types
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
)
|
||||
|
||||
// RegisterCodec registers the necessary x/distribution interfaces and concrete types
|
||||
@ -15,6 +17,19 @@ func RegisterCodec(cdc *codec.Codec) {
|
||||
cdc.RegisterConcrete(&CommunityPoolSpendProposal{}, "cosmos-sdk/CommunityPoolSpendProposal", nil)
|
||||
}
|
||||
|
||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
registry.RegisterImplementations(
|
||||
(*sdk.Msg)(nil),
|
||||
&MsgWithdrawDelegatorReward{},
|
||||
&MsgWithdrawValidatorCommission{},
|
||||
&MsgSetWithdrawAddress{},
|
||||
)
|
||||
registry.RegisterImplementations(
|
||||
(*gov.Content)(nil),
|
||||
&CommunityPoolSpendProposal{},
|
||||
)
|
||||
}
|
||||
|
||||
var (
|
||||
amino = codec.New()
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ func EndBlocker(ctx sdk.Context, keeper Keeper) {
|
||||
// The proposal handler may execute state mutating logic depending
|
||||
// on the proposal content. If the handler fails, no state mutation
|
||||
// is written and the error message is logged.
|
||||
err := handler(cacheCtx, proposal.Content)
|
||||
err := handler(cacheCtx, proposal.GetContent())
|
||||
if err == nil {
|
||||
proposal.Status = StatusPassed
|
||||
tagValue = types.AttributeValueProposalPassed
|
||||
|
||||
@ -4,8 +4,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/std"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
@ -29,7 +27,7 @@ func TestTickExpiredDepositPeriod(t *testing.T) {
|
||||
require.False(t, inactiveQueue.Valid())
|
||||
inactiveQueue.Close()
|
||||
|
||||
newProposalMsg, err := std.NewMsgSubmitProposal(
|
||||
newProposalMsg, err := gov.NewMsgSubmitProposal(
|
||||
gov.ContentFromProposalType("test", "test", gov.ProposalTypeText),
|
||||
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
|
||||
addrs[0],
|
||||
@ -81,7 +79,7 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) {
|
||||
require.False(t, inactiveQueue.Valid())
|
||||
inactiveQueue.Close()
|
||||
|
||||
newProposalMsg, err := std.NewMsgSubmitProposal(
|
||||
newProposalMsg, err := gov.NewMsgSubmitProposal(
|
||||
gov.ContentFromProposalType("test", "test", gov.ProposalTypeText),
|
||||
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
|
||||
addrs[0],
|
||||
@ -104,7 +102,7 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) {
|
||||
require.False(t, inactiveQueue.Valid())
|
||||
inactiveQueue.Close()
|
||||
|
||||
newProposalMsg2, err := std.NewMsgSubmitProposal(
|
||||
newProposalMsg2, err := gov.NewMsgSubmitProposal(
|
||||
gov.ContentFromProposalType("test2", "test2", gov.ProposalTypeText),
|
||||
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
|
||||
addrs[0],
|
||||
@ -161,7 +159,7 @@ func TestTickPassedDepositPeriod(t *testing.T) {
|
||||
require.False(t, activeQueue.Valid())
|
||||
activeQueue.Close()
|
||||
|
||||
newProposalMsg, err := std.NewMsgSubmitProposal(
|
||||
newProposalMsg, err := gov.NewMsgSubmitProposal(
|
||||
gov.ContentFromProposalType("test2", "test2", gov.ProposalTypeText),
|
||||
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
|
||||
addrs[0],
|
||||
@ -217,7 +215,7 @@ func TestTickPassedVotingPeriod(t *testing.T) {
|
||||
activeQueue.Close()
|
||||
|
||||
proposalCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(5))}
|
||||
newProposalMsg, err := std.NewMsgSubmitProposal(TestProposal, proposalCoins, addrs[0])
|
||||
newProposalMsg, err := gov.NewMsgSubmitProposal(TestProposal, proposalCoins, addrs[0])
|
||||
require.NoError(t, err)
|
||||
|
||||
res, err := govHandler(ctx, newProposalMsg)
|
||||
|
||||
@ -81,7 +81,6 @@ var (
|
||||
SplitKeyDeposit = types.SplitKeyDeposit
|
||||
SplitKeyVote = types.SplitKeyVote
|
||||
NewMsgSubmitProposal = types.NewMsgSubmitProposal
|
||||
NewMsgSubmitProposalBase = types.NewMsgSubmitProposalBase
|
||||
NewMsgDeposit = types.NewMsgDeposit
|
||||
NewMsgVote = types.NewMsgVote
|
||||
ParamKeyTable = types.ParamKeyTable
|
||||
@ -124,34 +123,32 @@ var (
|
||||
)
|
||||
|
||||
type (
|
||||
Keeper = keeper.Keeper
|
||||
Content = types.Content
|
||||
Handler = types.Handler
|
||||
Deposit = types.Deposit
|
||||
Deposits = types.Deposits
|
||||
GenesisState = types.GenesisState
|
||||
MsgSubmitProposalI = types.MsgSubmitProposalI
|
||||
MsgSubmitProposal = types.MsgSubmitProposal
|
||||
MsgSubmitProposalBase = types.MsgSubmitProposalBase
|
||||
MsgDeposit = types.MsgDeposit
|
||||
MsgVote = types.MsgVote
|
||||
DepositParams = types.DepositParams
|
||||
TallyParams = types.TallyParams
|
||||
VotingParams = types.VotingParams
|
||||
Params = types.Params
|
||||
Proposal = types.Proposal
|
||||
Proposals = types.Proposals
|
||||
ProposalQueue = types.ProposalQueue
|
||||
ProposalStatus = types.ProposalStatus
|
||||
TextProposal = types.TextProposal
|
||||
QueryProposalParams = types.QueryProposalParams
|
||||
QueryDepositParams = types.QueryDepositParams
|
||||
QueryVoteParams = types.QueryVoteParams
|
||||
QueryProposalsParams = types.QueryProposalsParams
|
||||
ValidatorGovInfo = types.ValidatorGovInfo
|
||||
TallyResult = types.TallyResult
|
||||
Vote = types.Vote
|
||||
Votes = types.Votes
|
||||
VoteOption = types.VoteOption
|
||||
Codec = types.Codec
|
||||
Keeper = keeper.Keeper
|
||||
Content = types.Content
|
||||
Handler = types.Handler
|
||||
Deposit = types.Deposit
|
||||
Deposits = types.Deposits
|
||||
GenesisState = types.GenesisState
|
||||
MsgSubmitProposalI = types.MsgSubmitProposalI
|
||||
MsgSubmitProposal = types.MsgSubmitProposal
|
||||
MsgDeposit = types.MsgDeposit
|
||||
MsgVote = types.MsgVote
|
||||
DepositParams = types.DepositParams
|
||||
TallyParams = types.TallyParams
|
||||
VotingParams = types.VotingParams
|
||||
Params = types.Params
|
||||
Proposal = types.Proposal
|
||||
Proposals = types.Proposals
|
||||
ProposalQueue = types.ProposalQueue
|
||||
ProposalStatus = types.ProposalStatus
|
||||
TextProposal = types.TextProposal
|
||||
QueryProposalParams = types.QueryProposalParams
|
||||
QueryDepositParams = types.QueryDepositParams
|
||||
QueryVoteParams = types.QueryVoteParams
|
||||
QueryProposalsParams = types.QueryProposalsParams
|
||||
ValidatorGovInfo = types.ValidatorGovInfo
|
||||
TallyResult = types.TallyResult
|
||||
Vote = types.Vote
|
||||
Votes = types.Votes
|
||||
VoteOption = types.VoteOption
|
||||
)
|
||||
|
||||
@ -6,6 +6,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/types/errors"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -326,7 +328,10 @@ $ %s tx gov submit-proposal --title="Test Proposal" --description="My awesome pr
|
||||
|
||||
content := types.ContentFromProposalType(proposal.Title, proposal.Description, proposal.Type)
|
||||
|
||||
msg := types.NewMsgSubmitProposal(content, amount, cliCtx.GetFromAddress())
|
||||
msg, err := types.NewMsgSubmitProposal(content, amount, cliCtx.GetFromAddress())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "can't create new MsgSubmitProposal")
|
||||
}
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -162,7 +162,10 @@ func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
proposalType := gcutils.NormalizeProposalType(req.ProposalType)
|
||||
content := types.ContentFromProposalType(req.Title, req.Description, proposalType)
|
||||
|
||||
msg := types.NewMsgSubmitProposal(content, req.InitialDeposit, req.Proposer)
|
||||
msg, err := types.NewMsgSubmitProposal(content, req.InitialDeposit, req.Proposer)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
if rest.CheckBadRequestError(w, msg.ValidateBasic()) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -55,9 +55,9 @@ func TestImportExportQueues(t *testing.T) {
|
||||
govGenState := gov.ExportGenesis(ctx, app.GovKeeper)
|
||||
genesisState := simapp.NewDefaultGenesisState()
|
||||
|
||||
genesisState[auth.ModuleName] = app.Codec().MustMarshalJSON(authGenState)
|
||||
genesisState[bank.ModuleName] = app.Codec().MustMarshalJSON(bankGenState)
|
||||
genesisState[gov.ModuleName] = app.Codec().MustMarshalJSON(govGenState)
|
||||
genesisState[auth.ModuleName] = app.AppCodec().MustMarshalJSON(authGenState)
|
||||
genesisState[bank.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenState)
|
||||
genesisState[gov.ModuleName] = app.AppCodec().MustMarshalJSON(govGenState)
|
||||
|
||||
stateBytes, err := codec.MarshalJSONIndent(app.Codec(), genesisState)
|
||||
if err != nil {
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
@ -26,7 +27,7 @@ type Keeper struct {
|
||||
storeKey sdk.StoreKey
|
||||
|
||||
// The codec codec for binary encoding/decoding.
|
||||
cdc types.Codec
|
||||
cdc codec.Marshaler
|
||||
|
||||
// Proposal router
|
||||
router types.Router
|
||||
@ -40,7 +41,7 @@ type Keeper struct {
|
||||
//
|
||||
// CONTRACT: the parameter Subspace must have the param key table already initialized
|
||||
func NewKeeper(
|
||||
cdc types.Codec, key sdk.StoreKey, paramSpace types.ParamSubspace,
|
||||
cdc codec.Marshaler, key sdk.StoreKey, paramSpace types.ParamSubspace,
|
||||
authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper, rtr types.Router,
|
||||
) Keeper {
|
||||
|
||||
|
||||
@ -32,7 +32,10 @@ func (keeper Keeper) SubmitProposal(ctx sdk.Context, content types.Content) (typ
|
||||
submitTime := ctx.BlockHeader().Time
|
||||
depositPeriod := keeper.GetDepositParams(ctx).MaxDepositPeriod
|
||||
|
||||
proposal := types.NewProposal(content, proposalID, submitTime, submitTime.Add(depositPeriod))
|
||||
proposal, err := types.NewProposal(content, proposalID, submitTime, submitTime.Add(depositPeriod))
|
||||
if err != nil {
|
||||
return types.Proposal{}, err
|
||||
}
|
||||
|
||||
keeper.SetProposal(ctx, proposal)
|
||||
keeper.InsertInactiveProposalQueue(ctx, proposalID, proposal.DepositEndTime)
|
||||
@ -57,10 +60,8 @@ func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (types.Prop
|
||||
return types.Proposal{}, false
|
||||
}
|
||||
|
||||
proposal, err := keeper.cdc.UnmarshalProposal(bz)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
var proposal types.Proposal
|
||||
keeper.MustUnmarshalProposal(bz, &proposal)
|
||||
|
||||
return proposal, true
|
||||
}
|
||||
@ -69,10 +70,7 @@ func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (types.Prop
|
||||
func (keeper Keeper) SetProposal(ctx sdk.Context, proposal types.Proposal) {
|
||||
store := ctx.KVStore(keeper.storeKey)
|
||||
|
||||
bz, err := keeper.cdc.MarshalProposal(proposal)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
bz := keeper.MustMarshalProposal(proposal)
|
||||
|
||||
store.Set(types.ProposalKey(proposal.ProposalID), bz)
|
||||
}
|
||||
@ -97,7 +95,8 @@ func (keeper Keeper) IterateProposals(ctx sdk.Context, cb func(proposal types.Pr
|
||||
defer iterator.Close()
|
||||
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
proposal, err := keeper.cdc.UnmarshalProposal(iterator.Value())
|
||||
var proposal types.Proposal
|
||||
err := keeper.UnmarshalProposal(iterator.Value(), &proposal)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -126,7 +125,7 @@ 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.Proposal {
|
||||
func (keeper Keeper) GetProposalsFiltered(ctx sdk.Context, params types.QueryProposalsParams) types.Proposals {
|
||||
proposals := keeper.GetProposals(ctx)
|
||||
filteredProposals := make([]types.Proposal, 0, len(proposals))
|
||||
|
||||
@ -191,3 +190,34 @@ func (keeper Keeper) ActivateVotingPeriod(ctx sdk.Context, proposal types.Propos
|
||||
keeper.RemoveFromInactiveProposalQueue(ctx, proposal.ProposalID, proposal.DepositEndTime)
|
||||
keeper.InsertActiveProposalQueue(ctx, proposal.ProposalID, proposal.VotingEndTime)
|
||||
}
|
||||
|
||||
func (keeper Keeper) MarshalProposal(proposal types.Proposal) ([]byte, error) {
|
||||
bz, err := keeper.cdc.MarshalBinaryBare(&proposal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bz, nil
|
||||
}
|
||||
|
||||
func (keeper Keeper) UnmarshalProposal(bz []byte, proposal *types.Proposal) error {
|
||||
err := keeper.cdc.UnmarshalBinaryBare(bz, proposal)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (keeper Keeper) MustMarshalProposal(proposal types.Proposal) []byte {
|
||||
bz, err := keeper.MarshalProposal(proposal)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return bz
|
||||
}
|
||||
|
||||
func (keeper Keeper) MustUnmarshalProposal(bz []byte, proposal *types.Proposal) {
|
||||
err := keeper.UnmarshalProposal(bz, proposal)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,9 @@ func TestGetProposalsFiltered(t *testing.T) {
|
||||
|
||||
for _, s := range status {
|
||||
for i := 0; i < 50; i++ {
|
||||
p := types.NewProposal(TestProposal, proposalID, time.Now(), time.Now())
|
||||
p, err := types.NewProposal(TestProposal, proposalID, time.Now(), time.Now())
|
||||
require.NoError(t, err)
|
||||
|
||||
p.Status = s
|
||||
|
||||
if i%2 == 0 {
|
||||
|
||||
@ -297,10 +297,8 @@ func TestPaginatedVotesQuery(t *testing.T) {
|
||||
appCodec := app.AppCodec()
|
||||
|
||||
proposal := types.Proposal{
|
||||
ProposalBase: types.ProposalBase{
|
||||
ProposalID: 100,
|
||||
Status: types.StatusVotingPeriod,
|
||||
},
|
||||
ProposalID: 100,
|
||||
Status: types.StatusVotingPeriod,
|
||||
}
|
||||
|
||||
app.GovKeeper.SetProposal(ctx, proposal)
|
||||
|
||||
@ -14,6 +14,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
@ -28,11 +29,12 @@ var (
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ module.InterfaceModule = AppModuleBasic{}
|
||||
)
|
||||
|
||||
// AppModuleBasic defines the basic application module used by the gov module.
|
||||
type AppModuleBasic struct {
|
||||
cdc Codec
|
||||
cdc codec.Marshaler
|
||||
proposalHandlers []client.ProposalHandler // proposal handlers which live in governance cli and rest
|
||||
}
|
||||
|
||||
@ -95,6 +97,11 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command {
|
||||
return cli.GetQueryCmd(StoreKey, cdc)
|
||||
}
|
||||
|
||||
// RegisterInterfaceTypes implements InterfaceModule.RegisterInterfaceTypes
|
||||
func (a AppModuleBasic) RegisterInterfaceTypes(registry codectypes.InterfaceRegistry) {
|
||||
types.RegisterInterfaces(registry)
|
||||
}
|
||||
|
||||
//____________________________________________________________________________
|
||||
|
||||
// AppModule implements an application module for the gov module.
|
||||
@ -107,7 +114,7 @@ type AppModule struct {
|
||||
}
|
||||
|
||||
// NewAppModule creates a new AppModule object
|
||||
func NewAppModule(cdc Codec, keeper Keeper, ak types.AccountKeeper, bk types.BankKeeper) AppModule {
|
||||
func NewAppModule(cdc codec.Marshaler, keeper Keeper, ak types.AccountKeeper, bk types.BankKeeper) AppModule {
|
||||
return AppModule{
|
||||
AppModuleBasic: AppModuleBasic{cdc: cdc},
|
||||
keeper: keeper,
|
||||
|
||||
@ -7,20 +7,23 @@ import (
|
||||
|
||||
tmkv "github.com/tendermint/tendermint/libs/kv"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
)
|
||||
|
||||
// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's
|
||||
// Value to the corresponding gov type.
|
||||
func NewDecodeStore(cdc types.Codec) func(kvA, kvB tmkv.Pair) string {
|
||||
func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB tmkv.Pair) string {
|
||||
return func(kvA, kvB tmkv.Pair) string {
|
||||
switch {
|
||||
case bytes.Equal(kvA.Key[:1], types.ProposalsKeyPrefix):
|
||||
proposalA, err := cdc.UnmarshalProposal(kvA.Value)
|
||||
var proposalA types.Proposal
|
||||
err := cdc.UnmarshalBinaryBare(kvA.Value, &proposalA)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
proposalB, err := cdc.UnmarshalProposal(kvB.Value)
|
||||
var proposalB types.Proposal
|
||||
err = cdc.UnmarshalBinaryBare(kvA.Value, &proposalB)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -29,13 +29,15 @@ func TestDecodeStore(t *testing.T) {
|
||||
endTime := time.Now().UTC()
|
||||
|
||||
content := types.ContentFromProposalType("test", "test", types.ProposalTypeText)
|
||||
proposal := types.NewProposal(content, 1, endTime, endTime.Add(24*time.Hour))
|
||||
proposal, err := types.NewProposal(content, 1, 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.OptionYes)
|
||||
|
||||
proposalBz, err := cdc.MarshalProposal(proposal)
|
||||
proposalBz, err := cdc.MarshalBinaryBare(&proposal)
|
||||
require.NoError(t, err)
|
||||
|
||||
kvPairs := tmkv.Pairs{
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
std "github.com/cosmos/cosmos-sdk/std"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
|
||||
@ -126,7 +125,7 @@ func SimulateSubmitProposal(
|
||||
return simtypes.NoOpMsg(types.ModuleName), nil, err
|
||||
}
|
||||
|
||||
msg, err := std.NewMsgSubmitProposal(content, deposit, simAccount.Address)
|
||||
msg, err := types.NewMsgSubmitProposal(content, deposit, simAccount.Address)
|
||||
if err != nil {
|
||||
return simtypes.NoOpMsg(types.ModuleName), nil, err
|
||||
}
|
||||
|
||||
@ -3,27 +3,32 @@ package types
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// Codec defines the interface required to serialize custom x/gov types.
|
||||
type Codec interface {
|
||||
codec.Marshaler
|
||||
|
||||
MarshalProposal(Proposal) ([]byte, error)
|
||||
UnmarshalProposal([]byte) (Proposal, error)
|
||||
}
|
||||
|
||||
// RegisterCodec registers all the necessary types and interfaces for the
|
||||
// governance module.
|
||||
func RegisterCodec(cdc *codec.Codec) {
|
||||
cdc.RegisterInterface((*Content)(nil), nil)
|
||||
cdc.RegisterConcrete(MsgSubmitProposalBase{}, "cosmos-sdk/MsgSubmitProposalBase", nil)
|
||||
cdc.RegisterConcrete(&MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal", nil)
|
||||
cdc.RegisterConcrete(MsgDeposit{}, "cosmos-sdk/MsgDeposit", nil)
|
||||
cdc.RegisterConcrete(MsgVote{}, "cosmos-sdk/MsgVote", nil)
|
||||
cdc.RegisterConcrete(&TextProposal{}, "cosmos-sdk/TextProposal", nil)
|
||||
}
|
||||
|
||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgSubmitProposal{},
|
||||
&MsgVote{},
|
||||
&MsgDeposit{},
|
||||
)
|
||||
registry.RegisterInterface(
|
||||
"cosmos_sdk.gov.v1.Content",
|
||||
(*Content)(nil),
|
||||
&TextProposal{},
|
||||
)
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
||||
@ -3,6 +3,7 @@ package types
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@ -73,3 +74,16 @@ func ValidateGenesis(data GenesisState) error {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"gopkg.in/yaml.v2"
|
||||
"fmt"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
|
||||
"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"
|
||||
)
|
||||
@ -14,7 +19,11 @@ const (
|
||||
TypeMsgSubmitProposal = "submit_proposal"
|
||||
)
|
||||
|
||||
var _, _, _ sdk.Msg = MsgSubmitProposalBase{}, MsgDeposit{}, MsgVote{}
|
||||
var (
|
||||
_, _, _ sdk.Msg = MsgSubmitProposal{}, MsgDeposit{}, MsgVote{}
|
||||
_ MsgSubmitProposalI = &MsgSubmitProposal{}
|
||||
_ types.UnpackInterfacesMessage = MsgSubmitProposal{}
|
||||
)
|
||||
|
||||
// MsgSubmitProposalI defines the specific interface a concrete message must
|
||||
// implement in order to process governance proposals. The concrete MsgSubmitProposal
|
||||
@ -32,64 +41,107 @@ type MsgSubmitProposalI interface {
|
||||
SetProposer(sdk.AccAddress)
|
||||
}
|
||||
|
||||
// NewMsgSubmitProposalBase creates a new MsgSubmitProposalBase.
|
||||
func NewMsgSubmitProposalBase(initialDeposit sdk.Coins, proposer sdk.AccAddress) MsgSubmitProposalBase {
|
||||
return MsgSubmitProposalBase{
|
||||
// NewMsgSubmitProposal creates a new MsgSubmitProposal.
|
||||
func NewMsgSubmitProposal(content Content, initialDeposit sdk.Coins, proposer sdk.AccAddress) (*MsgSubmitProposal, error) {
|
||||
m := &MsgSubmitProposal{
|
||||
InitialDeposit: initialDeposit,
|
||||
Proposer: proposer,
|
||||
}
|
||||
err := m.SetContent(content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (msg *MsgSubmitProposalBase) GetInitialDeposit() sdk.Coins { return msg.InitialDeposit }
|
||||
func (m *MsgSubmitProposal) GetInitialDeposit() sdk.Coins { return m.InitialDeposit }
|
||||
|
||||
func (msg *MsgSubmitProposalBase) GetProposer() sdk.AccAddress { return msg.Proposer }
|
||||
func (m *MsgSubmitProposal) GetProposer() sdk.AccAddress { return m.Proposer }
|
||||
|
||||
func (msg *MsgSubmitProposalBase) SetInitialDeposit(coins sdk.Coins) {
|
||||
msg.InitialDeposit = coins
|
||||
func (m *MsgSubmitProposal) GetContent() Content {
|
||||
content, ok := m.Content.GetCachedValue().(Content)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
||||
func (msg *MsgSubmitProposalBase) SetProposer(address sdk.AccAddress) {
|
||||
msg.Proposer = address
|
||||
func (m *MsgSubmitProposal) SetInitialDeposit(coins sdk.Coins) {
|
||||
m.InitialDeposit = coins
|
||||
}
|
||||
|
||||
func (m *MsgSubmitProposal) SetProposer(address sdk.AccAddress) {
|
||||
m.Proposer = address
|
||||
}
|
||||
|
||||
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 (msg MsgSubmitProposalBase) Route() string { return RouterKey }
|
||||
func (m MsgSubmitProposal) Route() string { return RouterKey }
|
||||
|
||||
// Type implements Msg
|
||||
func (msg MsgSubmitProposalBase) Type() string { return TypeMsgSubmitProposal }
|
||||
func (m MsgSubmitProposal) Type() string { return TypeMsgSubmitProposal }
|
||||
|
||||
// ValidateBasic implements Msg
|
||||
func (msg MsgSubmitProposalBase) ValidateBasic() error {
|
||||
if msg.Proposer.Empty() {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Proposer.String())
|
||||
func (m MsgSubmitProposal) ValidateBasic() error {
|
||||
if m.Proposer.Empty() {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, m.Proposer.String())
|
||||
}
|
||||
if !msg.InitialDeposit.IsValid() {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.InitialDeposit.String())
|
||||
if !m.InitialDeposit.IsValid() {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.InitialDeposit.String())
|
||||
}
|
||||
if msg.InitialDeposit.IsAnyNegative() {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.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 (msg MsgSubmitProposalBase) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||
func (m MsgSubmitProposal) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(m)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// GetSigners implements Msg
|
||||
func (msg MsgSubmitProposalBase) GetSigners() []sdk.AccAddress {
|
||||
return []sdk.AccAddress{msg.Proposer}
|
||||
func (m MsgSubmitProposal) GetSigners() []sdk.AccAddress {
|
||||
return []sdk.AccAddress{m.Proposer}
|
||||
}
|
||||
|
||||
// String implements the Stringer interface
|
||||
func (msg MsgSubmitProposalBase) String() string {
|
||||
out, _ := yaml.Marshal(msg)
|
||||
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
|
||||
func NewMsgDeposit(depositor sdk.AccAddress, proposalID uint64, amount sdk.Coins) MsgDeposit {
|
||||
return MsgDeposit{proposalID, depositor, amount}
|
||||
@ -172,75 +224,3 @@ func (msg MsgVote) GetSignBytes() []byte {
|
||||
func (msg MsgVote) GetSigners() []sdk.AccAddress {
|
||||
return []sdk.AccAddress{msg.Voter}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Deprecated
|
||||
//
|
||||
// TODO: Remove once client-side Protobuf migration has been completed.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// MsgSubmitProposal defines a (deprecated) message to create/submit a governance
|
||||
// proposal.
|
||||
//
|
||||
// TODO: Remove once client-side Protobuf migration has been completed.
|
||||
type MsgSubmitProposal struct {
|
||||
Content Content `json:"content" yaml:"content"`
|
||||
InitialDeposit sdk.Coins `json:"initial_deposit" yaml:"initial_deposit"` // Initial deposit paid by sender. Must be strictly positive
|
||||
Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` // Address of the proposer
|
||||
}
|
||||
|
||||
var _ MsgSubmitProposalI = &MsgSubmitProposal{}
|
||||
|
||||
// NewMsgSubmitProposal returns a (deprecated) MsgSubmitProposal message.
|
||||
//
|
||||
// TODO: Remove once client-side Protobuf migration has been completed.
|
||||
func NewMsgSubmitProposal(content Content, initialDeposit sdk.Coins, proposer sdk.AccAddress) *MsgSubmitProposal {
|
||||
return &MsgSubmitProposal{content, initialDeposit, proposer}
|
||||
}
|
||||
|
||||
// ValidateBasic implements Msg
|
||||
func (msg MsgSubmitProposal) ValidateBasic() error {
|
||||
if msg.Content == nil {
|
||||
return sdkerrors.Wrap(ErrInvalidProposalContent, "missing content")
|
||||
}
|
||||
if msg.Proposer.Empty() {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Proposer.String())
|
||||
}
|
||||
if !msg.InitialDeposit.IsValid() {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.InitialDeposit.String())
|
||||
}
|
||||
if msg.InitialDeposit.IsAnyNegative() {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.InitialDeposit.String())
|
||||
}
|
||||
if !IsValidProposalType(msg.Content.ProposalType()) {
|
||||
return sdkerrors.Wrap(ErrInvalidProposalType, msg.Content.ProposalType())
|
||||
}
|
||||
|
||||
return msg.Content.ValidateBasic()
|
||||
}
|
||||
|
||||
// GetSignBytes implements Msg
|
||||
func (msg MsgSubmitProposal) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
func (msg MsgSubmitProposal) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Proposer} }
|
||||
func (msg MsgSubmitProposal) Route() string { return RouterKey }
|
||||
func (msg MsgSubmitProposal) Type() string { return TypeMsgSubmitProposal }
|
||||
func (msg MsgSubmitProposal) GetContent() Content { return msg.Content }
|
||||
func (msg MsgSubmitProposal) GetInitialDeposit() sdk.Coins { return msg.InitialDeposit }
|
||||
func (msg MsgSubmitProposal) GetProposer() sdk.AccAddress { return msg.Proposer }
|
||||
|
||||
func (msg *MsgSubmitProposal) SetContent(content Content) error {
|
||||
msg.Content = content
|
||||
return nil
|
||||
}
|
||||
|
||||
func (msg *MsgSubmitProposal) SetInitialDeposit(deposit sdk.Coins) {
|
||||
msg.InitialDeposit = deposit
|
||||
}
|
||||
|
||||
func (msg *MsgSubmitProposal) SetProposer(proposer sdk.AccAddress) {
|
||||
msg.Proposer = proposer
|
||||
}
|
||||
|
||||
@ -43,12 +43,14 @@ func TestMsgSubmitProposal(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, tc := range tests {
|
||||
msg := NewMsgSubmitProposal(
|
||||
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 {
|
||||
@ -115,3 +117,16 @@ func TestMsgVote(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{})
|
||||
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))
|
||||
}
|
||||
|
||||
@ -6,8 +6,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
@ -15,31 +17,30 @@ import (
|
||||
// DefaultStartingProposalID is 1
|
||||
const DefaultStartingProposalID uint64 = 1
|
||||
|
||||
// Proposal defines a struct used by the governance module to allow for voting
|
||||
// on network changes.
|
||||
type Proposal struct {
|
||||
Content `json:"content" yaml:"content"` // Proposal content interface
|
||||
ProposalBase
|
||||
}
|
||||
|
||||
// NewProposal creates a new Proposal instance
|
||||
func NewProposal(content Content, id uint64, submitTime, depositEndTime time.Time) Proposal {
|
||||
return Proposal{
|
||||
Content: content,
|
||||
ProposalBase: ProposalBase{
|
||||
ProposalID: id,
|
||||
Status: StatusDepositPeriod,
|
||||
FinalTallyResult: EmptyTallyResult(),
|
||||
TotalDeposit: sdk.NewCoins(),
|
||||
SubmitTime: submitTime,
|
||||
DepositEndTime: depositEndTime,
|
||||
},
|
||||
func NewProposal(content Content, id uint64, submitTime, depositEndTime time.Time) (Proposal, error) {
|
||||
p := Proposal{
|
||||
ProposalID: id,
|
||||
Status: StatusDepositPeriod,
|
||||
FinalTallyResult: EmptyTallyResult(),
|
||||
TotalDeposit: sdk.NewCoins(),
|
||||
SubmitTime: submitTime,
|
||||
DepositEndTime: depositEndTime,
|
||||
}
|
||||
}
|
||||
|
||||
// Equal returns true if two Proposal types are equal.
|
||||
func (p Proposal) Equal(other Proposal) bool {
|
||||
return p.ProposalBase.Equal(other.ProposalBase) && p.Content.String() == other.Content.String()
|
||||
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.Content = any
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// String implements stringer interface
|
||||
@ -48,9 +49,50 @@ 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()
|
||||
}
|
||||
|
||||
// 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) {
|
||||
@ -77,6 +119,17 @@ func (p Proposals) String() string {
|
||||
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
|
||||
}
|
||||
|
||||
type (
|
||||
// ProposalQueue defines a queue for proposal ids
|
||||
ProposalQueue []uint64
|
||||
|
||||
@ -6,13 +6,14 @@ package types
|
||||
import (
|
||||
bytes "bytes"
|
||||
fmt "fmt"
|
||||
types "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
||||
types "github.com/cosmos/cosmos-sdk/types"
|
||||
types1 "github.com/cosmos/cosmos-sdk/types"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
|
||||
_ "github.com/golang/protobuf/ptypes/timestamp"
|
||||
_ "github.com/regen-network/cosmos-proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
@ -107,29 +108,25 @@ func (ProposalStatus) EnumDescriptor() ([]byte, []int) {
|
||||
return fileDescriptor_a5ae5e91b5b3fb03, []int{1}
|
||||
}
|
||||
|
||||
// MsgSubmitProposalBase defines an sdk.Msg type that supports submitting arbitrary
|
||||
// MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary
|
||||
// proposal Content.
|
||||
//
|
||||
// Note, this message type provides the basis for which a true MsgSubmitProposal
|
||||
// can be constructed. Since the Content submitted in the message can be arbitrary,
|
||||
// assuming it fulfills the Content interface, it must be defined at the
|
||||
// application-level and extend MsgSubmitProposalBase.
|
||||
type MsgSubmitProposalBase struct {
|
||||
InitialDeposit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=initial_deposit,json=initialDeposit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"initial_deposit" yaml:"initial_deposit"`
|
||||
Proposer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=proposer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"proposer,omitempty"`
|
||||
type MsgSubmitProposal struct {
|
||||
Content *types.Any `protobuf:"bytes,1,opt,name=content,proto3" json:"content,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" yaml:"initial_deposit"`
|
||||
Proposer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,3,opt,name=proposer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"proposer,omitempty"`
|
||||
}
|
||||
|
||||
func (m *MsgSubmitProposalBase) Reset() { *m = MsgSubmitProposalBase{} }
|
||||
func (*MsgSubmitProposalBase) ProtoMessage() {}
|
||||
func (*MsgSubmitProposalBase) Descriptor() ([]byte, []int) {
|
||||
func (m *MsgSubmitProposal) Reset() { *m = MsgSubmitProposal{} }
|
||||
func (*MsgSubmitProposal) ProtoMessage() {}
|
||||
func (*MsgSubmitProposal) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_a5ae5e91b5b3fb03, []int{0}
|
||||
}
|
||||
func (m *MsgSubmitProposalBase) XXX_Unmarshal(b []byte) error {
|
||||
func (m *MsgSubmitProposal) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgSubmitProposalBase) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *MsgSubmitProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgSubmitProposalBase.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_MsgSubmitProposal.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
@ -139,17 +136,17 @@ func (m *MsgSubmitProposalBase) XXX_Marshal(b []byte, deterministic bool) ([]byt
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *MsgSubmitProposalBase) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgSubmitProposalBase.Merge(m, src)
|
||||
func (m *MsgSubmitProposal) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgSubmitProposal.Merge(m, src)
|
||||
}
|
||||
func (m *MsgSubmitProposalBase) XXX_Size() int {
|
||||
func (m *MsgSubmitProposal) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgSubmitProposalBase) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgSubmitProposalBase.DiscardUnknown(m)
|
||||
func (m *MsgSubmitProposal) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgSubmitProposal.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgSubmitProposalBase proto.InternalMessageInfo
|
||||
var xxx_messageInfo_MsgSubmitProposal proto.InternalMessageInfo
|
||||
|
||||
// MsgVote defines a message to cast a vote
|
||||
type MsgVote struct {
|
||||
@ -307,32 +304,30 @@ func (m *Deposit) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_Deposit proto.InternalMessageInfo
|
||||
|
||||
// ProposalBase defines the core field members of a governance proposal. It includes
|
||||
// all static fields (i.e fields excluding the dynamic Content). A full proposal
|
||||
// extends the ProposalBase with Content.
|
||||
type ProposalBase struct {
|
||||
// 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" yaml:"id"`
|
||||
Status ProposalStatus `protobuf:"varint,2,opt,name=status,proto3,enum=cosmos_sdk.x.gov.v1.ProposalStatus" json:"status,omitempty" yaml:"proposal_status"`
|
||||
FinalTallyResult TallyResult `protobuf:"bytes,3,opt,name=final_tally_result,json=finalTallyResult,proto3" json:"final_tally_result" yaml:"final_tally_result"`
|
||||
SubmitTime time.Time `protobuf:"bytes,4,opt,name=submit_time,json=submitTime,proto3,stdtime" json:"submit_time" yaml:"submit_time"`
|
||||
DepositEndTime time.Time `protobuf:"bytes,5,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,6,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,7,opt,name=voting_start_time,json=votingStartTime,proto3,stdtime" json:"voting_start_time" yaml:"voting_start_time"`
|
||||
VotingEndTime time.Time `protobuf:"bytes,8,opt,name=voting_end_time,json=votingEndTime,proto3,stdtime" json:"voting_end_time" yaml:"voting_end_time"`
|
||||
Content *types.Any `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
|
||||
Status ProposalStatus `protobuf:"varint,3,opt,name=status,proto3,enum=cosmos_sdk.x.gov.v1.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 *ProposalBase) Reset() { *m = ProposalBase{} }
|
||||
func (m *ProposalBase) String() string { return proto.CompactTextString(m) }
|
||||
func (*ProposalBase) ProtoMessage() {}
|
||||
func (*ProposalBase) Descriptor() ([]byte, []int) {
|
||||
func (m *Proposal) Reset() { *m = Proposal{} }
|
||||
func (*Proposal) ProtoMessage() {}
|
||||
func (*Proposal) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_a5ae5e91b5b3fb03, []int{5}
|
||||
}
|
||||
func (m *ProposalBase) XXX_Unmarshal(b []byte) error {
|
||||
func (m *Proposal) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *ProposalBase) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *Proposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_ProposalBase.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_Proposal.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
@ -342,17 +337,17 @@ func (m *ProposalBase) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *ProposalBase) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_ProposalBase.Merge(m, src)
|
||||
func (m *Proposal) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Proposal.Merge(m, src)
|
||||
}
|
||||
func (m *ProposalBase) XXX_Size() int {
|
||||
func (m *Proposal) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *ProposalBase) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_ProposalBase.DiscardUnknown(m)
|
||||
func (m *Proposal) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Proposal.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_ProposalBase proto.InternalMessageInfo
|
||||
var xxx_messageInfo_Proposal proto.InternalMessageInfo
|
||||
|
||||
// TallyResult defines a standard tally for a proposal
|
||||
type TallyResult struct {
|
||||
@ -437,12 +432,12 @@ var xxx_messageInfo_Vote proto.InternalMessageInfo
|
||||
func init() {
|
||||
proto.RegisterEnum("cosmos_sdk.x.gov.v1.VoteOption", VoteOption_name, VoteOption_value)
|
||||
proto.RegisterEnum("cosmos_sdk.x.gov.v1.ProposalStatus", ProposalStatus_name, ProposalStatus_value)
|
||||
proto.RegisterType((*MsgSubmitProposalBase)(nil), "cosmos_sdk.x.gov.v1.MsgSubmitProposalBase")
|
||||
proto.RegisterType((*MsgSubmitProposal)(nil), "cosmos_sdk.x.gov.v1.MsgSubmitProposal")
|
||||
proto.RegisterType((*MsgVote)(nil), "cosmos_sdk.x.gov.v1.MsgVote")
|
||||
proto.RegisterType((*MsgDeposit)(nil), "cosmos_sdk.x.gov.v1.MsgDeposit")
|
||||
proto.RegisterType((*TextProposal)(nil), "cosmos_sdk.x.gov.v1.TextProposal")
|
||||
proto.RegisterType((*Deposit)(nil), "cosmos_sdk.x.gov.v1.Deposit")
|
||||
proto.RegisterType((*ProposalBase)(nil), "cosmos_sdk.x.gov.v1.ProposalBase")
|
||||
proto.RegisterType((*Proposal)(nil), "cosmos_sdk.x.gov.v1.Proposal")
|
||||
proto.RegisterType((*TallyResult)(nil), "cosmos_sdk.x.gov.v1.TallyResult")
|
||||
proto.RegisterType((*Vote)(nil), "cosmos_sdk.x.gov.v1.Vote")
|
||||
}
|
||||
@ -450,94 +445,97 @@ func init() {
|
||||
func init() { proto.RegisterFile("x/gov/types/types.proto", fileDescriptor_a5ae5e91b5b3fb03) }
|
||||
|
||||
var fileDescriptor_a5ae5e91b5b3fb03 = []byte{
|
||||
// 1230 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x57, 0xcf, 0x8f, 0xd3, 0x46,
|
||||
0x14, 0x8e, 0xb3, 0xbf, 0xd8, 0x49, 0x36, 0x6b, 0x66, 0x29, 0x9b, 0xba, 0xaa, 0x6d, 0x02, 0x42,
|
||||
0x2b, 0x04, 0x5e, 0x58, 0x0e, 0x55, 0xa9, 0x54, 0x35, 0x26, 0x06, 0x8c, 0xd8, 0x38, 0xb2, 0xcd,
|
||||
0x22, 0x5a, 0x55, 0x96, 0x77, 0x6d, 0xbc, 0x2e, 0x8e, 0x27, 0xcd, 0xcc, 0xa6, 0xec, 0xad, 0xea,
|
||||
0xa1, 0x42, 0x39, 0x71, 0xe4, 0x12, 0x09, 0xa9, 0x1c, 0x50, 0x4f, 0xfd, 0x33, 0xf6, 0x56, 0x0e,
|
||||
0xad, 0x84, 0x7a, 0x08, 0x65, 0x39, 0xb4, 0xea, 0xa1, 0x07, 0x2e, 0x95, 0x7a, 0xaa, 0xe2, 0x19,
|
||||
0xb3, 0x4e, 0x76, 0xe9, 0xb2, 0xa2, 0x95, 0xaa, 0x5e, 0x92, 0xf8, 0xf9, 0xfb, 0xbe, 0x37, 0xef,
|
||||
0xcd, 0x9b, 0x6f, 0x14, 0x30, 0x7f, 0x67, 0x31, 0x40, 0x9d, 0x45, 0xb2, 0xd9, 0xf2, 0x31, 0xfd,
|
||||
0x54, 0x5a, 0x6d, 0x44, 0x10, 0x9c, 0x5b, 0x43, 0xb8, 0x89, 0xb0, 0x83, 0xbd, 0xdb, 0xca, 0x1d,
|
||||
0x25, 0x40, 0x1d, 0xa5, 0x73, 0x4e, 0x38, 0xbc, 0x0b, 0x27, 0x9c, 0x24, 0xeb, 0x61, 0xdb, 0x73,
|
||||
0x5a, 0x6e, 0x9b, 0x6c, 0x2e, 0x26, 0xa1, 0xc5, 0x00, 0x05, 0x68, 0xe7, 0x17, 0xc3, 0x49, 0x01,
|
||||
0x42, 0x41, 0xe4, 0x53, 0xc8, 0xea, 0xc6, 0xad, 0x45, 0x12, 0x36, 0x7d, 0x4c, 0xdc, 0x66, 0x8b,
|
||||
0x02, 0x2a, 0x7f, 0x70, 0xe0, 0xad, 0x65, 0x1c, 0x58, 0x1b, 0xab, 0xcd, 0x90, 0x34, 0xda, 0xa8,
|
||||
0x85, 0xb0, 0x1b, 0xa9, 0x2e, 0xf6, 0xe1, 0x5d, 0x0e, 0xcc, 0x86, 0x71, 0x48, 0x42, 0x37, 0x72,
|
||||
0x3c, 0xbf, 0x85, 0x70, 0x48, 0xca, 0x9c, 0x3c, 0xb6, 0x50, 0x58, 0x9a, 0x53, 0x32, 0xab, 0xec,
|
||||
0x9c, 0x53, 0x2e, 0xa2, 0x30, 0x56, 0xaf, 0x6e, 0xf5, 0xa5, 0xdc, 0x8b, 0xbe, 0x74, 0x74, 0xd3,
|
||||
0x6d, 0x46, 0x17, 0x2a, 0x23, 0xcc, 0xca, 0xb7, 0x4f, 0xa5, 0x85, 0x20, 0x24, 0xeb, 0x1b, 0xab,
|
||||
0xca, 0x1a, 0x6a, 0x2e, 0x52, 0x01, 0xf6, 0x75, 0x06, 0x7b, 0xb7, 0x59, 0x75, 0x03, 0x29, 0x6c,
|
||||
0x96, 0x18, 0xbb, 0x46, 0xc9, 0x70, 0x19, 0x1c, 0x6a, 0x25, 0x4b, 0xf3, 0xdb, 0xe5, 0xbc, 0xcc,
|
||||
0x2d, 0x14, 0xd5, 0x73, 0x7f, 0xf6, 0xa5, 0x33, 0xaf, 0xa1, 0x57, 0x5d, 0x5b, 0xab, 0x7a, 0x5e,
|
||||
0xdb, 0xc7, 0xd8, 0x7c, 0x29, 0x71, 0x61, 0xfc, 0xd7, 0x07, 0x12, 0x57, 0xf9, 0x85, 0x03, 0x53,
|
||||
0xcb, 0x38, 0x58, 0x41, 0xc4, 0x87, 0x36, 0x28, 0xb4, 0x58, 0xed, 0x4e, 0xe8, 0x95, 0x39, 0x99,
|
||||
0x5b, 0x18, 0x57, 0xcf, 0x6f, 0xf7, 0x25, 0x90, 0xb6, 0x44, 0xaf, 0xfd, 0xd6, 0x97, 0xb2, 0xa0,
|
||||
0x17, 0x7d, 0x09, 0xd2, 0x52, 0x33, 0xc1, 0x8a, 0x09, 0xd2, 0x27, 0xdd, 0x83, 0x97, 0xc1, 0x44,
|
||||
0x07, 0x91, 0x37, 0x59, 0x33, 0xe5, 0xc3, 0xf7, 0xc0, 0x24, 0x6a, 0x91, 0x10, 0xc5, 0xe5, 0x31,
|
||||
0x99, 0x5b, 0x28, 0x2d, 0x49, 0xca, 0x1e, 0x63, 0xa2, 0x0c, 0x2a, 0x31, 0x12, 0x98, 0xc9, 0xe0,
|
||||
0xac, 0xd2, 0xfb, 0x79, 0x00, 0x96, 0x71, 0x90, 0x76, 0xf3, 0xdf, 0x29, 0xd6, 0x00, 0xd3, 0x6c,
|
||||
0xaf, 0xd1, 0x1b, 0x14, 0xbc, 0xa3, 0x01, 0x3f, 0x05, 0x93, 0x6e, 0x13, 0x6d, 0xc4, 0xa4, 0x3c,
|
||||
0xf6, 0xea, 0xa9, 0x3b, 0x3b, 0x98, 0xba, 0x03, 0xcd, 0x16, 0x13, 0x65, 0xad, 0xb9, 0x06, 0x8a,
|
||||
0xb6, 0x7f, 0xe7, 0xe5, 0xe0, 0xc3, 0x23, 0x60, 0x82, 0x84, 0x24, 0xf2, 0x93, 0xae, 0x4c, 0x9b,
|
||||
0xf4, 0x01, 0xca, 0xa0, 0xe0, 0xf9, 0x78, 0xad, 0x1d, 0xd2, 0x4d, 0xc8, 0x27, 0xef, 0xb2, 0x21,
|
||||
0xa6, 0xf6, 0x75, 0x1e, 0x4c, 0xa5, 0x5d, 0xd6, 0xf6, 0xea, 0xf2, 0x89, 0xe1, 0x2e, 0xff, 0x6f,
|
||||
0xdb, 0xfa, 0xfd, 0x24, 0x28, 0x0e, 0x99, 0x89, 0xba, 0x57, 0x37, 0x8e, 0xed, 0x9a, 0xb9, 0x7c,
|
||||
0x32, 0x6a, 0xd3, 0xcc, 0x42, 0x46, 0x5a, 0x71, 0x03, 0x4c, 0x62, 0xe2, 0x92, 0x0d, 0x9c, 0xf4,
|
||||
0xa1, 0xb4, 0x74, 0x7c, 0xcf, 0x53, 0x90, 0xea, 0x59, 0x09, 0x54, 0x15, 0x76, 0x2c, 0xe9, 0xe5,
|
||||
0x02, 0xa8, 0x4a, 0xc5, 0x64, 0x72, 0xf0, 0x73, 0x00, 0x6f, 0x85, 0xb1, 0x1b, 0x39, 0xc4, 0x8d,
|
||||
0xa2, 0x4d, 0xa7, 0xed, 0xe3, 0x8d, 0x88, 0x24, 0x47, 0xad, 0xb0, 0x24, 0xef, 0x99, 0xc4, 0x1e,
|
||||
0x00, 0xcd, 0x04, 0xa7, 0x1e, 0x63, 0xc6, 0xf7, 0x36, 0xcd, 0xb2, 0x5b, 0xa9, 0x62, 0xf2, 0x49,
|
||||
0x30, 0x43, 0x82, 0x9f, 0x80, 0x02, 0x4e, 0x2c, 0xd7, 0x19, 0x18, 0x72, 0x79, 0x3c, 0xc9, 0x25,
|
||||
0x28, 0xd4, 0xad, 0x95, 0xd4, 0xad, 0x15, 0x3b, 0x75, 0x6b, 0x55, 0x64, 0x59, 0xd8, 0xbc, 0x64,
|
||||
0xc8, 0x95, 0x7b, 0x4f, 0x25, 0xce, 0x04, 0x34, 0x32, 0x20, 0xc0, 0x10, 0xf0, 0x6c, 0xbf, 0x1d,
|
||||
0x3f, 0xf6, 0x68, 0x86, 0x89, 0x7d, 0x33, 0x1c, 0x67, 0x19, 0xe6, 0x69, 0x86, 0x51, 0x05, 0x9a,
|
||||
0xa6, 0xc4, 0xc2, 0x5a, 0xec, 0x25, 0xa9, 0xbe, 0xe2, 0xc0, 0x0c, 0x41, 0x24, 0x73, 0x45, 0x4c,
|
||||
0xbe, 0x7a, 0xaa, 0xae, 0xb0, 0x0c, 0x47, 0x68, 0x86, 0x21, 0xde, 0xc1, 0x2e, 0x88, 0x62, 0xc2,
|
||||
0x4d, 0x8f, 0x5a, 0x04, 0x0e, 0x77, 0x10, 0x09, 0xe3, 0x60, 0xb0, 0xb3, 0x6d, 0xd6, 0xd2, 0xa9,
|
||||
0x7d, 0x0b, 0x3e, 0xc1, 0x96, 0x53, 0xa6, 0xcb, 0xd9, 0x25, 0x41, 0x2b, 0x9e, 0xa5, 0x71, 0x6b,
|
||||
0x10, 0x4e, 0x4a, 0xbe, 0x05, 0x58, 0x68, 0xa7, 0xb9, 0x87, 0xf6, 0xcd, 0x55, 0x19, 0xbe, 0x1d,
|
||||
0x47, 0x04, 0x68, 0xa6, 0x19, 0x1a, 0x65, 0xad, 0xbd, 0x50, 0xbc, 0xff, 0x40, 0xe2, 0x1e, 0x3d,
|
||||
0x90, 0xb8, 0xe4, 0x44, 0x6d, 0xe5, 0x41, 0x21, 0x3b, 0x40, 0x1f, 0x81, 0xb1, 0x4d, 0x1f, 0x53,
|
||||
0x9b, 0x52, 0x95, 0x81, 0xfa, 0x4f, 0x7d, 0xe9, 0xe4, 0x6b, 0x34, 0x50, 0x8f, 0x89, 0x39, 0xa0,
|
||||
0xc2, 0x2b, 0x60, 0xca, 0x5d, 0xc5, 0xc4, 0x0d, 0x99, 0xa1, 0x1d, 0x58, 0x25, 0xa5, 0xc3, 0x0f,
|
||||
0x41, 0x3e, 0x46, 0xc9, 0x79, 0x39, 0xb8, 0x48, 0x3e, 0x46, 0x30, 0x00, 0xc5, 0x18, 0x39, 0x5f,
|
||||
0x84, 0x64, 0xdd, 0xe9, 0xf8, 0x04, 0x25, 0xa7, 0x61, 0x5a, 0xd5, 0x0e, 0xa6, 0xf4, 0xa2, 0x2f,
|
||||
0xcd, 0xd1, 0xe6, 0x66, 0xb5, 0x2a, 0x26, 0x88, 0xd1, 0x8d, 0x90, 0xac, 0xaf, 0xf8, 0x04, 0x31,
|
||||
0x73, 0xfa, 0x91, 0x03, 0xe3, 0xc9, 0xad, 0xff, 0x0f, 0x59, 0xf4, 0x7f, 0xe4, 0x9a, 0x3f, 0xf5,
|
||||
0x3b, 0x07, 0xc0, 0xce, 0x4b, 0x78, 0x1a, 0xcc, 0xaf, 0x18, 0xb6, 0xe6, 0x18, 0x0d, 0x5b, 0x37,
|
||||
0xea, 0xce, 0xf5, 0xba, 0xd5, 0xd0, 0x2e, 0xea, 0x97, 0x74, 0xad, 0xc6, 0xe7, 0x84, 0xd9, 0x6e,
|
||||
0x4f, 0x2e, 0x50, 0xa0, 0xd6, 0x6c, 0x91, 0x4d, 0x58, 0x01, 0xb3, 0x59, 0xf4, 0x4d, 0xcd, 0xe2,
|
||||
0x39, 0x61, 0xa6, 0xdb, 0x93, 0xa7, 0x29, 0xea, 0xa6, 0x8f, 0xe1, 0x29, 0x30, 0x97, 0xc5, 0x54,
|
||||
0x55, 0xcb, 0xae, 0xea, 0x75, 0x3e, 0x2f, 0x1c, 0xee, 0xf6, 0xe4, 0x19, 0x8a, 0xab, 0xb2, 0x99,
|
||||
0x90, 0x41, 0x29, 0x8b, 0xad, 0x1b, 0xfc, 0x98, 0x50, 0xec, 0xf6, 0xe4, 0x43, 0x14, 0x56, 0x47,
|
||||
0x70, 0x09, 0x94, 0x87, 0x11, 0xce, 0x0d, 0xdd, 0xbe, 0xe2, 0xac, 0x68, 0xb6, 0xc1, 0x8f, 0x0b,
|
||||
0x47, 0xba, 0x3d, 0x99, 0x4f, 0xb1, 0xe9, 0x06, 0x0a, 0xc5, 0xbb, 0xdf, 0x88, 0xb9, 0x47, 0x0f,
|
||||
0xc5, 0xdc, 0x77, 0x0f, 0xc5, 0xdc, 0xa9, 0x1f, 0xf2, 0xa0, 0x34, 0x6c, 0xf7, 0x50, 0x01, 0xef,
|
||||
0x34, 0x4c, 0xa3, 0x61, 0x58, 0xd5, 0x6b, 0x8e, 0x65, 0x57, 0xed, 0xeb, 0xd6, 0x48, 0xe1, 0x49,
|
||||
0x49, 0x14, 0x5c, 0x0f, 0x23, 0xf8, 0x01, 0x10, 0x47, 0xf1, 0x35, 0xad, 0x61, 0x58, 0xba, 0xed,
|
||||
0x34, 0x34, 0x53, 0x37, 0x6a, 0x3c, 0x27, 0xcc, 0x77, 0x7b, 0xf2, 0x1c, 0xa5, 0x30, 0xc7, 0x69,
|
||||
0xf8, 0xed, 0x10, 0x79, 0xf0, 0x7d, 0xf0, 0xee, 0x28, 0x79, 0xc5, 0xb0, 0xf5, 0xfa, 0xe5, 0x94,
|
||||
0x9b, 0x17, 0x8e, 0x76, 0x7b, 0x32, 0xa4, 0xdc, 0x95, 0xe4, 0x74, 0x33, 0xea, 0x69, 0x70, 0x74,
|
||||
0x94, 0xda, 0xa8, 0x5a, 0x96, 0x56, 0xe3, 0xc7, 0x04, 0xbe, 0xdb, 0x93, 0x8b, 0x94, 0xd3, 0x70,
|
||||
0x31, 0xf6, 0x3d, 0x78, 0x16, 0x94, 0x47, 0xd1, 0xa6, 0x76, 0x55, 0xbb, 0x68, 0x6b, 0x35, 0x7e,
|
||||
0x5c, 0x80, 0xdd, 0x9e, 0x5c, 0xa2, 0x78, 0xd3, 0xff, 0xcc, 0x5f, 0x23, 0xfe, 0x9e, 0xfa, 0x97,
|
||||
0xaa, 0xfa, 0x35, 0xad, 0xc6, 0x4f, 0x64, 0xf5, 0x2f, 0xb9, 0x61, 0xe4, 0x7b, 0xc3, 0x6d, 0x55,
|
||||
0xeb, 0x5b, 0xcf, 0xc4, 0xdc, 0x93, 0x67, 0x62, 0xee, 0xcb, 0x6d, 0x31, 0xb7, 0xb5, 0x2d, 0x72,
|
||||
0x8f, 0xb7, 0x45, 0xee, 0xe7, 0x6d, 0x91, 0xbb, 0xf7, 0x5c, 0xcc, 0x3d, 0x7e, 0x2e, 0xe6, 0x9e,
|
||||
0x3c, 0x17, 0x73, 0x1f, 0xff, 0xbd, 0x59, 0x67, 0xfe, 0xdf, 0xac, 0x4e, 0x26, 0x7e, 0x78, 0xfe,
|
||||
0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc7, 0x53, 0x05, 0xd1, 0xf5, 0x0c, 0x00, 0x00,
|
||||
// 1275 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x57, 0xbd, 0x6f, 0xdb, 0xd6,
|
||||
0x17, 0x15, 0xe9, 0x0f, 0xd9, 0x4f, 0xb2, 0x4d, 0x3f, 0x1b, 0xb1, 0xc2, 0x1f, 0x7e, 0x24, 0xa3,
|
||||
0x04, 0x81, 0x91, 0x26, 0x74, 0xe2, 0x0c, 0x45, 0x53, 0xa0, 0xa8, 0x64, 0x31, 0x89, 0x82, 0x58,
|
||||
0x12, 0x28, 0xc6, 0x46, 0x5a, 0x14, 0x04, 0x2d, 0xbe, 0xc8, 0x6c, 0x24, 0x3e, 0x55, 0xef, 0x59,
|
||||
0x8d, 0xb6, 0xa0, 0x43, 0x11, 0x68, 0xca, 0xd8, 0x45, 0x40, 0x81, 0x66, 0x28, 0x3a, 0x65, 0xe8,
|
||||
0x1f, 0x61, 0x74, 0x0a, 0x8a, 0x16, 0x08, 0x3a, 0x28, 0x8d, 0x33, 0xb4, 0xe8, 0xd0, 0x21, 0x63,
|
||||
0xa7, 0x82, 0x7c, 0x8f, 0x11, 0x2d, 0x3b, 0x4d, 0xdc, 0x0f, 0xa0, 0xe8, 0x62, 0x98, 0x97, 0xe7,
|
||||
0x9c, 0xfb, 0xee, 0xe1, 0xbd, 0x97, 0x14, 0x58, 0xba, 0xb3, 0x52, 0xc7, 0x9d, 0x15, 0xda, 0x6d,
|
||||
0x21, 0xc2, 0xfe, 0xea, 0xad, 0x36, 0xa6, 0x18, 0x2e, 0xd4, 0x30, 0x69, 0x62, 0x62, 0x13, 0xf7,
|
||||
0xb6, 0x7e, 0x47, 0xaf, 0xe3, 0x8e, 0xde, 0xb9, 0x20, 0xcf, 0x1f, 0xc0, 0xc9, 0xa7, 0xe9, 0xb6,
|
||||
0xd7, 0x76, 0xed, 0x96, 0xd3, 0xa6, 0xdd, 0x95, 0x30, 0xb4, 0x52, 0xc7, 0x75, 0x3c, 0xfc, 0x8f,
|
||||
0xe3, 0xde, 0x38, 0x88, 0x63, 0x19, 0xce, 0xc5, 0x2f, 0x38, 0x58, 0xad, 0x63, 0x5c, 0x6f, 0x20,
|
||||
0x86, 0xdb, 0xda, 0xb9, 0xb5, 0x42, 0xbd, 0x26, 0x22, 0xd4, 0x69, 0xb6, 0x38, 0xe0, 0xf8, 0x28,
|
||||
0xc0, 0xf1, 0xbb, 0xec, 0x56, 0xf6, 0xa1, 0x08, 0xe6, 0xd7, 0x49, 0xbd, 0xba, 0xb3, 0xd5, 0xf4,
|
||||
0x68, 0xa5, 0x8d, 0x5b, 0x98, 0x38, 0x0d, 0xf8, 0x36, 0x48, 0xd6, 0xb0, 0x4f, 0x91, 0x4f, 0x33,
|
||||
0x82, 0x26, 0x2c, 0xa7, 0x56, 0x17, 0x75, 0x26, 0xa1, 0x47, 0x12, 0x7a, 0xce, 0xef, 0xe6, 0x53,
|
||||
0xdf, 0x7c, 0x7d, 0x2e, 0xb9, 0xc6, 0x80, 0x66, 0xc4, 0x80, 0xf7, 0x04, 0x30, 0xe7, 0xf9, 0x1e,
|
||||
0xf5, 0x9c, 0x86, 0xed, 0xa2, 0x16, 0x26, 0x1e, 0xcd, 0x88, 0xda, 0xd8, 0x72, 0x6a, 0x75, 0x41,
|
||||
0x8f, 0xd9, 0xd4, 0xb9, 0xa0, 0xaf, 0x61, 0xcf, 0xcf, 0x5f, 0xdb, 0x1d, 0xa8, 0x89, 0xe7, 0x03,
|
||||
0xf5, 0x58, 0xd7, 0x69, 0x36, 0x2e, 0x65, 0x47, 0x98, 0xd9, 0xaf, 0x9e, 0xa8, 0xcb, 0x75, 0x8f,
|
||||
0x6e, 0xef, 0x6c, 0xe9, 0x35, 0xdc, 0xe4, 0x85, 0x47, 0x66, 0x10, 0xf7, 0x36, 0xb7, 0x37, 0x90,
|
||||
0x22, 0xe6, 0x2c, 0x67, 0x17, 0x18, 0x19, 0xae, 0x83, 0xa9, 0x56, 0x58, 0x13, 0x6a, 0x67, 0xc6,
|
||||
0x34, 0x61, 0x39, 0x9d, 0xbf, 0xf0, 0xdb, 0x40, 0x3d, 0xf7, 0x1a, 0x7a, 0xb9, 0x5a, 0x2d, 0xe7,
|
||||
0xba, 0x6d, 0x44, 0x88, 0xf9, 0x42, 0xe2, 0xd2, 0xf8, 0xcf, 0x9f, 0xab, 0x42, 0xf6, 0x27, 0x01,
|
||||
0x24, 0xd7, 0x49, 0x7d, 0x03, 0x53, 0x04, 0x2d, 0x90, 0x6a, 0x71, 0xd3, 0x6c, 0xcf, 0x0d, 0xcd,
|
||||
0x1a, 0xcf, 0x5f, 0xdc, 0x1b, 0xa8, 0x20, 0xf2, 0xb2, 0x58, 0xf8, 0x65, 0xa0, 0xc6, 0x41, 0xcf,
|
||||
0x07, 0x2a, 0x64, 0xa5, 0xc6, 0x82, 0x59, 0x13, 0x44, 0x57, 0x45, 0x17, 0x5e, 0x01, 0x13, 0x1d,
|
||||
0x4c, 0x51, 0x3b, 0x23, 0xfe, 0xd9, 0x33, 0x33, 0x3e, 0x7c, 0x13, 0x4c, 0xe2, 0x16, 0xf5, 0xb0,
|
||||
0x1f, 0x56, 0x3f, 0xbb, 0xaa, 0xea, 0x87, 0xf4, 0xa9, 0x1e, 0x54, 0x52, 0x0e, 0x61, 0x26, 0x87,
|
||||
0xf3, 0x4a, 0x3f, 0x13, 0x01, 0x58, 0x27, 0xf5, 0xc8, 0xcd, 0x7f, 0xa6, 0xd8, 0x32, 0x98, 0xe6,
|
||||
0xcf, 0x1a, 0xff, 0x85, 0x82, 0x87, 0x1a, 0xf0, 0x03, 0x30, 0xe9, 0x34, 0xf1, 0x8e, 0x4f, 0x33,
|
||||
0x63, 0x2f, 0xef, 0xba, 0xf3, 0x41, 0xd7, 0x1d, 0xa9, 0xb7, 0xb8, 0x28, 0xb7, 0x66, 0x13, 0xa4,
|
||||
0x2d, 0x74, 0x67, 0x38, 0x31, 0x8b, 0x60, 0x82, 0x7a, 0xb4, 0x81, 0x42, 0x57, 0xa6, 0x4d, 0x76,
|
||||
0x01, 0x35, 0x90, 0x72, 0x11, 0xa9, 0xb5, 0x3d, 0xf6, 0x10, 0xc4, 0xf0, 0x5e, 0x3c, 0x74, 0x69,
|
||||
0x2e, 0x50, 0xfb, 0x76, 0x38, 0x46, 0xd9, 0x4f, 0x45, 0x90, 0x8c, 0x0c, 0x37, 0x0e, 0x33, 0xfc,
|
||||
0xd4, 0x7e, 0xc3, 0xff, 0xb3, 0x0e, 0xdf, 0x4d, 0x82, 0xa9, 0x17, 0xf6, 0xe6, 0x0f, 0x73, 0xe2,
|
||||
0xc4, 0x81, 0xd6, 0x13, 0xc3, 0x8e, 0x9b, 0xe6, 0x9b, 0x64, 0xc4, 0x86, 0xd8, 0x52, 0x13, 0x8f,
|
||||
0xbc, 0xd4, 0x36, 0xc1, 0x24, 0xa1, 0x0e, 0xdd, 0x21, 0x7c, 0x92, 0x4e, 0x1e, 0x3a, 0x49, 0xd1,
|
||||
0x61, 0xaa, 0x21, 0x34, 0x2f, 0x0f, 0xd7, 0xda, 0x8b, 0xd3, 0x33, 0x95, 0xac, 0xc9, 0xe5, 0xe0,
|
||||
0x47, 0x00, 0xde, 0xf2, 0x7c, 0xa7, 0x61, 0x53, 0xa7, 0xd1, 0xe8, 0xda, 0x6d, 0x44, 0x76, 0x1a,
|
||||
0x34, 0x33, 0x1e, 0x1e, 0x50, 0x3b, 0x34, 0x89, 0x15, 0x00, 0xcd, 0x10, 0x97, 0x3f, 0xc1, 0x97,
|
||||
0xe7, 0x71, 0x96, 0xe5, 0xa0, 0x52, 0xd6, 0x94, 0xc2, 0x60, 0x8c, 0x04, 0xdf, 0x07, 0x29, 0x12,
|
||||
0xee, 0x7b, 0x3b, 0x78, 0x51, 0x64, 0x26, 0xc2, 0x5c, 0xf2, 0x01, 0x33, 0xac, 0xe8, 0x2d, 0x92,
|
||||
0x57, 0x78, 0x16, 0xde, 0x68, 0x31, 0x72, 0xf6, 0xfe, 0x13, 0x55, 0x30, 0x01, 0x8b, 0x04, 0x04,
|
||||
0xe8, 0x01, 0x89, 0x37, 0x8a, 0x8d, 0x7c, 0x97, 0x65, 0x98, 0x7c, 0x65, 0x86, 0x93, 0x3c, 0xc3,
|
||||
0x12, 0xcb, 0x30, 0xaa, 0xc0, 0xd2, 0xcc, 0xf2, 0xb0, 0xe1, 0xbb, 0x61, 0xaa, 0x4f, 0x04, 0x30,
|
||||
0x43, 0x31, 0x8d, 0xbd, 0x66, 0x92, 0x2f, 0x6f, 0xc7, 0xab, 0x3c, 0xc3, 0x22, 0xcb, 0xb0, 0x8f,
|
||||
0x77, 0xb4, 0x97, 0x4c, 0x3a, 0xe4, 0x46, 0x33, 0xda, 0x00, 0xf3, 0x1d, 0x4c, 0x3d, 0xbf, 0x1e,
|
||||
0x3c, 0xd9, 0x36, 0xb7, 0x74, 0xea, 0x95, 0x05, 0x9f, 0xe2, 0xc7, 0xc9, 0xb0, 0xe3, 0x1c, 0x90,
|
||||
0x60, 0x15, 0xcf, 0xb1, 0x78, 0x35, 0x08, 0x87, 0x25, 0xdf, 0x02, 0x3c, 0x34, 0x34, 0x77, 0xfa,
|
||||
0x95, 0xb9, 0xb2, 0xfb, 0xdf, 0xb0, 0x23, 0x02, 0x2c, 0xd3, 0x0c, 0x8b, 0x72, 0x6b, 0xf9, 0x08,
|
||||
0xee, 0x8a, 0x20, 0x15, 0x6f, 0x9c, 0x77, 0xc1, 0x58, 0x17, 0x11, 0xb6, 0xe2, 0xf2, 0x7a, 0xa0,
|
||||
0xfa, 0xc3, 0x40, 0x3d, 0xfd, 0x1a, 0xc6, 0x15, 0x7d, 0x6a, 0x06, 0x54, 0x78, 0x15, 0x24, 0x9d,
|
||||
0x2d, 0x42, 0x1d, 0x8f, 0x2f, 0xc3, 0x23, 0xab, 0x44, 0x74, 0xf8, 0x0e, 0x10, 0x7d, 0x1c, 0x0e,
|
||||
0xe3, 0xd1, 0x45, 0x44, 0x1f, 0xc3, 0x3a, 0x48, 0xfb, 0xd8, 0xfe, 0xd8, 0xa3, 0xdb, 0x76, 0x07,
|
||||
0x51, 0x1c, 0x4e, 0xdc, 0x74, 0xde, 0x38, 0x9a, 0xd2, 0xf3, 0x81, 0xba, 0xc0, 0x4c, 0x8d, 0x6b,
|
||||
0x65, 0x4d, 0xe0, 0xe3, 0x4d, 0x8f, 0x6e, 0x6f, 0x20, 0x8a, 0xb9, 0x95, 0xdf, 0x0b, 0x60, 0x3c,
|
||||
0xfc, 0x62, 0xf8, 0x9b, 0x76, 0xfa, 0xbf, 0xe4, 0x13, 0xe1, 0xcc, 0xaf, 0x02, 0x00, 0xc3, 0x9b,
|
||||
0xf0, 0x2c, 0x58, 0xda, 0x28, 0x5b, 0x86, 0x5d, 0xae, 0x58, 0xc5, 0x72, 0xc9, 0xbe, 0x51, 0xaa,
|
||||
0x56, 0x8c, 0xb5, 0xe2, 0xe5, 0xa2, 0x51, 0x90, 0x12, 0xf2, 0x5c, 0xaf, 0xaf, 0xa5, 0x18, 0xd0,
|
||||
0x68, 0xb6, 0x68, 0x17, 0x66, 0xc1, 0x5c, 0x1c, 0x7d, 0xd3, 0xa8, 0x4a, 0x82, 0x3c, 0xd3, 0xeb,
|
||||
0x6b, 0xd3, 0x0c, 0x75, 0x13, 0x11, 0x78, 0x06, 0x2c, 0xc4, 0x31, 0xb9, 0x7c, 0xd5, 0xca, 0x15,
|
||||
0x4b, 0x92, 0x28, 0xcf, 0xf7, 0xfa, 0xda, 0x0c, 0xc3, 0xe5, 0x78, 0x4f, 0x68, 0x60, 0x36, 0x8e,
|
||||
0x2d, 0x95, 0xa5, 0x31, 0x39, 0xdd, 0xeb, 0x6b, 0x53, 0x0c, 0x56, 0xc2, 0x70, 0x15, 0x64, 0xf6,
|
||||
0x23, 0xec, 0xcd, 0xa2, 0x75, 0xd5, 0xde, 0x30, 0xac, 0xb2, 0x34, 0x2e, 0x2f, 0xf6, 0xfa, 0x9a,
|
||||
0x14, 0x61, 0xa3, 0x07, 0x28, 0xa7, 0xef, 0x7d, 0xa1, 0x24, 0xbe, 0x7c, 0xa0, 0x24, 0x1e, 0x3e,
|
||||
0x50, 0x12, 0x67, 0xbe, 0x13, 0xc1, 0xec, 0xfe, 0x35, 0x0f, 0x75, 0xf0, 0xbf, 0x8a, 0x59, 0xae,
|
||||
0x94, 0xab, 0xb9, 0xeb, 0x76, 0xd5, 0xca, 0x59, 0x37, 0xaa, 0x23, 0x85, 0x87, 0x25, 0x31, 0x70,
|
||||
0xc9, 0x0b, 0xbe, 0xae, 0x95, 0x51, 0x7c, 0xc1, 0xa8, 0x94, 0xab, 0x45, 0xcb, 0xae, 0x18, 0x66,
|
||||
0xb1, 0x5c, 0x90, 0x04, 0x79, 0xa9, 0xd7, 0xd7, 0x16, 0x18, 0x85, 0x6f, 0x9a, 0x0a, 0x6a, 0x7b,
|
||||
0xd8, 0x85, 0x6f, 0x81, 0xff, 0x8f, 0x92, 0x37, 0xca, 0x56, 0xb1, 0x74, 0x25, 0xe2, 0x8a, 0xf2,
|
||||
0xb1, 0x5e, 0x5f, 0x83, 0x8c, 0xbb, 0x11, 0x4e, 0x35, 0xa7, 0x9e, 0x05, 0xc7, 0x46, 0xa9, 0x95,
|
||||
0x5c, 0xb5, 0x6a, 0x14, 0xa4, 0x31, 0x59, 0xea, 0xf5, 0xb5, 0x34, 0xe3, 0x54, 0x1c, 0x42, 0x90,
|
||||
0x0b, 0xcf, 0x83, 0xcc, 0x28, 0xda, 0x34, 0xae, 0x19, 0x6b, 0x96, 0x51, 0x90, 0xc6, 0x65, 0xd8,
|
||||
0xeb, 0x6b, 0xb3, 0x0c, 0x6f, 0xa2, 0x0f, 0x51, 0x8d, 0xa2, 0x43, 0xf5, 0x2f, 0xe7, 0x8a, 0xd7,
|
||||
0x8d, 0x82, 0x34, 0x11, 0xd7, 0xbf, 0xec, 0x78, 0x0d, 0xe4, 0xee, 0xb7, 0x35, 0x5f, 0xda, 0x7d,
|
||||
0xaa, 0x24, 0x1e, 0x3f, 0x55, 0x12, 0x77, 0xf7, 0x94, 0xc4, 0xee, 0x9e, 0x22, 0x3c, 0xda, 0x53,
|
||||
0x84, 0x1f, 0xf7, 0x14, 0xe1, 0xfe, 0x33, 0x25, 0xf1, 0xe8, 0x99, 0x92, 0x78, 0xfc, 0x4c, 0x49,
|
||||
0xbc, 0xf7, 0xc7, 0x4b, 0x3a, 0xf6, 0xe3, 0x6c, 0x6b, 0x32, 0xdc, 0x83, 0x17, 0x7f, 0x0f, 0x00,
|
||||
0x00, 0xff, 0xff, 0xd6, 0x34, 0x18, 0x2d, 0xb2, 0x0d, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *MsgSubmitProposalBase) Equal(that interface{}) bool {
|
||||
func (this *MsgSubmitProposal) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*MsgSubmitProposalBase)
|
||||
that1, ok := that.(*MsgSubmitProposal)
|
||||
if !ok {
|
||||
that2, ok := that.(MsgSubmitProposalBase)
|
||||
that2, ok := that.(MsgSubmitProposal)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
@ -549,6 +547,9 @@ func (this *MsgSubmitProposalBase) Equal(that interface{}) bool {
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if !this.Content.Equal(that1.Content) {
|
||||
return false
|
||||
}
|
||||
if len(this.InitialDeposit) != len(that1.InitialDeposit) {
|
||||
return false
|
||||
}
|
||||
@ -689,14 +690,14 @@ func (this *Deposit) Equal(that interface{}) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *ProposalBase) Equal(that interface{}) bool {
|
||||
func (this *Proposal) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*ProposalBase)
|
||||
that1, ok := that.(*Proposal)
|
||||
if !ok {
|
||||
that2, ok := that.(ProposalBase)
|
||||
that2, ok := that.(Proposal)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
@ -711,6 +712,9 @@ func (this *ProposalBase) Equal(that interface{}) bool {
|
||||
if this.ProposalID != that1.ProposalID {
|
||||
return false
|
||||
}
|
||||
if !this.Content.Equal(that1.Content) {
|
||||
return false
|
||||
}
|
||||
if this.Status != that1.Status {
|
||||
return false
|
||||
}
|
||||
@ -802,73 +806,7 @@ func (this *Vote) Equal(that interface{}) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type ProposalBaseFace interface {
|
||||
Proto() github_com_gogo_protobuf_proto.Message
|
||||
GetProposalID() uint64
|
||||
GetStatus() ProposalStatus
|
||||
GetFinalTallyResult() TallyResult
|
||||
GetSubmitTime() time.Time
|
||||
GetDepositEndTime() time.Time
|
||||
GetTotalDeposit() github_com_cosmos_cosmos_sdk_types.Coins
|
||||
GetVotingStartTime() time.Time
|
||||
GetVotingEndTime() time.Time
|
||||
}
|
||||
|
||||
func (this *ProposalBase) Proto() github_com_gogo_protobuf_proto.Message {
|
||||
return this
|
||||
}
|
||||
|
||||
func (this *ProposalBase) TestProto() github_com_gogo_protobuf_proto.Message {
|
||||
return NewProposalBaseFromFace(this)
|
||||
}
|
||||
|
||||
func (this *ProposalBase) GetProposalID() uint64 {
|
||||
return this.ProposalID
|
||||
}
|
||||
|
||||
func (this *ProposalBase) GetStatus() ProposalStatus {
|
||||
return this.Status
|
||||
}
|
||||
|
||||
func (this *ProposalBase) GetFinalTallyResult() TallyResult {
|
||||
return this.FinalTallyResult
|
||||
}
|
||||
|
||||
func (this *ProposalBase) GetSubmitTime() time.Time {
|
||||
return this.SubmitTime
|
||||
}
|
||||
|
||||
func (this *ProposalBase) GetDepositEndTime() time.Time {
|
||||
return this.DepositEndTime
|
||||
}
|
||||
|
||||
func (this *ProposalBase) GetTotalDeposit() github_com_cosmos_cosmos_sdk_types.Coins {
|
||||
return this.TotalDeposit
|
||||
}
|
||||
|
||||
func (this *ProposalBase) GetVotingStartTime() time.Time {
|
||||
return this.VotingStartTime
|
||||
}
|
||||
|
||||
func (this *ProposalBase) GetVotingEndTime() time.Time {
|
||||
return this.VotingEndTime
|
||||
}
|
||||
|
||||
func NewProposalBaseFromFace(that ProposalBaseFace) *ProposalBase {
|
||||
this := &ProposalBase{}
|
||||
this.ProposalID = that.GetProposalID()
|
||||
this.Status = that.GetStatus()
|
||||
this.FinalTallyResult = that.GetFinalTallyResult()
|
||||
this.SubmitTime = that.GetSubmitTime()
|
||||
this.DepositEndTime = that.GetDepositEndTime()
|
||||
this.TotalDeposit = that.GetTotalDeposit()
|
||||
this.VotingStartTime = that.GetVotingStartTime()
|
||||
this.VotingEndTime = that.GetVotingEndTime()
|
||||
return this
|
||||
}
|
||||
|
||||
func (m *MsgSubmitProposalBase) Marshal() (dAtA []byte, err error) {
|
||||
func (m *MsgSubmitProposal) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
@ -878,12 +816,12 @@ func (m *MsgSubmitProposalBase) Marshal() (dAtA []byte, err error) {
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *MsgSubmitProposalBase) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *MsgSubmitProposal) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgSubmitProposalBase) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *MsgSubmitProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
@ -893,7 +831,7 @@ func (m *MsgSubmitProposalBase) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
copy(dAtA[i:], m.Proposer)
|
||||
i = encodeVarintTypes(dAtA, i, uint64(len(m.Proposer)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
if len(m.InitialDeposit) > 0 {
|
||||
for iNdEx := len(m.InitialDeposit) - 1; iNdEx >= 0; iNdEx-- {
|
||||
@ -906,9 +844,21 @@ func (m *MsgSubmitProposalBase) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i = encodeVarintTypes(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
}
|
||||
if m.Content != nil {
|
||||
{
|
||||
size, err := m.Content.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintTypes(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
@ -1087,7 +1037,7 @@ func (m *Deposit) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *ProposalBase) Marshal() (dAtA []byte, err error) {
|
||||
func (m *Proposal) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
@ -1097,32 +1047,32 @@ func (m *ProposalBase) Marshal() (dAtA []byte, err error) {
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *ProposalBase) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *Proposal) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *ProposalBase) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *Proposal) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.VotingEndTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.VotingEndTime):])
|
||||
if err1 != nil {
|
||||
return 0, err1
|
||||
}
|
||||
i -= n1
|
||||
i = encodeVarintTypes(dAtA, i, uint64(n1))
|
||||
i--
|
||||
dAtA[i] = 0x42
|
||||
n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.VotingStartTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.VotingStartTime):])
|
||||
n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.VotingEndTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.VotingEndTime):])
|
||||
if err2 != nil {
|
||||
return 0, err2
|
||||
}
|
||||
i -= n2
|
||||
i = encodeVarintTypes(dAtA, i, uint64(n2))
|
||||
i--
|
||||
dAtA[i] = 0x3a
|
||||
dAtA[i] = 0x4a
|
||||
n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.VotingStartTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.VotingStartTime):])
|
||||
if err3 != nil {
|
||||
return 0, err3
|
||||
}
|
||||
i -= n3
|
||||
i = encodeVarintTypes(dAtA, i, uint64(n3))
|
||||
i--
|
||||
dAtA[i] = 0x42
|
||||
if len(m.TotalDeposit) > 0 {
|
||||
for iNdEx := len(m.TotalDeposit) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
@ -1134,25 +1084,25 @@ func (m *ProposalBase) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i = encodeVarintTypes(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x32
|
||||
dAtA[i] = 0x3a
|
||||
}
|
||||
}
|
||||
n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.DepositEndTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.DepositEndTime):])
|
||||
if err3 != nil {
|
||||
return 0, err3
|
||||
}
|
||||
i -= n3
|
||||
i = encodeVarintTypes(dAtA, i, uint64(n3))
|
||||
i--
|
||||
dAtA[i] = 0x2a
|
||||
n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.SubmitTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.SubmitTime):])
|
||||
n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.DepositEndTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.DepositEndTime):])
|
||||
if err4 != nil {
|
||||
return 0, err4
|
||||
}
|
||||
i -= n4
|
||||
i = encodeVarintTypes(dAtA, i, uint64(n4))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
dAtA[i] = 0x32
|
||||
n5, err5 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.SubmitTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.SubmitTime):])
|
||||
if err5 != nil {
|
||||
return 0, err5
|
||||
}
|
||||
i -= n5
|
||||
i = encodeVarintTypes(dAtA, i, uint64(n5))
|
||||
i--
|
||||
dAtA[i] = 0x2a
|
||||
{
|
||||
size, err := m.FinalTallyResult.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
@ -1162,11 +1112,23 @@ func (m *ProposalBase) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i = encodeVarintTypes(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
dAtA[i] = 0x22
|
||||
if m.Status != 0 {
|
||||
i = encodeVarintTypes(dAtA, i, uint64(m.Status))
|
||||
i--
|
||||
dAtA[i] = 0x10
|
||||
dAtA[i] = 0x18
|
||||
}
|
||||
if m.Content != nil {
|
||||
{
|
||||
size, err := m.Content.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintTypes(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if m.ProposalID != 0 {
|
||||
i = encodeVarintTypes(dAtA, i, uint64(m.ProposalID))
|
||||
@ -1290,12 +1252,16 @@ func encodeVarintTypes(dAtA []byte, offset int, v uint64) int {
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *MsgSubmitProposalBase) Size() (n int) {
|
||||
func (m *MsgSubmitProposal) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.Content != nil {
|
||||
l = m.Content.Size()
|
||||
n += 1 + l + sovTypes(uint64(l))
|
||||
}
|
||||
if len(m.InitialDeposit) > 0 {
|
||||
for _, e := range m.InitialDeposit {
|
||||
l = e.Size()
|
||||
@ -1389,7 +1355,7 @@ func (m *Deposit) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *ProposalBase) Size() (n int) {
|
||||
func (m *Proposal) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@ -1398,6 +1364,10 @@ func (m *ProposalBase) Size() (n int) {
|
||||
if m.ProposalID != 0 {
|
||||
n += 1 + sovTypes(uint64(m.ProposalID))
|
||||
}
|
||||
if m.Content != nil {
|
||||
l = m.Content.Size()
|
||||
n += 1 + l + sovTypes(uint64(l))
|
||||
}
|
||||
if m.Status != 0 {
|
||||
n += 1 + sovTypes(uint64(m.Status))
|
||||
}
|
||||
@ -1462,7 +1432,7 @@ func sovTypes(x uint64) (n int) {
|
||||
func sozTypes(x uint64) (n int) {
|
||||
return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *MsgSubmitProposalBase) Unmarshal(dAtA []byte) error {
|
||||
func (m *MsgSubmitProposal) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
@ -1485,13 +1455,49 @@ func (m *MsgSubmitProposalBase) Unmarshal(dAtA []byte) error {
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: MsgSubmitProposalBase: wiretype end group for non-group")
|
||||
return fmt.Errorf("proto: MsgSubmitProposal: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgSubmitProposalBase: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
return fmt.Errorf("proto: MsgSubmitProposal: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Content == nil {
|
||||
m.Content = &types.Any{}
|
||||
}
|
||||
if err := m.Content.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field InitialDeposit", wireType)
|
||||
}
|
||||
@ -1520,12 +1526,12 @@ func (m *MsgSubmitProposalBase) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.InitialDeposit = append(m.InitialDeposit, types.Coin{})
|
||||
m.InitialDeposit = append(m.InitialDeposit, types1.Coin{})
|
||||
if err := m.InitialDeposit[len(m.InitialDeposit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Proposer", wireType)
|
||||
}
|
||||
@ -1819,7 +1825,7 @@ func (m *MsgDeposit) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Amount = append(m.Amount, types.Coin{})
|
||||
m.Amount = append(m.Amount, types1.Coin{})
|
||||
if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -2076,7 +2082,7 @@ func (m *Deposit) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Amount = append(m.Amount, types.Coin{})
|
||||
m.Amount = append(m.Amount, types1.Coin{})
|
||||
if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -2105,7 +2111,7 @@ func (m *Deposit) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *ProposalBase) Unmarshal(dAtA []byte) error {
|
||||
func (m *Proposal) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
@ -2128,10 +2134,10 @@ func (m *ProposalBase) Unmarshal(dAtA []byte) error {
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: ProposalBase: wiretype end group for non-group")
|
||||
return fmt.Errorf("proto: Proposal: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: ProposalBase: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
return fmt.Errorf("proto: Proposal: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
@ -2154,6 +2160,42 @@ func (m *ProposalBase) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Content == nil {
|
||||
m.Content = &types.Any{}
|
||||
}
|
||||
if err := m.Content.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType)
|
||||
}
|
||||
@ -2172,7 +2214,7 @@ func (m *ProposalBase) Unmarshal(dAtA []byte) error {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 3:
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field FinalTallyResult", wireType)
|
||||
}
|
||||
@ -2205,7 +2247,7 @@ func (m *ProposalBase) Unmarshal(dAtA []byte) error {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
case 5:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field SubmitTime", wireType)
|
||||
}
|
||||
@ -2238,7 +2280,7 @@ func (m *ProposalBase) Unmarshal(dAtA []byte) error {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 5:
|
||||
case 6:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field DepositEndTime", wireType)
|
||||
}
|
||||
@ -2271,7 +2313,7 @@ func (m *ProposalBase) Unmarshal(dAtA []byte) error {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 6:
|
||||
case 7:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field TotalDeposit", wireType)
|
||||
}
|
||||
@ -2300,12 +2342,12 @@ func (m *ProposalBase) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.TotalDeposit = append(m.TotalDeposit, types.Coin{})
|
||||
m.TotalDeposit = append(m.TotalDeposit, types1.Coin{})
|
||||
if err := m.TotalDeposit[len(m.TotalDeposit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 7:
|
||||
case 8:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field VotingStartTime", wireType)
|
||||
}
|
||||
@ -2338,7 +2380,7 @@ func (m *ProposalBase) Unmarshal(dAtA []byte) error {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 8:
|
||||
case 9:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field VotingEndTime", wireType)
|
||||
}
|
||||
|
||||
@ -3,29 +3,27 @@ package cosmos_sdk.x.gov.v1;
|
||||
|
||||
import "types/types.proto";
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "third_party/proto/cosmos-proto/cosmos.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
|
||||
option (gogoproto.goproto_stringer_all) = false;
|
||||
option (gogoproto.stringer_all) = false;
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
// MsgSubmitProposalBase defines an sdk.Msg type that supports submitting arbitrary
|
||||
// MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary
|
||||
// proposal Content.
|
||||
//
|
||||
// Note, this message type provides the basis for which a true MsgSubmitProposal
|
||||
// can be constructed. Since the Content submitted in the message can be arbitrary,
|
||||
// assuming it fulfills the Content interface, it must be defined at the
|
||||
// application-level and extend MsgSubmitProposalBase.
|
||||
message MsgSubmitProposalBase {
|
||||
message MsgSubmitProposal {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
repeated cosmos_sdk.v1.Coin initial_deposit = 1 [
|
||||
google.protobuf.Any content = 1 [(cosmos_proto.accepts_interface) = "Content"];
|
||||
repeated cosmos_sdk.v1.Coin initial_deposit = 2 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
|
||||
(gogoproto.moretags) = "yaml:\"initial_deposit\""
|
||||
];
|
||||
bytes proposer = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
bytes proposer = 3 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
}
|
||||
|
||||
// MsgVote defines a message to cast a vote
|
||||
@ -76,6 +74,8 @@ enum VoteOption {
|
||||
// TextProposal defines a standard text proposal whose changes need to be
|
||||
// manually updated in case of approval
|
||||
message TextProposal {
|
||||
option (cosmos_proto.implements_interface) = "Content";
|
||||
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
string title = 1;
|
||||
@ -92,31 +92,28 @@ message Deposit {
|
||||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
}
|
||||
|
||||
// ProposalBase defines the core field members of a governance proposal. It includes
|
||||
// all static fields (i.e fields excluding the dynamic Content). A full proposal
|
||||
// extends the ProposalBase with Content.
|
||||
message ProposalBase {
|
||||
// Proposal defines the core field members of a governance proposal
|
||||
message Proposal {
|
||||
option (gogoproto.equal) = true;
|
||||
option (gogoproto.goproto_stringer) = true;
|
||||
option (gogoproto.face) = true;
|
||||
|
||||
uint64 proposal_id = 1
|
||||
[(gogoproto.customname) = "ProposalID", (gogoproto.jsontag) = "id", (gogoproto.moretags) = "yaml:\"id\""];
|
||||
ProposalStatus status = 2 [(gogoproto.moretags) = "yaml:\"proposal_status\""];
|
||||
TallyResult final_tally_result = 3
|
||||
google.protobuf.Any content = 2 [(cosmos_proto.accepts_interface) = "Content"];
|
||||
ProposalStatus status = 3 [(gogoproto.moretags) = "yaml:\"proposal_status\""];
|
||||
TallyResult final_tally_result = 4
|
||||
[(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"final_tally_result\""];
|
||||
google.protobuf.Timestamp submit_time = 4
|
||||
google.protobuf.Timestamp submit_time = 5
|
||||
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"submit_time\""];
|
||||
google.protobuf.Timestamp deposit_end_time = 5
|
||||
google.protobuf.Timestamp deposit_end_time = 6
|
||||
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"deposit_end_time\""];
|
||||
repeated cosmos_sdk.v1.Coin total_deposit = 6 [
|
||||
repeated cosmos_sdk.v1.Coin total_deposit = 7 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
|
||||
(gogoproto.moretags) = "yaml:\"total_deposit\""
|
||||
];
|
||||
google.protobuf.Timestamp voting_start_time = 7
|
||||
google.protobuf.Timestamp voting_start_time = 8
|
||||
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_start_time\""];
|
||||
google.protobuf.Timestamp voting_end_time = 8
|
||||
google.protobuf.Timestamp voting_end_time = 9
|
||||
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_end_time\""];
|
||||
}
|
||||
|
||||
|
||||
@ -80,7 +80,10 @@ Where proposal.json contains:
|
||||
return err
|
||||
}
|
||||
|
||||
msg := govtypes.NewMsgSubmitProposal(content, deposit, from)
|
||||
msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -160,7 +163,10 @@ Where proposal.json contains:
|
||||
return err
|
||||
}
|
||||
|
||||
msg := govtypes.NewMsgSubmitProposal(content, deposit, from)
|
||||
msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -36,7 +36,10 @@ func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
|
||||
content := proposal.NewParameterChangeProposal(req.Title, req.Description, req.Changes.ToParamChanges())
|
||||
|
||||
msg := govtypes.NewMsgSubmitProposal(content, req.Deposit, req.Proposer)
|
||||
msg, err := govtypes.NewMsgSubmitProposal(content, req.Deposit, req.Proposer)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
if rest.CheckBadRequestError(w, msg.ValidateBasic()) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -4,6 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"math/rand"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/spf13/cobra"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
@ -21,6 +23,7 @@ var (
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ module.InterfaceModule = AppModuleBasic{}
|
||||
)
|
||||
|
||||
// AppModuleBasic defines the basic application module used by the params module.
|
||||
@ -52,6 +55,10 @@ func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command { return nil }
|
||||
// GetQueryCmd returns no root query command for the params module.
|
||||
func (AppModuleBasic) GetQueryCmd(_ *codec.Codec) *cobra.Command { return nil }
|
||||
|
||||
func (am AppModuleBasic) RegisterInterfaceTypes(registry types.InterfaceRegistry) {
|
||||
proposal.RegisterInterfaces(registry)
|
||||
}
|
||||
|
||||
//____________________________________________________________________________
|
||||
|
||||
// AppModule implements an application module for the distribution module.
|
||||
|
||||
@ -3,6 +3,7 @@ package proposal
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
)
|
||||
|
||||
type Codec struct {
|
||||
@ -31,3 +32,10 @@ func init() {
|
||||
func RegisterCodec(cdc *codec.Codec) {
|
||||
cdc.RegisterConcrete(&ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal", nil)
|
||||
}
|
||||
|
||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
registry.RegisterImplementations(
|
||||
(*gov.Content)(nil),
|
||||
&ParameterChangeProposal{},
|
||||
)
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/tendermint/go-amino"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
@ -156,7 +155,7 @@ func (w WeightedProposalContent) ContentSimulatorFn() simulation.ContentSimulato
|
||||
|
||||
// RandomParams returns random simulation consensus parameters, it extracts the Evidence from the Staking genesis state.
|
||||
func RandomConsensusParams(r *rand.Rand, appState json.RawMessage) *abci.ConsensusParams {
|
||||
cdc := amino.NewCodec()
|
||||
cdc := codec.New()
|
||||
|
||||
var genesisState map[string]json.RawMessage
|
||||
|
||||
|
||||
@ -224,7 +224,10 @@ func GetCmdSubmitUpgradeProposal(cdc *codec.Codec) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := gov.NewMsgSubmitProposal(content, deposit, from)
|
||||
msg, err := gov.NewMsgSubmitProposal(content, deposit, from)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -277,7 +280,10 @@ func GetCmdSubmitCancelUpgradeProposal(cdc *codec.Codec) *cobra.Command {
|
||||
|
||||
content := types.NewCancelSoftwareUpgradeProposal(title, description)
|
||||
|
||||
msg := gov.NewMsgSubmitProposal(content, deposit, from)
|
||||
msg, err := gov.NewMsgSubmitProposal(content, deposit, from)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -169,7 +169,10 @@ func postPlanHandler(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
|
||||
plan := types.Plan{Name: req.UpgradeName, Time: t, Height: req.UpgradeHeight, Info: req.UpgradeInfo}
|
||||
content := types.NewSoftwareUpgradeProposal(req.Title, req.Description, plan)
|
||||
msg := gov.NewMsgSubmitProposal(content, req.Deposit, fromAddr)
|
||||
msg, err := gov.NewMsgSubmitProposal(content, req.Deposit, fromAddr)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
if rest.CheckBadRequestError(w, msg.ValidateBasic()) {
|
||||
return
|
||||
}
|
||||
@ -197,7 +200,10 @@ func cancelPlanHandler(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
}
|
||||
|
||||
content := types.NewCancelSoftwareUpgradeProposal(req.Title, req.Description)
|
||||
msg := gov.NewMsgSubmitProposal(content, req.Deposit, fromAddr)
|
||||
msg, err := gov.NewMsgSubmitProposal(content, req.Deposit, fromAddr)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
if rest.CheckBadRequestError(w, msg.ValidateBasic()) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -11,10 +11,12 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/upgrade/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/upgrade/client/rest"
|
||||
types "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
||||
)
|
||||
|
||||
// module codec
|
||||
@ -25,8 +27,9 @@ func init() {
|
||||
}
|
||||
|
||||
var (
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
_ module.InterfaceModule = AppModuleBasic{}
|
||||
)
|
||||
|
||||
// AppModuleBasic implements the sdk.AppModuleBasic interface
|
||||
@ -71,6 +74,10 @@ func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||
return txCmd
|
||||
}
|
||||
|
||||
func (b AppModuleBasic) RegisterInterfaceTypes(registry codectypes.InterfaceRegistry) {
|
||||
types.RegisterInterfaces(registry)
|
||||
}
|
||||
|
||||
// AppModule implements the sdk.AppModule interface
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
|
||||
@ -2,6 +2,8 @@ package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
)
|
||||
|
||||
// RegisterCodec registers concrete types on the Amino codec
|
||||
@ -10,3 +12,11 @@ func RegisterCodec(cdc *codec.Codec) {
|
||||
cdc.RegisterConcrete(&SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal", nil)
|
||||
cdc.RegisterConcrete(&CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal", nil)
|
||||
}
|
||||
|
||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
registry.RegisterImplementations(
|
||||
(*gov.Content)(nil),
|
||||
&SoftwareUpgradeProposal{},
|
||||
&CancelSoftwareUpgradeProposal{},
|
||||
)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user