Skip to content

Commit

Permalink
Changes to be committed: Initial Base
Browse files Browse the repository at this point in the history
  • Loading branch information
gokulsan committed Nov 9, 2023
1 parent eb9e26c commit e7a5f24
Show file tree
Hide file tree
Showing 15 changed files with 786 additions and 21 deletions.
31 changes: 31 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18782,6 +18782,35 @@ paths:
format: int64
tags:
- Query
/gokulsan/bsn/bsn/bsn:
get:
summary: Queries a list of Bsn items.
operationId: GokulsanBsnBsnBsn
responses:
'200':
description: A successful response.
schema:
type: object
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
/gokulsan/bsn/bsn/params:
get:
summary: Parameters queries the parameters of the module.
Expand Down Expand Up @@ -44697,6 +44726,8 @@ definitions:
gokulsan.bsn.bsn.Params:
type: object
description: Params defines the parameters for the module.
gokulsan.bsn.bsn.QueryBsnResponse:
type: object
gokulsan.bsn.bsn.QueryParamsResponse:
type: object
properties:
Expand Down
13 changes: 12 additions & 1 deletion proto/bsn/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ service Query {
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/gokulsan/bsn/bsn/params";
}
// this line is used by starport scaffolding # 2
// Queries a list of Bsn items.
rpc Bsn(QueryBsnRequest) returns (QueryBsnResponse) {
option (google.api.http).get = "/gokulsan/bsn/bsn/bsn";
}

// this line is used by starport scaffolding # 2
}

// QueryParamsRequest is request type for the Query/Params RPC method.
Expand All @@ -27,4 +32,10 @@ message QueryParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}

message QueryBsnRequest {
}

message QueryBsnResponse {
}

