From 1d70f1b7b5aee257e60f255687ea0dd6f3869918 Mon Sep 17 00:00:00 2001 From: MinterTeam Date: Sat, 20 Jul 2024 18:00:36 +0000 Subject: [PATCH] dist --- gen/poker_connect.d.ts | 116 ++++++++++ gen/poker_connect.js | 116 ++++++++++ gen/poker_pb.d.ts | 480 +++++++++++++++++++++++++++++++++++++++++ gen/poker_pb.js | 177 +++++++++++++++ index.js | 5 + package.json | 29 +++ src/client.js | 13 ++ 7 files changed, 936 insertions(+) create mode 100644 gen/poker_connect.d.ts create mode 100644 gen/poker_connect.js create mode 100644 gen/poker_pb.d.ts create mode 100644 gen/poker_pb.js create mode 100644 index.js create mode 100644 package.json create mode 100644 src/client.js diff --git a/gen/poker_connect.d.ts b/gen/poker_connect.d.ts new file mode 100644 index 0000000..41a2ef1 --- /dev/null +++ b/gen/poker_connect.d.ts @@ -0,0 +1,116 @@ +// @generated by protoc-gen-connect-es v1.0.0-rc1 +// @generated from file poker.proto (package pokerhero, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { AdminTxRequest, AdminTxResponse, AllLeaveRoomRequest, CreateRoomRequest, EditRoomRequest, LeaveRoomRequest, PingRequest, PongResponse, RoomRequest, RoomResponse, RoomsRequest, RoomsResponse, UpdateRoomRequest } from "./poker_pb.js"; +import { MethodKind } from "@bufbuild/protobuf"; + +/** + * @generated from service pokerhero.Poker + */ +export declare const Poker: { + readonly typeName: "pokerhero.Poker", + readonly methods: { + /** + * @generated from rpc pokerhero.Poker.Room + */ + readonly room: { + readonly name: "Room", + readonly I: typeof RoomRequest, + readonly O: typeof RoomResponse, + readonly kind: MethodKind.Unary, + }, + /** + * @generated from rpc pokerhero.Poker.Rooms + */ + readonly rooms: { + readonly name: "Rooms", + readonly I: typeof RoomsRequest, + readonly O: typeof RoomsResponse, + readonly kind: MethodKind.Unary, + }, + /** + * CreateRoom (protected) + * 1. Creates room + * 2. Joins first player + * + * @generated from rpc pokerhero.Poker.CreateRoom + */ + readonly createRoom: { + readonly name: "CreateRoom", + readonly I: typeof CreateRoomRequest, + readonly O: typeof RoomResponse, + readonly kind: MethodKind.Unary, + }, + /** + * UpdateRoom (protected) + * 1. Updates balances in the room + * + * @generated from rpc pokerhero.Poker.UpdateRoom + */ + readonly updateRoom: { + readonly name: "UpdateRoom", + readonly I: typeof UpdateRoomRequest, + readonly O: typeof RoomResponse, + readonly kind: MethodKind.Unary, + }, + /** + * LeaveRoom (protected) + * 1. Pushes player from the room + * 2. Sends funds back to player + * + * @generated from rpc pokerhero.Poker.LeaveRoom + */ + readonly leaveRoom: { + readonly name: "LeaveRoom", + readonly I: typeof LeaveRoomRequest, + readonly O: typeof RoomResponse, + readonly kind: MethodKind.Unary, + }, + /** + * AllLeaveRoom (protected) + * 1. Pushes all player from all the rooms + * 2. Sends funds back to players + * + * @generated from rpc pokerhero.Poker.AllLeaveRoom + */ + readonly allLeaveRoom: { + readonly name: "AllLeaveRoom", + readonly I: typeof AllLeaveRoomRequest, + readonly O: typeof RoomsResponse, + readonly kind: MethodKind.Unary, + }, + /** + * EditRoom (protected) + * 1. Changes blinds in the room + * + * @generated from rpc pokerhero.Poker.EditRoom + */ + readonly editRoom: { + readonly name: "EditRoom", + readonly I: typeof EditRoomRequest, + readonly O: typeof RoomResponse, + readonly kind: MethodKind.Unary, + }, + /** + * @generated from rpc pokerhero.Poker.AdminTx + */ + readonly adminTx: { + readonly name: "AdminTx", + readonly I: typeof AdminTxRequest, + readonly O: typeof AdminTxResponse, + readonly kind: MethodKind.Unary, + }, + /** + * @generated from rpc pokerhero.Poker.Ping + */ + readonly ping: { + readonly name: "Ping", + readonly I: typeof PingRequest, + readonly O: typeof PongResponse, + readonly kind: MethodKind.Unary, + }, + } +}; + diff --git a/gen/poker_connect.js b/gen/poker_connect.js new file mode 100644 index 0000000..2d6c24f --- /dev/null +++ b/gen/poker_connect.js @@ -0,0 +1,116 @@ +// @generated by protoc-gen-connect-es v1.0.0-rc1 +// @generated from file poker.proto (package pokerhero, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { AdminTxRequest, AdminTxResponse, AllLeaveRoomRequest, CreateRoomRequest, EditRoomRequest, LeaveRoomRequest, PingRequest, PongResponse, RoomRequest, RoomResponse, RoomsRequest, RoomsResponse, UpdateRoomRequest } from "./poker_pb.js"; +import { MethodKind } from "@bufbuild/protobuf"; + +/** + * @generated from service pokerhero.Poker + */ +export const Poker = { + typeName: "pokerhero.Poker", + methods: { + /** + * @generated from rpc pokerhero.Poker.Room + */ + room: { + name: "Room", + I: RoomRequest, + O: RoomResponse, + kind: MethodKind.Unary, + }, + /** + * @generated from rpc pokerhero.Poker.Rooms + */ + rooms: { + name: "Rooms", + I: RoomsRequest, + O: RoomsResponse, + kind: MethodKind.Unary, + }, + /** + * CreateRoom (protected) + * 1. Creates room + * 2. Joins first player + * + * @generated from rpc pokerhero.Poker.CreateRoom + */ + createRoom: { + name: "CreateRoom", + I: CreateRoomRequest, + O: RoomResponse, + kind: MethodKind.Unary, + }, + /** + * UpdateRoom (protected) + * 1. Updates balances in the room + * + * @generated from rpc pokerhero.Poker.UpdateRoom + */ + updateRoom: { + name: "UpdateRoom", + I: UpdateRoomRequest, + O: RoomResponse, + kind: MethodKind.Unary, + }, + /** + * LeaveRoom (protected) + * 1. Pushes player from the room + * 2. Sends funds back to player + * + * @generated from rpc pokerhero.Poker.LeaveRoom + */ + leaveRoom: { + name: "LeaveRoom", + I: LeaveRoomRequest, + O: RoomResponse, + kind: MethodKind.Unary, + }, + /** + * AllLeaveRoom (protected) + * 1. Pushes all player from all the rooms + * 2. Sends funds back to players + * + * @generated from rpc pokerhero.Poker.AllLeaveRoom + */ + allLeaveRoom: { + name: "AllLeaveRoom", + I: AllLeaveRoomRequest, + O: RoomsResponse, + kind: MethodKind.Unary, + }, + /** + * EditRoom (protected) + * 1. Changes blinds in the room + * + * @generated from rpc pokerhero.Poker.EditRoom + */ + editRoom: { + name: "EditRoom", + I: EditRoomRequest, + O: RoomResponse, + kind: MethodKind.Unary, + }, + /** + * @generated from rpc pokerhero.Poker.AdminTx + */ + adminTx: { + name: "AdminTx", + I: AdminTxRequest, + O: AdminTxResponse, + kind: MethodKind.Unary, + }, + /** + * @generated from rpc pokerhero.Poker.Ping + */ + ping: { + name: "Ping", + I: PingRequest, + O: PongResponse, + kind: MethodKind.Unary, + }, + } +}; + diff --git a/gen/poker_pb.d.ts b/gen/poker_pb.d.ts new file mode 100644 index 0000000..8131fba --- /dev/null +++ b/gen/poker_pb.d.ts @@ -0,0 +1,480 @@ +// @generated by protoc-gen-es v1.3.1 +// @generated from file poker.proto (package pokerhero, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from message pokerhero.AdminTxRequest + */ +export declare class AdminTxRequest extends Message { + /** + * @generated from field: string tx = 1; + */ + tx: string; + + /** + * @generated from field: bool retry = 2; + */ + retry: boolean; + + /** + * server auth + * + * @generated from field: string token = 3; + */ + token: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.AdminTxRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): AdminTxRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): AdminTxRequest; + + static fromJsonString(jsonString: string, options?: Partial): AdminTxRequest; + + static equals(a: AdminTxRequest | PlainMessage | undefined, b: AdminTxRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message pokerhero.AdminTxResponse + */ +export declare class AdminTxResponse extends Message { + /** + * @generated from field: int32 id = 1; + */ + id: number; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.AdminTxResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): AdminTxResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): AdminTxResponse; + + static fromJsonString(jsonString: string, options?: Partial): AdminTxResponse; + + static equals(a: AdminTxResponse | PlainMessage | undefined, b: AdminTxResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message pokerhero.PingRequest + */ +export declare class PingRequest extends Message { + /** + * @generated from field: string message = 1; + */ + message: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.PingRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): PingRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): PingRequest; + + static fromJsonString(jsonString: string, options?: Partial): PingRequest; + + static equals(a: PingRequest | PlainMessage | undefined, b: PingRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message pokerhero.PongResponse + */ +export declare class PongResponse extends Message { + /** + * @generated from field: string message = 1; + */ + message: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.PongResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): PongResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): PongResponse; + + static fromJsonString(jsonString: string, options?: Partial): PongResponse; + + static equals(a: PongResponse | PlainMessage | undefined, b: PongResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message pokerhero.Player + */ +export declare class Player extends Message { + /** + * @generated from field: string address = 1; + */ + address: string; + + /** + * @generated from field: int32 balance = 2; + */ + balance: number; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.Player"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): Player; + + static fromJson(jsonValue: JsonValue, options?: Partial): Player; + + static fromJsonString(jsonString: string, options?: Partial): Player; + + static equals(a: Player | PlainMessage | undefined, b: Player | PlainMessage | undefined): boolean; +} + +/** + * @generated from message pokerhero.CreateRoomRequest + */ +export declare class CreateRoomRequest extends Message { + /** + * @generated from field: string creator_address = 1; + */ + creatorAddress: string; + + /** + * @generated from field: int32 big_blind = 2; + */ + bigBlind: number; + + /** + * @generated from field: int32 max_players = 3; + */ + maxPlayers: number; + + /** + * server auth + * + * @generated from field: string token = 4; + */ + token: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.CreateRoomRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): CreateRoomRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): CreateRoomRequest; + + static fromJsonString(jsonString: string, options?: Partial): CreateRoomRequest; + + static equals(a: CreateRoomRequest | PlainMessage | undefined, b: CreateRoomRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message pokerhero.RoomRequest + */ +export declare class RoomRequest extends Message { + /** + * @generated from field: int32 id = 1; + */ + id: number; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.RoomRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): RoomRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): RoomRequest; + + static fromJsonString(jsonString: string, options?: Partial): RoomRequest; + + static equals(a: RoomRequest | PlainMessage | undefined, b: RoomRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message pokerhero.RoomsRequest + */ +export declare class RoomsRequest extends Message { + /** + * @generated from field: string owner = 1; + */ + owner: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.RoomsRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): RoomsRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): RoomsRequest; + + static fromJsonString(jsonString: string, options?: Partial): RoomsRequest; + + static equals(a: RoomsRequest | PlainMessage | undefined, b: RoomsRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message pokerhero.RoomsResponse + */ +export declare class RoomsResponse extends Message { + /** + * @generated from field: repeated pokerhero.RoomResponse rooms = 1; + */ + rooms: RoomResponse[]; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.RoomsResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): RoomsResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): RoomsResponse; + + static fromJsonString(jsonString: string, options?: Partial): RoomsResponse; + + static equals(a: RoomsResponse | PlainMessage | undefined, b: RoomsResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message pokerhero.RoomResponse + */ +export declare class RoomResponse extends Message { + /** + * @generated from field: int32 id = 1; + */ + id: number; + + /** + * @generated from field: int32 min_buy_in = 2; + */ + minBuyIn: number; + + /** + * @generated from field: int32 big_blind = 3; + */ + bigBlind: number; + + /** + * @generated from field: repeated pokerhero.Player players = 4; + */ + players: Player[]; + + /** + * @generated from field: string address = 5; + */ + address: string; + + /** + * @generated from field: string owner = 6; + */ + owner: string; + + /** + * @generated from field: int32 max_players = 7; + */ + maxPlayers: number; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.RoomResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): RoomResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): RoomResponse; + + static fromJsonString(jsonString: string, options?: Partial): RoomResponse; + + static equals(a: RoomResponse | PlainMessage | undefined, b: RoomResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message pokerhero.BalanceChange + */ +export declare class BalanceChange extends Message { + /** + * @generated from field: string player_address = 1; + */ + playerAddress: string; + + /** + * @generated from field: int32 bet = 2; + */ + bet: number; + + /** + * @generated from field: int32 win = 3; + */ + win: number; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.BalanceChange"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): BalanceChange; + + static fromJson(jsonValue: JsonValue, options?: Partial): BalanceChange; + + static fromJsonString(jsonString: string, options?: Partial): BalanceChange; + + static equals(a: BalanceChange | PlainMessage | undefined, b: BalanceChange | PlainMessage | undefined): boolean; +} + +/** + * @generated from message pokerhero.UpdateRoomRequest + */ +export declare class UpdateRoomRequest extends Message { + /** + * @generated from field: int32 room_id = 1; + */ + roomId: number; + + /** + * @generated from field: repeated pokerhero.BalanceChange changes = 2; + */ + changes: BalanceChange[]; + + /** + * server auth + * + * @generated from field: string token = 3; + */ + token: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.UpdateRoomRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): UpdateRoomRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): UpdateRoomRequest; + + static fromJsonString(jsonString: string, options?: Partial): UpdateRoomRequest; + + static equals(a: UpdateRoomRequest | PlainMessage | undefined, b: UpdateRoomRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message pokerhero.LeaveRoomRequest + */ +export declare class LeaveRoomRequest extends Message { + /** + * @generated from field: int32 room_id = 1; + */ + roomId: number; + + /** + * @generated from field: string player_address = 2; + */ + playerAddress: string; + + /** + * server auth + * + * @generated from field: string token = 3; + */ + token: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.LeaveRoomRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): LeaveRoomRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): LeaveRoomRequest; + + static fromJsonString(jsonString: string, options?: Partial): LeaveRoomRequest; + + static equals(a: LeaveRoomRequest | PlainMessage | undefined, b: LeaveRoomRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message pokerhero.AllLeaveRoomRequest + */ +export declare class AllLeaveRoomRequest extends Message { + /** + * server auth + * + * @generated from field: string token = 1; + */ + token: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.AllLeaveRoomRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): AllLeaveRoomRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): AllLeaveRoomRequest; + + static fromJsonString(jsonString: string, options?: Partial): AllLeaveRoomRequest; + + static equals(a: AllLeaveRoomRequest | PlainMessage | undefined, b: AllLeaveRoomRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message pokerhero.EditRoomRequest + */ +export declare class EditRoomRequest extends Message { + /** + * @generated from field: int32 room_id = 1; + */ + roomId: number; + + /** + * @generated from field: int32 big_blind = 2; + */ + bigBlind: number; + + /** + * server auth + * + * @generated from field: string token = 3; + */ + token: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "pokerhero.EditRoomRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): EditRoomRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): EditRoomRequest; + + static fromJsonString(jsonString: string, options?: Partial): EditRoomRequest; + + static equals(a: EditRoomRequest | PlainMessage | undefined, b: EditRoomRequest | PlainMessage | undefined): boolean; +} + diff --git a/gen/poker_pb.js b/gen/poker_pb.js new file mode 100644 index 0000000..756e1b8 --- /dev/null +++ b/gen/poker_pb.js @@ -0,0 +1,177 @@ +// @generated by protoc-gen-es v1.3.1 +// @generated from file poker.proto (package pokerhero, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from message pokerhero.AdminTxRequest + */ +export const AdminTxRequest = proto3.makeMessageType( + "pokerhero.AdminTxRequest", + () => [ + { no: 1, name: "tx", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "retry", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 3, name: "token", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ], +); + +/** + * @generated from message pokerhero.AdminTxResponse + */ +export const AdminTxResponse = proto3.makeMessageType( + "pokerhero.AdminTxResponse", + () => [ + { no: 1, name: "id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ], +); + +/** + * @generated from message pokerhero.PingRequest + */ +export const PingRequest = proto3.makeMessageType( + "pokerhero.PingRequest", + () => [ + { no: 1, name: "message", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ], +); + +/** + * @generated from message pokerhero.PongResponse + */ +export const PongResponse = proto3.makeMessageType( + "pokerhero.PongResponse", + () => [ + { no: 1, name: "message", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ], +); + +/** + * @generated from message pokerhero.Player + */ +export const Player = proto3.makeMessageType( + "pokerhero.Player", + () => [ + { no: 1, name: "address", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "balance", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ], +); + +/** + * @generated from message pokerhero.CreateRoomRequest + */ +export const CreateRoomRequest = proto3.makeMessageType( + "pokerhero.CreateRoomRequest", + () => [ + { no: 1, name: "creator_address", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "big_blind", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 3, name: "max_players", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 4, name: "token", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ], +); + +/** + * @generated from message pokerhero.RoomRequest + */ +export const RoomRequest = proto3.makeMessageType( + "pokerhero.RoomRequest", + () => [ + { no: 1, name: "id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ], +); + +/** + * @generated from message pokerhero.RoomsRequest + */ +export const RoomsRequest = proto3.makeMessageType( + "pokerhero.RoomsRequest", + () => [ + { no: 1, name: "owner", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ], +); + +/** + * @generated from message pokerhero.RoomsResponse + */ +export const RoomsResponse = proto3.makeMessageType( + "pokerhero.RoomsResponse", + () => [ + { no: 1, name: "rooms", kind: "message", T: RoomResponse, repeated: true }, + ], +); + +/** + * @generated from message pokerhero.RoomResponse + */ +export const RoomResponse = proto3.makeMessageType( + "pokerhero.RoomResponse", + () => [ + { no: 1, name: "id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 2, name: "min_buy_in", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 3, name: "big_blind", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 4, name: "players", kind: "message", T: Player, repeated: true }, + { no: 5, name: "address", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 6, name: "owner", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 7, name: "max_players", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ], +); + +/** + * @generated from message pokerhero.BalanceChange + */ +export const BalanceChange = proto3.makeMessageType( + "pokerhero.BalanceChange", + () => [ + { no: 1, name: "player_address", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "bet", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 3, name: "win", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ], +); + +/** + * @generated from message pokerhero.UpdateRoomRequest + */ +export const UpdateRoomRequest = proto3.makeMessageType( + "pokerhero.UpdateRoomRequest", + () => [ + { no: 1, name: "room_id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 2, name: "changes", kind: "message", T: BalanceChange, repeated: true }, + { no: 3, name: "token", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ], +); + +/** + * @generated from message pokerhero.LeaveRoomRequest + */ +export const LeaveRoomRequest = proto3.makeMessageType( + "pokerhero.LeaveRoomRequest", + () => [ + { no: 1, name: "room_id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 2, name: "player_address", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "token", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ], +); + +/** + * @generated from message pokerhero.AllLeaveRoomRequest + */ +export const AllLeaveRoomRequest = proto3.makeMessageType( + "pokerhero.AllLeaveRoomRequest", + () => [ + { no: 1, name: "token", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ], +); + +/** + * @generated from message pokerhero.EditRoomRequest + */ +export const EditRoomRequest = proto3.makeMessageType( + "pokerhero.EditRoomRequest", + () => [ + { no: 1, name: "room_id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 2, name: "big_blind", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 3, name: "token", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ], +); + diff --git a/index.js b/index.js new file mode 100644 index 0000000..7babc1d --- /dev/null +++ b/index.js @@ -0,0 +1,5 @@ +export * from './gen/poker_pb.js'; +import createClient from './src/client.js'; + +export { createClient }; +export default createClient; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..ad3ef25 --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "pokerhero-grpc-client", + "version": "0.0.1", + "description": "JS client to communicate with PokerHero through GRPC", + "type": "module", + "main": "index.js", + "files": [ + "/index.js", + "/gen/", + "/src/" + ], + "dependencies": { + "@bufbuild/protobuf": "^1.3.1", + "@connectrpc/connect": "^1.0.0-rc1", + "@connectrpc/connect-web": "^1.0.0-rc1" + }, + "devDependencies": { + "@bufbuild/protoc-gen-es": "^1.3.1", + "@connectrpc/protoc-gen-connect-es": "^1.0.0-rc1", + "@protobuf-ts/protoc": "^2.9.1" + }, + "scripts": { + "protoc": "./protocgen.sh", + "prepublishOnly": "npm run test", + "test": "node example/index.js" + }, + "author": "shrpne ", + "license": "MIT" +} diff --git a/src/client.js b/src/client.js new file mode 100644 index 0000000..cf3e64f --- /dev/null +++ b/src/client.js @@ -0,0 +1,13 @@ +import { createPromiseClient } from "@connectrpc/connect"; +import { createGrpcWebTransport } from "@connectrpc/connect-web"; +import {Poker as PokerService} from '../gen/poker_connect.js'; + +/** + * @param {import('@connectrpc/connect-web').GrpcWebTransportOptions} transportOptions + * @return {import('@connectrpc/connect').PromiseClient} + */ +export default function createClient(transportOptions) { + const transport = createGrpcWebTransport(transportOptions); + + return createPromiseClient(PokerService, transport); +} \ No newline at end of file