cosmos / cosmjs

The Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers.
https://cosmos.github.io/cosmjs/
Apache License 2.0
635 stars 328 forks source link

Base64 error for non-padded attributes in decodeTxData #1539

Closed mdyring closed 6 months ago

mdyring commented 6 months ago

I'm seeing the below error popping up (often) against Osmosis mainnet.

base64-js is expecting encoded data to always be "=" padded, but this now seems to break.

Error: Invalid string. Length must be a multiple of 4
    at getLens (.../node_modules/base64-js/index.js:26:11)
    at Object.toByteArray (.../node_modules/base64-js/index.js:55:14)
    at fromBase64 (.../node_modules/@cosmjs/encoding/build/base64.js:36:21)
    at decodeAttribute (.../node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:43:40)
    at Array.map (<anonymous>)
    at decodeAttributes (.../node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:48:53)
    at decodeEvent (.../node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:53:40)
    at Array.map (<anonymous>)
    at decodeEvents (.../node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:58:49)
    at decodeTxData (.../node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:66:31
webmaster128 commented 6 months ago

Osmosis requires a Tendermint 0.37 client since the upgrade. See https://github.com/osmosis-labs/osmojs/issues/71. The latest version of CosmJS should do the auto-detection correctly behind the scenes.

mdyring commented 6 months ago

Thank you @webmaster128 - changed Tendermint34Client to Tendermint37Client and it works like a charm.