WIP on std codec
This commit is contained in:
parent
2cf8a5e955
commit
8bd648eef1
File diff suppressed because it is too large
Load Diff
|
@ -1,17 +1,28 @@
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
package cosmos_sdk.x.v1;
|
package cosmos_sdk.x.v1;
|
||||||
|
|
||||||
|
import "third_party/proto/cosmos-proto/cosmos.proto";
|
||||||
|
import "third_party/proto/gogoproto/gogo.proto";
|
||||||
import "x/gov/types/types.proto";
|
import "x/gov/types/types.proto";
|
||||||
import "x/params/types/proposal/types.proto";
|
import "x/params/types/proposal/types.proto";
|
||||||
import "x/upgrade/types/types.proto";
|
import "x/upgrade/types/types.proto";
|
||||||
import "x/distribution/types/types.proto";
|
import "x/distribution/types/types.proto";
|
||||||
|
|
||||||
|
option go_package = "github.com/cosmos/cosmos-sdk/codec/std";
|
||||||
|
|
||||||
message StdProposal {
|
message StdProposal {
|
||||||
oneof sum {
|
cosmos_sdk.x.gov.v1.ProposalBase base = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
|
||||||
cosmos_sdk.x.gov.v1.TextProposal text = 1;
|
Content content = 2 [(gogoproto.nullable) = false];
|
||||||
cosmos_sdk.x.params.v1.ParameterChangeProposal parameter_change = 2;
|
|
||||||
cosmos_sdk.x.upgrade.v1.SoftwareUpgradeProposal software_upgrade = 3;
|
message Content {
|
||||||
cosmos_sdk.x.upgrade.v1.CancelSoftwareUpgradeProposal cancel_software_upgrade = 4;
|
option (cosmos_proto.interface_type) = "github.com/cosmos/cosmos-sdk/x/gov/types.Content";
|
||||||
cosmos_sdk.x.distribution.v1.CommunityPoolSpendProposal community_pool_spend = 5;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package simapp
|
package simapp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
@ -208,7 +207,7 @@ func NewSimApp(
|
||||||
AddRoute(distr.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
|
AddRoute(distr.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
|
||||||
AddRoute(upgrade.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper))
|
AddRoute(upgrade.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper))
|
||||||
app.GovKeeper = gov.NewKeeper(
|
app.GovKeeper = gov.NewKeeper(
|
||||||
types.NewAminoGovCodec(app.cdc), keys[gov.StoreKey], app.subspaces[gov.ModuleName], app.SupplyKeeper,
|
appCodec, keys[gov.StoreKey], app.subspaces[gov.ModuleName], app.SupplyKeeper,
|
||||||
&stakingKeeper, govRouter,
|
&stakingKeeper, govRouter,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package codec
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
cosmos_sdk_x_v1 "github.com/cosmos/cosmos-sdk/codec/std"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
|
@ -9,6 +10,7 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
|
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
|
||||||
"github.com/cosmos/cosmos-sdk/x/evidence"
|
"github.com/cosmos/cosmos-sdk/x/evidence"
|
||||||
eviexported "github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
eviexported "github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/supply"
|
"github.com/cosmos/cosmos-sdk/x/supply"
|
||||||
supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported"
|
supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported"
|
||||||
)
|
)
|
||||||
|
@ -151,6 +153,26 @@ func (c *Codec) UnmarshalEvidenceJSON(bz []byte) (eviexported.Evidence, error) {
|
||||||
return evidence.GetEvidence(), nil
|
return evidence.GetEvidence(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Codec) MarshalProposal(p types.Proposal) ([]byte, error) {
|
||||||
|
stdProposal := &cosmos_sdk_x_v1.StdProposal{ProposalBase: p.ProposalBase}
|
||||||
|
if err := stdProposal.Content.SetContent(p.Content); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return c.Marshaler.MarshalBinaryBare(stdProposal)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Codec) UnmarshalProposal(bz []byte) (types.Proposal, error) {
|
||||||
|
stdProposal := &cosmos_sdk_x_v1.StdProposal{}
|
||||||
|
if err := c.Marshaler.UnmarshalBinaryLengthPrefixed(bz, stdProposal); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return types.Proposal{
|
||||||
|
//Content: stdProposal.Content.GetContent(),
|
||||||
|
ProposalBase: stdProposal.ProposalBase,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// necessary types and interfaces registered. This codec is provided to all the
|
// necessary types and interfaces registered. This codec is provided to all the
|
||||||
// modules the application depends on.
|
// modules the application depends on.
|
||||||
|
|
Loading…
Reference in New Issue