Skip to content

Commit

Permalink
finish with expired games
Browse files Browse the repository at this point in the history
  • Loading branch information
walter-cavinaw committed Jul 22, 2023
1 parent d04b552 commit 75c9a48
Show file tree
Hide file tree
Showing 22 changed files with 864 additions and 96 deletions.
48 changes: 48 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ paths:
moveCount:
type: string
format: uint64
beforeIndex:
type: string
description: Pertains to the FIFO. Toward head.
afterIndex:
type: string
description: Pertains to the FIFO. Toward tail.
pagination:
type: object
properties:
Expand Down Expand Up @@ -206,6 +212,12 @@ paths:
moveCount:
type: string
format: uint64
beforeIndex:
type: string
description: Pertains to the FIFO. Toward head.
afterIndex:
type: string
description: Pertains to the FIFO. Toward tail.
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -247,6 +259,12 @@ paths:
nextId:
type: string
format: uint64
fifoHeadIndex:
type: string
description: Will contain the index of the game at the head.
fifoTailIndex:
type: string
description: Will contain the index of the game at the tail.
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -29764,6 +29782,12 @@ definitions:
moveCount:
type: string
format: uint64
beforeIndex:
type: string
description: Pertains to the FIFO. Toward head.
afterIndex:
type: string
description: Pertains to the FIFO. Toward tail.
pagination:
type: object
properties:
Expand Down Expand Up @@ -29812,6 +29836,12 @@ definitions:
moveCount:
type: string
format: uint64
beforeIndex:
type: string
description: Pertains to the FIFO. Toward head.
afterIndex:
type: string
description: Pertains to the FIFO. Toward tail.
alice.checkers.checkers.QueryGetSystemInfoResponse:
type: object
properties:
Expand All @@ -29821,6 +29851,12 @@ definitions:
nextId:
type: string
format: uint64
fifoHeadIndex:
type: string
description: Will contain the index of the game at the head.
fifoTailIndex:
type: string
description: Will contain the index of the game at the tail.
alice.checkers.checkers.QueryParamsResponse:
type: object
properties:
Expand Down Expand Up @@ -29848,12 +29884,24 @@ definitions:
moveCount:
type: string
format: uint64
beforeIndex:
type: string
description: Pertains to the FIFO. Toward head.
afterIndex:
type: string
description: Pertains to the FIFO. Toward tail.
alice.checkers.checkers.SystemInfo:
type: object
properties:
nextId:
type: string
format: uint64
fifoHeadIndex:
type: string
description: Will contain the index of the game at the head.
fifoTailIndex:
type: string
description: Will contain the index of the game at the tail.
cosmos.base.query.v1beta1.PageRequest:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,60 +230,60 @@ export default {
},


