Skip to content

Commit

Permalink
chore: release v0.23.0 (#2652)
Browse files Browse the repository at this point in the history
chore: release v0.23.0
  • Loading branch information
ilgooz authored Jul 24, 2022
2 parents 365695c + a6886e2 commit 64df9ae
Show file tree
Hide file tree
Showing 48 changed files with 1,053 additions and 684 deletions.
4 changes: 2 additions & 2 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"projects": {
"default": "ignite"
"default": "ignite-hq"
},
"targets": {
"ignite": {
"ignite-hq": {
"hosting": {
"docs.ignite.com": [
"ignite-go-docs"
Expand Down
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CODEOWNERS: https://help.github.com/articles/about-codeowners/

# Docs
*.md @fadeev @ilgooz @barriebyron @ignite-hq/growth-ecodev
*.md @ilgooz @aljo242

# Primary repo maintainers
* @fadeev @ilgooz @lubtd @Pantani @ivanovpetr @jeronimoalbi
* @ilgooz @lubtd @jeronimoalbi @aljo242 @tbruyelle
2 changes: 1 addition & 1 deletion .github/workflows/docs-deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_IGNITE_HQ }}"
expires: 7d
target: docs.ignite.com
projectId: ignite
projectId: ignite-hq
2 changes: 1 addition & 1 deletion .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ jobs:
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_IGNITE_HQ }}"
channelId: live
target: docs.ignite.com
projectId: ignite
projectId: ignite-hq
19 changes: 19 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## [`v0.23.0`](https://github.com/ignite/cli/releases/tag/v0.23.0)

### Features

- Apps can now use generics

### Fixes

- Fix `pkg/cosmosanalysis` to support apps with generics
- Remove `ignite-hq/cli` from dependency list in scaffolded chains

### Changes

- Change `pkg/cosmosgen` to allow importing IBC proto files
- Improve docs for Docker related commands
- Improve and fix documentation issues in developer tutorials
- Add migration docs for v0.22.2
- Improve `go mod download` error report in `pkg/cosmosgen`

## [`v0.22.2`](https://github.com/ignite/cli/releases/tag/v0.22.2)

### Features
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/guide/02-hello.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ This tutorial is a great place to start your journey into the Cosmos ecosystem.

In the previous chapter you've learned how to install [Ignite CLI](https://github.com/ignite/cli), the tool that offers everything you need to build, test, and launch your blockchain with a decentralized worldwide community.

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:
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.22.2 use the following command:

```bash
curl https://get.ignite.com/cli@v0.21.2! | bash
curl https://get.ignite.com/cli@v0.22.2! | bash
```

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.
Expand Down
118 changes: 81 additions & 37 deletions docs/docs/guide/03-blog/00-build-blog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ By completing this tutorial, you will learn about:

## Prerequisites

This series of blog tutorials is based on a specific version of Ignite CLI, so to install Ignite CLI v0.20.0 use the following command:
This series of blog tutorials is based on a specific version of Ignite CLI, so to install Ignite CLI v0.22.2 use the following command:

```bash
curl https://get.ignite.com/[email protected].1! | bash
curl https://get.ignite.com/[email protected].2! | bash
```

## Create your blog chain
Expand Down Expand Up @@ -139,14 +139,17 @@ You need to do two things:
func (k msgServer) CreatePost(goCtx context.Context, msg *types.MsgCreatePost) (*types.MsgCreatePostResponse, error) {
// Get the context
ctx := sdk.UnwrapSDKContext(goCtx)

// Create variable of type Post
var post = types.Post{
Creator: msg.Creator,
Title: msg.Title,
Body: msg.Body,
}

// Add a post to the store and get back the ID
id := k.AppendPost(ctx, post)

// Return the ID of the post
return &types.MsgCreatePostResponse{Id: id}, nil
}
Expand All @@ -162,7 +165,9 @@ Create the `proto/blog/post.proto` file and define the `Post` message:

```go
syntax = "proto3";

package blog.blog;

option go_package = "blog/x/blog/types";

message Post {
Expand All @@ -175,8 +180,8 @@ message Post {

The contents of the `post.proto` file are standard. The file defines:

- A package name `username.blog.blog` that is used to identify messages
- The Go package `go_package = "github.com/username/blog/x/blog/types"` where new files are generated
- A package name `blog.blog` that is used to identify messages
- The Go package `go_package = "blog/x/blog/types"` where new files are generated
- The message `message Post`

Continue developing your blog chain.
Expand All @@ -196,7 +201,8 @@ Then, add these prefixes to the `x/blog/types/keys.go` file in the `const` and a
```go
const (
//...
// Keep track of the index of posts

// Keep track of the index of posts
PostKey = "Post-value-"
PostCountKey = "Post-count-"
)
Expand Down Expand Up @@ -228,14 +234,18 @@ First, implement `GetPostCount`:
func (k Keeper) GetPostCount(ctx sdk.Context) uint64 {
// Get the store using storeKey (which is "blog") and PostCountKey (which is "Post-count-")
store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.PostCountKey))

// Convert the PostCountKey to bytes
byteKey := []byte(types.PostCountKey)

// Get the value of the count
bz := store.Get(byteKey)

// Return zero if the count value is not found (for example, it's the first post)
if bz == nil {
return 0
}

// Convert the count into a uint64
return binary.BigEndian.Uint64(bz)
}
Expand All @@ -247,11 +257,14 @@ Now that `GetPostCount` returns the correct number of posts in the store, implem
func (k Keeper) SetPostCount(ctx sdk.Context, count uint64) {
// Get the store using storeKey (which is "blog") and PostCountKey (which is "Post-count-")
store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.PostCountKey))

