Skip to content

Commit 7c836df

Browse files
fadeevAlex Johnson
andauthored
fix: remove a placeholder in module.go (#2798)
Co-authored-by: Alex Johnson <alex@shmeeload.xyz>
1 parent b111136 commit 7c836df

File tree

5 files changed

+3
-89
lines changed

5 files changed

+3
-89
lines changed

docs/docs/guide/02-hello.md

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -227,39 +227,7 @@ func (k Keeper) Hello(c context.Context, req *types.QueryHelloRequest) (*types.Q
227227
```
228228

229229
- Save the file to restart your chain.
230-
- In a web browser, visit the `hello` endpoint [http://localhost:1317/hello/hello/hello](http://localhost:1317/hello/hello/hello).
231-
232-
Because the query handlers are not yet registered with gRPC, you see a not implemented or localhost cannot connect error. This error is expected behavior, because you still need to register the query handlers.
233-
234-
## Register query handlers
235-
236-
Make the required changes to the `x/hello/module.go` file.
237-
238-
1. Add `"context"` to the list of packages in the import statement.
239-
240-
```go
241-
import (
242-
// ...
243-
244-
"context"
245-
246-
// ...
247-
)
248-
```
249-
250-
Do not save the file yet, you need to continue with these modifications.
251-
252-
1. Search for `RegisterGRPCGatewayRoutes`.
253-
254-
1. Register the query handlers:
255-
256-
```go
257-
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
258-
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
259-
}
260-
```
261-
262-
2. After the chain has been started, visit [http://localhost:1317/hello/hello/hello](http://localhost:1317/hello/hello/hello) and see your text displayed:
230+
- After the chain has been started, visit [http://localhost:1317/hello/hello/hello](http://localhost:1317/hello/hello/hello) and see your text displayed:
263231

264232
```json
265233
{

ignite/templates/module/create/stargate/x/{{moduleName}}/module.go.plush

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package <%= moduleName %>
22

33
import (
4+
"context"
45
"encoding/json"
56
"fmt"
67
// this line is used by starport scaffolding # 1
@@ -71,7 +72,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
7172

7273
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module
7374
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
74-
// this line is used by starport scaffolding # 2
75+
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
7576
}
7677

7778
// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module

ignite/templates/typed/list/stargate.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ func NewStargate(replacer placeholder.Replacer, opts *typed.Options) (*genny.Gen
4949
)
5050

5151
g.RunFn(protoQueryModify(replacer, opts))
52-
g.RunFn(moduleGRPCGatewayModify(replacer, opts))
5352
g.RunFn(typesKeyModify(opts))
5453
g.RunFn(clientCliQueryModify(replacer, opts))
5554

@@ -243,22 +242,6 @@ message QueryAll%[2]vResponse {
243242
}
244243
}
245244

246-
func moduleGRPCGatewayModify(replacer placeholder.Replacer, opts *typed.Options) genny.RunFn {
247-
return func(r *genny.Runner) error {
248-
path := filepath.Join(opts.AppPath, "x", opts.ModuleName, "module.go")
249-
f, err := r.Disk.Find(path)
250-
if err != nil {
251-
return err
252-
}
253-
replacement := `"context"`
254-
content := replacer.ReplaceOnce(f.String(), typed.Placeholder, replacement)
255-
replacement = `types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))`
256-
content = replacer.ReplaceOnce(content, typed.Placeholder2, replacement)
257-
newFile := genny.NewFileS(path, content)
258-
return r.File(newFile)
259-
}
260-
}
261-
262245
func typesKeyModify(opts *typed.Options) genny.RunFn {
263246
return func(r *genny.Runner) error {
264247
path := filepath.Join(opts.AppPath, "x", opts.ModuleName, "types/keys.go")

ignite/templates/typed/map/stargate.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ func NewStargate(replacer placeholder.Replacer, opts *typed.Options) (*genny.Gen
7575
)
7676

7777
g.RunFn(protoRPCModify(replacer, opts))
78-
g.RunFn(moduleGRPCGatewayModify(replacer, opts))
7978
g.RunFn(clientCliQueryModify(replacer, opts))
8079
g.RunFn(genesisProtoModify(replacer, opts))
8180
g.RunFn(genesisTypesModify(replacer, opts))
@@ -217,24 +216,6 @@ message QueryAll%[2]vResponse {
217216
}
218217
}
219218

220-
func moduleGRPCGatewayModify(replacer placeholder.Replacer, opts *typed.Options) genny.RunFn {
221-
return func(r *genny.Runner) error {
222-
path := filepath.Join(opts.AppPath, "x", opts.ModuleName, "module.go")
223-
f, err := r.Disk.Find(path)
224-
if err != nil {
225-
return err
226-
}
227-
replacement := `"context"`
228-
content := replacer.ReplaceOnce(f.String(), typed.Placeholder, replacement)
229-
230-
replacement = `types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))`
231-
content = replacer.ReplaceOnce(content, typed.Placeholder2, replacement)
232-
233-
newFile := genny.NewFileS(path, content)
234-
return r.File(newFile)
235-
}
236-
}
237-
238219
func clientCliQueryModify(replacer placeholder.Replacer, opts *typed.Options) genny.RunFn {
239220
return func(r *genny.Runner) error {
240221
path := filepath.Join(opts.AppPath, "x", opts.ModuleName, "client/cli/query.go")

ignite/templates/typed/singleton/stargate.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ func NewStargate(replacer placeholder.Replacer, opts *typed.Options) (*genny.Gen
5151

5252
g.RunFn(typesKeyModify(opts))
5353
g.RunFn(protoRPCModify(replacer, opts))
54-
g.RunFn(moduleGRPCGatewayModify(replacer, opts))
5554
g.RunFn(clientCliQueryModify(replacer, opts))
5655
g.RunFn(genesisProtoModify(replacer, opts))
5756
g.RunFn(genesisTypesModify(replacer, opts))
@@ -152,24 +151,6 @@ message QueryGet%[2]vResponse {
152151
}
153152
}
154153

155-
func moduleGRPCGatewayModify(replacer placeholder.Replacer, opts *typed.Options) genny.RunFn {
156-
return func(r *genny.Runner) error {
157-
path := filepath.Join(opts.AppPath, "x", opts.ModuleName, "module.go")
158-
f, err := r.Disk.Find(path)
159-
if err != nil {
160-
return err
161-
}
162-
replacement := `"context"`
163-
content := replacer.ReplaceOnce(f.String(), typed.Placeholder, replacement)
164-
165-
replacement = `types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))`
166-
content = replacer.ReplaceOnce(content, typed.Placeholder2, replacement)
167-
168-
newFile := genny.NewFileS(path, content)
169-
return r.File(newFile)
170-
}
171-
}
172-
173154
func clientCliQueryModify(replacer placeholder.Replacer, opts *typed.Options) genny.RunFn {
174155
return func(r *genny.Runner) error {
175156
path := filepath.Join(opts.AppPath, "x", opts.ModuleName, "client/cli/query.go")

0 commit comments

Comments
 (0)