You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the blog network tutorial created with Ignite v28, I successfully made a post from the frontend.
The steps are outlined below, but would it be acceptable to add the MessageFns generated by buf to the generateType of the @cosmjs/proto-signing module?
importtype{GeneratedType}from"@cosmjs/proto-signing";import{MsgUpdatePost,MsgCreatePost,MsgDeletePost,}from"./proto/blog/blog/tx";//NOTE: Since GeneratedType has been edited, please review @cosmjs/proto-signing/build/registry.d.ts.constmsgTypes=[]asArray<[string,GeneratedType]>;msgTypes.push(["/blog.blog.MsgUpdatePost",MsgUpdatePost],["/blog.blog.MsgCreatePost",MsgCreatePost],["/blog.blog.MsgDeletePost",MsgDeletePost],);export{msgTypes};
frontend/main.ts
import{SigningStargateClient}from"@cosmjs/stargate";import{DirectSecp256k1HdWallet,Registry}from"@cosmjs/proto-signing";importtype{StdFee}from"@cosmjs/stargate";importtype{EncodeObject}from"@cosmjs/proto-signing";import{MsgCreatePost}from"$lib/proto/blog/blog/tx";import{msgTypes}from"$lib/registry";constrpcUrl="http://0.0.0.0:26657";constaliceMnemonic="mnemonic phrase";constdefaultFee: StdFee={amount: [],gas: "200000",};constmemo="test memo";constregistry=newRegistry(msgTypes);typemsgCreatePostParams={value: MsgCreatePost;};asyncfunctionsemdCreatePostTx(){constaliceWallet=awaitDirectSecp256k1HdWallet.fromMnemonic(aliceMnemonic);const{ address }=(awaitaliceWallet.getAccounts())[0];constvalue: MsgCreatePost={title: "test title",body: "test body",creator: address,};constclient=awaitSigningStargateClient.connectWithSigner(rpcUrl,aliceWallet,{ registry },);letmsg=msgCreatePost({value: MsgCreatePost.fromPartial(value)});returnawaitclient.signAndBroadcast(address,[msg],defaultFee,memo);}functionmsgCreatePost({ value }: msgCreatePostParams): EncodeObject{try{return{typeUrl: "/blog.blog.MsgCreatePost",value: MsgCreatePost.fromPartial(value),};}catch(e: any){thrownewError("TxClient:MsgCreatePost: Could not create message: "+e.message,);}}
Notes
The above code has been refactored for the purpose of this issue.
Since the frontend is created with Svelte, if the repository prior to refactoring is needed, I will attach it separately.
The text was updated successfully, but these errors were encountered:
Issue: Add
MessageFns
togenerateType
In the blog network tutorial created with Ignite v28, I successfully made a
post
from the frontend.The steps are outlined below, but would it be acceptable to add the
MessageFns
generated bybuf
to thegenerateType
of the@cosmjs/proto-signing
module?Environment
Steps Taken
Blog Tutorial
buf generate
withbuf.gen.ts.yaml
.proto/blog/blog.tx.ts
into the frontend.frontend/registry.ts
.MessageFns
to theGeneratedType
definition inproto-signing/build/registry.d.ts
.msgType
to theRegistry
infrontend/registry.ts
.node_modules/@cosmjs/proto-signing/build/registry.d.ts
frontend/registry.ts
frontend/main.ts
Notes
The above code has been refactored for the purpose of this issue.
Since the frontend is created with Svelte, if the repository prior to refactoring is needed, I will attach it separately.
The text was updated successfully, but these errors were encountered: