Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getAccount() method fails on the latest version of cosmos-sdk #312

Closed
Thunnini opened this issue Jul 23, 2020 · 7 comments · Fixed by #314
Closed

getAccount() method fails on the latest version of cosmos-sdk #312

Thunnini opened this issue Jul 23, 2020 · 7 comments · Fixed by #314
Milestone

Comments

@Thunnini
Copy link

https://github.com/CosmWasm/cosmjs/blob/master/packages/sdk38/src/cosmosclient.ts#L222

In the current implementation, getAccount() method expects that the public key is delivered as bech32. I'm not sure which version of the cosmos-sdk the changes were made, but accounts on the newer versions of the SDK return as follows:

{"height":"2724145","result":{"type":"cosmos-sdk/Account","value":{"address":"cosmos1ntck6f6534u630q87jpamettes6shwgddag769","coins":[{"denom":"uatom","amount":"489300"}],"public_key":{"type":"tendermint/PubKeySecp256k1","value":"Aqb4yDyanddEzrLjbTzhBsowmh6uC6InWAMRmCISoYt5"},"account_number":"58220","sequence":"6"}}}

Thus, bech32 decoding will fail and getAccount() method doesn't work.
And, because the above public key type is the same as https://github.com/CosmWasm/cosmjs/blob/master/packages/sdk38/src/types.ts#L39, it is not needed to parse them.

@ethanfrey
Copy link
Contributor

Good call. I think this changed from 0.38 to launchpad as well. We are working on #306 and hopefully address this there

@Thunnini
Copy link
Author

It seems like there isn't a problem on the later versions of the Cosmos-SDK(0.38, 0.39) but because the Cosmos Hub is running 0.37, there was an issue.

The current code is the right implementation for 0.38, so I am not sure how we should handle the 0.37 version.

@ethanfrey
Copy link
Contributor

Ah, your point was that this code does not work on 0.37? Or in 0.39?

Also, I know there were some changes exactly in pubkey encoding between 0.38 and 0.39... so maybe the 0.39 and 0.37 are the same. We are dropping 0.38 support in any case.

Maybe you can try this PR: #311 which should work for a 0.39 based chain. (still a bit wip, but bank/auth queries/messages work).

@ethanfrey
Copy link
Contributor

Nevermind, trying out the code I see this on our launchpad branch.

cosmos/cosmos-sdk#6749 is the root cause.
We will update launchpad support to include this likely on Monday

@ethanfrey
Copy link
Contributor

So, 0.39 and 0.37 have the same encoding, and 0.38 was just some broken version (with bech32 addresses > 90 chars)

@webmaster128
Copy link
Member

We can have a unified client that is more flexible with the format (to support 0.37-0.39). We just need to know what we need and where we get a test blockchain from.

@webmaster128
Copy link
Member

In #314 you see a solution to support 0.37-0.39 with one client. I think this make everyone's life easier and only took 2 hours (fixing a bug in Uint64 along the way).

@webmaster128 webmaster128 added this to the 0.22.0 milestone Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants