Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization of VaultPositionType #343

Open
larry0x opened this issue Oct 12, 2023 · 0 comments
Open

Serialization of VaultPositionType #343

larry0x opened this issue Oct 12, 2023 · 0 comments

Comments

@larry0x
Copy link
Contributor

larry0x commented Oct 12, 2023

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,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant