Skip to content

Commit f7c121b

Browse files
author
nashqueue
committed
ignite cli scaffold message submit-guess
1 parent 83b5b52 commit f7c121b

File tree

16 files changed

+759
-9
lines changed

16 files changed

+759
-9
lines changed

docs/static/openapi.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51927,6 +51927,8 @@ definitions:
5192751927
title: >-
5192851928
SignatureCounts contains information about signature reporting for a
5192951929
number of blocks
51930+
yazzyyaz.wordle.wordle.MsgSubmitGuessResponse:
51931+
type: object
5193051932
yazzyyaz.wordle.wordle.MsgSubmitWordleResponse:
5193151933
type: object
5193251934
yazzyyaz.wordle.wordle.Params:

proto/wordle/tx.proto

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ option go_package = "github.com/YazzyYaz/wordle/x/wordle/types";
88
// Msg defines the Msg service.
99
service Msg {
1010
rpc SubmitWordle(MsgSubmitWordle) returns (MsgSubmitWordleResponse);
11+
rpc SubmitGuess(MsgSubmitGuess) returns (MsgSubmitGuessResponse);
1112
// this line is used by starport scaffolding # proto/tx/rpc
1213
}
1314

@@ -19,4 +20,12 @@ message MsgSubmitWordle {
1920
message MsgSubmitWordleResponse {
2021
}
2122

23+
message MsgSubmitGuess {
24+
string creator = 1;
25+
string word = 2;
26+
}
27+
28+
message MsgSubmitGuessResponse {
29+
}
30+
2231
// this line is used by starport scaffolding # proto/tx/message

vue/src/store/generated/YazzyYaz/wordle/yazzyyaz.wordle.wordle/index.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,21 @@ export default {
150150
}
151151
}
152152
},
153+
async sendMsgSubmitGuess({ rootGetters }, { value, fee = [], memo = '' }) {
154+
try {
155+
const txClient=await initTxClient(rootGetters)
156+
const msg = await txClient.msgSubmitGuess(value)
157+
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
158+
gas: "200000" }, memo})
159+
return result
160+
} catch (e) {
161+
if (e == MissingWalletError) {
162+
throw new Error('TxClient:MsgSubmitGuess:Init Could not initialize signing client. Wallet is required.')
163+
}else{
164+
throw new Error('TxClient:MsgSubmitGuess:Send Could not broadcast Tx: '+ e.message)
165+
}
166+
}
167+
},
153168

154169
async MsgSubmitWordle({ rootGetters }, { value }) {
155170
try {
@@ -164,6 +179,19 @@ export default {
164179
}
165180
}
166181
},
182+
async MsgSubmitGuess({ rootGetters }, { value }) {
183+
try {
184+
const txClient=await initTxClient(rootGetters)
185+
const msg = await txClient.msgSubmitGuess(value)
186+
return msg
187+
} catch (e) {
188+
if (e == MissingWalletError) {
189+
throw new Error('TxClient:MsgSubmitGuess:Init Could not initialize signing client. Wallet is required.')
190+
} else{
191+
throw new Error('TxClient:MsgSubmitGuess:Create Could not create message: ' + e.message)
192+
}
193+
}
194+
},
167195

168196
}
169197
}

vue/src/store/generated/YazzyYaz/wordle/yazzyyaz.wordle.wordle/module/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import { SigningStargateClient } from "@cosmjs/stargate";
55
import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
66
import { Api } from "./rest";
77
import { MsgSubmitWordle } from "./types/wordle/tx";
8+
import { MsgSubmitGuess } from "./types/wordle/tx";
89

910

1011
const types = [
1112
["/yazzyyaz.wordle.wordle.MsgSubmitWordle", MsgSubmitWordle],
13+
["/yazzyyaz.wordle.wordle.MsgSubmitGuess", MsgSubmitGuess],
1214

1315
];
1416
export const MissingWalletError = new Error("wallet is required");
@@ -42,6 +44,7 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions =
4244
return {
4345
signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo),
4446
msgSubmitWordle: (data: MsgSubmitWordle): EncodeObject => ({ typeUrl: "/yazzyyaz.wordle.wordle.MsgSubmitWordle", value: MsgSubmitWordle.fromPartial( data ) }),
47+
msgSubmitGuess: (data: MsgSubmitGuess): EncodeObject => ({ typeUrl: "/yazzyyaz.wordle.wordle.MsgSubmitGuess", value: MsgSubmitGuess.fromPartial( data ) }),
4548

4649
};
4750
};

