Skip to content

Commit

Permalink
Update SayHello Function Example in Ignite Documentation to to Align …
Browse files Browse the repository at this point in the history
…with Latest Ignite (#4143)
  • Loading branch information
hiroyukikumazawa committed May 16, 2024
1 parent 423dcc4 commit 82316ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
11 changes: 5 additions & 6 deletions docs/docs/02-guide/03-hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,23 @@ import (
"context"
"fmt"

"hello/x/hello/types"

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

"hello/x/hello/types"
)

func (k Keeper) SayHello(goCtx context.Context, req *types.QuerySayHelloRequest) (*types.QuerySayHelloResponse, error) {
func (q queryServer) SayHello(ctx context.Context, req *types.QuerySayHelloRequest) (*types.QuerySayHelloResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}

// Validation and Context unwrapping
ctx := sdk.UnwrapSDKContext(goCtx)
sdkCtx := sdk.UnwrapSDKContext(ctx)

_ = ctx
_ = sdkCtx
// Custom Response
// highlight-next-line
return &types.QuerySayHelloResponse{Name: fmt.Sprintf("Hello %s!", req.Name)}, nil
}
```
Expand Down
11 changes: 5 additions & 6 deletions docs/versioned_docs/version-v28/02-guide/03-hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,23 @@ import (
"context"
"fmt"

"hello/x/hello/types"

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

"hello/x/hello/types"
)

func (k Keeper) SayHello(goCtx context.Context, req *types.QuerySayHelloRequest) (*types.QuerySayHelloResponse, error) {
func (q queryServer) SayHello(ctx context.Context, req *types.QuerySayHelloRequest) (*types.QuerySayHelloResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}

// Validation and Context unwrapping
ctx := sdk.UnwrapSDKContext(goCtx)
sdkCtx := sdk.UnwrapSDKContext(ctx)

_ = ctx
_ = sdkCtx
// Custom Response
// highlight-next-line
return &types.QuerySayHelloResponse{Name: fmt.Sprintf("Hello %s!", req.Name)}, nil
}
```
Expand Down

0 comments on commit 82316ac

Please sign in to comment.