Skip to content
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: add MsgWithdrawProposal to group module #10893

Merged
merged 234 commits into from
Feb 4, 2022
Merged
Changes from 1 commit
Commits
Show all changes
234 commits
Select commit Hold shift + click to select a range
32cb63a
remove Request suffix from Msg types
likhita-809 Oct 29, 2021
fe6a8d5
wip
likhita-809 Nov 8, 2021
246484e
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Nov 8, 2021
e274069
wip
likhita-809 Nov 9, 2021
4203f24
wip
likhita-809 Nov 9, 2021
743520c
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Nov 9, 2021
3f4179e
wip
likhita-809 Nov 9, 2021
acad315
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Nov 17, 2021
be27cba
wip
likhita-809 Nov 18, 2021
71c2dee
run go mod tidy
likhita-809 Nov 18, 2021
a864359
small change
likhita-809 Nov 18, 2021
18794db
wip
likhita-809 Nov 22, 2021
3851900
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Nov 22, 2021
36b07b3
wip
likhita-809 Nov 22, 2021
efb22ee
fix something
likhita-809 Nov 22, 2021
1edaf8c
wip
likhita-809 Nov 23, 2021
3d5c37d
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Nov 23, 2021
87054b8
wip
likhita-809 Nov 23, 2021
164a153
wip
likhita-809 Nov 23, 2021
0f6028b
run go mod tidy
likhita-809 Nov 23, 2021
d4156a2
wip
likhita-809 Nov 23, 2021
c473327
wip
likhita-809 Nov 23, 2021
491ff91
fix tests
likhita-809 Nov 23, 2021
8bcbbf7
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Nov 24, 2021
ec93341
add keeper tests
likhita-809 Nov 25, 2021
624726b
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Nov 25, 2021
ac4e247
address comments
likhita-809 Nov 25, 2021
f8a74b6
use single MsgServiceRouter
likhita-809 Nov 25, 2021
308852e
address review comments
likhita-809 Nov 25, 2021
f5fdbea
fix something
likhita-809 Nov 25, 2021
2c405d3
Update import
blushi Nov 25, 2021
100c4f4
delete conditions.go file
likhita-809 Nov 25, 2021
977c94e
Merge branch 'likhita/group-server-implementation' of https://github.…
likhita-809 Nov 25, 2021
ca772c6
fix something
likhita-809 Nov 25, 2021
020e58f
add func to run TestSuite
likhita-809 Nov 25, 2021
140fbb8
Set accKeeper in group keeper
blushi Nov 25, 2021
abbe3ba
update keeper_test
likhita-809 Nov 25, 2021
8ed012a
Merge branch 'likhita/group-server-implementation' of https://github.…
likhita-809 Nov 25, 2021
bf9a57f
Fix timeout duration in test
blushi Nov 25, 2021
d11be84
Fix get group account
blushi Nov 25, 2021
edaa1c7
fix failed test case in keeper
likhita-809 Nov 26, 2021
177ac08
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Nov 26, 2021
50f3241
Fix some tests
blushi Nov 26, 2021
2c3a4c0
Merge branch 'likhita/group-server-implementation' of github.com:cosm…
blushi Nov 26, 2021
66db140
Rm unneeded set policy
blushi Nov 26, 2021
410e96d
Fix more tests related to ctx not being cached
blushi Nov 26, 2021
d76908e
Fix keeper_tests
blushi Nov 29, 2021
8c1f888
Rm derivation key
blushi Nov 29, 2021
334c667
Merge branch 'master' into likhita/group-server-implementation
blushi Nov 29, 2021
2f7f72c
proto-gen
blushi Nov 29, 2021
00b8cdb
go mod tidy
blushi Nov 29, 2021
9c614ab
Merge branch 'likhita/group-server-implementation' of https://github.…
likhita-809 Nov 30, 2021
f44a1e6
add genesis proto files
likhita-809 Nov 30, 2021
ae4f551
add genesis import/export
likhita-809 Nov 30, 2021
952743d
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Nov 30, 2021
0782451
proto-gen
likhita-809 Nov 30, 2021
1e6cc91
few changes to genesis files
likhita-809 Dec 1, 2021
10cefb7
Update proto wip
blushi Dec 1, 2021
1501297
Merge branch 'master' into likhita/group-server-implementation
blushi Dec 1, 2021
8a0f415
Fix tests
blushi Dec 1, 2021
52fad21
proto lint
blushi Dec 1, 2021
318d527
go mod tidy
blushi Dec 1, 2021
799d411
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Dec 2, 2021
5921731
Merge branch 'likhita/add-group-genesis' of https://github.com/cosmos…
likhita-809 Dec 2, 2021
22d706e
add genesis tests
likhita-809 Dec 2, 2021
7c3f392
Merge branch 'likhita/add-group-genesis' of https://github.com/cosmos…
likhita-809 Dec 2, 2021
fef1c22
fix failing tests
likhita-809 Dec 2, 2021
b60e179
go mdo tidy
likhita-809 Dec 2, 2021
e2e26d0
Use existing TestMsg
blushi Dec 2, 2021
bdfa1f8
Merge branch 'master' into likhita/group-server-implementation
blushi Dec 2, 2021
12a2f32
go mod
blushi Dec 2, 2021
5422f59
Update x/group/keeper/msg_server.go
blushi Dec 2, 2021
6c8886d
Address review comments
blushi Dec 2, 2021
de9584d
Merge branch 'likhita/group-server-implementation' of github.com:cosm…
blushi Dec 2, 2021
b6442dc
tidy
blushi Dec 2, 2021
1b91a39
group module changes for genesis
likhita-809 Dec 2, 2021
9995ce1
remove unused imports
likhita-809 Dec 2, 2021
48c10a1
Merge branch 'master' into likhita/group-server-implementation
likhita-809 Dec 6, 2021
a4a8d8d
register group in stores
likhita-809 Dec 6, 2021
58ae1ac
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Dec 6, 2021
7cdeccc
Use BigEndian
blushi Dec 8, 2021
9bbcaba
Merge branch 'master' into likhita/group-server-implementation
blushi Dec 8, 2021
8994138
address review comments
likhita-809 Dec 8, 2021
3876313
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Dec 8, 2021
daa70d9
small change
likhita-809 Dec 8, 2021
f911eda
Merge branch 'master' into likhita/group-server-implementation
blushi Dec 9, 2021
4ecc776
Merge branch 'likhita/group-server-implementation' into likhita/add-g…
blushi Dec 9, 2021
65d962d
Fix tests
blushi Dec 9, 2021
81dd664
Use derivation for group acc addr
blushi Dec 9, 2021
ecb2cbc
Merge branch 'likhita/add-group-genesis' into marie/9901-group-sim
blushi Dec 9, 2021
f00433e
Add simulation WIP
blushi Dec 9, 2021
503c6b0
Fix operations and wire up random gen
blushi Dec 9, 2021
26435ec
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Dec 10, 2021
b38c26d
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Dec 10, 2021
6c72bd5
go mod tidy
likhita-809 Dec 10, 2021
82130f8
Decoder tests WIP
blushi Dec 10, 2021
9f0b1e9
Merge branch 'master' into likhita/group-server-implementation
blushi Dec 10, 2021
0cde5c3
Merge branch 'likhita/group-server-implementation' into marie/9901-gr…
blushi Dec 10, 2021
fa6ed11
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Dec 11, 2021
d473d87
fix something
likhita-809 Dec 11, 2021
140804c
fix something
likhita-809 Dec 11, 2021
026d396
fix some tests
likhita-809 Dec 14, 2021
4165132
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Dec 14, 2021
81f7f9a
go mod tidy
likhita-809 Dec 14, 2021
ef71946
fix tests
atheeshp Dec 15, 2021
6ea57af
fix test
atheeshp Dec 15, 2021
6b34c6c
fix tests
likhita-809 Dec 15, 2021
e3f6b6b
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Dec 15, 2021
8298b4a
refactor keeper test
likhita-809 Dec 15, 2021
7aa07b3
Merge branch 'master' into marie/9901-group-sim
blushi Dec 16, 2021
55450e2
Fix simapp
blushi Dec 16, 2021
d1cf191
Add group sim tests wip
blushi Dec 16, 2021
a902aa3
tidy
blushi Dec 16, 2021
3afe8e9
fix tests
likhita-809 Dec 16, 2021
cf8bb27
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Dec 16, 2021
ef4959e
go mod tidy
likhita-809 Dec 16, 2021
33dcaf2
revert keeper_test
likhita-809 Dec 16, 2021
fc80e7d
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Dec 16, 2021
3c1cb40
Merge branch 'master' into likhita/add-group-genesis
likhita-809 Dec 17, 2021
82264ba
address review comment
likhita-809 Dec 17, 2021
c8ffac7
Merge branch 'likhita/add-group-genesis' of https://github.com/cosmos…
likhita-809 Dec 17, 2021
51487d1
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Dec 19, 2021
e1305ca
go mod tidy
likhita-809 Dec 20, 2021
3b3737e
add genesis validation and related tests
likhita-809 Dec 22, 2021
910c9d9
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Dec 22, 2021
53db0f4
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Dec 22, 2021
05d4a1e
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Dec 23, 2021
ba3b5cb
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Jan 3, 2022
a99f140
go mod tidy
likhita-809 Jan 3, 2022
5ed1c54
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Jan 3, 2022
582e6ca
Merge branch 'master' into likhita/add-group-genesis
likhita-809 Jan 4, 2022
d369722
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Jan 5, 2022
4be1df8
Merge branch 'likhita/add-group-genesis' of https://github.com/cosmos…
likhita-809 Jan 5, 2022
08984fb
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Jan 5, 2022
e7cd038
rename group account to group policy in group genesis
likhita-809 Jan 5, 2022
c53d6d9
address few comments
likhita-809 Jan 5, 2022
2042000
add `MsgWithdrawProposal` (WIP)
atheeshp Jan 6, 2022
79f293e
address review comments
likhita-809 Jan 6, 2022
df98bf6
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Jan 6, 2022
f726f29
fix few tests
likhita-809 Jan 6, 2022
2998fae
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Jan 6, 2022
58eea10
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into li…
likhita-809 Jan 6, 2022
753ba43
add `msg_server`and tests
atheeshp Jan 6, 2022
c1ffd12
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ap/withdra…
atheeshp Jan 6, 2022
e2c3a41
wip on operations test
blushi Jan 6, 2022
5b189e1
Wrap up operations
blushi Jan 6, 2022
f9935ad
Merge branch 'master' into marie/9901-group-sim
blushi Jan 6, 2022
0d3a14d
Merge branch 'likhita/add-group-genesis' into marie/9901-group-sim
blushi Jan 6, 2022
51c0d4b
Fix SimulateMsgCreateProposal
blushi Jan 7, 2022
b13667e
Fix rand
blushi Jan 7, 2022
8ad58fb
Return no op for proposals that cannot pass
blushi Jan 7, 2022
95ceeca
Fix SimulateMsgVote
blushi Jan 7, 2022
eb3dbcf
add cli & tests
atheeshp Jan 10, 2022
42178c9
make proto-gen
atheeshp Jan 10, 2022
18123a6
add changelog
atheeshp Jan 10, 2022
c6634ea
Merge branch 'master' into marie/9901-group-sim
blushi Jan 11, 2022
697a627
Add logs
blushi Jan 13, 2022
253af3a
Merge branch 'master' into marie/9901-group-sim
blushi Jan 13, 2022
713bb12
Return no-op if group/group policy modified
blushi Jan 13, 2022
6ed7d36
Fix group msgs tests
blushi Jan 13, 2022
4397cb3
Rm unused
blushi Jan 13, 2022
9cdf0e8
Fix params test
blushi Jan 13, 2022
8abec3d
Fix no op
blushi Jan 13, 2022
c6fd43e
Filter member that already voted
blushi Jan 13, 2022
1653193
Fix non determinism in genesis
blushi Jan 14, 2022
dda857f
Clean up
blushi Jan 14, 2022
4bf6498
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ap/withdra…
atheeshp Jan 18, 2022
68584a4
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ap/withdra…
atheeshp Jan 19, 2022
c248c0c
update changes
atheeshp Jan 19, 2022
cb01bed
go mod tidy
atheeshp Jan 19, 2022
71bdd7f
Merge branch 'master' into marie/9901-group-sim
blushi Jan 19, 2022
c61d5a8
Update x/group/simulation/operations.go
blushi Jan 19, 2022
dcc37bb
Update x/group/simulation/operations.go
blushi Jan 19, 2022
2b33115
Update x/group/simulation/operations.go
blushi Jan 19, 2022
9c34681
Update x/group/simulation/operations.go
blushi Jan 19, 2022
bfa87c5
Update x/group/simulation/operations.go
blushi Jan 19, 2022
4ea9242
Apply suggestions from code review
blushi Jan 19, 2022
43dccdc
review changes
atheeshp Jan 19, 2022
ee55bf7
review changes
atheeshp Jan 19, 2022
844bf2e
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ap/withdra…
atheeshp Jan 19, 2022
7fa623c
fix tests
atheeshp Jan 19, 2022
9322f83
fix tests
atheeshp Jan 19, 2022
b53b4ea
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ap/withdra…
atheeshp Jan 19, 2022
c6f2e14
review changes
atheeshp Jan 19, 2022
2eec4e2
Merge branch 'master' into marie/9901-group-sim
blushi Jan 19, 2022
0c6c2e7
Merge branch 'master' into marie/9901-group-sim
blushi Jan 20, 2022
5a9ac71
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ap/withdra…
atheeshp Jan 20, 2022
f2d6f0e
review changes
atheeshp Jan 20, 2022
6cb665f
update docs
atheeshp Jan 20, 2022
5c21a97
Fix msg type name
blushi Jan 20, 2022
18cc425
Update x/group/simulation/decoder.go
blushi Jan 20, 2022
eccfd84
Merge branch 'master' into marie/9901-group-sim
blushi Jan 20, 2022
f6db995
Merge branch 'master' into marie/9901-group-sim
blushi Jan 21, 2022
0af0bb3
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ap/withdra…
atheeshp Jan 21, 2022
6377622
add msg tests
atheeshp Jan 21, 2022
df92ff9
Merge branch 'marie/9901-group-sim' of github.com:cosmos/cosmos-sdk i…
atheeshp Jan 21, 2022
40265d2
update simulations
atheeshp Jan 21, 2022
181205e
update tests
atheeshp Jan 21, 2022
7bf7608
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ap/withdra…
atheeshp Jan 24, 2022
aa8de8f
Merge branch 'ap/withdraw-proposal-sims' of github.com:cosmos/cosmos-…
atheeshp Jan 24, 2022
cd5cf33
Merge branch 'master' into ap/withdraw-proposal
atheeshp Jan 25, 2022
f08a2ec
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ap/withdra…
atheeshp Jan 25, 2022
bd0e7bb
Merge branch 'ap/withdraw-proposal' of github.com:cosmos/cosmos-sdk i…
atheeshp Jan 25, 2022
e945fc6
fix sims
atheeshp Jan 25, 2022
e920e9b
fix sim
atheeshp Jan 25, 2022
c5311dd
fix test
atheeshp Jan 25, 2022
79a44a9
udpate tests
atheeshp Jan 25, 2022
523eaf9
Merge branch 'master' into ap/withdraw-proposal
atheeshp Jan 25, 2022
1f4edf4
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ap/withdra…
atheeshp Jan 25, 2022
2a3253c
fix tests
atheeshp Jan 25, 2022
4d5dfe8
Merge branch 'ap/withdraw-proposal' of github.com:cosmos/cosmos-sdk i…
atheeshp Jan 25, 2022
0b9ccd4
update tests
atheeshp Jan 25, 2022
4e8941f
update tests
atheeshp Jan 25, 2022
6a2f3c3
fix tests
atheeshp Jan 25, 2022
fcb07ef
Merge branch 'master' into ap/withdraw-proposal
atheeshp Jan 25, 2022
d410b3b
review change
atheeshp Jan 25, 2022
4fd5fb0
Merge branch 'ap/withdraw-proposal' of github.com:cosmos/cosmos-sdk i…
atheeshp Jan 25, 2022
0c3ef62
fix tests
atheeshp Jan 25, 2022
968557e
update tests
atheeshp Jan 25, 2022
a2ebb2a
Update x/group/simulation/operations.go
atheeshp Jan 26, 2022
15c0e7e
Merge branch 'master' into ap/withdraw-proposal
atheeshp Jan 26, 2022
f2737a7
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ap/withdra…
atheeshp Jan 27, 2022
9ee10b9
Merge branch 'master' into ap/withdraw-proposal
atheeshp Jan 27, 2022
1511673
Merge branch 'master' into ap/withdraw-proposal
atheeshp Jan 28, 2022
342c5a4
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ap/withdra…
atheeshp Jan 31, 2022
62ebd0d
make proto-gen
atheeshp Jan 31, 2022
701bf6c
update sim
atheeshp Jan 31, 2022
d6c052a
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ap/withdra…
atheeshp Jan 31, 2022
8e32cf7
Merge branch 'ap/withdraw-proposal' of github.com:cosmos/cosmos-sdk i…
atheeshp Jan 31, 2022
fc37d74
Merge branch 'master' into ap/withdraw-proposal
atheeshp Feb 1, 2022
6e6ebd1
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ap/withdra…
atheeshp Feb 3, 2022
dbe961b
update tests
atheeshp Feb 3, 2022
b8cc814
Merge branch 'master' into ap/withdraw-proposal
amaury1093 Feb 3, 2022
d3a0a3f
Merge branch 'master' into ap/withdraw-proposal
blushi Feb 4, 2022
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
Prev Previous commit
Next Next commit
wip
  • Loading branch information
