cosmology-tech / telescope

A TypeScript Transpiler for Cosmos Protobufs ⚛️
https://cosmology.zone/products/telescope
Apache License 2.0
145 stars 43 forks source link

Byte arrays should be Amino encoded with base64 #521

Closed NoahSaso closed 9 months ago

NoahSaso commented 10 months ago

/cosmwasm.wasm.v1.MsgInstantiateContract2 is one of the few messages that uses a []byte type. The salt field is a byte array, which becomes Uint8Array in JavaScript. Amino encodes byte arrays as base64 strings, but the generated type is just passing the Uint8Array through, which causes signature validation errors.

To fix this, I found the utility function base64FromBytes, which I use in toAmino, and bytesFromBase64, which I use in fromAmino. This seems to work perfectly.

Zetazzz commented 9 months ago

Fixed by this PR: https://github.com/cosmology-tech/telescope/pull/537

Test results: https://github.com/cosmology-tech/telescope/blob/25d5b5de85633ec00432c66e03977fe9a0f008f5/__fixtures__/misc/output/misc/eval_request.ts#L1936C5-L1936C5