cosmos-sdk: CosmJS cannot parse Tx results in v0.46: Invalid string. Length must be a multiple of 4

Summary of Bug

The response of any Tx cannot be parsed by CosmJS in v0.46.0-beta2. This worked fine in v0.45.x and below. Not sure if this is a bug or due to a breaking change.

After signing and broadcasting the following Tx using CosmJS:

const result = await signingClient.sendTokens(
        alice,
        bob,
        [{ denom: "stake", amount: "100000" }],
        {
            amount: [{ denom: "stake", amount: "500" }],
            gas: "200000",
        },
    )

The result throws an error after the Tx has successfully executed:

/Users/noam/Code/cosmjs-sandbox/node_modules/base64-js/index.js:26
    throw new Error('Invalid string. Length must be a multiple of 4')
          ^
Error: Invalid string. Length must be a multiple of 4
    at getLens (/Users/noam/Code/cosmjs-sandbox/node_modules/base64-js/index.js:26:11)
    at Object.toByteArray (/Users/noam/Code/cosmjs-sandbox/node_modules/base64-js/index.js:55:14)
    at fromBase64 (/Users/noam/Code/cosmjs-sandbox/node_modules/@cosmjs/encoding/src/base64.ts:11:19)
    at decodeAttribute (/Users/noam/Code/cosmjs-sandbox/node_modules/@cosmjs/tendermint-rpc/src/tendermint34/adaptor/responses.ts:103:20)
    at Array.map (<anonymous>)
    at decodeAttributes (/Users/noam/Code/cosmjs-sandbox/node_modules/@cosmjs/tendermint-rpc/src/tendermint34/adaptor/responses.ts:109:34)
    at decodeEvent (/Users/noam/Code/cosmjs-sandbox/node_modules/@cosmjs/tendermint-rpc/src/tendermint34/adaptor/responses.ts:120:17)
    at Array.map (<anonymous>)
    at decodeEvents (/Users/noam/Code/cosmjs-sandbox/node_modules/@cosmjs/tendermint-rpc/src/tendermint34/adaptor/responses.ts:125:30)
    at decodeTxData (/Users/noam/Code/cosmjs-sandbox/node_modules/@cosmjs/tendermint-rpc/src/tendermint34/adaptor/responses.ts:145:27)

Version

v0.46.0-beta2

Steps to Reproduce

Get a response from any Tx using CosmJS. You can clone this repo and `npm run experiment-local to try it out for yourself.


For Admin Use

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

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

It fails because it uses a tendermint 0.34 client and the sdk uses a tendermint 0.35 since 0.46. Tendermint’s changelog shows a few breaking changes.

The relevant one here is the change in the EventAttribute type in tendermint.

https://github.com/tendermint/tendermint/pull/6408 https://github.com/cosmos/cosmjs/blob/main/packages/tendermint-rpc/src/tendermint34/adaptor/responses.ts#L101

When cosmjs has upgraded its implementation, we can see if it still happens.

@webmaster128

Hey @julienrbrt, so far I am not aware of any Tendermint change. We have a working TM 0.34 client and a private unused TM 0.35 client. Could you open a ticket in CosmJS, please?