// this line is used by starport scaffolding # 3
29 changes: 29 additions & 0 deletions vue/src/store/generated/gokulsan/bsn/gokulsan.bsn.bsn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function getStructure(template) {
const getDefaultState = () => {
return {
Params: {},
Bsn: {},

_Structure: {
Params: getStructure(Params.fromPartial({})),
Expand Down Expand Up @@ -79,6 +80,12 @@ export default {
}
return state.Params[JSON.stringify(params)] ?? {}
},
getBsn: (state) => (params = { params: {}}) => {
if (!(<any> params).query) {
(<any> params).query=null
}
return state.Bsn[JSON.stringify(params)] ?? {}
},

getTypeStructure: (state) => (type) => {
return state._Structure[type].fields
Expand Down Expand Up @@ -135,6 +142,28 @@ export default {
},







async QueryBsn({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) {
try {
const key = params ?? {};
const queryClient=await initQueryClient(rootGetters)
let value= (await queryClient.queryBsn()).data


commit('QUERY', { query: 'Bsn', key: { params: {...key}, query}, value })
if (subscribe) commit('SUBSCRIBE', { action: 'QueryBsn', payload: { options: { all }, params: {...key},query }})
return getters['getBsn']( { params: {...key}, query}) ?? {}
} catch (e) {
throw new Error('QueryClient:QueryBsn API Node Unavailable. Could not perform query: ' + e.message)

}
},


async sendMsgCreatePost({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export type BsnMsgCreatePostResponse = object;
*/
export type BsnParams = object;

export type BsnQueryBsnResponse = object;

/**
* QueryParamsResponse is response type for the Query/Params RPC method.
*/
Expand Down Expand Up @@ -231,6 +233,22 @@ export class HttpClient<SecurityDataType = unknown> {
* @version version not set
*/
export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
/**
* No description
*
* @tags Query
* @name QueryBsn
* @summary Queries a list of Bsn items.
* @request GET:/gokulsan/bsn/bsn/bsn
*/
queryBsn = (params: RequestParams = {}) =>
this.request<BsnQueryBsnResponse, RpcStatus>({
path: `/gokulsan/bsn/bsn/bsn`,
method: "GET",
format: "json",
...params,
});

/**
* No description
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export interface QueryParamsResponse {
params: Params | undefined;
}

export interface QueryBsnRequest {}

export interface QueryBsnResponse {}

const baseQueryParamsRequest: object = {};

export const QueryParamsRequest = {
Expand Down Expand Up @@ -110,10 +114,88 @@ export const QueryParamsResponse = {
},
};

const baseQueryBsnRequest: object = {};

export const QueryBsnRequest = {
encode(_: QueryBsnRequest, writer: Writer = Writer.create()): Writer {
return writer;
},

decode(input: Reader | Uint8Array, length?: number): QueryBsnRequest {
const reader = input instanceof Uint8Array ? new Reader(input) : input;
let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseQueryBsnRequest } as QueryBsnRequest;
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(_: any): QueryBsnRequest {
const message = { ...baseQueryBsnRequest } as QueryBsnRequest;
return message;
},

toJSON(_: QueryBsnRequest): unknown {
const obj: any = {};
return obj;
},

fromPartial(_: DeepPartial<QueryBsnRequest>): QueryBsnRequest {
const message = { ...baseQueryBsnRequest } as QueryBsnRequest;
return message;
},
};

const baseQueryBsnResponse: object = {};

export const QueryBsnResponse = {
encode(_: QueryBsnResponse, writer: Writer = Writer.create()): Writer {
return writer;
},

decode(input: Reader | Uint8Array, length?: number): QueryBsnResponse {
const reader = input instanceof Uint8Array ? new Reader(input) : input;
let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseQueryBsnResponse } as QueryBsnResponse;
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(_: any): QueryBsnResponse {
const message = { ...baseQueryBsnResponse } as QueryBsnResponse;
return message;
},

toJSON(_: QueryBsnResponse): unknown {
const obj: any = {};
return obj;
},

fromPartial(_: DeepPartial<QueryBsnResponse>): QueryBsnResponse {
const message = { ...baseQueryBsnResponse } as QueryBsnResponse;
return message;
},
};

/** Query defines the gRPC querier service. */
export interface Query {
/** Parameters queries the parameters of the module. */
Params(request: QueryParamsRequest): Promise<QueryParamsResponse>;
/** Queries a list of Bsn items. */
Bsn(request: QueryBsnRequest): Promise<QueryBsnResponse>;
}

export class QueryClientImpl implements Query {
Expand All @@ -126,6 +208,12 @@ export class QueryClientImpl implements Query {
const promise = this.rpc.request("gokulsan.bsn.bsn.Query", "Params", data);
return promise.then((data) => QueryParamsResponse.decode(new Reader(data)));
}

Bsn(request: QueryBsnRequest): Promise<QueryBsnResponse> {
const data = QueryBsnRequest.encode(request).finish();
const promise = this.rpc.request("gokulsan.bsn.bsn.Query", "Bsn", data);
return promise.then((data) => QueryBsnResponse.decode(new Reader(data)));
}
}

interface Rpc {
Expand Down
2 changes: 2 additions & 0 deletions x/bsn/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func GetQueryCmd(queryRoute string) *cobra.Command {
}

cmd.AddCommand(CmdQueryParams())
cmd.AddCommand(CmdBsn())

// this line is used by starport scaffolding # 1

return cmd
Expand Down
42 changes: 42 additions & 0 deletions x/bsn/client/cli/query_bsn.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package cli

import (
"strconv"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/gokulsan/bsn/x/bsn/types"
"github.com/spf13/cobra"
)

var _ = strconv.Itoa(0)

func CmdBsn() *cobra.Command {
cmd := &cobra.Command{
Use: "bsn",
Short: "Query bsn",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) (err error) {

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)

params := &types.QueryBsnRequest{}

res, err := queryClient.Bsn(cmd.Context(), params)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
44 changes: 44 additions & 0 deletions x/bsn/client/cli/tx_create_post.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package cli

import (
"strconv"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/gokulsan/bsn/x/bsn/types"
"github.com/spf13/cobra"
)

var _ = strconv.Itoa(0)

func CmdCreatePost() *cobra.Command {
cmd := &cobra.Command{
Use: "create-post [title] [body]",
Short: "Broadcast message createPost",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argTitle := args[0]
argBody := args[1]

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

msg := types.NewMsgCreatePost(
clientCtx.GetFromAddress().String(),
argTitle,
argBody,
)
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
23 changes: 23 additions & 0 deletions x/bsn/keeper/grpc_query_bsn.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package keeper

import (
"context"

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

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

ctx := sdk.UnwrapSDKContext(goCtx)

// TODO: Process the query
_ = ctx

return &types.QueryBsnResponse{}, nil
}
Loading

0 comments on commit e7a5f24

Please sign in to comment.