lib/unionlabs/README.md
unionlabsThis crate contains types and traits used throughout our stack.
Due to how prost generates protobuf bindings, working with the raw generated code is quite unergonomic and error-prone. This library provides a unified interface for all encodings (protobuf, ethabi, etc), allowing for both more type safety and ease of use for downstream users.
The general pattern is as follows, using Channel as an example:
protos::ibc::core::channel::v1::Channelcontracts::ibc_handler::IbcCoreChannelV1ChannelDataunionlabs::ibc::core::channel::ChannelNote that the unionlabs type doesn't include the version - we currently only support the latest version of each module.
Hash and UIntThe most commonly used crate for hash and uint types is parity's primitive-types, which is quite old and has quite a lot of issues (hidden panics, strange Display impl, parsing inconsistencies, etc). There are alternatives, such as ruint, which is used in alloy, but for simplicity we currently define our own hash and uint types (note that our uint is just a wrapper around primitive-types::U256 that provides sane string parsing and Display defaults). We will likely migrate to ruint in the future, once we migrate to alloy from ethers.
This library exposes generic Encoding and Decoding traits, to allow for abstracting over the encoding used for a type (essentially a poor man's HKTs). See the Voyager source code for examples of how this can be used.