vue/src/store/generated/YazzyYaz/wordle/yazzyyaz.wordle.wordle/module/rest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export interface RpcStatus {
2020
details?: ProtobufAny[];
2121
}
2222

23+
export type WordleMsgSubmitGuessResponse = object;
24+
2325
export type WordleMsgSubmitWordleResponse = object;
2426

2527
/**

vue/src/store/generated/YazzyYaz/wordle/yazzyyaz.wordle.wordle/module/types/wordle/tx.ts

Lines changed: 131 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ export interface MsgSubmitWordle {
1010

1111
export interface MsgSubmitWordleResponse {}
1212

13+
export interface MsgSubmitGuess {
14+
creator: string;
15+
word: string;
16+
}
17+
18+
export interface MsgSubmitGuessResponse {}
19+
1320
const baseMsgSubmitWordle: object = { creator: "", word: "" };
1421

1522
export const MsgSubmitWordle = {
@@ -128,10 +135,121 @@ export const MsgSubmitWordleResponse = {
128135
},
129136
};
130137

138+
const baseMsgSubmitGuess: object = { creator: "", word: "" };
139+
140+
export const MsgSubmitGuess = {
141+
encode(message: MsgSubmitGuess, writer: Writer = Writer.create()): Writer {
142+
if (message.creator !== "") {
143+
writer.uint32(10).string(message.creator);
144+
}
145+
if (message.word !== "") {
146+
writer.uint32(18).string(message.word);
147+
}
148+
return writer;
149+
},
150+
151+
decode(input: Reader | Uint8Array, length?: number): MsgSubmitGuess {
152+
const reader = input instanceof Uint8Array ? new Reader(input) : input;
153+
let end = length === undefined ? reader.len : reader.pos + length;
154+
const message = { ...baseMsgSubmitGuess } as MsgSubmitGuess;
155+
while (reader.pos < end) {
156+
const tag = reader.uint32();
157+
switch (tag >>> 3) {
158+
case 1:
159+
message.creator = reader.string();
160+
break;
161+
case 2:
162+
message.word = reader.string();
163+
break;
164+
default:
165+
reader.skipType(tag & 7);
166+
break;
167+
}
168+
}
169+
return message;
170+
},
171+
172+
fromJSON(object: any): MsgSubmitGuess {
173+
const message = { ...baseMsgSubmitGuess } as MsgSubmitGuess;
174+
if (object.creator !== undefined && object.creator !== null) {
175+
message.creator = String(object.creator);
176+
} else {
177+
message.creator = "";
178+
}
179+
if (object.word !== undefined && object.word !== null) {
180+
message.word = String(object.word);
181+
} else {
182+
message.word = "";
183+
}
184+
return message;
185+
},
186+
187+
toJSON(message: MsgSubmitGuess): unknown {
188+
const obj: any = {};
189+
message.creator !== undefined && (obj.creator = message.creator);
190+
message.word !== undefined && (obj.word = message.word);
191+
return obj;
192+
},
193+
194+
fromPartial(object: DeepPartial<MsgSubmitGuess>): MsgSubmitGuess {
195+
const message = { ...baseMsgSubmitGuess } as MsgSubmitGuess;
196+
if (object.creator !== undefined && object.creator !== null) {
197+
message.creator = object.creator;
198+
} else {
199+
message.creator = "";
200+
}
201+
if (object.word !== undefined && object.word !== null) {
202+
message.word = object.word;
203+
} else {
204+
message.word = "";
205+
}
206+
return message;
207+
},
208+
};
209+
210+
const baseMsgSubmitGuessResponse: object = {};
211+
212+
export const MsgSubmitGuessResponse = {
213+
encode(_: MsgSubmitGuessResponse, writer: Writer = Writer.create()): Writer {
214+
return writer;
215+
},
216+
217+
decode(input: Reader | Uint8Array, length?: number): MsgSubmitGuessResponse {
218+
const reader = input instanceof Uint8Array ? new Reader(input) : input;
219+
let end = length === undefined ? reader.len : reader.pos + length;
220+
const message = { ...baseMsgSubmitGuessResponse } as MsgSubmitGuessResponse;
221+
while (reader.pos < end) {
222+
const tag = reader.uint32();
223+
switch (tag >>> 3) {
224+
default:
225+
reader.skipType(tag & 7);
226+
break;
227+
}
228+
}
229+
return message;
230+
},
231+
232+
fromJSON(_: any): MsgSubmitGuessResponse {
233+
const message = { ...baseMsgSubmitGuessResponse } as MsgSubmitGuessResponse;
234+
return message;
235+
},
236+
237+
toJSON(_: MsgSubmitGuessResponse): unknown {
238+
const obj: any = {};
239+
return obj;
240+
},
241+
242+
fromPartial(_: DeepPartial<MsgSubmitGuessResponse>): MsgSubmitGuessResponse {
243+
const message = { ...baseMsgSubmitGuessResponse } as MsgSubmitGuessResponse;
244+
return message;
245+
},
246+
};
247+
131248
/** Msg defines the Msg service. */
132249
export interface Msg {
133-
/** this line is used by starport scaffolding # proto/tx/rpc */
134250
SubmitWordle(request: MsgSubmitWordle): Promise<MsgSubmitWordleResponse>;
251+
/** this line is used by starport scaffolding # proto/tx/rpc */
252+
SubmitGuess(request: MsgSubmitGuess): Promise<MsgSubmitGuessResponse>;
135253
}
136254