async sendMsgPlayMove({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgCreateGame({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgPlayMove(value)
const msg = await txClient.msgCreateGame(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgPlayMove:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgCreateGame:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgPlayMove:Send Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:MsgCreateGame:Send Could not broadcast Tx: '+ e.message)
}
}
},
async sendMsgCreateGame({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgPlayMove({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreateGame(value)
const msg = await txClient.msgPlayMove(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreateGame:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgPlayMove:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgCreateGame:Send Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:MsgPlayMove:Send Could not broadcast Tx: '+ e.message)
}
}
},

async MsgPlayMove({ rootGetters }, { value }) {
async MsgCreateGame({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgPlayMove(value)
const msg = await txClient.msgCreateGame(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgPlayMove:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgCreateGame:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgPlayMove:Create Could not create message: ' + e.message)
throw new Error('TxClient:MsgCreateGame:Create Could not create message: ' + e.message)
}
}
},
async MsgCreateGame({ rootGetters }, { value }) {
async MsgPlayMove({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreateGame(value)
const msg = await txClient.msgPlayMove(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreateGame:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgPlayMove:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgCreateGame:Create Could not create message: ' + e.message)
throw new Error('TxClient:MsgPlayMove:Create Could not create message: ' + e.message)
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { StdFee } from "@cosmjs/launchpad";
import { SigningStargateClient } from "@cosmjs/stargate";
import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { Api } from "./rest";
import { MsgPlayMove } from "./types/checkers/tx";
import { MsgCreateGame } from "./types/checkers/tx";
import { MsgPlayMove } from "./types/checkers/tx";


const types = [
["/alice.checkers.checkers.MsgPlayMove", MsgPlayMove],
["/alice.checkers.checkers.MsgCreateGame", MsgCreateGame],
["/alice.checkers.checkers.MsgPlayMove", MsgPlayMove],

];
export const MissingWalletError = new Error("wallet is required");
Expand Down Expand Up @@ -43,8 +43,8 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions =

return {
signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo),
msgPlayMove: (data: MsgPlayMove): EncodeObject => ({ typeUrl: "/alice.checkers.checkers.MsgPlayMove", value: MsgPlayMove.fromPartial( data ) }),
msgCreateGame: (data: MsgCreateGame): EncodeObject => ({ typeUrl: "/alice.checkers.checkers.MsgCreateGame", value: MsgCreateGame.fromPartial( data ) }),
msgPlayMove: (data: MsgPlayMove): EncodeObject => ({ typeUrl: "/alice.checkers.checkers.MsgPlayMove", value: MsgPlayMove.fromPartial( data ) }),

};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,23 @@ export interface CheckersStoredGame {

/** @format uint64 */
moveCount?: string;

/** Pertains to the FIFO. Toward head. */
beforeIndex?: string;

/** Pertains to the FIFO. Toward tail. */
afterIndex?: string;
}

export interface CheckersSystemInfo {
/** @format uint64 */
nextId?: string;

/** Will contain the index of the game at the head. */
fifoHeadIndex?: string;

/** Will contain the index of the game at the tail. */
fifoTailIndex?: string;
}

export interface ProtobufAny {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export interface StoredGame {
winner: string;
deadline: string;
moveCount: number;
/** Pertains to the FIFO. Toward head. */
beforeIndex: string;
/** Pertains to the FIFO. Toward tail. */
afterIndex: string;
}

const baseStoredGame: object = {
Expand All @@ -24,6 +28,8 @@ const baseStoredGame: object = {
winner: "",
deadline: "",
moveCount: 0,
beforeIndex: "",
afterIndex: "",
};

export const StoredGame = {
Expand Down Expand Up @@ -52,6 +58,12 @@ export const StoredGame = {
if (message.moveCount !== 0) {
writer.uint32(64).uint64(message.moveCount);
}
if (message.beforeIndex !== "") {
writer.uint32(74).string(message.beforeIndex);
}
if (message.afterIndex !== "") {
writer.uint32(82).string(message.afterIndex);
}
return writer;
},

Expand Down Expand Up @@ -86,6 +98,12 @@ export const StoredGame = {
case 8:
message.moveCount = longToNumber(reader.uint64() as Long);
break;
case 9:
message.beforeIndex = reader.string();
break;
case 10:
message.afterIndex = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
Expand Down Expand Up @@ -136,6 +154,16 @@ export const StoredGame = {
} else {
message.moveCount = 0;
}
if (object.beforeIndex !== undefined && object.beforeIndex !== null) {
message.beforeIndex = String(object.beforeIndex);
} else {
message.beforeIndex = "";
}
if (object.afterIndex !== undefined && object.afterIndex !== null) {
message.afterIndex = String(object.afterIndex);
} else {
message.afterIndex = "";
}
return message;
},

Expand All @@ -149,6 +177,9 @@ export const StoredGame = {
message.winner !== undefined && (obj.winner = message.winner);
message.deadline !== undefined && (obj.deadline = message.deadline);
message.moveCount !== undefined && (obj.moveCount = message.moveCount);
message.beforeIndex !== undefined &&
(obj.beforeIndex = message.beforeIndex);
message.afterIndex !== undefined && (obj.afterIndex = message.afterIndex);
return obj;
},

Expand Down Expand Up @@ -194,6 +225,16 @@ export const StoredGame = {
} else {
message.moveCount = 0;
}
if (object.beforeIndex !== undefined && object.beforeIndex !== null) {
message.beforeIndex = object.beforeIndex;
} else {
message.beforeIndex = "";
}
if (object.afterIndex !== undefined && object.afterIndex !== null) {
message.afterIndex = object.afterIndex;
} else {
message.afterIndex = "";
}
return message;
},
};
Expand Down
Loading

0 comments on commit 75c9a48

Please sign in to comment.