You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/hello.md
+59-48Lines changed: 59 additions & 48 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ In the previous chapter you've learned how to install [Ignite CLI](https://githu
14
14
This series of tutorials is based on a specific version of Ignite CLI, so be sure to install the correct version. For example, to install Ignite CLI v0.20.0 use the following command:
15
15
16
16
```bash
17
-
curl https://get.ignite.com/cli@v0.20.0!| bash
17
+
curl https://get.ignite.com/cli@v0.21.2!| bash
18
18
```
19
19
20
20
Ignite CLI comes with a number of scaffolding commands that are designed to make development easier by creating everything that's required to start working on a particular task.
@@ -26,7 +26,7 @@ Are you ready? Open a terminal window and navigate to a directory where you have
26
26
To create your blockchain with the default directory structure, run this command:
27
27
28
28
```bash
29
-
ignite scaffold chain github.com/username/hello
29
+
ignite scaffold chain hello
30
30
```
31
31
32
32
This command creates a Cosmos SDK blockchain called hello in a `hello` directory. The source code inside the `hello` directory contains a fully functional ready-to-use blockchain.
@@ -60,13 +60,13 @@ The `hello` directory contains a number of generated files and directories that
| app/ | Files that wire together the blockchain. The most important file is `app.go` that contains type definition of the blockchain and functions to create and initialize it. |
62
62
| cmd/ | The main package responsible for the CLI of compiled binary. |
63
-
| docs/ | Directory for project documentation. By default, an OpenAPI spec is generated. |
63
+
| docs/ | Directory for project documentation. By default, an OpenAPI spec is generated. |
64
64
| proto/ | Protocol buffer files describing the data structure. |
65
65
| testutil/ | Helper functions for testing. |
66
66
| vue/ | A Vue 3 web app template. |
67
67
| x/ | Cosmos SDK modules and custom modules. |
68
68
| config.yml | A configuration file for customizing a chain in development. |
69
-
| readme.md | A readme file for your sovereign application-specific blockchain project. |
69
+
| readme.md | A readme file for your sovereign application-specific blockchain project. |
70
70
71
71
Now you can get your blockchain up and running locally on a single node.
72
72
@@ -124,98 +124,110 @@ For all subsequent commands, use a terminal window that is different from the wi
124
124
125
125
In a different terminal window, run the commands in your `hello` directory.
126
126
127
-
Create a `posts` query:
127
+
Create a `hello` query:
128
128
129
129
```bash
130
-
ignite scaffold query posts --response title,body
130
+
ignite scaffold query hello --response text
131
131
```
132
132
133
-
`query` accepts a name of the query (in this case, `posts`), an optional list of request parameters (in this case, empty), and an optional comma-separated list of response fields with a `--response` flag (in this case, `body,title`).
133
+
`query` accepts a name of the query (in this case, `hello`), an optional list of request parameters (in this case, empty), and an optional comma-separated list of response fields with a `--response` flag (in this case, `text`).
134
134
135
135
The `query` command has created and modified several files:
136
136
137
-
- modified `proto/hello/query.proto`
138
-
- created `x/hello/keeper/grpc_query_posts.go`
139
-
- modified `x/hello/client/cli/query.go`
140
-
- created `x/hello/client/cli/query_posts.go`
137
+
```
138
+
modify proto/hello/query.proto
139
+
modify x/hello/client/cli/query.go
140
+
create x/hello/client/cli/query_hello.go
141
+
create x/hello/keeper/grpc_query_hello.go
142
+
```
141
143
142
144
Let's examine some of these changes. For clarity, the following code blocks do not show the placeholder comments that Ignite CLI uses to scaffold code. Don't delete these placeholders since they are required to continue using Ignite CLI's scaffolding functionality.
143
145
146
+
Note: it's recommended to commit changes to a version control system (for example, Git) after scaffolding. This allows others to easily distinguish between code generated by Ignite and the code writen by hand.
147
+
148
+
```
149
+
git add .
150
+
git commit -am "Scaffolded a hello query with Ignite CLI"
151
+
```
152
+
144
153
### Updates to the query service
145
154
146
-
In the `proto/hello/query.proto` file, the `Posts` rpc has been added to the `Query` service.
155
+
In the `proto/hello/query.proto` file, the `Hello` rpc has been added to the `Query` service.
- In a web browser, visit the posts endpoint [http://localhost:1317/username/hello/hello/posts](http://localhost:1317/username/hello/hello/posts).
230
+
- In a web browser, visit the `hello` endpoint [http://localhost:1317/hello/hello/hello](http://localhost:1317/hello/hello/hello).
219
231
220
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.
221
233
@@ -245,19 +257,18 @@ Make the required changes to the `x/hello/module.go` file.
245
257
}
246
258
```
247
259
248
-
1. After the chain has been started, visit [http://localhost:1317/username/hello/hello/posts](http://localhost:1317/username/hello/hello/posts) and see your text displayed:
260
+
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:
249
261
250
262
```go
251
263
{
252
-
"title": "Hello!",
253
-
"body": "Ignite CLI"
264
+
"text": "Hello, Ignite CLI!",
254
265
}
255
266
```
256
267
257
-
The `query` command has also scaffolded `x/hello/client/cli/query_posts.go` that implements a CLI equivalent of the posts query and mounted this command in `x/hello/client/cli/query.go` . Run the following command and get the same JSON response:
268
+
The `query` command has also scaffolded `x/hello/client/cli/query_hello.go` that implements a CLI equivalent of the hello query and mounted this command in `x/hello/client/cli/query.go` . Run the following command and get the same JSON response:
258
269
259
270
```go
260
-
hellod q hello posts
271
+
hellod q hello hello
261
272
```
262
273
263
274
Congratulations, you have built your first blockchain and your first CosmosSDK module. Continue the journey to learn more about scaffolding CosmosSDK messages, types in protocol buffer files, the keeper, and more.
0 commit comments