137255
export class MsgClientImpl implements Msg {
@@ -150,6 +268,18 @@ export class MsgClientImpl implements Msg {
150268
MsgSubmitWordleResponse.decode(new Reader(data))
151269
);
152270
}
271+
272+
SubmitGuess(request: MsgSubmitGuess): Promise<MsgSubmitGuessResponse> {
273+
const data = MsgSubmitGuess.encode(request).finish();
274+
const promise = this.rpc.request(
275+
"yazzyyaz.wordle.wordle.Msg",
276+
"SubmitGuess",
277+
data
278+
);
279+
return promise.then((data) =>
280+
MsgSubmitGuessResponse.decode(new Reader(data))
281+
);
282+
}
153283
}
154284

155285
interface Rpc {

x/wordle/client/cli/tx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func GetTxCmd() *cobra.Command {
3131
}
3232

3333
cmd.AddCommand(CmdSubmitWordle())
34+
cmd.AddCommand(CmdSubmitGuess())
3435
// this line is used by starport scaffolding # 1
3536

3637
return cmd
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package cli
2+
3+
import (
4+
"strconv"
5+
6+
"github.com/YazzyYaz/wordle/x/wordle/types"
7+
"github.com/cosmos/cosmos-sdk/client"
8+
"github.com/cosmos/cosmos-sdk/client/flags"
9+
"github.com/cosmos/cosmos-sdk/client/tx"
10+
"github.com/spf13/cobra"
11+
)
12+
13+
var _ = strconv.Itoa(0)
14+
15+
func CmdSubmitGuess() *cobra.Command {
16+
cmd := &cobra.Command{
17+
Use: "submit-guess [word]",
18+
Short: "Broadcast message submit-guess",
19+
Args: cobra.ExactArgs(1),
20+
RunE: func(cmd *cobra.Command, args []string) (err error) {
21+
argWord := args[0]
22+
23+
clientCtx, err := client.GetClientTxContext(cmd)
24+
if err != nil {
25+
return err
26+
}
27+
28+
msg := types.NewMsgSubmitGuess(
29+
clientCtx.GetFromAddress().String(),
30+
argWord,
31+
)
32+
if err := msg.ValidateBasic(); err != nil {
33+
return err
34+
}
35+
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
36+
},
37+
}
38+
39+
flags.AddTxFlagsToCmd(cmd)
40+
41+
return cmd
42+
}

x/wordle/handler.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
2020
case *types.MsgSubmitWordle:
2121
res, err := msgServer.SubmitWordle(sdk.WrapSDKContext(ctx), msg)
2222
return sdk.WrapServiceResult(ctx, res, err)
23+
case *types.MsgSubmitGuess:
24+
res, err := msgServer.SubmitGuess(sdk.WrapSDKContext(ctx), msg)
25+
return sdk.WrapServiceResult(ctx, res, err)
2326
// this line is used by starport scaffolding # 1
2427
default:
2528
errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package keeper
2+
3+
import (
4+
"context"
5+
6+
"github.com/YazzyYaz/wordle/x/wordle/types"
7+
sdk "github.com/cosmos/cosmos-sdk/types"
8+
)
9+
10+
func (k msgServer) SubmitGuess(goCtx context.Context, msg *types.MsgSubmitGuess) (*types.MsgSubmitGuessResponse, error) {
11+
ctx := sdk.UnwrapSDKContext(goCtx)
12+
13+
// TODO: Handling the message
14+
_ = ctx
15+
16+
return &types.MsgSubmitGuessResponse{}, nil
17+
}

0 commit comments

Comments
 (0)