Skip to content

Serialization of VaultPositionType #343

@larry0x

Description

@larry0x

NOTE: This is a state- and API-breaking change!

The VaultPositionType is defined as

#[cw_serde]
pub enum VaultPositionType {
    UNLOCKED,
    LOCKED,
    UNLOCKING,
}

However, all caps names don't work well with JSON serialization. For example, VaultPositionType::UNLOCKED is serialized to JSON string "u_n_l_o_c_k_e_d". Imo, this is undesirable.

To fix this, we can either no longer naming the variants in all caps:

#[cw_serde]
pub enum VaultPositionType {
    Unlocked,
    Locked,
    Unlocking,
}

or use #[serde(rename)]:

#[cw_serde]
pub enum VaultPositionType {
    #[serde(rename = "unlocked")]
    UNLOCKED,
    #[serde(rename = "locked")]
    LOCKED,
    #[serde(rename = "unlocking")]
    UNLOCKING,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions