Skip to content

CosmJS cannot parse Tx results in v0.46: Invalid string. Length must be a multiple of 4 #11997

Closed

Description

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Type

No type

Projects

  • Status

    No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions