cli icon indicating copy to clipboard operation
cli copied to clipboard

no server response when using ts-client

Open mme opened this issue 3 years ago • 2 comments

Describe the bug

When using ts-client, the server response is not present when sending a message.

To reproduce Steps to reproduce the behavior:

  1. For example, follow the blog tutorial and run ignite scaffold message createPost title body
  2. Modify tx.proto, adding a value to the response
message MsgCreatePostResponse {
  uint64 id = 1;
}
  1. Return something from CreatePost, e.g.
func (k msgServer) CreatePost(goCtx context.Context, msg *types.MsgCreatePost) (*types.MsgCreatePostResponse, error) {
	ctx := sdk.UnwrapSDKContext(goCtx)
	_ = ctx
	return &types.MsgCreatePostResponse{Id: 1}, nil
}
  1. Use the generated code from ts-client to make a call
const client = txClient({
      signer: this.wallet,
      prefix: "cosmos",
      addr: this.rpcEndpoint,
});

let res = await client.sendMsgCreatePost({
      value: { title: "A", body: "B", creator: this.account.address },
});

console.log(res);
  1. The response looks like this (I was expecting it to include the response from the server, i.e. the data from MsgCreatePostResponse):
{
 code: 0,
 height: 133,
 rawLog: '[{"msg_index":0,"events":[{"type":"message","attributes":[{"key":"action","value":"/evote.evote.MsgCreatePost"}]}]}]',
 transactionHash: 'BED69D59E5769C5756BAF3A678D38890B0F1DB948EE74898C2695A1ED49BBDD4',
 gasUsed: 53456,
 gasWanted: 200000
}

What version are you using?

Ignite CLI version:	v0.24.0
Ignite CLI build date:	2022-09-12T14:14:32Z
Ignite CLI source hash:	21c6430cfcc17c69885524990c448d4a3f56461c
Your OS:		linux
Your arch:		arm64
Your go version:	go version go1.19.1 linux/arm64
Your uname -a:		Linux 7349bff6f88b 5.10.124-linuxkit #1 SMP PREEMPT Thu Jun 30 08:18:26 UTC 2022 aarch64 GNU/Linux
Your cwd:		/app
Is on Gitpod:		false

mme avatar Sep 30 '22 14:09 mme

@mme The ts client relies on cosmjs to broadcast txs and unfortunately while building the response, the tx data is not propagated to the object in cosmjs.

That said, there's a pending PR about that https://github.com/cosmos/cosmjs/pull/1241, the best for now is probably to wait for its merge.

tbruyelle avatar Oct 03 '22 11:10 tbruyelle

@tbruyelle thanks, I'll wait

mme avatar Oct 03 '22 12:10 mme

@tbruyelle thanks, I'll wait

Your other option is to simply query the chain using the txhash once it's returned and you will receive the full tx response object

clockworkgr avatar Oct 27 '22 16:10 clockworkgr

Closing due to stale nature, please reopen if otherwise.

salmad3 avatar Feb 02 '24 17:02 salmad3