Add newtypes for ids in ibc-union-spec
#3410
Labels
A-cosmwasm
Area: our CosmWasm stack
A-ibc-union
Area: ibc-union
A-lightclients
Area: Light Clients
A-voyager
Area: voyager (relayer)
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
E-medium
Call for participation: Medium difficulty. Experience needed to fix: Intermediate.
Currently these are just raw type aliases:
union/lib/ibc-union-spec/src/lib.rs
Lines 484 to 486 in 7bac27e
These should instead be proper newtypes wrapping a
NonZeroU32
(since 0 is specified as the "nonexistentent" sentinel value for all ids). Anywhere where an id may be missing should be wrapped in anOption
, similar to how it is done throughout the types used inibc-classic-spec
(example).One issue that we'll hit (and the main reason why this isn't done yet) is that the state types in
union-ibc
require the keys and values to implement certain cosmwasm-specific traits in order to be used in the storage maps/items:union/cosmwasm/union-ibc/core/src/state.rs
Lines 7 to 34 in 7bac27e
Rather than bringing in the cosmwasm traits into the
ibc-union-spec
crate (which we definitely don't want to do), we should instead keep the storage id key/values as raw u32s, and expose helpers that wrap in the relevant types. We already do this in some places:union/cosmwasm/union-ibc/core/src/contract.rs
Lines 1558 to 1560 in 7bac27e
so hopefully this change won't be too drastic or invasive.
NOTE: This issue is labelled with all of
A-cosmwasm
,A-lightclients
, andA-voyager
since these spec crates touch a large portion of our codebase. That being said, the changes themselves are quite simple, just also quite pervasive. A small price to pay for type safety and reusable code 😁The text was updated successfully, but these errors were encountered: