Skip to content

Commit

Permalink
[tutorial] 3. Hello World
Browse files Browse the repository at this point in the history
  • Loading branch information
mingi3442 committed Dec 31, 2023
1 parent b5eea13 commit 9fa130c
Show file tree
Hide file tree
Showing 8 changed files with 1,661 additions and 98 deletions.
999 changes: 975 additions & 24 deletions api/min/min/query.pulsar.go

Large diffs are not rendered by default.

41 changes: 40 additions & 1 deletion api/min/min/query_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

134 changes: 88 additions & 46 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18910,6 +18910,79 @@ paths:
parameters.
tags:
- Msg
/min/min/params:
get:
summary: Parameters queries the parameters of the module.
operationId: MinMinQuery_Params
responses:
'200':
description: A successful response.
schema:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
description: >-
QueryParamsResponse is response type for the Query/Params RPC
method.
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
tags:
- Query
/min/min/say_hello/{name}:
get:
summary: Queries a list of SayHello items.
operationId: MinMinQuery_SayHello
responses:
'200':
description: A successful response.
schema:
type: object
properties:
name:
type: string
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
parameters:
- name: name
in: path
required: true
type: string
tags:
- Query
/min.min.Msg/UpdateParams:
post:
summary: |-
Expand Down Expand Up @@ -18966,42 +19039,6 @@ paths:
description: MsgUpdateParams is the Msg/UpdateParams request type.
tags:
- Msg
/min/min/params:
get:
summary: Parameters queries the parameters of the module.
operationId: MinMinQuery_Params
responses:
'200':
description: A successful response.
schema:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
description: >-
QueryParamsResponse is response type for the Query/Params RPC
method.
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
tags:
- Query
definitions:
cosmos.auth.v1beta1.MsgUpdateParams:
type: object
Expand Down Expand Up @@ -26637,6 +26674,21 @@ definitions:
description: |-
Version defines the versioning scheme used to negotiate the IBC verison in
the connection handshake.
min.min.Params:
type: object
description: Params defines the parameters for the module.
min.min.QueryParamsResponse:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
description: QueryParamsResponse is response type for the Query/Params RPC method.
min.min.QuerySayHelloResponse:
type: object
properties:
name:
type: string
min.min.MsgUpdateParams:
type: object
properties:
Expand All @@ -26657,13 +26709,3 @@ definitions:
description: |-
MsgUpdateParamsResponse defines the response structure for executing a
MsgUpdateParams message.
min.min.Params:
type: object
description: Params defines the parameters for the module.
min.min.QueryParamsResponse:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
description: QueryParamsResponse is response type for the Query/Params RPC method.
29 changes: 22 additions & 7 deletions proto/min/min/query.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
syntax = "proto3";

package min.min;

import "amino/amino.proto";
Expand All @@ -11,20 +12,34 @@ option go_package = "min/x/min/types";

// Query defines the gRPC querier service.
service Query {

// Parameters queries the parameters of the module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
rpc Params (QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/min/min/params";

}

// Queries a list of SayHello items.
rpc SayHello (QuerySayHelloRequest) returns (QuerySayHelloResponse) {
option (google.api.http).get = "/min/min/say_hello/{name}";

}
}

// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {

// params holds all the parameters of this module.
Params params = 1 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true
];
}
Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}

message QuerySayHelloRequest {
string name = 1;
}

message QuerySayHelloResponse {
string name = 1;
}

26 changes: 26 additions & 0 deletions x/min/keeper/query_say_hello.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package keeper

import (
"context"
"fmt"

"min/x/min/types"

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

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

ctx := sdk.UnwrapSDKContext(goCtx)

// TODO: Process the query
_ = ctx

//return &types.QuerySayHelloResponse{}, nil
return &types.QuerySayHelloResponse{Name: fmt.Sprintf("Hello %s!", req.Name)}, nil
}
7 changes: 7 additions & 0 deletions x/min/module/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
Use: "params",
Short: "Shows the parameters of the module",
},
{
RpcMethod: "SayHello",
Use: "say-hello [name]",
Short: "Query say-hello",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "name"}},
},

// this line is used by ignite scaffolding # autocli/query
},
},
Expand Down
Loading

0 comments on commit 9fa130c

Please sign in to comment.