cosmology-tech / telescope

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

Amino encoder incorrectly including `omitempty` boolean when false #522

Closed NoahSaso closed 10 months ago

NoahSaso commented 11 months ago

The /cosmwasm.wasm.v1.MsgInstantiateContract2 type has a FixMsg boolean that has omitempty in its go struct definition. Somewhat unintuitively, this means that whenever it is false, it should be ommitted, and whenever it is true, it should be set.

This is correctly represented by the protobuf encoder here:

Screenshot 2023-11-14 at 09 18 31

but is incorrectly represented in the Amino encoder:

Screenshot 2023-11-14 at 09 18 57

To fix this, I believe these changes should be made to toAmino and fromAmino respectively:

Screenshot 2023-11-14 at 09 19 22 Screenshot 2023-11-14 at 09 19 27
Zetazzz commented 10 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