-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(gov): app-wiring for x/gov #12369
Merged
Merged
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5255833
feat(gov): app-wiring in gov WIP
kocubinski b41e56a
Return gov handler from params module as output
kocubinski 7338ccc
fix x/distribution types
kocubinski 1ca6333
wip x/gov
kocubinski 9648308
refactor usages of gov keeper to pointer
kocubinski 86e89f0
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/g…
kocubinski 638a31b
Add gov module to golang app config
kocubinski 190d012
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/g…
kocubinski 16bf8a0
Remove unneeded dependencies
kocubinski ee2b8fb
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/g…
kocubinski 4c79c5e
remove initParamsKeeper from simapp/app.go
kocubinski 8ade797
Changelog entry & refactor module input/output
kocubinski f5f0db8
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/g…
kocubinski 924d49b
Move provideKeyTable back to x/gov
kocubinski 830f48f
better impl of keyTable provider
kocubinski 2453e17
clean up subspace provider
kocubinski bfbb0d9
Merge branch 'main' into kocubinski/gov-app-wiring
julienrbrt 995ec82
Merge branch 'main' into kocubinski/gov-app-wiring
julienrbrt e4bd03c
Merge branch 'main' into kocubinski/gov-app-wiring
julienrbrt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
syntax = "proto3"; | ||
|
||
package cosmos.gov.module.v1; | ||
|
||
import "cosmos/app/v1alpha1/module.proto"; | ||
|
||
// Module is the config object of the gov module. | ||
message Module { | ||
option (cosmos.app.v1alpha1.module) = { | ||
go_import: "github.com/cosmos/cosmos-sdk/x/gov" | ||
}; | ||
|
||
uint64 max_metadata_len = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,16 @@ package gov | |
|
||
import ( | ||
"context" | ||
modulev1 "cosmossdk.io/api/cosmos/gov/module/v1" | ||
"cosmossdk.io/core/appmodule" | ||
"encoding/json" | ||
"fmt" | ||
"github.com/cosmos/cosmos-sdk/baseapp" | ||
"github.com/cosmos/cosmos-sdk/runtime" | ||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
"math/rand" | ||
|
||
"github.com/grpc-ecosystem/grpc-gateway/runtime" | ||
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" | ||
"github.com/spf13/cobra" | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
|
||
|
@@ -74,7 +79,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod | |
} | ||
|
||
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the gov module. | ||
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { | ||
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) { | ||
if err := v1.RegisterQueryHandlerClient(context.Background(), mux, v1.NewQueryClient(clientCtx)); err != nil { | ||
panic(err) | ||
} | ||
|
@@ -128,6 +133,47 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, | |
} | ||
} | ||
|
||
func init() { | ||
appmodule.Register( | ||
&modulev1.Module{}, | ||
appmodule.Provide(provideModuleBasic, provideModule), | ||
appmodule.Invoke(invokeAddRoutes)) | ||
} | ||
|
||
func provideModuleBasic() runtime.AppModuleBasicWrapper { | ||
return runtime.WrapAppModuleBasic(AppModuleBasic{}) | ||
} | ||
|
||
func provideModule( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency I'd think we should use a struct named |
||
config *modulev1.Module, | ||
cdc codec.Codec, | ||
key *store.KVStoreKey, | ||
subSpace types.ParamSubspace, | ||
msgServiceRouter *baseapp.MsgServiceRouter, | ||
ak types.AccountKeeper, | ||
bk types.BankKeeper, | ||
sk types.StakingKeeper) (runtime.AppModuleWrapper, v1beta1.RoutedHandler) { | ||
|
||
kConfig := types.DefaultConfig() | ||
if config.MaxMetadataLen != 0 { | ||
kConfig.MaxMetadataLen = config.MaxMetadataLen | ||
} | ||
|
||
k := keeper.NewKeeper(cdc, key, subSpace, ak, bk, sk, msgServiceRouter, kConfig) | ||
m := NewAppModule(cdc, k, ak, bk) | ||
return runtime.WrapAppModule(m), v1beta1.RoutedHandler{Handler: v1beta1.ProposalHandler, RouteKey: types.RouterKey} | ||
} | ||
|
||
func invokeAddRoutes( | ||
keeper keeper.Keeper, | ||
routes []v1beta1.RoutedHandler) { | ||
router := v1beta1.NewRouter() | ||
for _, r := range routes { | ||
router.AddRoute(r.RouteKey, r.Handler) | ||
} | ||
keeper.SetLegacyRouter(router) | ||
} | ||
|
||
// Name returns the gov module's name. | ||
func (AppModule) Name() string { | ||
return types.ModuleName | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -18,3 +18,11 @@ type Content interface { | |||||
// Handler defines a function that handles a proposal after it has passed the | ||||||
// governance process. | ||||||
type Handler func(ctx sdk.Context, content Content) error | ||||||
|
||||||
type RoutedHandler struct { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Handler Handler | ||||||
RouteKey string | ||||||
} | ||||||
|
||||||
// ManyPerContainer implements the depinject.ManyPerContainer interface. | ||||||
func (RoutedHandler) ManyPerContainer() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this requires a changelog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100% this is api breaking