Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,22 +420,24 @@ func New(
// register the governance hooks
),
)

// register the proposal types
adminRouter := govv1beta1.NewRouter()
adminRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
adminRouterLegacy := govv1beta1.NewRouter()
adminRouterLegacy.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(&app.UpgradeKeeper)).
AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))

adminRouter := baseapp.NewMsgServiceRouter()
app.AdminmoduleKeeper = *adminmodulemodulekeeper.NewKeeper(
appCodec,
keys[adminmodulemoduletypes.StoreKey],
keys[adminmodulemoduletypes.MemStoreKey],
adminRouterLegacy,
adminRouter,
// this allows any type of proposal to be submitted to the admin module (everything is whitelisted)
// projects will implement their functions to define what is allowed for admins.
func(govv1beta1.Content) bool { return true },
func(msg sdk.Msg) bool { return true },
)
adminModule := adminmodulemodule.NewAppModule(appCodec, app.AdminmoduleKeeper)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require (

require (
cosmossdk.io/core v0.5.1
cosmossdk.io/errors v1.0.0-beta.7
cosmossdk.io/tools/rosetta v0.2.1
github.com/cosmos/cosmos-proto v1.0.0-beta.2
github.com/cosmos/gogoproto v1.4.10
Expand All @@ -36,7 +37,6 @@ require (
cloud.google.com/go/storage v1.29.0 // indirect
cosmossdk.io/api v0.3.1 // indirect
cosmossdk.io/depinject v1.0.0-alpha.3 // indirect
cosmossdk.io/errors v1.0.0-beta.7 // indirect
cosmossdk.io/log v1.1.0 // indirect
cosmossdk.io/math v1.0.1 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
Expand Down
19 changes: 18 additions & 1 deletion proto/cosmos/adminmodule/adminmodule/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cosmos.adminmodule.adminmodule;

import "google/api/annotations.proto";
import "cosmos/gov/v1beta1/gov.proto";
import "cosmos/gov/v1/gov.proto";

option go_package = "github.com/cosmos/admin-module/x/adminmodule/types";

Expand All @@ -19,6 +20,11 @@ service Query {
option (google.api.http).get = "/cosmos/adminmodule/adminmodule/archivedproposals";
}

// Queries a list of archived proposals.
rpc ArchivedProposalsLegacy(QueryArchivedProposalsLegacyRequest) returns (QueryArchivedProposalsLegacyResponse) {
option (google.api.http).get = "/cosmos/adminmodule/adminmodule/archivedproposalslegacy";
}

}

message QueryAdminsRequest {
Expand All @@ -31,6 +37,17 @@ message QueryAdminsResponse {
message QueryArchivedProposalsRequest {
}

message QueryArchivedProposalsLegacyRequest {
}

message QueryProposalsResponse {
repeated cosmos.gov.v1.Proposal proposals = 1;
}

message QueryArchivedProposalsResponse {
repeated cosmos.gov.v1beta1.Proposal proposals = 1;
repeated cosmos.gov.v1.Proposal proposals = 1;
}

message QueryArchivedProposalsLegacyResponse {
repeated cosmos.gov.v1beta1.Proposal proposalsLegacy = 1;
}
21 changes: 20 additions & 1 deletion proto/cosmos/adminmodule/adminmodule/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ service Msg {
rpc DeleteAdmin(MsgDeleteAdmin) returns (MsgDeleteAdminResponse);
rpc AddAdmin(MsgAddAdmin) returns (MsgAddAdminResponse);
rpc SubmitProposal(MsgSubmitProposal) returns (MsgSubmitProposalResponse);
rpc SubmitProposalLegacy(MsgSubmitProposalLegacy) returns (MsgSubmitProposalLegacyResponse);
}

message MsgDeleteAdmin {
Expand All @@ -31,6 +32,23 @@ message MsgAddAdmin {
message MsgAddAdminResponse {
}

// MsgSubmitProposalLegacy defines an sdk.Msg type that supports submitting arbitrary
// proposal Content.
message MsgSubmitProposalLegacy {
option (gogoproto.equal) = false;
option (gogoproto.goproto_stringer) = false;
option (gogoproto.stringer) = false;
option (gogoproto.goproto_getters) = false;

google.protobuf.Any content = 1 [(cosmos_proto.accepts_interface) = "Content"];
string proposer = 2;
}

// MsgSubmitProposalLegacyResponse defines the Msg/SubmitProposalLegacy response type.
message MsgSubmitProposalLegacyResponse {
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""];
}

// MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary
// proposal Content.
message MsgSubmitProposal {
Expand All @@ -39,7 +57,8 @@ message MsgSubmitProposal {
option (gogoproto.stringer) = false;
option (gogoproto.goproto_getters) = false;

google.protobuf.Any content = 1 [(cosmos_proto.accepts_interface) = "Content"];
// messages are the arbitrary messages to be executed if proposal passes.
repeated google.protobuf.Any messages = 1;
string proposer = 2;
}

Expand Down
71 changes: 0 additions & 71 deletions x/adminmodule/abci.go

This file was deleted.

2 changes: 1 addition & 1 deletion x/adminmodule/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command {

// this line is used by starport scaffolding # 1

cmd.AddCommand(CmdAdmins(), CmdArchivedProposals())
cmd.AddCommand(CmdAdmins(), CmdArchivedProposals(), CmdArchivedProposalsLegacy())

return cmd
}
33 changes: 32 additions & 1 deletion x/adminmodule/client/cli/query_archived_proposals.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package cli

import (
"github.com/spf13/cobra"
"strconv"

"github.com/spf13/cobra"

"github.com/cosmos/admin-module/x/adminmodule/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
Expand Down Expand Up @@ -40,3 +41,33 @@ func CmdArchivedProposals() *cobra.Command {

return cmd
}

func CmdArchivedProposalsLegacy() *cobra.Command {
cmd := &cobra.Command{
Use: "archivedproposalslegacy",
Short: "Query archived proposals legacy",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add more info to the errors pls

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Literally any x/ (both neutron & non-neutron) cmd function written this way. is there a reason to do this in a single one?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's do our best to not increase this chaos. I'd like our code to be well-written. I don't ask you to rewrite all x/ returned errors this way, just to make the ones you write like that

}

queryClient := types.NewQueryClient(clientCtx)

params := &types.QueryArchivedProposalsLegacyRequest{}

res, err := queryClient.ArchivedProposalsLegacy(cmd.Context(), params)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
2 changes: 1 addition & 1 deletion x/adminmodule/client/cli/tx_client_update_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewCmdSubmitUpdateClientProposal() *cobra.Command {

from := clientCtx.GetFromAddress()

msg, err := types.NewMsgSubmitProposal(content, from)
msg, err := types.NewMsgSubmitProposalLegacy(content, from)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion x/adminmodule/client/cli/tx_ibc_upgrade_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func NewCmdSubmitIbcClientUpgradeProposal() *cobra.Command {

from := clientCtx.GetFromAddress()

msg, err := types.NewMsgSubmitProposal(content, from)
msg, err := types.NewMsgSubmitProposalLegacy(content, from)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions x/adminmodule/client/cli/tx_software_upgrade_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewCmdSubmitUpgradeProposal() *cobra.Command {

from := clientCtx.GetFromAddress()

msg, err := types.NewMsgSubmitProposal(content, from)
msg, err := types.NewMsgSubmitProposalLegacy(content, from)
if err != nil {
return err
}
Expand Down Expand Up @@ -93,7 +93,7 @@ func NewCmdSubmitCancelUpgradeProposal() *cobra.Command {

content := upgradetypes.NewCancelSoftwareUpgradeProposal(title, description)

msg, err := types.NewMsgSubmitProposal(content, from)
msg, err := types.NewMsgSubmitProposalLegacy(content, from)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Where proposal.json contains:
proposal.Title, proposal.Description, proposal.Changes.ToParamChanges(),
)

msg, err := types.NewMsgSubmitProposal(content, from)
msg, err := types.NewMsgSubmitProposalLegacy(content, from)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion x/adminmodule/client/cli/tx_submit_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ $ %s tx adminmodule submit-proposal --title="Test Proposal" --description="My aw

content, _ := govv1types.ContentFromProposalType(proposal.Title, proposal.Description, proposal.Type)

msg, err := types.NewMsgSubmitProposal(content, clientCtx.GetFromAddress())
msg, err := types.NewMsgSubmitProposalLegacy(content, clientCtx.GetFromAddress())
if err != nil {
return fmt.Errorf("invalid message: %w", err)
}
Expand Down
1 change: 1 addition & 0 deletions x/adminmodule/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState)
k.SetAdmin(ctx, admin)
}
k.SetProposalID(ctx, 1)
k.SetProposalIDLegacy(ctx, 1)
}

// ExportGenesis returns the capability module's exported genesis.
Expand Down
11 changes: 11 additions & 0 deletions x/adminmodule/keeper/grpc_query_archived_proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"

"github.com/cosmos/admin-module/x/adminmodule/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"google.golang.org/grpc/codes"
Expand All @@ -17,3 +18,13 @@ func (k Keeper) ArchivedProposals(goCtx context.Context, req *types.QueryArchive
Proposals: proposals,
}, nil
}

func (k Keeper) ArchivedProposalsLegacy(goCtx context.Context, req *types.QueryArchivedProposalsLegacyRequest) (*types.QueryArchivedProposalsLegacyResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
proposals := k.GetArchivedProposalsLegacy(sdk.UnwrapSDKContext(goCtx))
return &types.QueryArchivedProposalsLegacyResponse{
ProposalsLegacy: proposals,
}, nil
}
Loading