cosmos-sdk icon indicating copy to clipboard operation
cosmos-sdk copied to clipboard

add back tx/encode endpoint

Open tac0turtle opened this issue 3 years ago • 15 comments

Summary

tx/encode endpoint was removed without a migration path given to many users. This has caused lots of trouble. It would be good to add an endpoint to grpc for tx/encode. This will help a lot with client interactions.

Proposal

Add tx/encode to grpc services.

cc @ValarDragon


For Admin Use

  • [x] Not duplicate issue
  • [x] Appropriate labels applied
  • [ ] Appropriate contributors tagged
  • [ ] Contributor assigned/self-assigned

tac0turtle avatar Jan 02 '22 17:01 tac0turtle

Please, this would be a great time saver for so many integrations

ValarDragon avatar Jan 03 '22 03:01 ValarDragon

@amaurym do you have any insight here?

alexanderbez avatar Jan 03 '22 14:01 alexanderbez

The old /tx/encode endpoint took as input a StdTx as JSON, and outputs new proto Tx's proto-binary bytes (as base64). Unfortunately we cannot do that anymore. The StdTx does not have a readable sequence, so we can't populate this field in the proto tx.

We could add a new endpoint for proto tx JSON -> proto tx Binary conversion, but then what's the point of doing that over network when 4 lines of code suffice to do it locally.

amaury1093 avatar Jan 03 '22 14:01 amaury1093

4 lines of code in go or js, python, etc as well?

for my use case I don't want to have any codecs on my client, I want to get the format of the message from grpc and be able to broadcast it. To do this currently my understanding is I need codecs of the proto messages.

tac0turtle avatar Jan 03 '22 14:01 tac0turtle

OK, sgtm, then adding an endpoint for proto tx JSON<->binary encodings sounds fine 👍 It should go in the tx service.

amaury1093 avatar Jan 03 '22 14:01 amaury1093

Are we sure there are no hidden traps? Can we safely encode every message with standard JSON (not a proto-json) without missing anything? Before we were using Amino....

robert-zaremba avatar Jan 03 '22 15:01 robert-zaremba

Also, if we confirm the above, do we need it in 0.45?

robert-zaremba avatar Jan 03 '22 15:01 robert-zaremba

Are we sure there are no hidden traps? Can we safely encode every message with standard JSON (not a proto-json) without missing anything? Before we were using Amino....

I believe the json received in grpc reflection is Proto-json? @fdymylja could you confirm?

Also, if we confirm the above, do we need it in 0.45?

I would love this for 0.45 but also its not breaking so we could backport it(?)

tac0turtle avatar Jan 03 '22 15:01 tac0turtle

Are we sure there are no hidden traps? Can we safely encode every message with standard JSON (not a proto-json) without missing anything? Before we were using Amino....

Yeah, as Marko said, that endpoint would handle proto json only. No std json, no amino json.

amaury1093 avatar Jan 03 '22 15:01 amaury1093

We could add a new endpoint for proto tx JSON -> proto tx Binary conversion, but then what's the point of doing that over network when 4 lines of code suffice to do it locally.

@amaurym do you have a js/ts example of doing this locally? I maintain https://github.com/shapeshift/hdwallet a library for broad Hardware wallet support (trezor/ledger/keepkey) and i'm unable to broadcast our signed payloads. (example) with the latest node version.

any advice for how to address this offline, in client, would be helpful, thanks.

BitHighlander avatar Jan 16 '22 19:01 BitHighlander

I don't unfortunately. it may be worth asking https://github.com/cosmos/cosmjs

amaury1093 avatar Jan 17 '22 13:01 amaury1093

any news about this?

roccomuso avatar Apr 11 '22 13:04 roccomuso

Sharing an example of how to convert from json to protobuff can be very helpful. Thank you!!

kevin486 avatar Jun 09 '22 11:06 kevin486

@amaurym what do you think about injecting an endpoint with grpcgatteway to handle all encoding?

tac0turtle avatar Sep 12 '22 07:09 tac0turtle

SGTM!

amaury1093 avatar Sep 12 '22 11:09 amaury1093