likhita-809 committed Nov 8, 2021
commit fe6a8d5a57477afd50a34781fa058ed422a061d1
17 changes: 17 additions & 0 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
@@ -49,8 +49,10 @@ type BaseApp struct { // nolint: maligned
db dbm.DB // common DB backend
cms sdk.CommitMultiStore // Main (uncached) state
storeLoader StoreLoader // function to handle store loading, may be overridden with SetStoreLoader()
router sdk.Router // handle any kind of message
queryRouter sdk.QueryRouter // router for redirecting query calls
grpcQueryRouter *GRPCQueryRouter // router for redirecting gRPC query calls
msgServiceRouter *MsgServiceRouter // router for redirecting Msg service messages
interfaceRegistry types.InterfaceRegistry
txDecoder sdk.TxDecoder // unmarshal []byte into sdk.Tx

@@ -145,6 +147,7 @@ func NewBaseApp(
db: db,
cms: store.NewCommitMultiStore(db),
storeLoader: DefaultStoreLoader,
router: NewRouter(),
queryRouter: NewQueryRouter(),
grpcQueryRouter: NewGRPCQueryRouter(),
txDecoder: txDecoder,
@@ -187,6 +190,9 @@ func (app *BaseApp) Trace() bool {
return app.trace
}

// MsgServiceRouter returns the MsgServiceRouter of a BaseApp.
func (app *BaseApp) MsgServiceRouter() *MsgServiceRouter { return app.msgServiceRouter }

// MountStores mounts all IAVL or DB stores to the provided keys in the BaseApp
// multistore.
func (app *BaseApp) MountStores(keys ...storetypes.StoreKey) {
@@ -341,6 +347,17 @@ func (app *BaseApp) setIndexEvents(ie []string) {
}
}

// Router returns the router of the BaseApp.
func (app *BaseApp) Router() sdk.Router {
if app.sealed {
// We cannot return a Router when the app is sealed because we can't have
// any routes modified which would cause unexpected routing behavior.
panic("Router() on sealed BaseApp")
}

return app.router
}

// QueryRouter returns the QueryRouter of a BaseApp.
func (app *BaseApp) QueryRouter() sdk.QueryRouter { return app.queryRouter }

140 changes: 140 additions & 0 deletions baseapp/msg_service_router.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
package baseapp

import (
"context"
"fmt"

gogogrpc "github.com/gogo/protobuf/grpc"
"github.com/gogo/protobuf/proto"
"google.golang.org/grpc"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

// MsgServiceRouter routes fully-qualified Msg service methods to their handler.
type MsgServiceRouter struct {
interfaceRegistry codectypes.InterfaceRegistry
routes map[string]MsgServiceHandler
}

var _ gogogrpc.Server = &MsgServiceRouter{}

// NewMsgServiceRouter creates a new MsgServiceRouter.
func NewMsgServiceRouter() *MsgServiceRouter {
return &MsgServiceRouter{
routes: map[string]MsgServiceHandler{},
}
}

// MsgServiceHandler defines a function type which handles Msg service message.
type MsgServiceHandler = func(ctx sdk.Context, req sdk.Msg) (*sdk.Result, error)

// Handler returns the MsgServiceHandler for a given msg or nil if not found.
func (msr *MsgServiceRouter) Handler(msg sdk.Msg) MsgServiceHandler {
return msr.routes[sdk.MsgTypeURL(msg)]
}

// HandlerByTypeURL returns the MsgServiceHandler for a given query route path or nil
// if not found.
func (msr *MsgServiceRouter) HandlerByTypeURL(typeURL string) MsgServiceHandler {
return msr.routes[typeURL]
}

// RegisterService implements the gRPC Server.RegisterService method. sd is a gRPC
// service description, handler is an object which implements that gRPC service.
//
// This function PANICs:
// - if it is called before the service `Msg`s have been registered using
// RegisterInterfaces,
// - or if a service is being registered twice.
func (msr *MsgServiceRouter) RegisterService(sd *grpc.ServiceDesc, handler interface{}) {
// Adds a top-level query handler based on the gRPC service name.
for _, method := range sd.Methods {
fqMethod := fmt.Sprintf("/%s/%s", sd.ServiceName, method.MethodName)
methodHandler := method.Handler

var requestTypeName string

// NOTE: This is how we pull the concrete request type for each handler for registering in the InterfaceRegistry.
// This approach is maybe a bit hacky, but less hacky than reflecting on the handler object itself.
// We use a no-op interceptor to avoid actually calling into the handler itself.
_, _ = methodHandler(nil, context.Background(), func(i interface{}) error {
msg, ok := i.(sdk.Msg)
if !ok {
// We panic here because there is no other alternative and the app cannot be initialized correctly
// this should only happen if there is a problem with code generation in which case the app won't
// work correctly anyway.
panic(fmt.Errorf("can't register request type %T for service method %s", i, fqMethod))
}

requestTypeName = sdk.MsgTypeURL(msg)
return nil
}, noopInterceptor)

// Check that the service Msg fully-qualified method name has already
// been registered (via RegisterInterfaces). If the user registers a
// service without registering according service Msg type, there might be
// some unexpected behavior down the road. Since we can't return an error
// (`Server.RegisterService` interface restriction) we panic (at startup).
reqType, err := msr.interfaceRegistry.Resolve(requestTypeName)
if err != nil || reqType == nil {
panic(
fmt.Errorf(
"type_url %s has not been registered yet. "+
"Before calling RegisterService, you must register all interfaces by calling the `RegisterInterfaces` "+
"method on module.BasicManager. Each module should call `msgservice.RegisterMsgServiceDesc` inside its "+
"`RegisterInterfaces` method with the `_Msg_serviceDesc` generated by proto-gen",
requestTypeName,
),
)
}

// Check that each service is only registered once. If a service is
// registered more than once, then we should error. Since we can't
// return an error (`Server.RegisterService` interface restriction) we
// panic (at startup).
_, found := msr.routes[requestTypeName]
if found {
panic(
fmt.Errorf(
"msg service %s has already been registered. Please make sure to only register each service once. "+
"This usually means that there are conflicting modules registering the same msg service",
fqMethod,
),
)
}

msr.routes[requestTypeName] = func(ctx sdk.Context, req sdk.Msg) (*sdk.Result, error) {
ctx = ctx.WithEventManager(sdk.NewEventManager())
interceptor := func(goCtx context.Context, _ interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
goCtx = context.WithValue(goCtx, sdk.SdkContextKey, ctx)
return handler(goCtx, req)
}
// Call the method handler from the service description with the handler object.
// We don't do any decoding here because the decoding was already done.
res, err := methodHandler(handler, sdk.WrapSDKContext(ctx), noopDecoder, interceptor)
if err != nil {
return nil, err
}

resMsg, ok := res.(proto.Message)
if !ok {
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "Expecting proto.Message, got %T", resMsg)
}

return sdk.WrapServiceResult(ctx, resMsg, err)
}
}
}

// SetInterfaceRegistry sets the interface registry for the router.
func (msr *MsgServiceRouter) SetInterfaceRegistry(interfaceRegistry codectypes.InterfaceRegistry) {
msr.interfaceRegistry = interfaceRegistry
}

func noopDecoder(_ interface{}) error { return nil }
func noopInterceptor(_ context.Context, _ interface{}, _ *grpc.UnaryServerInfo, _ grpc.UnaryHandler) (interface{}, error) {
return nil, nil
}
41 changes: 41 additions & 0 deletions baseapp/router.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package baseapp

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
)

type Router struct {
routes map[string]sdk.Handler
}

var _ sdk.Router = NewRouter()

// NewRouter returns a reference to a new router.
func NewRouter() *Router {
return &Router{
routes: make(map[string]sdk.Handler),
}
}

// AddRoute adds a route path to the router with a given handler. The route must
// be alphanumeric.
func (rtr *Router) AddRoute(route sdk.Route) sdk.Router {
if !sdk.IsAlphaNumeric(route.Path()) {
panic("route expressions can only contain alphanumeric characters")
}
if rtr.routes[route.Path()] != nil {
panic(fmt.Sprintf("route %s has already been initialized", route.Path()))
}

rtr.routes[route.Path()] = route.Handler()
return rtr
}

// Route returns a handler for a given route path.
//
// TODO: Handle expressive matches.
func (rtr *Router) Route(_ sdk.Context, path string) sdk.Handler {
return rtr.routes[path]
}
130 changes: 130 additions & 0 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
@@ -407,6 +407,15 @@

- [Msg](#cosmos.gov.v1beta1.Msg)

- [cosmos/group/v1beta1/events.proto](#cosmos/group/v1beta1/events.proto)
- [EventCreateGroup](#cosmos.group.v1beta1.EventCreateGroup)
- [EventCreateGroupAccount](#cosmos.group.v1beta1.EventCreateGroupAccount)
- [EventCreateProposal](#cosmos.group.v1beta1.EventCreateProposal)
- [EventExec](#cosmos.group.v1beta1.EventExec)
- [EventUpdateGroup](#cosmos.group.v1beta1.EventUpdateGroup)
- [EventUpdateGroupAccount](#cosmos.group.v1beta1.EventUpdateGroupAccount)
- [EventVote](#cosmos.group.v1beta1.EventVote)

- [cosmos/group/v1beta1/types.proto](#cosmos/group/v1beta1/types.proto)
- [GroupAccountInfo](#cosmos.group.v1beta1.GroupAccountInfo)
- [GroupInfo](#cosmos.group.v1beta1.GroupInfo)
@@ -6026,6 +6035,127 @@ Since: cosmos-sdk 0.43 | |



<a name="cosmos/group/v1beta1/events.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## cosmos/group/v1beta1/events.proto



<a name="cosmos.group.v1beta1.EventCreateGroup"></a>

### EventCreateGroup
EventCreateGroup is an event emitted when a group is created.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `group_id` | [uint64](#uint64) | | group_id is the unique ID of the group. |






<a name="cosmos.group.v1beta1.EventCreateGroupAccount"></a>

### EventCreateGroupAccount
EventCreateGroupAccount is an event emitted when a group account is created.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | address is the address of the group account. |






<a name="cosmos.group.v1beta1.EventCreateProposal"></a>

### EventCreateProposal
EventCreateProposal is an event emitted when a proposal is created.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `proposal_id` | [uint64](#uint64) | | proposal_id is the unique ID of the proposal. |






<a name="cosmos.group.v1beta1.EventExec"></a>

### EventExec
EventExec is an event emitted when a proposal is executed.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `proposal_id` | [uint64](#uint64) | | proposal_id is the unique ID of the proposal. |






<a name="cosmos.group.v1beta1.EventUpdateGroup"></a>

### EventUpdateGroup
EventUpdateGroup is an event emitted when a group is updated.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `group_id` | [uint64](#uint64) | | group_id is the unique ID of the group. |






<a name="cosmos.group.v1beta1.EventUpdateGroupAccount"></a>

### EventUpdateGroupAccount
EventUpdateGroupAccount is an event emitted when a group account is updated.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | address is the address of the group account. |






<a name="cosmos.group.v1beta1.EventVote"></a>

### EventVote
EventVote is an event emitted when a voter votes on a proposal.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `proposal_id` | [uint64](#uint64) | | proposal_id is the unique ID of the proposal. |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="cosmos/group/v1beta1/types.proto"></a>
<p align="right"><a href="#top">Top</a></p>

Loading