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 autocli app wiring + remote info support #13281

Merged
merged 61 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
056417a
feat: add autocli remote services for dynamic clients
aaronc Sep 14, 2022
093057e
WIP
aaronc Sep 14, 2022
7beb25c
implement autocli service
aaronc Sep 14, 2022
f03eb1d
WIP
aaronc Sep 14, 2022
a7c0531
start adding auth options
aaronc Sep 14, 2022
f02490e
Merge branch 'main' of github.com:cosmos/cosmos-sdk into aaronc/autoc…
aaronc Sep 14, 2022
7642ee1
go.mod, proto annotations
aaronc Sep 14, 2022
ed72cc6
Merge branch 'main' of github.com:cosmos/cosmos-sdk into aaronc/autoc…
aaronc Oct 10, 2022
76bdebf
revert
aaronc Oct 10, 2022
de9dfa1
update proto files
aaronc Oct 10, 2022
c356f95
WIP
aaronc Oct 10, 2022
8e39b91
Merge branch 'main' of github.com:cosmos/cosmos-sdk into aaronc/autoc…
aaronc Oct 13, 2022
9581ac7
migrate to extension interfaces
aaronc Oct 13, 2022
e5c3221
update go mods
aaronc Oct 13, 2022
e6d9ab0
tidying up
aaronc Oct 13, 2022
fde6de8
WIP
aaronc Oct 19, 2022
e68c93b
Merge branch 'main' of github.com:cosmos/cosmos-sdk into aaronc/autoc…
aaronc Oct 19, 2022
f18b52f
add tests
aaronc Oct 19, 2022
2fa1031
Merge branch 'main' of github.com:cosmos/cosmos-sdk into aaronc/autoc…
aaronc Oct 19, 2022
c0245ad
add IsAppModule method
aaronc Oct 19, 2022
d84db81
go.mod updates
aaronc Oct 19, 2022
fee0601
go.mod updates
aaronc Oct 19, 2022
f8adf66
go.mod updates
aaronc Oct 19, 2022
6249703
feat: add autocli service proto
aaronc Oct 19, 2022
ffa49e3
protogen
aaronc Oct 19, 2022
db54c62
protogen
aaronc Oct 19, 2022
4648c0c
move to cosmos.reflection.v1
aaronc Oct 20, 2022
de513e0
docs
aaronc Oct 20, 2022
ba5365e
proto gen
aaronc Oct 20, 2022
1d8c533
proto lint
aaronc Oct 21, 2022
f9d9d0c
Merge branch 'main' into aaronc/autocli-service-proto
tac0turtle Oct 24, 2022
e10afea
Update proto/cosmos/autocli/v1/service.proto
aaronc Oct 24, 2022
8f5e3e6
address review comments
aaronc Oct 24, 2022
11ba162
Merge branch 'main' into aaronc/autocli-service-proto
aaronc Oct 24, 2022
db6c8df
Merge branch 'aaronc/autocli-service-proto' of github.com:cosmos/cosm…
aaronc Oct 24, 2022
9e7d7c0
Merge branch 'main' of github.com:cosmos/cosmos-sdk into aaronc/autoc…
aaronc Oct 25, 2022
d40f15c
WIP
aaronc Oct 25, 2022
ad1b3ad
update services
aaronc Oct 25, 2022
86af306
fix tests
aaronc Oct 25, 2022
5fa2cbf
update go.mod
aaronc Oct 25, 2022
c4e0ac0
revert
aaronc Oct 25, 2022
77fca15
fix proto-gen
aaronc Oct 25, 2022
afced96
docs
aaronc Oct 25, 2022
395be19
Merge branch 'main' into aaronc/autocli-service
aaronc Oct 25, 2022
2c389a2
Update tests/integration/runtime/query_test.go
aaronc Oct 26, 2022
e38cbcd
remove dead code
aaronc Oct 26, 2022
88aa67a
Merge remote-tracking branch 'origin/aaronc/autocli-service' into aar…
aaronc Oct 26, 2022
ca2c553
Merge branch 'main' of github.com:cosmos/cosmos-sdk into aaronc/autoc…
aaronc Oct 26, 2022
c8c049a
revert auth.NewAppModule change
aaronc Oct 26, 2022
f256fba
add godocs
aaronc Oct 26, 2022
7d2d3d4
revert
aaronc Oct 26, 2022
dccd3d6
Merge branch 'main' of github.com:cosmos/cosmos-sdk into aaronc/autoc…
aaronc Oct 26, 2022
b17c189
update go.mod's
aaronc Oct 26, 2022
48d9f22
remove pagination
aaronc Oct 26, 2022
5001bb3
revert
aaronc Oct 26, 2022
1ab237d
lint
aaronc Oct 26, 2022
1bd0ce6
tests
aaronc Oct 26, 2022
9eeba41
Merge branch 'main' of github.com:cosmos/cosmos-sdk into aaronc/autoc…
aaronc Nov 1, 2022
406c688
go mods
aaronc Nov 1, 2022
f7c3acc
`make proto-gen`
julienrbrt Nov 1, 2022
e6ea180
import group
julienrbrt Nov 1, 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
32 changes: 32 additions & 0 deletions client/v2/autocli/interface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package autocli

