Skip to content

Commit

Permalink
nextgame id rule file
Browse files Browse the repository at this point in the history
  • Loading branch information
james.zhang committed Mar 30, 2022
1 parent 66aa2b8 commit 5a69f28
Show file tree
Hide file tree
Showing 28 changed files with 1,472 additions and 38 deletions.
51 changes: 51 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27679,6 +27679,42 @@ paths:
format: uint64
tags:
- Query
/james-zhang-bing/checkers/checkers/next_game:
get:
summary: Queries a NextGame by index.
operationId: JameszhangbingCheckersCheckersNextGame
responses:
'200':
description: A successful response.
schema:
type: object
properties:
NextGame:
type: object
properties:
idValue:
type: string
format: uint64
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
/jameszhangbing/checkers/checkers/params:
get:
summary: Parameters queries the parameters of the module.
Expand Down Expand Up @@ -47029,9 +47065,24 @@ definitions:
method.
jameszhangbing.checkers.checkers.MsgCreatePostResponse:
type: object
jameszhangbing.checkers.checkers.NextGame:
type: object
properties:
idValue:
type: string
format: uint64
jameszhangbing.checkers.checkers.Params:
type: object
description: Params defines the parameters for the module.
jameszhangbing.checkers.checkers.QueryGetNextGameResponse:
type: object
properties:
NextGame:
type: object
properties:
idValue:
type: string
format: uint64
jameszhangbing.checkers.checkers.QueryParamsResponse:
type: object
properties:
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ require (
github.com/google/go-cmp v0.5.7 // indirect
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.0 // indirect
github.com/regen-network/cosmos-proto v0.3.1 // indirect
github.com/spf13/cast v1.4.1
github.com/spf13/cobra v1.2.1
github.com/stretchr/testify v1.7.0
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ github.com/fzipp/gocyclo v0.3.1/go.mod h1:DJHO6AUmbdqj2ET4Z9iArSuwWgYDRryYt2wASx
github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
Expand Down Expand Up @@ -612,6 +613,8 @@ github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/
github.com/gogo/googleapis v1.2.0/go.mod h1:Njal3psf3qN6dwBtQfUmBZh2ybovJ0tlu3o/AC7HYjU=
github.com/gogo/googleapis v1.4.0/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -765,6 +768,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqC
github.com/grpc-ecosystem/grpc-gateway v1.14.7/go.mod h1:oYZKL012gGh6LMyg/xA7Q2yq6j8bu0wa+9w14EEthWU=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.0 h1:ESEyqQqXXFIcImj/BE8oKEX37Zsuceb2cZI+EL/zNCY=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.0/go.mod h1:XnLCLFp3tjoZJszVKjfpyAK6J8sYIcQXWQxmqLWF21I=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0=
github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
Expand Down Expand Up @@ -1650,6 +1655,7 @@ golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ
golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down Expand Up @@ -2109,4 +2115,6 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
sigs.k8s.io/structured-merge-diff/v4 v4.0.3/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
2 changes: 2 additions & 0 deletions proto/checkers/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package jameszhangbing.checkers.checkers;

import "gogoproto/gogo.proto";
import "checkers/params.proto";
import "checkers/next_game.proto";
// this line is used by starport scaffolding # genesis/proto/import

option go_package = "github.com/james-zhang-bing/checkers/x/checkers/types";

// GenesisState defines the checkers module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
NextGame nextGame = 2;
// this line is used by starport scaffolding # genesis/proto/state
}
9 changes: 9 additions & 0 deletions proto/checkers/next_game.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";
package jameszhangbing.checkers.checkers;

option go_package = "github.com/james-zhang-bing/checkers/x/checkers/types";

message NextGame {
uint64 idValue = 1;

}
12 changes: 11 additions & 1 deletion proto/checkers/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "checkers/params.proto";
import "checkers/next_game.proto";
// this line is used by starport scaffolding # 1

option go_package = "github.com/james-zhang-bing/checkers/x/checkers/types";
Expand All @@ -15,7 +16,11 @@ service Query {
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/jameszhangbing/checkers/checkers/params";
}
// this line is used by starport scaffolding # 2
// Queries a NextGame by index.
rpc NextGame(QueryGetNextGameRequest) returns (QueryGetNextGameResponse) {
option (google.api.http).get = "/james-zhang-bing/checkers/checkers/next_game";
}
// this line is used by starport scaffolding # 2
}

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

message QueryGetNextGameRequest {}

message QueryGetNextGameResponse {
NextGame NextGame = 1 [(gogoproto.nullable) = false];
}
// this line is used by starport scaffolding # 3
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { txClient, queryClient, MissingWalletError , registry} from './module'