// Convert the PostCountKey to bytes
byteKey := []byte(types.PostCountKey)

// Convert count from uint64 to string and get bytes
bz := make([]byte, 8)
binary.BigEndian.PutUint64(bz, count)

// Set the value of Post-count- to count
store.Set(byteKey, bz)
}
Expand All @@ -264,25 +277,33 @@ package keeper

import (
"encoding/binary"
"blog/x/blog/types"

"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"

"blog/x/blog/types"
)

func (k Keeper) AppendPost(ctx sdk.Context, post types.Post) uint64 {
// Get the current number of posts in the store
count := k.GetPostCount(ctx)

// Assign an ID to the post based on the number of posts in the store
post.Id = count

// Get the store
store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.PostKey))

// Convert the post ID into bytes
byteKey := make([]byte, 8)
binary.BigEndian.PutUint64(byteKey, post.Id)

// Marshal the post into bytes
appendedValue := k.cdc.MustMarshal(&post)

// Insert the post bytes using post ID as a key
store.Set(byteKey, appendedValue)

// Update the post count
k.SetPostCount(ctx, count+1)
return count
Expand Down Expand Up @@ -315,73 +336,83 @@ To define the types in proto files, make the following updates in `proto/blog/qu

1. Add the `import`:

```go
import "blog/post.proto";
```
```go
import "blog/post.proto";
```

2. Add pagination to the post request:

```go
message QueryPostsRequest {
// Adding pagination to request
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}
```
```go
message QueryPostsRequest {
// Adding pagination to request
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}
```

3. Add pagination to the post response:

```go
message QueryPostsResponse {
// Returning a list of posts
repeated Post Post = 1;
// Adding pagination to response
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
```
```go
message QueryPostsResponse {
// Returning a list of posts
repeated Post Post = 1;

// Adding pagination to response
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
```

To implement post querying logic in the `grpc_query_posts.go` file, delete the contents of that file and replace it with:
To implement post querying logic in the `x/blog/keeper/grpc_query_posts.go` file, delete the contents of that file and replace it with:

```go
package keeper

import (
"context"
"blog/x/blog/types"

"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/query"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"blog/x/blog/types"
)

func (k Keeper) Posts(c context.Context, req *types.QueryPostsRequest) (*types.QueryPostsResponse, error) {
// Throw an error if request is nil
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}

// Define a variable that will store a list of posts
var posts []*types.Post

// Get context with the information about the environment
ctx := sdk.UnwrapSDKContext(c)

// Get the key-value module store using the store key (in our case store key is "chain")
store := ctx.KVStore(k.storeKey)

// Get the part of the store that keeps posts (using post key, which is "Post-value-")
postStore := prefix.NewStore(store, []byte(types.PostKey))

// Paginate the posts store based on PageRequest
pageRes, err := query.Paginate(postStore, req.Pagination, func(key []byte, value []byte) error {
var post types.Post
if err := k.cdc.Unmarshal(value, &post); err != nil {
return err
}

posts = append(posts, &post)

return nil
})

// Throw an error if pagination failed
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

// Return a struct containing a list of posts and pagination info
return &types.QueryPostsResponse{Post: posts, Pagination: pageRes}, nil
}
Expand All @@ -393,28 +424,41 @@ In the `x/blog/module.go` file:

1. Add `"context"` to the imports, don't save the file yet.

```go
import (
"context"
```go
import (
"context"

// ... other imports
)
```
)
```

2. Update the `RegisterGRPCGatewayRoutes` function to register the query handler client:

```go
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
}
```
```go
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
}
```

3. Now that you've modified the file with the two updates, now it's safe to save the file.

## Use the CLI to create a post

Now that you have implemented logic for creating and querying posts, you can interact with your blog chain using the command line. The blog chain binary is `blogd`.

First, start the chain on your development machine by running the following command in the `blog` directory:

```bash
ignite chain serve
```

The binary is built by the `ignite chain serve` command bit it can also be built by running:

```bash
ignite chain build
```

To create a post at the command line:

```bash
Expand Down
Loading

0 comments on commit 64df9ae

Please sign in to comment.