import (
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
"github.com/spf13/cobra"

"cosmossdk.io/core/appmodule"
)

// HasAutoCLIConfig is an AppModule extension interface for declaring autocli module options.
type HasAutoCLIConfig interface {
appmodule.AppModule

// AutoCLIOptions are the autocli module options for this module.
AutoCLIOptions() *autocliv1.ModuleOptions
}

// HasCustomQueryCommand is an AppModule extension interface for declaring a custom query command.
type HasCustomQueryCommand interface {
appmodule.AppModule

// GetQueryCmd returns a custom cobra query command for this module.
GetQueryCmd() *cobra.Command
}

// HasCustomTxCommand is an AppModule extension interface for declaring a custom tx command.
type HasCustomTxCommand interface {
appmodule.AppModule

// GetTxCmd returns a custom cobra tx command for this module.
GetTxCmd() *cobra.Command
}
6 changes: 5 additions & 1 deletion client/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module cosmossdk.io/client/v2
go 1.19

require (
cosmossdk.io/api v0.2.2
cosmossdk.io/api v0.2.3
cosmossdk.io/core v0.3.2
github.com/cosmos/cosmos-proto v1.0.0-alpha8
github.com/iancoleman/strcase v0.2.0
github.com/spf13/cobra v1.6.1
Expand All @@ -14,10 +15,13 @@ require (
)

require (
cosmossdk.io/depinject v1.0.0-alpha.3 // indirect
github.com/cosmos/gogoproto v1.4.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
golang.org/x/exp v0.0.0-20221019170559-20944726eadf // indirect
golang.org/x/net v0.0.0-20221017152216-f25eb7ecb193 // indirect
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43 // indirect
golang.org/x/text v0.3.8 // indirect
Expand Down
23 changes: 21 additions & 2 deletions client/v2/go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
cosmossdk.io/api v0.2.2 h1:eDIfykRdaxeIvfa6zi0QstHJtMGAk2zzXwMwRhZ1mUI=
cosmossdk.io/api v0.2.2/go.mod h1:7xfxe8ghXHoKj3W2oG/HcuxGVwUHN3q8piiIEiJ3CEU=
cosmossdk.io/api v0.2.3 h1:WtjmTmVIC7c/3ZVguaAcuoEQvsOHQjKk/1k1Fbxz9vA=
cosmossdk.io/api v0.2.3/go.mod h1:7xfxe8ghXHoKj3W2oG/HcuxGVwUHN3q8piiIEiJ3CEU=
cosmossdk.io/core v0.3.2 h1:KlQIufpJHJvOs7YLGTZsZcCo1WlkencDXepsr8STKZQ=
cosmossdk.io/core v0.3.2/go.mod h1:CO7vbe+evrBvHc0setFHL/u7nlY7HJGzdRSBkT/sirc=
cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z+zfw=
cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU=
github.com/alecthomas/participle/v2 v2.0.0-alpha7 h1:cK4vjj0VSgb3lN1nuKA5F7dw+1s1pWBe5bx7nNCnN+c=
github.com/cockroachdb/apd/v3 v3.1.0 h1:MK3Ow7LH0W8zkd5GMKA1PvS9qG3bWFI95WaVNfyZJ/w=
github.com/cosmos/cosmos-proto v1.0.0-alpha8 h1:d3pCRuMYYvGA5bM0ZbbjKn+AoQD4A7dyNG2wzwWalUw=
github.com/cosmos/cosmos-proto v1.0.0-alpha8/go.mod h1:6/p+Bc4O8JKeZqe0VqUGTX31eoYqemTT4C1hLCWsO7I=
github.com/cosmos/gogoproto v1.4.2 h1:UeGRcmFW41l0G0MiefWhkPEVEwvu78SZsHBvI78dAYw=
github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cucumber/common/gherkin/go/v22 v22.0.0 h1:4K8NqptbvdOrjL9DEea6HFjSpbdT9+Q5kgLpmmsHYl0=
github.com/cucumber/common/messages/go/v17 v17.1.1 h1:RNqopvIFyLWnKv0LfATh34SWBhXeoFTJnSrgm9cT/Ts=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
Expand All @@ -15,15 +25,22 @@ github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHL
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/regen-network/gocuke v0.6.2 h1:pHviZ0kKAq2U2hN2q3smKNxct6hS0mGByFMHGnWA97M=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20221019170559-20944726eadf h1:nFVjjKDgNY37+ZSYCJmtYf7tOlfQswHqplG2eosjOMg=
golang.org/x/exp v0.0.0-20221019170559-20944726eadf/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
Expand Down Expand Up @@ -58,6 +75,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o=
gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g=
pgregory.net/rapid v0.5.3 h1:163N50IHFqr1phZens4FQOdPgfJscR7a562mjQqeo4M=
2 changes: 1 addition & 1 deletion core/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module cosmossdk.io/core
go 1.19

require (
cosmossdk.io/api v0.2.2
cosmossdk.io/api v0.2.3
cosmossdk.io/depinject v1.0.0-alpha.3
cosmossdk.io/math v1.0.0-beta.3
github.com/cosmos/cosmos-proto v1.0.0-alpha8
Expand Down
4 changes: 2 additions & 2 deletions core/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cosmossdk.io/api v0.2.2 h1:eDIfykRdaxeIvfa6zi0QstHJtMGAk2zzXwMwRhZ1mUI=
cosmossdk.io/api v0.2.2/go.mod h1:7xfxe8ghXHoKj3W2oG/HcuxGVwUHN3q8piiIEiJ3CEU=
cosmossdk.io/api v0.2.3 h1:WtjmTmVIC7c/3ZVguaAcuoEQvsOHQjKk/1k1Fbxz9vA=
cosmossdk.io/api v0.2.3/go.mod h1:7xfxe8ghXHoKj3W2oG/HcuxGVwUHN3q8piiIEiJ3CEU=
cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z+zfw=
cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU=
github.com/alecthomas/participle/v2 v2.0.0-alpha7 h1:cK4vjj0VSgb3lN1nuKA5F7dw+1s1pWBe5bx7nNCnN+c=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ go 1.19
module github.com/cosmos/cosmos-sdk

require (
cosmossdk.io/api v0.2.2
cosmossdk.io/api v0.2.3
cosmossdk.io/core v0.3.2
cosmossdk.io/depinject v1.0.0-alpha.3
cosmossdk.io/errors v1.0.0-beta.7
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0 h1:6RRlFMv1omScs6iq2hfE3IvgE+l6RfJPampq8UZc5TU=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
cosmossdk.io/api v0.2.2 h1:eDIfykRdaxeIvfa6zi0QstHJtMGAk2zzXwMwRhZ1mUI=
cosmossdk.io/api v0.2.2/go.mod h1:7xfxe8ghXHoKj3W2oG/HcuxGVwUHN3q8piiIEiJ3CEU=
cosmossdk.io/api v0.2.3 h1:WtjmTmVIC7c/3ZVguaAcuoEQvsOHQjKk/1k1Fbxz9vA=
cosmossdk.io/api v0.2.3/go.mod h1:7xfxe8ghXHoKj3W2oG/HcuxGVwUHN3q8piiIEiJ3CEU=
cosmossdk.io/core v0.3.2 h1:KlQIufpJHJvOs7YLGTZsZcCo1WlkencDXepsr8STKZQ=
cosmossdk.io/core v0.3.2/go.mod h1:CO7vbe+evrBvHc0setFHL/u7nlY7HJGzdRSBkT/sirc=
cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z+zfw=
Expand Down
2 changes: 1 addition & 1 deletion orm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/cosmos/cosmos-sdk/orm
go 1.19

require (
cosmossdk.io/api v0.2.2
cosmossdk.io/api v0.2.3
cosmossdk.io/errors v1.0.0-beta.7
github.com/cosmos/cosmos-proto v1.0.0-alpha8
github.com/golang/mock v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions orm/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cosmossdk.io/api v0.2.2 h1:eDIfykRdaxeIvfa6zi0QstHJtMGAk2zzXwMwRhZ1mUI=
cosmossdk.io/api v0.2.2/go.mod h1:7xfxe8ghXHoKj3W2oG/HcuxGVwUHN3q8piiIEiJ3CEU=
cosmossdk.io/api v0.2.3 h1:WtjmTmVIC7c/3ZVguaAcuoEQvsOHQjKk/1k1Fbxz9vA=
cosmossdk.io/api v0.2.3/go.mod h1:7xfxe8ghXHoKj3W2oG/HcuxGVwUHN3q8piiIEiJ3CEU=
cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w=
cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
Expand Down
14 changes: 13 additions & 1 deletion runtime/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import (
"encoding/json"
"fmt"

runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1"
abci "github.com/tendermint/tendermint/abci/types"
"golang.org/x/exp/slices"

runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1"
"cosmossdk.io/core/appmodule"

appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
Expand Down Expand Up @@ -49,6 +53,8 @@ type App struct {
endBlockers []func(sdk.Context, abci.RequestEndBlock) []abci.ValidatorUpdate
baseAppOptions []BaseAppOption
msgServiceRouter *baseapp.MsgServiceRouter
appConfig *appv1alpha1.Config
appModules map[string]appmodule.AppModule
}

// RegisterModules registers the provided modules with the module manager and
Expand Down Expand Up @@ -76,6 +82,12 @@ func (a *App) RegisterModules(modules ...module.AppModule) error {

// Load finishes all initialization operations and loads the app.
func (a *App) Load(loadLatest bool) error {
// register runtime module services
err := a.registerRuntimeServices()
if err != nil {
return err
}

a.configurator = module.NewConfigurator(a.cdc, a.MsgServiceRouter(), a.GRPCQueryRouter())
a.ModuleManager.RegisterServices(a.configurator)

Expand Down
23 changes: 23 additions & 0 deletions runtime/internal/services/app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package services

import (
"context"

appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
)

// AppQueryService implements the cosmos.app.v1alpha1.Query service
type AppQueryService struct {
appv1alpha1.UnimplementedQueryServer
appConfig *appv1alpha1.Config
}

func NewAppQueryService(appConfig *appv1alpha1.Config) *AppQueryService {
return &AppQueryService{appConfig: appConfig}
}

func (a *AppQueryService) Config(context.Context, *appv1alpha1.QueryConfigRequest) (*appv1alpha1.QueryConfigResponse, error) {
return &appv1alpha1.QueryConfigResponse{Config: a.appConfig}, nil
}

var _ appv1alpha1.QueryServer = &AppQueryService{}
37 changes: 37 additions & 0 deletions runtime/internal/services/autocli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package services

import (
"context"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
"cosmossdk.io/core/appmodule"
)

// AutoCLIQueryService implements the cosmos.autocli.v1.Query service.
type AutoCLIQueryService struct {
autocliv1.UnimplementedQueryServer
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved

moduleOptions map[string]*autocliv1.ModuleOptions
}

func NewAutoCLIQueryService(appModules map[string]appmodule.AppModule) *AutoCLIQueryService {
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
moduleOptions := map[string]*autocliv1.ModuleOptions{}
for modName, mod := range appModules {
if autoCliMod, ok := mod.(interface {
AutoCLIOptions() *autocliv1.ModuleOptions
}); ok {
moduleOptions[modName] = autoCliMod.AutoCLIOptions()
}
}
Comment on lines +19 to +25

Check failure

Code scanning / gosec

the value in the range statement should be _ unless copying a map: want: for key := range m

the value in the range statement should be _ unless copying a map: want: for key := range m
Comment on lines +19 to +25

Check warning

Code scanning / CodeQL

Iteration over map

Iteration over map may be a possible source of non-determinism
return &AutoCLIQueryService{
moduleOptions: moduleOptions,
}
}

func (a AutoCLIQueryService) AppOptions(context.Context, *autocliv1.AppOptionsRequest) (*autocliv1.AppOptionsResponse, error) {
return &autocliv1.AppOptionsResponse{
ModuleOptions: a.moduleOptions,
}, nil
}

var _ autocliv1.QueryServer = &AutoCLIQueryService{}
73 changes: 73 additions & 0 deletions runtime/internal/services/reflection.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package services

import (
"bytes"
"compress/gzip"
"context"
"io"

reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"github.com/cosmos/gogoproto/proto"
"golang.org/x/exp/slices"
protov2 "google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protodesc"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/reflect/protoregistry"
"google.golang.org/protobuf/types/descriptorpb"
)

// ReflectionService implements the cosmos.reflection.v1 service.
type ReflectionService struct {
reflectionv1.UnimplementedReflectionServiceServer
files *descriptorpb.FileDescriptorSet
}

func NewReflectionService() (*ReflectionService, error) {
fds := &descriptorpb.FileDescriptorSet{}

// load gogo proto file descriptors
allFds := proto.AllFileDescriptors()
haveFileDescriptor := map[string]bool{}
for _, compressedBz := range allFds {
rdr, err := gzip.NewReader(bytes.NewReader(compressedBz))
if err != nil {
return nil, err
}

bz, err := io.ReadAll(rdr)
if err != nil {
return nil, err
}

fd := &descriptorpb.FileDescriptorProto{}
err = protov2.Unmarshal(bz, fd)
if err != nil {
return nil, err
}

fds.File = append(fds.File, fd)
haveFileDescriptor[*fd.Name] = true
}
Comment on lines +31 to +50

Check failure

Code scanning / gosec

the value in the range statement should be _ unless copying a map: want: for key := range m

expected exactly 1 statement (either append, delete, or copying to another map) in a range with a map, got 9
Comment on lines +31 to +50

Check warning

Code scanning / CodeQL

Iteration over map

Iteration over map may be a possible source of non-determinism

// load any protoregistry file descriptors not in gogo
protoregistry.GlobalFiles.RangeFiles(func(fileDescriptor protoreflect.FileDescriptor) bool {
if !haveFileDescriptor[fileDescriptor.Path()] {
fds.File = append(fds.File, protodesc.ToFileDescriptorProto(fileDescriptor))
}
return true
})

slices.SortFunc(fds.File, func(x, y *descriptorpb.FileDescriptorProto) bool {
return *x.Name < *y.Name
})

return &ReflectionService{files: fds}, nil
}

func (r ReflectionService) FileDescriptors(_ context.Context, _ *reflectionv1.FileDescriptorsRequest) (*reflectionv1.FileDescriptorsResponse, error) {
return &reflectionv1.FileDescriptorsResponse{
Files: r.files.File,
}, nil
}

var _ reflectionv1.ReflectionServiceServer = &ReflectionService{}
10 changes: 8 additions & 2 deletions runtime/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import (

abci "github.com/tendermint/tendermint/abci/types"

runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/depinject"

"cosmossdk.io/core/appmodule"

runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1"
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand Down Expand Up @@ -77,10 +79,12 @@ func ProvideCodecs(moduleBasics map[string]AppModuleBasicWrapper) (
type appInputs struct {
depinject.In

AppConfig *appv1alpha1.Config
Config *runtimev1alpha1.Module
AppBuilder *AppBuilder
Modules map[string]AppModuleWrapper
BaseAppOptions []BaseAppOption
AppModules map[string]appmodule.AppModule
}

func SetupAppBuilder(inputs appInputs) {
Expand All @@ -92,6 +96,8 @@ func SetupAppBuilder(inputs appInputs) {
app.baseAppOptions = inputs.BaseAppOptions
app.config = inputs.Config
app.ModuleManager = mm
app.appConfig = inputs.AppConfig
app.appModules = inputs.AppModules
}

func registerStoreKey(wrapper *AppBuilder, key storetypes.StoreKey) {
Expand Down
22 changes: 22 additions & 0 deletions runtime/services.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package runtime

import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"

"github.com/cosmos/cosmos-sdk/runtime/internal/services"
)

func (a *App) registerRuntimeServices() error {
appv1alpha1.RegisterQueryServer(a.GRPCQueryRouter(), services.NewAppQueryService(a.appConfig))
autocliv1.RegisterQueryServer(a.GRPCQueryRouter(), services.NewAutoCLIQueryService(a.appModules))

reflectionSvc, err := services.NewReflectionService()
if err != nil {
return err
}
reflectionv1.RegisterReflectionServiceServer(a.GRPCQueryRouter(), reflectionSvc)

return nil
}
Loading