import { NextGame } from "./module/types/checkers/next_game"
import { Params } from "./module/types/checkers/params"


export { Params };
export { NextGame, Params };

async function initTxClient(vuexGetters) {
return await txClient(vuexGetters['common/wallet/signer'], {
Expand Down Expand Up @@ -42,8 +43,10 @@ function getStructure(template) {
const getDefaultState = () => {
return {
Params: {},
NextGame: {},

_Structure: {
NextGame: getStructure(NextGame.fromPartial({})),
Params: getStructure(Params.fromPartial({})),

},
Expand Down Expand Up @@ -79,6 +82,12 @@ export default {
}
return state.Params[JSON.stringify(params)] ?? {}
},
getNextGame: (state) => (params = { params: {}}) => {
if (!(<any> params).query) {
(<any> params).query=null
}
return state.NextGame[JSON.stringify(params)] ?? {}
},

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







async QueryNextGame({ 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.queryNextGame()).data


commit('QUERY', { query: 'NextGame', key: { params: {...key}, query}, value })
if (subscribe) commit('SUBSCRIBE', { action: 'QueryNextGame', payload: { options: { all }, params: {...key},query }})
return getters['getNextGame']( { params: {...key}, query}) ?? {}
} catch (e) {
throw new Error('QueryClient:QueryNextGame 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 @@ -11,11 +11,20 @@

export type CheckersMsgCreatePostResponse = object;

export interface CheckersNextGame {
/** @format uint64 */
idValue?: string;
}

/**
* Params defines the parameters for the module.
*/
export type CheckersParams = object;

export interface CheckersQueryGetNextGameResponse {
NextGame?: CheckersNextGame;
}

/**
* QueryParamsResponse is response type for the Query/Params RPC method.
*/
Expand Down Expand Up @@ -231,6 +240,22 @@ export class HttpClient<SecurityDataType = unknown> {
* @version version not set
*/
export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
/**
* No description
*
* @tags Query
* @name QueryNextGame
* @summary Queries a NextGame by index.
* @request GET:/james-zhang-bing/checkers/checkers/next_game
*/
queryNextGame = (params: RequestParams = {}) =>
this.request<CheckersQueryGetNextGameResponse, RpcStatus>({
path: `/james-zhang-bing/checkers/checkers/next_game`,
method: "GET",
format: "json",
...params,
});

/**
* No description
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
/* eslint-disable */
import { Params } from "../checkers/params";
import { NextGame } from "../checkers/next_game";
import { Writer, Reader } from "protobufjs/minimal";

export const protobufPackage = "jameszhangbing.checkers.checkers";

/** GenesisState defines the checkers module's genesis state. */
export interface GenesisState {
/** this line is used by starport scaffolding # genesis/proto/state */
params: Params | undefined;
/** this line is used by starport scaffolding # genesis/proto/state */
nextGame: NextGame | undefined;
}

const baseGenesisState: object = {};
Expand All @@ -17,6 +19,9 @@ export const GenesisState = {
if (message.params !== undefined) {
Params.encode(message.params, writer.uint32(10).fork()).ldelim();
}
if (message.nextGame !== undefined) {
NextGame.encode(message.nextGame, writer.uint32(18).fork()).ldelim();
}
return writer;
},

Expand All @@ -30,6 +35,9 @@ export const GenesisState = {
case 1:
message.params = Params.decode(reader, reader.uint32());
break;
case 2:
message.nextGame = NextGame.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
Expand All @@ -45,13 +53,22 @@ export const GenesisState = {
} else {
message.params = undefined;
}
if (object.nextGame !== undefined && object.nextGame !== null) {
message.nextGame = NextGame.fromJSON(object.nextGame);
} else {
message.nextGame = undefined;
}
return message;
},

toJSON(message: GenesisState): unknown {
const obj: any = {};
message.params !== undefined &&
(obj.params = message.params ? Params.toJSON(message.params) : undefined);
message.nextGame !== undefined &&
(obj.nextGame = message.nextGame
? NextGame.toJSON(message.nextGame)
: undefined);
return obj;
},

Expand All @@ -62,6 +79,11 @@ export const GenesisState = {
} else {
message.params = undefined;
}
if (object.nextGame !== undefined && object.nextGame !== null) {
message.nextGame = NextGame.fromPartial(object.nextGame);
} else {
message.nextGame = undefined;
}
return message;
},
};
Expand Down
Loading

0 comments on commit 5a69f28

Please sign in to comment.